当前位置: 首页>>代码示例>>C++>>正文


C++ Board2D::saveCairo方法代码示例

本文整理汇总了C++中Board2D::saveCairo方法的典型用法代码示例。如果您正苦于以下问题:C++ Board2D::saveCairo方法的具体用法?C++ Board2D::saveCairo怎么用?C++ Board2D::saveCairo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Board2D的用法示例。


在下文中一共展示了Board2D::saveCairo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

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;
}
开发者ID:151706061,项目名称:DGtal,代码行数:26,代码来源:dgtalBoard2D-1-points.cpp

示例2: main

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;
}
开发者ID:SqLL,项目名称:DGtal,代码行数:53,代码来源:dgtalBoard2D-4-colormaps.cpp

示例3: exampleNaiveDSS

/**
 * @brief Function that illustrates the basic usage of
 * a naive DSS. 
 */
void exampleNaiveDSS()
{
  trace.beginBlock ( "Naive DSS" );

  using namespace Z2i; 

  //! [ArithmeticalDSSNaiveCtor]
  // Construct a naive DSS
  NaiveDSS8<Integer> segment( 5, 8,                   //slope
			      Point(0,0), Point(8,5), //ending points 
			      Point(0,0), Point(8,5), //upper points
			      Point(3,1), Point(3,1)  //lower points
			      );
  //! [ArithmeticalDSSNaiveCtor]

  // Trace to the standard output
  trace.info() << segment << std::endl; 

  //! [ArithmeticalDSSIteration]
  // Trace the position and remainder of each point
  for (NaiveDSS8<Integer>::ConstIterator 
	 it = segment.begin(), 
	 ite = segment.end(); 
       it != ite; ++it )
    {
      trace.info() << "(" 
		   << segment.position( *it ) << ","
		   << segment.remainder( *it ) 
		   << ") "; 
    }
  //! [ArithmeticalDSSIteration]
  trace.info() << std::endl; 

  //! [NaiveDSS8DrawingUsage]
  Board2D board;
  
  // Draw the grid
  Domain domain( Point(0,0), Point(8,5) );
  board << SetMode(domain.className(), "Grid")
	<< domain;    
  
  //Draw the points of the DSS
  board << SetMode("PointVector", "Both");
  board << SetMode(segment.className(), "Points") 
	<< segment;

  // Draw the bounding box
  board << SetMode(segment.className(), "BoundingBox") 
  	<< segment;
  //! [NaiveDSS8DrawingUsage]


  // Save
  board.saveSVG("NaiveDSS8.svg");
#ifdef WITH_CAIRO
  board.saveCairo("NaiveDSS8.png", Board2D::CairoPNG);
#endif

  trace.endBlock();
}
开发者ID:arnaudetitia,项目名称:DGtal,代码行数:64,代码来源:exampleArithmeticalDSS.cpp

示例4: draw

void draw( const TImage aImg, const double& aMaxValue, std::string aBasename) 
{
  typedef typename TImage::Domain::ConstIterator ConstIteratorOnPoints; 
  typedef typename TImage::Domain::Point Point; 
  HueShadeColorMap<double, 2> colorMap(0,aMaxValue);

  Board2D b; 
  b.setUnit ( LibBoard::Board::UCentimeter );
 
  for (ConstIteratorOnPoints it = aImg.domain().begin(), itEnd = aImg.domain().end();
       it != itEnd; ++it)
    {
      Point p = *it; 
      b << CustomStyle( p.className(), new CustomFillColor( colorMap( aImg(p) ) ) );
      b << p;
    }

  {
    std::stringstream s; 
    s << aBasename << ".eps"; 
    b.saveEPS(s.str().c_str());
  }
  #ifdef WITH_CAIRO
  {
    std::stringstream s; 
    s << aBasename << ".png"; 
    b.saveCairo(s.str().c_str(), Board2D::CairoPNG);
  }
  #endif
} 
开发者ID:Victor-Ostromoukhov,项目名称:DGtal,代码行数:30,代码来源:exampleFMM2D.cpp

示例5: testDrawGridCurve

/**
 * Display
 *
 */
bool testDrawGridCurve(const string &filename)
{

  GridCurve<KhalimskySpaceND<2> > c; //grid curve

  trace.info() << endl;
  trace.info() << "Displaying GridCurve " << endl;
  
  //reading grid curve
  fstream inputStream;
  inputStream.open (filename.c_str(), ios::in);
  c.initFromVectorStream(inputStream); 
  inputStream.close();

  //displaying it
  Board2D aBoard;
  aBoard.setUnit(Board2D::UCentimeter);
  aBoard << c; 
  aBoard.saveEPS( "GridCurve.eps", Board2D::BoundingBox, 5000 );
#ifdef WITH_CAIRO
  aBoard.saveCairo("GridCurve-cairo.pdf", Board2D::CairoPDF, Board2D::BoundingBox, 5000);
#endif

  return true;
}
开发者ID:kerautret,项目名称:DGtal-forIPOL,代码行数:29,代码来源:testGridCurve.cpp

示例6: main

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;
}
开发者ID:BorisMansencal,项目名称:DGtal,代码行数:44,代码来源:exampleBezierCurve.cpp

示例7: save

  /** 
   * Export a given Set into an image file.
   * 
   * @param aSet input set.
   * @param outputName output file name.
   * @param outputFormat output file format.
   *
   */
  static
  void save(const Set &aSet, 
	    const std::string outputName, 
	    const std::string outputFormat)
  {
    
    Image  image = ImageFromSet<Image>::template create<Set>(aSet, 255, true);
    
    if  (outputFormat == "pgm")
      PNMWriter<Image,Gray>::exportPGM(outputName+"."+outputFormat,image,0,255);
    else
      if (outputFormat == "raw")
	RawWriter<Image,Gray>::exportRaw8(outputName+"."+outputFormat,image,0,255);
      else
	if (outputFormat == "svg")
	  {
	    Board2D board;
	    board << aSet;
	    board.saveSVG((outputName+"."+outputFormat).c_str());
	  }
	else
#ifdef WITH_CAIRO
	  if (outputFormat == "pdf")
	    {
	      Board2D board;
	      board << aSet;
	      board.saveCairo((outputName+"."+outputFormat).c_str(), Board2D::CairoPDF);
	      
	    }
	  else
	    if (outputFormat == "png")
	      {
		Board2D board;
		board << aSet;
		board.saveCairo((outputName+"."+outputFormat).c_str(), Board2D::CairoPNG);
	      }
	    else
#endif
	      {
		trace.error()<< "Output format: "<<outputFormat<< " not recognized."<<std::endl;
		exit(1);
	      }
  }
开发者ID:malaterre,项目名称:DGtal,代码行数:51,代码来源:shapeGenerator.cpp

示例8: main

int main()
{
  trace.beginBlock ( "Example dgtalboard-3-custom-classes" );

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

  Color red( 255, 0, 0 );
  Color dred( 192, 0, 0 );
  Color dgreen( 0, 192, 0 );
  Color blue( 0, 0, 255 );
  Color dblue( 0, 0, 192 );
  
  Board2D board;
  board << domain 
  << CustomStyle( p1.styleName(), new CustomColors( red, dred ) )
  << p1
  << CustomStyle( p2.styleName(), new CustomFillColor( dgreen ) )
  << p2
  << CustomStyle( p3.styleName(), 
      new CustomPen( blue, dblue, 6.0, 
               Board2D::Shape::SolidStyle,
               Board2D::Shape::RoundCap,
               Board2D::Shape::RoundJoin ) )
  << p3;
  board.saveSVG("dgtalboard-3-custom-classes.svg");
  board.saveEPS("dgtalboard-3-custom-classes.eps");

#ifdef WITH_CAIRO
  board.saveCairo("dgtalboard-3-custom-classes-cairo.pdf", Board2D::CairoPDF);
  board.saveCairo("dgtalboard-3-custom-classes-cairo.png", Board2D::CairoPNG);
  board.saveCairo("dgtalboard-3-custom-classes-cairo.ps", Board2D::CairoPS);
  board.saveCairo("dgtalboard-3-custom-classes-cairo.svg", Board2D::CairoSVG);
#endif
  
  trace.endBlock();
  return 0;
}
开发者ID:gdamiand,项目名称:DGtal,代码行数:40,代码来源:dgtalBoard2D-3-custom-classes.cpp

示例9: testDisplay

/**
 * testDisplay
 *
 */
bool testDisplay()
{
  typedef FreemanChain<int> FreemanChain;
  //typedef FreemanChain::Point Point;
  //typedef FreemanChain::Vector Vector;
  //typedef FreemanChain::ConstIterator Iterator;
  //typedef std::vector<unsigned int> numVector;

  Board2D aBoard;
  aBoard.setUnit(Board::UCentimeter);
  
  fstream fst;
  fst.open ((testPath + "samples/contourS.fc").c_str() , ios::in);
  FreemanChain fc(fst);  

  aBoard.setPenColor(Color::Red);
  
  //aBoard << DrawPavingPixel();
  
  aBoard << fc;
  
  std::string filenameImage = testPath + "samples/contourS.png"; // ! only PNG with Cairo for the moment !
  LibBoard::Image image( 0, 84, 185, 85, filenameImage, 20 ); 
  image.shiftDepth(500);
  LibBoard::Board & board = aBoard;
  board << image;
  
  aBoard.saveSVG( "testDisplayFC.svg", Board::BoundingBox, 5000 );
  aBoard.saveEPS( "testDisplayFC.eps", Board::BoundingBox, 5000 );
  aBoard.saveFIG( "testDisplayFC.fig", Board::BoundingBox, 5000 );
  
#ifdef WITH_CAIRO
  aBoard.saveCairo("testDisplayFC-cairo.pdf", Board2D::CairoPDF, Board::BoundingBox, 5000);
  aBoard.saveCairo("testDisplayFC-cairo.png", Board2D::CairoPNG, Board::BoundingBox, 5000);
  aBoard.saveCairo("testDisplayFC-cairo.ps",  Board2D::CairoPS,  Board::BoundingBox, 5000);
  aBoard.saveCairo("testDisplayFC-cairo.svg", Board2D::CairoSVG, Board::BoundingBox, 5000);
#endif
  
  return true;
}
开发者ID:arnaudetitia,项目名称:DGtal,代码行数:44,代码来源:testFreemanChain.cpp

示例10: main

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;
}
开发者ID:BorisMansencal,项目名称:DGtal,代码行数:22,代码来源:testArcDrawing.cpp

示例11: main

/**
 * @brief Program that draws the maximal segments
 * of digital curve whose chain code may be given
 * as an argument. The chain code must be a sequence
 *  of characters belonging to the set {0,1,2,3}.
 * @param argc number of arguments
 * @param argv array of arguments
 * @return 0
 */
int main( int argc, char** argv )
{

  trace.beginBlock ( "Example convex-and-concave-parts" );

  Board2D aBoard; //create a board

  //create a chain code
  string codes;
  if (argc >= 2) codes = argv[1];
  else codes = "030030330303303030300001010101101011010000030330303303030300001010110101011010000033";

  stringstream ss(stringstream::in | stringstream::out);
  ss << "0 0 " << codes << endl;
  FreemanChain<int> theContour( ss );

  trace.info() << "Processing of " << ss.str() << endl;

  //draw the digital contour
  aBoard
   << SetMode( "PointVector", "Grid" )
   << theContour;

  //draw the maximal segments
  segmentationIntoMaximalDSSs(theContour.begin(), theContour.end(), aBoard);

  //save the drawing
  aBoard.saveSVG("convex-and-concave-parts.svg");
  #ifdef WITH_CAIRO
    aBoard.saveCairo("convex-and-concave-parts.png"); 
  #endif

  trace.endBlock();

  return 0;
}
开发者ID:BorisMansencal,项目名称:DGtal,代码行数:45,代码来源:convex-and-concave-parts.cpp

示例12: alphaShape

/**
 * Algorithms that computes the alpha-shape
 * of a point set
 */
void alphaShape()
{

  //Digitization of a disk of radius 8
  Ball2D<Z2i::Space> ball(Z2i::Point(0,0), 8);
  Z2i::Domain domain(ball.getLowerBound(), ball.getUpperBound());
  Z2i::DigitalSet digitalSet(domain);   
  Shapes<Z2i::Domain>::euclideanShaper(digitalSet, ball);
  
  //Contour of the digital set
  Z2i::KSpace kspace; 
  kspace.init(domain.lowerBound()-Z2i::Point(1,1), domain.upperBound()+Z2i::Point(1,1), true); 
  typedef DigitalSetBoundary<Z2i::KSpace, Z2i::DigitalSet> DigitalSurfaceContainer;
  typedef DigitalSurface<DigitalSurfaceContainer> CustomDigitalSurface; 
  DigitalSurfaceContainer digitalSurfaceContainer( kspace, digitalSet ); 
  CustomDigitalSurface digitalSurface( digitalSurfaceContainer ); 

  //Grid curve
  Z2i::Curve gridCurve; 
  typedef DepthFirstVisitor<DigitalSurface<DigitalSurfaceContainer> > CustomVisitor;
  CustomVisitor visitor( digitalSurface, *digitalSurface.begin() );
  while ( ! visitor.finished() )
    {
      gridCurve.pushBack( visitor.current().first );
      visitor.expand();
    }

  //Point set defined as the set of (not duplicated) inner points  
  typedef Z2i::Curve::InnerPointsRange PointRange; 
  PointRange pointsRange = gridCurve.getInnerPointsRange();
  vector<Z2i::Point> border; 
  unique_copy( pointsRange.begin(), pointsRange.end(), back_inserter( border ) ); 

  //namespace for hull functions
  using namespace functions::Hull2D; 

  { //alpha = 0
    trace.info() << " alpha == 0 " << endl; 
    vector<Z2i::Point> res; 
    
    //! [Hull2D-RadiusPredicateInf]
    typedef AvnaimEtAl2x2DetSignComputer<DGtal::int64_t> DetComputer; 
    typedef InGeneralizedDiskOfGivenRadius<Z2i::Point, DetComputer> Functor; 
    Functor functor(true, 1, 0); //alpha = 0; 1/alpha -> +inf 
    typedef PredicateFromOrientationFunctor2<Functor> Predicate; 
    Predicate predicate( functor ); 
    //! [Hull2D-RadiusPredicateInf]

    //! [Hull2D-ClosedGrahamScan]
    closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate );   
    //! [Hull2D-ClosedGrahamScan]

    //display
    Board2D board;
    drawPolygon( res.begin(), res.end(), board ); 
    board.saveSVG( "AlphaShape0.svg" );  
#ifdef WITH_CAIRO
    board.saveCairo("AlphaShape0.png", Board2D::CairoPNG);
#endif

   }

  { //alpha = 0
    trace.info() << " alpha == 0 " << endl; 
    vector<Z2i::Point> res; 
    
    //comparator and functor
    typedef InHalfPlaneBySimple3x3Matrix<Z2i::Point, DGtal::int64_t> Functor;  
    Functor functor; 
    typedef PredicateFromOrientationFunctor2<Functor> Predicate; 
    Predicate predicate( functor ); 

    closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate );   
    
    //display
    Board2D board;
    drawPolygon( res.begin(), res.end(), board ); 
    board.saveSVG( "AlphaShape0bis.svg" );  
#ifdef WITH_CAIRO
    board.saveCairo("AlphaShape0bis.png", Board2D::CairoPNG);
#endif

   }

  //negative alpha shape
  { //alpha = -1
    trace.info() << " alpha == -1 " << endl; 
    vector<Z2i::Point> res; 

    typedef AvnaimEtAl2x2DetSignComputer<DGtal::int64_t> DetComputer; 
    typedef InGeneralizedDiskOfGivenRadius<Z2i::Point, DetComputer> Functor; 
    //! [Hull2D-RadiusPredicateM1]
    Functor functor(false, 1, 1); //1/alpha = -sqrt(1/1) = -1 
    //! [Hull2D-RadiusPredicateM1]
    typedef PredicateFromOrientationFunctor2<Functor> Predicate; 
    Predicate predicate( functor ); 
//.........这里部分代码省略.........
开发者ID:Victor-Ostromoukhov,项目名称:DGtal,代码行数:101,代码来源:exampleAlphaShape.cpp

示例13: exampleUpdate

/**
 * @brief Function showing how a DSS can be extended and retracted. 
 */
void exampleUpdate()
{
  trace.beginBlock ( "DSS update" );

  using namespace Z2i; 

  //Construction --------------------------------------------------
  //! [ArithmeticalDSSUpdateInit]
  Point M(11, 7); 
  NaiveDSS8<Integer> S( 5, 8,       //slope 
			Point(0,0), Point(10,6), //ending points 
			Point(0,0), Point(8,5), //upper points
			Point(3,1), Point(3,1)  //lower points
			);
  //! [ArithmeticalDSSUpdateInit]

  //this segment should be valid: 
  if (!S.isValid()) throw std::exception();
  // Store a copy before any operation
  NaiveDSS8<Integer> copyOfS = S; 

  trace.info() << S << std::endl;


  //Display ------------------------------------------------------  
  {
    Board2D board;

    // Draw the grid
    Domain domain( Point(0,0), M );
    board << SetMode(domain.className(), "Grid")
	  << domain;    
    // Draw the points of the DSS and its bounding box
    board << SetMode("PointVector", "Both");
    board << SetMode(S.className(), "Points") 
	  << S
	  << SetMode(S.className(), "BoundingBox") 
	  << S;
    // Draw the orthonormal base
    board.drawArrow(0.0, 0.0, 1.0, 0.0); 
    board.drawArrow(0.0, 0.0, 0.0, 1.0); 
    // Draw M
    board << SetMode(M.className(), "Both")
	  << CustomStyle( M.className(), new CustomColors( Color(255,0,0), Color(192, 0, 0)) )
	  << M; 


    // Save
    board.saveSVG("NaiveDSS8ExtInit.svg");
#ifdef WITH_CAIRO
    board.saveCairo("NaiveDSS8ExtInit.png", Board2D::CairoPNG);
#endif
  }

  // Extension -----------------------------------------------------
  //! [ArithmeticalDSSUpdateExtension]
  bool resExtention = S.extendFront( M ); 
  //! [ArithmeticalDSSUpdateExtension]
  //this segment should be extended: 
  if (!resExtention) throw std::exception(); 

  trace.info() << S << std::endl; 

  //Display ------------------------------------------------------  
  {
    Board2D board;

    // Draw the grid
    Domain domain( Point(0,0), M );
    board << SetMode(domain.className(), "Grid")
	  << domain;    
    // Draw the points of the DSS and its bounding box
    board << SetMode("PointVector", "Both");
    board << SetMode(S.className(), "Points") 
	  << S
	  << SetMode(S.className(), "BoundingBox") 
	  << S;
    // Draw the orthonormal base
    board.drawArrow(0.0, 0.0, 1.0, 0.0); 
    board.drawArrow(0.0, 0.0, 0.0, 1.0); 

    // Save
    board.saveSVG("NaiveDSS8ExtDone.svg");
#ifdef WITH_CAIRO
    board.saveCairo("NaiveDSS8ExtDone.png", Board2D::CairoPNG);
#endif
  }
    
  // Retraction ----------------------------------------------------
  //! [ArithmeticalDSSUpdateRetraction]
  bool resRetraction = S.retractFront(); 
  //! [ArithmeticalDSSUpdateRetraction]
  //this segment should be retracted: 
  if (!resRetraction) throw std::exception(); 

  trace.info() << S << std::endl; 

//.........这里部分代码省略.........
开发者ID:arnaudetitia,项目名称:DGtal,代码行数:101,代码来源:exampleArithmeticalDSS.cpp

示例14: exampleStandardDSS

/**
 * @brief Function that illustrates the basic usage of
 * a standard DSS. 
 */
void exampleStandardDSS()
{
  trace.beginBlock ( "Standard DSS" );

  using namespace Z2i; 

  //! [ArithmeticalDSSStandardCtor]
  // Construct a standard DSS
  StandardDSS4<Integer> segment( 5, 8,                   //slope
				 Point(0,0), Point(8,5), //ending points 
				 Point(0,0), Point(8,5), //upper points
				 Point(4,1), Point(4,1)  //lower points
				 );
  //! [ArithmeticalDSSStandardCtor]

  // Trace to the standard output
  trace.info() << segment << std::endl; 

  // Display the DSS with a domain on a board
  Domain domain( Point(0,0), Point(8,5) );
  Board2D board;

  //! [StandardDSS4DrawingUsage] 
  // Draw the grid
  board << SetMode(domain.className(), "Grid")
	<< domain;    

  // Draw the points of the DSS
  board << SetMode("PointVector", "Grid")
	<< SetMode(segment.className(), "Points") 
	<< segment;

  // Draw the bounding box
  board << SetMode(segment.className(), "BoundingBox") 
	<< segment;
  //! [StandardDSS4DrawingUsage]

  // Save
  board.saveSVG("StandardDSS4.svg");
#ifdef WITH_CAIRO
  board.saveCairo("StandardDSS4.png", Board2D::CairoPNG);
#endif

  board.clear(); 
  //! [ArithmeticalDSSDrawingUsage]
  // Draw the pixels
  board << SetMode(domain.className(), "Paving")
	<< domain;    
  
  //Draw the points of the DSS
  board << SetMode("PointVector", "Both");
  board << SetMode(segment.className(), "Points") 
	<< segment;

  // Draw the bounding box
  board << SetMode(segment.className(), "BoundingBox") 
	<< segment;
  //! [ArithmeticalDSSDrawingUsage]

  board.saveSVG("StandardDSS4bis.svg");
#ifdef WITH_CAIRO
  board.saveCairo("StandardDSS4bis.png", Board2D::CairoPNG);
#endif

  trace.endBlock();
}
开发者ID:arnaudetitia,项目名称:DGtal,代码行数:70,代码来源:exampleArithmeticalDSS.cpp

示例15: convexHull

/**
 * Algorithms that computes the convex hull
 * of a point set
 */
void convexHull()
{
  //Digitization of a disk of radius 6
  Ball2D<Z2i::Space> ball(Z2i::Point(0,0), 6);
  Z2i::Domain domain(ball.getLowerBound(), ball.getUpperBound());
  Z2i::DigitalSet pointSet(domain);   
  Shapes<Z2i::Domain>::euclideanShaper(pointSet, ball);

  //! [Hull2D-Namespace]
  using namespace functions::Hull2D; 
  //! [Hull2D-Namespace]

  //! [Hull2D-Functor]
  typedef InHalfPlaneBySimple3x3Matrix<Z2i::Point, DGtal::int64_t> Functor;  
  Functor functor; 
  //! [Hull2D-Functor]

  { //convex hull in counter-clockwise order
    vector<Z2i::Point> res; 

    //! [Hull2D-StrictPredicateCCW]
    typedef PredicateFromOrientationFunctor2<Functor, false, false> StrictPredicate; 
    StrictPredicate predicate( functor ); 
    //! [Hull2D-StrictPredicateCCW]
    //according to the last two template arguments, neither strictly negative values, nor zeros are accepted: 
    //the predicate returns 'true' only for strictly positive values returned by the underlying functor. 

    //! [Hull2D-AndrewAlgo]
    andrewConvexHullAlgorithm( pointSet.begin(), pointSet.end(), back_inserter( res ), predicate );   
    //! [Hull2D-AndrewAlgo]
    //![Hull2D-Caliper-computeBasic]
    double th = DGtal::functions::Hull2D::computeHullThickness(res.begin(), res.end(), DGtal::functions::Hull2D::HorizontalVerticalThickness);
    //![Hull2D-Caliper-computeBasic]

    //![Hull2D-Caliper-computeAnti]
    Z2i::Point antipodalP, antipodalQ, antipodalS;
    th = DGtal::functions::Hull2D::computeHullThickness(res.begin(), res.end(), DGtal::functions::Hull2D::HorizontalVerticalThickness, antipodalP, antipodalQ, antipodalS);
    //![Hull2D-Caliper-computeAnti]

    
    trace.info() <<" ConvexHull HV thickness: " << th << std::endl;
    //display
    Board2D board;
    drawPolygon( res.begin(), res.end(), board ); 
    //![Hull2D-Caliper-display]
    board.setPenColor(DGtal::Color::Red);
    board.drawCircle( antipodalS[0], antipodalS[1], 0.2) ;
    board.setPenColor(DGtal::Color::Blue);
    board.drawCircle(antipodalP[0], antipodalP[1], 0.2);
    board.drawCircle(antipodalQ[0], antipodalQ[1], 0.2);
    board.drawLine(antipodalP[0], antipodalP[1], antipodalQ[0], antipodalQ[1]);
    //![Hull2D-Caliper-display]
    
    board.saveSVG( "ConvexHullCCW.svg" );  
#ifdef WITH_CAIRO
    board.saveCairo("ConvexHullCCW.png", Board2D::CairoPNG);
#endif
  }

  { //convex hull in counter-clockwise order with all the points lying on the edges
    vector<Z2i::Point> res; 

    //! [Hull2D-LargePredicateCCW]
    typedef PredicateFromOrientationFunctor2<Functor, false, true> LargePredicate; 
    LargePredicate predicate( functor ); 
    //! [Hull2D-LargePredicateCCW]
    //according to the last template argument, zeros are accepted so that  
    //the predicate returns 'true' for all the positive values returned by the underlying functor. 

    //andrew algorithm
    andrewConvexHullAlgorithm( pointSet.begin(), pointSet.end(), back_inserter( res ), predicate );   

    //display
    Board2D board;
    drawPolygon( res.begin(), res.end(), board ); 
    board.saveSVG( "ConvexHullCCWWithPointsOnEdges.svg" );  
#ifdef WITH_CAIRO
    board.saveCairo("ConvexHullCCWWithPointsOnEdges.png", Board2D::CairoPNG);
#endif

  }

  { //convex hull in clockwise order
    vector<Z2i::Point> res; 

    //! [Hull2D-StrictPredicateCW]
    typedef PredicateFromOrientationFunctor2<Functor, true, false> StrictPredicate; 
    StrictPredicate predicate( functor );
    //! [Hull2D-StrictPredicateCW]
    //according to the last two argument template, 
    //the predicate returns 'true' only for strictly negative values returned by the underlying functor. 

    //andrew algorithm
    andrewConvexHullAlgorithm( pointSet.begin(), pointSet.end(), back_inserter( res ), predicate );   

    //display
//.........这里部分代码省略.........
开发者ID:Victor-Ostromoukhov,项目名称:DGtal,代码行数:101,代码来源:exampleConvexHull2D.cpp


注:本文中的Board2D::saveCairo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。