int main() { KSpace K; Point plow(-3,-2); Point pup(5,3); Domain domain( plow, pup ); Board2D board; // for 2D display K.init( plow, pup, true ); board << SetMode( domain.styleName(), "Paving" ) << domain; Cell pixlow = K.uSpel( plow ); // pixel (-3*2+1,-2*2+1) Cell ptlow = K.uPointel( plow ); // pointel (-3*2,-2*2) Cell pixup = K.uSpel( pup ); // pixel (5*2+1,3*2+1) Cell ptup1 = K.uPointel( pup ); // pointel (5*2,3*2) Cell ptup2 = K.uTranslation( ptup1, Point::diagonal() ); // pointel (6*2,4*2) Cell linelb = K.uCell( Point( 1, 0 ) ); // linel (1,0) bottom Cell linelt = K.uCell( Point( 1, 2 ) ); // linel (1,2) top Cell linell = K.uCell( Point( 0, 1 ) ); // linel (0,1) left Cell linelr = K.uCell( Point( 2, 1 ) ); // linel (2,1) right board << CustomStyle( ptlow.styleName(), new CustomColors( Color( 0, 0, 200 ), Color( 100, 100, 255 ) ) ) << ptlow << ptup2; board << CustomStyle( pixlow.styleName(), new CustomColors( Color( 200, 0, 0 ), Color( 255, 100, 100 ) ) ) << pixlow << pixup; board << CustomStyle( linelb.styleName(), new CustomColors( Color( 0, 200, 0 ), Color( 100, 255, 100 ) ) ) << linelb << linelt << linell << linelr; board.saveSVG("ctopo-1.svg"); board.saveEPS("ctopo-1.eps"); return 0; }
int main( int /* argc */, char** /* argv */ ) { //! [cubical-complex-illustrations-X] using namespace DGtal::Z2i; typedef CubicalComplex< KSpace > CC; KSpace K; K.init( Point( 0,0 ), Point( 5,3 ), true ); trace.beginBlock( "Creating Cubical Complex" ); CC X( K ); Domain domain( Point( 0,0 ), Point( 5,3 ) ); X.insertCell( K.uSpel( Point(1,1) ) ); X.insertCell( K.uSpel( Point(2,1) ) ); X.insertCell( K.uSpel( Point(3,1) ) ); X.insertCell( K.uSpel( Point(2,2) ) ); X.insertCell( K.uSpel( Point(3,2) ) ); X.insertCell( K.uSpel( Point(4,2) ) ); X.close(); trace.endBlock(); trace.beginBlock( "Displays Cubical Complex" ); Board2D board; board << domain; board << CustomStyle( X.className(), new CustomColors( Color(80,80,100), Color(180,180,200) ) ) << X; board.saveTikZ( "cubical-complex-illustrations-X.tikz" ); trace.endBlock(); //! [cubical-complex-illustrations-X] //! [cubical-complex-illustrations-S] CC S( K ); S.insertCell( K.uCell( Point( 5, 4 ) ) ); // a linel S.insertCell( K.uCell( Point( 4, 4 ) ) ); // a pointel S.insertCell( K.uCell( Point( 7, 5 ) ) ); // a pixel board << CustomStyle( X.className(), new CustomColors( Color::Black, Color(60,60,60) ) ) << S; board.saveTikZ( "cubical-complex-illustrations-S.tikz" ); board.clear(); //! [cubical-complex-illustrations-S] //! [cubical-complex-illustrations-closure] board << domain; board << CustomStyle( X.className(), new CustomColors( Color(80,80,100), Color(180,180,200) ) ) << X; board << CustomStyle( X.className(), new CustomColors( Color::Red, Color(255,120,120) ) ) << X.closure( S ); board.saveTikZ( "cubical-complex-illustrations-closure.tikz" ); board.clear(); //! [cubical-complex-illustrations-closure] //! [cubical-complex-illustrations-star] board << domain; board << CustomStyle( X.className(), new CustomColors( Color(80,80,100), Color(180,180,200) ) ) << X; board << CustomStyle( X.className(), new CustomColors( Color::Blue, Color(120,120,255) ) ) << X.star( S ); board.saveTikZ( "cubical-complex-illustrations-star.tikz" ); board.clear(); //! [cubical-complex-illustrations-star] //! [cubical-complex-illustrations-link] board << domain; board << CustomStyle( X.className(), new CustomColors( Color(80,80,100), Color(180,180,200) ) ) << X; board << CustomStyle( X.className(), new CustomColors( Color::Green, Color(120,255,120) ) ) << X.link( S ); board.saveTikZ( "cubical-complex-illustrations-link.tikz" ); board.clear(); //! [cubical-complex-illustrations-link] //! [cubical-complex-illustrations-bd] board << domain; board << CustomStyle( X.className(), new CustomColors( Color(80,80,100), Color(180,180,200) ) ) << X; board << CustomStyle( X.className(), new CustomColors( Color::Magenta, Color(255,120,255) ) ) << X.boundary(); board.saveTikZ( "cubical-complex-illustrations-bd.tikz" ); board.clear(); //! [cubical-complex-illustrations-bd] //! [cubical-complex-illustrations-int] board << domain; board << CustomStyle( X.className(), new CustomColors( Color(80,80,100), Color(180,180,200) ) ) << X; board << CustomStyle( X.className(), new CustomColors( Color::Cyan, Color(120,255,255) ) ) << X.interior(); board.saveTikZ( "cubical-complex-illustrations-int.tikz" ); board.clear(); //! [cubical-complex-illustrations-int] //! [cubical-complex-illustrations-collapse] board << domain; board << CustomStyle( X.className(), new CustomColors( Color(80,80,100), Color(180,180,200) ) ) << X; Cell p1 = K.uCell( Point(2,2) ); Cell p2 = K.uCell( Point(10,6) ); X[ p1 ] = CC::FIXED; X[ p2 ] = CC::FIXED; CC::DefaultCellMapIteratorPriority P; functions::collapse( X, X.begin(), X.end(), P, true, true, true ); board << CustomStyle( X.className(), new CustomColors( Color(255,120,20), Color(255,150,50) ) ) << X << CustomStyle( p1.className(), new CustomColors( Color::Blue, Color(120,120,255) ) ) << p1 << p2; board.saveTikZ( "cubical-complex-illustrations-collapse.tikz" ); board.clear(); //! [cubical-complex-illustrations-collapse] return 0; }