Exemplo n.º 1
0
int main()
{
  trace.beginBlock ( "Example dgtalBoard2D-1-points" );

  Point p1( -3, -2 );
  Point p2( 7, 3 );
  Point p3( 0, 0 );
  Domain domain( p1, p2 );
  
  Board2D board;
  board << domain << p1 << p2 << p3;

  board.saveSVG("dgtalBoard2D-1-points.svg");
  board.saveEPS("dgtalBoard2D-1-points.eps");
  board.saveTikZ("dgtalBoard2D-1-points.tikz");

#ifdef WITH_CAIRO
  board.saveCairo("dgtalBoard2D-1-points-cairo.pdf", Board2D::CairoPDF);
  board.saveCairo("dgtalBoard2D-1-points-cairo.png", Board2D::CairoPNG);
  board.saveCairo("dgtalBoard2D-1-points-cairo.ps", Board2D::CairoPS);
  board.saveCairo("dgtalBoard2D-1-points-cairo.svg", Board2D::CairoSVG);
#endif
  
  trace.endBlock();
  return 0;
}
Exemplo n.º 2
0
bool testDomain()
{
    typedef SpaceND<2> TSpace;
    typedef TSpace::Point Point;
    Point a ( 1, 1);
    Point b ( 15, 15);

    trace.beginBlock ( "HyperRectDomain Iterator" );
    HyperRectDomain<TSpace> myDomain ( a,b );
    
    Board2D board;
    
    board << SetMode( myDomain.className(), "Grid" ) << myDomain;
    board.scale(10);
    board.saveSVG( "domain-grid.svg" );
    board.saveTikZ( "domain-grid.tikz" );
    
    Board2D b2;
    b2 << SetMode( myDomain.className(), "Paving" ) << myDomain;
    b2.scale(10);
    b2.saveSVG( "domain-paving.svg" );
    b2.saveTikZ( "domain-paving.tikz" );


    trace.endBlock();

    PointVector<3,int> pl;
    //An assert should be raised 
    //Display2DFactory::draw(b2, pl);

    return true;
}
Exemplo n.º 3
0
/**
 * Example of a test. To be completed.
 *
 */
bool testSimpleBoard()
{
  unsigned int nbok = 0;
  unsigned int nb = 2;

  trace.beginBlock ( "Testing class SimpleBoard" );
  
  Board2D board;

  board.setPenColorRGBi( 0, 0, 0);
  board.drawRectangle( -1, 1, 2.0, 2.0 );
  board.setPenColorRGBi( 0, 0, 255 );
  board.fillCircle( 2, 2, 1 );
  
  

  board.saveSVG( "simpleboard.svg" );
  board.saveFIG( "simpleboard.fig" );
  board.saveEPS( "simpleboard.eps" );
  board.saveTikZ( "simpleboard.tikz" );
  nbok++;

  typedef  PointVector<2,int> Point2D;
  Point2D apoint, p2;
  apoint[0] = 5;
  p2[0] = 1;
  apoint[1] = 8;
  p2[1] = 1;

  board.setPenColorRGBi( 255, 0, 255 );
  board << apoint;

  board.setPenColorRGBi( 255, 0, 0 );
  Display2DFactory::draw(board, apoint, p2);

  board.scale(10);

  board.saveSVG( "pointsimpleboard.svg" );
  board.saveFIG( "pointsimpleboard.fig" );
  board.saveEPS( "pointsimpleboard.eps" );
  board.saveTikZ( "pointsimpleboard.tikz" );
  nbok++;
  trace.endBlock();
  return nbok == nb;
}
Exemplo n.º 4
0
int main( int argc, char** argv )
{
  trace.beginBlock ( "Example exampleBezierCurve" );
  trace.info() << "Args:";
  for ( int i = 0; i < argc; ++i )
    trace.info() << " " << argv[ i ];
  trace.info() << endl;

  //control points
  typedef PointVector<2,int> Point;
  Point P(0,0), Q(4,4), R(8,0); 

  //display
  Board2D board; 

  //with fill
  board << SetMode(P.className(), "Grid") << P << Q << R; 
  board.drawQuadraticBezierCurve(P[0], P[1], Q[0], Q[1], R[0], R[1]); 

  board.saveSVG("BezierCurve.svg", Board2D::BoundingBox, 5000 ); 
  board.saveEPS("BezierCurve.eps", Board2D::BoundingBox, 5000 ); 
  board.saveTikZ("BezierCurve.tikz", Board2D::BoundingBox, 5000 ); 
  board.saveFIG("BezierCurve.fig", Board2D::BoundingBox, 5000 ); 
#ifdef WITH_CAIRO
  board.saveCairo("BezierCurve.pdf", Board2D::CairoPDF); 
#endif

  board.clear(); 
  //without fill
  board << SetMode(P.className(), "Grid") << P << Q << R; 
  board.setFillColor(Color::None); 
  board.drawQuadraticBezierCurve(P[0], P[1], Q[0], Q[1], R[0], R[1]); 

  board.saveSVG("BezierCurve2.svg", Board2D::BoundingBox, 5000 ); 
  board.saveEPS("BezierCurve2.eps", Board2D::BoundingBox, 5000 ); 
  board.saveTikZ("BezierCurve2.tikz", Board2D::BoundingBox, 5000 ); 
  board.saveFIG("BezierCurve2.fig", Board2D::BoundingBox, 5000 ); 
#ifdef WITH_CAIRO
  board.saveCairo("BezierCurve2.pdf", Board2D::CairoPDF); 
#endif

  trace.endBlock();
  return 0;
}
Exemplo n.º 5
0
int main()
{
  trace.beginBlock ( "Example dgtalBoard2D-4-colormaps" );

  Point p1( -10, -7 );
  Point p2( 10, 7 );
  Domain domain( p1, p2 );
  Point c1( -5, -1 );
  Point c2( 5, 1 );
  DigitalSet shape_set( domain );
  Shapes<Domain>::addNorm1Ball( shape_set, c1, 5 );
  Shapes<Domain>::addNorm1Ball( shape_set, c2, 5 );
  shape_set.erase( c1 );
  shape_set.erase( c2 );

  // Creating colormap.
  GradientColorMap<int> cmap_grad( 0, 15 );
  cmap_grad.addColor( Color( 50, 50, 255 ) );
  cmap_grad.addColor( Color( 255, 0, 0 ) );
  cmap_grad.addColor( Color( 255, 255, 10 ) );

  // Creating board.
  Board2D board;
  board << SetMode( domain.className(), "Paving" )
  << domain
  << SetMode( p1.className(), "Paving" );
  // This is the name of the style for a Point in mode "Paving".
  string specificStyle =  p1.className() + "/Paving";
  for ( DigitalSet::ConstIterator it = shape_set.begin();
  it != shape_set.end();
  ++it )
    {
      unsigned int d = (unsigned int) ceil( ( *it - c1 ).norm() );
      // specific color depending on the distance to point c1.
      board << CustomStyle( specificStyle,
          new CustomColors( Color::Black,
                cmap_grad( d ) ) )
      << *it;
    }
  board.saveSVG( "dgtalBoard2D-4-colormaps.svg");
  board.saveEPS( "dgtalBoard2D-4-colormaps.eps");
  board.saveTikZ( "dgtalBoard2D-4-colormaps.tikz");

#ifdef WITH_CAIRO
  board.saveCairo("dgtalBoard2D-4-colormaps-cairo.pdf", Board2D::CairoPDF);
  board.saveCairo("dgtalBoard2D-4-colormaps-cairo.png", Board2D::CairoPNG);
  board.saveCairo("dgtalBoard2D-4-colormaps-cairo.ps", Board2D::CairoPS);
  board.saveCairo("dgtalBoard2D-4-colormaps-cairo.svg", Board2D::CairoSVG);
#endif

  trace.endBlock();
  return 0;
}
Exemplo n.º 6
0
int main()
{
  trace.beginBlock ( "Board example" );

  Point p1( -3, -2 );
  Point p2( 7, 3 );
  Point p3( 0, 0 );
  Domain domain( p1, p2 );
  

  Board2D board;
  
  //We display the underlying domain
  board << domain ;

  //We display points
  board << p1 << p2 << p3;


  //Output
  board.saveSVG("test.svg");
  board.saveEPS("test.eps");
  board.saveTikZ("test.tikz");
  
  //Clear
  board.clear();
  
  //Upade position + color
  p2[0] = 5; //x-coordinate
  board << domain << p1 << p3;
  
  Color red( 255, 0, 0 );
  
  //All points will be in red
  board  << CustomStyle( p2.className(), new CustomColors( red, red ) )
	 << p2;
  
  //Export again
  board.saveEPS("test2.eps");


  trace.endBlock();
  return 0;
}
Exemplo n.º 7
0
int main(int /*argc*/, char** /*argv*/)
{
  


////////////////////////////////////////
  Board2D board;
  board.setUnit(Board2D::UCentimeter);
  board.drawArc(0.0, 1.0, 5.0, 0, M_PI/2.0, false); 
  board.drawArc(0.0, 1.0, 4.0, 0, M_PI/2.0, true); 
  board.drawArc(0.0, 1.0, 3.0, -0.5, M_PI/2.0-0.5, false); 
  board.drawArc(0.0, 1.0, 2.0, 0.5, M_PI/2.0+0.5, false); 
  board.saveEPS( "essai.eps" );
  board.saveSVG( "essai.svg" );  
  board.saveTikZ( "essai.tikz" );
#ifdef WITH_CAIRO
    board.saveCairo("essai.pdf", Board2D::CairoPDF);
#endif
////////////////////////////////////////

  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;
}