politopix  5.0.0
Polytope_Rn.cpp
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-2016 : 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 #include <iostream>
22 #include <sstream>
23 #include <vector>
24 #include <math.h>
25 #include "Rn.h"
26 #include "Polytope_Rn.h"
27 #include "IO_Polytope.h"
28 #include "DoubleDescription_Rn.h"
30 
31 
33  // Check all edges, built from neighbor generators and topological data, are on frontier and not inside the polytope.
34  std::cout << "Check edges.......... ";
35  unsigned int RnDIM= this->dimension();
36  bool checkEdgesOK = true;
37  {for (unsigned int i=0; i<numberOfGenerators(); i++) {
38  boost::shared_ptr<Generator_Rn> V1 = _listOfGenerators[i];
39  for (unsigned int j=0; j<numberOfGenerators(); j++) {
40  boost::shared_ptr<Generator_Rn> V2 = _listOfGenerators[j];
41  std::vector< boost::shared_ptr<HalfSpace_Rn> > commonFacets;
42  if (V1 != V2 && checkNeighbours(V1, V2, commonFacets) == true) {
43  // Build the edge with V1 & V2 and check it is inside all facets.
44  std::vector<double> edge(RnDIM);
45  for (unsigned int k=0; k<RnDIM; k++)
46  edge[k] = V1->getCoordinate(k) - V2->getCoordinate(k);
47  unsigned int countFacets = 0;
48  double scalarProduct = 0.;
49  for (unsigned int l=0; l<commonFacets.size(); l++) {
50  for (unsigned int n=0; n<RnDIM; n++)
51  scalarProduct = scalarProduct + edge[n]*commonFacets[l]->getCoefficient(n);
52  if (scalarProduct < -Rn::getTolerance() || scalarProduct > Rn::getTolerance()) {
53  std::cout << "\t### Edge for generators " << i << " and " << j << " not on facet (";
54  {for (unsigned int jj=0; jj<RnDIM; jj++) {
55  std::cout << commonFacets[l]->getCoefficient(jj) << " ";
56  if (jj == RnDIM-1)
57  std::cout << commonFacets[l]->getSideAsText() << " " << commonFacets[l]->getConstant();
58  }}
59  std::cout << ") " << std::endl;
60  checkEdgesOK = false;
61  }
62  else
63  countFacets++;
64  }
65  // For polytopes only.
66  if (countFacets < RnDIM-1) {
67  std::cout << "\t### Edge for generators " << i << " and " << j << " has not enough facets" << std::endl;
68  checkEdgesOK = false;
69  }
70  }
71  }
72  }}
73  if (checkEdgesOK == true)
74  std::cout << "OK" << std::endl;
75  return checkEdgesOK;
76 }
77 
80  double MIN =-M;
81  double MAX = (2*dimension()-1)*M;
82  unsigned int dim = dimension();
83  unsigned int currentNumberOfFacets = (unsigned int)dimension()+1;
84  unsigned int currentNumberOfGenerators = (unsigned int)dimension()+1;
85  //std::cout << "Number of generators = " << currentNumberOfGenerators << std::endl;
86 
87  // Fill the data structure with blank Generators, 4 in dim 2, 8 in dim 3, ...
88  {for (unsigned int vtx_count=0; vtx_count<currentNumberOfGenerators; vtx_count++) {
89  boost::shared_ptr<Generator_Rn> VX;
90  VX.reset(new Generator_Rn(dim));
91  addGenerator(VX);
92  }}
93  // Create the simplex generators (MIN, MIN, ..., MAX, ..., MIN) where MAX
94  // moves from 0 to (n-1) and the last vertex is (MIN, ..., MIN).
95  {for (unsigned int coord_count=0; coord_count<dim; coord_count++) {
96  {for (unsigned int vtx_count=0; vtx_count<currentNumberOfGenerators; vtx_count++) {
97  //vtx_count==currentNumberOfGenerators-1 => this vertex is the corner i.e. (MIN, ..., MIN)
98  if (vtx_count==coord_count && vtx_count<currentNumberOfGenerators-1)
99  getGenerator(vtx_count)->setCoordinate(coord_count, MAX);
100  else
101  getGenerator(vtx_count)->setCoordinate(coord_count, MIN);
102  }}
103  }}
104  // Create the simplex array of facets excepted the oblic one, for the moment.
105  std::vector< boost::shared_ptr<HalfSpace_Rn> > supportFacets;
106  // M + xi >= 0.
107  {for (unsigned int facet_count=0; facet_count<currentNumberOfFacets-1; facet_count++) {
108  boost::shared_ptr<HalfSpace_Rn> HalfSp(new HalfSpace_Rn(dim));
109  {for (unsigned int coord_count=0; coord_count<dim; coord_count++) {
110  if (facet_count == coord_count)
111  HalfSp->setCoefficient(coord_count, 1.);
112  else
113  HalfSp->setCoefficient(coord_count, 0.);
114  }}
115  HalfSp->setConstant(M);
116  supportFacets.push_back(HalfSp);
117  // The first generator is the corner so it has
118  // to contain all the perpendicular half-spaces.
119  getGenerator(currentNumberOfGenerators-1)->setFacet(HalfSp);
120  }}
121  // Oblic half-space (Rn::getDimension()*M, -1., ..., -1.)
122  boost::shared_ptr<HalfSpace_Rn> oblicHalfSp(new HalfSpace_Rn(dim));
123  {for (unsigned int coord_count=0; coord_count<dim; coord_count++) {
124  oblicHalfSp->setCoefficient(coord_count, -1.);
125  }}
126  oblicHalfSp->setConstant(dimension()*M);
127  supportFacets.push_back(oblicHalfSp);
129  {for (iteH.begin(); iteH.end()!=true; iteH.next()) {
130  supportFacets.push_back(iteH.current());
131  }}
133  std::vector< boost::shared_ptr<HalfSpace_Rn> >::const_iterator itF;
134  {for (itF=supportFacets.begin(); itF!=supportFacets.end();++itF) {
136  }}
137  // Make connections between the generators excepted the corner (already treated).
138  {for (unsigned int vtx_count1=0; vtx_count1<currentNumberOfGenerators-1; vtx_count1++) {
139  boost::shared_ptr<Generator_Rn> VX1 = getGenerator(vtx_count1);
140  VX1->setFacet(oblicHalfSp);
141  {for (unsigned int coord_count=0; coord_count<dim; coord_count++) {
142  if (VX1->getCoordinate(coord_count) == MIN) {
143  VX1->setFacet(_listOfHalfSpaces[coord_count]);
144  }
145  }}
146  }}
147  //std::string FileOut("simplex.ptop");
148  //boost::shared_ptr<Polytope_Rn> A(this);
149  //IO_Polytope::save(FileOut, A);
150  //exit(0);
151 }
152 
155  double MAX = M;
156  unsigned int dim = dimension();
157  unsigned int currentNumberOfGenerators = (unsigned int)pow(static_cast<double>(2), static_cast<int>(dim));
158  //std::cout << "Number of generators = " << currentNumberOfGenerators << std::endl;
159 
160  // Fill the data structure with blank Generators, 4 in dim 2, 8 in dim 3, ...
161  for (unsigned int vtx_count=0; vtx_count<currentNumberOfGenerators; vtx_count++) {
162  boost::shared_ptr<Generator_Rn> VX;
163  VX.reset(new Generator_Rn(dim));
164  addGenerator(VX);
165  }
166  // Create the cube generators.
167  for (unsigned int coord_count=0; coord_count<dim; coord_count++) {
168  int counter = 0;
169  for (unsigned int vtx_count=0; vtx_count<currentNumberOfGenerators; vtx_count++) {
170  if (counter >= pow(static_cast<double>(2), static_cast<int>(coord_count))) {
171  MAX = -1. * MAX;
172  counter = 0;
173  }
174  getGenerator(vtx_count)->setCoordinate(coord_count, MAX);
175  counter++;
176  }
177  }
178  // Create the cube array of facets.
179  std::vector< boost::shared_ptr<HalfSpace_Rn> > supportFacets;
180  // xi < M
181  for (unsigned int facet_count=0; facet_count<dim; facet_count++) {
182  boost::shared_ptr<HalfSpace_Rn> HalfSp(new HalfSpace_Rn(dim));
183  for (unsigned int coord_count=0; coord_count<dim; coord_count++) {
184  if (facet_count == coord_count)
185  HalfSp->setCoefficient(coord_count, -1.);
186  else
187  HalfSp->setCoefficient(coord_count, 0.);
188  }
189  HalfSp->setConstant(M);
190  supportFacets.push_back(HalfSp);
191  }
192  // xi > -M
193  for (unsigned int facet_count=0; facet_count<dim; facet_count++) {
194  boost::shared_ptr<HalfSpace_Rn> HalfSp(new HalfSpace_Rn(dim));
195  for (unsigned int coord_count=0; coord_count<dim; coord_count++) {
196  if (facet_count == coord_count)
197  HalfSp->setCoefficient(coord_count, 1.);
198  else
199  HalfSp->setCoefficient(coord_count, 0.);
200  }
201  HalfSp->setConstant(M);
202  supportFacets.push_back(HalfSp);
203  }
205  {for (iteH.begin(); iteH.end()!=true; iteH.next()) {
206  supportFacets.push_back(iteH.current());
207  }}
209  std::vector< boost::shared_ptr<HalfSpace_Rn> >::const_iterator itF;
210  {for (itF=supportFacets.begin(); itF!=supportFacets.end();++itF) {
212  }}
213  // Make connections between the generators.
214  for (unsigned int vtx_count1=0; vtx_count1<currentNumberOfGenerators; vtx_count1++) {
215  boost::shared_ptr<Generator_Rn> VX1 = getGenerator(vtx_count1);
216  for (unsigned int coord_count=0; coord_count<dim; coord_count++) {
217  if (VX1->getCoordinate(coord_count) == M)
218  VX1->setFacet(_listOfHalfSpaces[coord_count]);
219  else if (VX1->getCoordinate(coord_count) == -M)
220  VX1->setFacet(_listOfHalfSpaces[coord_count+dim]);
221  }
222  }
223 }
224 
227  const boost::shared_ptr<Generator_Rn_SD>& out,
228  const boost::shared_ptr<Generator_Rn_SD>& in,
229  boost::shared_ptr<Generator_Rn_SD> newV, double ay, double az, double b) const {
230  // Formula for polytopes.
231  double t = (-b-az) / (ay-az);
232  //for (unsigned int k=0; k<Rn::getDimension(); k++) {
233  //double yi = out->getCoordinate(k);
234  //double zi = in->getCoordinate(k);
235  //newV->setCoordinate(k, zi+(yi-zi)*t);
236  //}
237  newV->makeDiff(out, in);
238  newV->makeCoefSum(in, newV, 1., t);
239  return t;
240 }
241 
242 bool Polytope_Rn::checkEqualityOfVertices(const boost::shared_ptr<Polytope_Rn>& B, bool printOnScreen) const {
243  double RnDIM = Rn::getDimension();
244  double TOL2 = Rn::getTolerance()*Rn::getTolerance();
245  std::vector<bool> vtxOfA(numberOfGenerators());
246  std::vector<bool> vtxOfB(B->numberOfGenerators());
247  for (unsigned int i=0; i<vtxOfA.size(); ++i)
248  vtxOfA[i] = false;
249  for (unsigned int i=0; i<vtxOfB.size(); ++i)
250  vtxOfB[i] = false;
253  {for (iteGN_A.begin(); iteGN_A.end()!=true; iteGN_A.next()) {
254  {for (iteGN_B.begin(); iteGN_B.end()!=true; iteGN_B.next()) {
255  if (iteGN_A.current()->isEqual2(iteGN_B.current(), RnDIM, TOL2)) {
256  vtxOfA[ iteGN_A.currentIteratorNumber() ] = true;
257  vtxOfB[ iteGN_B.currentIteratorNumber() ] = true;
258  }
259  }}
260  }}
261  bool AinsideB = true, BinsideA = true;
262  {for (unsigned int i=0; i<vtxOfA.size(); ++i) {
263  if (vtxOfA[i] == false) {
264  AinsideB = false;
265  break;
266  }
267  }}
268  {for (unsigned int i=0; i<vtxOfB.size(); ++i) {
269  if (vtxOfB[i] == false) {
270  BinsideA = false;
271  break;
272  }
273  }}
274  if (printOnScreen == true) {
275  if (AinsideB == true)
276  std::cout << "The set of vertices of A in included in the set of vertices of B." << std::endl;
277  if (BinsideA == true)
278  std::cout << "The set of vertices of B in included in the set of vertices of A." << std::endl;
279  }
280 
281  return (AinsideB && BinsideA);
282 }
283 
284 boost::shared_ptr<PolyhedralCone_Rn> Polytope_Rn::getPrimalCone(unsigned int u, const std::vector<unsigned int>& allNgb) const {
285  if (u >= numberOfGenerators())
286  throw std::out_of_range("Polytope_Rn::getPrimalCone() index out of range");
287  unsigned int RnDIM=dimension();
288  boost::shared_ptr<Generator_Rn> vx1 = getGenerator(u);
289  boost::shared_ptr<PolyhedralCone_Rn> primalCone;
291  // Split the polytope into its primal polyhedral cones //
293  primalCone.reset(new PolyhedralCone_Rn());
294  // Insert all half-spaces connected to the current vertex into the primal cone.
295  for (unsigned int i=0; i<vx1->numberOfFacets(); i++) {
296  primalCone->addHalfSpace(vx1->getFacet(i));
297  }
298  {
299  std::vector<unsigned int>::const_iterator ngb;
300  for (ngb=allNgb.begin(); ngb!=allNgb.end(); ngb++) {
301  boost::shared_ptr<Generator_Rn> vx2 = getGenerator(*ngb);
302  // Build the edge.
303  boost::shared_ptr<Generator_Rn> edge12(new Generator_Rn(RnDIM));
304  edge12->makeDiff(vx2, vx1);
305  // Build the facet list.
306  std::vector< boost::shared_ptr<HalfSpace_Rn> > commonFacets;
307  // Get facets.
308  checkNeighbours(vx1, vx2, commonFacets);
309  for (unsigned int j=0; j<commonFacets.size(); ++j) {
310  boost::shared_ptr<HalfSpace_Rn> Fj = commonFacets[j];
311  edge12->setFacet(Fj);
312  }
313  // Insert the edge into the primal cone.
314  primalCone->addGenerator(edge12);
315  }
316  }
317  return primalCone;
318 }
319 
320 boost::shared_ptr<Polytope_Rn> Polytope_Rn::sum(const boost::shared_ptr<Polytope_Rn>& pol2sum) {
321  boost::shared_ptr<Polytope_Rn> currentSum(new Polytope_Rn());
322  boost::shared_ptr<Polytope_Rn> operand1(this);
323  MinkowskiSum Ope(operand1, pol2sum, currentSum);
324  currentSum->checkTopologyAndGeometry();
325  return currentSum;
326 }
327 
328 boost::shared_ptr<Polytope_Rn> Polytope_Rn::intersect(const boost::shared_ptr<Polytope_Rn>& pol2intersect) {
329  boost::shared_ptr<Polytope_Rn> C(new Polytope_Rn()), A(this);
330  // Copy the generators of A.
332  for (iteHS0.begin(); iteHS0.end()!=true; iteHS0.next()) {
333  C->addGenerator(iteHS0.current());
334  }
335  // Copy the half-spaces of A.
337  for (iteHS1.begin(); iteHS1.end()!=true; iteHS1.next()) {
338  C->addHalfSpace(iteHS1.current());
339  }
340  // Copy the half-spaces of B.
341  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > iteHS2(pol2intersect->getListOfHalfSpaces());
342  for (iteHS2.begin(); iteHS2.end()!=true; iteHS2.next()) {
343  C->addHalfSpace(iteHS2.current());
344  }
345  unsigned int truncationStep = A->numberOfHalfSpaces();
346  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > lexmin_ite(C->getListOfHalfSpaces());
347  //StrongRedundancyProcessing< boost::shared_ptr<Polytope_Rn> > NRP(C->neigbourhoodCondition());
348  // The number of facets for a cube.
350  boost::shared_ptr<Polytope_Rn>,
352  //StrongRedundancyProcessing< boost::shared_ptr<Polytope_Rn> > >
353  DD(C, lexmin_ite, truncationStep);
354  C->checkTopologyAndGeometry();
355  return C;
356 }
357 
358 boost::shared_ptr<CappedPolytope_Rn> CappedPolytope_Rn::sum(const boost::shared_ptr<CappedPolytope_Rn>& pol2sum, double bb_size) {
359  std::set< unsigned int > newCaps;
360  boost::shared_ptr<Polytope_Rn> C(new Polytope_Rn());
361  boost::shared_ptr<Polytope_Rn> A(this->_polytope);
362  PseudoSumWithoutCaps(A, pol2sum->_polytope, C, _operandCaps, pol2sum->_operandCaps, newCaps, bb_size);
363  boost::shared_ptr<CappedPolytope_Rn> finalSum(new CappedPolytope_Rn(C, newCaps) );
364  return finalSum;
365 }
366 
367 boost::shared_ptr<CappedPolytope_Rn> CappedPolytope_Rn::intersect(const boost::shared_ptr<CappedPolytope_Rn>& pol2intersect) {
368  std::set< unsigned int > newCaps;
369  boost::shared_ptr<Polytope_Rn> C(new Polytope_Rn());
370  boost::shared_ptr<Polytope_Rn> A(this->_polytope);
371  PseudoIntersectionWithoutCaps(A, pol2intersect->_polytope, C, _operandCaps, pol2intersect->_operandCaps, newCaps);
372  boost::shared_ptr<CappedPolytope_Rn> finalSum(new CappedPolytope_Rn(C, newCaps) );
373  return finalSum;
374 }
375 
376 void CappedPolytope_Rn::load(const std::string& pathA, double bb_size) {
377  boost::shared_ptr<Polytope_Rn> loadedPolytope(new Polytope_Rn()), cube(new Polytope_Rn());
378  IO_Polytope::load(pathA, loadedPolytope);
379  _polytope.reset(new Polytope_Rn());
380  _operandCaps.clear();
381  // Use a trick based on the size of the bounding box, if it is null consider we do not truncate and return now.
382  if (bb_size == 0.) {
383  // Copy the half-spaces of loadedPolytope.
384  {
385  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > iteHS1(loadedPolytope->getListOfHalfSpaces());
386  for (iteHS1.begin(); iteHS1.end()!=true; iteHS1.next())
387  _polytope->addHalfSpace(iteHS1.current());
388  }
389  return;
390  }
391  // Create the bounding box centered on the origin.
392  _polytope->createBoundingBox(bb_size);
393  // Make a copy the half-spaces of the cube, after the truncation we want to know which one remained.
394  {
396  for (iteHS1.begin(); iteHS1.end()!=true; iteHS1.next())
397  cube->addHalfSpace(iteHS1.current());
398  }
399  // Copy the half-spaces of loadedPolytope.
400  {
401  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > iteHS1(loadedPolytope->getListOfHalfSpaces());
402  for (iteHS1.begin(); iteHS1.end()!=true; iteHS1.next())
403  _polytope->addHalfSpace(iteHS1.current());
404  }
406  //StrongRedundancyProcessing< boost::shared_ptr<Polytope_Rn> > NRP(_polytope->neigbourhoodCondition());
407  // The number of facets for a cube.
408  unsigned int truncationStep = 2*_polytope->dimension();
410  boost::shared_ptr<Polytope_Rn>,
412  //StrongRedundancyProcessing< boost::shared_ptr<Polytope_Rn> > >
413  DD(_polytope, lexmin_ite, truncationStep);
414  // Now try to find all the cube half-space remaining inside _polytope
415  {
416  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > allCubeHS(cube->getListOfHalfSpaces());
418  unsigned int polFacetNb = 0;
419  for (allPolHS.begin(); allPolHS.end()!=true; allPolHS.next()) {
420  bool isEqual = false;
421  for (allCubeHS.begin(); allCubeHS.end()!=true; allCubeHS.next()) {
422  if (allCubeHS.current() == allPolHS.current())
423  isEqual = true;
424  }
425  if (isEqual == true)
426  _operandCaps.insert(polFacetNb);
427  polFacetNb++;
428  }
429  }
430 }
431 
432 void CappedPolytope_Rn::save(const std::string& pathA) {
433  boost::shared_ptr<Polytope_Rn> loadedPolytope(new Polytope_Rn());
435  for (allPolHS.begin(); allPolHS.end()!=true; allPolHS.next()) {
436  if (_operandCaps.find(allPolHS.currentIteratorNumber()) == _operandCaps.end())
437  loadedPolytope->addHalfSpace(allPolHS.current());
438  }
439  IO_Polytope::save(pathA, loadedPolytope);
440 }
441 
443  return TopGeomTools::scalingFactor(this->_polytope, factor);
444 }
PolyhedralCone_Rn::getListOfHalfSpaces
listOfGeometricObjects< boost::shared_ptr< HalfSpace_Rn > > & getListOfHalfSpaces()
Return the list of half-spaces.
Definition: PolyhedralCone_Rn.h:131
Polytope_Rn::createTruncatedGenerator
virtual double createTruncatedGenerator(const boost::shared_ptr< Generator_Rn_SD > &in, const boost::shared_ptr< Generator_Rn_SD > &out, boost::shared_ptr< Generator_Rn_SD > newV, double ay, double az, double b=0.) const
This is the intersection vertex in the truncating algorithm, defined by the intersection between an e...
Definition: Polytope_Rn.cpp:226
PseudoSumWithoutCaps
Compute the Minkowski sum of two polytopes and then remove all cap half-spaces to truncate again.
Definition: PolyhedralAlgorithms_Rn.h:267
CappedPolytope_Rn::load
void load(const std::string &pathA, double bb_size=10000.)
Definition: Polytope_Rn.cpp:376
CappedPolytope_Rn::save
void save(const std::string &pathA)
Definition: Polytope_Rn.cpp:432
TopGeomTools::scalingFactor
static int scalingFactor(boost::shared_ptr< Polytope_Rn > &pol, double sfactor)
Multiply a polytope by a given real number.
Definition: PolyhedralAlgorithms_Rn.cpp:1311
listOfGeometricObjects::push_back
void push_back(const GEOMETRIC_OBJECT &gn)
Include a new half space in the list.
Definition: GeometricObjectIterator_Rn.h:47
Polytope_Rn::createBoundingBox
virtual void createBoundingBox(double M)
Initialize the truncating algorithm building a M-sized bounding box around the polytope.
Definition: Polytope_Rn.cpp:154
listOfGeometricObjects::clear
void clear()
Clear the whole list.
Definition: GeometricObjectIterator_Rn.h:67
PolyhedralCone_Rn::getGenerator
const boost::shared_ptr< Generator_Rn > & getGenerator(unsigned int i) const
Return the i-th generator.
Definition: PolyhedralCone_Rn.cpp:191
CappedPolytope_Rn::_polytope
boost::shared_ptr< Polytope_Rn > _polytope
Definition: Polytope_Rn.h:280
CappedPolytope_Rn::sum
boost::shared_ptr< CappedPolytope_Rn > sum(const boost::shared_ptr< CappedPolytope_Rn > &pol2sum, double bb_size=1000.)
Definition: Polytope_Rn.cpp:358
CappedPolytope_Rn::intersect
void intersect(const std::vector< boost::shared_ptr< CappedPolytope_Rn > > &allPolytopes0)
Definition: Polytope_Rn.h:229
Polytope_Rn::getPrimalCone
boost::shared_ptr< PolyhedralCone_Rn > getPrimalCone(unsigned int u, const std::vector< unsigned int > &allNgb) const
Definition: Polytope_Rn.cpp:284
Polytope_Rn::intersect
boost::shared_ptr< Polytope_Rn > intersect(const boost::shared_ptr< Polytope_Rn > &pol2intersect)
Definition: Polytope_Rn.cpp:328
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
PolyhedralAlgorithms_Rn.h
constIteratorOfListOfGeometricObjects::current
const GEOMETRIC_OBJECT current()
Return the current geometric element.
Definition: GeometricObjectIterator_Rn.h:177
constIteratorOfListOfGeometricObjects::currentIteratorNumber
int currentIteratorNumber() const
Return the current position in the list.
Definition: GeometricObjectIterator_Rn.h:192
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
HalfSpace_Rn
A half-space whose frontier is a linear (n-1) dimension space. _constant + _coefficients[0]....
Definition: HalfSpace_Rn.h:40
Rn.h
Polytope_Rn::createBoundingSimplex
virtual void createBoundingSimplex(double M)
Initialize the truncating algorithm building a M-sized simplex around the polytope.
Definition: Polytope_Rn.cpp:79
constIteratorOfListOfGeometricObjects
This class is designed to run the list of all geometric objects representing a polytope.
Definition: GeometricObjectIterator_Rn.h:142
Polytope_Rn::checkEdges
virtual bool checkEdges() const
Always true in the polyhedral cone case.
Definition: Polytope_Rn.cpp:32
DoubleDescription
The algorithm implemented here is an incremental algorithm as mentioned in How Good are Convex Hull ...
Definition: DoubleDescription_Rn.h:86
Generator_Rn
A n-coordinates generator, which can be a vertex or an edge whether it is contained by a polytope or ...
Definition: Generator_Rn.h:39
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
Polytope_Rn::sum
boost::shared_ptr< Polytope_Rn > sum(const boost::shared_ptr< Polytope_Rn > &pol2sum)
Definition: Polytope_Rn.cpp:320
PseudoIntersectionWithoutCaps
Remove all cap half-spaces and then compute the intersection of two capped polytopes.
Definition: PolyhedralAlgorithms_Rn.h:304
DoubleDescription_Rn.h
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::_listOfHalfSpaces
listOfGeometricObjects< boost::shared_ptr< HalfSpace_Rn > > _listOfHalfSpaces
The list of half-spaces defining the polyhedron.
Definition: PolyhedralCone_Rn.h:856
CappedPolytope_Rn::scalingFactor
int scalingFactor(double factor)
Definition: Polytope_Rn.cpp:442
CappedPolytope_Rn::_operandCaps
std::set< unsigned int > _operandCaps
Contain the number of the facets which are cap facets.
Definition: Polytope_Rn.h:278
IO_Polytope::load
static polito_EXPORT void load(const std::string &filename, boost::shared_ptr< PolyhedralCone_Rn > POLY)
Load the main data format to store polytopes.
Definition: IO_Polytope.cpp:26
Polytope_Rn.h
CappedPolytope_Rn::CappedPolytope_Rn
CappedPolytope_Rn()
Definition: Polytope_Rn.h:161
IO_Polytope.h
constIteratorOfListOfGeometricObjects::next
void next()
Move the iterator one step forward.
Definition: GeometricObjectIterator_Rn.h:153
IO_Polytope::save
static polito_EXPORT void save(const std::string &filename, boost::shared_ptr< PolyhedralCone_Rn > POLY)
Save the polytope to the main data format.
Definition: IO_Polytope.cpp:132
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
Polytope_Rn::Polytope_Rn
Polytope_Rn()
Constructor for polytopes i.e. bounded convex polyhedra.
Definition: Polytope_Rn.h:40
Polytope_Rn
Model a polytope using its two equivalent definitions : the convex hull and the half-space intersecti...
Definition: Polytope_Rn.h:36
Polytope_Rn::checkEqualityOfVertices
bool checkEqualityOfVertices(const boost::shared_ptr< Polytope_Rn > &B, bool printOnScreen=false) const
Check whether two V-polytopes are identical Check whether the sets of vertices of A and B are equal.
Definition: Polytope_Rn.cpp:242
PolyhedralCone_Rn::PolyhedralCone_Rn
PolyhedralCone_Rn()
Constructor.
Definition: PolyhedralCone_Rn.h:53
MinkowskiSum
Compute the Minkowski sum of two polytopes.
Definition: PolyhedralAlgorithms_Rn.h:138