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 (SHAPE_POLY_SET &aPolyList, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, const BOARD_ITEM &aBoardItem)
 

Function Documentation

◆ ConvertPolygonToTriangles()

void ConvertPolygonToTriangles ( 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  aPolyList.CacheTriangulation( false );
129  const double conver_d = (double)aBiuTo3dUnitsScale;
130 
131  for( unsigned int j = 0; j < aPolyList.TriangulatedPolyCount(); j++ )
132  {
133  auto 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 GetTriangle(int index, VECTOR2I &a, VECTOR2I &b, VECTOR2I &c) const
Define a general 2D-vector/point.
Definition: vector2d.h:61
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
unsigned int TriangulatedPolyCount() const
Return the number of outlines in the set.
void CacheTriangulation(bool aPartition=true)
const TRIANGULATED_POLYGON * TriangulatedPolygon(int aIndex) const

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

Referenced by BOARD_ADAPTER::addShapeWithClearance(), BOARD_ADAPTER::addSolidAreasShapes(), RENDER_3D_OPENGL::createBoard(), BOARD_ADAPTER::createPadWithClearance(), and RENDER_3D_OPENGL::generateViasAndPads().