DGtal 1.3.0
Loading...
Searching...
No Matches
SurfaceMeshMeasure.h
1
17#pragma once
18
31#if defined(SurfaceMeshMeasure_RECURSES)
32#error Recursive header files inclusion detected in SurfaceMeshMeasure.h
33#else // defined(SurfaceMeshMeasure_RECURSES)
35#define SurfaceMeshMeasure_RECURSES
36
37#if !defined SurfaceMeshMeasure_h
39#define SurfaceMeshMeasure_h
40
42// Inclusions
43#include <vector>
44#include "DGtal/kernel/CCommutativeRing.h"
45#include "DGtal/shapes/SurfaceMesh.h"
46
47namespace DGtal
48{
81 template < typename TRealPoint, typename TRealVector, typename TValue >
83 {
84 // ------------------------- Public Types ------------------------------
85 public:
86
87 typedef TRealPoint RealPoint;
88 typedef TRealVector RealVector;
89 typedef TValue Value;
91 // JOL: cannot check commutative ring on Tensor matrices, since it
92 // is required in the concept to be constructible from the (int)
93 // 0.
94 // BOOST_CONCEPT_ASSERT(( concepts::CCommutativeRing< Value > ));
96 typedef typename SurfaceMesh::Index Index;
97 typedef typename SurfaceMesh::Size Size;
98 typedef typename SurfaceMesh::Vertex Vertex;
99 typedef typename SurfaceMesh::Edge Edge;
100 typedef typename SurfaceMesh::Face Face;
101 typedef std::vector< Value > Values;
103 typedef std::pair< Face, Scalar > WeightedFace;
104 typedef std::pair< Edge, Scalar > WeightedEdge;
105 typedef std::pair< Vertex, Scalar > WeightedVertex;
107 typedef std::vector< Vertex > Vertices;
109 typedef std::vector< Edge > Edges;
111 typedef std::vector< Face > Faces;
112 typedef std::vector< WeightedVertex > WeightedVertices;
113 typedef std::vector< WeightedEdge > WeightedEdges;
114 typedef std::vector< WeightedFace > WeightedFaces;
116
117 // ------------------------- Standard services ------------------------------
118 public:
121
126 Value zero_value = Value() )
127 : myMeshPtr( &aMesh ), myZero( zero_value ) {}
128
131 const SurfaceMesh* meshPtr() const
132 {
133 return myMeshPtr;
134 }
135
140 {
141 return ( dim == 0 ) ? vertex_measures
142 : ( (dim == 1 ) ? edge_measures : face_measures );
143 }
148 {
149 return ( dim == 0 ) ? vertex_measures
150 : ( (dim == 1 ) ? edge_measures : face_measures );
151 }
152
154
155 // ------------------------- Measure services ------------------------------
156 public:
159
162 {
163 Value m = myZero;
164 for ( auto&& lm : vertex_measures ) m += lm;
165 for ( auto&& lm : edge_measures ) m += lm;
166 for ( auto&& lm : face_measures ) m += lm;
167 return m;
168 }
176 Value measure( const RealPoint& x, Scalar r, Face f ) const
177 {
178 if ( vertex_measures.empty() && edge_measures.empty() )
179 {
181 faces = myMeshPtr->computeFacesInclusionsInBall( r, f, x );
182 return faceMeasure( faces );
183 }
184 else
185 {
186 std::tuple< Vertices, WeightedEdges, WeightedFaces >
187 wcells = myMeshPtr->computeCellsInclusionsInBall( r, f, x );
188 Value m = vertexMeasure( std::get< 0 >( wcells ) );
189 m += edgeMeasure ( std::get< 1 >( wcells ) );
190 m += faceMeasure ( std::get< 2 >( wcells ) );
191 return m;
192 }
193 }
194
198 {
199 return v < vertex_measures.size() ? vertex_measures[ v ] : Value();
200 }
201
204 Value vertexMeasure( const Vertices& vertices ) const
205 {
206 Value m = myZero;
207 if ( vertex_measures.empty() ) return m;
208 for ( auto&& v : vertices ) m += vertex_measures[ v ];
209 return m;
210 }
211
214 Value vertexMeasure( const WeightedVertices& wvertices ) const
215 {
216 Value m = myZero;
217 if ( vertex_measures.empty() ) return m;
218 for ( auto&& v : wvertices ) m += vertex_measures[ v.first ] * v.second;
219 return m;
220 }
221
225 {
226 return e < edge_measures.size() ? edge_measures[ e ] : Value();
227 }
228
231 Value edgeMeasure( const Edges& edges ) const
232 {
233 Value m = myZero;
234 if ( edge_measures.empty() ) return m;
235 for ( auto&& e : edges ) m += edge_measures[ e ];
236 return m;
237 }
238
241 Value edgeMeasure( const WeightedEdges& wedges ) const
242 {
243 Value m = myZero;
244 if ( edge_measures.empty() ) return m;
245 for ( auto&& e : wedges ) m += edge_measures[ e.first ] * e.second;
246 return m;
247 }
248
252 {
253 return f < face_measures.size() ? face_measures[ f ] : Value();
254 }
255
258 Value faceMeasure( const Faces& faces ) const
259 {
260 Value m = myZero;
261 if ( face_measures.empty() ) return m;
262 for ( auto&& v : faces ) m += face_measures[ v ];
263 return m;
264 }
265
268 Value faceMeasure( const WeightedFaces& wfaces ) const
269 {
270 Value m = myZero;
271 if ( face_measures.empty() ) return m;
272 for ( auto&& v : wfaces ) m += face_measures[ v.first ] * v.second;
273 return m;
274 }
275
277
278 // ------------------------- Public Datas ------------------------------
279 public:
286
287 // ------------------------- Protected Datas ------------------------------
288 protected:
293 };
294
295
296} // namespace DGtal
297
299// Includes inline functions.
300// //
302
303#endif // !defined SurfaceMeshMeasure_h
304
305#undef SurfaceMeshMeasure_RECURSES
306#endif // else defined(SurfaceMeshMeasure_RECURSES)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
TEuclideanRing Component
Type for Vector elements.
Definition: PointVector.h:614
static const Dimension dimension
Copy of the static dimension of the Point/Vector.
Definition: PointVector.h:626
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::uint32_t Dimension
Definition: Common.h:137
Aim: stores an arbitrary measure on a SurfaceMesh object. The measure can be spread onto its vertices...
const SurfaceMesh * meshPtr() const
Value edgeMeasure(Edge e) const
std::pair< Edge, Scalar > WeightedEdge
Value vertexMeasure(Vertex v) const
Values face_measures
Stores the scalar curvature measure per indexed face element.
std::pair< Vertex, Scalar > WeightedVertex
SurfaceMeshMeasure(ConstAlias< SurfaceMesh > aMesh=nullptr, Value zero_value=Value())
Values vertex_measures
Stores the scalar curvature measure per indexed vertex element.
std::vector< Face > Faces
The type that defines a range of faces.
RealVector::Component Scalar
std::vector< WeightedEdge > WeightedEdges
Value myZero
Zero value for the given type.
Values & kMeasures(Dimension dim)
SurfaceMeshMeasure< RealPoint, RealVector, Value > Self
std::vector< WeightedFace > WeightedFaces
const SurfaceMesh * myMeshPtr
A pointer to the mesh over which computations are done.
Value edgeMeasure(const Edges &edges) const
std::pair< Face, Scalar > WeightedFace
Value faceMeasure(const WeightedFaces &wfaces) const
Value measure(const RealPoint &x, Scalar r, Face f) const
Value faceMeasure(Face f) const
DGtal::SurfaceMesh< RealPoint, RealVector > SurfaceMesh
Value faceMeasure(const Faces &faces) const
std::vector< Value > Values
SurfaceMesh::Vertex Vertex
Value edgeMeasure(const WeightedEdges &wedges) const
const Values & kMeasures(Dimension dim) const
static const Dimension dimension
std::vector< WeightedVertex > WeightedVertices
Value vertexMeasure(const WeightedVertices &wvertices) const
std::vector< Edge > Edges
The type that defines a range of edges.
Value vertexMeasure(const Vertices &vertices) const
std::vector< Vertex > Vertices
The type that defines a range of vertices.
Values edge_measures
Stores the scalar curvature measure per indexed edge element.
Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces ...
Definition: SurfaceMesh.h:92
std::size_t Index
The type used for numbering vertices and faces.
Definition: SurfaceMesh.h:105
std::size_t Size
The type for counting elements.
Definition: SurfaceMesh.h:103
std::tuple< Vertices, WeightedEdges, WeightedFaces > computeCellsInclusionsInBall(Scalar r, Index f) const
WeightedFaces computeFacesInclusionsInBall(Scalar r, Index f) const