22 #include <boost/timer.hpp>
33 catch(ios_base::failure& except) {
34 cerr <<
"In/out exception in politopixAPI::savePolytope(const string&, boost::shared_ptr<Polytope_Rn>&): " << except.what() << endl;
45 catch(ios_base::failure& except) {
46 cerr <<
"In/out exception in politopixAPI::loadPolytope(const string&, boost::shared_ptr<Polytope_Rn>&): " << except.what() << endl;
57 catch(ios_base::failure& except) {
58 cerr <<
"In/out exception in politopixAPI::savePolyhedralCone(const string&, boost::shared_ptr<PolyhedralCone_Rn>&): " << except.what() << endl;
68 catch(ios_base::failure& except) {
69 cerr <<
"In/out exception in politopixAPI::loadPolyhedralCone(const string&, boost::shared_ptr<PolyhedralCone_Rn>&): " << except.what() << endl;
86 boost::timer this_timer;
89 if (A->numberOfGenerators() == 0) {
91 A->createBoundingBox(bb_size);
95 unsigned int truncationStep = 2*A->dimension();
97 boost::shared_ptr<PolyhedralCone_Rn>,
100 DD(A, lexmin_ite, truncationStep);
102 else if (A->numberOfHalfSpaces() == 0) {
106 catch(invalid_argument& except) {
107 cerr <<
"TIME=" << this_timer.elapsed() << endl;
108 cerr <<
"Invalid argument exception in politopixAPI::computeDoubleDescriptionWithoutCheck() " << except.what() << endl;
111 catch(out_of_range& except) {
112 cerr <<
"TIME=" << this_timer.elapsed() << endl;
113 cerr <<
"Out of range exception in politopixAPI::computeDoubleDescriptionWithoutCheck() " << except.what() << endl;
116 catch(ios_base::failure& except) {
117 cerr <<
"TIME=" << this_timer.elapsed() << endl;
118 cerr <<
"In/out exception in politopixAPI::computeDoubleDescriptionWithoutCheck() " << except.what() << endl;
121 catch(logic_error& except) {
122 cerr <<
"TIME=" << this_timer.elapsed() << endl;
123 cerr <<
"Logic error exception in politopixAPI::computeDoubleDescriptionWithoutCheck() " << except.what() << endl;
127 cerr <<
"TIME=" << this_timer.elapsed() << endl;
128 cerr <<
"Unexpected exception caught in politopixAPI::computeDoubleDescriptionWithoutCheck() !" << endl;
131 cout <<
"TIME=" << this_timer.elapsed() << endl;
144 const boost::shared_ptr<Polytope_Rn>& B) {
146 unsigned int truncationStep = A->numberOfHalfSpaces();
147 for (iteHSB.
begin(); iteHSB.
end()!=
true; iteHSB.
next()) {
148 A->addHalfSpace(iteHSB.
current());
150 boost::timer this_timer;
155 boost::shared_ptr<PolyhedralCone_Rn>,
158 DD(A, lexmin_ite, truncationStep);
160 catch(invalid_argument& except) {
161 cerr <<
"TIME=" << this_timer.elapsed() << endl;
162 cerr <<
"Invalid argument exception in politopixAPI::computeIntersection() " << except.what() << endl;
165 catch(out_of_range& except) {
166 cerr <<
"TIME=" << this_timer.elapsed() << endl;
167 cerr <<
"Out of range exception in politopixAPI::computeIntersection() " << except.what() << endl;
170 catch(ios_base::failure& except) {
171 cerr <<
"TIME=" << this_timer.elapsed() << endl;
172 cerr <<
"In/out exception in politopixAPI::computeIntersection() " << except.what() << endl;
175 catch(logic_error& except) {
176 cerr <<
"TIME=" << this_timer.elapsed() << endl;
177 cerr <<
"Logic error exception in politopixAPI::computeIntersection() " << except.what() << endl;
181 cerr <<
"TIME=" << this_timer.elapsed() << endl;
182 cerr <<
"Unexpected exception caught in politopixAPI::computeIntersection() !" << endl;
185 cout <<
"TIME=" << this_timer.elapsed() << endl;
187 if (A->numberOfGenerators()==0 && A->numberOfHalfSpaces()==0) {
188 cout <<
"The result is empty." << std::endl;
196 boost::shared_ptr<Polytope_Rn>& C) {
199 for (iteHS0.
begin(); iteHS0.
end()!=
true; iteHS0.
next()) {
200 C->addGenerator(iteHS0.
current());
204 for (iteHS1.
begin(); iteHS1.
end()!=
true; iteHS1.
next()) {
205 C->addHalfSpace(iteHS1.
current());
209 for (iteHS2.
begin(); iteHS2.
end()!=
true; iteHS2.
next()) {
210 C->addHalfSpace(iteHS2.
current());
213 boost::timer this_timer;
216 unsigned int truncationStep = A->numberOfHalfSpaces();
221 boost::shared_ptr<PolyhedralCone_Rn>,
224 DD(C, lexmin_ite, truncationStep);
226 catch(invalid_argument& except) {
227 cerr <<
"TIME=" << this_timer.elapsed() << endl;
228 cerr <<
"Invalid argument exception in politopixAPI::computeIntersection() " << except.what() << endl;
231 catch(out_of_range& except) {
232 cerr <<
"TIME=" << this_timer.elapsed() << endl;
233 cerr <<
"Out of range exception in politopixAPI::computeIntersection() " << except.what() << endl;
236 catch(ios_base::failure& except) {
237 cerr <<
"TIME=" << this_timer.elapsed() << endl;
238 cerr <<
"In/out exception in politopixAPI::computeIntersection() " << except.what() << endl;
241 catch(logic_error& except) {
242 cerr <<
"TIME=" << this_timer.elapsed() << endl;
243 cerr <<
"Logic error exception in politopixAPI::computeIntersection() " << except.what() << endl;
247 cerr <<
"TIME=" << this_timer.elapsed() << endl;
248 cerr <<
"Unexpected exception caught in politopixAPI::computeIntersection() !" << endl;
251 cout <<
"TIME=" << this_timer.elapsed() << endl;
253 if (C->numberOfGenerators()==0 && C->numberOfHalfSpaces()==0) {
254 cout <<
"The result is empty." << std::endl;
262 const boost::shared_ptr<Polytope_Rn>& B) {
263 boost::timer this_timer;
264 bool isInside =
false;
266 isInside = A->isIncluded(B);
268 catch(invalid_argument& except) {
269 cerr <<
"TIME=" << this_timer.elapsed() << endl;
270 cerr <<
"Invalid argument exception in politopixAPI::isIncluded() " << except.what() << endl;
273 catch(out_of_range& except) {
274 cerr <<
"TIME=" << this_timer.elapsed() << endl;
275 cerr <<
"Out of range exception in politopixAPI::isIncluded() " << except.what() << endl;
278 catch(ios_base::failure& except) {
279 cerr <<
"TIME=" << this_timer.elapsed() << endl;
280 cerr <<
"In/out exception in politopixAPI::isIncluded() " << except.what() << endl;
283 catch(logic_error& except) {
284 cerr <<
"TIME=" << this_timer.elapsed() << endl;
285 cerr <<
"Logic error exception in politopixAPI::isIncluded() " << except.what() << endl;
289 cerr <<
"TIME=" << this_timer.elapsed() << endl;
290 cerr <<
"Unexpected exception caught in politopixAPI::isIncluded() !" << endl;
293 cout <<
"TIME=" << this_timer.elapsed() << endl;
299 const boost::shared_ptr<Polytope_Rn>& B) {
301 unsigned int truncationStep = A->numberOfHalfSpaces();
302 for (iteHSB.
begin(); iteHSB.
end()!=
true; iteHSB.
next()) {
303 A->addHalfSpace(iteHSB.
current());
305 boost::timer this_timer;
310 boost::shared_ptr<PolyhedralCone_Rn>,
313 DD(A, lexmin_ite, truncationStep);
315 catch(invalid_argument& except) {
316 cerr <<
"TIME=" << this_timer.elapsed() << endl;
317 cerr <<
"Invalid argument exception in politopixAPI::computeIntersectionWithoutCheck() " << except.what() << endl;
320 catch(out_of_range& except) {
321 cerr <<
"TIME=" << this_timer.elapsed() << endl;
322 cerr <<
"Out of range exception in politopixAPI::computeIntersectionWithoutCheck() " << except.what() << endl;
325 catch(ios_base::failure& except) {
326 cerr <<
"TIME=" << this_timer.elapsed() << endl;
327 cerr <<
"In/out exception in politopixAPI::computeIntersectionWithoutCheck() " << except.what() << endl;
330 catch(logic_error& except) {
331 cerr <<
"TIME=" << this_timer.elapsed() << endl;
332 cerr <<
"Logic error exception in politopixAPI::computeIntersectionWithoutCheck() " << except.what() << endl;
336 cerr <<
"TIME=" << this_timer.elapsed() << endl;
337 cerr <<
"Unexpected exception caught in politopixAPI::computeIntersectionWithoutCheck() !" << endl;
342 if (A->numberOfGenerators()==0 && A->numberOfHalfSpaces()==0) {
351 const boost::shared_ptr<Polytope_Rn>& B, boost::shared_ptr<Polytope_Rn>& C) {
352 boost::timer this_timer;
356 catch(invalid_argument& except) {
357 cerr <<
"TIME=" << this_timer.elapsed() << endl;
358 cerr <<
"Invalid argument exception in politopixAPI::computeMinkowskiSumOfPolytopes() " << except.what() << endl;
361 catch(out_of_range& except) {
362 cerr <<
"TIME=" << this_timer.elapsed() << endl;
363 cerr <<
"Out of range exception in politopixAPI::computeMinkowskiSumOfPolytopes() " << except.what() << endl;
366 catch(ios_base::failure& except) {
367 cerr <<
"TIME=" << this_timer.elapsed() << endl;
368 cerr <<
"In/out exception in politopixAPI::computeMinkowskiSumOfPolytopes() " << except.what() << endl;
371 catch(logic_error& except) {
372 cerr <<
"TIME=" << this_timer.elapsed() << endl;
373 cerr <<
"Logic error exception in politopixAPI::computeMinkowskiSumOfPolytopes() " << except.what() << endl;
377 cerr <<
"TIME=" << this_timer.elapsed() << endl;
378 cerr <<
"Unexpected exception caught in politopixAPI::computeMinkowskiSumOfPolytopes() !" << endl;
381 cout <<
"TIME=" << this_timer.elapsed() << endl;
387 const std::vector< boost::shared_ptr<Polytope_Rn> >& arrayOfPol,
388 boost::shared_ptr<Polytope_Rn>& C) {
389 boost::timer this_timer;
393 catch(invalid_argument& except) {
394 cerr <<
"TIME=" << this_timer.elapsed() << endl;
395 cerr <<
"Invalid argument exception in politopixAPI::computeMinkowskiSumOfPolytopes() " << except.what() << endl;
398 catch(out_of_range& except) {
399 cerr <<
"TIME=" << this_timer.elapsed() << endl;
400 cerr <<
"Out of range exception in politopixAPI::computeMinkowskiSumOfPolytopes() " << except.what() << endl;
403 catch(ios_base::failure& except) {
404 cerr <<
"TIME=" << this_timer.elapsed() << endl;
405 cerr <<
"In/out exception in politopixAPI::computeMinkowskiSumOfPolytopes() " << except.what() << endl;
408 catch(logic_error& except) {
409 cerr <<
"TIME=" << this_timer.elapsed() << endl;
410 cerr <<
"Logic error exception in politopixAPI::computeMinkowskiSumOfPolytopes() " << except.what() << endl;
414 cerr <<
"TIME=" << this_timer.elapsed() << endl;
415 cerr <<
"Unexpected exception caught in politopixAPI::computeMinkowskiSumOfPolytopes() !" << endl;
418 cout <<
"TIME=" << this_timer.elapsed() << endl;
424 const boost::shared_ptr<Polytope_Rn>& B,
425 boost::shared_ptr<Polytope_Rn>& C,
426 const std::vector< std::vector<int> >& genitorsOfGeneratorsA,
427 const std::vector< std::vector<int> >& genitorsOfGeneratorsB,
428 std::vector< std::vector<int> >& traceGenerators) {
429 boost::timer this_timer;
431 MinkowskiSum Ope(A,B,C,genitorsOfGeneratorsA,genitorsOfGeneratorsB,traceGenerators);
433 catch(invalid_argument& except) {
434 cerr <<
"TIME=" << this_timer.elapsed() << endl;
435 cerr <<
"Invalid argument exception in politopixAPI::computeMinkowskiSumOfPolytopes() " << except.what() << endl;
438 catch(out_of_range& except) {
439 cerr <<
"TIME=" << this_timer.elapsed() << endl;
440 cerr <<
"Out of range exception in politopixAPI::computeMinkowskiSumOfPolytopes() " << except.what() << endl;
443 catch(ios_base::failure& except) {
444 cerr <<
"TIME=" << this_timer.elapsed() << endl;
445 cerr <<
"In/out exception in politopixAPI::computeMinkowskiSumOfPolytopes() " << except.what() << endl;
448 catch(logic_error& except) {
449 cerr <<
"TIME=" << this_timer.elapsed() << endl;
450 cerr <<
"Logic error exception in politopixAPI::computeMinkowskiSumOfPolytopes() " << except.what() << endl;
454 cerr <<
"TIME=" << this_timer.elapsed() << endl;
455 cerr <<
"Unexpected exception caught in politopixAPI::computeMinkowskiSumOfPolytopes() !" << endl;
458 cout <<
"TIME=" << this_timer.elapsed() << endl;
464 const boost::shared_ptr<Polytope_Rn>& B,
bool getFaceMapping) {
466 boost::timer this_timer;
468 ret_val = A->checkEquality(B, getFaceMapping);
470 catch(invalid_argument& except) {
471 cerr <<
"TIME=" << this_timer.elapsed() << endl;
472 cerr <<
"Invalid argument exception in politopixAPI::checkEqualityOfPolytopes() " << except.what() << endl;
475 catch(out_of_range& except) {
476 cerr <<
"TIME=" << this_timer.elapsed() << endl;
477 cerr <<
"Out of range exception in politopixAPI::checkEqualityOfPolytopes() " << except.what() << endl;
480 catch(ios_base::failure& except) {
481 cerr <<
"TIME=" << this_timer.elapsed() << endl;
482 cerr <<
"In/out exception in politopixAPI::checkEqualityOfPolytopes() " << except.what() << endl;
485 catch(logic_error& except) {
486 cerr <<
"TIME=" << this_timer.elapsed() << endl;
487 cerr <<
"Logic error exception in politopixAPI::checkEqualityOfPolytopes() " << except.what() << endl;
491 cerr <<
"TIME=" << this_timer.elapsed() << endl;
492 cerr <<
"Unexpected exception caught in politopixAPI::checkEqualityOfPolytopes() " << endl;
495 cout <<
"TIME=" << this_timer.elapsed() << endl;
501 const boost::shared_ptr<Polytope_Rn>& B) {
503 boost::timer this_timer;
505 ret_val = A->checkEqualityOfVertices(B);
507 catch(invalid_argument& except) {
508 cerr <<
"TIME=" << this_timer.elapsed() << endl;
509 cerr <<
"Invalid argument exception in politopixAPI::checkEqualityOfVertices() " << except.what() << endl;
512 catch(out_of_range& except) {
513 cerr <<
"TIME=" << this_timer.elapsed() << endl;
514 cerr <<
"Out of range exception in politopixAPI::checkEqualityOfVertices() " << except.what() << endl;
517 catch(ios_base::failure& except) {
518 cerr <<
"TIME=" << this_timer.elapsed() << endl;
519 cerr <<
"In/out exception in politopixAPI::checkEqualityOfVertices() " << except.what() << endl;
522 catch(logic_error& except) {
523 cerr <<
"TIME=" << this_timer.elapsed() << endl;
524 cerr <<
"Logic error exception in politopixAPI::checkEqualityOfVertices() " << except.what() << endl;
528 cerr <<
"TIME=" << this_timer.elapsed() << endl;
529 cerr <<
"Unexpected exception caught in politopixAPI::checkEqualityOfVertices() " << endl;
532 cout <<
"TIME=" << this_timer.elapsed() << endl;
539 boost::timer this_timer;
543 catch(std::invalid_argument& e) {
544 std::cerr <<
"politopixAPI::computeVolume() : invalid argument exception " << e.what() << std::endl;
547 catch(std::out_of_range& e) {
548 std::cerr <<
"politopixAPI::computeVolume() : out of range exception " << e.what() << std::endl;
551 catch(std::ios_base::failure& e) {
552 std::cerr <<
"politopixAPI::computeVolume() : in/out exception " << e.what() << std::endl;
556 std::cerr <<
"politopixAPI::computeVolume() : unexpected exception caught !" << std::endl;
559 cout <<
"TIME=" << this_timer.elapsed() << endl;
565 return A->checkTopologyAndGeometry(check_all) ==
true ?
TEST_OK :
TEST_KO;
570 A->createBoundingBox(M);
578 {
for (
unsigned int i=0; i<dimension; ++i) {
586 {
for (
unsigned int i=0; i<dimension; ++i) {
587 boost::shared_ptr<HalfSpace_Rn> HS;
590 for (
unsigned int coord_count=0; coord_count<dimension; coord_count++) {
591 if (coord_count == i)
592 HS->setCoefficient(coord_count, 1.);
594 HS->setCoefficient(coord_count, 0.);
599 {
for (
unsigned int i=0; i<dimension; ++i) {
600 boost::shared_ptr<HalfSpace_Rn> HS;
603 for (
unsigned int coord_count=0; coord_count<dimension; coord_count++) {
604 if (coord_count == i)
605 HS->setCoefficient(coord_count, -1.);
607 HS->setCoefficient(coord_count, 0.);
623 const boost::shared_ptr<Polytope_Rn>& A,
624 const boost::shared_ptr<Polytope_Rn>& B,
625 boost::shared_ptr<Polytope_Rn>& C,
626 const std::set< unsigned int >& firstOperandCaps,
627 const std::set< unsigned int >& secondOperandCaps,
628 std::set< unsigned int >& newCaps,
630 boost::timer this_timer;
634 catch(invalid_argument& except) {
635 cerr <<
"TIME=" << this_timer.elapsed() << endl;
636 cerr <<
"Invalid argument exception in politopixAPI::PseudoIntersection() " << except.what() << endl;
639 catch(out_of_range& except) {
640 cerr <<
"TIME=" << this_timer.elapsed() << endl;
641 cerr <<
"Out of range exception in politopixAPI::PseudoIntersection() " << except.what() << endl;
644 catch(ios_base::failure& except) {
645 cerr <<
"TIME=" << this_timer.elapsed() << endl;
646 cerr <<
"In/out exception in politopixAPI::PseudoIntersection() " << except.what() << endl;
649 catch(logic_error& except) {
650 cerr <<
"TIME=" << this_timer.elapsed() << endl;
651 cerr <<
"Logic error exception in politopixAPI::PseudoIntersection() " << except.what() << endl;
655 cerr <<
"TIME=" << this_timer.elapsed() << endl;
656 cerr <<
"Unexpected exception caught in politopixAPI::PseudoIntersection() !" << endl;
659 cout <<
"TIME=" << this_timer.elapsed() << endl;
661 if (C->numberOfGenerators()==0 && C->numberOfHalfSpaces()==0) {
662 cout <<
"The result is empty." << std::endl;
670 const boost::shared_ptr<Polytope_Rn>& A,
671 const boost::shared_ptr<Polytope_Rn>& B,
672 boost::shared_ptr<Polytope_Rn>& C,
673 const std::set< unsigned int >& firstOperandCaps,
674 const std::set< unsigned int >& secondOperandCaps,
675 std::set< unsigned int >& newCaps,
677 boost::timer this_timer;
681 catch(invalid_argument& except) {
682 cerr <<
"TIME=" << this_timer.elapsed() << endl;
683 cerr <<
"Invalid argument exception in politopixAPI::pseudoSum() " << except.what() << endl;
686 catch(out_of_range& except) {
687 cerr <<
"TIME=" << this_timer.elapsed() << endl;
688 cerr <<
"Out of range exception in politopixAPI::pseudoSum() " << except.what() << endl;
691 catch(ios_base::failure& except) {
692 cerr <<
"TIME=" << this_timer.elapsed() << endl;
693 cerr <<
"In/out exception in politopixAPI::pseudoSum() " << except.what() << endl;
696 catch(logic_error& except) {
697 cerr <<
"TIME=" << this_timer.elapsed() << endl;
698 cerr <<
"Logic error exception in politopixAPI::pseudoSum() " << except.what() << endl;
702 cerr <<
"TIME=" << this_timer.elapsed() << endl;
703 cerr <<
"Unexpected exception caught in politopixAPI::pseudoSum() !" << endl;
706 cout <<
"TIME=" << this_timer.elapsed() << endl;
708 if (C->numberOfGenerators()==0 && C->numberOfHalfSpaces()==0) {
709 cout <<
"The result is empty." << std::endl;
717 const boost::shared_ptr<Polytope_Rn>& inputSpace,
718 const std::vector<Point_Rn>& listOfSeeds,
719 std::vector< boost::shared_ptr<Polytope_Rn> >& VoronoiCells,
721 boost::timer this_timer;
722 boost::shared_ptr<Voronoi_Rn> VD;
737 boost::shared_ptr<CellByCellVoronoiDistNgb> VDd = boost::static_pointer_cast<CellByCellVoronoiDistNgb>(VD);
738 VDd->setAverageNumberOfNeighbours(1.);
742 boost::shared_ptr<CellByCellVoronoiDistNgb> VDd = boost::static_pointer_cast<CellByCellVoronoiDistNgb>(VD);
743 VDd->setAverageNumberOfNeighbours(10.);
747 boost::shared_ptr<CellByCellVoronoiDistNgb> VDd = boost::static_pointer_cast<CellByCellVoronoiDistNgb>(VD);
748 VDd->setAverageNumberOfNeighbours(20.);
752 boost::shared_ptr<CellByCellVoronoiDistNgb> VDd = boost::static_pointer_cast<CellByCellVoronoiDistNgb>(VD);
753 VDd->setAverageNumberOfNeighbours(30.);
757 boost::shared_ptr<CellByCellVoronoiDistNgb> VDd = boost::static_pointer_cast<CellByCellVoronoiDistNgb>(VD);
758 VDd->setAverageNumberOfNeighbours(40.);
761 throw std::invalid_argument(
"politopixAPI::computeVoronoiDiagram() vorAlgo out of range");
765 VoronoiCells = VD->getVoronoiCells();
767 catch(length_error& except) {
768 cerr <<
"TIME=" << this_timer.elapsed() << endl;
769 cerr <<
"Length error exception in politopixAPI::computeVoronoiDiagram() " << except.what() << endl;
773 cerr <<
"TIME=" << this_timer.elapsed() << endl;
774 cerr <<
"Unexpected exception caught in politopixAPI::computeVoronoiDiagram() !" << endl;
777 cout <<
"TIME=" << this_timer.elapsed() << endl;
778 return VD->checkTopologyAndGeometry() ==
true ?
TEST_OK :
TEST_KO;