33#include "DGtal/topology/tables/NeighborhoodTablesGenerators.h"
35#include "DGtal/shapes/Shapes.h"
36#include "DGtal/io/boards/Board2D.h"
37#include "DGtal/io/Color.h"
40#include <boost/iostreams/filtering_streambuf.hpp>
41#include <boost/iostreams/copy.hpp>
42#include <boost/iostreams/filter/zlib.hpp>
63template <
typename Object,
typename Map>
74 Point p1 = Point::diagonal( -1 );
75 Point p2 = Point::diagonal( 1 );
76 Point c = Point::diagonal( 0 );
79 Point q1 = Point::diagonal( -1 );
80 Point q2 = Point::diagonal( 4*16-1 );
81 Domain fullDomain( q1, q2 );
84 for (
unsigned int y = 0; y < 16; ++y )
85 for (
unsigned int x = 0; x < 16; ++x, ++cfg )
87 bool simple = map[ cfg ];
88 Point base( x*4, y*4 );
89 unsigned int mask = 1;
93 Point q = base + (*it);
97 Color( 30, 30, 30 ) ) );
105 Color( 10, 255, 10 ) )
107 Color( 255, 10, 10 ) ) );
113 Color( 245, 255, 245 ) )
115 Color( 255, 245, 245 ) ) );
126template <
typename Map>
130 const string & tableName )
132 typedef typename Map::const_iterator MapConstIterator;
133 out <<
"const bool " << tableName <<
"[ " << map.size() <<
" ] = { ";
134 for ( MapConstIterator it = map.begin(), it_end = map.end();
139 if ( it != it_end ) out <<
", ";
141 out <<
" };" << std::endl;
163 board.
saveEPS(
"table4_8.eps" );
169 board.
saveEPS(
"table8_4.eps" );
179 using ConfigMapBit = std::bitset<256> ;
180 ConfigMapBit bit_table8_4;
181 ConfigMapBit bit_table4_8;
189 string filename =
"simplicity_table8_4.zlib";
190 ofstream file( filename );
191 ConfigMapBit* table = &bit_table8_4;
192 std::stringstream table_stream;
193 table_stream << *table;
194 namespace io = boost::iostreams;
195 io::filtering_streambuf<io::input> filter;
196 filter.push(io::zlib_compressor());
197 filter.push(table_stream);
198 io::copy(filter,file);
207 string filename =
"simplicity_table4_8.zlib";
208 ofstream file( filename );
209 ConfigMapBit* table = &bit_table4_8;
210 std::stringstream table_stream;
211 table_stream << *table;
212 namespace io = boost::iostreams;
213 io::filtering_streambuf<io::input> filter;
214 filter.push(io::zlib_compressor());
215 filter.push(table_stream);
216 io::copy(filter,file);
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Structure representing an RGB triple with alpha component.
TDomain Domain
Domain type.
Iterator for HyperRectDomain.
const ConstIterator & begin() const
std::string className() const
const ConstIterator & end() const
TDigitalTopology DigitalTopology
void beginBlock(const std::string &keyword="")
void clear(const DGtal::Color &color=DGtal::Color::None)
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
std::vector< bool > ConfigMap
void displaySimplicityTable(Board2D &board, const typename Object::DigitalTopology &, const Map &map)
void outputTableAsArray(ostream &out, const Map &map, const string &tableName)
void generateSimplicityTable(const typename TObject::DigitalTopology &dt, TMap &map)
DGtal is the top-level namespace which contains all DGtal functions and types.
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
std::unordered_map< Cell, CubicalCellData > Map
HyperRectDomain< Space > Domain
Z2i::DigitalSet DigitalSet