DGtal 1.3.0
Loading...
Searching...
No Matches
Static Public Member Functions
DGtal::MeshHelpers Class Reference

Aim: Static class that provides builder and converters between meshes. More...

#include <DGtal/shapes/MeshHelpers.h>

Static Public Member Functions

template<typename Point >
static bool mesh2TriangulatedSurface (const Mesh< Point > &mesh, TriangulatedSurface< Point > &trisurf)
 
template<typename Point >
static bool mesh2PolygonalSurface (const Mesh< Point > &mesh, PolygonalSurface< Point > &polysurf)
 
template<typename Point >
static void polygonalSurface2TriangulatedSurface (const PolygonalSurface< Point > &polysurf, TriangulatedSurface< Point > &trisurf, bool centroid=true)
 
template<typename DigitalSurfaceContainer , typename CellEmbedder , typename VertexMap >
static void digitalSurface2DualTriangulatedSurface (const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, TriangulatedSurface< typename CellEmbedder::Value > &trisurf, VertexMap &vertexmap)
 
template<typename DigitalSurfaceContainer , typename CellEmbedder , typename VertexMap >
static void digitalSurface2DualPolygonalSurface (const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, PolygonalSurface< typename CellEmbedder::Value > &polysurf, VertexMap &vertexmap)
 
template<typename DigitalSurfaceContainer , typename CellEmbedder , typename CellMap >
static bool digitalSurface2PrimalPolygonalSurface (const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, PolygonalSurface< typename CellEmbedder::Value > &polysurf, CellMap &cellmap)
 
template<typename DigitalSurfaceContainer , typename CellEmbedder , typename CellMap >
static bool digitalSurface2PrimalSurfaceMesh (const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, SurfaceMesh< typename CellEmbedder::Value, typename CellEmbedder::Value > &polysurf, CellMap &cellmap)
 
template<typename Point >
static void triangulatedSurface2Mesh (const TriangulatedSurface< Point > &trisurf, Mesh< Point > &mesh)
 
template<typename Point >
static void polygonalSurface2Mesh (const PolygonalSurface< Point > &polysurf, Mesh< Point > &mesh)
 
template<typename RealPoint , typename RealVector >
static void surfaceMesh2Mesh (const SurfaceMesh< RealPoint, RealVector > &smesh, Mesh< RealPoint > &mesh, const std::vector< Color > &cols={})
 
template<typename Point >
static bool exportOBJ (std::ostream &output, const TriangulatedSurface< Point > &trisurf)
 
template<typename Point >
static bool exportOBJ (std::ostream &output, const PolygonalSurface< Point > &polysurf)
 
template<typename TTriangulatedOrPolygonalSurface >
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)
 
static bool exportMTLNewMaterial (std::ostream &output_mtl, unsigned long idxMaterial, const Color &ambient_color, const Color &diffuse_color, const Color &specular_color)
 

Detailed Description

Aim: Static class that provides builder and converters between meshes.

Description of template class 'MeshHelpers'

Definition at line 63 of file MeshHelpers.h.

Member Function Documentation

◆ digitalSurface2DualPolygonalSurface()

template<typename DigitalSurfaceContainer , typename CellEmbedder , typename VertexMap >
static void DGtal::MeshHelpers::digitalSurface2DualPolygonalSurface ( const DigitalSurface< DigitalSurfaceContainer > &  dsurf,
const CellEmbedder &  cembedder,
PolygonalSurface< typename CellEmbedder::Value > &  polysurf,
VertexMap &  vertexmap 
)
static

Builds a polygonal surface (class PolygonalSurface) from the dual graph of a 2-dimensional digital surface in K^3 (class DigitalSurface).

Template Parameters
DigitalSurfaceContainerthe container chosen for the digital surface.
CellEmbedderthe embedder chosen for the digital surface.
Parameters
[in]dsurfthe input digital surface.
[in]cembedderthe embedder for 2-cells of the digital surface, which are vertices in the output polygonal surface.
[out]polysurfthe output polygonal surface mesh.
[out]vertexmapthe output mapping between a Vertex of dsurf and an Index in polysurf.

Referenced by main(), DGtal::Shortcuts< TKSpace >::makeDualPolygonalSurface(), and DGtal::Shortcuts< TKSpace >::makePolygonalSurface().

◆ digitalSurface2DualTriangulatedSurface()

template<typename DigitalSurfaceContainer , typename CellEmbedder , typename VertexMap >
static void DGtal::MeshHelpers::digitalSurface2DualTriangulatedSurface ( const DigitalSurface< DigitalSurfaceContainer > &  dsurf,
const CellEmbedder &  cembedder,
TriangulatedSurface< typename CellEmbedder::Value > &  trisurf,
VertexMap &  vertexmap 
)
static

Builds a triangulated surface (class TriangulatedSurface) from the dual graph of a 2-dimensional digital surface in K^3 (class DigitalSurface).

Note
that a triangulated surface contains only triangles, so faces of the input dual graph of the digital surface mesh are triangulated by adding a new vertex at the barycenter of the face vertices.
Template Parameters
DigitalSurfaceContainerthe container chosen for the digital surface.
CellEmbedderthe embedder chosen for the digital surface.
Parameters
[in]dsurfthe input digital surface.
[in]cembedderthe embedder for 2-cells of the digital surface, which are vertices in the output triangulated surface.
[out]trisurfthe output triangulated surface mesh.
[out]vertexmapthe output mapping between a Vertex of dsurf and an Index in trisurf.

Referenced by laplacian(), main(), and DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface().

◆ digitalSurface2PrimalPolygonalSurface()

template<typename DigitalSurfaceContainer , typename CellEmbedder , typename CellMap >
static bool DGtal::MeshHelpers::digitalSurface2PrimalPolygonalSurface ( const DigitalSurface< DigitalSurfaceContainer > &  dsurf,
const CellEmbedder &  cembedder,
PolygonalSurface< typename CellEmbedder::Value > &  polysurf,
CellMap &  cellmap 
)
static

Builds a polygonal surface (class PolygonalSurface) from the primal graph of a 2-dimensional digital surface in K^3 (class DigitalSurface).

Template Parameters
DigitalSurfaceContainerthe container chosen for the digital surface.
CellEmbedderthe embedder chosen for the digital surface.
CellMapthe type for encoding the map 0-cell -> Index.
Parameters
[in]dsurfthe input digital surface.
[in]cembedderthe embedder for 0-cells of the digital surface, which are vertices in the output polygonal surface.
[out]polysurfthe output polygonal surface mesh.
[out]cellmapthe output mapping between a 0-cell of dsurf and an Index in polysurf.
Returns
'true' if it was able to build the primal polygonal surface, otherwise the digital surface was not a combinatorial 2-manifold and is not valid.

Referenced by DGtal::Shortcuts< TKSpace >::makePrimalPolygonalSurface().

◆ digitalSurface2PrimalSurfaceMesh()

template<typename DigitalSurfaceContainer , typename CellEmbedder , typename CellMap >
static bool DGtal::MeshHelpers::digitalSurface2PrimalSurfaceMesh ( const DigitalSurface< DigitalSurfaceContainer > &  dsurf,
const CellEmbedder &  cembedder,
SurfaceMesh< typename CellEmbedder::Value, typename CellEmbedder::Value > &  polysurf,
CellMap &  cellmap 
)
static

Builds a polygonal surface (class SurfaceMesh) from the primal graph of a digital surface in K^3 (class DigitalSurface). The digital surface does not need to be a combinatorial 2-manifold.

Template Parameters
DigitalSurfaceContainerthe container chosen for the digital surface.
CellEmbedderthe embedder chosen for the digital surface.
CellMapthe type for encoding the map 0-cell -> Index.
Parameters
[in]dsurfthe input digital surface.
[in]cembedderthe embedder for 0-cells of the digital surface, which are vertices in the output polygonal surface.
[out]polysurfthe output polygonal surface mesh.
[out]cellmapthe output mapping between a 0-cell of dsurf and an Index in polysurf.
Returns
'true' if it was able to build the primal polygonal surface, otherwise the digital surface was not a combinatorial 2-manifold and is not valid.

Referenced by DGtal::Shortcuts< TKSpace >::makePrimalSurfaceMesh().

◆ exportMTLNewMaterial()

static bool DGtal::MeshHelpers::exportMTLNewMaterial ( std::ostream &  output_mtl,
unsigned long  idxMaterial,
const Color ambient_color,
const Color diffuse_color,
const Color specular_color 
)
static

Exports a new material in a MTL stream.

Parameters
[in,out]output_mtlan output stream into a MTL file
[in]idxMaterialthe index of the new material.
[in]ambient_colorthe ambient color for the material.
[in]diffuse_colorthe diffuse color for the material.
[in]specular_colorthe specular color for the material.

Referenced by DGtal::Shortcuts< TKSpace >::saveOBJ(), and DGtal::Shortcuts< TKSpace >::saveVectorFieldOBJ().

◆ exportOBJ() [1/2]

template<typename Point >
static bool DGtal::MeshHelpers::exportOBJ ( std::ostream &  output,
const PolygonalSurface< Point > &  polysurf 
)
static

Exports a polygonal surface as an OBJ file (with topology) into the given output stream.

Template Parameters
Pointthe type for points.
Parameters
[in,out]outputan output stream
[in]polysurfthe input polygonal surface mesh.

◆ exportOBJ() [2/2]

template<typename Point >
static bool DGtal::MeshHelpers::exportOBJ ( std::ostream &  output,
const TriangulatedSurface< Point > &  trisurf 
)
static

Exports a triangulated surface as an OBJ file (with topology) into the given output stream.

Template Parameters
Pointthe type for points.
Parameters
[in,out]outputan output stream
[in]trisurfthe input triangulated surface mesh.

Referenced by DGtal::Shortcuts< TKSpace >::saveOBJ().

◆ exportOBJwithFaceNormalAndColor()

template<typename TTriangulatedOrPolygonalSurface >
static bool DGtal::MeshHelpers::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 
)
static

Exports a triangulated or polygonal surface as an OBJ file (with topology) into the given output stream. It can also specifies normals per face and colors per face.

Template Parameters
TTriangulatedOrPolygonalSurfaceeither some TriangulatedSurface or some PolygonalSurface.
Parameters
[in,out]output_objan output stream where the OBJ file is written.
[in]mtl_filenamethe name of the material filename (stores colors).
[in]polysurfthe input triangulated or polygonal surface mesh.
[in]normalseither empty or a vector of size polysurf.nbFaces specifying the normal vector for each face.
[in]diffuse_colorseither empty or a vector of size polysurf.nbFaces specifying the diffuse color for each face.
[in]ambient_colorthe ambient color of all faces.
[in]diffuse_colorthe diffuse color of all faces if diffuse_colors was empty.
[in]specular_colorthe specular color of all faces.

Referenced by DGtal::Shortcuts< TKSpace >::saveOBJ().

◆ mesh2PolygonalSurface()

template<typename Point >
static bool DGtal::MeshHelpers::mesh2PolygonalSurface ( const Mesh< Point > &  mesh,
PolygonalSurface< Point > &  polysurf 
)
static

Builds a polygon mesh (class PolygonalSurface) from a mesh (class Mesh). The output polygonal surface rebuilds a topology between faces.

Template Parameters
Pointthe type for points.
Parameters
[in]meshthe input mesh.
[out]polysurfthe output polygonal surface mesh.
Returns
'true' on success, 'false' if the input mesh was not a combinatorial surface.

Referenced by DGtal::Shortcuts< TKSpace >::makePolygonalSurface(), and SCENARIO().

◆ mesh2TriangulatedSurface()

template<typename Point >
static bool DGtal::MeshHelpers::mesh2TriangulatedSurface ( const Mesh< Point > &  mesh,
TriangulatedSurface< Point > &  trisurf 
)
static

Builds a triangulated surface (class TriangulatedSurface) from a mesh (class Mesh). Note that a triangulated surface contains only triangles, so polygonal faces (0,1,2,3,4,...) of the input mesh are (naively) triangulated (triangles (0,1,2), (0,2,3), (0,3,4), etc). Furthermore, the output triangulated surface rebuilds a topology between faces.

Template Parameters
Pointthe type for points.
Parameters
[in]meshthe input mesh.
[out]trisurfthe output triangulated surface mesh.
Returns
'true' on success, 'false' if the input mesh was not a combinatorial surface.

Referenced by DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface(), and SCENARIO().

◆ polygonalSurface2Mesh()

template<typename Point >
static void DGtal::MeshHelpers::polygonalSurface2Mesh ( const PolygonalSurface< Point > &  polysurf,
Mesh< Point > &  mesh 
)
static

Builds a mesh (class Mesh) from a polygon mesh (class PolygonalSurface). Note that the mesh looses the topology of the polygonal surface, since it is essentially a soup of triangles.

Template Parameters
Pointthe type for points.
Parameters
[in]polysurfthe input polygonal surface (ie a polygon mesh).
[in,out]meshthe output mesh (which should be empty).

Referenced by main(), DGtal::Shortcuts< TKSpace >::makeMesh(), DGtal::Shortcuts< TKSpace >::saveOFF(), and SCENARIO().

◆ polygonalSurface2TriangulatedSurface()

template<typename Point >
static void DGtal::MeshHelpers::polygonalSurface2TriangulatedSurface ( const PolygonalSurface< Point > &  polysurf,
TriangulatedSurface< Point > &  trisurf,
bool  centroid = true 
)
static

Builds a polygonal surface from a triangulated surface. Polygonal faces are triangulated according to centroid: when 'true', creates a vertex in each non triangular face, otherwise creates triangles (0,i,i+1) in face (0, 1, ..., n) for i < n-1.

Template Parameters
Pointthe type for points.
Parameters
[in]polysurfthe input polygonal surface mesh.
[out]trisurfthe output triangulated surface.
[in]centroidwhen 'true' creates a vertex in the middle of non triangular faces and a fan around it, otherwise naively subdivides the face as a fan around the first vertex.
Note
The vertices of trisurf are the same as the one of polysurf, except if there are newly created vertices (centroid case) which are put at the end.
Be very careful with "Naive" subdivision, since it may create non-manifold edges on general polygonal surfaces. Indeed, take the closed surface made of faces (0, 1, 2, 3) and (3, 2, 1, 0). Depending on how faces are triangulated, it is still a valid combinatorial triangulated 2-manifold (e.g. (0,1,2,3) gives (0,1,2) and (2,0,3) and (3,2,1,0) gives (3,2,1) and (1,3,0)) or a non-valid one (e.g. (0,1,2,3) gives (0,1,2) and (2,0,3) and (3,2,1,0) gives (3,2,0) and (0,2,1): then edge {2,0} is shared by four faces).

Referenced by DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface().

◆ surfaceMesh2Mesh()

template<typename RealPoint , typename RealVector >
static void DGtal::MeshHelpers::surfaceMesh2Mesh ( const SurfaceMesh< RealPoint, RealVector > &  smesh,
Mesh< RealPoint > &  mesh,
const std::vector< Color > &  cols = {} 
)
static

Builds a mesh (class Mesh) from a surface mesh (class SurfaceMesh). Note that the mesh looses the topology of the surface mesh, since it is essentially a soup of triangles.

Template Parameters
RealPointthe type for 3d points.
RealVectorthe type for 3d vectors.
Parameters
[in]smeshthe input surface mesh.
[in]colsa vector defining the face colors.
[in,out]meshthe output mesh (which should be empty).

Referenced by main().

◆ triangulatedSurface2Mesh()

template<typename Point >
static void DGtal::MeshHelpers::triangulatedSurface2Mesh ( const TriangulatedSurface< Point > &  trisurf,
Mesh< Point > &  mesh 
)
static

Builds a mesh (class Mesh) from a triangulated surface (class TriangulatedSurface). Note that the mesh looses the topology of the triangulated surface, since it is essentially a soup of triangles.

Template Parameters
Pointthe type for points.
Parameters
[in]trisurfthe input triangulated surface mesh.
[in,out]meshthe output mesh (which should be empty).

Referenced by laplacian(), main(), DGtal::Shortcuts< TKSpace >::makeMesh(), DGtal::Shortcuts< TKSpace >::saveOFF(), and SCENARIO().


The documentation for this class was generated from the following file: