Creates precomputed tables for determining whether some point is simple within an 2D object.
#include "DGtal/topology/tables/NeighborhoodTablesGenerators.h"
#include <vector>
#include "DGtal/shapes/Shapes.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/Color.h"
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/zlib.hpp>
template <typename Object, typename Map>
void
{
typedef typename DigitalSet::Domain
Domain;
typedef typename Domain::ConstIterator DomainConstIterator;
Point p1 = Point::diagonal( -1 );
Point p2 = Point::diagonal( 1 );
Point c = Point::diagonal( 0 );
Point q1 = Point::diagonal( -1 );
Point q2 = Point::diagonal( 4*16-1 );
board <<
SetMode( fullDomain.className(),
"Paving" );
unsigned int cfg = 0;
for ( unsigned int y = 0; y < 16; ++y )
for ( unsigned int x = 0; x < 16; ++x, ++cfg )
{
bool simple = map[ cfg ];
unsigned int mask = 1;
for ( DomainConstIterator it =
domain.begin();
{
if ( *it == c )
else
{
if ( cfg & mask )
board <<
simple
Color( 255, 10, 10 ) ) );
else
board <<
simple
Color( 255, 245, 245 ) ) );
mask <<= 1;
}
board << q;
}
}
}
template <typename Map>
void
const string & tableName )
{
typedef typename Map::const_iterator MapConstIterator;
out << "const bool " << tableName << "[ " << map.size() << " ] = { ";
for ( MapConstIterator it = map.begin(), it_end = map.end();
it != it_end; )
{
out << *it;
++it;
if ( it != it_end ) out << ", ";
}
out << " };" << std::endl;
}
{
using namespace Z2i;
functions::generateSimplicityTable< Object4_8 >( dt4_8, table4_8 );
functions::generateSimplicityTable< Object8_4 >( dt8_4, table8_4 );
displaySimplicityTable< Object4_8 >( board, dt4_8, table4_8 );
displaySimplicityTable< Object8_4 >( board, dt8_4, table8_4 );
using ConfigMapBit = std::bitset<256> ;
ConfigMapBit bit_table8_4;
ConfigMapBit bit_table4_8;
functions::generateSimplicityTable< Object8_4 >( dt8_4, bit_table8_4 );
functions::generateSimplicityTable< Object4_8 >( dt4_8, bit_table4_8 );
{
string filename = "simplicity_table8_4.zlib";
ofstream file( filename );
ConfigMapBit* table = &bit_table8_4;
std::stringstream table_stream;
table_stream << *table;
namespace io = boost::iostreams;
io::filtering_streambuf<io::input> filter;
filter.push(io::zlib_compressor());
filter.push(table_stream);
io::copy(filter,file);
file.close();
}
{
string filename = "simplicity_table4_8.zlib";
ofstream file( filename );
ConfigMapBit* table = &bit_table4_8;
std::stringstream table_stream;
table_stream << *table;
namespace io = boost::iostreams;
io::filtering_streambuf<io::input> filter;
filter.push(io::zlib_compressor());
filter.push(table_stream);
io::copy(filter,file);
file.close();
}
return 0;
}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Structure representing an RGB triple with alpha component.
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 ConfigMap &map, bool complement, bool with)
void outputTableAsArray(ostream &out, const string &tableName, const ConfigMap &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