Skip to content

Commit

Permalink
Merge pull request #1209 from hadjiszs/voxelization
Browse files Browse the repository at this point in the history
Voxelization
  • Loading branch information
dcoeurjo committed Dec 4, 2017
2 parents 295b98e + 5b1b71d commit 8c2c800
Show file tree
Hide file tree
Showing 21 changed files with 1,200 additions and 41 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## New Features / Critical Changes

- *Shapes*

- Mesh Voxelizer using 6- or 26-separability templated
(DavidCoeurjolly, Monir Hadji,
[#1209](https://github.com/DGtal-team/DGtal/pull/1209))

- *Topology Package*
- Adding the half-edge data structure to represent arbitrary
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ More details are given in the [documentation pages](http://dgtal.org/download/).

```shell
git clone https://github.com/DGtal-team/DGtal.git
cd DGtal ; mkdir buid ; cd build
cd DGtal ; mkdir build ; cd build
cmake ..
make install
```
Expand Down
3 changes: 2 additions & 1 deletion examples/shapes/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SET(DGTAL_EXAMPLES_SRC
exampleEuclideanShapesDecorator
exampleEuclideanShapesDecorator
exampleMeshVoxelizer
)

FOREACH(FILE ${DGTAL_EXAMPLES_SRC})
Expand Down
109 changes: 109 additions & 0 deletions examples/shapes/exampleMeshVoxelizer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/**
* 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/>.
*
**/

/**
* @file exampleMeshVoxelizer.cpp
* @ingroup Examples
* @author David Coeurjolly (\c david.coeurjolly@liris.cnrs.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.
*/


/**
* \image html resultCube.png "Resulting digitization of a cube"
*
* \example shapes/exampleMeshVoxelizer.cpp
*/

///////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/Common.h"
#include "DGtal/shapes/Mesh.h"
//! [MeshVoxelizerInc]
#include "DGtal/shapes/MeshVoxelizer.h"
//! [MeshVoxelizerInc]
#include "DGtal/io/boards/Board3D.h"
#include "DGtal/io/writers/MeshWriter.h"
///////////////////////////////////////////////////////////////////////////////

using namespace std;
using namespace DGtal;

///////////////////////////////////////////////////////////////////////////////

int main( )
{
trace.beginBlock ( "Example MeshVoxelizer" );


//! [MeshVoxelizerCreatingMesh]
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);
//! [MeshVoxelizerCreatingMesh]


//! [MeshVoxelizerDig]
Domain domain(Point(0,0,0), Point(128,128,128));
DigitalSet outputSet(domain);

MeshVoxelizer<DigitalSet, 6> voxelizer;

trace.info()<<"Digitization..."<<std::endl;
voxelizer.voxelize(outputSet, aMesh, 15.0);

trace.info()<<"Got "<< outputSet.size() << " voxels."<<std::endl;
//! [MeshVoxelizerDig]

//! [MeshVoxelizerExport]
Board3D<> board;
for(auto voxel : outputSet)
board << voxel;
board.saveOBJ("voxelizedCube.obj");
//! [MeshVoxelizerExport]



trace.endBlock();
return 0;
}
// //
///////////////////////////////////////////////////////////////////////////////
2 changes: 1 addition & 1 deletion examples/shapes/mesh3DConstructionAndVisualisation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int main( int argc, char** argv )
//! [MeshUseDisplay]
bool res = application.exec();
FATAL_ERROR(res);
return true;
return 0;
}
// //
///////////////////////////////////////////////////////////////////////////////
Expand Down
26 changes: 1 addition & 25 deletions src/Board/Shapes.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* -*- mode: c++ -*- */
/**
* @file Shapes.cpp
* @author Sebastien Fourey <http://www.greyc.ensicaen.fr/~seb>
Expand Down Expand Up @@ -2078,30 +2077,7 @@ Rectangle::flushTikZ( std::ostream & stream,
stream << "\\path[" << tikzProperties(transform) << "] ("
<< _path[0].x << ',' << _path[0].y << ')'
<< " rectangle ("
<< _path[1].x << ',' << _path[3].y << ");" << std::endl;
/*
if ( _path[0].y == _path[1].y ) {
stream << "<rect x=\"" << transform.mapX( _path[0].x ) << '"'
<< " y=\"" << transform.mapY( _path[0].y ) << '"'
<< " width=\"" << transform.scale( _path[1].x - _path[0].x ) << '"'
<< " height=\"" << transform.scale( _path[0].y - _path[3].y ) << '"'
<< svgProperties( transform )
<< " />" << std::endl;
} else {
Point v = _path[1] - _path[0];
v /= v.norm();
double angle = ( _path[1].y > _path[0].y ) ? acos( v * Point(1,0) ) : -acos( v * Point( 1, 0 ) );
angle = ( angle * 180 ) / M_PI;
stream << "<rect x=\"" << transform.mapX( _path[0].x ) << '"'
<< " y=\"" << transform.mapY( _path[0].y ) << '"'
<< " width=\"" << transform.scale( (_path[1] - _path[0]).norm() ) << '"'
<< " height=\"" << transform.scale( (_path[0] - _path[3]).norm() ) << '"'
<< svgProperties( transform ) << ' '
<< " transform=\"rotate(" << -angle << ", "
<< transform.mapX( _path[0].x ) << ", " << transform.mapY( _path[0].y ) << ") \" "
<< " />" << std::endl;
}
*/
<< _path[1].x << ',' << _path[3].y << "); ";
}

/*
Expand Down
39 changes: 38 additions & 1 deletion src/DGtal/doc/global.bib
Original file line number Diff line number Diff line change
@@ -1,9 +1,46 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Misc
@book{KletteRosenfeld_book,
author = {Reinhard Klette and
Azriel Rosenfeld},
title = {Digital geometry - geometric methods for digital picture analysis},
publisher = {Morgan Kaufmann},
year = {2004},
isbn = {978-1-55860-861-0},
timestamp = {Thu, 14 Apr 2011 14:43:22 +0200},
biburl = {http://dblp.uni-trier.de/rec/bib/books/daglib/0013534},
bibsource = {dblp computer science bibliography, http://dblp.org}
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Images
%% Shapes Voxelization
@article{Laine13,
added-at = {2013-08-18T00:00:00.000+0200},
author = {Laine, Samuli},
biburl = {http://www.bibsonomy.org/bibtex/270e10190a2b8fc35721e7e3e58be920c/dblp},
ee = {http://dx.doi.org/10.1111/cgf.12153},
interhash = {9327ac1bf79fa410ea45865566098671},
intrahash = {70e10190a2b8fc35721e7e3e58be920c},
journal = {Comput. Graph. Forum},
keywords = {dblp},
number = 4,
pages = {77-86},
timestamp = {2013-08-20T11:34:58.000+0200},
title = {A Topological Approach to Voxelization.},
url = {http://dblp.uni-trier.de/db/journals/cgf/cgf32.html#Laine13},
volume = 32,
year = 2013
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Images
@Misc{belongieRot,
author = {Belongie, Serge},
Expand Down
6 changes: 1 addition & 5 deletions src/DGtal/shapes/GaussDigitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,8 @@ namespace DGtal
typedef HyperRectDomain<Space> Domain;
typedef RegularPointEmbedder<Space> PointEmbedder;

// JOL: GaussDigitizer do not need a bounded shape.
// BOOST_CONCEPT_ASSERT(( CEuclideanBoundedShape<TEuclideanShape> ));

BOOST_CONCEPT_ASSERT(( concepts::CEuclideanOrientedShape<TEuclideanShape> ));



/**
* Destructor.
*/
Expand Down
Loading

0 comments on commit 8c2c800

Please sign in to comment.