DGtal  0.9.2
ShapeList.ih
1 /*
2  * @file
3  */
4 
5 ShapeList::ShapeList( int depthValue )
6  : Shape( DGtal::Color::None, DGtal::Color::None, 1.0, SolidStyle, ButtCap, MiterJoin, depthValue ),
7  _nextDepth( std::numeric_limits<int>::max() - 1 )
8 { }
9 
10 template<typename T>
11 T &
12 ShapeList::last( const unsigned int position )
13 {
14  if ( position < _shapes.size() ) {
15  std::vector<Shape*>::reverse_iterator it = _shapes.rbegin() + position;
16  return dynamic_cast<T&>( *(*it) );
17  } else {
18  error << "Trying to access an element that does not exist ("
19  << position << "/" << _shapes.size() << ").\n";
20  throw -1;
21  }
22 }