本文整理汇总了C++中GridCurve::initFromVectorStream方法的典型用法代码示例。如果您正苦于以下问题:C++ GridCurve::initFromVectorStream方法的具体用法?C++ GridCurve::initFromVectorStream怎么用?C++ GridCurve::initFromVectorStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridCurve
的用法示例。
在下文中一共展示了GridCurve::initFromVectorStream方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testIOGridCurve
bool testIOGridCurve(const string& filename)
{
unsigned int d = KSpace::Point::dimension;
GridCurve<KSpace> c; //grid curve
//////////////////////////////////////////
trace.info() << endl;
trace.info() << "Reading GridCurve d=" << d << " ";
ifstream instream; // input stream
instream.open (filename.c_str(), ifstream::in);
c.initFromVectorStream(instream);
trace.info() << "(" << c.size() << ") elts" << std::endl;
trace.info() << c << endl;
///////////////////////////////////////////
std::stringstream s;
s << "gridcurve" << d << ".dat";
trace.info() << "Writing GridCurve d=" << d << " in " << s.str() << endl;
ofstream outstream(s.str().c_str()); //output stream
if (!outstream.is_open()) return false;
else {
c.writeVectorToStream(outstream);
}
outstream.close();
return true;
}
示例2: 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;
}
示例3: testExceptions
/**
* Exceptions
*
*/
bool testExceptions(const string &filename)
{
GridCurve<KhalimskySpaceND<2> > c; //grid curve
trace.info() << endl;
trace.info() << "Trying to read bad file: " << filename << endl;
ifstream instream; // input stream
instream.open (filename.c_str(), ifstream::in);
try {
c.initFromVectorStream(instream);
trace.info() << "no exception catched!?" << endl;
return false;
} catch (DGtal::ConnectivityException& e) {
trace.info() << e.what() << endl;
return true;
} catch (DGtal::InputException& e) {
trace.info() << e.what() << endl;
return true;
} catch (exception& e) {
trace.info() << e.what() << endl;
return true;
}
}
示例4: main
int main( int argc, char** argv )
{
trace.beginBlock ( "Testing class GeometricalDSS" );
trace.info() << "Args:";
for ( int i = 0; i < argc; ++i )
trace.info() << " " << argv[ i ];
trace.info() << endl;
bool res;
{//concept checking
testGeometricalDSSConceptChecking();
}
{//basic operations
std::string filename = testPath + "samples/DSS.dat";
ifstream instream; // input stream
instream.open (filename.c_str(), ifstream::in);
typedef KhalimskySpaceND<2,int> KSpace;
GridCurve<KSpace> c; //grid curve
c.initFromVectorStream(instream);
res = testGeometricalDSS(c)
&& drawingTestGeometricalDSS(c);
}
{//segmentations
std::string filename = testPath + "samples/sinus2D4.dat";
ifstream instream; // input stream
instream.open (filename.c_str(), ifstream::in);
typedef KhalimskySpaceND<2,int> KSpace;
GridCurve<KSpace> c; //grid curve
c.initFromVectorStream(instream);
res = res && testSegmentation(c);
}
trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
trace.endBlock();
return res ? 0 : 1;
}
示例5: testIsOpen
/**
* Open/Closed
*
*/
bool testIsOpen(const string &filename, const bool& aFlag)
{
trace.info() << endl;
trace.info() << "Open/Closed test" << endl;
GridCurve<KhalimskySpaceND<2> > c; //grid curve
ifstream instream; // input stream
instream.open (filename.c_str(), ifstream::in);
c.initFromVectorStream(instream);
trace.info() << c.isOpen() << " == " << aFlag << endl;
return (c.isOpen() == aFlag);
}
示例6: main
int main( int argc, char** argv )
{
trace.beginBlock ( "Testing class StabbingCircleComputer" );
trace.info() << "Args:";
for ( int i = 0; i < argc; ++i )
trace.info() << " " << argv[ i ];
trace.info() << endl;
bool res;
{//concept checking
testStabbingCircleComputerConceptChecking();
}
{//basic operations
typedef KhalimskySpaceND<2,int> KSpace;
GridCurve<KSpace> c, rc;
c = ballGenerator<KSpace>(0,0,6,false);
std::vector<PointVector<2,int> > rv;
rc = ballGenerator<KSpace>(0,0,6,true);
res = testStabbingCircleComputer(c)
&& drawingTestStabbingCircleComputer(c, "CCW")
&& drawingTestStabbingCircleComputer(rc, "CW");
}
{//recognition
res = res && testRecognition();
}
{//segmentations
std::string filename = testPath + "samples/sinus2D4.dat";
ifstream instream; // input stream
instream.open (filename.c_str(), ifstream::in);
typedef KhalimskySpaceND<2,int> KSpace;
GridCurve<KSpace> c; //grid curve
c.initFromVectorStream(instream);
res = res && testSegmentation(c);
}
trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
trace.endBlock();
return res ? 0 : 1;
}
示例7: testTrueLocalEstimator
/**
* Example of a test. To be completed.
*
*/
bool testTrueLocalEstimator(const std::string &filename)
{
trace.info() << "Reading GridCurve " << endl;
ifstream instream; // input stream
instream.open (filename.c_str(), ifstream::in);
typedef KhalimskySpaceND<2> Kspace; //space
GridCurve<Kspace> c;
c.initFromVectorStream(instream); //building grid curve
typedef GridCurve<Kspace >::PointsRange Range;//range
Range r = c.getPointsRange();//building range
typedef Ball2D<Z2i::Space> Shape;
typedef GridCurve<KhalimskySpaceND<2> >::PointsRange Range;
typedef Range::ConstIterator ConstIteratorOnPoints;
typedef ParametricShapeCurvatureFunctor< Shape > Curvature;
typedef ParametricShapeTangentFunctor< Shape > Tangent;
typedef ParametricShapeArcLengthFunctor< Shape > Length;
Shape ball(Z2i::Point(0,0), 30);
TrueLocalEstimatorOnPoints< ConstIteratorOnPoints, Shape, Curvature > curvatureEstimator;
TrueLocalEstimatorOnPoints< ConstIteratorOnPoints, Shape, Tangent > tangentEstimator;
TrueGlobalEstimatorOnPoints< ConstIteratorOnPoints, Shape, Length > lengthEstimator;
curvatureEstimator.init( 1, r.begin(), r.end(), &ball, true);
tangentEstimator.init( 1, r.begin(), r.end(), &ball, true);
ConstIteratorOnPoints it = r.begin();
// ConstIteratorOnPoints it2 = r.begin()+15;
ConstIteratorOnPoints it2 = it;
for ( int compteur = 0; compteur < 15; ++compteur ) ++it2;
lengthEstimator.init( 1, it, it2, &ball, true);
trace.info() << "Current point = "<<*it<<std::endl;
trace.info() << "Current point+15 = "<<*it2<<std::endl;
trace.info() << "Eval curvature (begin, h=1) = "<< curvatureEstimator.eval(it2)<<std::endl;
trace.info() << "Eval tangent (begin, h=1) = "<< tangentEstimator.eval(it2)<<std::endl;
trace.info() << "Eval length ( h=1) = "<< lengthEstimator.eval(it,it2)<<std::endl;
return true;
}
示例8: testFP
/**
* Test
*
*/
bool testFP(string filename)
{
trace.info() << endl;
trace.info() << "Reading GridCurve from " << filename << endl;
ifstream instream; // input stream
instream.open (filename.c_str(), ifstream::in);
//range of points
typedef int Coordinate;
typedef KhalimskySpaceND<2,Coordinate> Kspace; //space
GridCurve<Kspace> c; //building grid curve
c.initFromVectorStream(instream);
typedef GridCurve<Kspace >::PointsRange Range;//range
Range r = c.getPointsRange();//building range
typedef Range::ConstIterator ConstIterator;//constIterator
//faithful polyon
trace.info() << "Building FP (process digital curve as";
trace.info() << ( (c.isClosed())?"closed":"open" ) << ")" << endl;
bool res = true;
if (c.isClosed())
{
typedef FP<Range::ConstCirculator,Coordinate,4> FP;
FP theFP( r.c(), r.c() );
res = theFP.isValid();
}
else
{
typedef FP<Range::ConstIterator,Coordinate,4> FP;
FP theFP( r.begin(), r.end() );
res = theFP.isValid();
}
return res;
}
示例9: testEval
/**
* Applying test on a given data file
*
*/
bool testEval(string filename)
{
trace.info() << endl;
trace.info() << "Reading GridCurve from " << filename << endl;
ifstream instream; // input stream
instream.open (filename.c_str(), ifstream::in);
typedef KhalimskySpaceND<2> Kspace; //space
GridCurve<Kspace> c; //building grid curve
c.initFromVectorStream(instream);
typedef GridCurve<Kspace >::PointsRange Range;//range
Range r = c.getPointsRange();//building range
trace.info() << "Building Estimator (process range as";
trace.info() << ( (c.isClosed())?"closed":"open" ) << ")" << endl;
if (c.isClosed())
return test(r.c(), r.c());
else
return test(r.begin(), r.end());
}
示例10: main
int main()
{
std::string filename = testPath + "samples/DSS.dat";
ifstream instream; // input stream
instream.open (filename.c_str(), ifstream::in);
typedef KhalimskySpaceND<2,int> KSpace;
GridCurve<KSpace> c; //grid curve
c.initFromVectorStream(instream);
trace.beginBlock("Simple preimage test");
typedef StraightLineFrom2Points<GridCurve<KSpace>::Point> StraightLine;
StraightLine aStraightLine; //instance of straight line
typedef Preimage2D<StraightLine> Preimage2D;
GridCurve<KSpace>::IncidentPointsRange r = c.getIncidentPointsRange(); //range
GridCurve<KSpace>::IncidentPointsRange::ConstReverseIterator it (r.rbegin()); //iterators
GridCurve<KSpace>::IncidentPointsRange::ConstReverseIterator itEnd (r.rend());
//preimage computation
Preimage2D thePreimage(it->first, it->second, aStraightLine);
++it;
while ( (it != itEnd) &&
(thePreimage.addBack(it->first, it->second)) )
{
trace.info() << (it - r.rbegin()) << endl << thePreimage << endl;
++it;
}
trace.endBlock();
return 0;
}
示例11: main
int main( int argc, char** argv )
{
trace.beginBlock ( "Testing class GridCurve" );
trace.info() << "Args:";
for ( int i = 0; i < argc; ++i )
trace.info() << " " << argv[ i ];
trace.info() << endl;
std::string sinus2D4 = testPath + "samples/sinus2D4.dat";
std::string polyg2D = testPath + "samples/polyg2D.dat";
std::string sinus3D = testPath + "samples/sinus3D.dat";
std::string emptyFile = testPath + "samples/emptyFile.dat";
std::string square = testPath + "samples/smallSquare.dat";
typedef KhalimskySpaceND<2> K2;
typedef KhalimskySpaceND<3> K3;
///////// general tests
bool res = testIOGridCurve<K2>(sinus2D4)
&& testIOGridCurve<K3>(sinus3D)
&& testExceptions(sinus3D)
&& testExceptions(polyg2D)
&& testExceptions(emptyFile)
&& testDrawGridCurve(sinus2D4)
&& testIsOpen(sinus2D4,true)
&& testIsOpen(square,false);
/////////// ranges test
typedef GridCurve<K2> GridCurve;
testRangeConceptChecking<GridCurve::SCellsRange>();
testRangeConceptChecking<GridCurve::SCellsRange>();
testRangeConceptChecking<GridCurve::PointsRange>();
testRangeConceptChecking<GridCurve::MidPointsRange>();
testRangeConceptChecking<GridCurve::ArrowsRange>();
testRangeConceptChecking<GridCurve::InnerPointsRange>();
testRangeConceptChecking<GridCurve::OuterPointsRange>();
testRangeConceptChecking<GridCurve::IncidentPointsRange>();
//reading grid curve
GridCurve c;
fstream inputStream;
inputStream.open (square.c_str(), ios::in);
c.initFromVectorStream(inputStream);
inputStream.close();
res = res
&& testRange<GridCurve::SCellsRange>(c.getSCellsRange())
&& testRange<GridCurve::PointsRange>(c.getPointsRange())
&& testRange<GridCurve::MidPointsRange>(c.getMidPointsRange())
&& testPairsRange<GridCurve::ArrowsRange>(c.getArrowsRange())
&& testRange<GridCurve::InnerPointsRange>(c.getInnerPointsRange())
&& testRange<GridCurve::OuterPointsRange>(c.getOuterPointsRange())
&& testPairsRange<GridCurve::IncidentPointsRange>(c.getIncidentPointsRange())
&& testRange<GridCurve::CodesRange>(c.getCodesRange())
;
res = res
&& testDisplayRange<GridCurve::SCellsRange>(c.getSCellsRange())
&& testDisplayRange<GridCurve::PointsRange>(c.getPointsRange())
&& testDisplayRange<GridCurve::MidPointsRange>(c.getMidPointsRange())
&& testDisplayRange<GridCurve::ArrowsRange>(c.getArrowsRange())
&& testDisplayRange<GridCurve::InnerPointsRange>(c.getInnerPointsRange())
&& testDisplayRange<GridCurve::OuterPointsRange>(c.getOuterPointsRange())
&& testDisplayRange<GridCurve::IncidentPointsRange>(c.getIncidentPointsRange())
&& testDisplayRange<GridCurve::CodesRange>(c.getCodesRange())
;
res = res
&& testDrawRange<GridCurve::SCellsRange>(c.getSCellsRange(),"1cells","Grid")
&& testDrawRange<GridCurve::PointsRange>(c.getPointsRange(),"Points","Paving")
&& testDrawRange<GridCurve::MidPointsRange>(c.getMidPointsRange(),"MidPoints","Paving")
&& testDrawRange<GridCurve::ArrowsRange>(c.getArrowsRange(),"Arrows","Paving")
&& testDrawRange<GridCurve::InnerPointsRange>(c.getInnerPointsRange(),"InnerPoints","Grid")
&& testDrawRange<GridCurve::OuterPointsRange>(c.getOuterPointsRange(),"OuterPoints","Grid")
&& testDrawRange<GridCurve::IncidentPointsRange>(c.getIncidentPointsRange(),"IncidentPoints","Grid")
;
//////////////////////
trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
trace.endBlock();
return res ? 0 : 1;
}