Go to the documentation of this file.
21 #ifndef GEOMETRIC_OBJECT_ITERATOR_Rn
22 #define GEOMETRIC_OBJECT_ITERATOR_Rn
24 #include <boost/numeric/ublas/io.hpp>
25 #include <boost/shared_ptr.hpp>
35 using namespace boost::numeric::ublas;
47 void push_back(
const GEOMETRIC_OBJECT& gn) {_GO.push_back(gn);}
50 const GEOMETRIC_OBJECT& operator [](
unsigned int i)
const {
return _GO[i];}
54 {_GO.clear(); _GO = listOfGN.
_GO;}
58 {_GO.clear(); _GO = listOfGN.
_GO;}
61 bool empty()
const {
return _GO.empty();}
64 unsigned int size()
const {
return _GO.size();}
71 for (
typename std::vector< GEOMETRIC_OBJECT >::iterator it=_GO.begin(); it!=_GO.end(); ++it)
76 unsigned int find(
const GEOMETRIC_OBJECT& GO)
const {
78 typename std::vector< GEOMETRIC_OBJECT >::const_iterator it;
79 for (it=_GO.begin(); it!=_GO.end() && *it!=GO; ++it)
81 if (it == _GO.end()) {
82 std::ostringstream stream_;
83 stream_ <<
"listOfGeometricObjects::find() The current object is not stored in array";
84 std::string valString = stream_.str();
85 throw std::out_of_range(valString);
92 for (
typename std::vector< GEOMETRIC_OBJECT >::iterator it=_GO.begin(); it!=_GO.end(); ) {
93 if (setToRemove.find(*it) != setToRemove.end())
104 static bool inferior(
const GEOMETRIC_OBJECT& HS1,
const GEOMETRIC_OBJECT& HS2) {
106 unsigned int n=HS1->dimension();
108 if (HS1->getCoefficient(i) < HS2->getCoefficient(i))
110 else if (HS1->getCoefficient(i) > HS2->getCoefficient(i))
119 static bool superior(
const GEOMETRIC_OBJECT& HS1,
const GEOMETRIC_OBJECT& HS2) {
120 return !inferior(HS1, HS2);
124 typename std::vector< GEOMETRIC_OBJECT >::iterator it = _GO.begin();
125 std::advance(it, step);
126 std::sort( it, _GO.end(), &inferior );
130 typename std::vector< GEOMETRIC_OBJECT >::iterator it = _GO.begin();
131 std::advance(it, step);
132 std::sort( it, _GO.end(), &superior );
137 std::vector< GEOMETRIC_OBJECT >
_GO;
147 {_iterator=0;_step=0;}
156 void setStep(
unsigned int n) {_step=n; advance(n);}
159 unsigned int size()
const {
return _list.size();}
163 if (n > _list.size())
return;
164 _iterator = _iterator+n;
174 bool end()
const {
return (_iterator==_list.size());}
179 if (_iterator < _list.size())
180 return _list[_iterator];
182 return GEOMETRIC_OBJECT();
186 GEOMETRIC_OBJECT el1 = _list[ind1];
187 _list[ind1] = _list[ind2];
209 _iterator(0),_list(l),_alreadySorted(false),_step(0)
222 bool end()
const {
return (_iterator==_list.size());}
226 if (_iterator < _list.size())
227 return _list[_iterator];
229 return GEOMETRIC_OBJECT();
260 if (this->_alreadySorted ==
false) {
261 this->_list.lexminSort(this->_step);
262 this->_alreadySorted =
true;
264 this->_iterator = this->_step;
268 void begin() {this->_iterator = this->_step;}
285 if (this->_alreadySorted ==
false) {
286 this->_list.lexmaxSort(this->_step);
287 this->_alreadySorted =
true;
289 this->_iterator = this->_step;
293 void begin() {this->_iterator = this->_step;}
298 #endif // GEOMETRIC_OBJECT_ITERATOR_Rn
void setStep(unsigned int n)
Step forward in the list geometric elements.
constIteratorOfListOfGeometricObjects(const listOfGeometricObjects< GEOMETRIC_OBJECT > &l)
Constructor.
void setStep(unsigned int n)
Step forward in the list geometric elements.
unsigned int _step
Sort after a step.
void push_back(const GEOMETRIC_OBJECT &gn)
Include a new half space in the list.
Insert the half-spaces in the list in lexicographically increasing order.
static bool superior(const GEOMETRIC_OBJECT &HS1, const GEOMETRIC_OBJECT &HS2)
The opposite of the function inferior(HS1, HS2)
bool end() const
Tell whether we have reached the end of the list.
void setStep(unsigned int n)
Move the iterator at the beginning of the list.
void clear()
Clear the whole list.
void begin()
Move the iterator at the beginning of the list.
listOfGeometricObjects< GEOMETRIC_OBJECT > & _list
The actual list of geometric elements.
void swapElements(unsigned int ind1, unsigned int ind2)
Insert the half-spaces in the list in lexicographically decreasing order.
const GEOMETRIC_OBJECT current()
Return the current geometric element.
This class is designed to contain the list of all generators or half-spaces representing a polytope o...
const GEOMETRIC_OBJECT current()
Return the current geometric element.
int currentIteratorNumber() const
Return the current position in the list.
void lexminSort(unsigned int step)
listOfGeometricObjects()
Constructor.
void next()
Move the iterator one step forward.
lexmaxIteratorOfListOfGeometricObjects(listOfGeometricObjects< GEOMETRIC_OBJECT > &l)
Constructor.
bool end() const
Tell whether we have reached the end of the list.
lexminIteratorOfListOfGeometricObjects(listOfGeometricObjects< GEOMETRIC_OBJECT > &l)
Constructor.
std::vector< GEOMETRIC_OBJECT > _GO
The full list of half spaces or generators for example.
bool empty() const
Check whether the set is empty or not.
void assign(const listOfGeometricObjects< GEOMETRIC_OBJECT > &listOfGN)
Copies all elements from listOfGN to _GN.
void operator=(const listOfGeometricObjects< GEOMETRIC_OBJECT > &listOfGN)
Copies all elements from listOfGN to _GN.
This class is designed to run the list of all geometric objects representing a polytope.
unsigned int _iterator
The current position in the list.
bool _alreadySorted
Not to do the same job twice.
const listOfGeometricObjects< GEOMETRIC_OBJECT > & _list
The actual list of geometric elements.
unsigned int _step
To perform a step.
void begin()
Move the iterator at the beginning of the list.
void advance(unsigned int n)
Step forward in the list geometric elements.
void negate()
Multiply all generators or half-spaces by -1.
unsigned int find(const GEOMETRIC_OBJECT &GO) const
Find a given object in list..
unsigned int size() const
Get the total number of stored elements.
void lexmaxSort(unsigned int step)
void begin()
Move the iterator at the beginning of the list.
Insert the half-spaces in the list in a lexicographically order, whether min or max.
void begin()
Move the iterator at the beginning of the list.
unsigned int size() const
Get the total number of stored elements.
unsigned int _iterator
The current position in the list.
void next()
Move the iterator one step forward.
void removeGeometricObjects(const std::set< GEOMETRIC_OBJECT > &setToRemove)
Get rid of all the objects stored in the set.
void setStep(unsigned int n)
Step forward in the list geometric elements.
static bool inferior(const GEOMETRIC_OBJECT &HS1, const GEOMETRIC_OBJECT &HS2)
Tell whether a given object is declared inferior to another one.
void removeGeometricObject(unsigned int j)
Remove the geometric object number j from the list.
int currentIteratorNumber() const
Return the current position in the list.
lexIteratorOfListOfGeometricObjects(listOfGeometricObjects< GEOMETRIC_OBJECT > &l)
Constructor.