Commit b2a76062 authored by jean-pierre charras's avatar jean-pierre charras

All: use CPOLYGONS_LIST, a typedef of std::vector<CPolyPt> to handle a Corners Polygons List.

This is a starting point of some code enhancements relative to polygons in Pcbew and 3D viewer.
parent ea990230
......@@ -30,15 +30,8 @@
#ifndef _3D_CANVAS_H_
#define _3D_CANVAS_H_
#include <wxBasePcbFrame.h> // for m_auimanager member.
#include <layers_id_colors_and_visibility.h> // Layers id definitions
#include <PolyLine.h> // for CPolyPt
#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif
#include <wx/glcanvas.h>
#include <wxBasePcbFrame.h> // for m_auimanager member.
#ifdef __WXMAC__
# ifdef __DARWIN__
......@@ -53,10 +46,6 @@
#include <3d_struct.h>
class BOARD_DESIGN_SETTINGS;
class TRACK;
class TEXTE_PCB;
class DRAWSEGMENT;
class ZONE_CONTAINER;
class EDA_3D_FRAME;
class S3D_VERTEX;
class SEGVIA;
......
This diff is collapsed.
......@@ -41,7 +41,7 @@
* The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList,
void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
int aZpos, int aThickness, double aBiuTo3DUnits );
/** draw the solid polygon found in aPolysList
......@@ -55,7 +55,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysLi
* The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
void Draw3D_SolidHorizontalPolygonWithHoles( const std::vector<CPolyPt>& aPolysList,
void Draw3D_SolidHorizontalPolygonWithHoles( const CPOLYGONS_LIST& aPolysList,
int aZpos, int aThickness, double aBiuTo3DUnits );
/** draw a thick segment using 3D primitives, in a XY plane
......
......@@ -31,8 +31,6 @@
#define __3D_VIEWER_H__
#include <wxBasePcbFrame.h> // for m_auimanager member.
#include <layers_id_colors_and_visibility.h> // Layers id definitions
#include <PolyLine.h> // fot CPolyPt
#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
......
......@@ -36,13 +36,13 @@
* We are using a lots polygons in calculations.
* and we are using 2 descriptions,
* one easy to use with boost::polygon (KI_POLYGON_SET)
* one easy to use in zones and in draw functions (std::vector<CPolyPt>)
* one easy to use in zones and in draw functions (CPOLYGONS_LIST)
* Copy polygons from a KI_POLYGON_SET set of polygons to
* a std::vector<CPolyPt> polygon list
* a CPOLYGONS_LIST polygon list
* Therefore we need conversion functions between these 2 descriptions
*/
void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList,
std::vector<CPolyPt>& aPolysList )
CPOLYGONS_LIST& aPolysList )
{
for( unsigned ii = 0; ii < aKiPolyList.size(); ii++ )
{
......@@ -64,14 +64,15 @@ void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList,
}
}
/**
* Helper function AddPolygonCornersToKiPolygonList
* This function adds a KI_POLYGON_SET description to a
* std::vector<CPolyPt> description
* CPOLYGONS_LIST description
* @param aCornersBuffer = source (set of polygons using CPolyPt corners descr)
* @param aPolysList = destination (set of polygons)
*/
void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
void AddPolygonCornersToKiPolygonList( CPOLYGONS_LIST& aCornersBuffer,
KI_POLYGON_SET& aKiPolyList )
{
std::vector<KI_POLY_POINT> cornerslist;
......@@ -79,6 +80,7 @@ void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
// Count the number of polygons in aCornersBuffer
int polycount = 0;
for( unsigned ii = 0; ii < corners_count; ii++ )
{
if( aCornersBuffer[ii].end_contour )
......@@ -93,6 +95,7 @@ void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
cornerslist.clear();
unsigned ii;
for( ii = icnt; ii < aCornersBuffer.size(); ii++ )
{
cornerslist.push_back( KI_POLY_POINT( aCornersBuffer[ii].x, aCornersBuffer[ii].y ) );
......@@ -118,7 +121,7 @@ void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
* Note: the polygon is inside the circle, so if you want to have the polygon
* outside the circle, you should give aRadius calculated with a corrrection factor
*/
void TransformCircleToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformCircleToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCenter, int aRadius,
int aCircleToSegmentsCount )
{
......@@ -153,7 +156,7 @@ void TransformCircleToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* Note: the polygon is inside the arc ends, so if you want to have the polygon
* outside the circle, you should give aStart and aEnd calculated with a correction factor
*/
void TransformRoundedEndsSegmentToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformRoundedEndsSegmentToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aStart, wxPoint aEnd,
int aCircleToSegmentsCount,
int aWidth )
......@@ -233,7 +236,7 @@ void TransformRoundedEndsSegmentToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aWidth = width (thickness) of the line
*/
void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformArcToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCentre, wxPoint aStart, int aArcAngle,
int aCircleToSegmentsCount, int aWidth )
{
......@@ -272,6 +275,7 @@ void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer,
aCircleToSegmentsCount, aWidth );
}
/**
* Function TransformRingToPolygon
* Creates a polygon from a ring
......@@ -282,7 +286,7 @@ void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aWidth = width (thickness) of the ring
*/
void TransformRingToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformRingToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCentre, int aRadius,
int aCircleToSegmentsCount, int aWidth )
{
......
......@@ -40,26 +40,26 @@
* We are using a lots polygons in calculations.
* and we are using 2 descriptions,
* one easy to use with boost::polygon (KI_POLYGON_SET)
* one easy to use in zones and in draw functions (std::vector<CPolyPt>)
* one easy to use in zones and in draw functions (CPOLYGONS_LIST)
* Copy polygons from a KI_POLYGON_SET set of polygons to
* a std::vector<CPolyPt> polygon list
* a CPOLYGONS_LIST corner polygon list
* Therefore we need conversion functions between these 2 descriptions
* This function converts a KI_POLYGON_SET description to a
* std::vector<CPolyPt> description
* CPOLYGONS_LIST description
* @param aKiPolyList = source (set of polygons)
* @param aPolysList = destination (set of polygons using CPolyPt corners descr)
*/
void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList,
std::vector<CPolyPt>& aPolysList );
CPOLYGONS_LIST& aPolysList );
/**
* Helper function AddPolygonCornersToKiPolygonList
* This function adds a KI_POLYGON_SET description to a
* std::vector<CPolyPt> description
* CPOLYGONS_LIST description
* @param aCornersBuffer = source (set of polygons using CPolyPt corners descr)
* @param aPolysList = destination (set of polygons)
*/
void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
void AddPolygonCornersToKiPolygonList( CPOLYGONS_LIST& aCornersBuffer,
KI_POLYGON_SET& aKiPolyList );
/**
......@@ -72,7 +72,7 @@ void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
* Note: the polygon is inside the circle, so if you want to have the polygon
* outside the circle, you should give aRadius calculated with a correction factor
*/
void TransformCircleToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformCircleToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCenter, int aRadius,
int aCircleToSegmentsCount );
......@@ -88,7 +88,7 @@ void TransformCircleToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* Note: the polygon is inside the arc ends, so if you want to have the polygon
* outside the circle, you should give aStart and aEnd calculated with a correction factor
*/
void TransformRoundedEndsSegmentToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformRoundedEndsSegmentToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aStart, wxPoint aEnd,
int aCircleToSegmentsCount,
int aWidth );
......@@ -105,7 +105,7 @@ void TransformRoundedEndsSegmentToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aWidth = width (thickness) of the line
*/
void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformArcToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCentre, wxPoint aStart, int aArcAngle,
int aCircleToSegmentsCount, int aWidth );
......@@ -119,7 +119,7 @@ void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aWidth = width (thickness) of the ring
*/
void TransformRingToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformRingToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCentre, int aRadius,
int aCircleToSegmentsCount, int aWidth );
......
......@@ -35,7 +35,7 @@
* initial radius * aCorrectionFactor
*/
void MODULE::TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer,
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue,
int aCircleToSegmentsCount,
double aCorrectionFactor )
......@@ -86,7 +86,7 @@ void MODULE::TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer,
*/
void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
LAYER_NUM aLayer,
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue,
int aCircleToSegmentsCount,
double aCorrectionFactor )
......@@ -166,12 +166,12 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
* keep arc radius when approximated by segments
*/
void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet(
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aCircleToSegmentsCount,
double aCorrectionFactor )
{
unsigned cornerscount = GetFilledPolysList().size();
std::vector <CPolyPt> polygonslist;
CPOLYGONS_LIST polygonslist;
if( cornerscount == 0 )
return;
......@@ -217,7 +217,7 @@ void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet(
* @param aClearanceValue = the clearance around the pad
*/
void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue ) const
{
if( GetText().Length() == 0 )
......@@ -251,7 +251,7 @@ void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(
* Convert the text shape to a set of polygons (one by segment)
* Used in filling zones calculations and 3D view
* Circles and arcs are approximated by segments
* aCornerBuffer = vector <CPolyPt> to store the polygon corners
* aCornerBuffer = CPOLYGONS_LIST to store the polygon corners
* aClearanceValue = the clearance around the text
* aCircleToSegmentsCount = the number of segments to approximate a circle
* aCorrectionFactor = the correction to apply to circles radius to keep
......@@ -263,7 +263,7 @@ void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(
// so we cannot send them as arguments.
int s_textWidth;
int s_textCircle2SegmentCount;
std::vector <CPolyPt>* s_cornerBuffer;
CPOLYGONS_LIST* s_cornerBuffer;
// This is a call back function, used by DrawGraphicText to draw the 3D text shape:
static void addTextSegmToPoly( int x0, int y0, int xf, int yf )
......@@ -274,7 +274,7 @@ static void addTextSegmToPoly( int x0, int y0, int xf, int yf )
}
void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const
......@@ -334,7 +334,7 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(
* clearance when the circle is approxiamted by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const
......@@ -375,7 +375,7 @@ void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& a
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void TRACK:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCornerBuffer,
void TRACK:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const
......@@ -404,14 +404,14 @@ void TRACK:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor
* Convert the pad shape to a closed polygon
* Used in filling zones calculations and 3D view generation
* Circles and arcs are approximated by segments
* aCornerBuffer = a vector < CPolyPt> to store the polygon corners
* aCornerBuffer = a CPOLYGONS_LIST to store the polygon corners
* aClearanceValue = the clearance around the pad
* aCircleToSegmentsCount = the number of segments to approximate a circle
* aCorrectionFactor = the correction to apply to circles radius to keep
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCornerBuffer,
void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const
......@@ -547,7 +547,7 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor
* Note: for Round and oval pads this function is equivalent to
* TransformShapeWithClearanceToPolygon, but not for other shapes
*/
void D_PAD::BuildPadShapePolygon( std::vector <CPolyPt>& aCornerBuffer,
void D_PAD::BuildPadShapePolygon( CPOLYGONS_LIST& aCornerBuffer,
wxSize aInflateValue, int aSegmentsPerCircle,
double aCorrectionFactor ) const
{
......@@ -584,7 +584,7 @@ void D_PAD::BuildPadShapePolygon( std::vector <CPolyPt>& aCornerBuffer,
* depending on shape pad hole and orientation
* return false if the pad has no hole, true otherwise
*/
bool D_PAD::BuildPadDrillShapePolygon( std::vector <CPolyPt>& aCornerBuffer,
bool D_PAD::BuildPadDrillShapePolygon( CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue, int aSegmentsPerCircle ) const
{
wxSize drillsize = GetDrillSize();
......@@ -658,7 +658,7 @@ bool D_PAD::BuildPadDrillShapePolygon( std::vector <CPolyPt>& aCornerBuffer,
* and are used in microwave applications and they *DO NOT* have a thermal relief that
* change the shape by creating stubs and destroy their properties.
*/
void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
D_PAD& aPad,
int aThermalGap,
int aCopperThickness,
......
......@@ -211,7 +211,7 @@ public:
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const;
......
......@@ -37,6 +37,7 @@
#include <class_board_item.h>
#include <class_text_mod.h>
#include <PolyLine.h>
#include "zones.h"
class LINE_READER;
......@@ -46,7 +47,6 @@ class EDA_DRAW_PANEL;
class D_PAD;
class BOARD;
class MSG_PANEL_ITEM;
class CPolyPt;
/**
......@@ -268,7 +268,7 @@ public:
* initial radius * aCorrectionFactor
*/
void TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer,
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue,
int aCircleToSegmentsCount,
double aCorrectionFactor );
......@@ -292,7 +292,7 @@ public:
*/
void TransformGraphicShapesWithClearanceToPolygonSet(
LAYER_NUM aLayer,
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue,
int aCircleToSegmentsCount,
double aCorrectionFactor );
......
......@@ -220,7 +220,7 @@ public:
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const;;
......@@ -317,7 +317,7 @@ public:
* @param aCorrectionFactor = the correction to apply to circles radius to keep
* the pad size when the circle is approximated by segments
*/
void BuildPadShapePolygon( std::vector <CPolyPt>& aCornerBuffer,
void BuildPadShapePolygon( CPOLYGONS_LIST& aCornerBuffer,
wxSize aInflateValue, int aSegmentsPerCircle,
double aCorrectionFactor ) const;
......@@ -332,7 +332,7 @@ public:
* (used for round and oblong shapes only(16 to 32 is a good value)
* @return false if the pad has no hole, true otherwise
*/
bool BuildPadDrillShapePolygon( std::vector <CPolyPt>& aCornerBuffer,
bool BuildPadDrillShapePolygon( CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue, int aSegmentsPerCircle ) const;
/**
......
......@@ -93,7 +93,7 @@ public:
* to the real clearance value (usually near from 1.0)
*/
void TransformBoundingBoxWithClearanceToPolygon(
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue ) const;
/**
......@@ -108,7 +108,7 @@ public:
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void TransformShapeWithClearanceToPolygonSet( std::vector <CPolyPt>& aCornerBuffer,
void TransformShapeWithClearanceToPolygonSet( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const;
......
......@@ -175,7 +175,7 @@ public:
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const;
......
......@@ -274,7 +274,7 @@ public:
* @param aCorrectionFactor = the correction to apply to arcs radius to roughly
* keep arc radius when approximated by segments
*/
void TransformSolidAreasShapesToPolygonSet( std::vector <CPolyPt>& aCornerBuffer,
void TransformSolidAreasShapesToPolygonSet( CPOLYGONS_LIST& aCornerBuffer,
int aCircleToSegmentsCount,
double aCorrectionFactor );
/**
......@@ -296,7 +296,7 @@ public:
* This function calls AddClearanceAreasPolygonsToPolysList()
* to add holes for pads and tracks and other items not in net.
*/
bool BuildFilledSolidAreasPolygons( BOARD* aPcb, std::vector <CPolyPt>* aCornerBuffer = NULL );
bool BuildFilledSolidAreasPolygons( BOARD* aPcb, CPOLYGONS_LIST* aCornerBuffer = NULL );
/**
* Function CopyPolygonsFromKiPolygonListToFilledPolysList
......@@ -339,7 +339,7 @@ public:
* @param aAddClearance = true to add a clearance area to the polygon
* false to create the outline polygon.
*/
void TransformOutlinesShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformOutlinesShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
bool aAddClearance );
/**
......@@ -506,7 +506,7 @@ public:
* returns a reference to the list of filled polygons.
* @return Reference to the list of filled polygons.
*/
const std::vector<CPolyPt>& GetFilledPolysList() const
const CPOLYGONS_LIST& GetFilledPolysList() const
{
return m_FilledPolysList;
}
......@@ -515,7 +515,7 @@ public:
* Function AddFilledPolysList
* sets the list of filled polygons.
*/
void AddFilledPolysList( std::vector<CPolyPt>& aPolysList )
void AddFilledPolysList( CPOLYGONS_LIST& aPolysList )
{
m_FilledPolysList = aPolysList;
}
......@@ -549,7 +549,7 @@ public:
void AddPolygon( std::vector< wxPoint >& aPolygon );
void AddFilledPolygon( std::vector< CPolyPt >& aPolygon )
void AddFilledPolygon( CPOLYGONS_LIST& aPolygon )
{
m_FilledPolysList.insert( m_FilledPolysList.end(), aPolygon.begin(), aPolygon.end() );
}
......@@ -652,7 +652,7 @@ private:
* connecting "holes" with external main outline. In complex cases an outline
* described by m_Poly can have many filled areas
*/
std::vector <CPolyPt> m_FilledPolysList;
CPOLYGONS_LIST m_FilledPolysList;
};
......
......@@ -1395,7 +1395,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
m_out->Print( 0, ")\n" );
const std::vector< CPolyPt >& cv = aZone->Outline()->m_CornersList;
const CPOLYGONS_LIST& cv = aZone->Outline()->m_CornersList;
int newLine = 0;
if( cv.size() )
......@@ -1403,7 +1403,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
m_out->Print( aNestLevel+1, "(polygon\n");
m_out->Print( aNestLevel+2, "(pts\n" );
for( std::vector< CPolyPt >::const_iterator it = cv.begin(); it != cv.end(); ++it )
for( CPOLYGONS_LIST::const_iterator it = cv.begin(); it != cv.end(); ++it )
{
if( newLine == 0 )
m_out->Print( aNestLevel+3, "(xy %s %s)",
......@@ -1443,7 +1443,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
}
// Save the PolysList
const std::vector< CPolyPt >& fv = aZone->GetFilledPolysList();
const CPOLYGONS_LIST& fv = aZone->GetFilledPolysList();
newLine = 0;
if( fv.size() )
......@@ -1451,7 +1451,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
m_out->Print( aNestLevel+1, "(filled_polygon\n" );
m_out->Print( aNestLevel+2, "(pts\n" );
for( std::vector< CPolyPt >::const_iterator it = fv.begin(); it != fv.end(); ++it )
for( CPOLYGONS_LIST::const_iterator it = fv.begin(); it != fv.end(); ++it )
{
if( newLine == 0 )
m_out->Print( aNestLevel+3, "(xy %s %s)",
......
......@@ -2346,7 +2346,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
else if( TESTLINE( "$POLYSCORNERS" ) )
{
// Read the PolysList (polygons used for fill areas in the zone)
std::vector<CPolyPt> polysList;
CPOLYGONS_LIST polysList;
while( ( line = READLINE( m_reader ) ) != NULL )
{
......@@ -3690,12 +3690,10 @@ void LEGACY_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const
me->GetCornerSmoothingType(),
fmtBIU( me->GetCornerRadius() ).c_str() );
typedef std::vector< CPolyPt > CPOLY_PTS;
// Save the corner list
const CPOLY_PTS& cv = me->Outline()->m_CornersList;
const CPOLYGONS_LIST& cv = me->Outline()->m_CornersList;
for( CPOLY_PTS::const_iterator it = cv.begin(); it != cv.end(); ++it )
for( CPOLYGONS_LIST::const_iterator it = cv.begin(); it != cv.end(); ++it )
{
fprintf( m_fp, "ZCorner %s %d\n",
fmtBIUPair( it->x, it->y ).c_str(),
......@@ -3703,12 +3701,12 @@ void LEGACY_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const
}
// Save the PolysList
const CPOLY_PTS& fv = me->GetFilledPolysList();
const CPOLYGONS_LIST& fv = me->GetFilledPolysList();
if( fv.size() )
{
fprintf( m_fp, "$POLYSCORNERS\n" );
for( CPOLY_PTS::const_iterator it = fv.begin(); it != fv.end(); ++it )
for( CPOLYGONS_LIST::const_iterator it = fv.begin(); it != fv.end(); ++it )
{
fprintf( m_fp, "%s %d %d\n",
fmtBIUPair( it->x, it->y ).c_str(),
......
......@@ -2371,7 +2371,7 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR )
T token;
// bigger scope since each filled_polygon is concatenated in here
std::vector< CPolyPt > pts;
CPOLYGONS_LIST pts;
auto_ptr< ZONE_CONTAINER > zone( new ZONE_CONTAINER( m_board ) );
......
......@@ -53,7 +53,7 @@
#include <pcbplot.h>
// Imported function
extern void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
extern void AddPolygonCornersToKiPolygonList( CPOLYGONS_LIST& aCornersBuffer,
KI_POLYGON_SET& aKiPolyList );
// Local
/* Plot a solder mask layer.
......@@ -506,8 +506,8 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter,
// This extra margin is used to merge too close shapes
// (distance < aMinThickness), and will be removed when creating
// the actual shapes
std::vector <CPolyPt> bufferPolys; // Contains shapes to plot
std::vector <CPolyPt> initialPolys; // Contains exact shapes to plot
CPOLYGONS_LIST bufferPolys; // Contains shapes to plot
CPOLYGONS_LIST initialPolys; // Contains exact shapes to plot
/* calculates the coeff to compensate radius reduction of holes clearance
* due to the segment approx ( 1 /cos( PI/circleToSegmentsCount )
......
......@@ -506,7 +506,7 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte )
*/
void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE_CONTAINER* aZone )
{
std::vector<CPolyPt> polysList = aZone->GetFilledPolysList();
const CPOLYGONS_LIST& polysList = aZone->GetFilledPolysList();
unsigned imax = polysList.size();
if( imax == 0 ) // Nothing to draw
......@@ -526,10 +526,10 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE_CONTAINER* aZone )
*/
for( unsigned ic = 0; ic < imax; ic++ )
{
CPolyPt* corner = &polysList[ic];
cornerList.push_back( wxPoint( corner->x, corner->y) );
const CPolyPt& corner = polysList[ic];
cornerList.push_back( wxPoint( corner.x, corner.y) );
if( corner->end_contour ) // Plot the current filled area outline
if( corner.end_contour ) // Plot the current filled area outline
{
// First, close the outline
if( cornerList[0] != cornerList[cornerList.size() - 1] )
......
......@@ -55,7 +55,7 @@
*/
bool ZONE_CONTAINER::BuildFilledSolidAreasPolygons( BOARD* aPcb,
std::vector <CPolyPt>* aCornerBuffer )
CPOLYGONS_LIST* aCornerBuffer )
{
if( aCornerBuffer == NULL )
m_FilledPolysList.clear();
......
......@@ -64,7 +64,7 @@
#include <convert_basic_shapes_to_polygon.h>
extern void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCornerBuffer,
extern void BuildUnconnectedThermalStubsPolygonList( CPOLYGONS_LIST& aCornerBuffer,
BOARD* aPcb, ZONE_CONTAINER* aZone,
double aArcCorrection,
int aRoundPadThermalRotation);
......@@ -72,7 +72,7 @@ extern void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCorn
extern void Test_For_Copper_Island_And_Remove( BOARD* aPcb,
ZONE_CONTAINER* aZone_container );
extern void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
extern void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
D_PAD& aPad,
int aThermalGap,
int aCopperThickness,
......@@ -187,7 +187,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
int item_clearance;
// static to avoid unnecessary memory allocation when filling many zones.
static std::vector <CPolyPt> cornerBufferPolysToSubstract;
static CPOLYGONS_LIST cornerBufferPolysToSubstract;
cornerBufferPolysToSubstract.clear();
/* Use a dummy pad to calculate hole clerance when a pad is not on all copper layers
......
......@@ -48,11 +48,11 @@
* false to create the outline polygon.
*/
void ZONE_CONTAINER::TransformOutlinesShapeWithClearanceToPolygon(
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue, bool aAddClearance )
{
// Creates the zone outlines polygon (with linked holes if any)
std::vector <CPolyPt> zoneOutines;
CPOLYGONS_LIST zoneOutines;
BuildFilledSolidAreasPolygons( NULL, &zoneOutines );
// add clearance to outline
......@@ -119,14 +119,14 @@ void ZONE_CONTAINER::TransformOutlinesShapeWithClearanceToPolygon(
* Function BuildUnconnectedThermalStubsPolygonList
* Creates a set of polygons corresponding to stubs created by thermal shapes on pads
* which are not connected to a zone (dangling bridges)
* @param aCornerBuffer = a std::vector<CPolyPt> where to store polygons
* @param aCornerBuffer = a CPOLYGONS_LIST where to store polygons
* @param aPcb = the board.
* @param aZone = a pointer to the ZONE_CONTAINER to examine.
* @param aArcCorrection = a pointer to the ZONE_CONTAINER to examine.
* @param aRoundPadThermalRotation = the rotation in 1.0 degree for thermal stubs in round pads
*/
void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCornerBuffer,
void BuildUnconnectedThermalStubsPolygonList( CPOLYGONS_LIST& aCornerBuffer,
BOARD* aPcb,
ZONE_CONTAINER* aZone,
double aArcCorrection,
......
......@@ -143,7 +143,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
// test if a candidate is inside a filled area of this zone
unsigned indexstart = 0, indexend;
std::vector<CPolyPt> polysList = curr_zone->GetFilledPolysList();
const CPOLYGONS_LIST& polysList = curr_zone->GetFilledPolysList();
for( indexend = 0; indexend < polysList.size(); indexend++ )
{
// end of a filled sub-area found
......
......@@ -1204,7 +1204,7 @@ int CPolyLine::Distance( const wxPoint& aPoint )
* @param aPolysList = the list of corners of contours
* @param aPolygoneWithHole = a KI_POLYGON_WITH_HOLES to populate
*/
void CopyPolysListToKiPolygonWithHole( const std::vector<CPolyPt>& aPolysList,
void CopyPolysListToKiPolygonWithHole( const CPOLYGONS_LIST& aPolysList,
KI_POLYGON_WITH_HOLES& aPolygoneWithHole )
{
unsigned corners_count = aPolysList.size();
......@@ -1261,8 +1261,8 @@ void CopyPolysListToKiPolygonWithHole( const std::vector<CPolyPt>& aPolysList,
* @param aPolysListWithHoles = the list of corners of contours (haing holes
* @param aOnePolyList = a polygon with no holes
*/
void ConvertPolysListWithHolesToOnePolygon( const std::vector<CPolyPt>& aPolysListWithHoles,
std::vector<CPolyPt>& aOnePolyList )
void ConvertPolysListWithHolesToOnePolygon( const CPOLYGONS_LIST& aPolysListWithHoles,
CPOLYGONS_LIST& aOnePolyList )
{
unsigned corners_count = aPolysListWithHoles.size();
......@@ -1338,9 +1338,7 @@ void ConvertPolysListWithHolesToOnePolygon( const std::vector<CPolyPt>& aPolysL
aOnePolyList.push_back( corner );
}
corner.end_contour = true;
aOnePolyList.pop_back();
aOnePolyList.push_back( corner );
aOnePolyList.back().end_contour = true;
}
/**
......
......@@ -76,6 +76,14 @@ public:
{ return (x != cpt2.x) || (y != cpt2.y) || (end_contour != cpt2.end_contour); }
};
/**
* CPOLYGONS_LIST handle a list of contours.
* Each contour is a polygon, i.e. a list of corners.
* Each corner is a CPolyPt item.
* The last cornet of each contour has its end_contour member = true
*/
typedef std::vector<CPolyPt> CPOLYGONS_LIST;
class CPolyLine
{
......@@ -262,7 +270,7 @@ private:
int m_utility; // a flag used in some calculations
public:
std::vector <CPolyPt> m_CornersList; // array of points for corners
CPOLYGONS_LIST m_CornersList; // array of points for corners
std::vector <CSegment> m_HatchLines; // hatch lines showing the polygon area
};
......@@ -273,7 +281,7 @@ public:
* @param aPolysList = the list of corners of contours
* @param aPolygoneWithHole = a KI_POLYGON_WITH_HOLES to populate
*/
void CopyPolysListToKiPolygonWithHole( const std::vector<CPolyPt>& aPolysList,
void CopyPolysListToKiPolygonWithHole( const CPOLYGONS_LIST& aPolysList,
KI_POLYGON_WITH_HOLES& aPolygoneWithHole );
......@@ -286,7 +294,7 @@ void CopyPolysListToKiPolygonWithHole( const std::vector<CPolyPt>& aPolysList,
* @param aPolysListWithHoles = the list of corners of contours (haing holes
* @param aOnePolyList = a polygon with no holes
*/
void ConvertPolysListWithHolesToOnePolygon( const std::vector<CPolyPt>& aPolysListWithHoles,
std::vector<CPolyPt>& aOnePolyList );
void ConvertPolysListWithHolesToOnePolygon( const CPOLYGONS_LIST& aPolysListWithHoles,
CPOLYGONS_LIST& aOnePolyList );
#endif // #ifndef POLYLINE_H
......@@ -26,7 +26,7 @@
#define OUTSIDE false
#define INSIDE true
bool TestPointInsidePolygon( std::vector <CPolyPt> aPolysList,
bool TestPointInsidePolygon( CPOLYGONS_LIST aPolysList,
int aIdxstart,
int aIdxend,
int aRefx,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment