KiCad PCB EDA Suite
ctriangle2d.h File Reference
#include "cobject2d.h"
#include "../accelerators/ccontainer2d.h"
#include <geometry/shape_line_chain.h>
#include <geometry/shape_poly_set.h>
#include <clipper.hpp>

Go to the source code of this file.

Classes

class  CTRIANGLE2D
 

Functions

void Convert_shape_line_polygon_to_triangles (SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
 

Function Documentation

◆ 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 
)

Definition at line 129 of file ctriangle2d.cpp.

133 {
134 
135  aPolyList.CacheTriangulation( false );
136  const double conver_d = (double)aBiuTo3DunitsScale;
137 
138  for( unsigned int j = 0; j < aPolyList.TriangulatedPolyCount(); j++ )
139  {
140  auto triPoly = aPolyList.TriangulatedPolygon( j );
141 
142  for( size_t i = 0; i < triPoly->GetTriangleCount(); i++ )
143  {
144  VECTOR2I a;
145  VECTOR2I b;
146  VECTOR2I c;
147  triPoly->GetTriangle( i, a, b, c );
148 
149  aDstContainer.Add( new CTRIANGLE2D( SFVEC2F( a.x * conver_d,
150  -a.y * conver_d ),
151  SFVEC2F( b.x * conver_d,
152  -b.y * conver_d ),
153  SFVEC2F( c.x * conver_d,
154  -c.y * conver_d ),
155  aBoardItem ) );
156  }
157 
158  }
159 }
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
unsigned int TriangulatedPolyCount() const
Returns the number of triangulated polygons
void CacheTriangulation(bool aPartition=true)
const TRIANGULATED_POLYGON * TriangulatedPolygon(int aIndex) const

References CGENERICCONTAINER2D::Add(), SHAPE_POLY_SET::CacheTriangulation(), SHAPE_POLY_SET::TriangulatedPolyCount(), SHAPE_POLY_SET::TriangulatedPolygon(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by BOARD_ADAPTER::AddShapeWithClearanceToContainer(), BOARD_ADAPTER::AddSolidAreasShapesToContainer(), C3D_RENDER_OGL_LEGACY::createBoard(), BOARD_ADAPTER::createNewPadWithClearance(), and C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads().