DGtal  1.1.0
shapes/exampleMeshVoxelizer.cpp
Resulting digitization of a cube
#include <iostream>
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/Common.h"
#include "DGtal/shapes/Mesh.h"
#include "DGtal/shapes/MeshVoxelizer.h"
#include "DGtal/io/boards/Board3D.h"
#include "DGtal/io/writers/MeshWriter.h"
using namespace std;
using namespace DGtal;
int main( )
{
trace.beginBlock ( "Example MeshVoxelizer" );
using namespace Z3i;
Mesh<Point> aMesh;
trace.info()<<"Creating a cube"<<std::endl;
//Creating a cube
aMesh.addVertex(Point(0,0,0));
aMesh.addVertex(Point(1,0,0));
aMesh.addVertex(Point(1,1,0));
aMesh.addVertex(Point(0,1,0));
aMesh.addVertex(Point(0,1,1));
aMesh.addVertex(Point(1,1,1));
aMesh.addVertex(Point(1,0,1));
aMesh.addVertex(Point(0,0,1));
aMesh.addQuadFace(0,1,2,3);
aMesh.addQuadFace(1,2,5,6);
aMesh.addQuadFace(7,6,5,4);
aMesh.addQuadFace(3,2,5,4);
aMesh.addQuadFace(0,3,4,7);
aMesh.addQuadFace(0,1,6,7);
Domain domain(Point(0,0,0), Point(128,128,128));
DigitalSet outputSet(domain);
trace.info()<<"Digitization..."<<std::endl;
voxelizer.voxelize(outputSet, aMesh, 15.0);
trace.info()<<"Got "<< outputSet.size() << " voxels."<<std::endl;
Board3D<> board;
for(auto voxel : outputSet)
board << voxel;
board.saveOBJ("voxelizedCube.obj");
return 0;
}
// //
DGtal::HyperRectDomain< Space >
DGtal::Trace::endBlock
double endBlock()
DGtal::trace
Trace trace
Definition: Common.h:150
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Board3D
The class Board3D is a type of Display3D which export the figures in the format OBJ/MTL when calling ...
Definition: Board3D.h:82
DGtal::Mesh::addVertex
void addVertex(const TPoint &vertex)
DGtal::Trace::info
std::ostream & info()
DGtal::Z2i::DigitalSet
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition: StdDefs.h:100
DGtal::Board3D::saveOBJ
void saveOBJ(const std::string &filename, const bool isNormalized=false)
DGtal::Mesh
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition: Mesh.h:92
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
main
int main(int argc, char **argv)
Definition: testArithmeticDSS-benchmark.cpp:147
DGtal::MeshVoxelizer::voxelize
void voxelize(DigitalSet &outputSet, const Mesh< MeshPoint > &aMesh, const double scaleFactor=1.0)
domain
Domain domain
Definition: testProjection.cpp:88
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::MeshVoxelizer
Aim: A class for computing the digitization of a triangle or a Mesh.
Definition: MeshVoxelizer.h:80
DGtal::Mesh::addQuadFace
void addQuadFace(unsigned int indexVertex1, unsigned int indexVertex2, unsigned int indexVertex3, unsigned int indexVertex4, const DGtal::Color &aColor=DGtal::Color::White)