KiCad PCB EDA Suite
triangle_2d.cpp File Reference
#include "triangle_2d.h"
#include "../ray.h"
#include <wx/debug.h>
#include <geometry/polygon_triangulation.h>
#include "../../../3d_fastmath.h"

Go to the source code of this file.

Functions

void ConvertPolygonToTriangles (const SHAPE_POLY_SET &aPolyList, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, const BOARD_ITEM &aBoardItem)
 

Function Documentation

◆ ConvertPolygonToTriangles()

void ConvertPolygonToTriangles ( const SHAPE_POLY_SET aPolyList,
CONTAINER_2D_BASE aDstContainer,
float  aBiuTo3dUnitsScale,
const BOARD_ITEM aBoardItem 
)

Definition at line 121 of file triangle_2d.cpp.

123{
124 VECTOR2I a;
125 VECTOR2I b;
126 VECTOR2I c;
127
128 const_cast<SHAPE_POLY_SET&>( aPolyList ).CacheTriangulation( false );
129 const double conver_d = (double)aBiuTo3dUnitsScale;
130
131 for( unsigned int j = 0; j < aPolyList.TriangulatedPolyCount(); j++ )
132 {
133 const SHAPE_POLY_SET::TRIANGULATED_POLYGON* triPoly = aPolyList.TriangulatedPolygon( j );
134
135 for( size_t i = 0; i < triPoly->GetTriangleCount(); i++ )
136 {
137 triPoly->GetTriangle( i, a, b, c );
138
139 aDstContainer.Add( new TRIANGLE_2D( SFVEC2F( a.x * conver_d, -a.y * conver_d ),
140 SFVEC2F( b.x * conver_d, -b.y * conver_d ),
141 SFVEC2F( c.x * conver_d, -c.y * conver_d ),
142 aBoardItem ) );
143 }
144 }
145}
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
void GetTriangle(int index, VECTOR2I &a, VECTOR2I &b, VECTOR2I &c) const
Represent a set of closed polygons.
const TRIANGULATED_POLYGON * TriangulatedPolygon(int aIndex) const
unsigned int TriangulatedPolyCount() const
Return the number of outlines in the set.
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42

References CONTAINER_2D_BASE::Add(), SHAPE_POLY_SET::TRIANGULATED_POLYGON::GetTriangle(), SHAPE_POLY_SET::TRIANGULATED_POLYGON::GetTriangleCount(), SHAPE_POLY_SET::TriangulatedPolyCount(), SHAPE_POLY_SET::TriangulatedPolygon(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by BOARD_ADAPTER::addShape(), BOARD_ADAPTER::addSolidAreasShapes(), BOARD_ADAPTER::addText(), RENDER_3D_OPENGL::createBoard(), BOARD_ADAPTER::createPadWithMargin(), and RENDER_3D_OPENGL::generateViasAndPads().