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


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

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


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

示例1: main

int main()
{
  trace.beginBlock ( "Example of greedy alpha thick segment  decompotion" );
  
  typedef  std::vector<Z2i::RealPoint>::const_iterator ConstIterator;
  typedef  AlphaThickSegmentComputer<Z2i::RealPoint, ConstIterator > AlphaThickSegmentComputer2D;
  
  Board2D aBoard;
  std::string file = examplesPath + "samples/contourSnoisy.sdp";
  std::vector<Z2i::RealPoint> aContour = PointListReader<Z2i::RealPoint>::getPointsFromFile (file);

  typedef GreedySegmentation<AlphaThickSegmentComputer2D> DecompositionAT;

  // displaying contour
  aBoard << SetMode(aContour[0].className(), "Grid"); 
  std::vector<LibBoard::Point> poly;
  for (unsigned int i = 0; i< aContour.size(); i++)  poly.push_back(LibBoard::Point(aContour[i][0], aContour[i][1]));
  aBoard.setPenColor(DGtal::Color::Gray);
  aBoard.fillPolyline(poly);
  
  // Computing greedy Alpha Thick decomposition.
  //! [greedyAlphaThickDecompositionModeDisplay]
  aBoard << SetMode("AlphaThickSegment", "BoundingBox");
  //! [greedyAlphaThickDecompositionModeDisplay]
  
  //! [greedyAlphaThickDecompositionAlgo]
  DecompositionAT theDecomposition(aContour.begin(), aContour.end(), AlphaThickSegmentComputer2D(4)); 
  //! [greedyAlphaThickDecompositionAlgo]

  //! [greedyAlphaThickDecompositionDisplay]  
  for ( DecompositionAT::SegmentComputerIterator 
           it = theDecomposition.begin(),
           itEnd = theDecomposition.end();
         it != itEnd; ++it ) 
     {
       aBoard << CustomStyle( (*it).className(), 
                              new CustomPenColor( Color::Blue ) );
       aBoard<< *it;
     } 
  //! [greedyAlphaThickDecompositionDisplay]  

  aBoard.saveEPS("greedyAlphaThickDecomposition.eps");

  trace.endBlock();
  return 0;
}
开发者ID:Victor-Ostromoukhov,项目名称:DGtal,代码行数:46,代码来源:greedyAlphaThickDecomposition.cpp

示例2: main


//.........这里部分代码省略.........
        }



    }



    if(vm.count("SDP") || vm.count("SFP")) {
        bool drawPoints= vm.count("drawContourPoint");
        bool invertYaxis = vm.count("invertYaxis");
        double pointSize=1.0;
        if(drawPoints) {
            pointSize = vm["drawContourPoint"].as<double>();
        }
        std::vector<LibBoard::Point> contourPt;
        if(vm.count("SDP")) {
            std::string fileName = vm["SDP"].as<std::string>();
            std::vector< Z2i::Point >  contour =
                PointListReader< Z2i::Point >::getPointsFromFile(fileName);
            for(unsigned int j=0; j<contour.size(); j++) {
                LibBoard::Point pt((double)(contour.at(j)[0]),
                                   (invertYaxis? (double)(-contour.at(j)[1]+contour.at(0)[1]):(double)(contour.at(j)[1])));
                contourPt.push_back(pt);
                if(drawPoints) {
                    aBoard.fillCircle(pt.x, pt.y, pointSize);
                }
            }
        }

        if(vm.count("SFP")) {
            std::string fileName = vm["SFP"].as<std::string>();
            std::vector< PointVector<2,double>  >  contour =
                PointListReader<  PointVector<2,double>  >::getPointsFromFile(fileName);
            for(unsigned int j=0; j<contour.size(); j++) {
                LibBoard::Point pt((double)(contour.at(j)[0]),
                                   (invertYaxis? (double)(-contour.at(j)[1]+contour.at(0)[1]):(double)(contour.at(j)[1])));
                contourPt.push_back(pt);
                if(drawPoints) {
                    aBoard.fillCircle(pt.x, pt.y, pointSize);
                }
            }

        }


        aBoard.setPenColor(Color::Red);
        aBoard.setFillColor(Color::Gray);
        aBoard.setLineStyle (LibBoard::Shape::SolidStyle );
        aBoard.setLineWidth (lineWidth);
        if(!filled) {
            aBoard.drawPolyline(contourPt);
        } else {
            aBoard.fillPolyline(contourPt);
        }
        if(vm.count("drawPointOfIndex")) {
            int index = vm["drawPointOfIndex"].as<int>();
            double size = vm["pointSize"].as<double>();
            aBoard.fillCircle((double)(contourPt.at(index).x), (double)(contourPt.at(index).y), size);
        }



    }




    if(vm.count("outputFile")) {
        std::string outputFileName= vm["outputFile"].as<std::string>();
        std::string extension = outputFileName.substr(outputFileName.find_last_of(".") + 1);

        if(extension=="svg") {
            aBoard.saveSVG(outputFileName.c_str());
        }
#ifdef WITH_CAIRO
        else if (extension=="eps") {
            aBoard.saveCairo(outputFileName.c_str(),Board2D::CairoEPS );
        } else if (extension=="pdf") {
            aBoard.saveCairo(outputFileName.c_str(),Board2D::CairoPDF );
        } else if (extension=="png") {
            aBoard.saveCairo(outputFileName.c_str(),Board2D::CairoPNG );
        }
#endif
        else if(extension=="eps") {
            aBoard.saveEPS(outputFileName.c_str());
        } else if(extension=="fig") {
            aBoard.saveFIG(outputFileName.c_str(),LibBoard::Board::BoundingBox, 10.0, !vm.count("noXFIGHeader") );
        }
    }

    if (vm.count("outputStreamSVG")) {
        aBoard.saveSVG(std::cout);
    } else if (vm.count("outputStreamFIG")) {
        aBoard.saveFIG(std::cout, LibBoard::Board::BoundingBox, 10.0,  !vm.count("noXFIGHeader"));
    } else if (vm.count("outputStreamEPS")) {
        aBoard.saveEPS(std::cout);
    }

}
开发者ID:vanthonguyen,项目名称:DGtalTools,代码行数:101,代码来源:displayContours.cpp

示例3: main


//.........这里部分代码省略.........
  if(args.check("-backgroundImageXFIG")){
    string imageName = args.getOption("-backgroundImageXFIG")->getValue(0);
    unsigned int width = args.getOption("-backgroundImageXFIG")->getIntValue(1);
    unsigned int height = args.getOption("-backgroundImageXFIG")->getIntValue(2);
    aBoard.drawImage(imageName, 0,height-1, width, height, -1, 1.0 );
    }
 
  if(args.check("-fc")){
    string fileName = args.getOption("-fc")->getValue(0);
    vector< FreemanChain<int> > vectFc =  PointListReader< Z2i::Point>:: getFreemanChainsFromFile<int> (fileName); 
    //aBoard <<  SetMode( vectFc.at(0).className(), "InterGrid" );
    aBoard << CustomStyle( vectFc.at(0).className(), 
			   new CustomColors( Color::Red  ,  (filled ? (Color::Black) : (Color::None))  ) );    
    for(unsigned int i=0; i<vectFc.size(); i++){
      aBoard <<  vectFc.at(i) ;
    }
  } 
 

  if( args.check("-sdp") || args.check("-sfp")){
    bool drawPoints= args.check("-drawContourPoint");
    bool invertYaxis = args.check("-invertYaxis");
    
    double pointSize = args.getOption("-drawContourPoint")->getFloatValue(0);
    
    vector<LibBoard::Point> contourPt;
    if(args.check("-sdp")){
      string fileName = args.getOption("-sdp")->getValue(0);
      vector< Z2i::Point >  contour = 
	PointListReader< Z2i::Point >::getPointsFromFile(fileName); 
      for(unsigned int j=0; j<contour.size(); j++){
	LibBoard::Point pt((double)(contour.at(j)[0]),
			   (invertYaxis? (double)(-contour.at(j)[1]+contour.at(0)[1]):(double)(contour.at(j)[1])));
	contourPt.push_back(pt);
	if(drawPoints){
	  aBoard.fillCircle(pt.x, pt.y, pointSize);
	}
      }
    }
    
    if(args.check("-sfp")){
      string fileName = args.getOption("-sfp")->getValue(0);
      vector< PointVector<2,double>  >  contour = 
	PointListReader<  PointVector<2,double>  >::getPointsFromFile(fileName); 
      for(unsigned int j=0; j<contour.size(); j++){
	LibBoard::Point pt((double)(contour.at(j)[0]),
			   (invertYaxis? (double)(-contour.at(j)[1]+contour.at(0)[1]):(double)(contour.at(j)[1])));
	contourPt.push_back(pt);
	if(drawPoints){
	  aBoard.fillCircle(pt.x, pt.y, pointSize);
	}
      }
    }
    aBoard.setPenColor(Color::Red);
    aBoard.setLineStyle (LibBoard::Shape::SolidStyle );
    aBoard.setLineWidth (lineWidth);
    if(!filled){
      aBoard.drawPolyline(contourPt);
    }else{
      aBoard.fillPolyline(contourPt);
    }
    
  
  }

 
  
  if (args.check("-outputSVG")){
    string outputFileName= args.getOption("-outputSVG")->getValue(0);
    aBoard.saveSVG(outputFileName.c_str());
  } else   
    if (args.check("-outputFIG")){
      string outputFileName= args.getOption("-outputFIG")->getValue(0);
      aBoard.saveFIG(outputFileName.c_str());
    } else
      if (args.check("-outputEPS")){
	string outputFileName= args.getOption("-outputEPS")->getValue(0);
	aBoard.saveEPS(outputFileName.c_str());
      }  
#ifdef WITH_CAIRO
      else
	if (args.check("-outputEPS")){
	  string outputFileName= args.getOption("-outputSVG")->getValue(0);
	  aBoard.saveCairo(outputFileName.c_str(),Board2D::CairoEPS );
	} else 
	  if (args.check("-outputPDF")){
	    string outputFileName= args.getOption("-outputPDF")->getValue(0);
	    aBoard.saveCairo(outputFileName.c_str(),Board2D::CairoPDF );
	  } else 
	    if (args.check("-outputPNG")){
	      string outputFileName= args.getOption("-outputPNG")getValue(0);
	      aBoard.saveCairo(outputFileName.c_str(),Board2D::CairoPNG );
	    }
#endif
	    else { //default output
	      string outputFileName= "output.eps";
	      aBoard.saveEPS(outputFileName.c_str());
	    }
  
}
开发者ID:kerautret,项目名称:DGtal-forIPOL,代码行数:101,代码来源:displayContours.cpp


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