DGtal 1.4.2
Loading...
Searching...
No Matches
PolygonalSurface.h
1
17#pragma once
18
31#if defined(PolygonalSurface_RECURSES)
32#error Recursive header files inclusion detected in PolygonalSurface.h
33#else // defined(PolygonalSurface_RECURSES)
35#define PolygonalSurface_RECURSES
36
37#if !defined PolygonalSurface_h
39#define PolygonalSurface_h
40
42// Inclusions
43#include <iostream>
44#include <set>
45#include <map>
46#include "DGtal/base/Common.h"
47#include "DGtal/base/Clone.h"
48#include "DGtal/base/OwningOrAliasingPtr.h"
49#include "DGtal/base/IntegerSequenceIterator.h"
50#include "DGtal/topology/HalfEdgeDataStructure.h"
52
53namespace DGtal
54{
55
57 // template class PolygonalSurface
85 template <typename TPoint>
87 {
88 public:
89 typedef TPoint Point;
98 typedef std::vector<Point> PositionsStorage;
99 typedef std::vector<PolygonalFace> PolygonalFacesStorage;
100
101 // Required by CUndirectedSimpleLocalGraph
103 typedef std::set<Vertex> VertexSet;
104 template <typename Value> struct VertexMap {
105 typedef typename std::map<Vertex, Value> Type;
106 };
107
108 // Required by CUndirectedSimpleGraph
111
112 // Required for CCombinatorialSurface
115 typedef std::vector<Arc> ArcRange;
116 typedef std::vector<Face> FaceRange;
117 typedef std::vector<Vertex> VertexRange;
118
120
129 template <typename TData>
132 typedef TData Data;
133 typedef std::vector<Data> Storage;
134
137
142 IndexedPropertyMap( const Self& aSurface, Size s, Data def_data = Data() )
143 : mySurface( &aSurface ),
144 myData( Storage( s, def_data ) )
145 {}
146
154 IndexedPropertyMap( const Self& aSurface,
155 Storage& aStorage )
156 : mySurface( &aSurface ),
157 myData( &aStorage, false )
158 {}
159
161 const Self& surface() const
162 {
163 ASSERT( isValid() );
164 return *mySurface;
165 }
166
170 const Data& operator()( Argument v ) const
171 {
172 ASSERT( isValid() && v < myData->size() );
173 return (*myData)[ v ];
174 }
175
179 const Data& operator[]( Argument v ) const
180 {
181 ASSERT( isValid() && v < myData->size() );
182 return (*myData)[ v ];
183 }
184
189 {
190 ASSERT( isValid() && v < myData->size() );
191 return (*myData)[ v ];
192 }
193
195 bool isValid() const { return mySurface != 0; }
196
198 Size size() const { return myData->size(); }
199
201 Storage& storage() { return *myData; }
202
204 const Storage& storage() const { return *myData; }
205
206 private:
211 };
212
214
215 protected:
217
218 // ----------------------- Standard services ------------------------------
219 public:
220
225
230
242
244 void clear();
245
252 bool build();
253
257 VertexIndex addVertex( const Point& vdata );
258
262
266
270
274
277 const HalfEdgeDataStructure& heds() const { return myHEDS; }
278
279 // ------------------------- standard services ------------------------------
280 public:
282 Size nbArcs() const { return myHEDS.nbHalfEdges(); }
283
285 Size nbVertices() const { return myHEDS.nbVertices(); }
286
288 Size nbEdges() const { return myHEDS.nbEdges(); }
289
291 Size nbFaces() const { return myHEDS.nbFaces(); }
292
296 long Euler() const { return myHEDS.Euler(); }
297
301 {
302 return PositionsMap( *this, myPositions );
303 }
304
306 template <typename AnyData>
311
314 template <typename AnyData>
316 {
317 return IndexedPropertyMap< AnyData >( *this, nbVertices(), value );
318 }
319
321 template <typename AnyData>
326
329 template <typename AnyData>
331 {
332 return IndexedPropertyMap< AnyData >( *this, nbEdges(), value );
333 }
334
336 template <typename AnyData>
341
344 template <typename AnyData>
346 {
347 return IndexedPropertyMap< AnyData >( *this, nbFaces(), value );
348 }
349
357 const Point& position( Vertex v ) const;
358
359 // ----------------------- Undirected simple graph services -------------------------
360 public:
364 Size size() const;
365
373
379 Size degree( const Vertex & v ) const;
380
392 template <typename OutputIterator>
393 void
394 writeNeighbors( OutputIterator &it ,
395 const Vertex & v ) const;
396
413 template <typename OutputIterator, typename VertexPredicate>
414 void
415 writeNeighbors( OutputIterator &it ,
416 const Vertex & v,
417 const VertexPredicate & pred) const;
418
421 { return ConstIterator( 0 ); }
422
425 { return ConstIterator( nbVertices() ); }
426
427 // ----------------------- CombinatorialSurface --------------------------
428 public:
429
434 ArcRange outArcs( const Vertex & v ) const;
435
440 ArcRange inArcs( const Vertex & v ) const;
441
447
452 Vertex head( const Arc & a ) const;
453
458 Vertex tail( const Arc & a ) const;
459
464 Arc opposite( const Arc & a ) const;
465
472 Arc next( const Arc & a ) const;
473
481 Arc arc( const Vertex & t, const Vertex & h ) const;
482
493 Face faceAroundArc( const Arc & a ) const;
494
503 FaceRange facesAroundArc( const Arc & a ) const;
504
516
526 ArcRange arcsAroundFace( const Face & f ) const;
527
533 bool isVertexBoundary( const Vertex& v ) const;
534
541 bool isArcBoundary( const Arc& v ) const;
542
558
567
576
577 // ----------------------- Interface --------------------------------------
578 public:
579
584 void selfDisplay ( std::ostream & out ) const;
585
590 bool isValid() const;
591
592 // ------------------------- Protected Datas ------------------------------
593 protected:
602
603 // ------------------------- Private Datas --------------------------------
604 private:
605
606 // ------------------------- Hidden services ------------------------------
607 protected:
608
609 private:
610
611 // ------------------------- Internals ------------------------------------
612 private:
613
614 }; // end of class PolygonalSurface
615
616
623 template <typename TPoint>
624 std::ostream&
625 operator<< ( std::ostream & out, const PolygonalSurface<TPoint> & object );
626
627} // namespace DGtal
628
629
631// Includes inline functions.
632#include "DGtal/shapes/PolygonalSurface.ih"
633
634// //
636
637#endif // !defined PolygonalSurface_h
638
639#undef PolygonalSurface_RECURSES
640#endif // else defined(PolygonalSurface_RECURSES)
Aim: This class encapsulates its parameter class to indicate that the given parameter is required to ...
Definition Clone.h:267
Aim: This class represents an half-edge data structure, which is a structure for representing the top...
Index EdgeIndex
The type for numbering edges.
Index HalfEdgeIndex
The type used for numbering half-edges (alias)
Index VertexIndex
The type for numbering vertices.
std::size_t Size
The type for counting elements.
Index FaceIndex
The type for numbering faces.
std::size_t Index
The type used for numbering half-edges (an offset an the half-edges structure).
std::vector< VertexIndex > PolygonalFace
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: Represents a polygon mesh, i.e. a 2-dimensional combinatorial surface whose faces are (topologic...
ConstIterator begin() const
FaceRange facesAroundArc(const Arc &a) const
HalfEdgeDataStructure::PolygonalFace PolygonalFace
std::vector< Face > FaceRange
const HalfEdgeDataStructure & heds() const
void writeNeighbors(OutputIterator &it, const Vertex &v) const
bool isHEDSValid
Indicates if the half-edge structure has been created/updated.
ConstIterator end() const
IndexedPropertyMap< AnyData > makeVertexMap() const
ArcRange allBoundaryArcs() const
IndexedPropertyMap< AnyData > makeEdgeMap(AnyData value) const
FaceIndex addQuadrangle(VertexIndex v0, VertexIndex v1, VertexIndex v2, VertexIndex v3)
FaceIndex addTriangle(VertexIndex v0, VertexIndex v1, VertexIndex v2)
VertexRange allBoundaryVertices() const
const Point & position(Vertex v) const
ArcRange arcsAroundFace(const Face &f) const
Point & position(Vertex v)
Arc next(const Arc &a) const
Arc opposite(const Arc &a) const
IntegerSequenceIterator< VertexIndex > ConstIterator
HalfEdgeDataStructure::FaceIndex FaceIndex
Arc arc(const Vertex &t, const Vertex &h) const
FaceRange facesAroundVertex(const Vertex &v) const
PolygonalSurface(Clone< HalfEdgeDataStructure > aHeds, Clone< PositionsStorage > pos)
HalfEdgeDataStructure::VertexIndex VertexIndex
PolygonalFacesStorage myPolygonalFaces
Stores the polygonal faces.
HalfEdgeDataStructure::Size Size
bool isVertexBoundary(const Vertex &v) const
IndexedPropertyMap< Point > PositionsMap
VertexRange verticesAroundFace(const Face &f) const
void writeNeighbors(OutputIterator &it, const Vertex &v, const VertexPredicate &pred) const
IndexedPropertyMap< AnyData > makeEdgeMap() const
HalfEdgeDataStructure & heds()
void selfDisplay(std::ostream &out) const
PositionsStorage myPositions
Stores the information for each Vertex.
HalfEdgeDataStructure::HalfEdge HalfEdge
HalfEdgeDataStructure::EdgeIndex EdgeIndex
FaceRange allFaces() const
HalfEdgeDataStructure::FaceIndex Face
Vertex tail(const Arc &a) const
Size degree(const Vertex &v) const
VertexIndex addVertex(const Point &vdata)
HalfEdgeDataStructure myHEDS
The half-edge data structure that stores the topology of the mesh.
BOOST_STATIC_CONSTANT(Face, INVALID_FACE=HALF_EDGE_INVALID_INDEX)
std::vector< Vertex > VertexRange
IndexedPropertyMap< AnyData > makeVertexMap(AnyData value) const
HalfEdgeDataStructure::Index Index
HalfEdgeDataStructure::Triangle Triangle
Face faceAroundArc(const Arc &a) const
Size bestCapacity() const
Vertex head(const Arc &a) const
VertexRange allVertices() const
ArcRange outArcs(const Vertex &v) const
FaceIndex addPolygonalFace(const PolygonalFace &f)
std::vector< PolygonalFace > PolygonalFacesStorage
void clear()
Clears everything.
PolygonalSurface< TPoint > Self
std::set< Vertex > VertexSet
bool isArcBoundary(const Arc &v) const
std::vector< Point > PositionsStorage
IndexedPropertyMap< AnyData > makeFaceMap() const
std::vector< Arc > ArcRange
ArcRange allArcs() const
ArcRange inArcs(const Vertex &v) const
HalfEdgeDataStructure::HalfEdgeIndex Arc
IndexedPropertyMap< AnyData > makeFaceMap(AnyData value) const
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.
const Self * mySurface
The associated polygonal surface.
IndexedPropertyMap(const Self &aSurface, Size s, Data def_data=Data())
OwningOrAliasingPtr< Storage > myData
An owned or aliased pointer to the vector of data.
const Data & operator[](Argument v) const
IndexedPropertyMap()
Default constructor. The object is invalid.
const Data & operator()(Argument v) const
IndexedPropertyMap(const Self &aSurface, Storage &aStorage)