Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
exampleMeshVoxelizer.cpp
Go to the documentation of this file.
1
16
29
30
36
38#include <iostream>
39#include "ConfigExamples.h"
40#include "DGtal/helpers/StdDefs.h"
41#include "DGtal/base/Common.h"
42#include "DGtal/shapes/Mesh.h"
44#include "DGtal/shapes/MeshVoxelizer.h"
46#include "DGtal/io/writers/MeshWriter.h"
48
49using namespace std;
50using namespace DGtal;
51
53
54int main( )
55{
56 trace.beginBlock ( "Example MeshVoxelizer" );
57
58
60 using namespace Z3i;
61 Mesh<Point> aMesh;
62
63 trace.info()<<"Creating a cube"<<std::endl;
64 //Creating a cube
65 aMesh.addVertex(Point(0,0,0));
66 aMesh.addVertex(Point(1,0,0));
67 aMesh.addVertex(Point(1,1,0));
68 aMesh.addVertex(Point(0,1,0));
69 aMesh.addVertex(Point(0,1,1));
70 aMesh.addVertex(Point(1,1,1));
71 aMesh.addVertex(Point(1,0,1));
72 aMesh.addVertex(Point(0,0,1));
73
74 aMesh.addQuadFace(0,1,2,3);
75 aMesh.addQuadFace(1,2,5,6);
76 aMesh.addQuadFace(7,6,5,4);
77 aMesh.addQuadFace(3,2,5,4);
78 aMesh.addQuadFace(0,3,4,7);
79 aMesh.addQuadFace(0,1,6,7);
81
82
84 Domain domain(Point(0,0,0), Point(128,128,128));
85 DigitalSet outputSet(domain);
86
88
89 trace.info()<<"Digitization..."<<std::endl;
90 voxelizer.voxelize(outputSet, aMesh, 15.0);
91
92 trace.info()<<"Got "<< outputSet.size() << " voxels."<<std::endl;
94
95 trace.endBlock();
96 return 0;
97}
98// //
Aim: A class for computing the digitization of a triangle or a Mesh.
void voxelize(DigitalSet &outputSet, const Mesh< MeshPoint > &aMesh, const double scaleFactor=1.0)
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition Mesh.h:92
void addQuadFace(Index indexVertex1, Index indexVertex2, Index indexVertex3, Index indexVertex4, const DGtal::Color &aColor=DGtal::Color::White)
void addVertex(const TPoint &vertex)
int main()
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
STL namespace.
MyPointD Point
Domain domain
Z2i::DigitalSet DigitalSet