本文整理汇总了C++中Board2D::setUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ Board2D::setUnit方法的具体用法?C++ Board2D::setUnit怎么用?C++ Board2D::setUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Board2D
的用法示例。
在下文中一共展示了Board2D::setUnit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testDigitalSetBoardSnippet
bool testDigitalSetBoardSnippet()
{
typedef SpaceND<2> Z2;
typedef HyperRectDomain<Z2> Domain;
typedef Z2::Point Point;
Point p1( -10, -10 );
Point p2( 10, 10 );
Domain domain( p1, p2 );
typedef DigitalSetSelector < Domain, BIG_DS + HIGH_ITER_DS + HIGH_BEL_DS >::Type SpecificSet;
BOOST_CONCEPT_ASSERT(( concepts::CDigitalSet< SpecificSet > ));
SpecificSet mySet( domain );
Point c( 0, 0 );
mySet.insert( c );
Point d( 5, 2 );
mySet.insert( d );
Point e( 1, -3 );
mySet.insert( e );
Board2D board;
board.setUnit(LibBoard::Board::UCentimeter);
board << mySet;
board.saveSVG("myset-export.svg");
board.clear();
board.setUnit(LibBoard::Board::UCentimeter);
board << SetMode( domain.className(), "Grid" ) << domain << mySet;
board.saveSVG("simpleSet-grid.svg");
board.clear();
board.setUnit(LibBoard::Board::UCentimeter);
board << SetMode( domain.className(), "Paving" ) << domain;
board << mySet;
board.saveSVG("simpleSet-paving.svg");
board.clear();
board.setUnit(LibBoard::Board::UCentimeter);
board << CustomStyle( mySet.className(), new MyDomainStyleCustomRed );
board << mySet;
board.saveSVG("simpleSet-color.svg");
return true;
}
示例2: testBadKeySizes
bool testBadKeySizes()
{
typedef SpaceND<2> SpaceType;
typedef HyperRectDomain<SpaceType> TDomain;
typedef TDomain::Point Point;
Board2D board;
typedef HueShadeColorMap<unsigned char,2> HueTwice;
board.setUnit(Board2D::UCentimeter);
//Default image selector = STLVector
typedef ImageContainerByHashTree<TDomain, char> Image;
Point d(128,128);
trace.beginBlock ( "Test maximal depth > number of bits of the HashKey type" );
Image myImage ( 3, 80, 0 );
trace.info() << myImage;
trace.endBlock();
trace.beginBlock ( "Test morton hash size > number of bits of the HashKey type" );
///This should raise an ASSERT abort if uncommented
// Image myImage2 ( 80, 8, 0 );
//trace.info() << myImage2;
trace.endBlock();
//Default image selector = STLVector
typedef ImageContainerByHashTree<TDomain, unsigned int, DGtal::uint32_t> Image2;
trace.beginBlock ( "Changing the HashKey type" );
Image2 myImage3( 3, 80, 0 );
trace.info() << myImage3;
trace.endBlock();
return true;
}
示例3: 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
}
示例4: 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;
}
示例5: testDrawRange
bool testDrawRange(const Range &aRange, const string &aName, const string& aDomainMode)
{
std::stringstream s;
s << aName << "Range.eps";
trace.info() << endl;
trace.info() << "Drawing " << s.str() << " (" << aRange.size() << " elts)" << endl;
//board
Board2D aBoard;
aBoard.setUnit(Board2D::UCentimeter);
//displaying domain
PointVector<2,int> low(-1,-1);
PointVector<2,int> up(3,3);
if (aDomainMode == "Paving") up = PointVector<2,int>(4,4);
HyperRectDomain< SpaceND<2,int> > aDomain( low,up );
aBoard << SetMode(aDomain.className(), aDomainMode) << aDomain;
//displaying range
aBoard << aRange;
//save
aBoard.saveEPS( s.str().c_str(), Board2D::BoundingBox, 5000 );
return true;
}
示例6: testDigitalSetBoardSnippet
bool testDigitalSetBoardSnippet()
{
typedef SpaceND<2> Z2;
typedef HyperRectDomain<Z2> Domain;
typedef Z2::Point Point;
Point p1( -10, -10 );
Point p2( 10, 10 );
Domain domain( p1, p2 );
typedef DigitalSetSelector < Domain, BIG_DS + HIGH_ITER_DS + HIGH_BEL_DS >::Type SpecificSet;
SpecificSet mySet( domain );
Point c( 0, 0 );
mySet.insert( c );
Point d( 5, 2 );
mySet.insert( d );
Point e( 1, -3 );
mySet.insert( e );
Board2D board;
board.setUnit(Board::UCentimeter);
board << mySet;
board.saveSVG("myset-export.svg");
board.clear();
board.setUnit(Board::UCentimeter);
board << DrawDomainGrid() << domain << mySet;
board.saveSVG("simpleSet-grid.svg");
board.clear();
board.setUnit(Board::UCentimeter);
board << DrawDomainPaving() << domain;
board << mySet;
board.saveSVG("simpleSet-paving.svg");
board.clear();
board.setUnit(Board::UCentimeter);
board << CustomStyle( mySet.styleName(), new MyDomainStyleCustomRed );
board << mySet;
board.saveSVG("simpleSet-color.svg");
return true;
}
示例7: testDSS8drawing
/**
* Test for 8-connected points
*
*/
bool testDSS8drawing()
{
typedef PointVector<2,int> Point;
typedef std::vector<Point>::iterator Iterator;
typedef ArithmeticalDSS<Iterator,int,8> DSS8;
std::vector<Point> boundary;
boundary.push_back(Point(0,0));
boundary.push_back(Point(1,1));
boundary.push_back(Point(2,1));
boundary.push_back(Point(3,2));
boundary.push_back(Point(4,2));
boundary.push_back(Point(5,2));
boundary.push_back(Point(6,3));
boundary.push_back(Point(6,4));
// Good Initialisation
trace.beginBlock("Add points while it is possible and draw the result");
DSS8 theDSS8;
theDSS8.init( boundary.begin() );
trace.info() << theDSS8 << " " << theDSS8.isValid() << std::endl;
{
while ( (theDSS8.end()!=boundary.end())
&&(theDSS8.extendForward()) ) {}
trace.info() << theDSS8 << " " << theDSS8.isValid() << std::endl;
HyperRectDomain< SpaceND<2,int> > domain( Point(0,0), Point(10,10) );
Board2D board;
board.setUnit(Board::UCentimeter);
board << SetMode(domain.className(), "Paving")
<< domain;
board << SetMode("PointVector", "Both");
board << SetMode(theDSS8.className(), "Points")
<< theDSS8;
board << SetMode(theDSS8.className(), "BoundingBox")
<< theDSS8;
board.saveSVG("DSS8.svg");
}
trace.endBlock();
return true;
}
示例8: testDisplayDT3d
/**
* Simple 3d distance transform
* and slice display
*/
bool testDisplayDT3d(int size, int area, double distance)
{
static const DGtal::Dimension dimension = 3;
//Domain
typedef HyperRectDomain< SpaceND<dimension, int> > Domain;
typedef Domain::Point Point;
Domain d(Point::diagonal(-size), Point::diagonal(size));
DomainPredicate<Domain> dp(d);
//Image and set
typedef ImageContainerBySTLMap<Domain,double> Image;
Image map( d, 0.0 );
map.setValue( Point::diagonal(0), 0.0 );
typedef DigitalSetFromMap<Image> Set;
Set set(map);
//computation
trace.beginBlock ( "Display 3d FMM results " );
typedef FMM<Image, Set, DomainPredicate<Domain> > FMM;
FMM fmm(map, set, dp, area, distance);
fmm.compute();
trace.info() << fmm << std::endl;
trace.endBlock();
{ //display
HueShadeColorMap<unsigned char, 2> colorMap(0,2*size);
Board2D b;
b.setUnit ( LibBoard::Board::UCentimeter );
Domain::ConstIterator it = d.begin();
for ( ; it != d.end(); ++it)
{
Point p3 = *it;
if (p3[2] == 0)
{
PointVector<2,Point::Coordinate> p2(p3[0], p3[1]);
b << CustomStyle( p2.className(),
new CustomFillColor( colorMap(map(p3)) ) )
<< p2;
}
}
std::stringstream s;
s << "DTFrom3dPt-" << size << "-" << area << "-" << distance
<< ".eps";
b.saveEPS(s.str().c_str());
}
return fmm.isValid();
}
示例9: testDSS4drawing
/**
* Test for 4-connected points
*
*/
bool testDSS4drawing()
{
typedef PointVector<2,int> Point;
typedef std::vector<Point>::iterator Iterator;
typedef ArithmeticalDSS<Iterator,int,4> DSS4;
std::vector<Point> contour;
contour.push_back(Point(0,0));
contour.push_back(Point(1,0));
contour.push_back(Point(1,1));
contour.push_back(Point(2,1));
contour.push_back(Point(3,1));
contour.push_back(Point(3,2));
contour.push_back(Point(4,2));
contour.push_back(Point(5,2));
contour.push_back(Point(6,2));
contour.push_back(Point(6,3));
contour.push_back(Point(6,4));
// Adding step
trace.beginBlock("Add points while it is possible and draw the result");
DSS4 theDSS4;
theDSS4.init( contour.begin() );
trace.info() << theDSS4 << " " << theDSS4.isValid() << std::endl;
while ( (theDSS4.end() != contour.end())
&&(theDSS4.extendForward()) ) {}
trace.info() << theDSS4 << " " << theDSS4.isValid() << std::endl;
HyperRectDomain< SpaceND<2,int> > domain( Point(0,0), Point(10,10) );
Board2D board;
board.setUnit(Board::UCentimeter);
board << SetMode(domain.className(), "Grid")
<< domain;
board << SetMode("PointVector", "Grid");
board << SetMode(theDSS4.className(), "Points")
<< theDSS4;
board << SetMode(theDSS4.className(), "BoundingBox")
<< theDSS4;
board.saveSVG("DSS4.svg");
trace.endBlock();
return true;
}
示例10: testPNMWriter
/**
* Example of a test. To be completed.
*
*/
bool testPNMWriter()
{
trace.beginBlock ( "Testing block ..." );
typedef SpaceND<2> TSpace;
typedef TSpace::Point Point;
typedef HyperRectDomain<TSpace> Domain;
typedef HueShadeColorMap<unsigned char> Hue;
typedef HueShadeColorMap<unsigned char,2> HueTwice;
typedef GrayscaleColorMap<unsigned char> Gray;
// Gradient using the "Jet" preset.
typedef GradientColorMap<unsigned char, CMAP_JET > Jet;
// Gradient from black to red.
const int BlackColor = DGTAL_RGB2INT(0,0,0);
const int RedColor = DGTAL_RGB2INT(255,0,0);
typedef GradientColorMap< unsigned char, CMAP_CUSTOM, BlackColor, RedColor > RedShade1;
// Gradient from black to red, using a ColorBrightnessColorMap.
typedef ColorBrightnessColorMap< unsigned char, RedColor > RedShade2;
Point a ( 1, 1);
Point b ( 16, 16);
typedef ImageSelector<Domain, unsigned char>::Type Image;
Image image(Domain(a,b));
for(unsigned int i=0 ; i < 256; i++)
image[i] = i;
PPMWriter<Image,Hue>::exportPPM("export-hue.ppm",image, Hue(0,255) );
PPMWriter<Image,HueTwice>::exportPPM("export-hue-twice.ppm",image,HueTwice(0,255));
PGMWriter<Image>::exportPGM("export-hue-twice.pgm",image);
PPMWriter<Image,Gray>::exportPPM("export-gray.ppm",image, Gray(0,255));
PPMWriter<Image,Jet>::exportPPM("export-jet.ppm",image,Jet(0,255));
PPMWriter<Image,RedShade1>::exportPPM("export-red1.ppm",image,RedShade1(0,255));
PPMWriter<Image,RedShade2>::exportPPM("export-red2.ppm",image,RedShade2(0,255));
//TestingFunctor
typedef DGtal::functors::Composer< Jet, functors::RedChannel, unsigned char> RedFunctor;
RedFunctor redFunctor( Jet(0,255), functors::RedChannel() ) ;
PGMWriter<Image, RedFunctor>::exportPGM("export-jet-red.pgm",image, redFunctor);
//test Raw export
RawWriter<Image>::exportRaw8("export-hue-twice.raw",image);
//test Image export with libboard
Board2D board;
board.setUnit(LibBoard::Board::UCentimeter);
Display2DFactory::drawImage<HueTwice>(board, image, (unsigned char)0, (unsigned char)255);
board.saveSVG("export-hue-twice.svg");
trace.endBlock();
return true;
}
示例11: testCover4
/**
* Test for the tangential cover of
* 4-connected digital curves
*
*/
bool testCover4()
{
typedef int Coordinate;
typedef PointVector<2,Coordinate> Point;
typedef FreemanChain<Coordinate> ContourType;
typedef ArithmeticalDSS<ContourType::ConstIterator,Coordinate,4> PrimitiveType;
typedef MaximalSegments<PrimitiveType> DecompositionType;
std::string filename = testPath + "samples/france.fc";
std::cout << filename << std::endl;
std::fstream fst;
fst.open (filename.c_str(), std::ios::in);
ContourType theContour(fst);
//Segmentation
trace.beginBlock("Tangential cover of 4-connected digital curves");
PrimitiveType primitive;
DecompositionType theDecomposition(theContour.begin(), theContour.end(), primitive, false);
// Draw the grid
Board2D aBoard;
aBoard.setUnit(Board::UCentimeter);
aBoard << SetMode("PointVector", "Grid")
<< theContour;
//for each segment
unsigned int compteur = 0;
DecompositionType::SegmentIterator i = theDecomposition.begin();
for ( ; i != theDecomposition.end(); ++i) {
compteur++;
PrimitiveType segment(*i);
trace.info() << segment << std::endl; //standard output
aBoard << SetMode( "ArithmeticalDSS", "BoundingBox" )
<< segment; // draw each segment
}
aBoard.saveEPS("segmentationDSS4.eps");
trace.info() << "# segments" << compteur << std::endl;
trace.endBlock();
return true;
}
示例12: testSmartDSS
bool testSmartDSS()
{
typedef PointVector<2,int> Point;
typedef std::vector<Point>::iterator Iterator;
typedef ArithmeticalDSS<Iterator,int,4> DSS4;
std::vector<Point> contour;
contour.push_back(Point(0,0));
contour.push_back(Point(1,0));
contour.push_back(Point(1,1));
contour.push_back(Point(2,1));
contour.push_back(Point(3,1));
contour.push_back(Point(3,2));
contour.push_back(Point(4,2));
contour.push_back(Point(5,2));
contour.push_back(Point(6,2));
contour.push_back(Point(6,3));
contour.push_back(Point(6,4));
// Adding step
trace.beginBlock("extension");
DSS4 s;
s.init( contour.begin() );
while ( (s.end()!=contour.end())
&&(s.extend()) ) {}
HyperRectDomain< SpaceND<2,int> > domain( Point(0,0), Point(10,10) );
Board2D board;
board.setUnit(Board::UCentimeter);
board << SetMode(domain.styleName(), "Grid")
<< domain;
board << SetMode("PointVector", "Grid");
board << SetMode(s.styleName(), "Points")
<< s;
board << SetMode(s.styleName(), "BoundingBox")
<< s;
board.saveEPS("DSS.eps");
trace.endBlock();
return true;
}
示例13: testOneDSS
/**
* Test for the segmentation of
* one DSS into DSSs
*
*/
bool testOneDSS()
{
typedef int Coordinate;
typedef PointVector<2,Coordinate> Point;
typedef ArithmeticalDSS<std::vector<Point>::iterator,Coordinate,8> PrimitiveType;
typedef MaximalSegments<PrimitiveType> DecompositionType;
std::vector<Point> curve;
curve.push_back(Point(0,0));
curve.push_back(Point(1,1));
curve.push_back(Point(2,1));
curve.push_back(Point(3,2));
curve.push_back(Point(4,2));
curve.push_back(Point(5,2));
curve.push_back(Point(6,3));
curve.push_back(Point(7,3));
//Segmentation
trace.beginBlock("Segmentation of one DSS");
PrimitiveType primitive;
DecompositionType theDecomposition(curve.begin(), curve.end(), primitive, false);
// Draw the pixels
Board2D aBoard;
aBoard.setUnit(Board::UCentimeter);
aBoard << SetMode("PointVector", "Both");
for (std::vector<Point>::iterator it = curve.begin(); it != curve.end(); ++it) {
aBoard << (*it);
}
//for each segment
unsigned int compteur = 0;
DecompositionType::SegmentIterator i = theDecomposition.begin();
for ( ; i != theDecomposition.end(); ++i) {
++compteur;
PrimitiveType segment(*i);
trace.info() << segment << std::endl; //standard output
aBoard << SetMode( "ArithmeticalDSS", "BoundingBox" )
<< segment; // draw each segment
}
aBoard.saveSVG("oneDSS.svg");
trace.endBlock();
return (compteur==1);
}
示例14: draw
void draw( const TIterator& itb, const TIterator& ite, const int& size, std::string basename)
{
typedef typename std::iterator_traits<TIterator>::value_type Pair;
typedef typename Pair::first_type Point;
HueShadeColorMap<unsigned char, 2> colorMap(0,3*size);
Board2D b;
b.setUnit ( LibBoard::Board::UCentimeter );
TIterator it = itb;
for ( ; it != ite; ++it)
{
Point p = it->first;
b << CustomStyle( p.className(), new CustomFillColor( colorMap( it->second) ) );
b << p;
}
std::stringstream s;
s << basename << ".eps";
b.saveEPS(s.str().c_str());
}
示例15: 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;
}