本文整理汇总了C++中Board2D::saveFIG方法的典型用法代码示例。如果您正苦于以下问题:C++ Board2D::saveFIG方法的具体用法?C++ Board2D::saveFIG怎么用?C++ Board2D::saveFIG使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Board2D
的用法示例。
在下文中一共展示了Board2D::saveFIG方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testSimpleBoard
/**
* 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;
}
示例2: 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;
}
示例3: main
int main()
{
typedef SpaceND<2> Space2;
typedef HyperRectDomain<Space2> TDomain;
typedef TDomain::Vector Vector;
//Default image selector = STLVector
typedef ImageSelector<TDomain, unsigned char>::Type Image;
// Creating FreemanChain from file
std::string freemanChainFilename = examplesPath + "samples/contourS.fc";
fstream fst;
fst.open (freemanChainFilename.c_str(), ios::in);
FreemanChain<Space::Integer> fc(fst);
fst.close();
// Importing image with MagickReader
MagickReader<Image> reader;
std::string filenameImage = examplesPath + "samples/contourS.gif";
Image img = reader.importImage( filenameImage );
Point ptInf = img.lowerBound();
Point ptSup = img.upperBound();
unsigned int width = abs(ptSup.at(0)-ptInf.at(0)+1);
unsigned int height = abs(ptSup.at(1)-ptInf.at(1)+1);
// Draw the freemanchain and the contour
Board2D dgBoard;
dgBoard.drawImage(filenameImage, 0,height-1, width, height );
dgBoard << fc;
dgBoard.saveEPS("freemanChainDisplay.eps");
dgBoard.saveSVG("freemanChainDisplay.svg");
dgBoard.saveFIG("freemanChainDisplay.fig");
return 0;
}
示例4: 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;
}
示例5: main
int main( int /*argc*/, char** /*argv*/ )
{
trace.beginBlock ( "Example ctopo-fillContours" );
DGtal::KhalimskySpaceND< 2, int > K;
K.init(Z2i::Point(0, 10), Z2i::Point(20, 30), false);
// We choose a direct and indirect oriented contour.
//! [ctopoFillContoursInit]
FreemanChain<int> fc1 ("001001001001001111101111011222222223222222322233333330301033333003", 6, 14);
FreemanChain<int> fc2 ("1111000033332222", 6, 20);
//! [ctopoFillContoursInit]
Board2D aBoard;
Board2D aBoard2;
aBoard << K.lowerBound() << K.upperBound() ;
aBoard2 << K.lowerBound() << K.upperBound() ;
//From the FreemanChain we can get a vector of SCell wrapped in a SurfelSetPredicate with sign defined from the FreemanChain orientation:
//! [ctopoFillContoursGetSCells]
typedef KhalimskySpaceND<2, int>::SCell SCell;
std::set<DGtal::KhalimskySpaceND< 2, int >::SCell> boundarySCell;
FreemanChain<int>::getInterPixelLinels(K, fc1, boundarySCell, false);
//! [ctopoFillContoursGetSCells]
aBoard << CustomStyle((*boundarySCell.begin()).className(), new CustomColors(DGtal::Color::Red, DGtal::Color::Red) );
for( std::set<DGtal::KhalimskySpaceND< 2, int >::SCell>::const_iterator it= boundarySCell.begin();
it!= boundarySCell.end(); it++){
aBoard << *it;
}
// We can also add other freeman chains with indirect orientation to construct a hole in interior of the shape:
//! [ctopoFillContoursGetSCellsHole]
std::set<DGtal::KhalimskySpaceND< 2, int >::SCell> boundarySCellhole;
FreemanChain<int>::getInterPixelLinels(K, fc2, boundarySCellhole, false);
//! [ctopoFillContoursGetSCellsHole]
aBoard << CustomStyle((*boundarySCell.begin()).className(), new CustomColors(DGtal::Color::Blue, DGtal::Color::Blue) );
aBoard2 << CustomStyle((*boundarySCell.begin()).className(), new CustomColors(DGtal::Color::Blue, DGtal::Color::Blue) );
for( std::set<DGtal::KhalimskySpaceND< 2, int >::SCell>::const_iterator it= boundarySCellhole.begin(); it!= boundarySCellhole.end(); it++){
aBoard << *it;
aBoard2 << *it;
boundarySCell.insert(*it);
}
// Now we can compute the unsigned cell associated to interior pixels:
//! [ctopoFillContoursFillRegion]
typedef ImageContainerBySTLMap< Z2i::Domain, bool> BoolImage2D;
BoolImage2D::Domain imageDomain( Z2i::Point(0,10), Z2i::Point(20,30) );
BoolImage2D interiorCellImage( imageDomain );
Surfaces<DGtal::KhalimskySpaceND< 2, int > >::uFillInterior(K, functors::SurfelSetPredicate<std::set<SCell>,SCell>(boundarySCell),
interiorCellImage, 1, false);
//! [ctopoFillContoursFillRegion]
aBoard << CustomStyle(K.uSpel(Z2i::Point(0,0)).className(), new CustomColors(DGtal::Color::None, Color(200, 200, 200)) );
for(BoolImage2D::Domain::ConstIterator it = interiorCellImage.domain().begin();
it!=interiorCellImage.domain().end(); it++){
if(interiorCellImage(*it)){
aBoard << K.uSpel(*it);
}
}
// We can also compute the unsigned cell associated to interior and exterior pixels:
//! [ctopoFillContoursFillRegionHoles]
BoolImage2D interiorCellHoleImage( imageDomain );
BoolImage2D exteriorCellHoleImage( imageDomain );
Surfaces<DGtal::KhalimskySpaceND< 2, int > >::uFillInterior(K, functors::SurfelSetPredicate<std::set<SCell>, SCell>(boundarySCellhole),
interiorCellHoleImage, 1, true);
Surfaces<DGtal::KhalimskySpaceND< 2, int > >::uFillExterior(K, functors::SurfelSetPredicate<std::set<SCell>, SCell>(boundarySCellhole),
exteriorCellHoleImage, 1, false);
//! [ctopoFillContoursFillRegionHoles]
aBoard2 << CustomStyle(K.uSpel(Z2i::Point(0,0)).className(),
new CustomColors(DGtal::Color::None, Color(200, 200, 200)) );
for(BoolImage2D::Domain::ConstIterator it = interiorCellHoleImage.domain().begin();
it!=interiorCellHoleImage.domain().end(); it++){
if(interiorCellHoleImage(*it)){
aBoard2 << K.uSpel(*it);
}
}
aBoard2 << CustomStyle(K.uSpel(Z2i::Point(0,0)).className(),
new CustomColors(DGtal::Color::None, Color(100, 100, 100)) );
for(BoolImage2D::Domain::ConstIterator it = exteriorCellHoleImage.domain().begin();
it!=exteriorCellHoleImage.domain().end(); it++){
if(exteriorCellHoleImage(*it)){
aBoard2 << K.uSpel(*it);
}
}
aBoard.saveEPS("example_ctopo-fillContours.eps");
aBoard.saveFIG("example_ctopo-fillContours.fig");
//.........这里部分代码省略.........
示例6: 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);
}
}
示例7: 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());
}
}
示例8: main
int main(int argc, char** argv)
{
Point ptL(-1, -1);
Point ptU(3, 3);
Domain d (ptL, ptU);
Point pt0(0,0);
Point pt1(1,0);
Point pt2(0,1);
Point pt3(2,1);
Point pt4(1,2);
Point pt5(2,2);
DigitalSet aSet( d );
aSet.insert(pt0);
aSet.insert(pt1);
aSet.insert(pt2);
aSet.insert(pt3);
aSet.insert(pt4);
Board2D boardAdj;
boardAdj << d;
std::set<SCell> bdry;
Z2i::KSpace ks;
ks.init( ptL, ptU, true );
boardAdj << aSet;
// Extracting the surface boundary of the shape
Surfaces<Z2i::KSpace>::sMakeBoundary( bdry, ks, aSet, ks.lowerBound(), ks.upperBound() );
SurfelAdjacency<Z2i::KSpace::dimension> sAdjInt( true );
SurfelAdjacency<Z2i::KSpace::dimension> sAdjExt( false );
//Displaying the boundary bels
std::set<SCell>::iterator itBoundary;
int i=0;
Board2D boardDisplayAll;
boardDisplayAll<< d;
boardAdj.saveFIG("illustrationAdjSRC.fig");
for(itBoundary= bdry.begin(); itBoundary!= bdry.end(); itBoundary++){
boardDisplayAll << *itBoundary;
}
boardDisplayAll.saveFIG("illustrationAdjBdr.fig");
itBoundary = bdry.begin();
for (int i =0; i<10; i++) itBoundary++;
SCell surfel = *itBoundary;
// Defining surfel Neighborhood given an surfel Adjacency
SurfelNeighborhood<KSpace> sNeighInt;
sNeighInt.init( &ks, &sAdjInt, surfel );
SurfelNeighborhood<KSpace> sNeighExt;
sNeighExt.init( &ks, &sAdjExt, surfel );
SCell surfelFollowerInt;
SCell surfelFollowerExt;
sNeighInt.getAdjacentOnDigitalSet ( surfelFollowerInt, aSet, *(ks.sDirs(surfel)), true);
sNeighExt.getAdjacentOnDigitalSet ( surfelFollowerExt, aSet, *(ks.sDirs(surfel)), true);
boardAdj << CustomStyle( surfel.className() ,
new CustomColors( Color::Blue,
Color::Gray ));
boardAdj << surfel;
boardAdj << CustomStyle( surfel.className() ,
new CustomColors( Color::Red,
Color::Black ));
boardAdj << surfelFollowerInt;
boardAdj << CustomStyle( surfel.className() ,
new CustomColors( Color::Green,
Color::White ));
boardAdj << surfelFollowerExt;
boardAdj.saveFIG("illustrationAdjIntExt.fig");
// Extraction of contour
std::set<SCell> aContour1;
Surfaces<Z2i::KSpace>::trackBoundary( aContour1, ks,
sAdjExt,
aSet, surfel );
Board2D boardContour1;
boardContour1 << d;
//.........这里部分代码省略.........