本文整理汇总了C++中GridCurve::getMidPointsRange方法的典型用法代码示例。如果您正苦于以下问题:C++ GridCurve::getMidPointsRange方法的具体用法?C++ GridCurve::getMidPointsRange怎么用?C++ GridCurve::getMidPointsRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridCurve
的用法示例。
在下文中一共展示了GridCurve::getMidPointsRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: vlow
//.........这里部分代码省略.........
Surfaces<KSpace>::track2DBoundaryPoints( points, K, SAdj, dig, bel );
// Create GridCurve
GridCurve<KSpace> gridcurve;
gridcurve.initFromVector( points );
// gridcurve contains the digital boundary to analyze.
Range r = gridcurve.getPointsRange(); //building range
if ( outputFormat == "pts" )
{
for ( ConstIteratorOnPoints it = r.begin(), it_end = r.end();
it != it_end; ++it )
{
Point p = *it;
std::cout << p[ 0 ] << " " << p[ 1 ] << std::endl;
}
}
else if ( outputFormat == "fc" )
{
ConstIteratorOnPoints it = r.begin();
Point p = *it++;
std::cout << p[ 0 ] << " " << p[ 1 ] << " ";
for ( ConstIteratorOnPoints it_end = r.end(); it != it_end; ++it )
{
Point p2 = *it;
Vector v = p2 - p;
if ( v[0 ]== 1 ) std::cout << '0';
if ( v[ 1 ] == 1 ) std::cout << '1';
if ( v[ 0 ] == -1 ) std::cout << '2';
if ( v[ 1 ] == -1 ) std::cout << '3';
p = p2;
}
// close freemanchain if necessary.
Point p2= *(r.begin());
Vector v = p2 - p;
if ( v.norm1() == 1 )
{
if ( v[ 0 ] == 1 ) std::cout << '0';
if ( v[ 1 ] == 1 ) std::cout << '1';
if ( v[ 0 ] == -1 ) std::cout << '2';
if ( v[ 1 ] == -1 ) std::cout << '3';
}
std::cout << std::endl;
}
if (withGeom)
{
// write geometry of the shape
std::stringstream s;
s << outputFileName << ".geom";
std::ofstream outstream(s.str().c_str()); //output stream
if (!outstream.is_open()) return false;
else {
outstream << "# " << outputFileName << std::endl;
outstream << "# Pointel (x,y), Midpoint of the following linel (x',y')" << std::endl;
outstream << "# id x y tangentx tangenty curvaturexy"
<< " x' y' tangentx' tangenty' curvaturex'y'" << std::endl;
std::vector<RealPoint> truePoints, truePoints2;
std::vector<RealPoint> trueTangents, trueTangents2;
std::vector<double> trueCurvatures, trueCurvatures2;
estimateGeometry<Shape, Range, RealPoint, double>
(aShape, h, r, truePoints, trueTangents, trueCurvatures);
estimateGeometry<Shape, MidPointsRange, RealPoint, double>
(aShape, h, gridcurve.getMidPointsRange(), truePoints2, trueTangents2, trueCurvatures2);
unsigned int n = (unsigned int)r.size();
for (unsigned int i = 0; i < n; ++i ) {
outstream << std::setprecision( 15 ) << i
<< " " << truePoints[ i ][ 0 ]
<< " " << truePoints[ i ][ 1 ]
<< " " << trueTangents[ i ][ 0 ]
<< " " << trueTangents[ i ][ 1 ]
<< " " << trueCurvatures[ i ]
<< " " << truePoints2[ i ][ 0 ]
<< " " << truePoints2[ i ][ 1 ]
<< " " << trueTangents2[ i ][ 0 ]
<< " " << trueTangents2[ i ][ 1 ]
<< " " << trueCurvatures2[ i ]
<< std::endl;
}
}
outstream.close();
}
/////////////////
}
catch ( InputException e )
{
std::cerr << "[generateContour]"
<< " error in finding a bel." << std::endl;
return false;
}
return true;
}