politopix  5.0.0
main.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-2019 : 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 <boost/shared_ptr.hpp>
22 #include <boost/timer.hpp>
23 #include <iostream>
24 #include <string.h>
25 #include <cmath>
27 #include "Config.h"
28 
29 
31 class RunOptions {
32 
33  public:
34  RunOptions() {}
35 
37  static void setCheckGeneratorsTest(bool b) {_checkGeneratorsTest = b;}
38 
40  static bool getCheckGeneratorsTest() {return _checkGeneratorsTest;}
41 
43  static void setCheckGeneratorsValue(unsigned int d) {_checkGeneratorsValue = d;}
44 
46  static unsigned int getCheckGeneratorsValue() {return _checkGeneratorsValue;}
47 
48  protected:
49  static bool _checkGeneratorsTest;
50  static unsigned int _checkGeneratorsValue;
51 
52 };
53 
54 
55 bool RunOptions::_checkGeneratorsTest = false;
56 unsigned int RunOptions::_checkGeneratorsValue = 0;
57 
58 
59 int main(int argc, char* argv[]) {
60 
61  unsigned int dimension = 0;
62  double tolerance= 0.;
64  std::string fileName1,fileName2;
65  bool boundingBox = true;
66  bool boundingVolume = false;
67  double boundingSize = 1000;
68  double volumeOfPolytope = -1.;
69  unsigned int facetsToCheck = 0, generatorsToCheck = 0;
70  int vertexToComputeDistances=-1, facetToComputeDistances=-1;
71  bool computeDistances=false;
72  bool p1=false, p2=false, c1=false, c2=false;
73  bool COMPUTE_VOL=false, SUBSET=false, BOUNDS=false, POLAR=false;
74  bool INTER=false, CHCK_EQ=false, MS=false, check_all=false, output=false;
75  std::string outputFileName;
76 
77  std::ostringstream stream_;
78  stream_ << "Version ";
79  stream_ << politopix_VERSION_MAJOR;
80  stream_ << ".";
81  stream_ << politopix_VERSION_MINOR;
82  stream_ << ".";
83  stream_ << politopix_VERSION_PATCH;
84  std::string version = stream_.str();
85 
86  // Parse the main arguments
87  for(int i = 1; i < argc; ++i) {
88  if (strcmp(argv[i], "-p1") == 0 || strcmp(argv[i], "--polytope1") == 0) {
89  if (i+1 == argc) {
90  cerr << "Invalid file " << argv[i] << std::endl;
91  return EXIT_FAILURE;
92  }
93  // Get file
94  char* fileName_1 = argv[++i];
95  std::string file1(fileName_1);
96  fileName1 = file1;
97  p1 = true;
98  }
99  else if (strcmp(argv[i], "-p2") == 0 || strcmp(argv[i], "--polytope2") == 0) {
100  if (i+1 == argc) {
101  cerr << "Invalid file " << argv[i] << std::endl;
102  return EXIT_FAILURE;
103  }
104  char* fileName_2 = argv[++i];
105  std::string file2(fileName_2);
106  fileName2 = file2;
107  p2 = true;
108  }
109  else if (strcmp(argv[i], "-o") == 0 || strcmp(argv[i], "--output") == 0) {
110  if (i+1 == argc) {
111  cerr << "Invalid file " << argv[i] << std::endl;
112  return EXIT_FAILURE;
113  }
114  char* fileName_3 = argv[++i];
115  std::string file3(fileName_3);
116  outputFileName = file3;
117  output = true;
118  }
119  else if (strcmp(argv[i], "-c1") == 0 || strcmp(argv[i], "--polyhedralcone1") == 0) {
120  if (i+1 == argc) {
121  cerr << "Invalid file " << argv[i] << std::endl;
122  return EXIT_FAILURE;
123  }
124  // Get file
125  char* fileName_1 = argv[++i];
126  std::string file1(fileName_1);
127  fileName1 = file1;
128  c1 = true;
129  }
130  else if (strcmp(argv[i], "-c2") == 0 || strcmp(argv[i], "--polyhedralcone2") == 0) {
131  if (i+1 == argc) {
132  cerr << "Invalid file " << argv[i] << std::endl;
133  return EXIT_FAILURE;
134  }
135  char* fileName_2 = argv[++i];
136  std::string file2(fileName_2);
137  fileName2 = file2;
138  c2 = true;
139  }
140  else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) {
141  cout << version << std::endl;
142  return EXIT_SUCCESS;
143  }
144  else if (strcmp(argv[i], "-ch") == 0 || strcmp(argv[i], "--check-all") == 0) {
145  // We perform all checks, it can be slow.
146  check_all = true;
147  }
148  else if (strcmp(argv[i], "-MS") == 0 || strcmp(argv[i], "--MinkowskiSum") == 0) {
149  // We compute Minkowski sums.
150  MS = true;
151  INTER = false;
152  CHCK_EQ = false;
153  POLAR = false;
154  SUBSET = false;
155  }
156  else if (strcmp(argv[i], "-IN") == 0 || strcmp(argv[i], "--Intersection") == 0) {
157  // We intersect polytopes or polyhedral cones, this is the default behaviour.
158  MS = false;
159  INTER = true;
160  CHCK_EQ = false;
161  POLAR = false;
162  SUBSET = false;
163  }
164  else if (strcmp(argv[i], "-PO") == 0 || strcmp(argv[i], "--Polar") == 0) {
165  // We compute a polar polytope.
166  SUBSET = false;
167  MS = false;
168  INTER = false;
169  CHCK_EQ = false;
170  POLAR = true;
171  }
172  else if (strcmp(argv[i], "-SS") == 0 || strcmp(argv[i], "--Subset") == 0) {
173  // We intersect polytopes or polyhedral cones, this is the default behaviour.
174  SUBSET = true;
175  MS = false;
176  INTER = false;
177  CHCK_EQ = false;
178  }
179  else if (strcmp(argv[i], "-EQ") == 0 || strcmp(argv[i], "--Equality") == 0) {
180  // We intersect polytopes or polyhedral cones, this is the default behaviour.
181  MS = false;
182  INTER = false;
183  CHCK_EQ = true;
184  POLAR = false;
185  SUBSET = false;
186  }
187  else if (strcmp(argv[i], "-bb") == 0 || strcmp(argv[i], "--boundingbox") == 0) {
188  if (i+1 == argc) {
189  cerr << "Invalid bounding box dimension " << argv[i] << std::endl;
190  return EXIT_FAILURE;
191  }
192  INTER = true;
193  boundingBox = true;
194  boundingVolume = true;
195  boundingSize = atof(argv[++i]);
196  }
197  else if (strcmp(argv[i], "-bs") == 0 || strcmp(argv[i], "--boundingsimplex") == 0) {
198  if (i+1 == argc) {
199  cerr << "Invalid bounding simplex dimension " << argv[i] << std::endl;
200  return EXIT_FAILURE;
201  }
202  // Here mark the fact we choose a simplex and not a cube.
203  INTER = true;
204  boundingBox = false;
205  boundingVolume = true;
206  boundingSize = atof(argv[++i]);
207  }
208  else if (strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "--dimension") == 0) {
209  if (i+1 == argc) {
210  cerr << "Invalid cartesian space dimension " << argv[i] << std::endl;
211  return EXIT_FAILURE;
212  }
213  dimension = atoi(argv[++i]);
214  Rn::setDimension(dimension);
215  }
216  else if (strcmp(argv[i], "-t") == 0 || strcmp(argv[i], "--tolerance") == 0) {
217  if (i+1 == argc) {
218  cerr << "Invalid cartesian space tolerance " << argv[i] << std::endl;
219  return EXIT_FAILURE;
220  }
221  tolerance = atof(argv[++i]);
222  Rn::setTolerance(tolerance);
223  }
224  else if (strcmp(argv[i], "-VO") == 0 || strcmp(argv[i], "--Volume") == 0) {
225  COMPUTE_VOL = true;
226  INTER = false;
227  }
228  else if (strcmp(argv[i], "-cg") == 0 || strcmp(argv[i], "--check-generators") == 0) {
229  if (i+1 == argc) {
230  cerr << "Invalid number of generators to check " << argv[i] << std::endl;
231  return EXIT_FAILURE;
232  }
233  generatorsToCheck = atoi(argv[++i]);
234  RunOptions::setCheckGeneratorsTest(true);
235  RunOptions::setCheckGeneratorsValue(generatorsToCheck);
236  }
237  else if (strcmp(argv[i], "-cf") == 0 || strcmp(argv[i], "--check-facets") == 0) {
238  if (i+1 == argc) {
239  cerr << "Invalid number of facets to check " << argv[i] << std::endl;
240  return EXIT_FAILURE;
241  }
242  facetsToCheck = atoi(argv[++i]);
243  RunOptions::setCheckGeneratorsTest(true);
244  RunOptions::setCheckGeneratorsValue(generatorsToCheck);
245  }
246  else if (strcmp(argv[i], "--generator") == 0) {
247  if (i+1 == argc) {
248  cerr << "Invalid number of generator " << argv[i] << std::endl;
249  return EXIT_FAILURE;
250  }
251  vertexToComputeDistances = atoi(argv[++i]);
252  computeDistances = true;
253  MS = false;
254  INTER = false;
255  CHCK_EQ = false;
256  }
257  else if (strcmp(argv[i], "--facet") == 0) {
258  if (i+1 == argc) {
259  cerr << "Invalid number of facet " << argv[i] << std::endl;
260  return EXIT_FAILURE;
261  }
262  facetToComputeDistances = atoi(argv[++i]);
263  computeDistances = true;
264  MS = false;
265  INTER = false;
266  CHCK_EQ = false;
267  }
268  else if (strcmp(argv[i], "--Bounds") == 0) {
269  BOUNDS = true;
270  }
271  else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
272  cout << version << std::endl;
273  cout << "\t-d [--dimension] ARG\t:\tSet the cartesian space dimension" << std::endl;
274  cout << "\t-t [--tolerance] ARG\t:\tSet the cartesian space tolerance [default: 1.e-06]" << std::endl;
275  cout << "\t-o [--output] ARG\t:\tThe optional output file (ptop or pcon extension)" << std::endl;
276  cout << "\t-p1 [--polytope1] ARG\t:\tFirst polytope input file (ptop extension)" << std::endl;
277  cout << "\t-p2 [--polytope2] ARG\t:\tSecond polytope input file (ptop extension)" << std::endl;
278  cout << "\t-c1 [--polyhedralcone1] ARG\t:\tFirst polyhedral cone input file (pcon extension)" << std::endl;
279  cout << "\t-c2 [--polyhedralcone2] ARG\t:\tSecond polyhedral cone input file (pcon extension)" << std::endl;
280  cout << "\t-cf [--check-facets] ARG\t:\tUsed to test when we know the final number of facets" << std::endl;
281  cout << "\t-cg [--check-generators] ARG\t:\tUsed to test when we know the final number of generators" << std::endl;
282  cout << "\t-bs [--boundingsimplex] ARG\t:\tBounding simplex size, containing the bounding box -bb (n+1 vertices)" << std::endl;
283  cout << "\t-bb [--boundingbox] ARG\t:\tBounding box size centered on the origin including the polytope (2^n vertices)" << std::endl;
284  cout << "\t-ch [--check-all]\t\t:\tUsed to perform all tests (no arguments, can be slow)." << std::endl;
285  cout << "\t-MS [--MinkowskiSum] \t:\tSet the option to turn on Minkowski sums" << std::endl;
286  cout << "\t-IN [--Intersection] \t:\tSet the option to turn on intersections (default option)" << std::endl;
287  cout << "\t-SS [--Subset] \t:\tSet the option to test whether P1 is included in P2" << std::endl;
288  cout << "\t-VO [--Volume] \t:\tSet the option to turn on the volume computation for the polytope" << std::endl;
289  cout << "\t-EQ [--Equality] \t:\tSet the option to turn on the equality check between ptop or pcon" << std::endl;
290  cout << "\t-v [--version]\t\t\t:\tGive the current version" << std::endl;
291  return 0;
292  }
293  else {
294  cerr << "Unknown option " << argv[i] << std::endl;
295  return EXIT_FAILURE;
296  }
297  }
298 
299  if (Rn::getDimension() == 0) {
300  cerr << "Dimension has not been set." << std::endl;
301  return EXIT_FAILURE;
302  }
303 
304  // Here we deal with the fact that the intersection is the default operation.
305  // So if we have two operands and we don't perform neither a sum nor an equality/inclusion check then it's an intersection
306  if (c2 == true || p2 == true)
307  if (MS == false && CHCK_EQ == false && SUBSET == false)
308  INTER = true;
309 
310  int truncationStep = 0;
311  boost::shared_ptr<PolyhedralCone_Rn> A;
312  boost::shared_ptr<PolyhedralCone_Rn> B;
313  boost::shared_ptr<PolyhedralCone_Rn> C;
314  try {
315  if (p1==true) {
316  A.reset(new Polytope_Rn());
317  IO_Polytope::load(fileName1, A);
318  // Is a bounding volume provided ?
319  if (boundingVolume == true) {
320  if (A->numberOfGenerators() == 0) {
321  // By default the bounding volume is a cube (2n facets), if not a tetrahedron (n+1 facets).
322  if (boundingBox == true) {
323  truncationStep = 2*Rn::getDimension();
324  A->createBoundingBox(boundingSize);
325  }
326  else {
327  truncationStep = Rn::getDimension()+1;
328  A->createBoundingSimplex(boundingSize);
329  }
330  }
331  else {
332  boost::shared_ptr<Polytope_Rn> PA = boost::dynamic_pointer_cast<Polytope_Rn>(A);
333  DoubleDescriptionFromGenerators::Compute( PA, boundingSize);
334  if (check_all == true)
335  PA->checkTopologyAndGeometry();
336  std::string FileOut("output");
337  FileOut += fileName1;
338  if (output == true)
339  FileOut = outputFileName;
340  IO_Polytope::save(FileOut, PA);
341 
342  return EXIT_SUCCESS;
343  }
344  }
345  }
346  else if (c1==true) {
347  A.reset(new PolyhedralCone_Rn());
348  IO_Polytope::load(fileName1, A);
349  }
350  if (p2==true) {
351  B.reset(new Polytope_Rn());
352  IO_Polytope::load(fileName2, B);
353  }
354  else if (c2==true) {
355  B.reset(new PolyhedralCone_Rn());
356  IO_Polytope::load(fileName2, B);
357  }
358  }
359  catch(std::ios_base::failure& e) {
360  cerr << "In/out exception: " << e.what() << std::endl;
361  return EXIT_FAILURE;
362  }
363 
364  if ((p1==true && p2==true) || (c1==true && c2==true)) {
365  if (p1==true && p2==true) {
366  C.reset(new Polytope_Rn());
367  }
368  else {
369  C.reset(new PolyhedralCone_Rn());
370  }
371  {for (unsigned int i=0; i<A->numberOfGenerators(); i++) {
372  C->addGenerator(A->getGenerator(i));
373  }}
375  for (iteHSA.begin(); iteHSA.end()!=true; iteHSA.next()) {
376  C->addHalfSpace(iteHSA.current());
377  }
379  for (iteHSB.begin(); iteHSB.end()!=true; iteHSB.next()) {
380  C->addHalfSpace(iteHSB.current());
381  }
382  truncationStep = A->numberOfHalfSpaces();
383  }
384  else if ((p1==true && p2!=true) || (c1==true && c2!=true)) {
385  // There is no polytope or polyhedral cone other than A.
386  C = A;
387  }
388  else {
389  cerr << "This program needs at least one polytope or one polyhedral cone and no mix between them." << std::endl;
390  return EXIT_FAILURE;
391  }
392 
393  boost::timer this_timer;
394  try {
395  // Do we have two operands and a sum or an intersection ?
396  if ((MS == true) || (INTER == true) || (COMPUTE_VOL == true) || (SUBSET == true) || (POLAR == true)) {
397  if (MS == true) {
398  // Minkowski sum calculation
399  if (p1!=true || p2!=true) {
400  cout << "ERROR 2 polytopes are needed to compute the minkowski sum." << std::endl;
401  return -1;
402  }
403  //NormalFan_Rn NFA(boost::dynamic_pointer_cast<Polytope_Rn>(A));
404  //NFA.dump(cout);
405  //NormalFan_Rn NFB(boost::dynamic_pointer_cast<Polytope_Rn>(B));
406  //NFB.dump(cout);
407  //NormalFan_Rn NFC;
408  //NFC.computeCommonRefinement(NFA,NFB);
409  //NFC.dump(cout);
410  C.reset(new Polytope_Rn());
411 
412  //cout << "VERTEX NUMBER = " << Polytope_Rn().computeMinkowskiVerticesNumber(A,B) << std::endl;
413 
414  boost::shared_ptr<Polytope_Rn> PA = boost::dynamic_pointer_cast<Polytope_Rn>(A);
415  boost::shared_ptr<Polytope_Rn> PB = boost::dynamic_pointer_cast<Polytope_Rn>(B);
416  boost::shared_ptr<Polytope_Rn> PC = boost::dynamic_pointer_cast<Polytope_Rn>(C);
417  MinkowskiSum Ope(PA,PB,PC);
418  //return 0;
419  }
420  else if (COMPUTE_VOL == true) {
421  boost::shared_ptr<Polytope_Rn> Pol = boost::dynamic_pointer_cast<Polytope_Rn>(C);
422  volumeOfPolytope = VolumeOfPolytopes_Rn::compute(Pol);
423  cout.precision(15);
424  cout << "VolumeOfPolytope=" << volumeOfPolytope << std::endl;
425  return EXIT_SUCCESS;
426  }
427  else if (POLAR == true) {
428  boost::shared_ptr<Polytope_Rn> Pol = boost::dynamic_pointer_cast<Polytope_Rn>(C);
429  boost::shared_ptr<Polytope_Rn> result;
430  result.reset(new Polytope_Rn());
431  TopGeomTools::PolarPolytope(Pol, result, false);
432  cout.precision(15);
433  std::string FileOut("output");
434  FileOut += fileName1;
435  if (output == true)
436  FileOut = outputFileName;
437  IO_Polytope::save(FileOut, result);
438  return EXIT_SUCCESS;
439  }
440  else if (SUBSET == true) {
441  bool isInside = A->isIncluded(B);
442  std::string answer = (isInside == true) ? "" : "not";
443  cout << "P1 is " << answer << " inside of P2" << std::endl;
444  return EXIT_SUCCESS;
445  }
446  else if (INTER == false && MS == false && check_all == true && p2 == false && c2 == false) {
447  // Here we just check the input body, we don't perform neither intersection nor sum.
448  A->checkTopologyAndGeometry();
449  return EXIT_SUCCESS;
450  }
451  else {
452  //C->truncate(truncationStep);
453 
454  // Declare an iterator.
455  //lexmaxIteratorOfListOfHalfSpaces lexmin_ite(C);
456  //constIteratorOfListOfHalfSpaces lexmin_ite(C);
457  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > lexmin_ite(C->getListOfHalfSpaces());
458  //DoubleDescriptionWeakRedundancy< boost::shared_ptr<PolyhedralCone_Rn>, lexmaxIteratorOfListOfHalfSpaces > DD(C, lexmin_ite, truncationStep);
459  //NoRedundancyProcessing< boost::shared_ptr<PolyhedralCone_Rn> > NRP;
460  //WeakRedundancyProcessing< boost::shared_ptr<PolyhedralCone_Rn> > NRP;
461  //StrongRedundancyProcessing< boost::shared_ptr<PolyhedralCone_Rn> > NRP(C->neigbourhoodCondition());
463  boost::shared_ptr<PolyhedralCone_Rn>,
465  //constIteratorOfListOfHalfSpaces,
466  //NoRedundancyProcessing< boost::shared_ptr<PolyhedralCone_Rn> > >
467  //WeakRedundancyProcessing< boost::shared_ptr<PolyhedralCone_Rn> > >
468  //StrongRedundancyProcessing< boost::shared_ptr<PolyhedralCone_Rn> > >
469  DD(C, lexmin_ite, truncationStep);
470  }
471  cout.precision(10 - (int)log10(Rn::getTolerance()) );
472  cout << "TIME=" << this_timer.elapsed() << std::endl;
473 
474  if (C->numberOfGenerators()==0 && C->numberOfHalfSpaces()==0)
475  cout << "The result is empty." << std::endl;
476  else {
477  if (generatorsToCheck != 0) {
478  if (generatorsToCheck == C->numberOfGenerators())
479  cout << "Found " << generatorsToCheck << " generators..... OK" << std::endl;
480  else
481  cout << "Found " << C->numberOfGenerators() << " generators instead of " << generatorsToCheck << " KO !!!!!" << std::endl;
482  }
483  if (facetsToCheck != 0) {
484  if (facetsToCheck == C->numberOfHalfSpaces())
485  cout << "Found " << facetsToCheck << " facets ..... OK" << std::endl;
486  else
487  cout << "Found " << C->numberOfHalfSpaces() << " facets instead of " << facetsToCheck << " KO !!!!!" << std::endl;
488  }
489  std::string FileOut("output");
490  FileOut += fileName1;
491  if (output == true)
492  FileOut = outputFileName;
493  IO_Polytope::save(FileOut, C);
494  }
495  }
496  if (BOUNDS == true) {
497  if (C->numberOfGenerators() != 0) {
498  std::vector< double > allMin;
499  std::vector< double > allMax;
500  for (unsigned int i=0; i<dimension; ++i) {
501  //std::cout << "val = " << std::numeric_limits<double>::min() << std::endl;
502  allMin.push_back(std::numeric_limits<double>::max());
503  allMax.push_back(std::numeric_limits<double>::min());
504  //std::cout << "Min = " << allMin[i] << std::endl;
505  }
507  {for (iteGN1.begin(); iteGN1.end()!=true; iteGN1.next()) {
508  for (unsigned int i=0; i<dimension; ++i) {
509  //std::cout << "coord = " << iteGN1.current()->getCoordinate(i) << std::endl;
510  if (iteGN1.current()->getCoordinate(i) < allMin[i])
511  allMin[i] = iteGN1.current()->getCoordinate(i);
512  if (iteGN1.current()->getCoordinate(i) > allMax[i])
513  allMax[i] = iteGN1.current()->getCoordinate(i);
514  }
515  }}
516  std::vector< double > diff;
517  for (unsigned int i=0; i<dimension; ++i)
518  diff.push_back(allMax[i] - allMin[i]);
519  std::cout << std::endl << "Minima: ";
520  for (unsigned int i=0; i<dimension; ++i)
521  std::cout << allMin[i] << " ";
522  std::cout << std::endl << std::endl << "Maxima: ";
523  for (unsigned int i=0; i<dimension; ++i)
524  std::cout << allMax[i] << " ";
525  std::cout << std::endl << std::endl << "Range: ";
526  for (unsigned int i=0; i<dimension; ++i)
527  std::cout << diff[i] << " ";
528  std::cout << std::endl;
529  }
530  }
531  }
532  catch(std::invalid_argument& excep) {
533  cerr << "TIME=" << this_timer.elapsed() << std::endl;
534  cerr << "Invalid argument exception " << excep.what() << std::endl;
535  return EXIT_FAILURE;
536  }
537  catch(std::out_of_range& excep) {
538  cerr << "TIME=" << this_timer.elapsed() << std::endl;
539  cerr << "Out of range exception " << excep.what() << std::endl;
540  return EXIT_FAILURE;
541  }
542  catch(std::ios_base::failure& excep) {
543  cerr << "TIME=" << this_timer.elapsed() << std::endl;
544  cerr << "In/out exception " << excep.what() << std::endl;
545  return EXIT_FAILURE;
546  }
547  catch(std::domain_error& excep) {
548  cerr << "TIME=" << this_timer.elapsed() << std::endl;
549  cerr << "Domain error exception " << excep.what() << std::endl;
550  return EXIT_FAILURE;
551  }
552  catch(std::logic_error& excep) {
553  cerr << "TIME=" << this_timer.elapsed() << std::endl;
554  cerr << "Logic error exception " << excep.what() << std::endl;
555  return EXIT_FAILURE;
556  }
557  catch(...) {
558  cerr << "TIME=" << this_timer.elapsed() << std::endl;
559  cerr << "Unexpected exception caught !" << std::endl;
560  return EXIT_FAILURE;
561  }
562  //C->dump();
563  if (check_all == true)
564  C->checkTopologyAndGeometry();
565  else if (CHCK_EQ == true) {
566  if ((p1==true && p2==true) || (c1==true && c2==true))
567  A->checkEquality(B);
568  else {
569  cerr << "ERROR 2 polytopes or polyhedral cones are needed to check equality." << std::endl;
570  return EXIT_FAILURE;
571  }
572  }
573  else if (computeDistances == true) {
574  if (vertexToComputeDistances >= 0) {
575  C->checkGenerator(vertexToComputeDistances, std::cout);
576  }
577  else if (facetToComputeDistances >= 0) {
578  C->checkFacet(facetToComputeDistances, std::cout);
579  }
580  }
581 
582  return EXIT_SUCCESS;
583 }
politopix_VERSION_MINOR
#define politopix_VERSION_MINOR
Definition: Config.h:3
PolyhedralCone_Rn
Model a polyhedral cone using its two equivalent definitions : the convex hull and the half-space int...
Definition: PolyhedralCone_Rn.h:47
politopix_VERSION_MAJOR
#define politopix_VERSION_MAJOR
Definition: Config.h:2
Config.h
Rn::getDimension
static polito_EXPORT unsigned int getDimension()
Return the dimension of the cartesian space we work in.
Definition: Rn.cpp:29
PolyhedralAlgorithms_Rn.h
constIteratorOfListOfGeometricObjects::current
const GEOMETRIC_OBJECT current()
Return the current geometric element.
Definition: GeometricObjectIterator_Rn.h:177
constIteratorOfListOfGeometricObjects::end
bool end() const
Tell whether we have reached the end of the list.
Definition: GeometricObjectIterator_Rn.h:174
DoubleDescriptionFromGenerators::Compute
static int Compute(boost::shared_ptr< Polytope_Rn > &pol, double bb_size=1000.)
Use the polarity to get the facets from the generators.
Definition: PolyhedralAlgorithms_Rn.cpp:1634
constIteratorOfListOfGeometricObjects
This class is designed to run the list of all geometric objects representing a polytope.
Definition: GeometricObjectIterator_Rn.h:142
politopix_VERSION_PATCH
#define politopix_VERSION_PATCH
Definition: Config.h:4
DoubleDescription
The algorithm implemented here is an incremental algorithm as mentioned in How Good are Convex Hull ...
Definition: DoubleDescription_Rn.h:86
TopGeomTools::PolarPolytope
static int PolarPolytope(const boost::shared_ptr< Polytope_Rn > &original_pol, boost::shared_ptr< Polytope_Rn > &polar_pol, bool forceComputation=true, double bb_size=1000.)
Compute the polar polytope.
Definition: PolyhedralAlgorithms_Rn.cpp:1428
VolumeOfPolytopes_Rn::compute
static double compute(const boost::shared_ptr< Polytope_Rn > P)
Return the volume of the given polytope P.
Definition: VolumeOfPolytopes_Rn.h:153
constIteratorOfListOfGeometricObjects::begin
void begin()
Move the iterator at the beginning of the list.
Definition: GeometricObjectIterator_Rn.h:150
Rn::setTolerance
static polito_EXPORT void setTolerance(double t)
Give the minimum distance between two points.
Definition: Rn.cpp:33
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
Rn::setDimension
static polito_EXPORT void setDimension(unsigned int dim)
Set the dimension for the cartesian space we work in.
Definition: Rn.cpp:27
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
Polytope_Rn
Model a polytope using its two equivalent definitions : the convex hull and the half-space intersecti...
Definition: Polytope_Rn.h:36
main
int main(int argc, char *argv[])
Definition: main.cpp:59
MinkowskiSum
Compute the Minkowski sum of two polytopes.
Definition: PolyhedralAlgorithms_Rn.h:138