Skip to content

Commit

Permalink
Merge pull request #281 from dcoeurjo/FullBoundary
Browse files Browse the repository at this point in the history
Export closure to OBJ in volBoundary2obj
  • Loading branch information
kerautret committed Nov 5, 2016
2 parents ebd566e + 4787652 commit 5753271
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
3 changes: 2 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
- *converters*:
- fix tool itk2vol which was not able to read and convert int type image.
(Bertrand Kerautret, [#276](https://github.com/DGtal-team/DGtalTools/pull/271))

- add a CLOSURE export mode in volBoundary2obj. Default mode has been changed to "BDRY"
(David Coeurjolly, [#281](https://github.com/DGtal-team/DGtalTools/pull/281))

# DGtalTools 0.9.2

Expand Down
40 changes: 31 additions & 9 deletions converters/volBoundary2obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

///////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <set>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
Expand Down Expand Up @@ -81,8 +82,9 @@ namespace po = boost::program_options;
scale
--dicomMax arg (=3000) set maximum density threshold on Hounsfield
scale
--mode arg (=INNER) set mode for display: INNER: inner voxels,
OUTER: outer voxels, BDRY: surfels
--mode arg (=BDRY) set mode for display: INNER: inner voxels,
OUTER: outer voxels, BDRY: surfels, CLOSURE:
surfels with linels and pointels.
-n [ --normalization ] Normalization so that the geometry fits in
[-1/2,1/2]^3
@endcode
Expand All @@ -107,7 +109,6 @@ int main( int argc, char** argv )
typedef KhalimskySpaceND<3,int> KSpace;
typedef HyperRectDomain<Space> Domain;
typedef ImageSelector<Domain, unsigned char>::Type Image;
typedef DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet;
typedef SurfelAdjacency<KSpace::dimension> MySurfelAdjacency;

// parse command line ----------------------------------------------
Expand All @@ -122,7 +123,7 @@ int main( int argc, char** argv )
("dicomMin", po::value<int>()->default_value(-1000), "set minimum density threshold on Hounsfield scale")
("dicomMax", po::value<int>()->default_value(3000), "set maximum density threshold on Hounsfield scale")
#endif
("mode", po::value<std::string>()->default_value("INNER"), "set mode for display: INNER: inner voxels, OUTER: outer voxels, BDRY: surfels")
("mode", po::value<std::string>()->default_value("BDRY"), "set mode for display: INNER: inner voxels, OUTER: outer voxels, BDRY: surfels (default), CLOSURE: surfels with linels and pointels.")
("normalization,n", "Normalization so that the geometry fits in [-1/2,1/2]^3") ;

bool parseOK=true;
Expand Down Expand Up @@ -224,22 +225,43 @@ int main( int argc, char** argv )
<< std::endl;
trace.endBlock();

trace.beginBlock( "Displaying everything. " );
trace.beginBlock( "Exporting everything." );
Board3D<Space,KSpace> board(ks);

board << SetMode3D( ks.unsigns( *digSurf.begin() ).className(), "Basic" );

typedef MyDigitalSurface::ConstIterator ConstIterator;
if ( mode == "BDRY" )
for ( ConstIterator it = digSurf.begin(), itE = digSurf.end(); it != itE; ++it )
board << ks.unsigns( *it );
board << ks.unsigns( *it );
else if ( mode == "INNER" )
for ( ConstIterator it = digSurf.begin(), itE = digSurf.end(); it != itE; ++it )
board << ks.sCoords( ks.sDirectIncident( *it, ks.sOrthDir( *it ) ) );
board << ks.sCoords( ks.sDirectIncident( *it, ks.sOrthDir( *it ) ) );
else if ( mode == "OUTER" )
for ( ConstIterator it = digSurf.begin(), itE = digSurf.end(); it != itE; ++it )
board << ks.sCoords( ks.sIndirectIncident( *it, ks.sOrthDir( *it ) ) );

board << ks.sCoords( ks.sIndirectIncident( *it, ks.sOrthDir( *it ) ) );
else if (mode == "CLOSURE")
{
std::set<KSpace::Cell> container;
for ( ConstIterator it = digSurf.begin(), itE = digSurf.end(); it != itE; ++it )
{
container.insert( ks.unsigns( *it ) );
KSpace::SCells oneNeig = ks.sLowerIncident(*it);
//Processing linels
for(KSpace::SCells::ConstIterator itt = oneNeig.begin(), ittend = oneNeig.end(); itt != ittend; ++itt)
{
container.insert( ks.unsigns( *itt) );
KSpace::SCells oneNeig2 = ks.sLowerIncident(*itt);
//Processing pointels
for(KSpace::SCells::ConstIterator ittt = oneNeig2.begin(), itttend = oneNeig2.end(); ittt != itttend; ++ittt)
container.insert( ks.unsigns(*ittt) );
}
}
trace.info()<< "Exporting "<< container.size() << " cells"<<std::endl;
for(auto cell: container)
board << cell;
}

string outputFilename = vm["output"].as<std::string>();

board.saveOBJ(outputFilename, normalization);
Expand Down

0 comments on commit 5753271

Please sign in to comment.