DGtal 1.3.0
Loading...
Searching...
No Matches
IndexedDigitalSurface.h
1
17#pragma once
18
31#if defined(IndexedDigitalSurface_RECURSES)
32#error Recursive header files inclusion detected in IndexedDigitalSurface.h
33#else // defined(IndexedDigitalSurface_RECURSES)
35#define IndexedDigitalSurface_RECURSES
36
37#if !defined IndexedDigitalSurface_h
39#define IndexedDigitalSurface_h
40
42// Inclusions
43#include <iostream>
44#include <set>
45#include <map>
46#include <vector>
47#include "DGtal/base/Common.h"
48#include "DGtal/base/OwningOrAliasingPtr.h"
49#include "DGtal/base/IntegerSequenceIterator.h"
50#include "DGtal/topology/HalfEdgeDataStructure.h"
51#include "DGtal/topology/CDigitalSurfaceContainer.h"
53
54namespace DGtal
55{
56
58 // template class IndexedDigitalSurface
95 template <typename TDigitalSurfaceContainer>
97 {
98 public:
100 typedef TDigitalSurfaceContainer DigitalSurfaceContainer;
102
103 typedef typename DigitalSurfaceContainer::KSpace KSpace;
104 typedef typename KSpace::Space Space;
105 typedef typename KSpace::Surfel Surfel;
106 typedef typename KSpace::SCell SCell;
107 typedef typename KSpace::Cell Cell;
108 typedef typename Space::RealPoint RealPoint;
116 typedef std::vector<RealPoint> PositionsStorage;
117 typedef std::vector<PolygonalFace> PolygonalFacesStorage;
118 typedef std::vector<SCell> SCellStorage;
119
120 // Required by CUndirectedSimpleLocalGraph
122 typedef std::set<Vertex> VertexSet;
123 template <typename Value> struct VertexMap {
124 typedef typename std::map<Vertex, Value> Type;
125 };
126
127 // Required by CUndirectedSimpleGraph
130
131 // Required for CCombinatorialSurface
134 typedef std::vector<Arc> ArcRange;
135 typedef std::vector<Face> FaceRange;
136 typedef std::vector<Vertex> VertexRange;
137
139
148 template <typename TData>
151 typedef TData Data;
152 typedef std::vector<Data> Storage;
153
156
161 IndexedPropertyMap( const Self& aSurface, Size s, Data def_data = Data() )
162 : mySurface( &aSurface ),
163 myData( Storage( s, def_data ) )
164 {}
165
173 IndexedPropertyMap( const Self& aSurface,
174 Storage& aStorage )
175 : mySurface( &aSurface ),
176 myData( &aStorage, false )
177 {}
178
180 const Self& surface() const
181 {
182 ASSERT( isValid() );
183 return *mySurface;
184 }
185
189 const Data& operator()( Argument v ) const
190 {
191 ASSERT( isValid() && v < myData->size() );
192 return (*myData)[ v ];
193 }
194
198 const Data& operator[]( Argument v ) const
199 {
200 ASSERT( isValid() && v < myData->size() );
201 return (*myData)[ v ];
202 }
203
208 {
209 ASSERT( isValid() && v < myData->size() );
210 return (*myData)[ v ];
211 }
212
214 bool isValid() const { return mySurface != 0; }
215
217 Size size() const { return myData->size(); }
218
220 Storage& storage() { return *myData; }
221
223 const Storage& storage() const { return *myData; }
224
225 private:
230 };
231
233
234 protected:
236
237 // ----------------------- Standard services ------------------------------
238 public:
239
244
249
255 : isHEDSValid( false ), myContainer( 0 )
256 {
257 build( surfContainer );
258 }
259
261 void clear();
262
274
279 { return *myContainer; }
280
282 const KSpace& space() const
283 { return myContainer->space(); }
284
287 { return myHEDS; }
288
289 // ------------------------- standard services ------------------------------
290 public:
292 Size nbArcs() const { return myHEDS.nbHalfEdges(); }
293
295 Size nbVertices() const { return myHEDS.nbVertices(); }
296
298 Size nbEdges() const { return myHEDS.nbEdges(); }
299
301 Size nbFaces() const { return myHEDS.nbFaces(); }
302
306 long Euler() const { return myHEDS.Euler(); }
307
311 {
312 return PositionsMap( *this, myPositions );
313 }
314
318 {
320 }
321
325 {
327 }
328
332 {
334 }
335
337 template <typename AnyData>
339 {
340 return IndexedPropertyMap< AnyData >( *this, nbVertices() );
341 }
342
345 template <typename AnyData>
347 {
348 return IndexedPropertyMap< AnyData >( *this, nbVertices(), value );
349 }
350
352 template <typename AnyData>
354 {
355 return IndexedPropertyMap< AnyData >( *this, nbEdges() );
356 }
357
360 template <typename AnyData>
362 {
363 return IndexedPropertyMap< AnyData >( *this, nbEdges(), value );
364 }
365
367 template <typename AnyData>
369 {
370 return IndexedPropertyMap< AnyData >( *this, nbFaces() );
371 }
372
375 template <typename AnyData>
377 {
378 return IndexedPropertyMap< AnyData >( *this, nbFaces(), value );
379 }
380
388 const RealPoint& position( Vertex v ) const;
389
392 const SCell& surfel( Vertex v ) const
393 {
394 ASSERT( v < nbVertices() );
395 return myVertexIndex2Surfel[ v ];
396 }
397
400 const SCell& linel( Arc a ) const
401 {
402 ASSERT( a < nbArcs() );
403 return myArc2Linel[ a ];
404 }
405
408 const SCell& pointel( Face f ) const
409 {
410 ASSERT( f < nbFaces() );
411 return myFaceIndex2Pointel[ f ];
412 }
413
418 Vertex getVertex( const SCell& aSurfel ) const
419 {
420 auto it = mySurfel2VertexIndex.find( aSurfel );
421 return it != mySurfel2VertexIndex.end() ? it->second : INVALID_FACE;
422 }
423
428 Arc getArc( const SCell& aLinel ) const
429 {
430 auto it = myLinel2Arc.find( aLinel );
431 return it != myLinel2Arc.end() ? it->second : INVALID_FACE;
432 }
433
438 Face getFace( const SCell& aPointel ) const
439 {
440 auto it = myPointel2FaceIndex.find( aPointel );
441 return it != myPointel2FaceIndex.end() ? it->second : INVALID_FACE;
442 }
443
444 // ----------------------- Undirected simple graph services -------------------------
445 public:
449 Size size() const;
450
458
464 Size degree( const Vertex & v ) const;
465
477 template <typename OutputIterator>
478 void
479 writeNeighbors( OutputIterator &it ,
480 const Vertex & v ) const;
481
498 template <typename OutputIterator, typename VertexPredicate>
499 void
500 writeNeighbors( OutputIterator &it ,
501 const Vertex & v,
502 const VertexPredicate & pred) const;
503
506 { return ConstIterator( 0 ); }
507
510 { return ConstIterator( nbVertices() ); }
511
512 // ----------------------- CombinatorialSurface --------------------------
513 public:
514
519 ArcRange outArcs( const Vertex & v ) const;
520
525 ArcRange inArcs( const Vertex & v ) const;
526
532
537 Vertex head( const Arc & a ) const;
538
543 Vertex tail( const Arc & a ) const;
544
549 Arc opposite( const Arc & a ) const;
550
557 Arc next( const Arc & a ) const;
558
566 Arc arc( const Vertex & t, const Vertex & h ) const;
567
578 Face faceAroundArc( const Arc & a ) const;
579
588 FaceRange facesAroundArc( const Arc & a ) const;
589
601
607 bool isVertexBoundary( const Vertex& v ) const;
608
615 bool isArcBoundary( const Arc& v ) const;
616
632
641
650
651 // ----------------------- Interface --------------------------------------
652 public:
653
658 void selfDisplay ( std::ostream & out ) const;
659
664 bool isValid() const;
665
666 // ------------------------- Protected Datas ------------------------------
667 protected:
674
680 std::map< SCell, VertexIndex > mySurfel2VertexIndex;
682 std::map< SCell, Arc > myLinel2Arc;
684 std::map< SCell, FaceIndex > myPointel2FaceIndex;
691
692
693 // ------------------------- Private Datas --------------------------------
694 private:
695
696 // ------------------------- Hidden services ------------------------------
697 protected:
698
699 private:
700
701 // ------------------------- Internals ------------------------------------
702 private:
703
704 }; // end of class IndexedDigitalSurface
705
706
713 template <typename TDigitalSurfaceContainer>
714 std::ostream&
715 operator<< ( std::ostream & out,
717
718} // namespace DGtal
719
720
722// Includes inline functions.
723#include "DGtal/topology/IndexedDigitalSurface.ih"
724
725// //
727
728#endif // !defined IndexedDigitalSurface_h
729
730#undef IndexedDigitalSurface_RECURSES
731#endif // else defined(IndexedDigitalSurface_RECURSES)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
Aim: This class represents an half-edge data structure, which is a structure for representing the top...
Index HalfEdgeIndex
The type used for numbering half-edges (alias)
std::vector< VertexIndex > PolygonalFace
Index FaceIndex
The type for numbering faces.
Index EdgeIndex
The type for numbering edges.
std::size_t Index
The type used for numbering half-edges (an offset an the half-edges structure).
Index VertexIndex
The type for numbering vertices.
std::size_t Size
The type for counting elements.
Aim: Represents a digital surface with the topology of its dual surface. Its aim is to mimick the sta...
SCellStorage myVertexIndex2Surfel
Mapping VertexIndex -> Surfel.
VertexRange allVertices() const
HalfEdgeDataStructure::FaceIndex Face
ArcRange outArcs(const Vertex &v) const
void writeNeighbors(OutputIterator &it, const Vertex &v, const VertexPredicate &pred) const
IndexedPropertyMap< AnyData > makeFaceMap() const
IndexedDigitalSurface< TDigitalSurfaceContainer > Self
FaceRange facesAroundArc(const Arc &a) const
std::vector< PolygonalFace > PolygonalFacesStorage
const RealPoint & position(Vertex v) const
HalfEdgeDataStructure::Index Index
HalfEdgeDataStructure myHEDS
The half-edge data structure that stores the topology of the mesh.
IndexedPropertyMap< AnyData > makeFaceMap(AnyData value) const
IndexedPropertyMap< AnyData > makeEdgeMap(AnyData value) const
HalfEdgeDataStructure::EdgeIndex EdgeIndex
Vertex tail(const Arc &a) const
void selfDisplay(std::ostream &out) const
BOOST_STATIC_CONSTANT(Face, INVALID_FACE=HALF_EDGE_INVALID_INDEX)
PolygonalFacesStorage myPolygonalFaces
Stores the polygonal faces.
const HalfEdgeDataStructure & heds() const
const SCell & pointel(Face f) const
Vertex getVertex(const SCell &aSurfel) const
void clear()
Clears everything.
bool isVertexBoundary(const Vertex &v) const
HalfEdgeDataStructure::VertexIndex VertexIndex
std::vector< RealPoint > PositionsStorage
RealPoint & position(Vertex v)
const SCell & surfel(Vertex v) const
PositionsStorage myPositions
Stores the information for each Vertex.
std::map< SCell, Arc > myLinel2Arc
Mapping Linel -> Arc.
CountedConstPtrOrConstPtr< DigitalSurfaceContainer > myContainer
The (secured or not) pointer to the associated digital surface container.
ArcRange inArcs(const Vertex &v) const
HalfEdgeDataStructure::Triangle Triangle
IndexedDigitalSurface(ConstAlias< DigitalSurfaceContainer > surfContainer)
std::map< SCell, FaceIndex > myPointel2FaceIndex
Mapping Pointel -> FaceIndex.
IndexedPropertyMap< AnyData > makeEdgeMap() const
bool isArcBoundary(const Arc &v) const
IndexedPropertyMap< RealPoint > PositionsMap
Arc opposite(const Arc &a) const
bool build(ConstAlias< DigitalSurfaceContainer > surfContainer)
Arc arc(const Vertex &t, const Vertex &h) const
void writeNeighbors(OutputIterator &it, const Vertex &v) const
IndexedPropertyMap< AnyData > makeVertexMap(AnyData value) const
BOOST_CONCEPT_ASSERT((concepts::CDigitalSurfaceContainer< DigitalSurfaceContainer >))
IntegerSequenceIterator< VertexIndex > ConstIterator
SCellStorage myFaceIndex2Pointel
Mapping FaceIndex -> Pointel.
TDigitalSurfaceContainer DigitalSurfaceContainer
const DigitalSurfaceContainer & container() const
IndexedPropertyMap< AnyData > makeVertexMap() const
IndexedPropertyMap< SCell > surfels()
FaceRange allFaces() const
Vertex head(const Arc &a) const
HalfEdgeDataStructure::FaceIndex FaceIndex
FaceRange facesAroundVertex(const Vertex &v) const
bool isHEDSValid
Indicates if the half-edge structure has been created/updated.
Arc next(const Arc &a) const
HalfEdgeDataStructure::PolygonalFace PolygonalFace
IndexedPropertyMap< SCell > linels()
DigitalSurfaceContainer::KSpace KSpace
HalfEdgeDataStructure::Size Size
Face faceAroundArc(const Arc &a) const
ArcRange allBoundaryArcs() const
IndexedPropertyMap< SCell > pointels()
std::map< SCell, VertexIndex > mySurfel2VertexIndex
Mapping Surfel -> VertexIndex.
SCellStorage myArc2Linel
Mapping Arc -> Linel.
Arc getArc(const SCell &aLinel) const
const SCell & linel(Arc a) const
HalfEdgeDataStructure::HalfEdge HalfEdge
Size degree(const Vertex &v) const
VertexRange verticesAroundFace(const Face &f) const
Face getFace(const SCell &aPointel) const
HalfEdgeDataStructure::HalfEdgeIndex Arc
VertexRange allBoundaryVertices() const
Aim: It is a simple class that mimics a (non mutable) iterator over integers. You can increment it,...
Aim: This class describes a smart pointer that is, given the constructor called by the user,...
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
DGtal is the top-level namespace which contains all DGtal functions and types.
static std::size_t const HALF_EDGE_INVALID_INDEX
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Represents an unoriented triangle as three vertices.
OwningOrAliasingPtr< Storage > myData
An owned or aliased pointer to the vector of data.
IndexedPropertyMap(const Self &aSurface, Storage &aStorage)
const Self * mySurface
The associated indexed digital surface.
IndexedPropertyMap()
Default constructor. The object is invalid.
IndexedPropertyMap(const Self &aSurface, Size s, Data def_data=Data())
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Aim: The digital surface container concept describes a minimal set of inner types and methods so as t...