DGtal 1.4.0
Loading...
Searching...
No Matches
Mesh.h
1
17#pragma once
18
31#if defined(Mesh_RECURSES)
32#error Recursive header files inclusion detected in Mesh.h
33#else // defined(Mesh_RECURSES)
35#define Mesh_RECURSES
36
37#if !defined Mesh_h
39#define Mesh_h
40
42// Inclusions
43#include <iostream>
44#include <vector>
45#include "DGtal/base/Common.h"
46#include "DGtal/kernel/PointVector.h"
47#include "DGtal/io/Color.h"
49
50namespace DGtal
51{
52
53
55 // template class Mesh
90 template <typename TPoint >
91 class Mesh
92 {
93
94
95 // ----------------------- associated types ------------------------------
96 public:
97
98
102 typedef TPoint Point;
103
104
105
110
111
115 typedef std::vector<TPoint> VertexStorage;
116
120 typedef typename VertexStorage::size_type Index;
121
126 typedef std::vector<Index> MeshFace;
127
128
132 typedef std::vector<MeshFace> FaceStorage;
133
137 typedef std::vector<DGtal::Color> ColorStorage;
138
139
143 typedef typename VertexStorage::const_iterator ConstIterator;
144
148 typedef typename VertexStorage::iterator Iterator;
149
153 typedef typename std::size_t Size;
154
155
156
157 // ----------------------- Standard services ------------------------------
158 public:
166 Mesh(bool saveFaceColor=false);
167
174 Mesh(const DGtal::Color &aColor);
175
181 Mesh(const std::vector<TPoint> &vertexSet);
182
187
192 Mesh ( const Mesh & other );
193
199 Mesh & operator= ( const Mesh & other );
200
201
202
203 // --------------- CDrawableWithDisplay3D realization -------------------
204 public:
205
209 std::string className() const;
210
211
212
213
214 // ----------------------- Interface --------------------------------------
215 public:
216
217
222 void addVertex(const TPoint &vertex);
223
224
225
238 void addTriangularFace(Index indexVertex1, Index indexVertex2, Index indexVertex3,
239 const DGtal::Color &aColor=DGtal::Color::White);
240
241
255 void addQuadFace(Index indexVertex1, Index indexVertex2,
256 Index indexVertex3, Index indexVertex4,
257 const DGtal::Color & aColor=DGtal::Color::White);
258
259
268 void addFace(const MeshFace &aFace, const DGtal::Color &aColor=DGtal::Color::White);
269
270
277 void removeFaces(const std::vector<Index> &facesIndex);
278
279
284 const TPoint & getVertex(Index i) const;
285
290 TPoint & getVertex(Index i);
291
292
293
298 const MeshFace & getFace(Index i) const;
299
300
306
307
308
314
315
316
322 const Color & getFaceColor(Index i) const;
323
324
325
329 std::pair<TPoint, TPoint> getBoundingBox() const;
330
331
344 void setFaceColor(Index i, const DGtal::Color &aColor) ;
345
346
352
353
359 vertexBegin() const {
360 return myVertexList.begin();
361 }
362
363
369 vertexEnd() const {
370 return myVertexList.end();
371 }
372
373
380 return myVertexList.begin();
381 }
382
383
384
391 return myVertexList.end();
392 }
393
394
395
401 typename FaceStorage::const_iterator
402 faceBegin() const {
403 return myFaceList.begin();
404 }
405
406
407
413 typename FaceStorage::const_iterator
414 faceEnd() const {
415 return myFaceList.end();
416 }
417
418
424 typename FaceStorage::iterator
426 return myFaceList.begin();
427 }
428
429
430
436 typename FaceStorage::iterator
438 return myFaceList.end();
439 }
440
441
442
447 Size nbFaces() const;
448
453 Size nbVertex() const;
454
455
456
462
467
468
473
479
484 void rescale(const typename TPoint::Component aScale);
485
491 double subDivideTriangularFaces(const double minArea);
492
497 unsigned int quadToTriangularFaces();
498
503 void selfDisplay ( std::ostream & out ) const;
504
509 bool isValid() const;
510
511 // ------------------------- Private Datas --------------------------------
512 private:
518
519
520 // ------------------------- Mesh generation ------------------------------
521
522 public:
523
538 static
539 void
540 createTubularMesh(Mesh<TPoint> &aMesh, const std::vector<TPoint> &aSkeleton, const double aRadius,
541 const double angleStep = 0.2, const DGtal::Color &aMeshColor = DGtal::Color::White );
542
543
544
559 static
560 void
561 createTubularMesh(Mesh<TPoint> &aMesh, const std::vector<TPoint> &aSkeleton, const std::vector<double> &aVectOfRadius,
562 const double angleStep = 0.2, const DGtal::Color &aMeshColor = DGtal::Color::White );
563
583 template <typename TValue>
584 static
585 void
586 createMeshFromHeightSequence(Mesh<TPoint> &aMesh, const std::vector<TValue> & anValueSequence,
587 const unsigned int lengthSequence,
588 double stepX, double stepY, double stepZ,
589 const DGtal::Color &aMeshColor = DGtal::Color::White );
590
591
592
593
594
595
596
597
598
599 // ------------------------- Internals ------------------------------------
600 private:
601
603 {
604 CompPoints(typename TPoint::Dimension d): myDim(d){};
605 bool operator() (const TPoint &p1, const TPoint &p2){return p1[myDim]<p2[myDim];};
606 typename TPoint::Dimension myDim;
607 };
608
609
610
611
612
613
614
615
616 }; // end of class Mesh
617
618
625 template <typename TPoint>
626 std::ostream&
627 operator<< ( std::ostream & out, const Mesh<TPoint> & object );
628
629
630
631} // namespace DGtal
632
633
635// Includes inline functions.
636#include "DGtal/shapes/Mesh.ih"
637
638// //
640
641#endif // !defined Mesh_h
642
643#undef Mesh_RECURSES
644#endif // else defined(Mesh_RECURSES)
Structure representing an RGB triple with alpha component.
Definition Color.h:68
static const Color White
Definition Color.h:415
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition Mesh.h:92
const Color & getFaceColor(Index i) const
Mesh(const DGtal::Color &aColor)
DGtal::PointVector< TPoint::dimension, double > RealPoint
Definition Mesh.h:109
std::vector< TPoint > VertexStorage
Definition Mesh.h:115
std::pair< TPoint, TPoint > getBoundingBox() const
Mesh & operator=(const Mesh &other)
void clearVertices()
void addQuadFace(Index indexVertex1, Index indexVertex2, Index indexVertex3, Index indexVertex4, const DGtal::Color &aColor=DGtal::Color::White)
void rescale(const typename TPoint::Component aScale)
ColorStorage myFaceColorList
Definition Mesh.h:515
Size nbFaces() const
RealPoint getFaceBarycenter(Index i) const
Iterator vertexBegin()
Definition Mesh.h:379
MeshFace & getFace(Index i)
unsigned int quadToTriangularFaces()
Size nbVertex() const
void selfDisplay(std::ostream &out) const
void addFace(const MeshFace &aFace, const DGtal::Color &aColor=DGtal::Color::White)
bool isValid() const
const MeshFace & getFace(Index i) const
VertexStorage::iterator Iterator
Definition Mesh.h:148
void setFaceColor(Index i, const DGtal::Color &aColor)
std::vector< DGtal::Color > ColorStorage
Definition Mesh.h:137
void clearFaces()
Mesh(const Mesh &other)
FaceStorage::const_iterator faceEnd() const
Definition Mesh.h:414
std::string className() const
VertexStorage::const_iterator ConstIterator
Definition Mesh.h:143
void invertVertexFaceOrder()
Mesh(const std::vector< TPoint > &vertexSet)
Iterator vertexEnd()
Definition Mesh.h:390
static void createMeshFromHeightSequence(Mesh< TPoint > &aMesh, const std::vector< TValue > &anValueSequence, const unsigned int lengthSequence, double stepX, double stepY, double stepZ, const DGtal::Color &aMeshColor=DGtal::Color::White)
const TPoint & getVertex(Index i) const
std::size_t Size
Definition Mesh.h:153
TPoint & getVertex(Index i)
ConstIterator vertexEnd() const
Definition Mesh.h:369
VertexStorage::size_type Index
Definition Mesh.h:120
std::vector< Index > MeshFace
Definition Mesh.h:126
void removeFaces(const std::vector< Index > &facesIndex)
double subDivideTriangularFaces(const double minArea)
Mesh(bool saveFaceColor=false)
std::vector< MeshFace > FaceStorage
Definition Mesh.h:132
VertexStorage myVertexList
Definition Mesh.h:514
DGtal::Color myDefaultColor
Definition Mesh.h:517
void addTriangularFace(Index indexVertex1, Index indexVertex2, Index indexVertex3, const DGtal::Color &aColor=DGtal::Color::White)
static void createTubularMesh(Mesh< TPoint > &aMesh, const std::vector< TPoint > &aSkeleton, const std::vector< double > &aVectOfRadius, const double angleStep=0.2, const DGtal::Color &aMeshColor=DGtal::Color::White)
bool isStoringFaceColors() const
FaceStorage myFaceList
Definition Mesh.h:513
FaceStorage::iterator faceBegin()
Definition Mesh.h:425
bool mySaveFaceColor
Definition Mesh.h:516
FaceStorage::const_iterator faceBegin() const
Definition Mesh.h:402
FaceStorage::iterator faceEnd()
Definition Mesh.h:437
TPoint Point
Definition Mesh.h:102
ConstIterator vertexBegin() const
Definition Mesh.h:359
void removeIsolatedVertices()
static void createTubularMesh(Mesh< TPoint > &aMesh, const std::vector< TPoint > &aSkeleton, const double aRadius, const double angleStep=0.2, const DGtal::Color &aMeshColor=DGtal::Color::White)
void addVertex(const TPoint &vertex)
Aim: Implements basic operations that will be used in Point and Vector classes.
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
bool operator()(const TPoint &p1, const TPoint &p2)
Definition Mesh.h:605
CompPoints(typename TPoint::Dimension d)
Definition Mesh.h:604
TPoint::Dimension myDim
Definition Mesh.h:606