31#if defined(SurfaceMesh_RECURSES)
32#error Recursive header files inclusion detected in SurfaceMesh.h
35#define SurfaceMesh_RECURSES
37#if !defined SurfaceMesh_h
46#include "DGtal/base/Common.h"
47#include "DGtal/base/IntegerSequenceIterator.h"
48#include "DGtal/helpers/StdDefs.h"
90 template <
typename TRealPo
int,
typename TRealVector >
123 typedef typename std::map<Vertex, Value>
Type;
178 template <
typename RealPo
intIterator,
typename VerticesIterator>
180 VerticesIterator itVertices, VerticesIterator itVerticesEnd );
203 template <
typename RealPo
intIterator,
typename VerticesIterator>
204 bool init( RealPointIterator itPos, RealPointIterator itPosEnd,
205 VerticesIterator itVertices, VerticesIterator itVerticesEnd );
219 template <
typename RealVectorIterator>
224 template <
typename RealVectorIterator>
251 template <
typename AnyRing>
253 (
const std::vector<AnyRing>& vvalues )
const;
258 template <
typename AnyRing>
260 (
const std::vector<AnyRing>& fvalues )
const;
265 (
const std::vector<RealVector>& vuvectors )
const;
270 (
const std::vector<RealVector>& fuvectors )
const;
449 std::map<Vertex,Vertices> adjacent;
451 if (MBE.size()==0)
return false;
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;
463 for(
const auto &adj : adjacent)
464 if (adj.second.size() != 2)
return false;
475 std::vector<Vertices> boundaries;
478 std::map<Vertex,bool> visited;
479 std::map<Vertex,Vertices> adjacent;
481 ASSERT_MSG(MBE.size()>0,
"The surface mesh must have boundary edges");
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);
494 auto boundary_it = visited.begin();
496 while(boundary_it != visited.end() )
498 Vertex first = (*boundary_it).first;
499 visited[first] =
true;
501 boundary.push_back(first);
507 while ((!pushed) && (nb_iter < MBE.size()*2))
510 for (
auto other : adjacent[current])
513 boundary.push_back(other);
515 visited[other] =
true;
522 for (
auto other : adjacent[current])
525 boundaries.push_back(boundary);
534 boundary_it = std::find_if(visited.begin(), visited.end(),
536 (std::pair<Vertex,bool> x){return !x.second;});
580 template <
typename OutputIterator>
605 template <
typename OutputIterator,
typename VertexPredicate>
609 const VertexPredicate & pred)
const
612 if ( pred( nv ) ) *it++ = nv;
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]));
792 std::tuple< Vertices, WeightedEdges, WeightedFaces >
811 std::tuple< Vertices, WeightedEdges, WeightedFaces >
929 template <
typename TRealPo
int,
typename TRealVector >
938#include "SurfaceMesh.ih"
944#undef SurfaceMesh_RECURSES
Aim: It is a simple class that mimics a (non mutable) iterator over integers. You can increment it,...
TEuclideanRing Component
Type for Vector elements.
static const Dimension dimension
Copy of the static dimension of the Point/Vector.
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::uint32_t Dimension
std::map< Vertex, Value > Type
Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces ...
std::vector< WeightedEdge > WeightedEdges
const Faces & incidentFaces(Vertex v) const
void writeNeighbors(OutputIterator &it, const Vertex &v, const VertexPredicate &pred) const
WeightedFaces computeFacesInclusionsInBall(Scalar r, Index f, RealPoint p) const
std::pair< Vertex, Vertex > VertexPair
Scalar edgeInclusionRatio(RealPoint p, Scalar r, Index e) const
RealVector & vertexNormal(Vertex v)
RealVector & faceNormal(Face f)
Edges computeManifoldInnerUnconsistentEdges() const
const std::vector< Faces > & allIncidentFaces() const
SurfaceMesh(RealPointIterator itPos, RealPointIterator itPosEnd, VerticesIterator itVertices, VerticesIterator itVerticesEnd)
SurfaceMesh(const Self &other)=default
void perturbateWithAdaptiveUniformRandomNoise(Scalar p)
bool setVertexNormals(RealVectorIterator itN, RealVectorIterator itNEnd)
std::vector< Vertex > Vertices
The type that defines a list/range of vertices (e.g. to define faces)
Edges computeManifoldInnerEdges() const
std::vector< Faces > myNeighborFaces
For each face, its range of neighbor faces (no particular order)
RealPoint faceCentroid(Index f) const
std::vector< Scalar > Scalars
const VertexPair & edgeVertices(Edge e) const
const std::vector< RealVector > & vertexNormals() const
void computeEdges()
Computes edge information.
SurfaceMesh< RealPoint, RealVector > Self
static const Dimension dimension
Scalars getMaxWeights(Index v) const
std::vector< WeightedFace > WeightedFaces
std::vector< RealVector > & faceNormals()
Scalar localWindow(Face f) const
void perturbateWithUniformRandomNoise(Scalar p)
Scalar faceArea(Index f) const
std::vector< Faces > myIncidentFaces
For each vertex, its range of incident faces.
void computeFaceNormalsFromPositions()
std::vector< Faces > myEdgeRightFaces
const Faces & edgeFaces(Edge e) const
bool isBoundariesManifold(bool checkClosed=true) const
ConstIterator begin() const
void computeVertexNormalsFromFaceNormals()
const Faces & neighborFaces(Face f) const
std::size_t Index
The type used for numbering vertices and faces.
~SurfaceMesh()=default
Default destructor.
const Vertices & neighborVertices(Vertex v) const
IntegerSequenceIterator< Vertex > ConstIterator
Non mutable iterator for visiting vertices.
std::vector< Vertices > myNeighborVertices
For each vertex, its range of neighbor vertices (no particular order)
BOOST_STATIC_ASSERT((dimension==3))
std::vector< Edge > Edges
The type that defines a list/range of edges.
std::pair< Face, Scalar > WeightedFace
const Faces & edgeLeftFaces(Edge e) const
const Vertices & incidentVertices(Face f) const
const std::vector< RealVector > & faceNormals() const
std::vector< RealVector > computeVertexUnitVectorsFromFaceUnitVectors(const std::vector< RealVector > &fuvectors) const
std::vector< Faces > myEdgeFaces
For each edge, its faces (one, two, or more if non manifold)
Scalar distance(const Vertex i, const Vertex j) const
void computeVertexNormalsFromFaceNormalsWithMaxWeights()
std::set< Vertex > VertexSet
bool setFaceNormals(RealVectorIterator itN, RealVectorIterator itNEnd)
SurfaceMesh(Self &&other)=default
Scalar faceInclusionRatio(RealPoint p, Scalar r, Index f) const
std::size_t Size
The type for counting elements.
const std::vector< RealPoint > & positions() const
std::vector< AnyRing > computeVertexValuesFromFaceValues(const std::vector< AnyRing > &fvalues) const
std::tuple< Vertices, WeightedEdges, WeightedFaces > computeCellsInclusionsInBall(Scalar r, Index f) const
Edges computeManifoldBoundaryEdges() const
Edges computeManifoldInnerConsistentEdges() const
const std::vector< Faces > & allEdgeLeftFaces() const
Size bestCapacity() const
WeightedFaces computeFacesInclusionsInBall(Scalar r, Index f) const
const RealVector & faceNormal(Face f) const
const std::vector< Vertices > & allNeighborVertices() const
const std::vector< Vertices > & allIncidentVertices() const
bool init(RealPointIterator itPos, RealPointIterator itPosEnd, VerticesIterator itVertices, VerticesIterator itVerticesEnd)
Self & operator=(const Self &other)=default
RealVector::Component Scalar
Edge makeEdge(Vertex i, Vertex j) const
RealPoint & position(Vertex v)
std::vector< AnyRing > computeFaceValuesFromVertexValues(const std::vector< AnyRing > &vvalues) const
Size degree(const Vertex &v) const
RealPoint edgeCentroid(Index e) const
void computeFaceNormalsFromVertexNormals()
std::vector< RealVector > computeFaceUnitVectorsFromVertexUnitVectors(const std::vector< RealVector > &vuvectors) const
std::vector< VertexPair > myEdgeVertices
For each edge, its two vertices.
void clear()
Clears everything. The object is empty.
Edges computeNonManifoldEdges() const
const RealVector & vertexNormal(Vertex v) const
std::vector< RealVector > myFaceNormals
For each face, its normal vector.
std::tuple< Vertices, WeightedEdges, WeightedFaces > computeCellsInclusionsInBall(Scalar r, Index f, RealPoint p) const
ConstIterator end() const
std::vector< Face > Faces
const std::vector< Faces > & allEdgeRightFaces() const
std::pair< Edge, Scalar > WeightedEdge
void computeNeighbors()
Computes neighboring information.
std::vector< Vertices > myIncidentVertices
For each face, its range of incident vertices.
std::vector< Faces > myEdgeLeftFaces
std::vector< RealVector > myVertexNormals
For each vertex, its normal vector.
const RealPoint & position(Vertex v) const
const std::vector< VertexPair > & allEdgeVertices() const
std::vector< RealVector > & vertexNormals()
const Faces & edgeRightFaces(Edge e) const
std::vector< RealPoint > myPositions
For each vertex, its position.
std::vector< Vertices > computeManifoldBoundaryChains() const
void writeNeighbors(OutputIterator &it, const Vertex &v) const
Scalar averageEdgeLength() const
const std::vector< Faces > & allEdgeFaces() const
Scalar vertexInclusionRatio(RealPoint p, Scalar r, Index v) const
const std::vector< Faces > & allNeighborFaces() const
void selfDisplay(std::ostream &out) const