KiCad PCB EDA Suite
Loading...
Searching...
No Matches
shape_poly_tri_index.h File Reference
#include <cstdint>
#include <deque>
#include <limits>
#include <vector>
#include <utility>
#include <math/box2.h>
#include <geometry/rtree/packed_rtree.h>
#include <geometry/shape_poly_set.h>

Go to the source code of this file.

Classes

class  TRIANGULATION_INDEX
 A spatial index over the triangles of a cached triangulation, used to prune collision tests. More...
 

Functions

template<typename VISITOR>
bool VisitTriangleCandidates (const TRIANGULATION_INDEX *aIndex, const std::vector< std::unique_ptr< SHAPE_POLY_SET::TRIANGULATED_POLYGON > > &aPolys, const BOX2I &aBox, VISITOR aVisitor)
 Visit the triangles that could collide with something inside aBox, through aIndex when one exists, or by scanning every polygon otherwise.
 
bool AnyTriangleHit (const TRIANGULATION_INDEX *aIndex, const std::vector< std::unique_ptr< SHAPE_POLY_SET::TRIANGULATED_POLYGON > > &aPolys, const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr)
 Return true if any candidate triangle collides with aShape within aClearance.
 
bool AnyTriangleHit (const TRIANGULATION_INDEX *aIndex, const std::vector< std::unique_ptr< SHAPE_POLY_SET::TRIANGULATED_POLYGON > > &aPolys, const VECTOR2I &aPt)
 Return true if any candidate triangle contains aPt.
 

Function Documentation

◆ AnyTriangleHit() [1/2]

bool AnyTriangleHit ( const TRIANGULATION_INDEX * aIndex,
const std::vector< std::unique_ptr< SHAPE_POLY_SET::TRIANGULATED_POLYGON > > & aPolys,
const SHAPE * aShape,
int aClearance = 0,
int * aActual = nullptr,
VECTOR2I * aLocation = nullptr )
inline

Return true if any candidate triangle collides with aShape within aClearance.

With aActual or aLocation, every candidate is visited and the least collision distance and where it occurs are reported; without them the walk stops at the first hit.

Definition at line 157 of file shape_poly_tri_index.h.

References actual, SHAPE::BBox(), SHAPE::Collide(), BOX2< Vec >::Inflate(), location, and VisitTriangleCandidates().

Referenced by CN_ZONE_LAYER::Collide(), SHAPE_POLY_SET::Collide(), and CN_ZONE_LAYER::ContainsPoint().

◆ AnyTriangleHit() [2/2]

bool AnyTriangleHit ( const TRIANGULATION_INDEX * aIndex,
const std::vector< std::unique_ptr< SHAPE_POLY_SET::TRIANGULATED_POLYGON > > & aPolys,
const VECTOR2I & aPt )
inline

Return true if any candidate triangle contains aPt.

Definition at line 212 of file shape_poly_tri_index.h.

References SHAPE_LINE_CHAIN_BASE::Collide(), and VisitTriangleCandidates().

◆ VisitTriangleCandidates()

template<typename VISITOR>
bool VisitTriangleCandidates ( const TRIANGULATION_INDEX * aIndex,
const std::vector< std::unique_ptr< SHAPE_POLY_SET::TRIANGULATED_POLYGON > > & aPolys,
const BOX2I & aBox,
VISITOR aVisitor )

Visit the triangles that could collide with something inside aBox, through aIndex when one exists, or by scanning every polygon otherwise.

aVisitor is called as bool( const TRI* ); returning false stops the walk.

Implementation detail of the AnyTriangleHit() overloads below; call those instead.

Returns
false if the visitor stopped the walk, true if it ran to completion.

Definition at line 117 of file shape_poly_tri_index.h.

References TRIANGULATION_INDEX::Query().

Referenced by AnyTriangleHit(), and AnyTriangleHit().