29 #ifndef PolyhedronCore_hpp
30 #define PolyhedronCore_hpp
36 class vtkUnstructuredGrid;
99 void to_off_format(std::stringstream &offString,
bool basefacet =
true)
const;
240 for (
unsigned int ii = 0; ii < 3; ii++)
241 for (
unsigned int jj = 0; jj < 3; jj++)
339 double facet_area(
unsigned int facetIndex)
const;
346 void apply_offset(
double offsetX,
double offsetY,
double offsetZ);
375 bool contain(
double aPoint[3])
const;
420 void closest_point(
double aPoint[3],
double (&closestPoint)[3])
const;
488 void furthest_vertex_callback(
unsigned int aFacet,
const double *aPoint,
const double *anAxis,
double &distance)
const;
523 double closest_point_to_edge(
const double *point0,
const double *point1,
const double *,
double (&closestPoint)[3])
const;
553 static const unsigned int NotInList = (
unsigned int)(-1);
Definition: PolyhedronCore.hpp:38
void apply_offset(double offsetX, double offsetY, double offsetZ)
Applies an offset to all vertices coordinates of the polyhedron.
Definition: PolyhedronCore.cpp:695
const double * normal_ptr_of_facet(int facetIndex) const
Allows to get the normal of a given facet.
Definition: PolyhedronCore.hpp:286
std::vector< unsigned int > _nonManifoldEdges
The list of the non-manifold edges.
Definition: PolyhedronCore.hpp:630
double closest_point_to_edge(const double *point0, const double *point1, const double *, double(&closestPoint)[3]) const
Definition: PolyhedronCore.cpp:1298
std::vector< unsigned int > _candidateFacets
A vector containing candidate facets during the closest_pointAndPrimitive() procedure....
Definition: PolyhedronCore.hpp:757
std::vector< unsigned int > _hitPrimitives
The list primitives hit by a ray during a raycast on the AABB tree, set by the raycast_aabb_tree_call...
Definition: PolyhedronCore.hpp:741
void build_aabb_tree()
Builds a static AABB tree based on the polyhedron primitives.
Definition: PolyhedronCore.cpp:634
double _initialCentroid[3]
The initial centroid of the polyhedron, before any transformation.
Definition: PolyhedronCore.hpp:696
double volume() const
Definition: PolyhedronCore.hpp:217
static double SquaredDistanceErrorThreshold
Small value used to detect squared distance mismatch between two points.
Definition: PolyhedronCore.hpp:529
std::vector< unsigned int > _facetToVertex
The relationship between triangle facets and vertices.
Definition: PolyhedronCore.hpp:581
void apply_scale_factor(double factor, double yFactor, double zFactor)
Applies a scale factor to all vertices coordinates of the polyhedron.
Definition: PolyhedronCore.cpp:728
std::vector< unsigned int > _facetToEdge
The facet to edges connectivity list.
Definition: PolyhedronCore.hpp:606
void furthest_vertex_along_axis(const double *anAxis, unsigned int &furthestVertex) const
Finds the vertex in the polyhedron which is the furthest in the given direction.
Definition: PolyhedronCore.cpp:882
const double * centroid_ptr() const
Definition: PolyhedronCore.hpp:231
std::vector< double > _verticesNormals
The normals of each vertex in the polyhedron.
Definition: PolyhedronCore.hpp:651
const double * vertex_ptr_of_facet(unsigned int facetIndex, unsigned int vectorIndex) const
Allows to get the in-plane vectors of a given facet.
Definition: PolyhedronCore.hpp:277
bool is_convex() const
Definition: PolyhedronCore.hpp:210
const std::vector< unsigned int > & facet_to_vertex() const
Definition: PolyhedronCore.hpp:510
const unsigned int vertex_index_of_facet(int facetIndex, int vertexIndex) const
Allows to get a the global vertex index for a given facet, with a given local vertex index.
Definition: PolyhedronCore.hpp:268
unsigned int _furthestVertex
contains the furthest vertex found during a call to furthest_vertex_along_axis() method.
Definition: PolyhedronCore.hpp:729
void closest_point_callback(unsigned int aFacet, const double *aPoint, double &distance) const
Finds the point in a polyhedron facets which is the closest to the requested point.
Definition: PolyhedronCore.cpp:952
double facet_area(unsigned int facetIndex) const
Computes the area of a triangle facet with index facetIndex.
Definition: PolyhedronCore.cpp:679
unsigned int find_local_edge_index_of_facet(unsigned int aFacet, unsigned int anEdge)
Finds the local index of an edge of a given global facet.
Definition: PolyhedronCore.cpp:1332
std::pair< unsigned int, unsigned int > VertexPrimitivePair
Definition: PolyhedronCore.hpp:41
void clear_metric()
Clears the all computations performed on the polyhedron.
Definition: PolyhedronCore.cpp:104
std::vector< double > _vertices
The list of vertices coordinates, given as [x0,y0,z0,...,xn,yn,zn].
Definition: PolyhedronCore.hpp:559
double _iMatrix[3][3]
The inertia matrix of the polyhedron.
Definition: PolyhedronCore.hpp:706
PolyhedronCore()
instanciates a new PolyhedronCore object
Definition: PolyhedronCore.cpp:54
std::vector< double > _hitPoints
The list of points coordinates on primitives hit by a ray during raycast on the AABB tree,...
Definition: PolyhedronCore.hpp:735
std::vector< unsigned int > _facetToFacet
The facet to facets connectivity list.
Definition: PolyhedronCore.hpp:599
unsigned int _closestVertexIndex
The index of the closest vertex found during a closest point query on the AABB tree,...
Definition: PolyhedronCore.hpp:713
std::vector< unsigned int > & facet_to_vertex()
Definition: PolyhedronCore.hpp:511
void to_vtk_ugrid(vtkUnstructuredGrid &uGrid)
Creates a VTK unstructured grid with the polyhedron contents.
Definition: PolyhedronCore.cpp:297
std::vector< unsigned int > _verticesPerBaseFacet
The number of vertices that form a base facet.
Definition: PolyhedronCore.hpp:576
std::vector< double > _facetsVectors
The in-plane vectors of each facet in the polyhedron.
Definition: PolyhedronCore.hpp:637
const double * vertex_ptr(int vertexIndex) const
Allows to get a vertex coordinates array from its index in the _vertices vector.
Definition: PolyhedronCore.hpp:295
unsigned int basefacet_number() const
Definition: PolyhedronCore.hpp:168
double _minCorner[3]
The min corner of the polyhedron bounding box.
Definition: PolyhedronCore.hpp:664
void build_data_structure()
Builds the data structure which can be used to perform queries, e.g. adjacency.
Definition: PolyhedronCore.cpp:322
double _closestPoint[3]
contains the closest point found during a call to closest_point() method.
Definition: PolyhedronCore.hpp:724
std::vector< unsigned int > _edgeToVertex
The edge to vertices connectivity list.
Definition: PolyhedronCore.hpp:613
void compute_metric()
Computes geometric parameters related to the polyhedron.
Definition: PolyhedronCore.cpp:415
VertexPrimitivePair _closestVertexAndPrimitiveIndices
The index of the closest primitive associated to the closest vertex found during a closest and primit...
Definition: PolyhedronCore.hpp:750
void furthest_vertex_callback(unsigned int aFacet, const double *aPoint, const double *anAxis, double &distance) const
Finds the vertex in a polyhedron facets which is the furthest, in the requested direction.
Definition: PolyhedronCore.cpp:974
void clear()
Clears the geometric entities of the PolyhedronCore object.
Definition: PolyhedronCore.cpp:88
StaticAABBTree _aabbTree
The Axis Aligned Bounding Box tree built from the facets of the polyhedron.
Definition: PolyhedronCore.hpp:681
const unsigned int vertex_index_of_basefacet(int basefacetIndex, int vertexIndex) const
Allows to get a the global vertex index for a given base facet, with a given local vertex index.
Definition: PolyhedronCore.hpp:258
unsigned int vertex_number() const
Definition: PolyhedronCore.hpp:152
unsigned int basefacet_index_for_facet(unsigned int facetIndex) const
Returns the base facet index for a triangle facet.
Definition: PolyhedronCore.hpp:323
std::vector< unsigned int > _facetToBaseFacet
The relationship between a triangle facet to its base facet.
Definition: PolyhedronCore.hpp:591
const double * closest_vertex_ptr(double aPoint[3]) const
Finds the vertex in the polyhedron which is the closest to the query point.
Definition: PolyhedronCore.cpp:801
bool raycast_aabb_tree_callback(unsigned int aFacet, Ray aRay) const
Checks if a primitive is hit by a ray.
Definition: PolyhedronCore.cpp:1019
const double * initial_centroid_ptr() const
Definition: PolyhedronCore.hpp:224
double _volume
The volume of the tetrahedron.
Definition: PolyhedronCore.hpp:691
void inertia_tensor(double(&tensor)[3][3]) const
update the tensor to the inertia operator of the polyhedron.
Definition: PolyhedronCore.hpp:238
std::vector< double > & get_hitPoint()
Definition: PolyhedronCore.hpp:160
bool _isWatertight
A flag that say if the polyhedron is watertight or not.
Definition: PolyhedronCore.hpp:659
std::vector< unsigned int > _basefacetToVertexOffset
stores the offset required to access the first vertex of a base facet in _basefacetToVertex vector.
Definition: PolyhedronCore.hpp:571
void closest_vertex_and_primitive_callback(unsigned int aFacet, const double *aPoint, double &distance) const
Finds the vertex in a polyhedron facet and the associated facet which realizes the shortest distance ...
Definition: PolyhedronCore.cpp:934
void closest_point(double aPoint[3], double(&closestPoint)[3]) const
Finds the point in the polyhedron which is the closest to the query point.
Definition: PolyhedronCore.cpp:862
static unsigned char FacetEdgeDirection[3][3]
contains flags that allow to know if an edge is oriented towards a facet. or its incident counterpart...
Definition: PolyhedronCore.hpp:548
static const unsigned int NotInList
A flag to determine if an index is in a list.
Definition: PolyhedronCore.hpp:553
std::vector< double > _facetsNormals
The normals of each facet in the polyhedron.
Definition: PolyhedronCore.hpp:644
double _centroid[3]
The centroid of the polyhedron.
Definition: PolyhedronCore.hpp:701
const double * min_corner_ptr() const
Definition: PolyhedronCore.hpp:196
std::vector< unsigned int > _basefacetToFacetOffset
stores the offset required to access the first triangle facet of a base facet in _facetToBaseFacet ve...
Definition: PolyhedronCore.hpp:586
bool _isConvex
The convexity of the polyhedron.
Definition: PolyhedronCore.hpp:686
unsigned int facet_number() const
Definition: PolyhedronCore.hpp:175
unsigned int edge_number() const
Definition: PolyhedronCore.hpp:182
bool contain(double aPoint[3]) const
Checks if the polyhedron contains a 3D point.
Definition: PolyhedronCore.cpp:751
static unsigned char FacetEdgeVertex[3][2]
contains the local connectivity of a facet vertices by edge.
Definition: PolyhedronCore.hpp:538
const double * normal_ptr_of_vertex(int vertexIndex) const
Allows to get a refernce to a vertex coordinates array from its index in the _vertices vector.
Definition: PolyhedronCore.hpp:311
std::vector< unsigned int > _basefacetToVertex
The relationship between base facets (or raw facets, directly from the geometry file that is,...
Definition: PolyhedronCore.hpp:566
void translate_to_centroid()
translates the polyhedron to its center of mass.
Definition: PolyhedronCore.cpp:718
double _maxCorner[3]
The max corner of the polyhedron bounding box.
Definition: PolyhedronCore.hpp:669
~PolyhedronCore()
Default PolyhedronCore destructor.
Definition: PolyhedronCore.cpp:81
bool is_facet_crossed_by_ray(unsigned int aFacet, Ray aRay, double(&hitPoint)[3]) const
Checks if a facet is crossed by a given ray.
Definition: PolyhedronCore.cpp:1053
VertexPrimitivePair closest_vertex_and_primitive(double aPoint[3]) const
Finds the vertex and the primitive it is associated to in the polyhedron which are the closest to the...
Definition: PolyhedronCore.cpp:821
unsigned int _primitivesHitByRayCount
The number of primitives hit by a ray during a intersections count query on the AABB tree,...
Definition: PolyhedronCore.hpp:719
double _greatestSquaredDiagonal
Greatest squared diagonal used to normalize errors.
Definition: PolyhedronCore.hpp:674
bool is_watertight() const
Definition: PolyhedronCore.hpp:189
unsigned int vertex_number_of_basefacet(int basefacetIndex) const
Definition: PolyhedronCore.hpp:248
void closest_point_in_facet(unsigned int aFacet, const double *aPoint, double(&closestPoint)[3]) const
Finds the closest point lying on a facet closest to aPoint.
Definition: PolyhedronCore.cpp:1146
const double * max_corner_ptr() const
Definition: PolyhedronCore.hpp:203
std::vector< unsigned int > facet_hit_by_ray(Ray aRay) const
get_s the list of facets hit by a ray.
Definition: PolyhedronCore.cpp:779
void closest_vertex_callback(unsigned int aFacet, const double *aPoint, double &distance) const
Finds the vertex in a polyhedron facets which is the closest to the requested point.
Definition: PolyhedronCore.cpp:917
std::vector< unsigned int > _edgeToFacet
The edge to facets connectivity list.
Definition: PolyhedronCore.hpp:623
void to_off_format(std::stringstream &offString, bool basefacet=true) const
Creates an std::stringstream with the polyhedron contents, in OFF file format.
Definition: PolyhedronCore.cpp:256
double basefacet_area(unsigned int facetIndex) const
Computes the area of a base facet.
Definition: PolyhedronCore.cpp:663
void read_off_file(std::string filePath)
Reads an OFF file given a file path.
Definition: PolyhedronCore.cpp:121
Definition: StaticAABBTree.hpp:79
Definition: StaticAABBTree.hpp:71