politopix  5.0.0
PolyhedralCone_Rn.h
Go to the documentation of this file.
1 // politopix allows to make computations on polytopes such as finding vertices, intersecting, Minkowski sums, ...
2 // Copyright (C) 2011-2022 : Delos Vincent
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
19 // I2M (UMR CNRS 5295 / University of Bordeaux)
20 
21 #ifndef POLYHEDRALCONE_Rn
22 #define POLYHEDRALCONE_Rn
23 
24 #include <boost/numeric/ublas/io.hpp>
25 #include <boost/shared_ptr.hpp>
26 #include <stdexcept>
27 #include <exception>
28 #include <iterator>
29 #include <numeric>
30 #include <vector>
31 #include <set>
32 #include "polito_Export.h"
34 #include "Neighbours_Rn.h"
35 #include "Generator_Rn.h"
36 #include "HalfSpace_Rn.h"
37 #include "Rn.h"
38 
39 #undef min
40 #undef max
41 using namespace boost::numeric::ublas;
42 
43 
48  friend class lexIteratorOfListOfHalfSpaces;
49  friend class constIteratorOfListOfHalfSpaces;
50 
51  public:
54 
57  _listOfHalfSpaces = A._listOfHalfSpaces;
58  _listOfGenerators = A._listOfGenerators;
59  }
60 
62  virtual ~PolyhedralCone_Rn() {}
63 
65  virtual unsigned int dimension() const {
66  if (numberOfHalfSpaces()==0 && numberOfGenerators()==0)
67  return Rn::getDimension();
68  else if (numberOfGenerators()==0) {
70  const boost::shared_ptr<HalfSpace_Rn>& currentHalfSpace = iteHS.current();
71  return currentHalfSpace->dimension();
72  }
73  else {
75  const boost::shared_ptr<Generator_Rn>& currentGenerator = iteGN.current();
76  return currentGenerator->dimension();
77  }
78  }
79 
81  virtual bool isBounded() const {return false;}
82 
84  virtual unsigned int neigbourhoodCondition() const {return (dimension()-2);}
85 
87  virtual unsigned int numberOfGeneratorsPerFacet() const {return (dimension()-1);}
88 
90  void reset() {_listOfHalfSpaces.clear(); _listOfGenerators.clear();}
91 
92  // HALF-SPACES
93 
95  unsigned int numberOfHalfSpaces() const {return _listOfHalfSpaces.size();}
96 
98  boost::shared_ptr<HalfSpace_Rn> addHalfSpace(boost::shared_ptr<HalfSpace_Rn> hs, bool check=false);
99 
101  void removeHalfSpaceFromListAndGenerators(const boost::shared_ptr<HalfSpace_Rn>& hs);
102 
104  void removeHalfSpace(unsigned int j) {_listOfHalfSpaces.removeGeometricObject(j);}
105 
107  void removeHalfSpaces(const std::set< boost::shared_ptr<HalfSpace_Rn> >& setOfRedundantHS) {
108  _listOfHalfSpaces.removeGeometricObjects( setOfRedundantHS );
109  }
110 
112  unsigned int getHalfSpaceNumber(const boost::shared_ptr<HalfSpace_Rn>& F) const {
113  unsigned int index;
114  try {
115  index = _listOfHalfSpaces.find(F);
116  }
117  catch(std::out_of_range& excep) {
118  F->dump(std::cerr);
119  std::cerr << std::endl;
120  std::string ex(excep.what());
121  ex += std::string(" : Catch in PolyhedralCone_Rn::getHalfSpaceNumber()");
122  throw std::out_of_range(ex);
123  }
124  return index;
125  }
126 
128  const boost::shared_ptr<HalfSpace_Rn>& getHalfSpace(unsigned int i) const;
129 
132 
135 
137  void setListOfHalfSpaces(const listOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> >& hsList) {_listOfHalfSpaces = hsList;}
138 
139 
140  // CONVEX HULL
141 
143  unsigned int numberOfGenerators() const {return _listOfGenerators.size();}
144 
146  void addGenerator(boost::shared_ptr<Generator_Rn> vx) {_listOfGenerators.push_back(vx);}
147 
149  const boost::shared_ptr<Generator_Rn>& getGenerator(unsigned int i) const;
150 
152  unsigned int getGeneratorNumber(boost::shared_ptr<Generator_Rn> G) const;
153 
156 
157  unsigned int getListOfGeneratorsSD(std::vector< boost::shared_ptr<Generator_Rn_SD> >& currentListOfGeneratorsSD) const {
158  unsigned int generatorNumber=0;
160  {
161  for (iteGN.begin(); iteGN.end()!=true; iteGN.next()) {
162  // By default, Generator_Rn_SD are created with the status UNCHANGED.
163  boost::shared_ptr<Generator_Rn_SD> currentGeneratorSD(new Generator_Rn_SD(*iteGN.current(), generatorNumber, Generator_Rn_SD::UNCHANGED));
164  {
165  for (unsigned int ii=0; ii<iteGN.current()->numberOfFacets(); ii++) {
166  unsigned int fctNumber = getHalfSpaceNumber( iteGN.current()->getFacet(ii) );
167  currentGeneratorSD->setFacet(fctNumber);
168  }
169  }
170  currentGeneratorSD->orderFacets();
171  currentListOfGeneratorsSD.push_back(currentGeneratorSD);
172  ++generatorNumber;
173  }
174  }
175  return generatorNumber;
176  }
177 
179  void setListOfGeneratorsSD(const std::vector< boost::shared_ptr<Generator_Rn_SD> >& gnList) {
181  std::vector< boost::shared_ptr<Generator_Rn_SD> >::const_iterator iteGN;
182  {
183  for (iteGN=gnList.begin(); iteGN!=gnList.end(); ++iteGN) {
184  if ((*iteGN)->getStatus() == Generator_Rn_SD::CREATED || (*iteGN)->getStatus() == Generator_Rn_SD::CREATED_AND_MODIFIED) {
185  boost::shared_ptr<Generator_Rn> currentGenerator = (*iteGN)->makeGenerator_Rn();
186  {
187  for (unsigned int ii=0; ii<(*iteGN)->numberOfFacets(); ii++)
188  currentGenerator->setFacet( _listOfHalfSpaces[(*iteGN)->getFacet(ii)] );
189  }
190  listOfGenerators.push_back( currentGenerator );
191  }
192  else if ((*iteGN)->getStatus() == Generator_Rn_SD::MODIFIED) {
193  // Substitute all old half-spaces with the new ones.
194  unsigned int nbGN = (*iteGN)->getGeneratorNumber();
195  boost::shared_ptr<Generator_Rn> currentGenerator = _listOfGenerators[nbGN];
196  currentGenerator->clearFacets();
197  {
198  for (unsigned int ii=0; ii<(*iteGN)->numberOfFacets(); ii++)
199  currentGenerator->setFacet( _listOfHalfSpaces[(*iteGN)->getFacet(ii)] );
200  }
201  listOfGenerators.push_back(_listOfGenerators[nbGN]);
202  }
203  else if ((*iteGN)->getStatus() == Generator_Rn_SD::UNCHANGED) {
204  // Substitute all old half-spaces with the new ones.
205  unsigned int nbGN = (*iteGN)->getGeneratorNumber();
206  listOfGenerators.push_back(_listOfGenerators[nbGN]);
207  }
208  // If it was deleted we obviously don't need it.
209  }
210  }
211  _listOfGenerators.clear();
212  _listOfGenerators = listOfGenerators;
213  }
214 
215  void relocateGenerators();
216 
218  void setListOfGenerators(const listOfGeometricObjects< boost::shared_ptr<Generator_Rn> >& gnList) {_listOfGenerators = gnList;}
219 
220 
221  // CHECK POLYHEDRON
222 
229  bool checkNeighbours(const boost::shared_ptr<Generator_Rn>& V1,
230  const boost::shared_ptr<Generator_Rn>& V2,
231  std::vector< boost::shared_ptr<HalfSpace_Rn> >& commonFacets,
232  const std::set< boost::shared_ptr<HalfSpace_Rn> >& listOfRedundantHS) const {
233  unsigned int sameHyperplane=0;
234  for (unsigned int i=0; i<V1->numberOfFacets(); i++) {
235  for (unsigned int j=0; j<V2->numberOfFacets(); j++) {
236  if (V1->getRawFacet(i)==V2->getRawFacet(j) && listOfRedundantHS.find(V1->getFacet(i))==listOfRedundantHS.end()) {
237  // Check the facet is not declared redundant !
238  sameHyperplane++;
239  commonFacets.push_back(V1->getFacet(i));
240  }
241  }
242  }
243  // For polyhedral cones it is Rn::getDimension()-1, for polytopes it is Rn::getDimension()-2.
244  if (sameHyperplane >= neigbourhoodCondition())
245  return true;
246  return false;
247  }
248 
252  bool isIncluded(const boost::shared_ptr<PolyhedralCone_Rn>& B) const;
253 
260  bool checkNeighbours(const boost::shared_ptr<Generator_Rn>& V1,
261  const boost::shared_ptr<Generator_Rn>& V2,
262  std::vector< boost::shared_ptr<HalfSpace_Rn> >& commonFacets,
263  unsigned int topologicalCode=1) const {
264  unsigned int sameHyperplane=0;
265  for (unsigned int i=0; i<V1->numberOfFacets(); i++) {
266  for (unsigned int j=0; j<V2->numberOfFacets(); j++) {
267  if (V1->getRawFacet(i) == V2->getRawFacet(j)) {
268  // Check the facet is not declared redundant !
269  sameHyperplane++;
270  commonFacets.push_back(V1->getFacet(i));
271  }
272  }
273  }
274  // For polyhedral cones neigbourhoodCondition() is Rn::getDimension()-1, for polytopes it is Rn::getDimension()-2.
275  if (sameHyperplane >= neigbourhoodCondition()-topologicalCode+1) {
276  return true;
277  }
278  return false;
279  }
280 
288  const boost::shared_ptr<Generator_Rn>& V1,
289  const boost::shared_ptr<Generator_Rn>& V2,
290  std::vector< HalfSpace_Rn* >& commonFacets,
291  unsigned int topologicalCode=1) const {
292  unsigned int sameHyperplane=0;
293  for (unsigned int i=0; i<V1->numberOfFacets(); ++i) {
294  for (unsigned int j=0; j<V2->numberOfFacets(); ++j) {
295  if (V1->getRawFacet(i)==V2->getRawFacet(j)) {
296  // Check the facet is not declared redundant !
297  sameHyperplane++;
298  commonFacets.push_back(V1->getRawFacet(i));
299  }
300  }
301  }
302  // For polyhedral cones neigbourhoodCondition() is Rn::getDimension()-1, for polytopes it is Rn::getDimension()-2.
303  if (sameHyperplane >= neigbourhoodCondition()-topologicalCode+1) {
304  return true;
305  }
306  return false;
307  }
308 
314  const boost::shared_ptr<Generator_Rn_SD>& genIn,
315  const boost::shared_ptr<Generator_Rn_SD>& genOut,
316  std::vector< unsigned int >& commonFacets) const {
317  // Compute the intersection on sorted lists of facets.
318  std::set_intersection(genIn->facetsBegin(), genIn->facetsEnd(), genOut->facetsBegin(), genOut->facetsEnd(),
319  std::inserter(commonFacets, commonFacets.end()));
320  // For polyhedral cones neigbourhoodCondition() is Rn::getDimension()-1, for polytopes it is Rn::getDimension()-2.
321  if (commonFacets.size() >= neigbourhoodCondition())
322  return true;
323 
324  return false;
325  }
326 
327 
336  const boost::shared_ptr<Generator_Rn>& V1,
337  const boost::shared_ptr<Generator_Rn>& V2,
338  std::vector< HalfSpace_Rn* >& commonFacets,
339  const std::set< boost::shared_ptr<HalfSpace_Rn> >& listOfRedundantHS,
340  unsigned int topologicalCode=1) const {
341  unsigned int sameHyperplane=0;
342  for (unsigned int i=0; i<V1->numberOfFacets(); ++i) {
343  for (unsigned int j=0; j<V2->numberOfFacets(); ++j) {
344  if (V1->getRawFacet(i)==V2->getRawFacet(j) &&
345  listOfRedundantHS.find(V1->getFacet(i))==listOfRedundantHS.end()) {
346  // Check the facet is not declared redundant !
347  sameHyperplane++;
348  commonFacets.push_back(V1->getRawFacet(i));
349  }
350  }
351  }
352  // For polyhedral cones neigbourhoodCondition() is Rn::getDimension()-1, for polytopes it is Rn::getDimension()-2.
353  if (sameHyperplane >= neigbourhoodCondition()-topologicalCode+1) {
354  return true;
355  }
356  return false;
357  }
358 
362  void fillNeighbourMatrix(std::vector< std::vector<unsigned int> >& neighboursA, unsigned int topologicalCode=1) const {
363  if (neighboursA.size() != numberOfGenerators()) {
364  std::string errorMessage("PolyhedralCone_Rn::fillNeighbourMatrix wrong matrix size");
365  throw std::out_of_range(errorMessage);
366  }
368  //Neighbours_Rn newGeneratorsTool;
369  {for (iteGN_A1.begin(); iteGN_A1.end()!=true; iteGN_A1.next()) {
370  const boost::shared_ptr<Generator_Rn>& v1_A = iteGN_A1.current();
372  {for (iteGN_A2.begin(); iteGN_A2.end()!=true; iteGN_A2.next()) {
373  const boost::shared_ptr<Generator_Rn>& v2_A = iteGN_A2.current();
374  std::vector< HalfSpace_Rn* > commonFacets;
375  if (v1_A != v2_A) {
376  //neighboursA(iteGN_A1.currentIteratorNumber(), iteGN_A2.currentIteratorNumber()) =
377  if (checkNeighbours(v1_A, v2_A, commonFacets, topologicalCode) == true) {
378  neighboursA[iteGN_A1.currentIteratorNumber()].push_back(iteGN_A2.currentIteratorNumber());
379  //newGeneratorsTool.addGenerator(
380  // commonFacets,
381  // v1_A,
382  // v2_A,
383  // iteGN_A1.currentIteratorNumber(),
384  // iteGN_A2.currentIteratorNumber());
385  }
386  }
387  else {
388  //std::cout << "v1=" << iteGN_A1.currentIteratorNumber() << ", v2=" << iteGN_A2.currentIteratorNumber() << std::endl;
389  neighboursA[iteGN_A1.currentIteratorNumber()].push_back(iteGN_A2.currentIteratorNumber());
390  }
391  }}
392  }}
393  //newGeneratorsTool.dump(std::cout);
394  //for (newGeneratorsTool.begin(); newGeneratorsTool.end()!=true; newGeneratorsTool.next()) {
395  // neighboursA(newGeneratorsTool.currentGenInNumber(), newGeneratorsTool.currentGenOutNumber()) = 1;
396  // neighboursA(newGeneratorsTool.currentGenOutNumber(), newGeneratorsTool.currentGenInNumber()) = 1;
397  //}
398  }
399 
402  void fillIrredundantNeighbourMatrix(std::vector< std::vector<unsigned int> >& neighboursA) const {
403  if (neighboursA.size() != numberOfGenerators()) {
404  std::string errorMessage("PolyhedralCone_Rn::fillIrredundantNeighbourMatrix wrong matrix size");
405  throw std::out_of_range(errorMessage);
406  }
408  std::vector< boost::shared_ptr<Generator_Rn_SD> > listOfGenSD;
409  // Generator_Rn => Generator_Rn_SD
410  // From the current generators make a list of generators dedicated to work in the data structure algorithm.
411  // Make sure the list of half-space numbers is sorted as we want to use algorithms further.
412  getListOfGeneratorsSD(listOfGenSD);
413  Neighbours_Rn newGeneratorsTool;
414  unsigned int count_OUT=0;
415  std::vector< boost::shared_ptr<Generator_Rn_SD> >::const_iterator iteGN_OUT;
416  {for (iteGN_OUT=listOfGenSD.begin(); iteGN_OUT!=listOfGenSD.end(); ++iteGN_OUT, ++count_OUT) {
417  unsigned int count_IN=0;
418  std::vector< boost::shared_ptr<Generator_Rn_SD> >::const_iterator iteGN_IN;
419  {for (iteGN_IN=listOfGenSD.begin(); iteGN_IN!=listOfGenSD.end(); ++iteGN_IN, ++count_IN) {
420  std::vector< unsigned int > commonFacets;
421  if (count_IN!=count_OUT && checkNeighbours(*iteGN_IN, *iteGN_OUT, commonFacets) == true)
422  newGeneratorsTool.addGenerator(commonFacets,
423  count_IN,
424  count_OUT,
426  }
427  }
428  }
429  }
430  for (newGeneratorsTool.begin(); newGeneratorsTool.end()!=true; newGeneratorsTool.next()) {
431  neighboursA[newGeneratorsTool.currentGenInNumber()].push_back(newGeneratorsTool.currentGenOutNumber());
432  neighboursA[newGeneratorsTool.currentGenOutNumber()].push_back(newGeneratorsTool.currentGenInNumber());
433  }
434 
435  }
436 
443  virtual bool checkTopologyAndGeometry(bool check_all=false) const {
444  std::cerr.precision(15);
445  std::cout.precision(15);
446  std::cout << "# Dimension NumberOfHalfspaces NumberOfGenerators" << std::endl;
447  std::cout << dimension() << " " << numberOfHalfSpaces() << " " << numberOfGenerators() << std::endl;
448 
449  // Check that all generators have at least (n-1) facets in the case of a polyhedral cone and are inside the H-representation.
450  bool checkGeneratorsOK = checkGenerators(_listOfGenerators, _listOfHalfSpaces, check_all);
451 
452  // Check that all facets have at least (n-1) generators in the case of a polyhedral cone.
453  bool checkFacetsOK = checkFacets();
454 
455  return (checkGeneratorsOK==true && checkFacetsOK==true);
456  }
457 
460  HalfSpace_Rn::State checkPoint(const Point_Rn& thisPoint) const;
461 
462  HalfSpace_Rn::State checkGenerator(const boost::shared_ptr<Generator_Rn>& thisGen) const {
463  unsigned int dim = thisGen->dimension();
464  Point_Rn thisPoint(dim);
465  {for (unsigned int i=0; i<dim; ++i) {
466  thisPoint.setCoordinate( i, thisGen->getCoordinate(i) );
467  }}
468  return checkPoint(thisPoint);
469  }
470 
473  HalfSpace_Rn::State checkPoint(
474  const boost::shared_ptr<Generator_Rn>& point,
475  const boost::shared_ptr<HalfSpace_Rn>& halfSpace,
476  double halfSpaceNorm) const;
477 
482  bool checkDuplicateGenerators(unsigned int& a, unsigned int& b);
483 
485  void checkGenerator(unsigned int vtxNumber, std::ostream &this_ostream) const {
486  if (vtxNumber >= _listOfGenerators.size())
487  throw std::out_of_range("PolyhedralCone_Rn::checkGenerator(unsigned int fctNumber, std::ostream &this_ostream) inadequate generator number!");
488  this_ostream.precision(15);
489  double TOL=Rn::getTolerance();
490  this_ostream << "Check generator " << vtxNumber << std::endl;
491  _listOfGenerators[vtxNumber]->dump(std::cout);
492  this_ostream << std::endl;
493  {for (unsigned int i=0; i< _listOfGenerators[vtxNumber]->numberOfFacets(); ++i) {
494  this_ostream << getHalfSpaceNumber( _listOfGenerators[vtxNumber]->getFacet(i) ) << " ";
495  }}
496  this_ostream << std::endl;
497  this_ostream << std::endl;
498  {for (unsigned int i=0; i< _listOfGenerators[vtxNumber]->numberOfFacets(); ++i) {
499  this_ostream << "H" << getHalfSpaceNumber( _listOfGenerators[vtxNumber]->getFacet(i) ) << std::endl;
500  _listOfGenerators[vtxNumber]->getFacet(i)->dump(this_ostream);
501  this_ostream << std::endl;
502  }}
503  this_ostream << std::endl;
504  this_ostream << "Check generator " << vtxNumber << std::endl;
506  {for (iteHS_B.begin(); iteHS_B.end()!=true; iteHS_B.next()) {
507  double halfSpaceNorm = std::inner_product(iteHS_B.current()->begin(), iteHS_B.current()->end(), iteHS_B.current()->begin(), 0.);
508  halfSpaceNorm = sqrt(halfSpaceNorm);
509  double scalarProduct = std::inner_product(_listOfGenerators[vtxNumber]->begin(), _listOfGenerators[vtxNumber]->end(), iteHS_B.current()->begin(), 0.);
510  double distanceToHyperplane = (scalarProduct+iteHS_B.current()->getConstant()) / halfSpaceNorm;
511  this_ostream << "H" << iteHS_B.currentIteratorNumber() << "\t";
512  this_ostream << ": " << distanceToHyperplane;
513  if (distanceToHyperplane<TOL && distanceToHyperplane>-TOL)
514  this_ostream << " (*)";
515  this_ostream << std::endl;
516  }}
517  }
518 
524  const listOfGeometricObjects< boost::shared_ptr<Generator_Rn> >& listGenA,
525  const listOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> >& listHSB, bool check_all=false) const {
526  std::cout << "Check generators..... ";
527  double TOL = Rn::getTolerance();
528  std::vector< std::vector<int> > listOfFacetsPerGenerator(listGenA.size());
530  {for (iteHS_B.begin(); iteHS_B.end()!=true; iteHS_B.next()) {
531  double halfSpaceNorm =
532  std::inner_product(iteHS_B.current()->begin(), iteHS_B.current()->end(), iteHS_B.current()->begin(), 0.);
533  halfSpaceNorm = sqrt(halfSpaceNorm);
535  {for (iteGN_A_.begin(); iteGN_A_.end()!=true; iteGN_A_.next()) {
536  double scalarProduct = std::inner_product(iteGN_A_.current()->begin(), iteGN_A_.current()->end(), iteHS_B.current()->begin(), 0.);
537  double distanceToHyperplane = (scalarProduct+iteHS_B.current()->getConstant()) / halfSpaceNorm;
538  if (distanceToHyperplane > TOL) {
539  // HalfSpace_Rn::hs_IN: nothing to do.
540  }
541  else if (distanceToHyperplane < -TOL) {
542  // HalfSpace_Rn::hs_OUT
543  std::cerr << "\t### G" << iteGN_A_.currentIteratorNumber() << " is out for half-space ";
544  std::cerr << iteHS_B.currentIteratorNumber() << std::endl;
545  std::cerr << "G" << iteGN_A_.currentIteratorNumber() << " = ";
546  iteGN_A_.current()->dump(std::cerr);
547  std::cerr << " (d=" << distanceToHyperplane << ")" << std::endl;
548  }
549  else {
550  // HalfSpace_Rn::hs_ON
551  listOfFacetsPerGenerator[ iteGN_A_.currentIteratorNumber() ].push_back( iteHS_B.currentIteratorNumber() );
552  }
553  }}
554  }}
555  bool checkGeneratorsOK=true;
557  {for (iteGN_A.begin(); iteGN_A.end()!=true; iteGN_A.next()) {
558  if (listOfFacetsPerGenerator[ iteGN_A.currentIteratorNumber() ].empty()==true ||
559  listOfFacetsPerGenerator[ iteGN_A.currentIteratorNumber() ].size() < numberOfGeneratorsPerFacet())
560  checkGeneratorsOK = false;
561  if (check_all &&
562  listOfFacetsPerGenerator[ iteGN_A.currentIteratorNumber() ].size() != iteGN_A.current()->numberOfFacets())
563  checkGeneratorsOK = false;
564  }}
565  if (checkGeneratorsOK == true)
566  std::cout << "OK" << std::endl;
567  else {
568  std::cout << "KO" << std::endl;
569  {for (iteGN_A.begin(); iteGN_A.end()!=true; iteGN_A.next()) {
570  if (listOfFacetsPerGenerator[ iteGN_A.currentIteratorNumber() ].empty()==true ||
571  listOfFacetsPerGenerator[ iteGN_A.currentIteratorNumber() ].size() < numberOfGeneratorsPerFacet())
572  std::cerr << "\t### G" << iteGN_A.currentIteratorNumber() << " has only "
573  << listOfFacetsPerGenerator[ iteGN_A.currentIteratorNumber() ].size() << " facets." << std::endl;
574  if (listOfFacetsPerGenerator[ iteGN_A.currentIteratorNumber() ].size() != iteGN_A.current()->numberOfFacets()) {
575  std::cerr << "\t### G" << iteGN_A.currentIteratorNumber() << " has different facet size "
576  << listOfFacetsPerGenerator[ iteGN_A.currentIteratorNumber() ].size() << " and "
577  << iteGN_A.current()->numberOfFacets() << std::endl;
578  //std::copy(
579  //listOfFacetsPerGenerator[ iteGN_A.currentIteratorNumber() ].begin(),
580  //listOfFacetsPerGenerator[ iteGN_A.currentIteratorNumber() ].end(), std::ostream_iterator<unsigned int>(std::cout, " ") );
581  }
582  }}
583  }
584  return checkGeneratorsOK;
585  }
586 
587  double checkVolumeEquality(const boost::shared_ptr<PolyhedralCone_Rn>& B) const {
588 // bool res1, res2;
589 // std::cout << "Check generators of A inside the half-spaces of B ..... ";
590 // res1 = checkGenerators( _listOfGenerators, B->_listOfHalfSpaces, false);
591 // std::cout << "Check generators of B inside the half-spaces of A ..... ";
592 // res2 = checkGenerators(B->_listOfGenerators, _listOfHalfSpaces, false);
593 // return (res1 || res2);
594  double TOL = Rn::getTolerance();
595  bool isOutFromB = false;
596  double distFromB = std::numeric_limits<int>::max();
597  {
598  std::vector< std::vector<int> > listOfFacetsPerGenerator(_listOfGenerators.size());
600  {for (iteHS_B.begin(); iteHS_B.end()!=true; iteHS_B.next()) {
601  double halfSpaceNorm =
602  std::inner_product(iteHS_B.current()->begin(), iteHS_B.current()->end(), iteHS_B.current()->begin(), 0.);
603  halfSpaceNorm = sqrt(halfSpaceNorm);
605  {for (iteGN_A_.begin(); iteGN_A_.end()!=true; iteGN_A_.next()) {
606  double scalarProduct = std::inner_product(iteGN_A_.current()->begin(), iteGN_A_.current()->end(), iteHS_B.current()->begin(), 0.);
607  double distanceToHyperplane = (scalarProduct+iteHS_B.current()->getConstant()) / halfSpaceNorm;
608  if (distanceToHyperplane > TOL) {
609  // HalfSpace_Rn::hs_IN: nothing to do.
610  }
611  else if (distanceToHyperplane < -TOL) {
612  // HalfSpace_Rn::hs_OUT
613  //std::cerr << "\t### G" << iteGN_A_.currentIteratorNumber() << " is out for half-space ";
614  //std::cerr << iteHS_B.currentIteratorNumber() << std::endl;
615  //std::cerr << "G" << iteGN_A_.currentIteratorNumber() << " = ";
616  //iteGN_A_.current()->dump(std::cerr);
617  //std::cerr << " (d=" << distanceToHyperplane << ")" << std::endl;
618  isOutFromB = true;
619  }
620  else {
621  // HalfSpace_Rn::hs_ON
622  listOfFacetsPerGenerator[ iteGN_A_.currentIteratorNumber() ].push_back( iteHS_B.currentIteratorNumber() );
623  }
624  if (distanceToHyperplane < distFromB)
625  distFromB = distanceToHyperplane;
626  }}
627  }}
628  }
629  bool isOutFromA = false;
630  double distFromA = std::numeric_limits<int>::max();
631  {
632  std::vector< std::vector<int> > listOfFacetsPerGenerator(B->_listOfGenerators.size());
634  {for (iteHS_A.begin(); iteHS_A.end()!=true; iteHS_A.next()) {
635  double halfSpaceNorm =
636  std::inner_product(iteHS_A.current()->begin(), iteHS_A.current()->end(), iteHS_A.current()->begin(), 0.);
637  halfSpaceNorm = sqrt(halfSpaceNorm);
639  {for (iteGN_B_.begin(); iteGN_B_.end()!=true; iteGN_B_.next()) {
640  double scalarProduct = std::inner_product(iteGN_B_.current()->begin(), iteGN_B_.current()->end(), iteHS_A.current()->begin(), 0.);
641  double distanceToHyperplane = (scalarProduct+iteHS_A.current()->getConstant()) / halfSpaceNorm;
642  if (distanceToHyperplane > TOL) {
643  // HalfSpace_Rn::hs_IN: nothing to do.
644  }
645  else if (distanceToHyperplane < -TOL) {
646  // HalfSpace_Rn::hs_OUT
647  //std::cerr << "\t### G" << iteGN_A_.currentIteratorNumber() << " is out for half-space ";
648  //std::cerr << iteHS_B.currentIteratorNumber() << std::endl;
649  //std::cerr << "G" << iteGN_A_.currentIteratorNumber() << " = ";
650  //iteGN_A_.current()->dump(std::cerr);
651  //std::cerr << " (d=" << distanceToHyperplane << ")" << std::endl;
652  isOutFromA = true;
653  }
654  else {
655  // HalfSpace_Rn::hs_ON
656  listOfFacetsPerGenerator[ iteGN_B_.currentIteratorNumber() ].push_back( iteHS_A.currentIteratorNumber() );
657  }
658  if (distanceToHyperplane < distFromA)
659  distFromA = distanceToHyperplane;
660  }}
661  }}
662  }
663  if (isOutFromA == true)
664  std::cout << "Outside A : distance = " << distFromA << std::endl;
665  if (isOutFromB == true)
666  std::cout << "Outside B : distance = " << distFromB << std::endl;
667  return std::min(distFromA, distFromB);
668  }
669 
671  void removeGenerator(unsigned int j) {_listOfGenerators.removeGeometricObject(j);}
672 
674  void removeGenerators(const std::set< boost::shared_ptr<Generator_Rn> >& setToRemove) {_listOfGenerators.removeGeometricObjects(setToRemove);}
675 
677  virtual bool checkEdges() const {return true;}
678 
679  void checkFacet(unsigned int fctNumber, std::ostream &this_ostream) const {
680  if (fctNumber >= _listOfHalfSpaces.size())
681  throw std::out_of_range("PolyhedralCone_Rn::checkFacet(unsigned int fctNumber, std::ostream &this_ostream) inadequate facet number!");
682  this_ostream.precision(15);
683  this_ostream << "Check facet " << fctNumber << std::endl;
684  _listOfHalfSpaces[fctNumber]->dump(this_ostream);
685  this_ostream << std::endl;
687  double halfSpaceNorm = std::inner_product(
688  _listOfHalfSpaces[fctNumber]->begin(), _listOfHalfSpaces[fctNumber]->end(), _listOfHalfSpaces[fctNumber]->begin(), 0.);
689  halfSpaceNorm = sqrt(halfSpaceNorm);
690  {for (iteGN.begin(); iteGN.end()!=true; iteGN.next()) {
691  HalfSpace_Rn::State currentState = checkPoint(iteGN.current(), _listOfHalfSpaces[fctNumber], halfSpaceNorm);
692  if (currentState == HalfSpace_Rn::hs_ON)
693  this_ostream << iteGN.currentIteratorNumber() << " ";
694  }}
696  //std::vector< boost::shared_ptr<Generator_Rn> > arrayOfGen;
697  //this_ostream << "Maximize" << std::endl << "obj:";
698  //this_ostream << "x_1" << std::endl << std::endl << "Subject To" << std::endl;
699  //{for (unsigned int j=0; j<Rn::getDimension(); ++j) {
700  //this_ostream << "r" << j << ":" << std::endl;
701  //{for (unsigned int i=0; i<arrayOfGen.size(); ++i) {
702  //if (arrayOfGen[i]->getCoordinate(j) > 0.)
703  //this_ostream << " + ";
704  //else
705  //this_ostream << " - ";
706  //this_ostream << fabs(arrayOfGen[i]->getCoordinate(j)) << "x_" << i << " ";
707  //}}
708  //this_ostream << " = " << std::endl;
709  //}}
710  //this_ostream << "r" << Rn::getDimension() << ":" << std::endl;
711  //{for (unsigned int i=0; i<arrayOfGen.size(); ++i) {
712  //this_ostream << " + x_" << i;
713  //}}
714  //this_ostream << " = 1." << std::endl << std::endl;
715  //this_ostream << "Bounds" << std::endl;
716  //{for (unsigned int i=0; i<arrayOfGen.size(); ++i) {
717  //this_ostream << 0. << " <= x_" << i << std::endl;
718  //}}
719  //this_ostream << std::endl;
720  //this_ostream << std::endl << "End" << std::endl;
721  this_ostream << std::endl;
722  double TOL=Rn::getTolerance();
723  {for (iteGN.begin(); iteGN.end()!=true; iteGN.next()) {
724  double scalarProduct = std::inner_product(iteGN.current()->begin(),iteGN.current()->end(), _listOfHalfSpaces[fctNumber]->begin(), 0.);
725  double distanceToHyperplane = (scalarProduct+ _listOfHalfSpaces[fctNumber]->getConstant()) / halfSpaceNorm;
726  this_ostream << "V" << iteGN.currentIteratorNumber() << "\t";
727  this_ostream << ": " << distanceToHyperplane;
728  if (distanceToHyperplane<TOL && distanceToHyperplane>-TOL)
729  this_ostream << " (*)";
730  this_ostream << std::endl;
731  }}
732  }
733 
741  bool checkFacets() const {
742  std::cout << "Check facets......... ";
743  bool checkFacetsOK=true;
744  unsigned int j=0;
745  std::vector<int> listOfGeneratorsPerFacetON(numberOfGenerators());
746  std::vector<int> listOfGeneratorsPerFacetOUT(numberOfGenerators());
748  {for (iteHS.begin(); iteHS.end()!=true; iteHS.next()) {
749  listOfGeneratorsPerFacetON.clear();
750  listOfGeneratorsPerFacetOUT.clear();
752  double halfSpaceNorm = std::inner_product(iteHS.current()->begin(), iteHS.current()->end(), iteHS.current()->begin(), 0.);
753  halfSpaceNorm = sqrt(halfSpaceNorm);
754  {for (iteGN.begin(); iteGN.end()!=true; iteGN.next()) {
755  HalfSpace_Rn::State currentState = checkPoint(iteGN.current(), iteHS.current(), halfSpaceNorm);
756  unsigned int i=iteGN.currentIteratorNumber();
757  if (currentState == HalfSpace_Rn::hs_ON)
758  listOfGeneratorsPerFacetON.push_back(i);
759  else if (currentState == HalfSpace_Rn::hs_OUT)
760  listOfGeneratorsPerFacetOUT.push_back(i);
761  }}
762  if (listOfGeneratorsPerFacetON.empty() == true || listOfGeneratorsPerFacetON.size() < numberOfGeneratorsPerFacet())
763  std::cout<< std::endl << "\t=== Facet " << j << " has only " << listOfGeneratorsPerFacetON.size() << " generators."<< std::endl;
764  if (listOfGeneratorsPerFacetOUT.empty() != true) {
765  {for (unsigned int i=0; i<listOfGeneratorsPerFacetOUT.size(); i++) {
766  checkFacetsOK = false;
767  std::cout<< std::endl;
768  std::cout << "\t### Facet " << j << " excludes generator " << listOfGeneratorsPerFacetOUT[i] << std::endl;
769  }}
770  }
771  j++;
772  }}
773  if (checkFacetsOK == true)
774  std::cout << "OK" << std::endl;
775  return checkFacetsOK;
776  }
777 
780  bool checkEquality(const boost::shared_ptr<PolyhedralCone_Rn>& B, bool getFaceMapping=false) const;
781 
783  void getGeneratorsPerFacet(std::vector< std::vector< unsigned int > >& listOfGeneratorsPerFacet) const {
784  listOfGeneratorsPerFacet.clear();
785  listOfGeneratorsPerFacet.resize(numberOfHalfSpaces());
787  {for (iteHS.begin(); iteHS.end()!=true; iteHS.next()) {
788  unsigned int facetNb = iteHS.currentIteratorNumber();
789  const boost::shared_ptr<HalfSpace_Rn>& thisFacet = iteHS.current();
791  {for (iteGN.begin(); iteGN.end()!=true; iteGN.next()) {
792  {for (unsigned int i=0; i<iteGN.current()->numberOfFacets(); ++i) {
793  if (iteGN.current()->getFacet(i) == thisFacet) {
794  unsigned int vtxNb = iteGN.currentIteratorNumber();
795  listOfGeneratorsPerFacet[facetNb].push_back(vtxNb);
796  }
797  }}
798  }}
799  }}
800  }
801 
802 
803  // ALGORITHMS
804 
806  void negate() {_listOfHalfSpaces.negate(); _listOfGenerators.negate();}
807 
818  virtual double createTruncatedGenerator(
819  const boost::shared_ptr<Generator_Rn_SD>& y,
820  const boost::shared_ptr<Generator_Rn_SD>& z,
821  boost::shared_ptr<Generator_Rn_SD> newG, double ay, double az, double b=0.) const;
822 
833  //virtual void createTruncatedGenerator(
834  // const Generator_Rn_SD& y,
835  // const Generator_Rn_SD& z,
836  // Generator_Rn_SD& newG, double ay, double az, double b=0.) const;
837 
839  boost::shared_ptr<PolyhedralCone_Rn> computeDualPolyhedralCone() const;
840 
842  virtual void dump(std::ostream &this_ostream) const;
843 
845  void dumpScilab(std::ostream &this_ostream) const;
846 
848  virtual void createBoundingBox(double) {}
849 
851  virtual void createBoundingSimplex(double) {}
852 
853 
854  protected:
859 };
860 
861 
862 #endif // POLYHEDRALCONE_Rn
PolyhedralCone_Rn::getListOfHalfSpaces
listOfGeometricObjects< boost::shared_ptr< HalfSpace_Rn > > & getListOfHalfSpaces()
Return the list of half-spaces.
Definition: PolyhedralCone_Rn.h:131
HalfSpace_Rn::hs_OUT
@ hs_OUT
Definition: HalfSpace_Rn.h:47
PolyhedralCone_Rn::createBoundingBox
virtual void createBoundingBox(double)
At the moment this function is useless in the case of polyhedral cones.
Definition: PolyhedralCone_Rn.h:848
GeometricObjectIterator_Rn.h
PolyhedralCone_Rn::checkTopologyAndGeometry
virtual bool checkTopologyAndGeometry(bool check_all=false) const
As stated by Komei Fukuda "the complexity of the polyhedral verification problem is unknown....
Definition: PolyhedralCone_Rn.h:443
Neighbours_Rn.h
PolyhedralCone_Rn::checkNeighboursWithHSnumbers
bool checkNeighboursWithHSnumbers(const boost::shared_ptr< Generator_Rn > &V1, const boost::shared_ptr< Generator_Rn > &V2, std::vector< HalfSpace_Rn * > &commonFacets, const std::set< boost::shared_ptr< HalfSpace_Rn > > &listOfRedundantHS, unsigned int topologicalCode=1) const
Check for polytopes that vertices share (n-1) facets. For polyhedral cones, it must check that vector...
Definition: PolyhedralCone_Rn.h:335
PolyhedralCone_Rn::checkGenerator
HalfSpace_Rn::State checkGenerator(const boost::shared_ptr< Generator_Rn > &thisGen) const
Definition: PolyhedralCone_Rn.h:462
Neighbours_Rn::end
bool end() const
Iterator function.
Definition: Neighbours_Rn.h:151
PolyhedralCone_Rn::removeGenerators
void removeGenerators(const std::set< boost::shared_ptr< Generator_Rn > > &setToRemove)
Remove the generators contained in setToRemove.
Definition: PolyhedralCone_Rn.h:674
PolyhedralCone_Rn::~PolyhedralCone_Rn
virtual ~PolyhedralCone_Rn()
Destructor.
Definition: PolyhedralCone_Rn.h:62
listOfGeometricObjects::push_back
void push_back(const GEOMETRIC_OBJECT &gn)
Include a new half space in the list.
Definition: GeometricObjectIterator_Rn.h:47
Generator_Rn_SD::CREATED_AND_MODIFIED
@ CREATED_AND_MODIFIED
Definition: Generator_Rn.h:293
PolyhedralCone_Rn
Model a polyhedral cone using its two equivalent definitions : the convex hull and the half-space int...
Definition: PolyhedralCone_Rn.h:47
HalfSpace_Rn::hs_IN_OR_OUT
@ hs_IN_OR_OUT
Definition: HalfSpace_Rn.h:49
PolyhedralCone_Rn::checkNeighbours
bool checkNeighbours(const boost::shared_ptr< Generator_Rn_SD > &genIn, const boost::shared_ptr< Generator_Rn_SD > &genOut, std::vector< unsigned int > &commonFacets) const
Check for polytopes that vertices share (n-1) facets. For polyhedral cones, it must check that vector...
Definition: PolyhedralCone_Rn.h:313
PolyhedralCone_Rn::checkNeighbours
bool checkNeighbours(const boost::shared_ptr< Generator_Rn > &V1, const boost::shared_ptr< Generator_Rn > &V2, std::vector< boost::shared_ptr< HalfSpace_Rn > > &commonFacets, unsigned int topologicalCode=1) const
Definition: PolyhedralCone_Rn.h:260
PolyhedralCone_Rn::checkNeighbours
bool checkNeighbours(const boost::shared_ptr< Generator_Rn > &V1, const boost::shared_ptr< Generator_Rn > &V2, std::vector< HalfSpace_Rn * > &commonFacets, unsigned int topologicalCode=1) const
Check for polytopes that vertices share (n-1) facets. For polyhedral cones, it must check that vector...
Definition: PolyhedralCone_Rn.h:287
PolyhedralCone_Rn::neigbourhoodCondition
virtual unsigned int neigbourhoodCondition() const
Two edges are neighbours in a polyhedral cone <=> they share at least (n-2) facets.
Definition: PolyhedralCone_Rn.h:84
PolyhedralCone_Rn::checkGenerator
void checkGenerator(unsigned int vtxNumber, std::ostream &this_ostream) const
Compute all distance from the current point to all half-spaces frontiers.
Definition: PolyhedralCone_Rn.h:485
polito_EXPORT
#define polito_EXPORT
Definition: polito_Export.h:15
PolyhedralCone_Rn::checkFacet
void checkFacet(unsigned int fctNumber, std::ostream &this_ostream) const
Definition: PolyhedralCone_Rn.h:679
PolyhedralCone_Rn::checkVolumeEquality
double checkVolumeEquality(const boost::shared_ptr< PolyhedralCone_Rn > &B) const
Definition: PolyhedralCone_Rn.h:587
PolyhedralCone_Rn::isBounded
virtual bool isBounded() const
Tell whether this polyhedron is bounded or not, polyhedral cones are not.
Definition: PolyhedralCone_Rn.h:81
PolyhedralCone_Rn::numberOfHalfSpaces
unsigned int numberOfHalfSpaces() const
Get the total number of half-spaces.
Definition: PolyhedralCone_Rn.h:95
Neighbours_Rn::currentGenInNumber
unsigned int currentGenInNumber() const
Iterator function.
Definition: Neighbours_Rn.h:154
Generator_Rn_SD::MODIFIED
@ MODIFIED
Definition: Generator_Rn.h:289
Neighbours_Rn::next
void next()
Iterator function.
Definition: Neighbours_Rn.h:142
listOfGeometricObjects
This class is designed to contain the list of all generators or half-spaces representing a polytope o...
Definition: GeometricObjectIterator_Rn.h:40
Neighbours_Rn::begin
void begin()
Iterator function.
Definition: Neighbours_Rn.h:139
Rn::getDimension
static polito_EXPORT unsigned int getDimension()
Return the dimension of the cartesian space we work in.
Definition: Rn.cpp:29
PolyhedralCone_Rn::checkNeighbours
bool checkNeighbours(const boost::shared_ptr< Generator_Rn > &V1, const boost::shared_ptr< Generator_Rn > &V2, std::vector< boost::shared_ptr< HalfSpace_Rn > > &commonFacets, const std::set< boost::shared_ptr< HalfSpace_Rn > > &listOfRedundantHS) const
Definition: PolyhedralCone_Rn.h:229
PolyhedralCone_Rn::removeHalfSpace
void removeHalfSpace(unsigned int j)
Remove the half-space number j from its list.
Definition: PolyhedralCone_Rn.h:104
constIteratorOfListOfGeometricObjects::current
const GEOMETRIC_OBJECT current()
Return the current geometric element.
Definition: GeometricObjectIterator_Rn.h:177
PolyhedralCone_Rn::getListOfGeneratorsSD
unsigned int getListOfGeneratorsSD(std::vector< boost::shared_ptr< Generator_Rn_SD > > &currentListOfGeneratorsSD) const
Definition: PolyhedralCone_Rn.h:157
constIteratorOfListOfGeometricObjects::currentIteratorNumber
int currentIteratorNumber() const
Return the current position in the list.
Definition: GeometricObjectIterator_Rn.h:192
Neighbours_Rn
Class dedicated to degeneration processing when looking for neighbours. Let A be a polytope of wher...
Definition: Neighbours_Rn.h:59
PolyhedralCone_Rn::addGenerator
void addGenerator(boost::shared_ptr< Generator_Rn > vx)
Add the given generator.
Definition: PolyhedralCone_Rn.h:146
constIteratorOfListOfGeometricObjects::end
bool end() const
Tell whether we have reached the end of the list.
Definition: GeometricObjectIterator_Rn.h:174
Neighbours_Rn::addGenerator
void addGenerator(const std::vector< unsigned int > &commonFacets, unsigned int numbergenIN, unsigned int numbergenOUT, HalfSpace_Rn::State state)
Tell whether a pseudo neighbor is a genuine one comparing set of half-spaces.
Definition: Neighbours_Rn.h:69
Rn.h
PolyhedralCone_Rn::removeGenerator
void removeGenerator(unsigned int j)
Remove the generator number j from its list.
Definition: PolyhedralCone_Rn.h:671
PolyhedralCone_Rn::setListOfHalfSpaces
void setListOfHalfSpaces(const listOfGeometricObjects< boost::shared_ptr< HalfSpace_Rn > > &hsList)
Set a new list of half-spaces.
Definition: PolyhedralCone_Rn.h:137
Neighbours_Rn::currentGenOutNumber
unsigned int currentGenOutNumber() const
Iterator function.
Definition: Neighbours_Rn.h:157
PolyhedralCone_Rn::checkGenerators
bool checkGenerators(const listOfGeometricObjects< boost::shared_ptr< Generator_Rn > > &listGenA, const listOfGeometricObjects< boost::shared_ptr< HalfSpace_Rn > > &listHSB, bool check_all=false) const
Check the number of facets per generator and make sure it is compliant with its current constraints....
Definition: PolyhedralCone_Rn.h:523
Generator_Rn_SD::CREATED
@ CREATED
Definition: Generator_Rn.h:291
Point_Rn
Creation of a n-coordinate geometric point designed to be shared by its neighbour faces.
Definition: Point_Rn.h:34
Generator_Rn.h
PolyhedralCone_Rn::PolyhedralCone_Rn
PolyhedralCone_Rn(const PolyhedralCone_Rn &A)
Constructor.
Definition: PolyhedralCone_Rn.h:56
PolyhedralCone_Rn::fillNeighbourMatrix
void fillNeighbourMatrix(std::vector< std::vector< unsigned int > > &neighboursA, unsigned int topologicalCode=1) const
Definition: PolyhedralCone_Rn.h:362
PolyhedralCone_Rn::getGeneratorsPerFacet
void getGeneratorsPerFacet(std::vector< std::vector< unsigned int > > &listOfGeneratorsPerFacet) const
Get topological connections: for each facet, list its generators.
Definition: PolyhedralCone_Rn.h:783
constIteratorOfListOfGeometricObjects
This class is designed to run the list of all geometric objects representing a polytope.
Definition: GeometricObjectIterator_Rn.h:142
PolyhedralCone_Rn::setListOfGeneratorsSD
void setListOfGeneratorsSD(const std::vector< boost::shared_ptr< Generator_Rn_SD > > &gnList)
Set a new list of generators. The list of half-spaces should have been previously set.
Definition: PolyhedralCone_Rn.h:179
PolyhedralCone_Rn::setListOfGenerators
void setListOfGenerators(const listOfGeometricObjects< boost::shared_ptr< Generator_Rn > > &gnList)
Set a new list of generators.
Definition: PolyhedralCone_Rn.h:218
HalfSpace_Rn::State
State
Definition: HalfSpace_Rn.h:44
Generator_Rn_SD
A n-coordinates generator for internal data structure. It can be a vertex or an edge whether it is em...
Definition: Generator_Rn.h:280
constIteratorOfListOfGeometricObjects::begin
void begin()
Move the iterator at the beginning of the list.
Definition: GeometricObjectIterator_Rn.h:150
PolyhedralCone_Rn::dimension
virtual unsigned int dimension() const
Return the space dimension.
Definition: PolyhedralCone_Rn.h:65
PolyhedralCone_Rn::removeHalfSpaces
void removeHalfSpaces(const std::set< boost::shared_ptr< HalfSpace_Rn > > &setOfRedundantHS)
Remove the half-space number j from its list.
Definition: PolyhedralCone_Rn.h:107
PolyhedralCone_Rn::getListOfGenerators
const listOfGeometricObjects< boost::shared_ptr< Generator_Rn > > & getListOfGenerators() const
Return the list of generators.
Definition: PolyhedralCone_Rn.h:155
PolyhedralCone_Rn::numberOfGenerators
unsigned int numberOfGenerators() const
Give the total number of generators.
Definition: PolyhedralCone_Rn.h:143
PolyhedralCone_Rn::checkFacets
bool checkFacets() const
Detect redundant half spaces and make sure each facet has the right number of generators.
Definition: PolyhedralCone_Rn.h:741
PolyhedralCone_Rn::_listOfHalfSpaces
listOfGeometricObjects< boost::shared_ptr< HalfSpace_Rn > > _listOfHalfSpaces
The list of half-spaces defining the polyhedron.
Definition: PolyhedralCone_Rn.h:856
HalfSpace_Rn::hs_ON
@ hs_ON
Definition: HalfSpace_Rn.h:45
Point_Rn::setCoordinate
void setCoordinate(unsigned int i, double val)
Definition: Point_Rn.cpp:61
PolyhedralCone_Rn::getListOfHalfSpaces
const listOfGeometricObjects< boost::shared_ptr< HalfSpace_Rn > > & getListOfHalfSpaces() const
Return the list of half-spaces.
Definition: PolyhedralCone_Rn.h:134
PolyhedralCone_Rn::reset
void reset()
Remove all half-spaces and generators.
Definition: PolyhedralCone_Rn.h:90
PolyhedralCone_Rn::fillIrredundantNeighbourMatrix
void fillIrredundantNeighbourMatrix(std::vector< std::vector< unsigned int > > &neighboursA) const
Definition: PolyhedralCone_Rn.h:402
PolyhedralCone_Rn::createBoundingSimplex
virtual void createBoundingSimplex(double)
At the moment this function is useless in the case of polyhedral cones.
Definition: PolyhedralCone_Rn.h:851
constIteratorOfListOfGeometricObjects::next
void next()
Move the iterator one step forward.
Definition: GeometricObjectIterator_Rn.h:153
Generator_Rn_SD::UNCHANGED
@ UNCHANGED
Definition: Generator_Rn.h:287
PolyhedralCone_Rn::negate
void negate()
Compute the symmetrical polyhedral cone.
Definition: PolyhedralCone_Rn.h:806
polito_Export.h
PolyhedralCone_Rn::getHalfSpaceNumber
unsigned int getHalfSpaceNumber(const boost::shared_ptr< HalfSpace_Rn > &F) const
For a given half-space, return its list index.
Definition: PolyhedralCone_Rn.h:112
Rn::getTolerance
static polito_EXPORT double getTolerance()
Give the minimum distance between two points.
Definition: Rn.cpp:31
PolyhedralCone_Rn::_listOfGenerators
listOfGeometricObjects< boost::shared_ptr< Generator_Rn > > _listOfGenerators
The convex hull of connected points.
Definition: PolyhedralCone_Rn.h:858
PolyhedralCone_Rn::checkEdges
virtual bool checkEdges() const
Always true in the polyhedral cone case.
Definition: PolyhedralCone_Rn.h:677
PolyhedralCone_Rn::numberOfGeneratorsPerFacet
virtual unsigned int numberOfGeneratorsPerFacet() const
Each facet in a polyhedral cone has got (n-1) edges.
Definition: PolyhedralCone_Rn.h:87
HalfSpace_Rn.h
PolyhedralCone_Rn::PolyhedralCone_Rn
PolyhedralCone_Rn()
Constructor.
Definition: PolyhedralCone_Rn.h:53