DGtal  1.2.0
exampleMeshVoxelizer.cpp File Reference
#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"
Include dependency graph for exampleMeshVoxelizer.cpp:

Go to the source code of this file.


int main ()

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France

An example file named exampleMeshVoxelizer

This file is part of the DGtal library.

Definition in file exampleMeshVoxelizer.cpp.

Function Documentation

◆ main()

int main ( void  )







Definition at line 55 of file exampleMeshVoxelizer.cpp.

56 {
57  trace.beginBlock ( "Example MeshVoxelizer" );
61  using namespace Z3i;
62  Mesh<Point> aMesh;
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));
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);
85  Domain domain(Point(0,0,0), Point(128,128,128));
86  DigitalSet outputSet(domain);
90  trace.info()<<"Digitization..."<<std::endl;
91  voxelizer.voxelize(outputSet, aMesh, 15.0);
93  trace.info()<<"Got "<< outputSet.size() << " voxels."<<std::endl;
97  Board3D<> board;
98  for(auto voxel : outputSet)
99  board << voxel;
100  board.saveOBJ("voxelizedCube.obj");
105  trace.endBlock();
106  return 0;
107 }
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 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(unsigned int indexVertex1, unsigned int indexVertex2, unsigned int indexVertex3, unsigned int indexVertex4, const DGtal::Color &aColor=DGtal::Color::White)
void addVertex(const TPoint &vertex)
void beginBlock(const std::string &keyword="")
std::ostream & info()
double endBlock()
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition: StdDefs.h:100
Trace trace
Definition: Common.h:154
MyPointD Point
Definition: testClone2.cpp:383
Domain domain

References DGtal::Mesh< TPoint >::addQuadFace(), DGtal::Mesh< TPoint >::addVertex(), DGtal::Trace::beginBlock(), domain, DGtal::Trace::endBlock(), DGtal::Trace::info(), DGtal::Board3D< Space, KSpace >::saveOBJ(), DGtal::trace, and DGtal::MeshVoxelizer< TDigitalSet, Separation >::voxelize().