当前位置: 首页>>代码示例>>C++>>正文


C++ Adapter::base方法代码示例

本文整理汇总了C++中Adapter::base方法的典型用法代码示例。如果您正苦于以下问题:C++ Adapter::base方法的具体用法?C++ Adapter::base怎么用?C++ Adapter::base使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Adapter的用法示例。


在下文中一共展示了Adapter::base方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testProjection

/**
 * Example of a test. To be completed.
 *
 */
bool testProjection()
{

  unsigned int nb = 0; 
  unsigned int nbok = 0; 
  
  typedef PointVector<3,int> Point3;
  typedef PointVector<2,int> Point2;
  typedef std::vector<Point3>::iterator Iterator3;

  //projector
  typedef DGtal::functors::Projector<SpaceND<2,int> > Projector2; 

  typedef ConstIteratorAdapter<Iterator3,Projector2,Point2> Adapter; 
  BOOST_CONCEPT_ASSERT(( boost::RandomAccessIterator<Iterator3> ));

  BOOST_CONCEPT_ASSERT(( boost_concepts::ReadableIteratorConcept<Adapter> ));
  BOOST_CONCEPT_ASSERT(( boost_concepts::RandomAccessTraversalConcept<Adapter> ));
  
  //range of 3d Points
  std::vector<Point3> r;
  r.push_back(Point3(0,0,0));
  r.push_back(Point3(1,0,0));
  r.push_back(Point3(2,0,0));
  r.push_back(Point3(2,1,0));
  r.push_back(Point3(2,1,1));
  r.push_back(Point3(3,1,1));
  r.push_back(Point3(4,1,1));
  r.push_back(Point3(4,2,1));
  r.push_back(Point3(4,2,2));
  r.push_back(Point3(5,2,2));
  r.push_back(Point3(6,2,2));
  r.push_back(Point3(6,3,2));
  r.push_back(Point3(6,3,3));
  r.push_back(Point3(6,4,3));
  r.push_back(Point3(6,4,4));
  r.push_back(Point3(6,5,4));
  
  //true projection
  std::vector<Point2> rtrue;
  rtrue.push_back(Point2(0,0));
  rtrue.push_back(Point2(1,0));
  rtrue.push_back(Point2(2,0));
  rtrue.push_back(Point2(2,1));
  rtrue.push_back(Point2(2,1));
  rtrue.push_back(Point2(3,1));
  rtrue.push_back(Point2(4,1));
  rtrue.push_back(Point2(4,2));
  rtrue.push_back(Point2(4,2));
  rtrue.push_back(Point2(5,2));
  rtrue.push_back(Point2(6,2));
  rtrue.push_back(Point2(6,3));
  rtrue.push_back(Point2(6,3));
  rtrue.push_back(Point2(6,4));
  rtrue.push_back(Point2(6,4));
  rtrue.push_back(Point2(6,5));
  
  trace.beginBlock ( "Testing block ..." );

  trace.info() << "2d points after projection (XY)" << endl; 

  Projector2 proj; 
    
  Adapter aitBegin(r.begin(),proj);
  Adapter ait = aitBegin;    
  Adapter aitEnd(r.end(),proj); 

  for ( ; ait != aitEnd; ++ait) 
    {
      trace.info() << *(ait.base()); 
      trace.info() << *ait; 
      trace.info() << "(" << ait->operator[](0) << ", " << ait->operator[](1) << ")" << endl;
    }

  //comparison
  if ( std::equal( rtrue.begin(), rtrue.end(), aitBegin ) == true )
    nbok++; 
  nb++; 
  trace.info() << nbok << "/" << nb << std::endl;   

  //basic operators
  trace.info() << "basic operators (operator==)" << endl; 
  if ( ( ait != aitBegin ) && ( ait == aitEnd ) )
    nbok++; 
  nb++; 
  trace.info() << nbok << "/" << nb << std::endl;   
  
  //random access
  ait = (aitBegin + 3);
  ait += 1;
  ait = 1 + ait; 
  trace.info() << "random access operators (operator+)" << endl; 
  trace.info() << *(aitBegin.base()) << *aitBegin << endl; 
  trace.info() << "+5" << std::endl; 
  trace.info() << *(ait.base()) << *ait << endl; 
  if ( ( *ait == Point2(3,1) ) == true )
//.........这里部分代码省略.........
开发者ID:BorisMansencal,项目名称:DGtal,代码行数:101,代码来源:testConstIteratorAdapter.cpp


注:本文中的Adapter::base方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。