DGtal  1.5.beta
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.

Functions

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/.

Author
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
Date
2017/11/16

An example file named exampleMeshVoxelizer

This file is part of the DGtal library.

Definition in file exampleMeshVoxelizer.cpp.

Function Documentation

◆ main()

int main ( void  )

[MeshVoxelizerCreatingMesh]

[MeshVoxelizerCreatingMesh]

[MeshVoxelizerDig]

[MeshVoxelizerDig]

[MeshVoxelizerExport]

[MeshVoxelizerExport]

Definition at line 55 of file exampleMeshVoxelizer.cpp.

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 }
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()
Trace trace
Definition: Common.h:153
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::DigitalSetByAssociativeContainer< TDomain, TContainer >::size(), DGtal::trace, and DGtal::MeshVoxelizer< TDigitalSet, Separation >::voxelize().