本文整理汇总了C++中GridCurve::getIncidentPointsRange方法的典型用法代码示例。如果您正苦于以下问题:C++ GridCurve::getIncidentPointsRange方法的具体用法?C++ GridCurve::getIncidentPointsRange怎么用?C++ GridCurve::getIncidentPointsRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridCurve
的用法示例。
在下文中一共展示了GridCurve::getIncidentPointsRange方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testRecognition
/**
* Recogition of randomly generated digital circles
*/
bool testRecognition()
{
typedef KhalimskySpaceND<2,int> KSpace;
GridCurve<KSpace> c;
unsigned int nbok = 0;
unsigned int nb = 0;
trace.beginBlock ( "Recognition" );
for (unsigned int i = 0; i < 50; ++i)
{
//generate digital circle
double cx = (rand()%100 ) / 100.0;
double cy = (rand()%100 ) / 100.0;
double radius = (rand()%100 )+100;
c = ballGenerator<KSpace>( cx, cy, radius, ((i%2)==1) );
trace.info() << " #ball #" << i << " c(" << cx << "," << cy << ") r=" << radius << endl;
//range
typedef GridCurve<KSpace>::IncidentPointsRange Range;
Range r = c.getIncidentPointsRange();
//recognition
typedef Range::ConstIterator ConstIterator; //iterator
StabbingCircleComputer<ConstIterator> s;
longestSegment(s,r.begin(),r.end());
//checking if the circle is separating
bool flag = true;
typedef CircleFrom3Points<KSpace::Point> Circle;
typedef functors::Point2ShapePredicate<Circle,false,true>
FirstInCirclePred;
typedef functors::Point2ShapePredicate<Circle,true,true>
SecondInCirclePred;
for (ConstIterator it = s.begin(); ((it != s.end()) && flag) ; ++it)
{
FirstInCirclePred p1( s.getSeparatingCircle() );
SecondInCirclePred p2( s.getSeparatingCircle() );
flag = ( p1(it->first)&&p2(it->second) );
}
//conclusion
nbok += flag ? 1 : 0;
nb++;
}
trace.endBlock();
trace.info() << "(" << nbok << "/" << nb << ") " << endl;
return nbok == nb;
}
示例2: 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;
}
示例3: testDisplayDTFromCircle
//.........这里部分代码省略.........
Set set(map);
GridCurve<KSpace>::InnerPointsRange r = gc.getInnerPointsRange();
FMM::initFromPointsRange(r.begin(), r.end(), map, set, 0.5);
//computation
Predicate bp(0,0,radius);
FMM fmm(map, set, bp);
fmm.compute();
trace.info() << fmm << std::endl;
nbok += (fmm.isValid()?1:0);
trace.info() << nbok << "/" << ++nb << std::endl;
//max
dmaxInt = fmm.getMax();
//display
std::stringstream s;
s << "DTInCircle-" << size;
draw(map.begin(), map.end(), size, s.str());
}
trace.endBlock();
double dmaxExt = 0;
trace.beginBlock ( "Exterior " );
{
typedef NotPointPredicate<BallPredicate<Point> > PointPredicate;
typedef BinaryPointPredicate<PointPredicate,
DomainPredicate<Domain> > Predicate;
typedef FMM<Image, Set, Predicate > FMM;
//init
Image map( d );
Set set(map);
GridCurve<KSpace>::OuterPointsRange r = gc.getOuterPointsRange();
FMM::initFromPointsRange(r.begin(), r.end(), map, set, 0.5);
//computation
BallPredicate<Point> bp(0,0,radius);
PointPredicate nbp( bp );
Predicate pred( nbp, dp, andBF2 );
FMM fmm(map, set, pred);
fmm.compute();
trace.info() << fmm << std::endl;
nbok += (fmm.isValid()?1:0);
trace.info() << nbok << "/" << ++nb << std::endl;
//max
dmaxExt = fmm.getMax();
//display
std::stringstream s;
s << "DTOutCircle-" << size;
draw(map.begin(), map.end(), size, s.str());
}
trace.endBlock();
double dmin = 0; //2*size*size;
double dmax = 0;
trace.beginBlock ( "Both " );
{
typedef DomainPredicate<Domain> Predicate;
typedef FMM<Image, Set, Predicate > FMM;
//init
Image map( d );
Set set(map);
GridCurve<KSpace>::IncidentPointsRange r = gc.getIncidentPointsRange();
FMM::initFromIncidentPointsRange(r.begin(), r.end(), map, set, 0.5);
//computation
FMM fmm(map, set, dp);
fmm.compute();
trace.info() << fmm << std::endl;
nbok += (fmm.isValid()?1:0);
trace.info() << nbok << "/" << ++nb << std::endl;
//min, max
dmin = fmm.getMin();
dmax = fmm.getMax();
//display
std::stringstream s;
s << "DTfromCircle-" << size;
draw(map.begin(), map.end(), size, s.str());
}
trace.endBlock();
trace.beginBlock ( "Comparison " );
{
double epsilon = 0.0001;
nbok += ( ( (std::abs(-dmaxInt - dmin) < epsilon)
&& (std::abs(dmaxExt - dmax) < epsilon) )?1:0);
trace.info() << nbok << "/" << ++nb << std::endl;
}
trace.endBlock();
return (nb == nbok);
}
示例4: 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;
}