DGtal 1.3.0
Loading...
Searching...
No Matches
Data Structures | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes
DGtal::SurfaceMesh< TRealPoint, TRealVector > Struct Template Reference

Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces but no specific topology is required. However, you also have methods to navigate between neighbor vertices, faces, etc. The mesh can be equipped with normals at faces and/or vertices. More...

#include <DGtal/shapes/SurfaceMesh.h>

Data Structures

struct  VertexMap
 

Public Types

typedef TRealPoint RealPoint
 
typedef TRealVector RealVector
 
typedef SurfaceMesh< RealPoint, RealVectorSelf
 
typedef RealVector::Component Scalar
 
typedef std::vector< ScalarScalars
 
typedef std::size_t Size
 The type for counting elements. More...
 
typedef std::size_t Index
 The type used for numbering vertices and faces. More...
 
typedef Index Face
 
typedef Index Edge
 
typedef Index Vertex
 
typedef std::pair< Edge, ScalarWeightedEdge
 
typedef std::pair< Face, ScalarWeightedFace
 
typedef std::vector< VertexVertices
 The type that defines a list/range of vertices (e.g. to define faces) More...
 
typedef std::vector< EdgeEdges
 The type that defines a list/range of edges. More...
 
typedef std::vector< WeightedEdgeWeightedEdges
 
typedef std::vector< FaceFaces
 
typedef std::vector< WeightedFaceWeightedFaces
 
typedef std::pair< Vertex, VertexVertexPair
 
typedef std::set< VertexVertexSet
 
typedef IntegerSequenceIterator< VertexConstIterator
 Non mutable iterator for visiting vertices. More...
 

Public Member Functions

 BOOST_STATIC_ASSERT ((dimension==3))
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 
Standard services
 ~SurfaceMesh ()=default
 Default destructor. More...
 
 SurfaceMesh ()=default
 
 SurfaceMesh (const Self &other)=default
 
 SurfaceMesh (Self &&other)=default
 
Selfoperator= (const Self &other)=default
 
template<typename RealPointIterator , typename VerticesIterator >
 SurfaceMesh (RealPointIterator itPos, RealPointIterator itPosEnd, VerticesIterator itVertices, VerticesIterator itVerticesEnd)
 
template<typename RealPointIterator , typename VerticesIterator >
bool init (RealPointIterator itPos, RealPointIterator itPosEnd, VerticesIterator itVertices, VerticesIterator itVerticesEnd)
 
void clear ()
 Clears everything. The object is empty. More...
 
Vertex and face vectors initialization and conversion services
template<typename RealVectorIterator >
bool setVertexNormals (RealVectorIterator itN, RealVectorIterator itNEnd)
 
template<typename RealVectorIterator >
bool setFaceNormals (RealVectorIterator itN, RealVectorIterator itNEnd)
 
void computeFaceNormalsFromPositions ()
 
void computeFaceNormalsFromVertexNormals ()
 
void computeVertexNormalsFromFaceNormals ()
 
void computeVertexNormalsFromFaceNormalsWithMaxWeights ()
 
template<typename AnyRing >
std::vector< AnyRing > computeFaceValuesFromVertexValues (const std::vector< AnyRing > &vvalues) const
 
template<typename AnyRing >
std::vector< AnyRing > computeVertexValuesFromFaceValues (const std::vector< AnyRing > &fvalues) const
 
std::vector< RealVectorcomputeFaceUnitVectorsFromVertexUnitVectors (const std::vector< RealVector > &vuvectors) const
 
std::vector< RealVectorcomputeVertexUnitVectorsFromFaceUnitVectors (const std::vector< RealVector > &fuvectors) const
 
Accessors
Size nbVertices () const
 
Size nbEdges () const
 
Size nbFaces () const
 
long Euler () const
 
Edge makeEdge (Vertex i, Vertex j) const
 
const VerticesincidentVertices (Face f) const
 
const FacesincidentFaces (Vertex v) const
 
const FacesneighborFaces (Face f) const
 
const VerticesneighborVertices (Vertex v) const
 
const VertexPairedgeVertices (Edge e) const
 
const FacesedgeFaces (Edge e) const
 
const FacesedgeRightFaces (Edge e) const
 
const FacesedgeLeftFaces (Edge e) const
 
const std::vector< Vertices > & allIncidentVertices () const
 
const std::vector< Faces > & allIncidentFaces () const
 
const std::vector< Faces > & allNeighborFaces () const
 
const std::vector< Vertices > & allNeighborVertices () const
 
const std::vector< VertexPair > & allEdgeVertices () const
 
const std::vector< Faces > & allEdgeFaces () const
 
const std::vector< Faces > & allEdgeRightFaces () const
 
const std::vector< Faces > & allEdgeLeftFaces () const
 
Other topological services
Edges computeManifoldBoundaryEdges () const
 
Edges computeManifoldInnerEdges () const
 
Edges computeManifoldInnerConsistentEdges () const
 
Edges computeManifoldInnerUnconsistentEdges () const
 
Edges computeNonManifoldEdges () const
 
bool isBoundariesManifold (bool checkClosed=true) const
 
std::vector< VerticescomputeManifoldBoundaryChains () const
 
Undirected simple graph services
Size size () const
 
Size bestCapacity () const
 
Size degree (const Vertex &v) const
 
template<typename OutputIterator >
void writeNeighbors (OutputIterator &it, const Vertex &v) const
 
template<typename OutputIterator , typename VertexPredicate >
void writeNeighbors (OutputIterator &it, const Vertex &v, const VertexPredicate &pred) const
 
ConstIterator begin () const
 
ConstIterator end () const
 
Geometric services
const std::vector< RealPoint > & positions () const
 
RealPointposition (Vertex v)
 
const RealPointposition (Vertex v) const
 
const std::vector< RealVector > & vertexNormals () const
 
std::vector< RealVector > & vertexNormals ()
 
RealVectorvertexNormal (Vertex v)
 
const RealVectorvertexNormal (Vertex v) const
 
const std::vector< RealVector > & faceNormals () const
 
std::vector< RealVector > & faceNormals ()
 
RealVectorfaceNormal (Face f)
 
const RealVectorfaceNormal (Face f) const
 
Scalar averageEdgeLength () const
 
Scalar distance (const Vertex i, const Vertex j) const
 
Scalar localWindow (Face f) const
 
void perturbateWithUniformRandomNoise (Scalar p)
 
void perturbateWithAdaptiveUniformRandomNoise (Scalar p)
 
RealPoint edgeCentroid (Index e) const
 
RealPoint faceCentroid (Index f) const
 
Scalar faceArea (Index f) const
 
Scalars getMaxWeights (Index v) const
 
WeightedFaces computeFacesInclusionsInBall (Scalar r, Index f) const
 
WeightedFaces computeFacesInclusionsInBall (Scalar r, Index f, RealPoint p) const
 
std::tuple< Vertices, WeightedEdges, WeightedFacescomputeCellsInclusionsInBall (Scalar r, Index f) const
 
std::tuple< Vertices, WeightedEdges, WeightedFacescomputeCellsInclusionsInBall (Scalar r, Index f, RealPoint p) const
 
Scalar faceInclusionRatio (RealPoint p, Scalar r, Index f) const
 
Scalar edgeInclusionRatio (RealPoint p, Scalar r, Index e) const
 
Scalar vertexInclusionRatio (RealPoint p, Scalar r, Index v) const
 

Static Public Attributes

static const Dimension dimension = RealPoint::dimension
 

Protected Member Functions

void computeNeighbors ()
 Computes neighboring information. More...
 
void computeEdges ()
 Computes edge information. More...
 

Static Protected Member Functions

static Scalar rand01 ()
 

Protected Attributes

std::vector< VerticesmyIncidentVertices
 For each face, its range of incident vertices. More...
 
std::vector< FacesmyIncidentFaces
 For each vertex, its range of incident faces. More...
 
std::vector< RealPointmyPositions
 For each vertex, its position. More...
 
std::vector< RealVectormyVertexNormals
 For each vertex, its normal vector. More...
 
std::vector< RealVectormyFaceNormals
 For each face, its normal vector. More...
 
std::vector< FacesmyNeighborFaces
 For each face, its range of neighbor faces (no particular order) More...
 
std::vector< VerticesmyNeighborVertices
 For each vertex, its range of neighbor vertices (no particular order) More...
 
std::vector< VertexPairmyEdgeVertices
 For each edge, its two vertices. More...
 
std::vector< FacesmyEdgeFaces
 For each edge, its faces (one, two, or more if non manifold) More...
 
std::vector< FacesmyEdgeRightFaces
 
std::vector< FacesmyEdgeLeftFaces
 

Detailed Description

template<typename TRealPoint, typename TRealVector>
struct DGtal::SurfaceMesh< TRealPoint, TRealVector >

Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces but no specific topology is required. However, you also have methods to navigate between neighbor vertices, faces, etc. The mesh can be equipped with normals at faces and/or vertices.

Description of template class 'SurfaceMesh'

We sum up below the possible classes for representing meshes:

See also SurfaceMeshReader and SurfaceMeshWriter for input/output operations for SurfaceMesh.

Template Parameters
TRealPointan arbitrary model of 3D RealPoint.
TRealVectoran arbitrary model of 3D RealVector.
Examples
geometry/meshes/curvature-comparator-ii-cnc-3d.cpp, geometry/meshes/curvature-measures-icnc-3d.cpp, geometry/meshes/curvature-measures-icnc-XY-3d.cpp, geometry/meshes/curvature-measures-nc-3d.cpp, geometry/meshes/curvature-measures-nc-XY-3d.cpp, geometry/meshes/digpoly-curvature-measures-cnc-3d.cpp, geometry/meshes/digpoly-curvature-measures-cnc-XY-3d.cpp, geometry/meshes/obj-curvature-measures-icnc-3d.cpp, geometry/meshes/obj-curvature-measures-icnc-XY-3d.cpp, geometry/meshes/vol-curvature-measures-icnc-3d.cpp, geometry/meshes/vol-curvature-measures-icnc-XY-3d.cpp, geometry/tools/exampleLatticeBallDelaunay2D.cpp, geometry/tools/exampleLatticeBallDelaunay3D.cpp, geometry/tools/exampleLatticeBallQuickHull3D.cpp, geometry/tools/exampleQuickHull3D.cpp, geometry/tools/exampleRationalBallDelaunay3D.cpp, geometry/tools/exampleRationalBallQuickHull3D.cpp, geometry/volumes/digitalPolyhedronBuilder3D.cpp, geometry/volumes/fullConvexitySphereGeodesics.cpp, geometry/volumes/standardDigitalPolyhedronBuilder3D.cpp, and shapes/exampleSurfaceMesh.cpp.

Definition at line 91 of file SurfaceMesh.h.

Member Typedef Documentation

◆ ConstIterator

template<typename TRealPoint , typename TRealVector >
typedef IntegerSequenceIterator< Vertex > DGtal::SurfaceMesh< TRealPoint, TRealVector >::ConstIterator

Non mutable iterator for visiting vertices.

Definition at line 129 of file SurfaceMesh.h.

◆ Edge

template<typename TRealPoint , typename TRealVector >
typedef Index DGtal::SurfaceMesh< TRealPoint, TRealVector >::Edge

Definition at line 107 of file SurfaceMesh.h.

◆ Edges

template<typename TRealPoint , typename TRealVector >
typedef std::vector< Edge > DGtal::SurfaceMesh< TRealPoint, TRealVector >::Edges

The type that defines a list/range of edges.

Definition at line 114 of file SurfaceMesh.h.

◆ Face

template<typename TRealPoint , typename TRealVector >
typedef Index DGtal::SurfaceMesh< TRealPoint, TRealVector >::Face

Definition at line 106 of file SurfaceMesh.h.

◆ Faces

template<typename TRealPoint , typename TRealVector >
typedef std::vector< Face > DGtal::SurfaceMesh< TRealPoint, TRealVector >::Faces

Definition at line 116 of file SurfaceMesh.h.

◆ Index

template<typename TRealPoint , typename TRealVector >
typedef std::size_t DGtal::SurfaceMesh< TRealPoint, TRealVector >::Index

The type used for numbering vertices and faces.

Definition at line 105 of file SurfaceMesh.h.

◆ RealPoint

template<typename TRealPoint , typename TRealVector >
typedef TRealPoint DGtal::SurfaceMesh< TRealPoint, TRealVector >::RealPoint

Definition at line 93 of file SurfaceMesh.h.

◆ RealVector

template<typename TRealPoint , typename TRealVector >
typedef TRealVector DGtal::SurfaceMesh< TRealPoint, TRealVector >::RealVector

Definition at line 94 of file SurfaceMesh.h.

◆ Scalar

template<typename TRealPoint , typename TRealVector >
typedef RealVector::Component DGtal::SurfaceMesh< TRealPoint, TRealVector >::Scalar

Definition at line 100 of file SurfaceMesh.h.

◆ Scalars

template<typename TRealPoint , typename TRealVector >
typedef std::vector<Scalar> DGtal::SurfaceMesh< TRealPoint, TRealVector >::Scalars

Definition at line 101 of file SurfaceMesh.h.

◆ Self

template<typename TRealPoint , typename TRealVector >
typedef SurfaceMesh< RealPoint, RealVector > DGtal::SurfaceMesh< TRealPoint, TRealVector >::Self

Definition at line 95 of file SurfaceMesh.h.

◆ Size

template<typename TRealPoint , typename TRealVector >
typedef std::size_t DGtal::SurfaceMesh< TRealPoint, TRealVector >::Size

The type for counting elements.

Definition at line 103 of file SurfaceMesh.h.

◆ Vertex

template<typename TRealPoint , typename TRealVector >
typedef Index DGtal::SurfaceMesh< TRealPoint, TRealVector >::Vertex

Definition at line 108 of file SurfaceMesh.h.

◆ VertexPair

template<typename TRealPoint , typename TRealVector >
typedef std::pair< Vertex, Vertex > DGtal::SurfaceMesh< TRealPoint, TRealVector >::VertexPair

Definition at line 118 of file SurfaceMesh.h.

◆ VertexSet

template<typename TRealPoint , typename TRealVector >
typedef std::set<Vertex> DGtal::SurfaceMesh< TRealPoint, TRealVector >::VertexSet

Definition at line 121 of file SurfaceMesh.h.

◆ Vertices

template<typename TRealPoint , typename TRealVector >
typedef std::vector< Vertex > DGtal::SurfaceMesh< TRealPoint, TRealVector >::Vertices

The type that defines a list/range of vertices (e.g. to define faces)

Definition at line 112 of file SurfaceMesh.h.

◆ WeightedEdge

template<typename TRealPoint , typename TRealVector >
typedef std::pair< Edge, Scalar > DGtal::SurfaceMesh< TRealPoint, TRealVector >::WeightedEdge

Definition at line 109 of file SurfaceMesh.h.

◆ WeightedEdges

template<typename TRealPoint , typename TRealVector >
typedef std::vector< WeightedEdge > DGtal::SurfaceMesh< TRealPoint, TRealVector >::WeightedEdges

Definition at line 115 of file SurfaceMesh.h.

◆ WeightedFace

template<typename TRealPoint , typename TRealVector >
typedef std::pair< Face, Scalar > DGtal::SurfaceMesh< TRealPoint, TRealVector >::WeightedFace

Definition at line 110 of file SurfaceMesh.h.

◆ WeightedFaces

template<typename TRealPoint , typename TRealVector >
typedef std::vector< WeightedFace > DGtal::SurfaceMesh< TRealPoint, TRealVector >::WeightedFaces

Definition at line 117 of file SurfaceMesh.h.

Constructor & Destructor Documentation

◆ ~SurfaceMesh()

template<typename TRealPoint , typename TRealVector >
DGtal::SurfaceMesh< TRealPoint, TRealVector >::~SurfaceMesh ( )
default

Default destructor.

◆ SurfaceMesh() [1/4]

template<typename TRealPoint , typename TRealVector >
DGtal::SurfaceMesh< TRealPoint, TRealVector >::SurfaceMesh ( )
default

Default constructor.

A typical construction usage is

std::vector< RealPoint > positions = { { 0, 0, 5 }, { 1, 1, 3 }, { -1, 1, 3 }, { -1, -1, 3 }, { 1, -1, 3 } };
std::vector< Vertices > faces = { { 0, 1, 2 }, { 0, 2, 3 }, { 0, 3, 4 }, { 0, 4, 1 }, { 4, 3, 2, 1 } };
SurfMesh pyramid_mesh;
pyramid_mesh.init( positions.cbegin(), positions.cend(), faces.cbegin(), faces.cend() );
const std::vector< RealPoint > & positions() const
Definition: SurfaceMesh.h:631

◆ SurfaceMesh() [2/4]

template<typename TRealPoint , typename TRealVector >
DGtal::SurfaceMesh< TRealPoint, TRealVector >::SurfaceMesh ( const Self other)
default

Default copy constructor.

Parameters
otherthe object to clone

◆ SurfaceMesh() [3/4]

template<typename TRealPoint , typename TRealVector >
DGtal::SurfaceMesh< TRealPoint, TRealVector >::SurfaceMesh ( Self &&  other)
default

Default move constructor.

Parameters
otherthe object to move

◆ SurfaceMesh() [4/4]

template<typename TRealPoint , typename TRealVector >
template<typename RealPointIterator , typename VerticesIterator >
DGtal::SurfaceMesh< TRealPoint, TRealVector >::SurfaceMesh ( RealPointIterator  itPos,
RealPointIterator  itPosEnd,
VerticesIterator  itVertices,
VerticesIterator  itVerticesEnd 
)

Builds a mesh from vertex positions and polygonal faces.

Template Parameters
RealPointIteratorany forward iterator on RealPoint.
VerticesIteratorany forward iterator on the range of vertices defining a face.
Parameters
itPosstart of range of iterators pointing on the positions of vertices of the mesh
itPosEndend of range of iterators pointing on the positions of vertices of the mesh.
itVerticesstart of range of iterators pointing on the (oriented) faces of the mesh, each face being a range of vertex indices.
itVerticesEndend of range of iterators pointing on the (oriented) faces of the mesh, each face being a range of vertex indices.

A typical construction usage is

std::vector< RealPoint > positions = { { 0, 0, 5 }, { 1, 1, 3 }, { -1, 1, 3 }, { -1, -1, 3 }, { 1, -1, 3 } };
std::vector< Vertices > faces = { { 0, 1, 2 }, { 0, 2, 3 }, { 0, 3, 4 }, { 0, 4, 1 }, { 4, 3, 2, 1 } };
auto pyramid_mesh = SurfMesh( positions.cbegin(), positions.cend(), faces.cbegin(), faces.cend() );

Member Function Documentation

◆ allEdgeFaces()

template<typename TRealPoint , typename TRealVector >
const std::vector< Faces > & DGtal::SurfaceMesh< TRealPoint, TRealVector >::allEdgeFaces ( ) const
inline
Returns
a const reference to the vector giving for each edge its incident faces (one, two, or more if non manifold)

Definition at line 386 of file SurfaceMesh.h.

387 { return myEdgeFaces; }
std::vector< Faces > myEdgeFaces
For each edge, its faces (one, two, or more if non manifold)
Definition: SurfaceMesh.h:891

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myEdgeFaces.

◆ allEdgeLeftFaces()

template<typename TRealPoint , typename TRealVector >
const std::vector< Faces > & DGtal::SurfaceMesh< TRealPoint, TRealVector >::allEdgeLeftFaces ( ) const
inline
Returns
a const reference to the vector giving for each edge its incident faces to its left (zero if open, one, or more if non manifold).
Note
an edge is stored as a vertex pair (i,j), i < j. So a face to its left, being defined ccw, means that the face is some (..., i, j, ... ).

Definition at line 406 of file SurfaceMesh.h.

407 { return myEdgeLeftFaces; }
std::vector< Faces > myEdgeLeftFaces
Definition: SurfaceMesh.h:903

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myEdgeLeftFaces.

◆ allEdgeRightFaces()

template<typename TRealPoint , typename TRealVector >
const std::vector< Faces > & DGtal::SurfaceMesh< TRealPoint, TRealVector >::allEdgeRightFaces ( ) const
inline
Returns
a const reference to the vector giving for each edge its incident faces to its right (zero if open, one, or more if non manifold).
Note
an edge is stored as a vertex pair (i,j), i < j. So a face to its right, being defined ccw, means that the face is some (..., j, i, ... ).

Definition at line 396 of file SurfaceMesh.h.

397 { return myEdgeRightFaces; }
std::vector< Faces > myEdgeRightFaces
Definition: SurfaceMesh.h:897

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myEdgeRightFaces.

◆ allEdgeVertices()

template<typename TRealPoint , typename TRealVector >
const std::vector< VertexPair > & DGtal::SurfaceMesh< TRealPoint, TRealVector >::allEdgeVertices ( ) const
inline
Returns
a const reference to the vector giving for each edge its two vertices (as a pair (i,j), i<j).
Note
edges are sorted in increasing order.

Definition at line 381 of file SurfaceMesh.h.

382 { return myEdgeVertices; }
std::vector< VertexPair > myEdgeVertices
For each edge, its two vertices.
Definition: SurfaceMesh.h:889

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myEdgeVertices.

Referenced by main().

◆ allIncidentFaces()

template<typename TRealPoint , typename TRealVector >
const std::vector< Faces > & DGtal::SurfaceMesh< TRealPoint, TRealVector >::allIncidentFaces ( ) const
inline
Returns
a const reference to the vector giving for each vertex its incident faces.

Definition at line 367 of file SurfaceMesh.h.

368 { return myIncidentFaces; }
std::vector< Faces > myIncidentFaces
For each vertex, its range of incident faces.
Definition: SurfaceMesh.h:877

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myIncidentFaces.

◆ allIncidentVertices()

template<typename TRealPoint , typename TRealVector >
const std::vector< Vertices > & DGtal::SurfaceMesh< TRealPoint, TRealVector >::allIncidentVertices ( ) const
inline
Returns
a const reference to the vector giving for each face its incident vertices.

Definition at line 362 of file SurfaceMesh.h.

363 { return myIncidentVertices; }
std::vector< Vertices > myIncidentVertices
For each face, its range of incident vertices.
Definition: SurfaceMesh.h:875

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myIncidentVertices.

Referenced by main().

◆ allNeighborFaces()

template<typename TRealPoint , typename TRealVector >
const std::vector< Faces > & DGtal::SurfaceMesh< TRealPoint, TRealVector >::allNeighborFaces ( ) const
inline
Returns
a const reference to the vector of neighbor faces for each face.

Definition at line 371 of file SurfaceMesh.h.

372 { return myNeighborFaces; }
std::vector< Faces > myNeighborFaces
For each face, its range of neighbor faces (no particular order)
Definition: SurfaceMesh.h:885

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myNeighborFaces.

◆ allNeighborVertices()

template<typename TRealPoint , typename TRealVector >
const std::vector< Vertices > & DGtal::SurfaceMesh< TRealPoint, TRealVector >::allNeighborVertices ( ) const
inline
Returns
a const reference to the vector of neighbor vertices for each vertex.

Definition at line 375 of file SurfaceMesh.h.

376 { return myNeighborVertices; }
std::vector< Vertices > myNeighborVertices
For each vertex, its range of neighbor vertices (no particular order)
Definition: SurfaceMesh.h:887

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myNeighborVertices.

◆ averageEdgeLength()

template<typename TRealPoint , typename TRealVector >
Scalar DGtal::SurfaceMesh< TRealPoint, TRealVector >::averageEdgeLength ( ) const
Returns
the average of the length of edges.

◆ begin()

template<typename TRealPoint , typename TRealVector >
ConstIterator DGtal::SurfaceMesh< TRealPoint, TRealVector >::begin ( ) const
inline
Returns
a (non mutable) iterator pointing on the first vertex.

Definition at line 616 of file SurfaceMesh.h.

617 { return ConstIterator( 0 ); }
IntegerSequenceIterator< Vertex > ConstIterator
Non mutable iterator for visiting vertices.
Definition: SurfaceMesh.h:129

◆ bestCapacity()

template<typename TRealPoint , typename TRealVector >
Size DGtal::SurfaceMesh< TRealPoint, TRealVector >::bestCapacity ( ) const
inline
Returns
an estimate of the maximum number of neighbors for this adjacency
Note
chosen here to be 8. Number of neighbors is 6 on average for planar triangulations.

Definition at line 559 of file SurfaceMesh.h.

560 { return 8; }

◆ BOOST_STATIC_ASSERT()

template<typename TRealPoint , typename TRealVector >
DGtal::SurfaceMesh< TRealPoint, TRealVector >::BOOST_STATIC_ASSERT ( (dimension==3)  )

◆ clear()

template<typename TRealPoint , typename TRealVector >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::clear ( )

Clears everything. The object is empty.

◆ computeCellsInclusionsInBall() [1/2]

template<typename TRealPoint , typename TRealVector >
std::tuple< Vertices, WeightedEdges, WeightedFaces > DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeCellsInclusionsInBall ( Scalar  r,
Index  f 
) const

Given a ball of radius r centered on the centroid of face f, return the vertices/edges/faces having an non empty intersection with this ball, each edge/face weighted by its ratio of inclusion (in the range [0,1] where 0 is empty intersection and 1 is completely included).

Parameters
rthe radius of the ball.
fthe face where the ball is centered.
Returns
the range of vertices/edges/faces having an non empty intersection with this ball, each edge/face weighted by its ratio of inclusion (in the range [0,1] where 0 is empty intersection and 1 is completely included).
Note
a vertex is either included or not, so no weight is necessary.

Referenced by DGtal::SurfaceMeshMeasure< TRealPoint, TRealVector, TValue >::measure().

◆ computeCellsInclusionsInBall() [2/2]

template<typename TRealPoint , typename TRealVector >
std::tuple< Vertices, WeightedEdges, WeightedFaces > DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeCellsInclusionsInBall ( Scalar  r,
Index  f,
RealPoint  p 
) const

Given a ball of radius r centered on a point p belonging to face f, return the vertices/edges/faces having an non empty intersection with this ball, each edge/face weighted by its ratio of inclusion (in the range [0,1] where 0 is empty intersection and 1 is completely included).

Parameters
rthe radius of the ball.
fthe face where the ball is centered.
pthe position on the face where the ball is centered.
Returns
the range of vertices/edges/faces having an non empty intersection with this ball, each edge/face weighted by its ratio of inclusion (in the range [0,1] where 0 is empty intersection and 1 is completely included).
Note
a vertex is either included or not, so no weight is necessary.

◆ computeEdges()

template<typename TRealPoint , typename TRealVector >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeEdges ( )
protected

Computes edge information.

◆ computeFaceNormalsFromPositions()

template<typename TRealPoint , typename TRealVector >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeFaceNormalsFromPositions ( )

Uses the positions of vertices to compute a normal vector to each face of the mesh. It computes the barycenter, triangulates implicitly the face to build the normal vector from the average of implicit triangle normals.

◆ computeFaceNormalsFromVertexNormals()

template<typename TRealPoint , typename TRealVector >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeFaceNormalsFromVertexNormals ( )

Uses the normals associated with vertices to compute a normal vector to each face of the mesh. It simply averages the normals at every incident vertex.

◆ computeFacesInclusionsInBall() [1/2]

template<typename TRealPoint , typename TRealVector >
WeightedFaces DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeFacesInclusionsInBall ( Scalar  r,
Index  f 
) const

Given a ball of radius r centered on the centroid of face f, return the faces having a non empty intersection with this ball, each one weighted by its ratio of inclusion (in the range [0,1] where 0 is empty intersection and 1 is completely included).

Parameters
rthe radius of the ball.
fthe face where the ball is centered.
Returns
the range of faces having an non empty intersection with this ball, each one weighted by its ratio of inclusion (in the range [0,1] where 0 is empty intersection and 1 is completely included).
Note
For faces, the ratio is the approximated area of the face part inside the ball and the face area. The approximation is estimated by computing the distance of face vertices and face barycenter to the ball center and by linear interpolation of the results.

Referenced by DGtal::SurfaceMeshMeasure< TRealPoint, TRealVector, TValue >::measure().

◆ computeFacesInclusionsInBall() [2/2]

template<typename TRealPoint , typename TRealVector >
WeightedFaces DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeFacesInclusionsInBall ( Scalar  r,
Index  f,
RealPoint  p 
) const

Given a ball of radius r centered on a point p belonging to face f, return the faces having a non empty intersection with this ball, each one weighted by its ratio of inclusion (in the range [0,1] where 0 is empty intersection and 1 is completely included).

Parameters
rthe radius of the ball.
fthe face where the ball is centered.
pthe position on the face where the ball is centered.
Returns
the range of faces having an non empty intersection with this ball, each one weighted by its ratio of inclusion (in the range [0,1] where 0 is empty intersection and 1 is completely included).
Note
For faces, the ratio is the approximated area of the face part inside the ball and the face area. The approximation is estimated by computing the distance of face vertices and face barycenter to the ball center and by linear interpolation of the results.

◆ computeFaceUnitVectorsFromVertexUnitVectors()

template<typename TRealPoint , typename TRealVector >
std::vector< RealVector > DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeFaceUnitVectorsFromVertexUnitVectors ( const std::vector< RealVector > &  vuvectors) const
Parameters
vuvectorsany vector of unit vectors on vertices.
Returns
a vector of unit vectors on faces approximating vuvectors.

◆ computeFaceValuesFromVertexValues()

template<typename TRealPoint , typename TRealVector >
template<typename AnyRing >
std::vector< AnyRing > DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeFaceValuesFromVertexValues ( const std::vector< AnyRing > &  vvalues) const
Parameters
vvaluesany vector of vertex values.
Returns
a vector of face values approximating vvalues.
Template Parameters
AnyRingany summable and averagable type.

Referenced by main(), and saveToObj().

◆ computeManifoldBoundaryChains()

template<typename TRealPoint , typename TRealVector >
std::vector< Vertices > DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeManifoldBoundaryChains ( ) const
inline

Extract the boundary of a surface mesh as a collection of sequences of vertices. The boundaries must be 1d manifold polygonal curves.

Precondition
the boundaries must be manifold.
Returns
a vector of polygonal simple curves (vector of vertices).

Definition at line 473 of file SurfaceMesh.h.

474 {
475 std::vector<Vertices> boundaries;
476 Vertices boundary;
477 auto MBE = this->computeManifoldBoundaryEdges();
478 std::map<Vertex,bool> visited;
479 std::map<Vertex,Vertices> adjacent;
480
481 ASSERT_MSG(MBE.size()>0,"The surface mesh must have boundary edges");
482 ASSERT_MSG(this->isBoundariesManifold(), "The surface mesh mush have manifold boundaries");
483
484 //Coompute adjecency relationships
485 for (auto e : MBE)
486 {
487 auto ij = this->edgeVertices(e);
488 visited[ij.first] = false;
489 visited[ij.second] = false;
490 adjacent[ij.first].push_back(ij.second);
491 adjacent[ij.second].push_back(ij.first);
492 }
493
494 auto boundary_it = visited.begin();
495
496 while(boundary_it != visited.end() )
497 {
498 Vertex first = (*boundary_it).first;
499 visited[first] = true;
500 boundary.clear();
501 boundary.push_back(first);
502
503 Vertex current = first;
504 size_t nb_iter = 0;
505 bool pushed=false;
506
507 while ((!pushed) && (nb_iter < MBE.size()*2))
508 {
509 bool ok = false;
510 for (auto other : adjacent[current])
511 if (!visited[other])
512 {
513 boundary.push_back(other);
514 current = other;
515 visited[other] = true;
516 ok = true;
517 break;
518 }
519 if (!ok)
520 {
521 //all neighboors are visited
522 for (auto other : adjacent[current])
523 if (other == first)
524 {
525 boundaries.push_back(boundary);
526 pushed = true;
527 break;
528 }
529 //if first vertex isn't found then this chain is not
530 //homeomorphic to a circle, hence isn't added to boundaries
531 }
532 nb_iter++;
533 }
534 boundary_it = std::find_if(visited.begin(), visited.end(),
535 []
536 (std::pair<Vertex,bool> x){return !x.second;});
537 }
538 return boundaries;
539 }
SMesh::Vertices Vertices
const VertexPair & edgeVertices(Edge e) const
Definition: SurfaceMesh.h:329
bool isBoundariesManifold(bool checkClosed=true) const
Definition: SurfaceMesh.h:446
Edges computeManifoldBoundaryEdges() const
TriMesh::Vertex Vertex

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeManifoldBoundaryEdges(), DGtal::SurfaceMesh< TRealPoint, TRealVector >::edgeVertices(), and DGtal::SurfaceMesh< TRealPoint, TRealVector >::isBoundariesManifold().

◆ computeManifoldBoundaryEdges()

template<typename TRealPoint , typename TRealVector >
Edges DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeManifoldBoundaryEdges ( ) const
Returns
the edges that lie on the boundary of the mesh, i.e. they have only one incident face.

Referenced by DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeManifoldBoundaryChains(), DGtal::SurfaceMesh< TRealPoint, TRealVector >::isBoundariesManifold(), SCENARIO(), and TEST_CASE().

◆ computeManifoldInnerConsistentEdges()

template<typename TRealPoint , typename TRealVector >
Edges DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeManifoldInnerConsistentEdges ( ) const
Returns
the edges that lie on the inside of the mesh, with consistent local orientation, i.e. they have one left incident face, and one right incident face.

◆ computeManifoldInnerEdges()

template<typename TRealPoint , typename TRealVector >
Edges DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeManifoldInnerEdges ( ) const
Returns
the edges that lie on the inside of the mesh, with two incident faces, consistently oriented or not.
Note
union of computeManifoldInnerConsistentEdges and computeManifoldInnerUnconsistentEdges

◆ computeManifoldInnerUnconsistentEdges()

template<typename TRealPoint , typename TRealVector >
Edges DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeManifoldInnerUnconsistentEdges ( ) const
Returns
the edges that have two incident faces, but not correctly oriented, i.e. they may have two left incident faces and no right incident face, or two right incident faces and no left incident face.

◆ computeNeighbors()

template<typename TRealPoint , typename TRealVector >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeNeighbors ( )
protected

Computes neighboring information.

◆ computeNonManifoldEdges()

template<typename TRealPoint , typename TRealVector >
Edges DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeNonManifoldEdges ( ) const
Returns
the edges that are non manifold, i.e. neither boundary or inner edges: they may have more than two incident faces, or two left incident faces for instance.

Referenced by SCENARIO().

◆ computeVertexNormalsFromFaceNormals()

template<typename TRealPoint , typename TRealVector >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeVertexNormalsFromFaceNormals ( )

Uses the normals associated with faces to compute a normal vector to each vertex of the mesh. It simply averages the normals of every incident face.

◆ computeVertexNormalsFromFaceNormalsWithMaxWeights()

template<typename TRealPoint , typename TRealVector >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeVertexNormalsFromFaceNormalsWithMaxWeights ( )

Uses the normals associated with faces to compute a normal vector to each vertex of the mesh. It uses the weights proposed by [84] for combining face information into vertex information.

◆ computeVertexUnitVectorsFromFaceUnitVectors()

template<typename TRealPoint , typename TRealVector >
std::vector< RealVector > DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeVertexUnitVectorsFromFaceUnitVectors ( const std::vector< RealVector > &  fuvectors) const
Parameters
fuvectorsany vector of unit vectors on faces.
Returns
a vector of unit vectors on vertices approximating fuvectors.

◆ computeVertexValuesFromFaceValues()

template<typename TRealPoint , typename TRealVector >
template<typename AnyRing >
std::vector< AnyRing > DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeVertexValuesFromFaceValues ( const std::vector< AnyRing > &  fvalues) const
Parameters
fvaluesany vector of vertex values.
Returns
a vector of vertex values approximating fvalues.
Template Parameters
AnyRingany summable and averagable type.

◆ degree()

template<typename TRealPoint , typename TRealVector >
Size DGtal::SurfaceMesh< TRealPoint, TRealVector >::degree ( const Vertex v) const
inline
Parameters
vany vertex
Returns
the number of neighbors of this vertex

Definition at line 567 of file SurfaceMesh.h.

568 { return myNeighborVertices[ v ].size(); }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myNeighborVertices.

◆ distance()

template<typename TRealPoint , typename TRealVector >
Scalar DGtal::SurfaceMesh< TRealPoint, TRealVector >::distance ( const Vertex  i,
const Vertex  j 
) const
inline
Returns
the Euclidean distance between any two vertices i and j.
Parameters
ifirst vertex
jsecond vertex

Definition at line 692 of file SurfaceMesh.h.

693 {
694 //unrolling for compiler optimization
695 const auto p=this->myPositions[ i ];
696 const auto q=this->myPositions[ j ];
697 return std::sqrt( (p[0]-q[0])*(p[0]-q[0]) + (p[1]-q[1])*(p[1]-q[1])+ (p[2]-q[2])*(p[2]-q[2]));
698 }
std::vector< RealPoint > myPositions
For each vertex, its position.
Definition: SurfaceMesh.h:879

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myPositions.

◆ edgeCentroid()

template<typename TRealPoint , typename TRealVector >
RealPoint DGtal::SurfaceMesh< TRealPoint, TRealVector >::edgeCentroid ( Index  e) const
Parameters
eany valid edge index.
Returns
the centroid (or barycenter) of edge f.

◆ edgeFaces()

template<typename TRealPoint , typename TRealVector >
const Faces & DGtal::SurfaceMesh< TRealPoint, TRealVector >::edgeFaces ( Edge  e) const
inline
Parameters
eany edge
Returns
a const reference to the range giving for edge e its incident faces (one, two, or more if non manifold)

Definition at line 335 of file SurfaceMesh.h.

336 { return myEdgeFaces[ e ]; }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myEdgeFaces.

◆ edgeInclusionRatio()

template<typename TRealPoint , typename TRealVector >
Scalar DGtal::SurfaceMesh< TRealPoint, TRealVector >::edgeInclusionRatio ( RealPoint  p,
Scalar  r,
Index  e 
) const

Computes an approximation of the inclusion ratio of a given edge e with a ball of radius r and center p.

Parameters
pthe center of the ball.
rthe radius of the ball.
eany index of edge.
Returns
the inclusion ratio as a scalar between 0 (no intersection) and 1 (inclusion).
Note
The approximation is estimated by computing the distance of edge vertices and edge midpoint to the ball center and by linear interpolation of the results.

◆ edgeLeftFaces()

template<typename TRealPoint , typename TRealVector >
const Faces & DGtal::SurfaceMesh< TRealPoint, TRealVector >::edgeLeftFaces ( Edge  e) const
inline
Parameters
eany edge
Returns
a const reference to the range giving for edge e its incident faces to its left (zero if open, one, or more if non manifold).
Note
an edge is stored as a vertex pair (i,j), i < j. So a face to its left, being defined ccw, means that the face is some (..., i, j, ... ).

Definition at line 357 of file SurfaceMesh.h.

358 { return myEdgeLeftFaces[ e ]; }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myEdgeLeftFaces.

◆ edgeRightFaces()

template<typename TRealPoint , typename TRealVector >
const Faces & DGtal::SurfaceMesh< TRealPoint, TRealVector >::edgeRightFaces ( Edge  e) const
inline
Parameters
eany edge
Returns
a const reference to the range giving for edge e its incident faces to its right (zero if open, one, or more if non manifold).
Note
an edge is stored as a vertex pair (i,j), i < j. So a face to its right, being defined ccw, means that the face is some (..., j, i, ... ).

Definition at line 346 of file SurfaceMesh.h.

347 { return myEdgeRightFaces[ e ]; }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myEdgeRightFaces.

◆ edgeVertices()

template<typename TRealPoint , typename TRealVector >
const VertexPair & DGtal::SurfaceMesh< TRealPoint, TRealVector >::edgeVertices ( Edge  e) const
inline
Parameters
eany edge
Returns
a const reference to the vector giving for edge e its two vertices (as a pair (i,j), i<j).

Definition at line 329 of file SurfaceMesh.h.

330 { return myEdgeVertices[ e ]; }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myEdgeVertices.

Referenced by DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeManifoldBoundaryChains(), DGtal::SurfaceMesh< TRealPoint, TRealVector >::isBoundariesManifold(), and TEST_CASE().

◆ end()

template<typename TRealPoint , typename TRealVector >
ConstIterator DGtal::SurfaceMesh< TRealPoint, TRealVector >::end ( ) const
inline
Returns
a (non mutable) iterator pointing after the last vertex.

Definition at line 620 of file SurfaceMesh.h.

621 { return ConstIterator( nbVertices() ); }
Size nbVertices() const
Definition: SurfaceMesh.h:280

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::nbVertices().

◆ Euler()

template<typename TRealPoint , typename TRealVector >
long DGtal::SurfaceMesh< TRealPoint, TRealVector >::Euler ( ) const
inline
Returns
the euler characteristic of the triangulated surface (a famous topological invariant that is the number of vertices minus the number of edges plus the number of faces).

Definition at line 294 of file SurfaceMesh.h.

295 { return nbVertices() - nbEdges() + nbFaces(); }
Size nbFaces() const
Definition: SurfaceMesh.h:288
Size nbEdges() const
Definition: SurfaceMesh.h:284

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::nbEdges(), DGtal::SurfaceMesh< TRealPoint, TRealVector >::nbFaces(), and DGtal::SurfaceMesh< TRealPoint, TRealVector >::nbVertices().

Referenced by SCENARIO().

◆ faceArea()

template<typename TRealPoint , typename TRealVector >
Scalar DGtal::SurfaceMesh< TRealPoint, TRealVector >::faceArea ( Index  f) const
Parameters
fany valid face index.
Returns
the area of face f.

◆ faceCentroid()

template<typename TRealPoint , typename TRealVector >
RealPoint DGtal::SurfaceMesh< TRealPoint, TRealVector >::faceCentroid ( Index  f) const
Parameters
fany valid face index.
Returns
the centroid (or barycenter) of face f.

◆ faceInclusionRatio()

template<typename TRealPoint , typename TRealVector >
Scalar DGtal::SurfaceMesh< TRealPoint, TRealVector >::faceInclusionRatio ( RealPoint  p,
Scalar  r,
Index  f 
) const

Computes an approximation of the inclusion ratio of a given face f with a ball of radius r and center p.

Parameters
pthe center of the ball.
rthe radius of the ball.
fany index of face.
Returns
the inclusion ratio as a scalar between 0 (no intersection) and 1 (inclusion).
Note
The approximation is estimated by computing the distance of face vertices and face barycenter to the ball center and by linear interpolation of the results.

◆ faceNormal() [1/2]

template<typename TRealPoint , typename TRealVector >
RealVector & DGtal::SurfaceMesh< TRealPoint, TRealVector >::faceNormal ( Face  f)
inline

Mutable accessor to face normal.

Parameters
fany face.
Returns
the mutable normal associated to f.

Definition at line 677 of file SurfaceMesh.h.

678 { return myFaceNormals[ f ]; }
std::vector< RealVector > myFaceNormals
For each face, its normal vector.
Definition: SurfaceMesh.h:883

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myFaceNormals.

◆ faceNormal() [2/2]

template<typename TRealPoint , typename TRealVector >
const RealVector & DGtal::SurfaceMesh< TRealPoint, TRealVector >::faceNormal ( Face  f) const
inline

Const accessor to face normal.

Parameters
fany face.
Returns
the non-mutable normal associated to f.

Definition at line 683 of file SurfaceMesh.h.

684 { return myFaceNormals[ f ]; }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myFaceNormals.

◆ faceNormals() [1/2]

template<typename TRealPoint , typename TRealVector >
std::vector< RealVector > & DGtal::SurfaceMesh< TRealPoint, TRealVector >::faceNormals ( )
inline
Returns
a reference to the vector of normals to faces.

Definition at line 671 of file SurfaceMesh.h.

672 { return myFaceNormals; }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myFaceNormals.

◆ faceNormals() [2/2]

template<typename TRealPoint , typename TRealVector >
const std::vector< RealVector > & DGtal::SurfaceMesh< TRealPoint, TRealVector >::faceNormals ( ) const
inline
Returns
a const reference to the vector of normals to faces.

Definition at line 667 of file SurfaceMesh.h.

668 { return myFaceNormals; }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myFaceNormals.

◆ getMaxWeights()

template<typename TRealPoint , typename TRealVector >
Scalars DGtal::SurfaceMesh< TRealPoint, TRealVector >::getMaxWeights ( Index  v) const
Parameters
vany valid vertex index.
Returns
the Max's weights for each incident face to v, in the same order as myIncidentFaces[ v ].
Note
Used in computeVertexNormalsFromFaceNormalsWithMaxWeights, see [84]

◆ incidentFaces()

template<typename TRealPoint , typename TRealVector >
const Faces & DGtal::SurfaceMesh< TRealPoint, TRealVector >::incidentFaces ( Vertex  v) const
inline

◆ incidentVertices()

template<typename TRealPoint , typename TRealVector >
const Vertices & DGtal::SurfaceMesh< TRealPoint, TRealVector >::incidentVertices ( Face  f) const
inline

◆ init()

template<typename TRealPoint , typename TRealVector >
template<typename RealPointIterator , typename VerticesIterator >
bool DGtal::SurfaceMesh< TRealPoint, TRealVector >::init ( RealPointIterator  itPos,
RealPointIterator  itPosEnd,
VerticesIterator  itVertices,
VerticesIterator  itVerticesEnd 
)

Initializes a mesh from vertex positions and polygonal faces (clears everything before).

Template Parameters
RealPointIteratorany forward iterator on RealPoint.
VerticesIteratorany forward iterator on a range of vertices.
Parameters
itPosstart of range of iterators pointing on the positions of vertices of the mesh
itPosEndend of range of iterators pointing on the positions of vertices of the mesh.
itVerticesstart of range of iterators pointing on the (oriented) faces of the mesh, each face being a range of vertex indices.
itVerticesEndend of range of iterators pointing on the (oriented) faces of the mesh, each face being a range of vertex indices.

A typical construction usage is

std::vector< RealPoint > positions = { { 0, 0, 5 }, { 1, 1, 3 }, { -1, 1, 3 }, { -1, -1, 3 }, { 1, -1, 3 } };
std::vector< Vertices > faces = { { 0, 1, 2 }, { 0, 2, 3 }, { 0, 3, 4 }, { 0, 4, 1 }, { 4, 3, 2, 1 } };
SurfMesh pyramid_mesh;
pyramid_mesh.init( positions.cbegin(), positions.cend(), faces.cbegin(), faces.cend() );

Referenced by main().

◆ isBoundariesManifold()

template<typename TRealPoint , typename TRealVector >
bool DGtal::SurfaceMesh< TRealPoint, TRealVector >::isBoundariesManifold ( bool  checkClosed = true) const
inline
Returns
true if the boundary edges define a collection of manifold 1d polygonal curves (at most 2 adjecent edges per vertex). If checkClosed is set to true, we also check that all polygonal curves are closed.

The method returns false if the surface mesh has no boundary.

Parameters
checkClosedif true, we check that each vertex has exactly two adejcent edges.

Definition at line 446 of file SurfaceMesh.h.

447 {
448 //computes unordered list of boundary vertices
449 std::map<Vertex,Vertices> adjacent;
450 auto MBE = this->computeManifoldBoundaryEdges();
451 if (MBE.size()==0) return false;
452
453 for (auto e : MBE)
454 {
455 auto ij = this->edgeVertices(e);
456 adjacent[ij.first].push_back(ij.second);
457 if (adjacent[ij.first].size()>2) return false;
458 adjacent[ij.second].push_back(ij.first);
459 if (adjacent[ij.second].size()>2) return false;
460 }
461 //we may check if all curves are closed.
462 if (checkClosed)
463 for(const auto &adj : adjacent)
464 if (adj.second.size() != 2) return false;
465 return true;
466 }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeManifoldBoundaryEdges(), and DGtal::SurfaceMesh< TRealPoint, TRealVector >::edgeVertices().

Referenced by DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeManifoldBoundaryChains().

◆ isValid()

template<typename TRealPoint , typename TRealVector >
bool DGtal::SurfaceMesh< TRealPoint, TRealVector >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

◆ localWindow()

template<typename TRealPoint , typename TRealVector >
Scalar DGtal::SurfaceMesh< TRealPoint, TRealVector >::localWindow ( Face  f) const
Parameters
fany valid face index
Returns
the average distance between the centroid of face f and its vertices.

◆ makeEdge()

template<typename TRealPoint , typename TRealVector >
Edge DGtal::SurfaceMesh< TRealPoint, TRealVector >::makeEdge ( Vertex  i,
Vertex  j 
) const
Parameters
iany vertex of the mesh
jany vertex of the mesh
Returns
the edge index of edge (i,j) or nbEdges() if this edge does not exist.
Note
O(log E) time complexity.

◆ nbEdges()

template<typename TRealPoint , typename TRealVector >
Size DGtal::SurfaceMesh< TRealPoint, TRealVector >::nbEdges ( ) const
inline
Returns
the number of (unordered) edges of the mesh.

Definition at line 284 of file SurfaceMesh.h.

285 { return myEdgeVertices.size(); }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myEdgeVertices.

Referenced by DGtal::SurfaceMesh< TRealPoint, TRealVector >::Euler(), main(), and SCENARIO().

◆ nbFaces()

template<typename TRealPoint , typename TRealVector >
Size DGtal::SurfaceMesh< TRealPoint, TRealVector >::nbFaces ( ) const
inline

◆ nbVertices()

template<typename TRealPoint , typename TRealVector >
Size DGtal::SurfaceMesh< TRealPoint, TRealVector >::nbVertices ( ) const
inline

◆ neighborFaces()

template<typename TRealPoint , typename TRealVector >
const Faces & DGtal::SurfaceMesh< TRealPoint, TRealVector >::neighborFaces ( Face  f) const
inline
Parameters
fany face
Returns
a const reference to the range of neighbor faces for face f.

Definition at line 318 of file SurfaceMesh.h.

319 { return myNeighborFaces[ f ]; }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myNeighborFaces.

◆ neighborVertices()

template<typename TRealPoint , typename TRealVector >
const Vertices & DGtal::SurfaceMesh< TRealPoint, TRealVector >::neighborVertices ( Vertex  v) const
inline
Parameters
vany vertex
Returns
a const reference to the range of neighbor vertices for vertex v.

Definition at line 323 of file SurfaceMesh.h.

324 { return myNeighborVertices[ v ]; }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myNeighborVertices.

Referenced by DGtal::PolygonalCalculus< TRealPoint, TRealVector >::Tv().

◆ operator=()

template<typename TRealPoint , typename TRealVector >
Self & DGtal::SurfaceMesh< TRealPoint, TRealVector >::operator= ( const Self other)
default

Default assignment constructor.

Parameters
otherthe object to clone
Returns
a reference to 'this'.

◆ perturbateWithAdaptiveUniformRandomNoise()

template<typename TRealPoint , typename TRealVector >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::perturbateWithAdaptiveUniformRandomNoise ( Scalar  p)

Perturbate the positions with a uniform random noise of 'p * averageLocalEdgeLength' along arbitrary directions.

Parameters
pany positive real value.

◆ perturbateWithUniformRandomNoise()

template<typename TRealPoint , typename TRealVector >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::perturbateWithUniformRandomNoise ( Scalar  p)

Perturbate the positions with a uniform random noise of 'p * averageEdgeLength' along arbitrary directions.

Parameters
pany positive real value.

◆ position() [1/2]

template<typename TRealPoint , typename TRealVector >
RealPoint & DGtal::SurfaceMesh< TRealPoint, TRealVector >::position ( Vertex  v)
inline

Mutable accessor to vertex position.

Parameters
vany vertex.
Returns
the mutable position associated to v.

Definition at line 637 of file SurfaceMesh.h.

638 { return myPositions[ v ]; }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myPositions.

Referenced by main(), DGtal::PolygonalCalculus< TRealPoint, TRealVector >::PolygonalCalculus(), TEST_CASE(), DGtal::PolygonalCalculus< TRealPoint, TRealVector >::Tf(), and DGtal::PolygonalCalculus< TRealPoint, TRealVector >::Tv().

◆ position() [2/2]

template<typename TRealPoint , typename TRealVector >
const RealPoint & DGtal::SurfaceMesh< TRealPoint, TRealVector >::position ( Vertex  v) const
inline

Const accessor to vertex position.

Parameters
vany vertex.
Returns
the non-mutable position associated to v.

Definition at line 643 of file SurfaceMesh.h.

644 { return myPositions[ v ]; }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myPositions.

◆ positions()

template<typename TRealPoint , typename TRealVector >
const std::vector< RealPoint > & DGtal::SurfaceMesh< TRealPoint, TRealVector >::positions ( ) const
inline
Returns
a const reference to the vector of positions (of vertices).

Definition at line 631 of file SurfaceMesh.h.

632 { return myPositions; }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myPositions.

◆ rand01()

template<typename TRealPoint , typename TRealVector >
static Scalar DGtal::SurfaceMesh< TRealPoint, TRealVector >::rand01 ( )
inlinestaticprotected
Returns
a random number between 0.0 and 1.0

Definition at line 918 of file SurfaceMesh.h.

919 { return (Scalar) rand() / (Scalar) RAND_MAX; }
RealVector::Component Scalar
Definition: SurfaceMesh.h:100

◆ selfDisplay()

template<typename TRealPoint , typename TRealVector >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

◆ setFaceNormals()

template<typename TRealPoint , typename TRealVector >
template<typename RealVectorIterator >
bool DGtal::SurfaceMesh< TRealPoint, TRealVector >::setFaceNormals ( RealVectorIterator  itN,
RealVectorIterator  itNEnd 
)

Given a range of real vectors, sets the normals of every face to the given vectors.

◆ setVertexNormals()

template<typename TRealPoint , typename TRealVector >
template<typename RealVectorIterator >
bool DGtal::SurfaceMesh< TRealPoint, TRealVector >::setVertexNormals ( RealVectorIterator  itN,
RealVectorIterator  itNEnd 
)

Given a range of real vectors, sets the normals of every vertex to the given vectors.

◆ size()

template<typename TRealPoint , typename TRealVector >
Size DGtal::SurfaceMesh< TRealPoint, TRealVector >::size ( ) const
inline
Returns
the number of vertices of the surface.

Definition at line 550 of file SurfaceMesh.h.

551 { return nbVertices(); }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::nbVertices().

◆ vertexInclusionRatio()

template<typename TRealPoint , typename TRealVector >
Scalar DGtal::SurfaceMesh< TRealPoint, TRealVector >::vertexInclusionRatio ( RealPoint  p,
Scalar  r,
Index  v 
) const

Computes the inclusion ratio of a given vertex v with a ball of radius r and center p.

Parameters
pthe center of the ball.
rthe radius of the ball.
vany index of vertex.
Returns
the inclusion ratio as a scalar, either 0 (no intersection) or 1 (inclusion).

◆ vertexNormal() [1/2]

template<typename TRealPoint , typename TRealVector >
RealVector & DGtal::SurfaceMesh< TRealPoint, TRealVector >::vertexNormal ( Vertex  v)
inline

Mutable accessor to vertex normal.

Parameters
vany vertex.
Returns
the mutable normal associated to v.

Definition at line 657 of file SurfaceMesh.h.

658 { return myVertexNormals[ v ]; }
std::vector< RealVector > myVertexNormals
For each vertex, its normal vector.
Definition: SurfaceMesh.h:881

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myVertexNormals.

◆ vertexNormal() [2/2]

template<typename TRealPoint , typename TRealVector >
const RealVector & DGtal::SurfaceMesh< TRealPoint, TRealVector >::vertexNormal ( Vertex  v) const
inline

Const accessor to vertex normal.

Parameters
vany vertex.
Returns
the non-mutable normal associated to v.

Definition at line 663 of file SurfaceMesh.h.

664 { return myVertexNormals[ v ]; }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myVertexNormals.

◆ vertexNormals() [1/2]

template<typename TRealPoint , typename TRealVector >
std::vector< RealVector > & DGtal::SurfaceMesh< TRealPoint, TRealVector >::vertexNormals ( )
inline
Returns
a reference to the vector of normals to vertices.

Definition at line 651 of file SurfaceMesh.h.

652 { return myVertexNormals; }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myVertexNormals.

◆ vertexNormals() [2/2]

template<typename TRealPoint , typename TRealVector >
const std::vector< RealVector > & DGtal::SurfaceMesh< TRealPoint, TRealVector >::vertexNormals ( ) const
inline
Returns
a const reference to the vector of normals to vertices.

Definition at line 647 of file SurfaceMesh.h.

648 { return myVertexNormals; }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myVertexNormals.

◆ writeNeighbors() [1/2]

template<typename TRealPoint , typename TRealVector >
template<typename OutputIterator >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::writeNeighbors ( OutputIterator &  it,
const Vertex v 
) const
inline

Writes the neighbors of a vertex using an output iterator

Template Parameters
OutputIteratorthe type of an output iterator writing in a container of vertices.
Parameters
itthe output iterator
vthe vertex whose neighbors will be writen

Definition at line 582 of file SurfaceMesh.h.

584 {
585 for ( auto&& nv : myNeighborVertices[ v ] )
586 *it++ = nv;
587 }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myNeighborVertices.

◆ writeNeighbors() [2/2]

template<typename TRealPoint , typename TRealVector >
template<typename OutputIterator , typename VertexPredicate >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::writeNeighbors ( OutputIterator &  it,
const Vertex v,
const VertexPredicate &  pred 
) const
inline

Writes the neighbors of a vertex which satisfy a predicate using an output iterator

Template Parameters
OutputIteratorthe type of an output iterator writing in a container of vertices.
VertexPredicatethe type of the predicate
Parameters
itthe output iterator
vthe vertex whose neighbors will be written
predthe predicate that must be satisfied

Definition at line 607 of file SurfaceMesh.h.

610 {
611 for ( auto&& nv : myNeighborVertices[ v ] )
612 if ( pred( nv ) ) *it++ = nv;
613 }

References DGtal::SurfaceMesh< TRealPoint, TRealVector >::myNeighborVertices.

Field Documentation

◆ dimension

template<typename TRealPoint , typename TRealVector >
const Dimension DGtal::SurfaceMesh< TRealPoint, TRealVector >::dimension = RealPoint::dimension
static

Definition at line 97 of file SurfaceMesh.h.

◆ myEdgeFaces

template<typename TRealPoint , typename TRealVector >
std::vector< Faces > DGtal::SurfaceMesh< TRealPoint, TRealVector >::myEdgeFaces
protected

For each edge, its faces (one, two, or more if non manifold)

Definition at line 891 of file SurfaceMesh.h.

Referenced by DGtal::SurfaceMesh< TRealPoint, TRealVector >::allEdgeFaces(), and DGtal::SurfaceMesh< TRealPoint, TRealVector >::edgeFaces().

◆ myEdgeLeftFaces

template<typename TRealPoint , typename TRealVector >
std::vector< Faces > DGtal::SurfaceMesh< TRealPoint, TRealVector >::myEdgeLeftFaces
protected

For each edge, its faces to its left (zero if open, one, or more if non manifold).

Note
an edge is stored as a vertex pair (i,j), i < j. So a face to its left, being defined ccw, means that the face is some (..., i, j, ... ).

Definition at line 903 of file SurfaceMesh.h.

Referenced by DGtal::SurfaceMesh< TRealPoint, TRealVector >::allEdgeLeftFaces(), and DGtal::SurfaceMesh< TRealPoint, TRealVector >::edgeLeftFaces().

◆ myEdgeRightFaces

template<typename TRealPoint , typename TRealVector >
std::vector< Faces > DGtal::SurfaceMesh< TRealPoint, TRealVector >::myEdgeRightFaces
protected

For each edge, its faces to its right (zero if open, one, or more if non manifold).

Note
an edge is stored as a vertex pair (i,j), i < j. So a face to its right, being defined ccw, means that the face is some (..., j, i, ... ).

Definition at line 897 of file SurfaceMesh.h.

Referenced by DGtal::SurfaceMesh< TRealPoint, TRealVector >::allEdgeRightFaces(), and DGtal::SurfaceMesh< TRealPoint, TRealVector >::edgeRightFaces().

◆ myEdgeVertices

template<typename TRealPoint , typename TRealVector >
std::vector< VertexPair > DGtal::SurfaceMesh< TRealPoint, TRealVector >::myEdgeVertices
protected

◆ myFaceNormals

template<typename TRealPoint , typename TRealVector >
std::vector< RealVector > DGtal::SurfaceMesh< TRealPoint, TRealVector >::myFaceNormals
protected

◆ myIncidentFaces

template<typename TRealPoint , typename TRealVector >
std::vector< Faces > DGtal::SurfaceMesh< TRealPoint, TRealVector >::myIncidentFaces
protected

◆ myIncidentVertices

template<typename TRealPoint , typename TRealVector >
std::vector< Vertices > DGtal::SurfaceMesh< TRealPoint, TRealVector >::myIncidentVertices
protected

◆ myNeighborFaces

template<typename TRealPoint , typename TRealVector >
std::vector< Faces > DGtal::SurfaceMesh< TRealPoint, TRealVector >::myNeighborFaces
protected

For each face, its range of neighbor faces (no particular order)

Definition at line 885 of file SurfaceMesh.h.

Referenced by DGtal::SurfaceMesh< TRealPoint, TRealVector >::allNeighborFaces(), and DGtal::SurfaceMesh< TRealPoint, TRealVector >::neighborFaces().

◆ myNeighborVertices

template<typename TRealPoint , typename TRealVector >
std::vector< Vertices > DGtal::SurfaceMesh< TRealPoint, TRealVector >::myNeighborVertices
protected

◆ myPositions

template<typename TRealPoint , typename TRealVector >
std::vector< RealPoint > DGtal::SurfaceMesh< TRealPoint, TRealVector >::myPositions
protected

◆ myVertexNormals

template<typename TRealPoint , typename TRealVector >
std::vector< RealVector > DGtal::SurfaceMesh< TRealPoint, TRealVector >::myVertexNormals
protected

The documentation for this struct was generated from the following file: