DGtal  1.5.beta
generateSimplicityTables3D.cpp File Reference
#include <DGtal/topology/tables/NeighborhoodTablesGenerators.h>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/zlib.hpp>
Include dependency graph for generateSimplicityTables3D.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

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
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
Date
2012/06/22

An example file named generateSimplicityTables3D. Creates precomputed tables for determining whether some point is simple within an object.

This file is part of the DGtal library.

Definition in file generateSimplicityTables3D.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 45 of file generateSimplicityTables3D.cpp.

46 {
47  using namespace Z3i;
48  string error_message(
49  "Select ForegroundAdjacency for object topology:\n"
50  "- 26_6 \n"
51  "- 18_6 \n"
52  "- 6_18 \n"
53  "- 6_26 \n");
54  if (argc != 2 ){
55  cout << error_message << std::endl;
56  return 1;
57  }
58  std::string input_str = std::string(argv[1]);
59 
60  using ConfigMap = std::bitset<67108864> ; // 2^26
61  // Too big for stack. Use heap instead.
62  unique_ptr<ConfigMap> table(new ConfigMap);
63  trace.beginBlock ( "Generate 3d table for " + input_str + " topology" );
64 
65  if (input_str == "26_6")
66  functions::generateSimplicityTable< Object26_6, ConfigMap >( dt26_6, *table );
67  else if (input_str == "18_6")
68  functions::generateSimplicityTable< Object18_6, ConfigMap >( dt18_6, *table );
69  else if (input_str == "6_18")
70  functions::generateSimplicityTable< Object6_18, ConfigMap >( dt6_18, *table );
71  else if (input_str == "6_26")
72  functions::generateSimplicityTable< Object6_26, ConfigMap >( dt6_26, *table );
73  else {
74  cout << error_message << endl;
75  return 1;
76  }
77  trace.endBlock();
78 
79  // string filename = "simplicity_table" + input_str + ".txt";
80  // ofstream file( filename );
81  // file << *table;
82  // file.close();
83  {
84  string filename = "simplicity_table" + input_str + ".zlib";
85  ofstream file( filename );
86  std::stringstream table_stream;
87  table_stream << *table;
88  namespace io = boost::iostreams;
89  io::filtering_streambuf<io::input> filter;
90  filter.push(io::zlib_compressor());
91  filter.push(table_stream);
92  io::copy(filter,file);
93  file.close();
94  }
95 
96  return 0;
97 }
void beginBlock(const std::string &keyword="")
double endBlock()
std::vector< bool > ConfigMap
Trace trace
Definition: Common.h:153

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), and DGtal::trace.