本文整理汇总了C++中SHAPE_POLY_SET类的典型用法代码示例。如果您正苦于以下问题:C++ SHAPE_POLY_SET类的具体用法?C++ SHAPE_POLY_SET怎么用?C++ SHAPE_POLY_SET使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SHAPE_POLY_SET类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeRawFilledAreas
/* Build the filled solid areas data from real outlines (stored in m_Poly)
* The solid areas can be more than one on copper layers, and do not have holes
* ( holes are linked by overlapping segments to the main outline)
*/
bool ZONE_FILLER::fillSingleZone( const ZONE_CONTAINER* aZone, SHAPE_POLY_SET& aRawPolys,
SHAPE_POLY_SET& aFinalPolys ) const
{
SHAPE_POLY_SET smoothedPoly;
/* convert outlines + holes to outlines without holes (adding extra segments if necessary)
* m_Poly data is expected normalized, i.e. NormalizeAreaOutlines was used after building
* this zone
*/
if ( !aZone->BuildSmoothedPoly( smoothedPoly ) )
return false;
if( aZone->IsOnCopperLayer() )
{
computeRawFilledAreas( aZone, smoothedPoly, aRawPolys, aFinalPolys );
}
else
{
aRawPolys = smoothedPoly;
aFinalPolys = smoothedPoly;
aFinalPolys.Inflate( -aZone->GetMinThickness() / 2, 16 );
aFinalPolys.Fracture( SHAPE_POLY_SET::PM_FAST );
}
return true;
}
示例2: TransformRingToPolygon
/* Build a pad outline as non filled polygon, to draw pads on silkscreen layer
* Used only to draw pads outlines on silkscreen layers.
*/
void EDA_3D_CANVAS::buildPadShapeThickOutlineAsPolygon( const D_PAD* aPad,
SHAPE_POLY_SET& aCornerBuffer,
int aWidth,
int aCircleToSegmentsCount,
double aCorrectionFactor )
{
if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
{
TransformRingToPolygon( aCornerBuffer, aPad->ShapePos(),
aPad->GetSize().x / 2, aCircleToSegmentsCount, aWidth );
return;
}
// For other shapes, draw polygon outlines
SHAPE_POLY_SET corners;
aPad->BuildPadShapePolygon( corners, wxSize( 0, 0 ),
aCircleToSegmentsCount, aCorrectionFactor );
// Add outlines as thick segments in polygon buffer
const SHAPE_LINE_CHAIN& path = corners.COutline( 0 );
for( int ii = 0; ii < path.PointCount(); ii++ )
{
const VECTOR2I& a = path.CPoint( ii );
const VECTOR2I& b = path.CPoint( ii + 1 );
TransformRoundedEndsSegmentToPolygon( aCornerBuffer,
wxPoint( a.x, a.y ),
wxPoint( b.x, b.y ),
aCircleToSegmentsCount, aWidth );
}
}
示例3: ThickSegment
void DXF_PLOTTER::ThickSegment( const wxPoint& aStart, const wxPoint& aEnd, int aWidth,
EDA_DRAW_MODE_T aPlotMode, void* aData )
{
if( aPlotMode == SKETCH )
{
std::vector<wxPoint> cornerList;
SHAPE_POLY_SET outlineBuffer;
TransformOvalClearanceToPolygon( outlineBuffer,
aStart, aEnd, aWidth, 32 , 1.0 );
const SHAPE_LINE_CHAIN& path = outlineBuffer.COutline(0 );
for( int jj = 0; jj < path.PointCount(); jj++ )
cornerList.push_back( wxPoint( path.CPoint( jj ).x , path.CPoint( jj ).y ) );
// Ensure the polygon is closed
if( cornerList[0] != cornerList[cornerList.size() - 1] )
cornerList.push_back( cornerList[0] );
PlotPoly( cornerList, NO_FILL );
}
else
{
MoveTo( aStart );
FinishTo( aEnd );
}
}
示例4: Polygon_Calc_BBox_3DU
void Polygon_Calc_BBox_3DU( const SHAPE_POLY_SET &aPolysList,
CBBOX2D &aOutBBox ,
float aBiuTo3DunitsScale )
{
aOutBBox.Reset();
for( int idx = 0; idx < aPolysList.OutlineCount(); ++idx )
{
// Each polygon in aPolysList is a polygon with holes
const SHAPE_POLY_SET::POLYGON& curr_polywithholes = aPolysList.CPolygon( idx );
for( unsigned ipoly = 0; ipoly < curr_polywithholes.size(); ++ipoly )
{
const SHAPE_LINE_CHAIN& path = curr_polywithholes[ipoly]; // a simple polygon
for( int jj = 0; jj < path.PointCount(); jj++ )
{
const VECTOR2I& a = path.CPoint( jj );
aOutBBox.Union( SFVEC2F( (float) a.x * aBiuTo3DunitsScale,
(float)-a.y * aBiuTo3DunitsScale ) );
}
}
}
aOutBBox.ScaleNextUp();
}
示例5: Convert_shape_line_polygon_to_triangles
void Convert_shape_line_polygon_to_triangles( SHAPE_POLY_SET &aPolyList,
CGENERICCONTAINER2D &aDstContainer,
float aBiuTo3DunitsScale ,
const BOARD_ITEM &aBoardItem )
{
aPolyList.CacheTriangulation();
const double conver_d = (double)aBiuTo3DunitsScale;
for( unsigned int j = 0; j < aPolyList.TriangulatedPolyCount(); j++ )
{
auto triPoly = aPolyList.TriangulatedPolygon( j );
for( size_t i = 0; i < triPoly->GetTriangleCount(); i++ )
{
VECTOR2I a;
VECTOR2I b;
VECTOR2I c;
triPoly->GetTriangle( i, a, b, c );
aDstContainer.Add( new CTRIANGLE2D( SFVEC2F( a.x * conver_d,
-a.y * conver_d ),
SFVEC2F( b.x * conver_d,
-b.y * conver_d ),
SFVEC2F( c.x * conver_d,
-c.y * conver_d ),
aBoardItem ) );
}
}
}
示例6: FlashPadRoundRect
void HPGL_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
int aCornerRadius, double aOrient,
EDA_DRAW_MODE_T aTraceMode )
{
SHAPE_POLY_SET outline;
const int segmentToCircleCount = 32;
wxSize size = aSize;
if( aTraceMode == FILLED )
{
// in filled mode, the pen diameter is removed from size
// to keep the pad size
size.x -= KiROUND( penDiameter ) / 2;
size.x = std::max( size.x, 0);
size.y -= KiROUND( penDiameter ) / 2;
size.y = std::max( size.y, 0);
// keep aCornerRadius to a value < min size x,y < 2:
aCornerRadius = std::min( aCornerRadius, std::min( size.x, size.y ) /2 );
}
TransformRoundRectToPolygon( outline, aPadPos, size, aOrient,
aCornerRadius, segmentToCircleCount );
// TransformRoundRectToPolygon creates only one convex polygon
std::vector< wxPoint > cornerList;
cornerList.reserve( segmentToCircleCount + 4 );
SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
for( int ii = 0; ii < poly.PointCount(); ++ii )
cornerList.push_back( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
PlotPoly( cornerList, aTraceMode == FILLED ? FILLED_SHAPE : NO_FILL );
}
示例7: BuildPadShapePolygon
/*
* Function BuildPadShapePolygon
* Build the Corner list of the polygonal shape,
* depending on shape, extra size (clearance ...) pad and orientation
* Note: for Round and oval pads this function is equivalent to
* TransformShapeWithClearanceToPolygon, but not for other shapes
*/
void D_PAD::BuildPadShapePolygon( SHAPE_POLY_SET& aCornerBuffer,
wxSize aInflateValue, int aSegmentsPerCircle,
double aCorrectionFactor ) const
{
wxPoint corners[4];
wxPoint PadShapePos = ShapePos(); /* Note: for pad having a shape offset,
* the pad position is NOT the shape position */
switch( GetShape() )
{
case PAD_SHAPE_CIRCLE:
case PAD_SHAPE_OVAL:
TransformShapeWithClearanceToPolygon( aCornerBuffer, aInflateValue.x,
aSegmentsPerCircle, aCorrectionFactor );
break;
case PAD_SHAPE_TRAPEZOID:
case PAD_SHAPE_RECT:
aCornerBuffer.NewOutline();
BuildPadPolygon( corners, aInflateValue, m_Orient );
for( int ii = 0; ii < 4; ii++ )
{
corners[ii] += PadShapePos; // Shift origin to position
aCornerBuffer.Append( corners[ii].x, corners[ii].y );
}
break;
}
}
示例8: TransformBoundingBoxWithClearanceToPolygon
/**
* Function TransformBoundingBoxWithClearanceToPolygon
* Convert the text bounding box to a rectangular polygon
* Used in filling zones calculations
* Circles and arcs are approximated by segments
* @param aCornerBuffer = a buffer to store the polygon
* @param aClearanceValue = the clearance around the text bounding box
*/
void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(
SHAPE_POLY_SET& aCornerBuffer,
int aClearanceValue ) const
{
if( GetText().Length() == 0 )
return;
wxPoint corners[4]; // Buffer of polygon corners
EDA_RECT rect = GetTextBox( -1 );
rect.Inflate( aClearanceValue );
corners[0].x = rect.GetOrigin().x;
corners[0].y = rect.GetOrigin().y;
corners[1].y = corners[0].y;
corners[1].x = rect.GetRight();
corners[2].x = corners[1].x;
corners[2].y = rect.GetBottom();
corners[3].y = corners[2].y;
corners[3].x = corners[0].x;
aCornerBuffer.NewOutline();
for( int ii = 0; ii < 4; ii++ )
{
// Rotate polygon
RotatePoint( &corners[ii].x, &corners[ii].y, m_Pos.x, m_Pos.y, m_Orient );
aCornerBuffer.Append( corners[ii].x, corners[ii].y );
}
}
示例9: FlashPadCircle
void GERBER_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
SHAPE_POLY_SET* aPolygons,
EDA_DRAW_MODE_T aTraceMode, void* aData )
{
// A Pad custom is plotted as polygon.
// A flashed circle @aPadPos is added (anchor pad)
// However, because the anchor pad can be circle or rect, we use only
// a circle not bigger than the rect.
// the main purpose is to print a flashed DCode as pad anchor
if( aTraceMode == FILLED )
FlashPadCircle( aPadPos, std::min( aSize.x, aSize.y ), aTraceMode, aData );
GBR_METADATA gbr_metadata;
if( aData )
{
gbr_metadata = *static_cast<GBR_METADATA*>( aData );
// If the pad is drawn on a copper layer,
// set attribute to GBR_APERTURE_ATTRIB_CONDUCTOR
if( gbr_metadata.IsCopper() )
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR );
wxString attrname( ".P" );
gbr_metadata.m_NetlistMetadata.ClearAttribute( &attrname ); // not allowed on inner layers
}
SHAPE_POLY_SET polyshape = *aPolygons;
if( aTraceMode != FILLED )
{
SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH, &gbr_metadata );
polyshape.Inflate( -GetCurrentLineWidth()/2, 16 );
}
std::vector< wxPoint > cornerList;
for( int cnt = 0; cnt < polyshape.OutlineCount(); ++cnt )
{
SHAPE_LINE_CHAIN& poly = polyshape.Outline( cnt );
cornerList.clear();
for( int ii = 0; ii < poly.PointCount(); ++ii )
cornerList.push_back( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
// Close polygon
cornerList.push_back( cornerList[0] );
PlotPoly( cornerList,
aTraceMode == FILLED ? FILLED_SHAPE : NO_FILL,
aTraceMode == FILLED ? 0 : GetCurrentLineWidth(), &gbr_metadata );
}
}
示例10: attrname
void GERBER_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
int aCornerRadius, double aOrient,
EDA_DRAW_MODE_T aTraceMode, void* aData )
{
GBR_METADATA gbr_metadata;
if( aData )
{
gbr_metadata = *static_cast<GBR_METADATA*>( aData );
// If the pad is drawn on a copper layer,
// set attribute to GBR_APERTURE_ATTRIB_CONDUCTOR
if( gbr_metadata.IsCopper() )
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR );
wxString attrname( ".P" );
gbr_metadata.m_NetlistMetadata.ClearAttribute( &attrname ); // not allowed on inner layers
}
if( aTraceMode != FILLED )
SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH, &gbr_metadata );
// Currently, a Pad RoundRect is plotted as polygon.
// TODO: use Aperture macro and flash it
SHAPE_POLY_SET outline;
const int segmentToCircleCount = 64;
TransformRoundRectToPolygon( outline, aPadPos, aSize, aOrient,
aCornerRadius, segmentToCircleCount );
if( aTraceMode != FILLED )
outline.Inflate( -GetCurrentLineWidth()/2, 16 );
std::vector< wxPoint > cornerList;
// TransformRoundRectToPolygon creates only one convex polygon
SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
cornerList.reserve( poly.PointCount() + 1 );
for( int ii = 0; ii < poly.PointCount(); ++ii )
cornerList.push_back( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
// Close polygon
cornerList.push_back( cornerList[0] );
PlotPoly( cornerList, aTraceMode == FILLED ? FILLED_SHAPE : NO_FILL,
aTraceMode == FILLED ? 0 : GetCurrentLineWidth(), &gbr_metadata );
// Now, flash a pad anchor, if a netlist attribute is set
// (remove me when a Aperture macro will be used)
if( aData && aTraceMode == FILLED )
{
int diameter = std::min( aSize.x, aSize.y );
FlashPadCircle( aPadPos, diameter, aTraceMode , aData );
}
}
示例11: AddToMiddleContourns
void CLAYER_TRIANGLES::AddToMiddleContourns( const SHAPE_POLY_SET &aPolySet,
float zBot,
float zTop,
double aBiuTo3Du,
bool aInvertFaceDirection )
{
wxASSERT( aPolySet.OutlineCount() > 0 );
if( aPolySet.OutlineCount() == 0 )
return;
// Calculate an estimation of points to reserve
unsigned int nrContournPointsToReserve = 0;
for( int i = 0; i < aPolySet.OutlineCount(); ++i )
{
const SHAPE_LINE_CHAIN& pathOutline = aPolySet.COutline( i );
nrContournPointsToReserve += pathOutline.PointCount();
for( int h = 0; h < aPolySet.HoleCount( i ); ++h )
{
const SHAPE_LINE_CHAIN &hole = aPolySet.CHole( i, h );
nrContournPointsToReserve += hole.PointCount();
}
}
// Request to reserve more space
m_layer_middle_contourns_quads->Reserve_More( nrContournPointsToReserve * 2,
true );
#pragma omp parallel for
for( signed int i = 0; i < aPolySet.OutlineCount(); ++i )
{
// Add outline
const SHAPE_LINE_CHAIN& pathOutline = aPolySet.COutline( i );
AddToMiddleContourns( pathOutline, zBot, zTop, aBiuTo3Du, aInvertFaceDirection );
// Add holes for this outline
for( int h = 0; h < aPolySet.HoleCount( i ); ++h )
{
const SHAPE_LINE_CHAIN &hole = aPolySet.CHole( i, h );
AddToMiddleContourns( hole, zBot, zTop, aBiuTo3Du, aInvertFaceDirection );
}
}
}
示例12: ConvertPolySetToPolyList
const CPOLYGONS_LIST ConvertPolySetToPolyList(const SHAPE_POLY_SET& aPolyset)
{
CPOLYGONS_LIST list;
CPolyPt corner, firstCorner;
const SHAPE_POLY_SET::POLYGON& poly = aPolyset.CPolygon( 0 );
for( unsigned int jj = 0; jj < poly.size() ; jj++ )
{
const SHAPE_LINE_CHAIN& path = poly[jj];
for( int i = 0; i < path.PointCount(); i++ )
{
const VECTOR2I &v = path.CPoint( i );
corner.x = v.x;
corner.y = v.y;
corner.end_contour = false;
if( i == 0 )
firstCorner = corner;
list.AddCorner( corner );
}
firstCorner.end_contour = true;
list.AddCorner( firstCorner );
}
return list;
}
示例13: TransformSolidAreasShapesToPolygonSet
void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet(
SHAPE_POLY_SET& aCornerBuffer, int aError ) const
{
if( GetFilledPolysList().IsEmpty() )
return;
// add filled areas polygons
aCornerBuffer.Append( m_FilledPolysList );
auto board = GetBoard();
int maxError = ARC_HIGH_DEF;
if( board )
maxError = board->GetDesignSettings().m_MaxError;
// add filled areas outlines, which are drawn with thick lines
for( int i = 0; i < m_FilledPolysList.OutlineCount(); i++ )
{
const SHAPE_LINE_CHAIN& path = m_FilledPolysList.COutline( i );
for( int j = 0; j < path.PointCount(); j++ )
{
const VECTOR2I& a = path.CPoint( j );
const VECTOR2I& b = path.CPoint( j + 1 );
TransformRoundedEndsSegmentToPolygon( aCornerBuffer, wxPoint( a.x, a.y ),
wxPoint( b.x, b.y ), maxError, GetMinThickness() );
}
}
}
示例14: TransformSolidAreasShapesToPolygonSet
/* Function TransformSolidAreasShapesToPolygonSet
* Convert solid areas full shapes to polygon set
* (the full shape is the polygon area with a thick outline)
* Used in 3D view
* Arcs (ends of segments) are approximated by segments
* aCornerBuffer = a buffer to store the polygons
* aCircleToSegmentsCount = the number of segments to approximate a circle
* aCorrectionFactor = the correction to apply to arcs radius to roughly
* keep arc radius when approximated by segments
*/
void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet(
SHAPE_POLY_SET& aCornerBuffer,
int aCircleToSegmentsCount,
double aCorrectionFactor )
{
if( GetFilledPolysList().IsEmpty() )
return;
// add filled areas polygons
aCornerBuffer.Append( m_FilledPolysList );
// add filled areas outlines, which are drawn with thick lines
for( int i = 0; i < m_FilledPolysList.OutlineCount(); i++ )
{
const SHAPE_LINE_CHAIN& path = m_FilledPolysList.COutline( i );
for( int j = 0; j < path.PointCount(); j++ )
{
const VECTOR2I& a = path.CPoint( j );
const VECTOR2I& b = path.CPoint( j + 1 );
TransformRoundedEndsSegmentToPolygon( aCornerBuffer, wxPoint( a.x, a.y ), wxPoint( b.x, b.y ),
aCircleToSegmentsCount,
GetMinThickness() );
}
}
}
示例15: BuildPadShapePolygon
/*
* Function BuildPadShapePolygon
* Build the Corner list of the polygonal shape,
* depending on shape, extra size (clearance ...) pad and orientation
* Note: for Round and oval pads this function is equivalent to
* TransformShapeWithClearanceToPolygon, but not for other shapes
*/
void D_PAD::BuildPadShapePolygon(
SHAPE_POLY_SET& aCornerBuffer, wxSize aInflateValue, int aError ) const
{
wxPoint corners[4];
wxPoint padShapePos = ShapePos(); /* Note: for pad having a shape offset,
* the pad position is NOT the shape position */
switch( GetShape() )
{
case PAD_SHAPE_CIRCLE:
case PAD_SHAPE_OVAL:
case PAD_SHAPE_ROUNDRECT:
case PAD_SHAPE_CHAMFERED_RECT:
{
// We are using TransformShapeWithClearanceToPolygon to build the shape.
// Currently, this method uses only the same inflate value for X and Y dirs.
// so because here this is not the case, we use a inflated dummy pad to build
// the polygonal shape
// TODO: remove this dummy pad when TransformShapeWithClearanceToPolygon will use
// a wxSize to inflate the pad size
D_PAD dummy( *this );
dummy.SetSize( GetSize() + aInflateValue + aInflateValue );
dummy.TransformShapeWithClearanceToPolygon( aCornerBuffer, 0 );
}
break;
case PAD_SHAPE_TRAPEZOID:
case PAD_SHAPE_RECT:
aCornerBuffer.NewOutline();
BuildPadPolygon( corners, aInflateValue, m_Orient );
for( int ii = 0; ii < 4; ii++ )
{
corners[ii] += padShapePos; // Shift origin to position
aCornerBuffer.Append( corners[ii].x, corners[ii].y );
}
break;
case PAD_SHAPE_CUSTOM:
// for a custom shape, that is in fact a polygon (with holes), we can use only a inflate value.
// so use ( aInflateValue.x + aInflateValue.y ) / 2 as polygon inflate value.
// (different values for aInflateValue.x and aInflateValue.y has no sense for a custom pad)
TransformShapeWithClearanceToPolygon(
aCornerBuffer, ( aInflateValue.x + aInflateValue.y ) / 2 );
break;
}
}