53 #include "DGtal/base/Common.h"
54 #include "DGtal/helpers/StdDefs.h"
55 #include "ConfigExamples.h"
57 #include "DGtal/shapes/Mesh.h"
58 #include "DGtal/shapes/SurfaceMesh.h"
59 #include "DGtal/shapes/SurfaceMeshHelper.h"
60 #include "DGtal/shapes/MeshHelpers.h"
61 #include "DGtal/graph/BreadthFirstVisitor.h"
62 #include "DGtal/io/readers/SurfaceMeshReader.h"
63 #include "DGtal/io/writers/SurfaceMeshWriter.h"
64 #include "DGtal/io/viewers/Viewer3D.h"
65 #include "DGtal/io/Color.h"
66 #include "DGtal/io/colormaps/GradientColorMap.h"
71 using namespace DGtal;
76 int main(
int argc,
char** argv )
88 std::string S = examplesPath +
"samples/spot.obj";
89 std::ifstream input( S.c_str() );
92 trace.
info() <<
"Read " << ( ok_read ?
"OK" :
"ERROR" )
93 <<
" mesh=" << smesh << std::endl;
99 auto torus_mesh = Helper::makeTorus
100 ( 2.5, 0.5,
RealPoint { 0.0, 0.0, 0.0 }, 40, 40, 0, Helper::NormalsType::NO_NORMALS );
106 std::vector< RealPoint > positions =
107 { { 0, 0, 5 }, { 1, 1, 3 }, { -1, 1, 3 }, { -1, -1, 3 }, { 1, -1, 3 } };
108 std::vector< Vertices > faces =
109 { { 0, 1, 2 }, { 0, 2, 3 }, { 0, 3, 4 }, { 0, 4, 1 }, { 4, 3, 2, 1 } };
110 auto pyramid_mesh =
SurfMesh( positions.cbegin(), positions.cend(),
111 faces.cbegin(), faces.cend() );
118 std::vector<double> distances( smesh.
nbVertices() );
119 double biggest_d = 0.0;
122 auto v = visitor.
current().first;
123 auto d = visitor.
current().second;
124 biggest_d = (double) d;
125 distances[ v ] = biggest_d;
136 std::vector<Color> face_colors( smesh.
nbFaces() );
138 face_colors[ j ] = cmap( face_distances[ j ] );
140 Writer::writeOBJ(
"spot-bft.obj", smesh, face_colors );
143 Writer::writeIsoLinesOBJ(
"spot-iso-0_25.obj", smesh,
144 face_distances, distances, distances.back() * 0.25, 0.2 );
145 Writer::writeIsoLinesOBJ(
"spot-iso-0_5.obj", smesh,
146 face_distances, distances, distances.back() * 0.5, 0.2 );
147 Writer::writeIsoLinesOBJ(
"spot-iso-0_75.obj", smesh,
148 face_distances, distances, distances.back() * 0.75, 0.2 );
155 MeshHelpers::surfaceMesh2Mesh( smesh, viewmesh , face_colors );
156 MeshHelpers::surfaceMesh2Mesh( torus_mesh, viewmesh2 );
157 MeshHelpers::surfaceMesh2Mesh( pyramid_mesh, viewmesh3 );
159 QApplication application(argc,argv);
162 viewer << viewmesh << viewmesh2 << viewmesh3;
163 viewer << Viewer3D<>::updateDisplay;
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
const Node & current() const
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Aim: Implements basic operations that will be used in Point and Vector classes.
void beginBlock(const std::string &keyword="")
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
SurfaceMesh< RealPoint, RealVector > SurfMesh
int main(int argc, char **argv)
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: An helper class for building classical meshes.
Aim: An helper class for reading mesh files (Wavefront OBJ at this point) and creating a SurfaceMesh.
Aim: An helper class for writing mesh file formats (Waverfront OBJ at this point) and creating a Surf...
Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces ...
std::vector< Vertex > Vertices
The type that defines a list/range of vertices (e.g. to define faces)
std::vector< AnyRing > computeFaceValuesFromVertexValues(const std::vector< AnyRing > &vvalues) const