DGtal 1.4.0
Loading...
Searching...
No Matches
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.
 
typedef std::size_t Index
 The type used for numbering vertices and faces.
 
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)
 
typedef std::vector< EdgeEdges
 The type that defines a list/range of edges.
 
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.
 

Public Member Functions

 BOOST_STATIC_ASSERT ((dimension==3))
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 
Standard services
 ~SurfaceMesh ()=default
 Default destructor.
 
 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.
 
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 computeFaceNormalFromPositions (const Face f)
 
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
 
VertexPair edgeVertices (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
 
Mesh editing services
bool isFlippable (const Edge e) const
 
VertexPair otherDiagonal (const Edge e) const
 
void flip (const Edge e, bool recompute_face_normals=false)
 
Look-up table computation services
void computeNeighbors ()
 Computes neighboring information.
 
void computeEdges ()
 Computes edge information.
 

Static Public Attributes

static const Dimension dimension = RealPoint::dimension
 

Protected Member Functions

void removeIndex (std::vector< Index > &v, Index i)
 
void replaceIndex (std::vector< Index > &v, Index i, Index ri)
 
void addIndex (std::vector< Index > &v, Index i)
 

Static Protected Member Functions

static Scalar rand01 ()
 

Protected Attributes

std::vector< VerticesmyIncidentVertices
 For each face, its range of incident vertices.
 
std::vector< FacesmyIncidentFaces
 For each vertex, its range of incident faces.
 
std::vector< RealPointmyPositions
 For each vertex, its position.
 
std::vector< RealVectormyVertexNormals
 For each vertex, its normal vector.
 
std::vector< RealVectormyFaceNormals
 For each face, its normal vector.
 
std::vector< FacesmyNeighborFaces
 For each face, its range of neighbor faces (no particular order)
 
std::vector< VerticesmyNeighborVertices
 For each vertex, its range of neighbor vertices (no particular order)
 
std::vector< VertexPairmyEdgeVertices
 For each edge, its two vertices.
 
std::map< VertexPair, EdgemyVertexPairEdge
 For each vertex pair, its edge index.
 
std::vector< FacesmyEdgeFaces
 For each edge, its faces (one, two, or more if non manifold)
 
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:

  • Mesh represents soaps of triangles with traversal operations but without any link between vertices;
  • TriangulatedSurface represents 2-manifold triangulated meshes, possibly with boundaries, and provides traversal and neighborhood operations (underlying fast index representation);
  • PolygonalSurface represents 2-manifold polygonal meshes, possibly with boundaries, and provides traversal and neighborhood operations (underlying fast index representation);
  • SurfaceMesh represents arbitrary sets of faces with possible connexions between faces, edges and vertices, provides traversal and neighborhood operations (underlying fast index representation), and may represent non manifold meshes.
  • DigitalSurface is a common interface to represent arbitrary digital surfaces, i.e. boundaries of sets of voxels or interfaces between such sets;
  • IndexedDigitalSurface is a common interface to represent arbitrary digital surfaces, i.e. boundaries of sets of voxels or interfaces between such sets, but with underlying fast index representation.

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() );
SurfaceMesh< RealPoint, RealVector > SurfMesh
const std::vector< RealPoint > & positions() const

◆ 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

◆ addIndex()

template<typename TRealPoint , typename TRealVector >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::addIndex ( std::vector< Index > & v,
Index i )
inlineprotected

Adds the index i to the vector v.

Parameters
[in,out]va vector of indices
[in]ian index

Definition at line 1047 of file SurfaceMesh.h.

1048 {
1049 v.push_back( i );
1050 }

◆ 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 396 of file SurfaceMesh.h.

397 { return myEdgeFaces; }
std::vector< Faces > myEdgeFaces
For each edge, its faces (one, two, or more if non manifold)

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 416 of file SurfaceMesh.h.

417 { return myEdgeLeftFaces; }
std::vector< Faces > myEdgeLeftFaces

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 406 of file SurfaceMesh.h.

407 { return myEdgeRightFaces; }
std::vector< Faces > myEdgeRightFaces

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 vector giving for each edge its two vertices (as a pair (i,j), i<j).
Note
Since 1.4, order is not significant (this is to allow flip and modification in the surface mesh).

Definition at line 391 of file SurfaceMesh.h.

392 { return myEdgeVertices; }
std::vector< VertexPair > myEdgeVertices
For each edge, its two vertices.

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 376 of file SurfaceMesh.h.

377 { return myIncidentFaces; }
std::vector< Faces > myIncidentFaces
For each vertex, its range of incident faces.

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 371 of file SurfaceMesh.h.

372 { return myIncidentVertices; }
std::vector< Vertices > myIncidentVertices
For each face, its range of incident vertices.

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 380 of file SurfaceMesh.h.

381 { return myNeighborFaces; }
std::vector< Faces > myNeighborFaces
For each face, its range of neighbor faces (no particular order)

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 384 of file SurfaceMesh.h.

385 { return myNeighborVertices; }
std::vector< Vertices > myNeighborVertices
For each vertex, its range of neighbor vertices (no particular order)

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 626 of file SurfaceMesh.h.

627 { return ConstIterator( 0 ); }
IntegerSequenceIterator< Vertex > ConstIterator
Non mutable iterator for visiting vertices.

◆ 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 569 of file SurfaceMesh.h.

570 { 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 ( )

Computes edge information.

◆ computeFaceNormalFromPositions()

template<typename TRealPoint , typename TRealVector >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::computeFaceNormalFromPositions ( const Face f)

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

Parameters
fany valid index of face.

◆ 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 483 of file SurfaceMesh.h.

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

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 main(), and 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 [86] 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 577 of file SurfaceMesh.h.

578 { 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 702 of file SurfaceMesh.h.

703 {
704 //unrolling for compiler optimization
705 const auto p=this->myPositions[ i ];
706 const auto q=this->myPositions[ j ];
707 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]));
708 }
std::vector< RealPoint > myPositions
For each vertex, its position.

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 344 of file SurfaceMesh.h.

345 { 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 366 of file SurfaceMesh.h.

367 { 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 355 of file SurfaceMesh.h.

356 { return myEdgeRightFaces[ e ]; }

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

◆ edgeVertices()

template<typename TRealPoint , typename TRealVector >
VertexPair DGtal::SurfaceMesh< TRealPoint, TRealVector >::edgeVertices ( Edge e) const
inline
Parameters
eany edge
Returns
a pair giving for edge e its two vertices (as a pair (i,j), i<j).
Note
if the edge is not valid, return {0,0}.

Definition at line 338 of file SurfaceMesh.h.

339 { return myEdgeVertices[ e ]; }

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

Referenced by computeLaplace(), 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 630 of file SurfaceMesh.h.

631 { return ConstIterator( nbVertices() ); }
Size nbVertices() const

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 302 of file SurfaceMesh.h.

303 { return nbVertices() - nbEdges() + nbFaces(); }
Size nbFaces() const
Size nbEdges() const

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.

Referenced by precompute().

◆ 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 687 of file SurfaceMesh.h.

688 { return myFaceNormals[ f ]; }
std::vector< RealVector > myFaceNormals
For each face, its normal vector.

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

Referenced by precompute().

◆ 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 693 of file SurfaceMesh.h.

694 { 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 681 of file SurfaceMesh.h.

682 { 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 677 of file SurfaceMesh.h.

678 { return myFaceNormals; }

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

◆ flip()

template<typename TRealPoint , typename TRealVector >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::flip ( const Edge e,
bool recompute_face_normals = false )

Flip the edge e. Be careful that after the flip, this edge index determines another edge, which is the other diagonal of the quadrilateral having e as its diagonal.

      l                   l
     / \                 /|\
    /   \               / | \
   /     \             /  |  \
  /   lf  \           /   |   \
 /         \         /    |    \
i --- e --- j  ==>  i  lf e  rf j    if k < l otherwise rf and lf are swapped
 \         /         \    |    /
  \   rf  /           \   |   /
   \     /             \  |  /
    \   /               \ | /
     \ /                 \|/
      k                   k
Parameters
eany valid edge.
recompute_face_normalswhen 'true', recompute normals of flipped faces with the positions of the vertices.
Precondition
the edge must be flippable, isFlippable( e ) == true
Postcondition
After the flip, the edge index e corresponds to the index of the flipped edge (if you reflip it you get your former configuration).
Note
Time complexity is O(log n), due to the updating of surrounding edges information.
Warning
For performance reasons, The neighbor faces of each face are not recomputed. One should call computeNeighbors to recompute them. However the neighbor vertices to each vertex are recomputed.
Vertex normals are not recomputed, but face normals may be recomputed if asked for. The face normals are then the geometric normals of triangles.

◆ 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 [86]

◆ incidentFaces()

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

◆ incidentVertices()

◆ 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 456 of file SurfaceMesh.h.

457 {
458 // computes unordered list of boundary vertices
459 std::map<Vertex,Vertices> adjacent;
460 auto MBE = this->computeManifoldBoundaryEdges();
461 if ( MBE.size() == 0 ) return false;
462
463 for (auto e : MBE)
464 {
465 auto ij = this->edgeVertices(e);
466 adjacent[ ij.first ].push_back( ij.second );
467 if ( adjacent[ ij.first ] .size() > 2 ) return false;
468 adjacent[ ij.second ].push_back( ij.first );
469 if ( adjacent[ ij.second ].size() > 2 ) return false;
470 }
471 //we may check if all curves are closed.
472 if ( checkClosed )
473 for ( const auto &adj : adjacent )
474 if ( adj.second.size() != 2 ) return false;
475 return true;
476 }

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

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

◆ isFlippable()

template<typename TRealPoint , typename TRealVector >
bool DGtal::SurfaceMesh< TRealPoint, TRealVector >::isFlippable ( const Edge e) const

An edge is (topologically) flippable iff: (1) it does not lie on the boundary, (2) it is bordered by two triangles, one that to its right, one to its left, (3) the two other vertices of the quad are not already neighbors, (4) the edge is not bordered by the same two triangles, in opposite orientation.

Parameters
eany edge.
Returns
'true' if the edge e is topologically flippable.
Note
Time complexity is O(1).

◆ 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 292 of file SurfaceMesh.h.

293 { return myEdgeVertices.size(); }

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

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

◆ nbFaces()

◆ nbVertices()

◆ 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 326 of file SurfaceMesh.h.

327 { 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 331 of file SurfaceMesh.h.

332 { 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'.

◆ otherDiagonal()

template<typename TRealPoint , typename TRealVector >
VertexPair DGtal::SurfaceMesh< TRealPoint, TRealVector >::otherDiagonal ( const Edge e) const
Precondition
isFlippable( e ) must be true.
Parameters
eany edge.
Returns
the two other vertices of the quadrilateral around the edge e.

◆ 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]

◆ 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 653 of file SurfaceMesh.h.

654 { 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 641 of file SurfaceMesh.h.

642 { 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 1054 of file SurfaceMesh.h.

1055 { return (Scalar) rand() / (Scalar) RAND_MAX; }
RealVector::Component Scalar

◆ removeIndex()

template<typename TRealPoint , typename TRealVector >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::removeIndex ( std::vector< Index > & v,
Index i )
inlineprotected

Removes the index i from the vector v.

Parameters
[in,out]va vector of indices
[in]ian index

Definition at line 1009 of file SurfaceMesh.h.

1010 {
1011 const std::size_t n = v.size();
1012 for ( std::size_t j = 0; j < n; j++ )
1013 if ( v[ j ] == i )
1014 {
1015 std::swap( v[ j ], v.back() );
1016 v.resize( n - 1 );
1017 return;
1018 }
1019 trace.error() << "[SurfaceMesh::removeIndex] Index " << i
1020 << " is not in vector:";
1021 for ( auto e : v ) std::cerr << " " << e;
1022 std::cerr << std::endl;
1023 }
std::ostream & error()
Trace trace
Definition Common.h:153
STL namespace.

References DGtal::Trace::error(), and DGtal::trace.

◆ replaceIndex()

template<typename TRealPoint , typename TRealVector >
void DGtal::SurfaceMesh< TRealPoint, TRealVector >::replaceIndex ( std::vector< Index > & v,
Index i,
Index ri )
inlineprotected

Replaces the index i with the index ri in the vector v.

Parameters
[in,out]va vector of indices
[in]ian index
[in]rian index

Definition at line 1029 of file SurfaceMesh.h.

1030 {
1031 const std::size_t n = v.size();
1032 for ( std::size_t j = 0; j < n; j++ )
1033 if ( v[ j ] == i )
1034 {
1035 v[ j ] = ri;
1036 return;
1037 }
1038 trace.error() << "[SurfaceMesh::replaceIndex] Index " << i
1039 << " (subs=" << ri << ") is not in vector:";
1040 for ( auto e : v ) std::cerr << " " << e;
1041 std::cerr << std::endl;
1042 }

References DGtal::Trace::error(), and DGtal::trace.

◆ 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.

Referenced by main().

◆ 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 560 of file SurfaceMesh.h.

561 { 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 667 of file SurfaceMesh.h.

668 { return myVertexNormals[ v ]; }
std::vector< RealVector > myVertexNormals
For each vertex, its normal vector.

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 673 of file SurfaceMesh.h.

674 { 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 661 of file SurfaceMesh.h.

662 { 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 657 of file SurfaceMesh.h.

658 { 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 592 of file SurfaceMesh.h.

594 {
595 for ( auto&& nv : myNeighborVertices[ v ] )
596 *it++ = nv;
597 }

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 617 of file SurfaceMesh.h.

620 {
621 for ( auto&& nv : myNeighborVertices[ v ] )
622 if ( pred( nv ) ) *it++ = nv;
623 }

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 985 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 997 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 991 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 977 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

◆ myVertexPairEdge

template<typename TRealPoint , typename TRealVector >
std::map< VertexPair,Edge > DGtal::SurfaceMesh< TRealPoint, TRealVector >::myVertexPairEdge
protected

For each vertex pair, its edge index.

Definition at line 983 of file SurfaceMesh.h.


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