DGtal  1.5.beta
generateSimplicityTables3D.cpp
Go to the documentation of this file.
1 
33 #include <DGtal/topology/tables/NeighborhoodTablesGenerators.h>
34 
35 // For saving compressed tables.
36 #include <boost/iostreams/filtering_streambuf.hpp>
37 #include <boost/iostreams/copy.hpp>
38 #include <boost/iostreams/filter/zlib.hpp>
39 
41 
42 using namespace std;
43 using namespace DGtal;
44 
45 int main( int argc, char** argv )
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 }
98 // //
void beginBlock(const std::string &keyword="")
double endBlock()
std::vector< bool > ConfigMap
int main(int argc, char **argv)
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:153