CVR-Lib last update 20 Sep 2009

cvr::pointList< T > Class Template Reference
[Aggregate Data Types]

Template class to store a list of points. More...

#include <cvrPointList.h>

Inheritance diagram for cvr::pointList< T >:

Inheritance graph
[legend]
Collaboration diagram for cvr::pointList< T >:

Collaboration graph
[legend]

List of all members.

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 ioObjectclone () const
virtual ioObjectnewInstance () 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
Sort the points int the pointList in ascending order first of y, and than of x.

Sort the pointList according to the compare function comp, which must return a bool and take two point<T> as arguments. See std::less() for an example.

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_


Detailed Description

template<class T>
class cvr::pointList< T >

Template class to store a list of points.

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.

See also:
borderPoints, areaPoints, ioPoints, polygonPoints
Example:

 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.


Member Typedef Documentation

template<class T>
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.

template<class T>
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).

template<class T>
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

template<class T>
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).


Constructor & Destructor Documentation

template<class T>
cvr::pointList< T >::pointList (  ) 

Default constructor creates an empty pointList;.

template<class T>
cvr::pointList< T >::pointList ( const pointList< T > &  other  ) 

Create this pointList as a copy of another pointList.

Parameters:
other the pointList to be copied.

template<class T>
cvr::pointList< T >::pointList ( const list< point< T > > &  other  ) 

Create this pointList as a copy of a list< point<T> > of point<T>.

Parameters:
other the pointList to be copied.

template<class T>
virtual cvr::pointList< T >::~pointList (  )  [virtual]

Destructor.


Member Function Documentation

template<class T>
template<class U >
pointList<T>& cvr::pointList< T >::castFrom ( const vector< point< U > > &  other  )  const [inline]

Cast the given vector of points into a list, where the first element in the vector will be the first element in the list.

template<class T>
template<class U >
pointList<T>& cvr::pointList< T >::castFrom ( const vector< point< U > > &  other  )  [inline]

Cast the given vector of points into a list, where the first element in the vector will be the first element in the list.

Parameters:
other the vector of points with the points
Returns:
a reference to this instance

template<class T>
template<class U >
pointList<T>& cvr::pointList< T >::castFrom ( const pointList< U > &  other  )  [inline]

Copy the other point-list by casting each of its elements.

Parameters:
other The point list to be casted

template<class T>
pointList<T>& cvr::pointList< T >::castFrom ( const list< point< T > > &  other  ) 

Copy the elements of the other standard list of point<T> in this object.

Parameters:
other the source pointList to be copied.

template<class T>
template<class U >
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.

template<class T>
virtual ioObject* cvr::pointList< T >::clone (  )  const [virtual]

Create a clone of this pointList.

Returns:
a pointer to a copy of this pointList

Implements cvr::ioObject.

Reimplemented in cvr::areaPoints, cvr::borderPoints, and cvr::ioPoints.

template<class T>
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().

Returns:
a the calculated boundary

template<class T>
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;
 }
Returns last element as a const iterator. For an example see begin() Returns last element as an iterator For an example see begin() Deletes all points from list and leaves empty pointList. Erases point, which is denoted by it. Returns iterator to next element. Erases points between first and last. Returns iterator to next element. Inserts point before position denoted by it. returns iterator to inserted element.

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.

Parameters:
other the source pointList to be copied.

template<class T>
bool cvr::pointList< T >::equals ( const pointList< T > &  other  )  const

Compare this pointList with other.

Parameters:
other the other pointList to be compared with
Returns:
true if both pointLists have the same elements and same size

template<class T>
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

template<class T>
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 >.

template<class T>
virtual ioObject* cvr::pointList< T >::newInstance (  )  const [virtual]

Create a new instance of pointList.

Returns:
a pointer to a copy of this pointList

Implements cvr::ioObject.

Reimplemented in cvr::areaPoints, cvr::borderPoints, and cvr::ioPoints.

template<class T>
bool cvr::pointList< T >::operator< ( const pointList< T > &  other  )  const

Returns the number of elements of the pointList.

Compares the size of this list with the size of the other point list and returns true if this list has fewer points than the other one.

template<class T>
pointList<T>& cvr::pointList< T >::operator= ( const pointList< T > &  other  ) 

Assigment operator (alias for copy(other)).

Parameters:
other the pointList to be copied
Returns:
a reference to the actual pointList

template<class T>
bool cvr::pointList< T >::operator== ( const pointList< T > &  other  )  const

Compare this pointList with other.

Parameters:
other the other pointList to be compared with
Returns:
true if both pointLists have the same elements and same size

template<class T>
bool cvr::pointList< T >::operator> ( const pointList< T > &  other  )  const

Compares the size of this list with the size of the other point list and returns true if this list has more points than the other one.

template<class T>
virtual bool cvr::pointList< T >::read ( ioHandler handler,
const bool  complete = true 
) [virtual]

Read the point list from the given ioHandler.

Reimplemented from cvr::ioObject.

template<class T>
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.

template<class T>
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().

Returns:
a reference to the calculated boundary

template<class T>
virtual bool cvr::pointList< T >::write ( ioHandler handler,
const bool  complete = true 
) const [virtual]

Write the point list in the given ioHandler.

Reimplemented from cvr::ioObject.


Member Data Documentation

template<class T>
rectangle<T> cvr::pointList< T >::boundary_ [protected]

This pointList class is implemented with a list< point<T> > instance.

Boundary is the smallest rectangle which includes all the points in the list


The documentation for this class was generated from the following file:

Generated on Sun Sep 20 22:09:08 2009 for CVR-Lib by Doxygen 1.5.8