last update 20 Sep 2009 |
#include <cvrPointList.h>
Public Types | |
typedef list< point< T > >::iterator | iterator |
typedef list< point< T > >::const_iterator | const_iterator |
typedef list< point< T > >::reference | reference |
typedef list< point< T > >::const_reference | const_reference |
Public Member Functions | |
pointList () | |
pointList (const pointList< T > &other) | |
pointList (const list< point< T > > &other) | |
virtual | ~pointList () |
bool | operator< (const pointList< T > &other) const |
bool | operator> (const pointList< T > &other) const |
pointList< T > & | copy (const pointList< T > &other) |
pointList< T > & | operator= (const pointList< T > &other) |
virtual const std::string & | name () const |
virtual ioObject * | clone () const |
virtual ioObject * | newInstance () const |
bool | equals (const pointList< T > &other) const |
bool | operator== (const pointList< T > &other) const |
const rectangle< T > & | getBoundary () const |
void | setBoundary (const rectangle< T > &r) |
const rectangle< T > | computeBoundary () const |
const rectangle< T > & | updateBoundary () |
virtual bool | write (ioHandler &handler, const bool complete=true) const |
virtual bool | read (ioHandler &handler, const bool complete=true) |
Conversion Methods | |
pointList< T > & | castFrom (const list< point< T > > &other) |
template<class U > | |
pointList< T > & | castFrom (const pointList< U > &other) |
template<class U > | |
pointList< T > & | castFrom (const vector< point< U > > &other) |
template<class U > | |
pointList< T > & | castFrom (const vector< point< U > > &other) const |
template<class U > | |
void | castTo (vector< point< U > > &other) const |
Protected Attributes | |
rectangle< T > | boundary_ |
The cvrpointList class allows the storage of a list of points<T>. The elements of the pointList can be accessed through iterators.
There are several inherited classes which have an additional semantical meaning.
cvr::pointList pts; // a list of points with integer coodinates // create 10 points for (int i=0;i<10;++i) { pts.push_back(point(i,i)); } // iterate on the list of points to add 1 to x and 2 to y: cvr::pointList::iterator it; for (it=pts.begin();it!=pts.end();++pts) { (*pts).add(point(1,2)); }
This class usually is just a wrapper for the cvr::smallObjectList<point<T>>, but it depends on the size you set while compiling the library for the cvr::list to be a std::list or a cvr::smallObjectList.
typedef list< point<T> >::const_iterator cvr::pointList< T >::const_iterator |
Const iterator type (allows read-only operations).
The use of the iterator classes is similar to the iterators of the STL (Standard Template Library). See cvr::pointList::begin() for an example.
typedef list< point<T> >::const_reference cvr::pointList< T >::const_reference |
Const_reference type (allows read-only operations) The use of the reference classes is similar to the references of the STL (Standard Template Library).
typedef list< point<T> >::iterator cvr::pointList< T >::iterator |
Iterator type (allows read and write operations).
The use of the iterator classes is similar to the iterators of the STL (Standard Template Library). See cvr::pointList::begin() for an example
typedef list< point<T> >::reference cvr::pointList< T >::reference |
Reference type (allows read and write operations) The use of the reference classes is similar to the references of the STL (Standard Template Library).
cvr::pointList< T >::pointList | ( | ) |
Default constructor creates an empty pointList;.
cvr::pointList< T >::pointList | ( | const pointList< T > & | other | ) |
cvr::pointList< T >::pointList | ( | const list< point< T > > & | other | ) |
virtual cvr::pointList< T >::~pointList | ( | ) | [virtual] |
Destructor.
pointList<T>& cvr::pointList< T >::castFrom | ( | const vector< point< U > > & | other | ) | const [inline] |
pointList<T>& cvr::pointList< T >::castFrom | ( | const vector< point< U > > & | other | ) | [inline] |
pointList<T>& cvr::pointList< T >::castFrom | ( | const pointList< U > & | other | ) | [inline] |
pointList<T>& cvr::pointList< T >::castFrom | ( | const list< point< T > > & | other | ) |
void cvr::pointList< T >::castTo | ( | vector< point< U > > & | other | ) | const [inline] |
Cast this list of points into a cvr::vector, which can be accessed in a faster way than the list.
virtual ioObject* cvr::pointList< T >::clone | ( | ) | const [virtual] |
Create a clone of this pointList.
Implements cvr::ioObject.
Reimplemented in cvr::areaPoints, cvr::borderPoints, and cvr::ioPoints.
const rectangle<T> cvr::pointList< T >::computeBoundary | ( | ) | const |
Calculate the boundary box.
The boundary is the smallest rectangle that contains all the points in the list. Note that the boundary must be set by the user, or the user must explicitly specify that it must be calculated.
This member computes the boundary, but it does not set the compute one into the internal boundary attribute. See also updateBoundary().
pointList<T>& cvr::pointList< T >::copy | ( | const pointList< T > & | other | ) |
Returns first element as a const_iterator.
Note that you can not change the values of the pointList elements when you use a const_iterator. See also begin() Returns an iterator pointing to the first element of the pointList The use of the interators is similar to the iterators of the Standard Template Library (STL). If you need to iterate on all elements of the pointList, you can use following code:
cvr::pointList<int> myPL; // an empty pointList cvr::pointList<int>::iterator it; // an iterator // Fill pointList with some arbitrary points for (int i=0; i<10; i++) { myPL.push_back(cvr::point(0,i)); } // Swap x and y for all points in list for (it=myPL.begin();it!=myPL.end();it++) { int temp; temp = (*it).x; (*it).x = (*it).y; (*it).y = temp; }
WARNING: This is not the same as default list behaviour which returns an iterator pointing after the last inserted element! Inserts points before position denoted by it. Returns iterator to first element of inserted elements.
WARNING: This is not the same as default list behaviour which returns an iterator pointing after the last inserted element! Inserts the elements from first to last, before position denoted by it. Returns iterator to first element of inserted elements.
WARNING: This is not the same as default list behaviour which returns an iterator pointing after the last inserted element! Transfer all elements in the second list into this one. At the end of the operation, the second list will be empty Inserts element at begin of pointList Removes element at begin of pointList Inserts element at end of pointList Removes element at end of pointList Returns a reference to the first element Returns a const reference to the first element Returns a reference to the last element Returns a const reference to the last element Copy function. copy the contents of other in this object.
other | the source pointList to be copied. |
bool cvr::pointList< T >::equals | ( | const pointList< T > & | other | ) | const |
const rectangle<T>& cvr::pointList< T >::getBoundary | ( | ) | const [inline] |
Returns true if the list is empty.
Returns the last set or calculated boundary.
The boundary is the smallest rectangle that contains all the points in the list. Note that the boundary must be set by the user, or the user must explicitly specify that it must be updated (see cvr::pointList<T>::updateBoundary). It will NOT be updated automatically
virtual const std::string& cvr::pointList< T >::name | ( | ) | const [virtual] |
Returns the name of this type.
Implements cvr::ioObject.
Reimplemented in cvr::areaPoints, cvr::borderPoints, cvr::ioPoints, and cvr::polygonPoints< T >.
virtual ioObject* cvr::pointList< T >::newInstance | ( | ) | const [virtual] |
Create a new instance of pointList.
Implements cvr::ioObject.
Reimplemented in cvr::areaPoints, cvr::borderPoints, and cvr::ioPoints.
bool cvr::pointList< T >::operator< | ( | const pointList< T > & | other | ) | const |
pointList<T>& cvr::pointList< T >::operator= | ( | const pointList< T > & | other | ) |
bool cvr::pointList< T >::operator== | ( | const pointList< T > & | other | ) | const |
bool cvr::pointList< T >::operator> | ( | const pointList< T > & | other | ) | const |
virtual bool cvr::pointList< T >::read | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | [virtual] |
void cvr::pointList< T >::setBoundary | ( | const rectangle< T > & | r | ) | [inline] |
Set the boundary of the points.
The boundary is the smallest rectangle that contains all the points in the list. Note that the boundary must be set by the user using this method, or the user must explicitly specify that it must be updated (see cvr::pointList<T>::updateBoundary). It will NOT be updated automatically with each point you insert or delete.
const rectangle<T>& cvr::pointList< T >::updateBoundary | ( | ) |
Calculate and update the boundary box.
The boundary is the smallest rectangle that contains all the points in the list. Note that the boundary must be set by the user, or the user must explicitly specify that it must be calculated.
This member computes the boundary AND set the internal boundary attribute. See also computeBoundary().
virtual bool cvr::pointList< T >::write | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | const [virtual] |
rectangle<T> cvr::pointList< T >::boundary_ [protected] |