本文整理汇总了C++中GridCurve::isClosed方法的典型用法代码示例。如果您正苦于以下问题:C++ GridCurve::isClosed方法的具体用法?C++ GridCurve::isClosed怎么用?C++ GridCurve::isClosed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridCurve
的用法示例。
在下文中一共展示了GridCurve::isClosed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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());
}
示例3: vlow
bool
compareShapeEstimators( const string & name,
Shape & aShape,
double h )
{
// Types
typedef typename Space::Point Point;
typedef typename Space::Vector Vector;
typedef typename Space::RealPoint RealPoint;
typedef typename Space::Integer Integer;
typedef HyperRectDomain<Space> Domain;
typedef KhalimskySpaceND<Space::dimension,Integer> KSpace;
typedef typename KSpace::SCell SCell;
typedef typename GridCurve<KSpace>::PointsRange PointsRange;
typedef typename GridCurve<KSpace>::ArrowsRange ArrowsRange;
typedef typename PointsRange::ConstIterator ConstIteratorOnPoints;
// Digitizer
GaussDigitizer<Space,Shape> dig;
dig.attach( aShape ); // attaches the shape.
Vector vlow(-1,-1); Vector vup(1,1);
dig.init( aShape.getLowerBound()+vlow, aShape.getUpperBound()+vup, h );
Domain domain = dig.getDomain();
// Create cellular space
KSpace K;
bool ok = K.init( dig.getLowerBound(), dig.getUpperBound(), true );
if ( ! ok )
{
std::cerr << "[compareShapeEstimators]"
<< " error in creating KSpace." << std::endl;
return false;
}
try {
// Extracts shape boundary
SurfelAdjacency<KSpace::dimension> SAdj( true );
SCell bel = Surfaces<KSpace>::findABel( K, dig, 10000 );
// Getting the consecutive surfels of the 2D boundary
std::vector<Point> points;
Surfaces<KSpace>::track2DBoundaryPoints( points, K, SAdj, dig, bel );
// Create GridCurve
GridCurve<KSpace> gridcurve;
gridcurve.initFromVector( points );
// Ranges
PointsRange r = gridcurve.getPointsRange();
std::cout << "# range size = " << r.size() << std::endl;
// Estimations
// True values
std::cout << "# True values computation" << std::endl;
typedef ParametricShapeTangentFunctor< Shape > TangentFunctor;
typedef ParametricShapeCurvatureFunctor< Shape > CurvatureFunctor;
TrueLocalEstimatorOnPoints< ConstIteratorOnPoints, Shape, TangentFunctor >
trueTangentEstimator;
TrueLocalEstimatorOnPoints< ConstIteratorOnPoints, Shape, CurvatureFunctor >
trueCurvatureEstimator;
trueTangentEstimator.init( h, r.begin(), r.end(), &aShape, gridcurve.isClosed());
std::vector<RealPoint> trueTangents =
estimateQuantity( trueTangentEstimator, r.begin(), r.end() );
trueCurvatureEstimator.init( h, r.begin(), r.end(), &aShape, gridcurve.isClosed());
std::vector<double> trueCurvatures =
estimateQuantity( trueCurvatureEstimator, r.begin(), r.end() );
// Maximal Segments
std::cout << "# Maximal DSS tangent estimation" << std::endl;
typedef ArithmeticalDSS<ConstIteratorOnPoints,Integer,4> SegmentComputer;
typedef TangentFromDSSFunctor<SegmentComputer> SCFunctor;
SegmentComputer sc;
SCFunctor f;
MostCenteredMaximalSegmentEstimator<SegmentComputer,SCFunctor> MSTangentEstimator(sc, f);
Clock c;
c.startClock();
MSTangentEstimator.init( h, r.begin(), r.end(), gridcurve.isClosed() );
std::vector<typename SCFunctor::Value> MSTangents =
estimateQuantity( MSTangentEstimator, r.begin(), r.end() );
double TMST = c.stopClock();
// Binomial
std::cout << "# Tangent and curvature estimation from binomial convolution" << std::endl;
typedef BinomialConvolver<ConstIteratorOnPoints, double> MyBinomialConvolver;
std::cout << "# mask size = " <<
MyBinomialConvolver::suggestedSize( h, r.begin(), r.end() ) << std::endl;
typedef TangentFromBinomialConvolverFunctor< MyBinomialConvolver, RealPoint >
TangentBCFct;
typedef CurvatureFromBinomialConvolverFunctor< MyBinomialConvolver, double >
CurvatureBCFct;
BinomialConvolverEstimator< MyBinomialConvolver, TangentBCFct> BCTangentEstimator;
BinomialConvolverEstimator< MyBinomialConvolver, CurvatureBCFct> BCCurvatureEstimator;
c.startClock();
BCTangentEstimator.init( h, r.begin(), r.end(), gridcurve.isClosed() );
std::vector<RealPoint> BCTangents =
estimateQuantity( BCTangentEstimator, r.begin(), r.end() );
double TBCTan = c.stopClock();
//.........这里部分代码省略.........
示例4: vlow
bool
lengthEstimators( const std::string & /*name*/,
Shape & aShape,
double h )
{
// Types
typedef typename Space::Point Point;
typedef typename Space::Vector Vector;
typedef typename Space::RealPoint RealPoint;
typedef typename Space::Integer Integer;
typedef HyperRectDomain<Space> Domain;
typedef KhalimskySpaceND<Space::dimension,Integer> KSpace;
typedef typename KSpace::SCell SCell;
typedef typename GridCurve<KSpace>::PointsRange PointsRange;
typedef typename GridCurve<KSpace>::ArrowsRange ArrowsRange;
// Digitizer
GaussDigitizer<Space,Shape> dig;
dig.attach( aShape ); // attaches the shape.
Vector vlow(-1,-1); Vector vup(1,1);
dig.init( aShape.getLowerBound()+vlow, aShape.getUpperBound()+vup, h );
Domain domain = dig.getDomain();
// Create cellular space
KSpace K;
bool ok = K.init( dig.getLowerBound(), dig.getUpperBound(), true );
if ( ! ok )
{
std::cerr << "[lengthEstimators]"
<< " error in creating KSpace." << std::endl;
return false;
}
try {
// Extracts shape boundary
SurfelAdjacency<KSpace::dimension> SAdj( true );
SCell bel = Surfaces<KSpace>::findABel( K, dig, 10000 );
// Getting the consecutive surfels of the 2D boundary
std::vector<Point> points;
Surfaces<KSpace>::track2DBoundaryPoints( points, K, SAdj, dig, bel );
// Create GridCurve
GridCurve<KSpace> gridcurve;
gridcurve.initFromVector( points );
// Ranges
ArrowsRange ra = gridcurve.getArrowsRange();
PointsRange rp = gridcurve.getPointsRange();
// Estimations
typedef typename PointsRange::ConstIterator ConstIteratorOnPoints;
typedef ParametricShapeArcLengthFunctor< Shape > Length;
TrueGlobalEstimatorOnPoints< ConstIteratorOnPoints, Shape, Length > trueLengthEstimator;
trueLengthEstimator.init( h, rp.begin(), rp.end(), &aShape, gridcurve.isClosed());
L1LengthEstimator< typename ArrowsRange::ConstCirculator > l1length;
DSSLengthEstimator< typename PointsRange::ConstCirculator > DSSlength;
MLPLengthEstimator< typename PointsRange::ConstIterator > MLPlength;
FPLengthEstimator< typename PointsRange::ConstIterator > FPlength;
BLUELocalLengthEstimator< typename ArrowsRange::ConstIterator > BLUElength;
RosenProffittLocalLengthEstimator< typename ArrowsRange::ConstIterator > RosenProffittlength;
// Output
double trueValue = trueLengthEstimator.eval();
double l1, blue, rosen,dss,mlp,fp;
double Tl1, Tblue, Trosen,Tdss,Tmlp,Tfp;
Clock c;
//Length evaluation & timing
c.startClock();
l1length.init(h, ra.c(), ra.c());
l1 = l1length.eval();
Tl1 = c.stopClock();
c.startClock();
BLUElength.init(h, ra.begin(), ra.end(), gridcurve.isClosed());
blue = BLUElength.eval();
Tblue = c.stopClock();
c.startClock();
RosenProffittlength.init(h, ra.begin(), ra.end(), gridcurve.isClosed());
rosen = RosenProffittlength.eval();
Trosen = c.stopClock();
c.startClock();
DSSlength.init(h, rp.c(), rp.c());
dss = DSSlength.eval();
Tdss = c.stopClock();
c.startClock();
MLPlength.init(h, rp.begin(), rp.end(), gridcurve.isClosed());
mlp = MLPlength.eval();
Tmlp = c.stopClock();
c.startClock();
FPlength.init(h, rp.begin(), rp.end(), gridcurve.isClosed());
fp = FPlength.eval();
Tfp = c.stopClock();
std::cout << std::setprecision( 15 ) << h << " " << rp.size() << " " << trueValue
<< " " << l1
//.........这里部分代码省略.........