DGtal 1.3.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
472 void changeScale(const typename TPoint::Component aScale);
473
479 double subDivideTriangularFaces(const double minArea);
480
485 unsigned int quadToTriangularFaces();
486
491 void selfDisplay ( std::ostream & out ) const;
492
497 bool isValid() const;
498
499 // ------------------------- Private Datas --------------------------------
500 private:
506
507
508 // ------------------------- Mesh generation ------------------------------
509
510 public:
511
526 static
527 void
528 createTubularMesh(Mesh<TPoint> &aMesh, const std::vector<TPoint> &aSkeleton, const double aRadius,
529 const double angleStep = 0.2, const DGtal::Color &aMeshColor = DGtal::Color::White );
530
531
532
547 static
548 void
549 createTubularMesh(Mesh<TPoint> &aMesh, const std::vector<TPoint> &aSkeleton, const std::vector<double> &aVectOfRadius,
550 const double angleStep = 0.2, const DGtal::Color &aMeshColor = DGtal::Color::White );
551
571 template <typename TValue>
572 static
573 void
574 createMeshFromHeightSequence(Mesh<TPoint> &aMesh, const std::vector<TValue> & anValueSequence,
575 const unsigned int lengthSequence,
576 double stepX, double stepY, double stepZ,
577 const DGtal::Color &aMeshColor = DGtal::Color::White );
578
579
580
581
582
583
584
585
586
587 // ------------------------- Internals ------------------------------------
588 private:
589
591 {
592 CompPoints(typename TPoint::Dimension d): myDim(d){};
593 bool operator() (const TPoint &p1, const TPoint &p2){return p1[myDim]<p2[myDim];};
594 typename TPoint::Dimension myDim;
595 };
596
597
598
599
600
601
602
603
604 }; // end of class Mesh
605
606
613 template <typename TPoint>
614 std::ostream&
615 operator<< ( std::ostream & out, const Mesh<TPoint> & object );
616
617
618
619} // namespace DGtal
620
621
623// Includes inline functions.
624#include "DGtal/shapes/Mesh.ih"
625
626// //
628
629#endif // !defined Mesh_h
630
631#undef Mesh_RECURSES
632#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 addQuadFace(Index indexVertex1, Index indexVertex2, Index indexVertex3, Index indexVertex4, const DGtal::Color &aColor=DGtal::Color::White)
ColorStorage myFaceColorList
Definition: Mesh.h:503
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
void changeScale(const typename TPoint::Component aScale)
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:502
DGtal::Color myDefaultColor
Definition: Mesh.h:505
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:501
FaceStorage::iterator faceBegin()
Definition: Mesh.h:425
bool mySaveFaceColor
Definition: Mesh.h:504
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
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.
Definition: PointVector.h:593
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:593
CompPoints(typename TPoint::Dimension d)
Definition: Mesh.h:592
TPoint::Dimension myDim
Definition: Mesh.h:594