本文整理汇总了C++中Board2D::setPenColor方法的典型用法代码示例。如果您正苦于以下问题:C++ Board2D::setPenColor方法的具体用法?C++ Board2D::setPenColor怎么用?C++ Board2D::setPenColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Board2D
的用法示例。
在下文中一共展示了Board2D::setPenColor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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;
}
示例3: aComputer
int
main(int argc, char ** argv){
typedef Z2i::Point Point;
std::vector<Point> contour = PointListReader<Point>::getPointsFromFile("../Samples/contourS.sdp");
Board2D aBoard;
for (auto&& p :contour) {
aBoard << p;
}
aBoard.setPenColor(DGtal::Color::Red);
aBoard.setFillColor(DGtal::Color::Red);
aBoard.drawCircle(contour[30][0], contour[30][1],1);
unsigned int startIndex = 30;
typedef AlphaThickSegmentComputer< Z2i::Point > AlphaThickSegmentComputer2D;
AlphaThickSegmentComputer2D aComputer(5);
aComputer.init(contour.begin()+30);
while(aComputer.extendFront()){
}
aBoard << CustomStyle( aComputer.className(), new CustomColors( DGtal::Color::Blue, DGtal::Color::None ) );
aBoard << aComputer;
aBoard.saveEPS("resultTuto2.eps");
return 0;
}
示例4: 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
//.........这里部分代码省略.........
示例5: main
int main( int argc, char** argv )
{
// parse command line ----------------------------------------------
po::options_description general_opt("Allowed options are: ");
general_opt.add_options()
("help,h", "display this message")
("input,i", po::value<std::string>(), "input FreemanChain file name")
("SDP", po::value<std::string>(), "Import a contour as a Sequence of Discrete Points (SDP format)")
("SFP", po::value<std::string>(), "Import a contour as a Sequence of Floating Points (SFP format)")
("drawContourPoint", po::value<double>(), "<size> display contour points as disk of radius <size>")
("fillContour", "fill the contours with default color (gray)")
("lineWidth", po::value<double>()->default_value(1.0), "Define the linewidth of the contour (SDP format)")
("drawPointOfIndex", po::value<int>(), "<index> Draw the contour point of index <index> (default 0) ")
("pointSize", po::value<double>()->default_value(2.0), "<size> Set the display point size of the point displayed by drawPointofIndex option (default 2.0) ")
("noXFIGHeader", " to exclude xfig header in the resulting output stream (no effect with option -outputFile).")
("withProcessing", po::value<std::string>(), "Processing (used only when the input is a Freeman chain (--input)):\n\t DSS segmentation {DSS}\n\t Maximal segments {MS}\n\t Faithful Polygon {FP}\n\t Minimum Length Polygon {MLP}")
("outputFile,o", po::value<std::string>(), " <filename> save output file automatically according the file format extension.")
("outputStreamEPS", " specify eps for output stream format.")
("outputStreamSVG", " specify svg for output stream format.")
("outputStreamFIG", " specify fig for output stream format.")
("invertYaxis", " invertYaxis invert the Y axis for display contours (used only with --SDP)")
("backgroundImage", po::value<std::string>(), "backgroundImage <filename> : display image as background ")
("alphaBG", po::value<double>(), "alphaBG <value> 0-1.0 to display the background image in transparency (default 1.0), (transparency works only if cairo is available)")
("scale", po::value<double>(), "scale <value> 1: normal; >1 : larger ; <1 lower resolutions )");
bool parseOK=true;
po::variables_map vm;
try {
po::store(po::parse_command_line(argc, argv, general_opt), vm);
} catch(const std::exception& ex) {
parseOK=false;
trace.info()<< "Error checking program options: "<< ex.what()<< std::endl;
}
po::notify(vm);
if(!parseOK||vm.count("help")||argc<=1 || (!(vm.count("input")) && !(vm.count("SDP")) && !(vm.count("SFP"))&&
!(vm.count("backgroundImage")) ) )
{
trace.info()<< "Display discrete contours. " <<std::endl << "Basic usage: "<<std::endl
<< "\t displayContours [options] --input <fileName> "<<std::endl
<< general_opt << "\n";
return 0;
}
double lineWidth= vm["lineWidth"].as<double>();
bool filled = vm.count("fillContour");
double scale=1.0;
if(vm.count("scale")) {
scale = vm["scale"].as<double>();
}
Board2D aBoard;
aBoard.setUnit (0.05*scale, LibBoard::Board::UCentimeter);
double alpha=1.0;
if(vm.count("alphaBG")) {
alpha = vm["alphaBG"].as<double>();
}
if(vm.count("backgroundImage")) {
std::string imageName = vm["backgroundImage"].as<std::string>();
typedef ImageSelector<Z2i::Domain, unsigned char>::Type Image;
Image img = DGtal::GenericReader<Image>::import( imageName );
Z2i::Point ptInf = img.domain().lowerBound();
Z2i::Point ptSup = img.domain().upperBound();
unsigned int width = abs(ptSup[0]-ptInf[0]+1);
unsigned int height = abs(ptSup[1]-ptInf[1]+1);
aBoard.drawImage(imageName, 0-0.5,height-0.5, width, height, -1, alpha );
}
if(vm.count("input")) {
std::string fileName = vm["input"].as<std::string>();
std::vector< FreemanChain<int> > vectFc = PointListReader< Z2i::Point>:: getFreemanChainsFromFile<int> (fileName);
aBoard << CustomStyle( vectFc.at(0).className(),
new CustomColors( Color::Red , filled? Color::Gray: Color::None ) );
aBoard.setLineWidth (lineWidth);
for(unsigned int i=0; i<vectFc.size(); i++) {
aBoard << vectFc.at(i) ;
if(vm.count("drawPointOfIndex")) {
int index = vm["drawPointOfIndex"].as<int>();
double size = vm["pointSize"].as<double>();
aBoard.setPenColor(Color::Blue);
aBoard.fillCircle((double)(vectFc.at(i).getPoint(index)[0]), (double)(vectFc.at(i).getPoint(index)[1]), size);
}
//.........这里部分代码省略.........
示例6: 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());
}
}