DGtal 1.3.0
Loading...
Searching...
No Matches
exampleMeshVoxelizer.cpp
Go to the documentation of this file.
1
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/boards/Board3D.h"
47#include "DGtal/io/writers/MeshWriter.h"
49
50using namespace std;
51using namespace DGtal;
52
54
55int main( )
56{
57 trace.beginBlock ( "Example MeshVoxelizer" );
58
59
61 using namespace Z3i;
62 Mesh<Point> aMesh;
63
64 trace.info()<<"Creating a cube"<<std::endl;
65 //Creating a cube
66 aMesh.addVertex(Point(0,0,0));
67 aMesh.addVertex(Point(1,0,0));
68 aMesh.addVertex(Point(1,1,0));
69 aMesh.addVertex(Point(0,1,0));
70 aMesh.addVertex(Point(0,1,1));
71 aMesh.addVertex(Point(1,1,1));
72 aMesh.addVertex(Point(1,0,1));
73 aMesh.addVertex(Point(0,0,1));
74
75 aMesh.addQuadFace(0,1,2,3);
76 aMesh.addQuadFace(1,2,5,6);
77 aMesh.addQuadFace(7,6,5,4);
78 aMesh.addQuadFace(3,2,5,4);
79 aMesh.addQuadFace(0,3,4,7);
80 aMesh.addQuadFace(0,1,6,7);
82
83
85 Domain domain(Point(0,0,0), Point(128,128,128));
86 DigitalSet outputSet(domain);
87
89
90 trace.info()<<"Digitization..."<<std::endl;
91 voxelizer.voxelize(outputSet, aMesh, 15.0);
92
93 trace.info()<<"Got "<< outputSet.size() << " voxels."<<std::endl;
95
97 Board3D<> board;
98 for(auto voxel : outputSet)
99 board << voxel;
100 board.saveOBJ("voxelizedCube.obj");
102
103
104
105 trace.endBlock();
106 return 0;
107}
108// //
The class Board3D is a type of Display3D which export the figures in the format OBJ/MTL when calling ...
Definition: Board3D.h:82
void saveOBJ(const std::string &filename, const bool isNormalized=false)
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: A class for computing the digitization of a triangle or a Mesh.
Definition: MeshVoxelizer.h:80
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)
void beginBlock(const std::string &keyword="")
std::ostream & info()
double endBlock()
int main()
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:154
STL namespace.
MyPointD Point
Definition: testClone2.cpp:383
Domain domain