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 throw (std::out_of_range) {
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);}
160 if (n > _list.size())
return;
161 _iterator = _iterator+n;
171 bool end()
const {
return (_iterator==_list.size());}
176 if (_iterator < _list.size())
177 return _list[_iterator];
179 return GEOMETRIC_OBJECT();
200 _iterator(0),_list(l),_alreadySorted(false),_step(0)
213 bool end()
const {
return (_iterator==_list.size());}
217 if (_iterator < _list.size())
218 return _list[_iterator];
220 return GEOMETRIC_OBJECT();
251 if (this->_alreadySorted ==
false) {
252 this->_list.lexminSort(this->_step);
253 this->_alreadySorted =
true;
255 this->_iterator = this->_step;
259 void begin() {this->_iterator = this->_step;}
276 if (this->_alreadySorted ==
false) {
277 this->_list.lexmaxSort(this->_step);
278 this->_alreadySorted =
true;
280 this->_iterator = this->_step;
284 void begin() {this->_iterator = this->_step;}
289 #endif // GEOMETRIC_OBJECT_ITERATOR_Rn
void negate()
Multiply all generators or half-spaces by -1.
listOfGeometricObjects< GEOMETRIC_OBJECT > & _list
The actual list of geometric elements.
void removeGeometricObjects(const std::set< GEOMETRIC_OBJECT > &setToRemove)
Get rid of all the objects stored in the set.
void lexminSort(unsigned int step)
void begin()
Move the iterator at the beginning of the list.
unsigned int size() const
Get the total number of genuine facets.
const listOfGeometricObjects< GEOMETRIC_OBJECT > & _list
The actual list of geometric elements.
int currentIteratorNumber() const
Return the current position in the list.
void setStep(unsigned int n)
Step forward in the list geometric elements.
bool empty() const
Check whether the set is empty or not.
const GEOMETRIC_OBJECT current()
Return the current geometric element.
void lexmaxSort(unsigned int step)
void setStep(unsigned int n)
Move the iterator at the beginning of the list.
unsigned int _iterator
The current position in the list.
unsigned int find(const GEOMETRIC_OBJECT &GO) const
Find a given object in list..
void begin()
Move the iterator at the beginning of the list.
lexIteratorOfListOfGeometricObjects(listOfGeometricObjects< GEOMETRIC_OBJECT > &l)
Constructor.
bool end() const
Tell whether we have reached the end of the list.
void begin()
Move the iterator at the beginning of the list.
listOfGeometricObjects()
Constructor.
lexmaxIteratorOfListOfGeometricObjects(listOfGeometricObjects< GEOMETRIC_OBJECT > &l)
Constructor.
Insert the half-spaces in the list in a lexicographically order, whether min or max.
bool end() const
Tell whether we have reached the end of the list.
void removeGeometricObject(unsigned int j)
Remove the geometric object number j from the list.
unsigned int _step
To perform a step.
void setStep(unsigned int n)
Step forward in the list geometric elements.
void assign(const listOfGeometricObjects< GEOMETRIC_OBJECT > &listOfGN)
Copies all elements from listOfGN to _GN.
Insert the half-spaces in the list in lexicographically increasing order.
static bool inferior(const GEOMETRIC_OBJECT &HS1, const GEOMETRIC_OBJECT &HS2)
Tell whether a given object is declared inferior to another one.
unsigned int _step
Sort after a step.
void setStep(unsigned int n)
Step forward in the list geometric elements.
bool _alreadySorted
Not to do the same job twice.
Insert the half-spaces in the list in lexicographically decreasing order.
This class is designed to run the list of all geometric objects representing a polytope.
void advance(unsigned int n)
Step forward in the list geometric elements.
std::vector< GEOMETRIC_OBJECT > _GO
The full list of half spaces or generators for example.
void next()
Move the iterator one step forward.
This class is designed to contain the list of all generators or half-spaces representing a polytope o...
static bool superior(const GEOMETRIC_OBJECT &HS1, const GEOMETRIC_OBJECT &HS2)
The opposite of the function inferior(HS1, HS2)
constIteratorOfListOfGeometricObjects(const listOfGeometricObjects< GEOMETRIC_OBJECT > &l)
Constructor.
const GEOMETRIC_OBJECT current()
Return the current geometric element.
void begin()
Move the iterator at the beginning of the list.
void clear()
Clear the whole list.
void operator=(const listOfGeometricObjects< GEOMETRIC_OBJECT > &listOfGN)
Copies all elements from listOfGN to _GN.
void push_back(const GEOMETRIC_OBJECT &gn)
Include a new half space in the list.
unsigned int _iterator
The current position in the list.
void next()
Move the iterator one step forward.
lexminIteratorOfListOfGeometricObjects(listOfGeometricObjects< GEOMETRIC_OBJECT > &l)
Constructor.
int currentIteratorNumber() const
Return the current position in the list.