KiCad PCB EDA Suite
ctriangle2d.cpp File Reference
#include "ctriangle2d.h"
#include <map>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/shared_array.hpp>
#include <wx/debug.h>
#include <wx/glcanvas.h>
#include <geometry/polygon_triangulation.h>
#include "../../../3d_fastmath.h"

Go to the source code of this file.

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();
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
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(), BOARD_ADAPTER::createNewPadWithClearance(), C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), and C3D_RENDER_OGL_LEGACY::reload().