DGtal  1.3.beta
MeshHelpers.h
1 
17 #pragma once
18 
31 #if defined(MeshHelpers_RECURSES)
32 #error Recursive header files inclusion detected in MeshHelpers.h
33 #else // defined(MeshHelpers_RECURSES)
34 
35 #define MeshHelpers_RECURSES
36 
37 #if !defined MeshHelpers_h
38 
39 #define MeshHelpers_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/topology/CCellEmbedder.h"
46 #include "DGtal/topology/CDigitalSurfaceContainer.h"
47 #include "DGtal/topology/DigitalSurface.h"
48 #include "DGtal/shapes/TriangulatedSurface.h"
49 #include "DGtal/shapes/PolygonalSurface.h"
50 #include "DGtal/shapes/Mesh.h"
51 #include "DGtal/shapes/SurfaceMesh.h"
53 
54 namespace DGtal
55 {
56 
58  // template class MeshHelpers
64  {
65  // ----------------------- Static services ------------------------------
66  public:
80  template <typename Point>
81  static
83  ( const Mesh<Point>& mesh,
84  TriangulatedSurface<Point>& trisurf );
85 
96  template <typename Point>
97  static
99  ( const Mesh<Point>& mesh,
100  PolygonalSurface<Point>& polysurf );
101 
129  template <typename Point>
130  static
132  ( const PolygonalSurface<Point>& polysurf,
134  bool centroid = true );
135 
152  template < typename DigitalSurfaceContainer,
153  typename CellEmbedder,
154  typename VertexMap >
155  static
158  const CellEmbedder& cembedder,
160  VertexMap& vertexmap );
161 
173  template < typename DigitalSurfaceContainer,
174  typename CellEmbedder,
175  typename VertexMap >
176  static
179  const CellEmbedder& cembedder,
181  VertexMap& vertexmap );
182 
196  template < typename DigitalSurfaceContainer,
197  typename CellEmbedder,
198  typename CellMap >
199  static
202  const CellEmbedder& cembedder,
204  CellMap& cellmap );
205 
220  template < typename DigitalSurfaceContainer,
221  typename CellEmbedder,
222  typename CellMap >
223  static
226  const CellEmbedder& cembedder,
228  CellMap& cellmap );
229 
230 
239  template <typename Point>
240  static
242  ( const TriangulatedSurface<Point>& trisurf,
243  Mesh<Point>& mesh );
244 
253  template <typename Point>
254  static
256  ( const PolygonalSurface<Point>& polysurf,
257  Mesh<Point>& mesh );
258 
269  template < typename RealPoint, typename RealVector >
270  static
271  void surfaceMesh2Mesh
273  Mesh< RealPoint >& mesh, const std::vector<Color> &cols = {} );
274 
281  template <typename Point>
282  static
283  bool exportOBJ
284  ( std::ostream& output,
285  const TriangulatedSurface<Point>& trisurf );
286 
293  template <typename Point>
294  static
295  bool exportOBJ
296  ( std::ostream& output,
297  const PolygonalSurface<Point>& polysurf );
298 
299 
313  template <typename TTriangulatedOrPolygonalSurface>
314  static
316  ( std::ostream& output_obj,
317  const std::string& mtl_filename,
318  const TTriangulatedOrPolygonalSurface& polysurf,
319  const std::vector< typename TTriangulatedOrPolygonalSurface::Point >& normals,
320  const std::vector< Color >& diffuse_colors,
321  const Color& ambient_color = Color( 32, 32, 32 ),
322  const Color& diffuse_color = Color( 200, 200, 255 ),
323  const Color& specular_color = Color::White );
324 
325 
333  static
335  ( std::ostream& output_mtl,
336  unsigned int idxMaterial,
337  const Color& ambient_color,
338  const Color& diffuse_color,
339  const Color& specular_color );
340 
341  }; // end of class MeshHelpers
342 
343 } // namespace DGtal
344 
345 
347 // Includes inline functions.
348 #include "DGtal/shapes/MeshHelpers.ih"
349 
350 // //
352 
353 #endif // !defined MeshHelpers_h
354 
355 #undef MeshHelpers_RECURSES
356 #endif // else defined(MeshHelpers_RECURSES)
DGtal::MeshHelpers::polygonalSurface2Mesh
static void polygonalSurface2Mesh(const PolygonalSurface< Point > &polysurf, Mesh< Point > &mesh)
DGtal::DigitalSurface
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
Definition: DigitalSurface.h:139
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:67
DGtal::SurfaceMesh
Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces ...
Definition: SurfaceMesh.h:91
DGtal::MeshHelpers::exportMTLNewMaterial
static bool exportMTLNewMaterial(std::ostream &output_mtl, unsigned int idxMaterial, const Color &ambient_color, const Color &diffuse_color, const Color &specular_color)
DGtal::MeshHelpers::digitalSurface2DualPolygonalSurface
static void digitalSurface2DualPolygonalSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, PolygonalSurface< typename CellEmbedder::Value > &polysurf, VertexMap &vertexmap)
DGtal::MeshHelpers::mesh2PolygonalSurface
static bool mesh2PolygonalSurface(const Mesh< Point > &mesh, PolygonalSurface< Point > &polysurf)
DGtal::MeshHelpers::digitalSurface2PrimalPolygonalSurface
static bool digitalSurface2PrimalPolygonalSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, PolygonalSurface< typename CellEmbedder::Value > &polysurf, CellMap &cellmap)
DGtal::MeshHelpers::triangulatedSurface2Mesh
static void triangulatedSurface2Mesh(const TriangulatedSurface< Point > &trisurf, Mesh< Point > &mesh)
DGtal::Color::White
static const Color White
Definition: Color.h:415
DGtal::MeshHelpers::exportOBJ
static bool exportOBJ(std::ostream &output, const TriangulatedSurface< Point > &trisurf)
DGtal::MeshHelpers::exportOBJwithFaceNormalAndColor
static bool exportOBJwithFaceNormalAndColor(std::ostream &output_obj, const std::string &mtl_filename, const TTriangulatedOrPolygonalSurface &polysurf, const std::vector< typename TTriangulatedOrPolygonalSurface::Point > &normals, const std::vector< Color > &diffuse_colors, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
DGtal::Mesh
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition: Mesh.h:91
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::MeshHelpers::surfaceMesh2Mesh
static void surfaceMesh2Mesh(const SurfaceMesh< RealPoint, RealVector > &smesh, Mesh< RealPoint > &mesh, const std::vector< Color > &cols={})
DGtal::MeshHelpers
Aim: Static class that provides builder and converters between meshes.
Definition: MeshHelpers.h:63
DGtal::MeshHelpers::polygonalSurface2TriangulatedSurface
static void polygonalSurface2TriangulatedSurface(const PolygonalSurface< Point > &polysurf, TriangulatedSurface< Point > &trisurf, bool centroid=true)
DGtal::TriangulatedSurface
Aim: Represents a triangulated surface. The topology is stored with a half-edge data structure....
Definition: TriangulatedSurface.h:85
DGtal::MeshHelpers::digitalSurface2PrimalSurfaceMesh
static bool digitalSurface2PrimalSurfaceMesh(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, SurfaceMesh< typename CellEmbedder::Value, typename CellEmbedder::Value > &polysurf, CellMap &cellmap)
DGtal::MeshHelpers::mesh2TriangulatedSurface
static bool mesh2TriangulatedSurface(const Mesh< Point > &mesh, TriangulatedSurface< Point > &trisurf)
DGtal::PolygonalSurface
Aim: Represents a polygon mesh, i.e. a 2-dimensional combinatorial surface whose faces are (topologic...
Definition: PolygonalSurface.h:86
DGtal::MeshHelpers::digitalSurface2DualTriangulatedSurface
static void digitalSurface2DualTriangulatedSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, TriangulatedSurface< typename CellEmbedder::Value > &trisurf, VertexMap &vertexmap)