DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
MeshFromPoints.h
1 
17 #pragma once
18 
31 #if defined(MeshFromPoints_RECURSES)
32 #error Recursive header files inclusion detected in MeshFromPoints.h
33 #else // defined(MeshFromPoints_RECURSES)
34 
35 #define MeshFromPoints_RECURSES
36 
37 #if !defined MeshFromPoints_h
38 
39 #define MeshFromPoints_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <vector>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/io/Color.h"
48 
49 namespace DGtal
50 {
51 
52 
54  // template class MeshFromPoints
85  template <typename TPoint >
87  {
88 
89 
90 
91 
92  // ----------------------- associated types ------------------------------
93  public:
98  typedef std::vector<unsigned int> MeshFace;
99 
100 
101 
102 
103  // ----------------------- Standard services ------------------------------
104  public:
112  MeshFromPoints(bool saveFaceColor=false);
113 
120  MeshFromPoints(const DGtal::Color &aColor);
121 
127  MeshFromPoints(const std::vector<TPoint> &vertexSet);
128 
132  ~MeshFromPoints();
133 
134 
135 
136 
137  // --------------- CDrawableWithDisplay3D realization -------------------
138  public:
139 
143  std::string className() const;
144 
145 
146 
147 
148  // ----------------------- Interface --------------------------------------
149  public:
150 
151 
156  void addVertex(const TPoint &vertex);
157 
158 
159 
168  void addTriangularFace(unsigned int indexVertex1, unsigned int indexVertex2, unsigned int indexVertex3,
169  const DGtal::Color &aColor=DGtal::Color::White);
170 
171 
180  void addQuadFace(unsigned int indexVertex1, unsigned int indexVertex2,
181  unsigned int indexVertex3, unsigned int indexVertex4,
182  const DGtal::Color & aColor=DGtal::Color::White);
183 
184 
190  void addFace(const MeshFace &aFace, const DGtal::Color &aColor=DGtal::Color::White);
191 
192 
193 
199  const TPoint & getVertex(unsigned int i) const;
200 
201 
202 
208  const MeshFace & getFace(unsigned int i) const;
209 
210 
211 
217  const Color & getFaceColor(unsigned int i) const;
218 
219 
220 
221 
222 
223 
228  unsigned int nbFaces() const;
229 
234  unsigned int nbVertex() const;
235 
236 
237 
243  void invertVertexFaceOrder();
244 
245 
246 
251  void selfDisplay ( std::ostream & out ) const;
252 
257  bool isValid() const;
258 
259  // ------------------------- Protected Datas ------------------------------
260  private:
261 
262 
263 
264 
265  // ------------------------- Private Datas --------------------------------
266  private:
267  std::vector<MeshFace> myFaceList;
268  std::vector<TPoint> myVertexList;
269  std::vector<DGtal::Color> myFaceColorList;
272 
273 
274 
275  // ------------------------- Hidden services ------------------------------
276  protected:
277 
278 
279 
280 
281 
282 
283 
284 
285 
286  private:
287 
293  MeshFromPoints ( const MeshFromPoints & other );
294 
301  MeshFromPoints & operator= ( const MeshFromPoints & other );
302 
303  // ------------------------- Internals ------------------------------------
304  private:
305 
306 
307 
308 
309 
310 
311 
312 
313  }; // end of class MeshFromPoints
314 
315 
322  template <typename TPoint>
323  std::ostream&
324  operator<< ( std::ostream & out, const MeshFromPoints<TPoint> & object );
325 
326 } // namespace DGtal
327 
328 
330 // Includes inline functions.
331 #include "DGtal/shapes/fromPoints/MeshFromPoints.ih"
332 
333 // //
335 
336 #endif // !defined MeshFromPoints_h
337 
338 #undef MeshFromPoints_RECURSES
339 #endif // else defined(MeshFromPoints_RECURSES)