DGtal  1.4.beta
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)
34 
35 #define SurfaceMeshMeasure_RECURSES
36 
37 #if !defined SurfaceMeshMeasure_h
38 
39 #define SurfaceMeshMeasure_h
40 
42 // Inclusions
43 #include <vector>
44 #include "DGtal/kernel/CCommutativeRing.h"
45 #include "DGtal/shapes/SurfaceMesh.h"
46 
47 namespace 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;
102  typedef typename RealVector::Component Scalar;
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 
139  const Values& kMeasures( Dimension dim ) const
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 
161  Value measure() const
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 
224  Value edgeMeasure( Edge e ) const
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 
251  Value faceMeasure( Face f ) const
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)
DGtal::SurfaceMesh::Vertex
Index Vertex
Definition: SurfaceMesh.h:108
DGtal::SurfaceMeshMeasure::Vertex
SurfaceMesh::Vertex Vertex
Definition: SurfaceMeshMeasure.h:98
DGtal::SurfaceMeshMeasure::SurfaceMesh
DGtal::SurfaceMesh< RealPoint, RealVector > SurfaceMesh
Definition: SurfaceMeshMeasure.h:95
DGtal::SurfaceMeshMeasure::edge_measures
Values edge_measures
Stores the scalar curvature measure per indexed edge element.
Definition: SurfaceMeshMeasure.h:283
DGtal::ConstAlias
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
DGtal::SurfaceMeshMeasure::vertexMeasure
Value vertexMeasure(const Vertices &vertices) const
Definition: SurfaceMeshMeasure.h:204
DGtal::SurfaceMeshMeasure::kMeasures
Values & kMeasures(Dimension dim)
Definition: SurfaceMeshMeasure.h:147
DGtal::SurfaceMeshMeasure::Faces
std::vector< Face > Faces
The type that defines a range of faces.
Definition: SurfaceMeshMeasure.h:111
DGtal::SurfaceMeshMeasure::faceMeasure
Value faceMeasure(const Faces &faces) const
Definition: SurfaceMeshMeasure.h:258
DGtal::SurfaceMeshMeasure::Face
SurfaceMesh::Face Face
Definition: SurfaceMeshMeasure.h:100
DGtal::Dimension
DGtal::uint32_t Dimension
Definition: Common.h:137
DGtal::SurfaceMesh
Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces ...
Definition: SurfaceMesh.h:91
DGtal::SurfaceMeshMeasure::WeightedVertex
std::pair< Vertex, Scalar > WeightedVertex
Definition: SurfaceMeshMeasure.h:105
DGtal::SurfaceMeshMeasure::Index
SurfaceMesh::Index Index
Definition: SurfaceMeshMeasure.h:96
DGtal::SurfaceMeshMeasure::RealPoint
TRealPoint RealPoint
Definition: SurfaceMeshMeasure.h:87
DGtal::SurfaceMeshMeasure::RealVector
TRealVector RealVector
Definition: SurfaceMeshMeasure.h:88
dim
unsigned int dim(const Vector &z)
Definition: viewDualSurface.cpp:174
DGtal::SurfaceMeshMeasure::meshPtr
const SurfaceMesh * meshPtr() const
Definition: SurfaceMeshMeasure.h:131
DGtal::SurfaceMeshMeasure::edgeMeasure
Value edgeMeasure(Edge e) const
Definition: SurfaceMeshMeasure.h:224
DGtal::SurfaceMeshMeasure::dimension
static const Dimension dimension
Definition: SurfaceMeshMeasure.h:115
DGtal::SurfaceMeshMeasure::face_measures
Values face_measures
Stores the scalar curvature measure per indexed face element.
Definition: SurfaceMeshMeasure.h:285
DGtal::PointVector::Component
TEuclideanRing Component
Type for Vector elements.
Definition: PointVector.h:614
DGtal::SurfaceMeshMeasure::Scalar
RealVector::Component Scalar
Definition: SurfaceMeshMeasure.h:102
DGtal::SurfaceMesh::computeFacesInclusionsInBall
WeightedFaces computeFacesInclusionsInBall(Scalar r, Index f) const
DGtal::SurfaceMeshMeasure::vertex_measures
Values vertex_measures
Stores the scalar curvature measure per indexed vertex element.
Definition: SurfaceMeshMeasure.h:281
DGtal::SurfaceMeshMeasure::faceMeasure
Value faceMeasure(Face f) const
Definition: SurfaceMeshMeasure.h:251
DGtal::SurfaceMeshMeasure::WeightedFaces
std::vector< WeightedFace > WeightedFaces
Definition: SurfaceMeshMeasure.h:114
DGtal::SurfaceMeshMeasure::Vertices
std::vector< Vertex > Vertices
The type that defines a range of vertices.
Definition: SurfaceMeshMeasure.h:107
DGtal::SurfaceMesh::Edge
Index Edge
Definition: SurfaceMesh.h:107
DGtal::SurfaceMeshMeasure::WeightedEdge
std::pair< Edge, Scalar > WeightedEdge
Definition: SurfaceMeshMeasure.h:104
DGtal::SurfaceMeshMeasure::measure
Value measure() const
Definition: SurfaceMeshMeasure.h:161
DGtal::SurfaceMeshMeasure::Values
std::vector< Value > Values
Definition: SurfaceMeshMeasure.h:101
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::SurfaceMeshMeasure::vertexMeasure
Value vertexMeasure(Vertex v) const
Definition: SurfaceMeshMeasure.h:197
DGtal::SurfaceMeshMeasure::Value
TValue Value
Definition: SurfaceMeshMeasure.h:89
DGtal::SurfaceMeshMeasure::edgeMeasure
Value edgeMeasure(const WeightedEdges &wedges) const
Definition: SurfaceMeshMeasure.h:241
DGtal::SurfaceMeshMeasure::vertexMeasure
Value vertexMeasure(const WeightedVertices &wvertices) const
Definition: SurfaceMeshMeasure.h:214
DGtal::SurfaceMesh::computeCellsInclusionsInBall
std::tuple< Vertices, WeightedEdges, WeightedFaces > computeCellsInclusionsInBall(Scalar r, Index f) const
DGtal::SurfaceMeshMeasure::WeightedVertices
std::vector< WeightedVertex > WeightedVertices
Definition: SurfaceMeshMeasure.h:112
DGtal::SurfaceMeshMeasure::edgeMeasure
Value edgeMeasure(const Edges &edges) const
Definition: SurfaceMeshMeasure.h:231
DGtal::SurfaceMeshMeasure
Aim: stores an arbitrary measure on a SurfaceMesh object. The measure can be spread onto its vertices...
Definition: SurfaceMeshMeasure.h:82
DGtal::SurfaceMeshMeasure::myMeshPtr
const SurfaceMesh * myMeshPtr
A pointer to the mesh over which computations are done.
Definition: SurfaceMeshMeasure.h:290
DGtal::SurfaceMesh::Face
Index Face
Definition: SurfaceMesh.h:106
DGtal::PointVector::dimension
static const Dimension dimension
Copy of the static dimension of the Point/Vector.
Definition: PointVector.h:626
DGtal::SurfaceMeshMeasure::kMeasures
const Values & kMeasures(Dimension dim) const
Definition: SurfaceMeshMeasure.h:139
DGtal::SurfaceMeshMeasure::WeightedFace
std::pair< Face, Scalar > WeightedFace
Definition: SurfaceMeshMeasure.h:103
DGtal::SurfaceMeshMeasure::SurfaceMeshMeasure
SurfaceMeshMeasure(ConstAlias< SurfaceMesh > aMesh=nullptr, Value zero_value=Value())
Definition: SurfaceMeshMeasure.h:125
DGtal::SurfaceMesh::Size
std::size_t Size
The type for counting elements.
Definition: SurfaceMesh.h:103
DGtal::SurfaceMeshMeasure::myZero
Value myZero
Zero value for the given type.
Definition: SurfaceMeshMeasure.h:292
DGtal::SurfaceMeshMeasure::Size
SurfaceMesh::Size Size
Definition: SurfaceMeshMeasure.h:97
DGtal::SurfaceMeshMeasure::faceMeasure
Value faceMeasure(const WeightedFaces &wfaces) const
Definition: SurfaceMeshMeasure.h:268
DGtal::SurfaceMeshMeasure::Self
SurfaceMeshMeasure< RealPoint, RealVector, Value > Self
Definition: SurfaceMeshMeasure.h:90
DGtal::SurfaceMeshMeasure::Edge
SurfaceMesh::Edge Edge
Definition: SurfaceMeshMeasure.h:99
DGtal::SurfaceMeshMeasure::Edges
std::vector< Edge > Edges
The type that defines a range of edges.
Definition: SurfaceMeshMeasure.h:109
DGtal::SurfaceMeshMeasure::measure
Value measure(const RealPoint &x, Scalar r, Face f) const
Definition: SurfaceMeshMeasure.h:176
DGtal::SurfaceMeshMeasure::WeightedEdges
std::vector< WeightedEdge > WeightedEdges
Definition: SurfaceMeshMeasure.h:113
DGtal::SurfaceMesh::Index
std::size_t Index
The type used for numbering vertices and faces.
Definition: SurfaceMesh.h:105