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>
259 template <
typename AnyRing>
261 (
const std::vector<AnyRing>& vvalues )
const;
266 template <
typename AnyRing>
268 (
const std::vector<AnyRing>& fvalues )
const;
273 (
const std::vector<RealVector>& vuvectors )
const;
278 (
const std::vector<RealVector>& fuvectors )
const;
459 std::map<Vertex,Vertices> adjacent;
461 if ( MBE.size() == 0 )
return false;
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;
473 for (
const auto &adj : adjacent )
474 if ( adj.second.size() != 2 )
return false;
485 std::vector<Vertices> boundaries;
488 std::map<Vertex,bool> visited;
489 std::map<Vertex,Vertices> adjacent;
491 ASSERT_MSG(MBE.size()>0,
"The surface mesh must have boundary edges");
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);
504 auto boundary_it = visited.begin();
506 while(boundary_it != visited.end() )
508 Vertex first = (*boundary_it).first;
509 visited[first] =
true;
511 boundary.push_back(first);
517 while ((!pushed) && (nb_iter < MBE.size()*2))
520 for (
auto other : adjacent[current])
523 boundary.push_back(other);
525 visited[other] =
true;
532 for (
auto other : adjacent[current])
535 boundaries.push_back(boundary);
544 boundary_it = std::find_if(visited.begin(), visited.end(),
546 (std::pair<Vertex,bool> x){return !x.second;});
590 template <
typename OutputIterator>
615 template <
typename OutputIterator,
typename VertexPredicate>
619 const VertexPredicate & pred)
const
622 if ( pred( nv ) ) *it++ = nv;
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]));
802 std::tuple< Vertices, WeightedEdges, WeightedFaces >
821 std::tuple< Vertices, WeightedEdges, WeightedFaces >
933 void flip(
const Edge e,
bool recompute_face_normals =
false );
1011 const std::size_t n = v.size();
1012 for ( std::size_t j = 0; j < n; j++ )
1015 std::swap( v[ j ], v.back() );
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;
1031 const std::size_t n = v.size();
1032 for ( std::size_t j = 0; j < n; j++ )
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;
1065 template <
typename TRealPo
int,
typename TRealVector >
1074 #include "SurfaceMesh.ih"
1080 #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.
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &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
void writeNeighbors(OutputIterator &it, const Vertex &v, const VertexPredicate &pred) const
std::vector< RealVector > & faceNormals()
WeightedFaces computeFacesInclusionsInBall(Scalar r, Index f, RealPoint p) const
const Faces & neighborFaces(Face f) const
std::pair< Vertex, Vertex > VertexPair
Scalar edgeInclusionRatio(RealPoint p, Scalar r, Index e) const
Edges computeManifoldInnerUnconsistentEdges() const
RealPoint & position(Vertex v)
SurfaceMesh(RealPointIterator itPos, RealPointIterator itPosEnd, VerticesIterator itVertices, VerticesIterator itVerticesEnd)
SurfaceMesh(const Self &other)=default
std::vector< RealVector > computeVertexUnitVectorsFromFaceUnitVectors(const std::vector< RealVector > &fuvectors) const
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 std::vector< Faces > & allEdgeRightFaces() const
void computeEdges()
Computes edge information.
SurfaceMesh< RealPoint, RealVector > Self
const std::vector< RealVector > & faceNormals() const
static const Dimension dimension
Scalars getMaxWeights(Index v) const
std::vector< WeightedFace > WeightedFaces
const Faces & edgeFaces(Edge e) const
Scalar localWindow(Face f) const
void perturbateWithUniformRandomNoise(Scalar p)
void replaceIndex(std::vector< Index > &v, Index i, Index ri)
const std::vector< RealVector > & vertexNormals() const
Scalar faceArea(Index f) const
void addIndex(std::vector< Index > &v, Index i)
std::vector< Faces > myIncidentFaces
For each vertex, its range of incident faces.
void computeFaceNormalsFromPositions()
std::vector< Faces > myEdgeRightFaces
std::vector< AnyRing > computeFaceValuesFromVertexValues(const std::vector< AnyRing > &vvalues) const
const std::vector< RealPoint > & positions() const
bool isBoundariesManifold(bool checkClosed=true) const
RealVector & vertexNormal(Vertex v)
ConstIterator begin() const
std::vector< AnyRing > computeVertexValuesFromFaceValues(const std::vector< AnyRing > &fvalues) const
void computeVertexNormalsFromFaceNormals()
RealVector & faceNormal(Face f)
std::size_t Index
The type used for numbering vertices and faces.
std::vector< Vertices > computeManifoldBoundaryChains() const
const Vertices & incidentVertices(Face f) const
~SurfaceMesh()=default
Default destructor.
const Faces & edgeRightFaces(Edge e) const
IntegerSequenceIterator< Vertex > ConstIterator
Non mutable iterator for visiting vertices.
VertexPair otherDiagonal(const Edge e) const
std::vector< Vertices > myNeighborVertices
For each vertex, its range of neighbor vertices (no particular order)
BOOST_STATIC_ASSERT((dimension==3))
const std::vector< VertexPair > & allEdgeVertices() const
std::vector< Edge > Edges
The type that defines a list/range of edges.
std::pair< Face, Scalar > WeightedFace
const std::vector< Faces > & allEdgeFaces() const
std::map< VertexPair, Edge > myVertexPairEdge
For each vertex pair, its edge index.
const std::vector< Vertices > & allNeighborVertices() const
const RealVector & faceNormal(Face f) 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::vector< RealVector > & vertexNormals()
std::set< Vertex > VertexSet
std::vector< RealVector > computeFaceUnitVectorsFromVertexUnitVectors(const std::vector< RealVector > &vuvectors) const
bool setFaceNormals(RealVectorIterator itN, RealVectorIterator itNEnd)
const RealVector & vertexNormal(Vertex v) const
SurfaceMesh(Self &&other)=default
Scalar faceInclusionRatio(RealPoint p, Scalar r, Index f) const
std::size_t Size
The type for counting elements.
Self & operator=(const Self &other)=default
std::tuple< Vertices, WeightedEdges, WeightedFaces > computeCellsInclusionsInBall(Scalar r, Index f) const
void computeFaceNormalFromPositions(const Face f)
Edges computeManifoldBoundaryEdges() const
Edges computeManifoldInnerConsistentEdges() const
const std::vector< Faces > & allEdgeLeftFaces() const
VertexPair edgeVertices(Edge e) const
void flip(const Edge e, bool recompute_face_normals=false)
Size bestCapacity() const
WeightedFaces computeFacesInclusionsInBall(Scalar r, Index f) const
const std::vector< Vertices > & allIncidentVertices() const
const Faces & incidentFaces(Vertex v) const
bool init(RealPointIterator itPos, RealPointIterator itPosEnd, VerticesIterator itVertices, VerticesIterator itVerticesEnd)
const Faces & edgeLeftFaces(Edge e) const
RealVector::Component Scalar
Edge makeEdge(Vertex i, Vertex j) const
Size degree(const Vertex &v) const
RealPoint edgeCentroid(Index e) const
void computeFaceNormalsFromVertexNormals()
std::vector< VertexPair > myEdgeVertices
For each edge, its two vertices.
void clear()
Clears everything. The object is empty.
Edges computeNonManifoldEdges() const
const Vertices & neighborVertices(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
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 std::vector< Faces > & allNeighborFaces() const
void removeIndex(std::vector< Index > &v, Index i)
std::vector< RealPoint > myPositions
For each vertex, its position.
void writeNeighbors(OutputIterator &it, const Vertex &v) const
const RealPoint & position(Vertex v) const
Scalar averageEdgeLength() const
Scalar vertexInclusionRatio(RealPoint p, Scalar r, Index v) const
bool isFlippable(const Edge e) const
const std::vector< Faces > & allIncidentFaces() const
void selfDisplay(std::ostream &out) const