politopix  5.0.0
test_politopix.cpp
Go to the documentation of this file.
1 // test_politopix allows to make computations on polytopes such as finding vertices, intersecting, Minkowski sums, ...
2 // Copyright (C) 2014-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 
20 // g++ -W -Wall -Wextra -Wswitch -Wformat -Wchar-subscripts -Wparentheses -Wmultichar -Wtrigraphs -Wpointer-arith -Wcast-align -Wreturn-type -Wshadow -Wundef -Woverloaded-virtual -Wno-unused-function -O3 -fno-strict-aliasing test_politopix.cpp -I /usr/include/boost/ -I $pol/trunk $pol/build/libpolito.a -o test_politopix
21 // To run the tests (the last one takes far longer):
22 // ./test_politopix.exe
23 // ./test_politopix.exe piston
24 
25 #include <boost/test/minimal.hpp>
26 #include <boost/shared_ptr.hpp>
27 #include <boost/timer.hpp>
28 #include <iostream>
29 #include <string.h>
30 #include <utility>
31 #include <vector>
32 #include <cmath>
33 #include "politopixAPI.h"
34 
35 using namespace std;
36 
37 void computeFlatPolytope(const std::vector< boost::shared_ptr<Hyperplane_Rn> >& vectOfHyp, boost::shared_ptr<Polytope_Rn> fptop_1, std::string compPol, bool strongRedundancy) {
38  unsigned int truncationStep = fptop_1->numberOfHalfSpaces();
39  std::vector< boost::shared_ptr<Hyperplane_Rn> >::const_iterator pos;
40  for (pos = vectOfHyp.begin(); pos != vectOfHyp.end(); ++pos)
41  fptop_1->addHalfSpace(*pos);
42  //fptop_1->dump(std::cout);
43  //std::cout << std::endl << "=== Double description begins ===" << std::endl << std::endl;
44  if (!strongRedundancy) {
45  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > lexmin_ite2(fptop_1->getListOfHalfSpaces());
48  boost::shared_ptr<Polytope_Rn>,
50  NoRedundancyProcessing< boost::shared_ptr<Polytope_Rn> > > DD2(fptop_1, lexmin_ite2, NRP2, truncationStep);
51  }
52  else {
53  //politopixAPI::computeDoubleDescription(fptop_1, 10000.);
54  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > lexmin_ite2(fptop_1->getListOfHalfSpaces());
55  StrongRedundancyProcessing< boost::shared_ptr<Polytope_Rn> > NRP2(fptop_1->neigbourhoodCondition());
57  boost::shared_ptr<Polytope_Rn>,
59  StrongRedundancyProcessing< boost::shared_ptr<Polytope_Rn> > > DD2(fptop_1, lexmin_ite2, NRP2, truncationStep);
60  }
61  constIteratorOfListOfGeometricObjects< boost::shared_ptr<Generator_Rn> > fiteGN1(fptop_1->getListOfGenerators());
62  for (fiteGN1.begin(); fiteGN1.end()!=true; fiteGN1.next()) {
63  fiteGN1.current()->dump(std::cout);
64  {
65  for (unsigned int ii=0; ii<fiteGN1.current()->numberOfFacets(); ii++) {
66  unsigned int fctNumber = fptop_1->getHalfSpaceNumber( fiteGN1.current()->getFacet(ii) );
67  std::cout << " " << fctNumber;
68  }
69  }
70  std::cout << std::endl;
71  }
72  fptop_1->dump(std::cout);
73  boost::shared_ptr<Polytope_Rn> ftop_1Test(new Polytope_Rn());
74  BOOST_REQUIRE( politopixAPI::loadPolytope(compPol, ftop_1Test) == TEST_OK );
75  BOOST_REQUIRE( politopixAPI::checkEqualityOfVertices(ftop_1Test, fptop_1) == TEST_OK );
76  //BOOST_REQUIRE( politopixAPI::savePolytope(string("restruncatedCube1.ptop"), fptop_1) == TEST_OK );
77 }
78 
79 
80 int test_main(int argc, char* argv[]) {
81 
82  cout << "####################" << endl;
83  cout << "# VORONOI DIAGRAMS #" << endl;
84  cout << "####################" << endl;
86  Rn::setTolerance(0.000001);
87  boost::shared_ptr<Polytope_Rn> inputSpace(new Polytope_Rn());
88  inputSpace->createBoundingBox(10);
89  Point_Rn P1(2), P2(2), P3(2), P4(2), P5(2);
90  P1.setCoordinate(0,1);
91  P1.setCoordinate(1,1);
92  P2.setCoordinate(0,8);
93  P2.setCoordinate(1,4);
94  P3.setCoordinate(0,-7);
95  P3.setCoordinate(1,7);
96  P4.setCoordinate(0,-4);
97  P4.setCoordinate(1,-2);
98  P5.setCoordinate(0,3);
99  P5.setCoordinate(1,-3);
100  std::vector<Point_Rn> listOfPoints;
101  listOfPoints.push_back(P1);listOfPoints.push_back(P2);listOfPoints.push_back(P3);listOfPoints.push_back(P4);listOfPoints.push_back(P5);
102  std::vector< boost::shared_ptr<Polytope_Rn> > allVoronoiCells;
103  BOOST_REQUIRE( politopixAPI::computeVoronoiDiagram(inputSpace, listOfPoints, allVoronoiCells) == TEST_OK );
104  string vorPath = string("./test/VORONOI/2D/");
105  boost::shared_ptr<Polytope_Rn> Vor_Test(new Polytope_Rn());
106  Vor_Test.reset(new Polytope_Rn());
107  BOOST_REQUIRE( politopixAPI::loadPolytope(vorPath + string("cell0.ptop"), Vor_Test) == TEST_OK );
108  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells[0], Vor_Test) == TEST_OK );
109  Vor_Test.reset(new Polytope_Rn());
110  BOOST_REQUIRE( politopixAPI::loadPolytope(vorPath + string("cell1.ptop"), Vor_Test) == TEST_OK );
111  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells[1], Vor_Test) == TEST_OK );
112  Vor_Test.reset(new Polytope_Rn());
113  BOOST_REQUIRE( politopixAPI::loadPolytope(vorPath + string("cell2.ptop"), Vor_Test) == TEST_OK );
114  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells[2], Vor_Test) == TEST_OK );
115  Vor_Test.reset(new Polytope_Rn());
116  BOOST_REQUIRE( politopixAPI::loadPolytope(vorPath + string("cell3.ptop"), Vor_Test) == TEST_OK );
117  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells[3], Vor_Test) == TEST_OK );
118  Vor_Test.reset(new Polytope_Rn());
119  BOOST_REQUIRE( politopixAPI::loadPolytope(vorPath + string("cell4.ptop"), Vor_Test) == TEST_OK );
120  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells[4], Vor_Test) == TEST_OK );
121 
122  Rn::setDimension(3);
123  Rn::setTolerance(0.000001);
124  boost::shared_ptr<Polytope_Rn> inputSpaceAngers(new Polytope_Rn());
125  inputSpaceAngers->createBoundingBox(0.5);
126  //Point_Rn P1(2), P2(2), P3(2), P4(2), P5(2);
127  string vorPath3DAngers = string("./test/VORONOI/3D/Angers/");
128  // Load the list of 3D germs as the V-description of a polytope.
129  boost::shared_ptr<Polytope_Rn> listOfPointsAsVDesc(new Polytope_Rn());
130  BOOST_REQUIRE( politopixAPI::loadPolytope(vorPath3DAngers + string("seedsAngers.txt"), listOfPointsAsVDesc) == TEST_OK );
131  std::vector<Point_Rn> listOfPoints3DAngers;
132  constIteratorOfListOfGeometricObjects< boost::shared_ptr<Generator_Rn> > iteGN(listOfPointsAsVDesc->getListOfGenerators());
133  {for (iteGN.begin(); iteGN.end()!=true; iteGN.next()) {
134  listOfPoints3DAngers.push_back(
135  Point_Rn(iteGN.current()->getCoordinate(0), iteGN.current()->getCoordinate(1), iteGN.current()->getCoordinate(2)) );
136  }}
137  // Incremental algorithm
138  std::vector< boost::shared_ptr<Polytope_Rn> > allVoronoiCells_Angers0;
139  BOOST_REQUIRE( politopixAPI::computeVoronoiDiagram(inputSpaceAngers, listOfPoints3DAngers, allVoronoiCells_Angers0, Voronoi_Rn::Incremental) == TEST_OK );
140  // Cell by cell algorithm
141  std::vector< boost::shared_ptr<Polytope_Rn> > allVoronoiCells_Angers1;
142  BOOST_REQUIRE( politopixAPI::computeVoronoiDiagram(inputSpaceAngers, listOfPoints3DAngers, allVoronoiCells_Angers1, Voronoi_Rn::CellByCell) == TEST_OK );
143  // Cell by cell algorithm with distances between seeds
144  std::vector< boost::shared_ptr<Polytope_Rn> > allVoronoiCells_Angers2;
145  BOOST_REQUIRE( politopixAPI::computeVoronoiDiagram(inputSpaceAngers, listOfPoints3DAngers, allVoronoiCells_Angers2, Voronoi_Rn::CellByCellDist) == TEST_OK );
146  // Cell by cell algorithm with distances and neighbours between seeds
147  std::vector< boost::shared_ptr<Polytope_Rn> > allVoronoiCells_Angers3;
148  BOOST_REQUIRE( politopixAPI::computeVoronoiDiagram(inputSpaceAngers, listOfPoints3DAngers, allVoronoiCells_Angers3, Voronoi_Rn::CellByCellDistNgb) == TEST_OK );
149  // Cell by cell algorithm with distances and neighbours between seeds with 1% of partial sorting
150  std::vector< boost::shared_ptr<Polytope_Rn> > allVoronoiCells_Angers4;
151  BOOST_REQUIRE( politopixAPI::computeVoronoiDiagram(inputSpaceAngers, listOfPoints3DAngers, allVoronoiCells_Angers4, Voronoi_Rn::CellByCellDistNgb_1pc) == TEST_OK );
152  // Cell by cell algorithm with distances and neighbours between seeds with 10% of partial sorting
153  std::vector< boost::shared_ptr<Polytope_Rn> > allVoronoiCells_Angers5;
154  BOOST_REQUIRE( politopixAPI::computeVoronoiDiagram(inputSpaceAngers, listOfPoints3DAngers, allVoronoiCells_Angers5, Voronoi_Rn::CellByCellDistNgb_10pc) == TEST_OK );
155  BOOST_CHECK( allVoronoiCells_Angers0.size() == allVoronoiCells_Angers1.size() );
156  BOOST_CHECK( allVoronoiCells_Angers1.size() == allVoronoiCells_Angers2.size() );
157  BOOST_CHECK( allVoronoiCells_Angers2.size() == allVoronoiCells_Angers3.size() );
158  BOOST_CHECK( allVoronoiCells_Angers3.size() == allVoronoiCells_Angers4.size() );
159  BOOST_CHECK( allVoronoiCells_Angers4.size() == allVoronoiCells_Angers5.size() );
160  for (unsigned int cellCounter=0; cellCounter<allVoronoiCells_Angers0.size(); ++cellCounter)
161  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells_Angers0[cellCounter], allVoronoiCells_Angers1[cellCounter]) == TEST_OK );
162  for (unsigned int cellCounter=0; cellCounter<allVoronoiCells_Angers1.size(); ++cellCounter)
163  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells_Angers1[cellCounter], allVoronoiCells_Angers2[cellCounter]) == TEST_OK );
164  for (unsigned int cellCounter=0; cellCounter<allVoronoiCells_Angers2.size(); ++cellCounter)
165  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells_Angers2[cellCounter], allVoronoiCells_Angers3[cellCounter]) == TEST_OK );
166  for (unsigned int cellCounter=0; cellCounter<allVoronoiCells_Angers3.size(); ++cellCounter)
167  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells_Angers3[cellCounter], allVoronoiCells_Angers4[cellCounter]) == TEST_OK );
168  for (unsigned int cellCounter=0; cellCounter<allVoronoiCells_Angers4.size(); ++cellCounter)
169  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells_Angers4[cellCounter], allVoronoiCells_Angers5[cellCounter]) == TEST_OK );
170  std::cout << "allVoronoiCells_Angers0.size() = " << allVoronoiCells_Angers0.size() << std::endl;
171  std::cout << "allVoronoiCells_Angers1.size() = " << allVoronoiCells_Angers1.size() << std::endl;
172  std::cout << "allVoronoiCells_Angers2.size() = " << allVoronoiCells_Angers2.size() << std::endl;
173  std::cout << "allVoronoiCells_Angers3.size() = " << allVoronoiCells_Angers3.size() << std::endl;
174  std::cout << "allVoronoiCells_Angers4.size() = " << allVoronoiCells_Angers4.size() << std::endl;
175  std::cout << "allVoronoiCells_Angers5.size() = " << allVoronoiCells_Angers5.size() << std::endl;
176 
177  Rn::setDimension(6);
178  Rn::setTolerance(0.000001);
179 
180  cout << endl;
181  cout << "////////////" << endl;
182  cout << "// DATA1 //" << endl;
183  cout << "//////////" << endl;
184  string path_test1("test/DATA1/");
185  boost::shared_ptr<Polytope_Rn> _polytopeTest(new Polytope_Rn());
186  cout << "######################" << endl;
187  cout << "# DATA1: truncations #" << endl;
188  cout << "######################" << endl;
189  Rn::setDimension(3);
190  _polytopeTest.reset(new Polytope_Rn());
191  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("lmp1.ptop"), _polytopeTest) == TEST_OK );
192  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
193  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 6 );
194  _polytopeTest.reset(new Polytope_Rn());
195  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("lmp2.ptop"), _polytopeTest) == TEST_OK );
196  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
197  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 6 );
198  _polytopeTest.reset(new Polytope_Rn());
199  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("lmp3.ptop"), _polytopeTest) == TEST_OK );
200  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
201  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 12 );
202  _polytopeTest.reset(new Polytope_Rn());
203  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("SharirCube.ptop"), _polytopeTest) == TEST_OK );
204  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
205  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 8 );
206  _polytopeTest.reset(new Polytope_Rn());
207  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("CUT3-3-4.ptop"), _polytopeTest) == TEST_OK );
208  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
209  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 4 );
210  _polytopeTest.reset(new Polytope_Rn());
211  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("CR0-3-6.ptop"), _polytopeTest) == TEST_OK );
212  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
213  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 6 );
214  Rn::setDimension(4);
215  _polytopeTest.reset(new Polytope_Rn());
216  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("neighborly_4_8.ptop"), _polytopeTest) == TEST_OK );
217  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
218  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 8 );
219  _polytopeTest.reset(new Polytope_Rn());
220  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cyclic.ptop"), _polytopeTest) == TEST_OK );
221  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 10000.) == TEST_OK );
222  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 8 );
223  _polytopeTest.reset(new Polytope_Rn());
224  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("BIR3-4-6.ptop"), _polytopeTest) == TEST_OK );
225  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
226  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 6 );
227  _polytopeTest.reset(new Polytope_Rn());
228  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("p4_7_simplicial_1.ptop"), _polytopeTest) == TEST_OK );
229  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
230  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 7 );
231  _polytopeTest.reset(new Polytope_Rn());
232  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("p4_7_nonsimplicial_01.ptop"), _polytopeTest) == TEST_OK );
233  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
234  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 7 );
235  _polytopeTest.reset(new Polytope_Rn());
236  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("120-cell.ptop"), _polytopeTest) == TEST_OK );
237  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
238  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 600 );
239  _polytopeTest.reset(new Polytope_Rn());
240  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("not-cubical4.ptop"), _polytopeTest) == TEST_OK );
241  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
242  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 32 );
243  Rn::setDimension(6);
244  _polytopeTest.reset(new Polytope_Rn());
245  boost::shared_ptr<Polytope_Rn> _polytope2(new Polytope_Rn());
246  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("8D6.ptop"), _polytopeTest) == TEST_OK );
247  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
248  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("8D6_v.ptop"), _polytope2) == TEST_OK );
249  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(_polytopeTest, _polytope2) == TEST_OK );
250  _polytope2.reset(new Polytope_Rn());
251  _polytopeTest.reset(new Polytope_Rn());
252  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("10D6.ptop"), _polytopeTest) == TEST_OK );
253  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
254  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("10D6_v.ptop"), _polytope2) == TEST_OK );
255  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(_polytopeTest, _polytope2) == TEST_OK );
256  _polytope2.reset(new Polytope_Rn());
257  _polytopeTest.reset(new Polytope_Rn());
258  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("20D6.ptop"), _polytopeTest) == TEST_OK );
259  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
260  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("20D6_v.ptop"), _polytope2) == TEST_OK );
261  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(_polytopeTest, _polytope2) == TEST_OK );
262  _polytope2.reset(new Polytope_Rn());
263  _polytopeTest.reset(new Polytope_Rn());
264  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("DD-P38_R6.ptop"), _polytope2) == TEST_OK );
265  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("P38_R6.ptop"), _polytopeTest) == TEST_OK );
266  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
267  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(_polytopeTest, _polytope2) == TEST_OK );
268  _polytopeTest.reset(new Polytope_Rn());
269  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("P38_R6.ptop"), _polytopeTest) == TEST_OK );
270  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000000.) == TEST_OK );
271  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(_polytopeTest, _polytope2) == TEST_OK );
272  Rn::setDimension(10);
273  _polytopeTest.reset(new Polytope_Rn());
274  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("CF-10-11.ptop"), _polytopeTest) == TEST_OK );
275  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
276  Rn::setDimension(4);
277  boost::shared_ptr<Polytope_Rn> parallel1(new Polytope_Rn());
278  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("parallel1.ptop"), parallel1) == TEST_OK );
279  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(parallel1, 1000000.) == TEST_OK );
280  BOOST_REQUIRE( politopixAPI::checkTopologyAndGeometry(parallel1, true) == TEST_OK );
281  boost::shared_ptr<Polytope_Rn> parallel2(new Polytope_Rn());
282  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("parallel2.ptop"), parallel2) == TEST_OK );
283  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(parallel2, 1000000.) == TEST_OK );
284  BOOST_REQUIRE( politopixAPI::checkTopologyAndGeometry(parallel2, true) == TEST_OK );
285  Rn::setDimension(4);
286  _polytope2.reset(new Polytope_Rn());
287  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("Hdesc0.ptop"), _polytope2) == TEST_OK );
288  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytope2, 1000000.) == TEST_OK );
289  BOOST_REQUIRE( politopixAPI::checkTopologyAndGeometry(_polytope2, true) == TEST_OK );
290  _polytope2.reset(new Polytope_Rn());
291  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("Hdesc1.ptop"), _polytope2) == TEST_OK );
292  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytope2, 1000000.) == TEST_OK );
293  BOOST_REQUIRE( politopixAPI::checkTopologyAndGeometry(_polytope2, true) == TEST_OK );
294  _polytope2.reset(new Polytope_Rn());
295  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("Hdesc2.ptop"), _polytope2) == TEST_OK );
296  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytope2, 1000000.) == TEST_OK );
297  BOOST_REQUIRE( politopixAPI::checkTopologyAndGeometry(_polytope2, true) == TEST_OK );
298  _polytope2.reset(new Polytope_Rn());
299  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("Vdesc0.ptop"), _polytope2) == TEST_OK );
300  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytope2, 1000000.) == TEST_OK );
301  BOOST_REQUIRE( politopixAPI::checkTopologyAndGeometry(_polytope2, true) == TEST_OK );
302  //BOOST_REQUIRE( politopixAPI::savePolytope(string("res.ptop"), _polytopeTest) == TEST_OK );
303 
304  cout << "########################" << endl;
305  cout << "# DATA1: intersections #" << endl;
306  cout << "########################" << endl;
307  Rn::setDimension(3);
308  _polytope2.reset(new Polytope_Rn());
309  _polytopeTest.reset(new Polytope_Rn());
310  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("lmp1_v.ptop"), _polytopeTest) == TEST_OK );
311  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("SharirCube_v.ptop"), _polytope2) == TEST_OK );
312  BOOST_REQUIRE( politopixAPI::computeIntersection(_polytopeTest, _polytope2) == TEST_OK );
313  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 8 );
314  cout << "###############" << endl;
315  cout << "# DATA1: sums #" << endl;
316  cout << "###############" << endl;
317  Rn::setDimension(3);
318  Rn::setTolerance(0.0001);
319  boost::shared_ptr<Polytope_Rn> _sum;
320  _sum.reset(new Polytope_Rn());
321  _polytope2.reset(new Polytope_Rn());
322  _polytopeTest.reset(new Polytope_Rn());
323  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("lmp1_v.ptop"), _polytopeTest) == TEST_OK );
324  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cube3D.ptop"), _polytope2) == TEST_OK );
325  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytopeTest, _polytope2, _sum) == TEST_OK );
326  BOOST_REQUIRE( _sum->numberOfGenerators() == 24 );
327  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 26 );
328  _sum.reset(new Polytope_Rn());
329  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytope2, _polytopeTest, _sum) == TEST_OK );
330  BOOST_REQUIRE( _sum->numberOfGenerators() == 24 );
331  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 26 );
332  Rn::setDimension(3);
333  Rn::setTolerance(0.000001);
334  boost::shared_ptr<Polytope_Rn> _polytope1(new Polytope_Rn());
335  _sum.reset(new Polytope_Rn());
336  _polytope1.reset(new Polytope_Rn());
337  _polytope2.reset(new Polytope_Rn());
338  BOOST_REQUIRE( politopixAPI::loadPolytope( string("./test/DATA1/octaedre3D_centre.ptop"), _polytope1) == TEST_OK );
339  BOOST_REQUIRE( politopixAPI::loadPolytope( string("./test/DATA1/cube3D_centre.ptop"), _polytope2) == TEST_OK );
340  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytope2, 1000.) == TEST_OK );
341  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytope1, 1000.) == TEST_OK );
342  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytope1, _polytope2, _sum) == TEST_OK );
343  BOOST_REQUIRE( _sum->numberOfGenerators() == 24 );
344  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 26 );
345  _polytopeTest.reset(new Polytope_Rn());
346  BOOST_REQUIRE( politopixAPI::loadPolytope( string("./test/DATA1/rhombicuboctahedron.ptop"), _polytopeTest) == TEST_OK );
347  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(_sum, _polytopeTest, true) == TEST_OK );
348  boost::shared_ptr<Polytope_Rn> _sum2(new Polytope_Rn());
349  boost::shared_ptr<Polytope_Rn> _polytope3(new Polytope_Rn());
350  BOOST_REQUIRE( politopixAPI::loadPolytope( string("./test/DATA1/tetra3D_v_2.ptop"), _polytope3) == TEST_OK );
351  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytope3, _sum, _sum2) == TEST_OK );
352  _polytopeTest.reset(new Polytope_Rn());
353  BOOST_REQUIRE( politopixAPI::loadPolytope( string("./test/DATA1/tetra_rhombicuboctahedron.ptop"), _polytopeTest) == TEST_OK );
354  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(_sum2, _polytopeTest, true) == TEST_OK );
355  _sum.reset(new Polytope_Rn());
356  _polytope2.reset(new Polytope_Rn());
357  _polytopeTest.reset(new Polytope_Rn());
358  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cyclic_v.ptop"), _polytopeTest) == TEST_OK );
359  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("120-cell_v.ptop"), _polytope2) == TEST_OK );
360  //BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytopeTest, _polytope2, _sum) == TEST_OK );
361  _polytope2.reset(new Polytope_Rn());
362  _polytopeTest.reset(new Polytope_Rn());
363  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cube_1.ptop"), _polytopeTest) == TEST_OK );
364  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cube_2.ptop"), _polytope2) == TEST_OK );
365  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytope2, 1000.) == TEST_OK );
366  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
367  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(_polytope2, _polytopeTest, true) == TEST_OK );
368  //BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytope2, _polytopeTest, _sum) == TEST_OK );
369  Rn::setTolerance(0.000001);
370  _sum.reset(new Polytope_Rn());
371  _polytope2.reset(new Polytope_Rn());
372  _polytopeTest.reset(new Polytope_Rn());
373  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("tetra3D_v_1.ptop"), _polytopeTest) == TEST_OK );
374  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("tetra3D_v_2.ptop"), _polytope2) == TEST_OK );
375  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytopeTest, _polytope2, _sum) == TEST_OK );
376  BOOST_REQUIRE( _sum->numberOfGenerators() == 9 );
377  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 7 );
378  _sum.reset(new Polytope_Rn());
379  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytope2, _polytopeTest, _sum) == TEST_OK );
380  BOOST_REQUIRE( _sum->numberOfGenerators() == 9 );
381  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 7 );
382  _sum.reset(new Polytope_Rn());
383  _polytope2.reset(new Polytope_Rn());
384  _polytopeTest.reset(new Polytope_Rn());
385  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("tetra3D_v_3.ptop"), _polytopeTest) == TEST_OK );
386  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("tetra3D_v_4.ptop"), _polytope2) == TEST_OK );
387  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytopeTest, _polytope2, _sum) == TEST_OK );
388  BOOST_REQUIRE( _sum->numberOfGenerators() == 17 );
389  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 17 );
390  _sum.reset(new Polytope_Rn());
391  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytope2, _polytopeTest, _sum) == TEST_OK );
392  BOOST_REQUIRE( _sum->numberOfGenerators() == 17 );
393  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 17 );
394  Rn::setDimension(4);
395  Rn::setTolerance(0.0001);
396  _sum.reset(new Polytope_Rn());
397  _polytope2.reset(new Polytope_Rn());
398  _polytopeTest.reset(new Polytope_Rn());
399  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("_p4s.ptop"), _polytopeTest) == TEST_OK );
400  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("_p4ns.ptop"), _polytope2) == TEST_OK );
401  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytopeTest, _polytope2, _sum) == TEST_OK );
402  BOOST_REQUIRE( _sum->numberOfGenerators() == 25 );
403  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 33 );
404  _sum.reset(new Polytope_Rn());
405  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytope2, _polytopeTest, _sum) == TEST_OK );
406  BOOST_REQUIRE( _sum->numberOfGenerators() == 25 );
407  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 33 );
408  Rn::setTolerance(0.000001);
409  _sum.reset(new Polytope_Rn());
410  _polytope2.reset(new Polytope_Rn());
411  _polytopeTest.reset(new Polytope_Rn());
412  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("neighborly_4_8_v.ptop"), _polytopeTest) == TEST_OK );
413  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("BIR3-4-6_v.ptop"), _polytope2) == TEST_OK );
414  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytopeTest, _polytope2, _sum) == TEST_OK );
415  BOOST_REQUIRE( _sum->numberOfGenerators() == 34 );
416  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 40 );
417  _sum.reset(new Polytope_Rn());
418  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytope2, _polytopeTest, _sum) == TEST_OK );
419  BOOST_REQUIRE( _sum->numberOfGenerators() == 34 );
420  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 40 );
421  Rn::setDimension(6);
422  Rn::setTolerance(0.000001);
423  _sum.reset(new Polytope_Rn());
424  _polytope2.reset(new Polytope_Rn());
425  _polytopeTest.reset(new Polytope_Rn());
426  boost::shared_ptr<Polytope_Rn> _pol2compare;
427  _pol2compare.reset(new Polytope_Rn());
428  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cube15pts.ptop"), _polytopeTest) == TEST_OK );
429  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("sph10D6.ptop"), _polytope2) == TEST_OK );
430  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytopeTest, _polytope2, _sum) == TEST_OK );
431  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cube15-sph10_D6.ptop"), _pol2compare) == TEST_OK );
432  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(_sum, _pol2compare) == TEST_OK );
433  std::cout << "* Extrusions *" << std::endl;
434  boost::shared_ptr<Polytope_Rn> polytope2extrude(new Polytope_Rn());
435  boost::shared_ptr<PolyhedralCone_Rn> extruded_polyedron(new PolyhedralCone_Rn()), extruded_polyedron_comp(new PolyhedralCone_Rn());
436  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("P1_3D.ptop"), polytope2extrude) == TEST_OK );
437  std::set< unsigned int > originalSpaceDirections;
438  originalSpaceDirections.insert(1);originalSpaceDirections.insert(2);originalSpaceDirections.insert(6);
439  TopGeomTools::extrudeInCanonicalDirections(originalSpaceDirections, 6, polytope2extrude, extruded_polyedron);
440  BOOST_REQUIRE( politopixAPI::loadPolyhedralCone(path_test1 + string("P1_6D.pcon"), extruded_polyedron_comp) == TEST_OK );
441  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > iteHS1(extruded_polyedron->getListOfHalfSpaces());
442  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > iteHS2(extruded_polyedron_comp->getListOfHalfSpaces());
443  for (iteHS1.begin(),iteHS2.begin(); iteHS1.end()!=true&&iteHS2.end()!=true; iteHS1.next(),iteHS2.next()) {
444  for (unsigned int i=0; i<6; ++i)
445  BOOST_REQUIRE( iteHS1.current()->getCoefficient(i) == iteHS2.current()->getCoefficient(i) );
446  }
447  Rn::setDimension(2);
448  polytope2extrude.reset(new Polytope_Rn());
449  extruded_polyedron.reset(new PolyhedralCone_Rn());
450  extruded_polyedron_comp.reset(new PolyhedralCone_Rn());
451  originalSpaceDirections.clear();
452  originalSpaceDirections.insert(1);originalSpaceDirections.insert(2);
453  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("P10_20_2D.ptop"), polytope2extrude) == TEST_OK );
454  TopGeomTools::extrudeInCanonicalDirections(originalSpaceDirections, 6, polytope2extrude, extruded_polyedron);
455  BOOST_REQUIRE( politopixAPI::loadPolyhedralCone(path_test1 + string("P10_20_6D.pcon"), extruded_polyedron_comp) == TEST_OK );
456  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > iteHS1_2D(extruded_polyedron->getListOfHalfSpaces());
457  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > iteHS2_2D(extruded_polyedron_comp->getListOfHalfSpaces());
458  for (iteHS1_2D.begin(),iteHS2_2D.begin(); iteHS1_2D.end()!=true&&iteHS2_2D.end()!=true; iteHS1_2D.next(),iteHS2_2D.next()) {
459  for (unsigned int i=0; i<6; ++i)
460  BOOST_REQUIRE( iteHS1_2D.current()->getCoefficient(i) == iteHS2_2D.current()->getCoefficient(i) );
461  }
462  std::cout << "* Box *" << std::endl;
463  Rn::setDimension(3);
464  Point_Rn Pmin(1., 2., 3.), Pmax(4., 5., 6.);
465  boost::shared_ptr<Polytope_Rn> box3D(new Polytope_Rn()), box3D_comp(new Polytope_Rn());
466  politopixAPI::makeBox(box3D, Pmin, Pmax);
467  box3D->dump(std::cout);
468  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("box3D.ptop"), box3D_comp) == TEST_OK );
469  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(box3D, box3D_comp) == TEST_OK );
470  std::cout << "* Scaling factor *" << std::endl;
471  TopGeomTools::scalingFactor(box3D, 2.);
472  box3D->checkTopologyAndGeometry();
473  box3D_comp.reset(new Polytope_Rn());
474  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("box3D_x2.ptop"), box3D_comp) == TEST_OK );
475  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(box3D, box3D_comp) == TEST_OK );
476  // Equivalent to a direct scaling factor of 2 * 0.25 = 0.5
477  TopGeomTools::scalingFactor(box3D, 0.25);
478  box3D->checkTopologyAndGeometry();
479  box3D_comp.reset(new Polytope_Rn());
480  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("box3D_x0_5.ptop"), box3D_comp) == TEST_OK );
481  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(box3D, box3D_comp) == TEST_OK );
482 
483 
484  cout << endl;
485  cout << "/////////////" << endl;
486  cout << "// DATA 2 //" << endl;
487  cout << "///////////" << endl;
488  Rn::setTolerance(0.000001);
489  Rn::setDimension(3);
490  path_test1 = string("test/DATA2/");
491  boost::shared_ptr<Polytope_Rn> v2h(new Polytope_Rn()), comp_v2h(new Polytope_Rn());
492  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("v_lmp1.ptop"), v2h) == TEST_OK );
493  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(v2h, 1000.) == TEST_OK );
494  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("comp_v_lmp1.ptop"), comp_v2h) == TEST_OK );
495  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(v2h, comp_v2h) == TEST_OK );
496  v2h.reset(new Polytope_Rn()); comp_v2h.reset(new Polytope_Rn());
497  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("v_lmp2.ptop"), v2h) == TEST_OK );
498  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(v2h, 1000.) == TEST_OK );
499  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("comp_v_lmp2.ptop"), comp_v2h) == TEST_OK );
500  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(v2h, comp_v2h) == TEST_OK );
501  v2h.reset(new Polytope_Rn()); comp_v2h.reset(new Polytope_Rn());
502  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("v_lmp3.ptop"), v2h) == TEST_OK );
503  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(v2h, 1000.) == TEST_OK );
504  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("comp_v_lmp3.ptop"), comp_v2h) == TEST_OK );
505  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(v2h, comp_v2h) == TEST_OK );
506  // CAPA TM
507  {
508  Rn::setDimension(3);
509  Rn::setTolerance(0.000001);
510  cout << endl;
511  cout << "////////////////////////////////////" << endl;
512  cout << "// SUMMING A CUBE AND A POLYTOPE //" << endl;
513  cout << "//////////////////////////////////" << endl;
514  boost::shared_ptr<Polytope_Rn> pcapa(new Polytope_Rn());
515  boost::shared_ptr<Polytope_Rn> pform(new Polytope_Rn()), pform_py(new Polytope_Rn());
516  Point_Rn Pmin(-0.01, -0.0005, -0.0005);
517  Point_Rn Pmax(0.01, 0.0005, 0.0005);
518  politopixAPI::makeBox(pcapa, Pmin, Pmax);
519  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("pform2.ptop"), pform) == TEST_OK );
520  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(pform, 1000000.) == TEST_OK );
521  BOOST_REQUIRE( politopixAPI::savePolytope(path_test1 + string("pform2HV.ptop"), pform) == TEST_OK );
522  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("pform2_py.ptop"), pform_py) == TEST_OK );
523  BOOST_REQUIRE( politopixAPI::checkEqualityOfVertices(pform, pform_py) == TEST_OK );;
524  // Compute the sum.
525  boost::shared_ptr<Polytope_Rn> pecart(new Polytope_Rn());
526  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(pcapa, pform, pecart) == TEST_OK );
527  // Translate the sum.
528  boost::numeric::ublas::vector<double> subs(3);
529  subs(0) = 0.3013277;
530  subs(1) = 0.01742817;
531  subs(2) = 0.01751706;
532  politopixAPI::Translate(pecart, subs);
533  }
534  // TM TEXAN
535  {
536  Rn::setDimension(4);
537  Rn::setTolerance(0.000001);
538  boost::shared_ptr<Polytope_Rn> _A_0(new Polytope_Rn());
539  boost::shared_ptr<Polytope_Rn> _A_1(new Polytope_Rn());
540  boost::shared_ptr<Polytope_Rn> _A_2(new Polytope_Rn());
541  boost::shared_ptr<Polytope_Rn> _A_3(new Polytope_Rn());
542  boost::shared_ptr<Polytope_Rn> sum0123(new Polytope_Rn());
543  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("_A_0_Rd.ptop"), _A_0) == TEST_OK );
544  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("_A_1_Rd.ptop"), _A_1) == TEST_OK );
545  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("_A_2_Rd.ptop"), _A_2) == TEST_OK );
546  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("_A_3_Rd.ptop"), _A_3) == TEST_OK );
547  std::vector< boost::shared_ptr<Polytope_Rn> > arrayOfPolytopes;
548  arrayOfPolytopes.push_back(_A_0);
549  arrayOfPolytopes.push_back(_A_1);
550  arrayOfPolytopes.push_back(_A_2);
551  arrayOfPolytopes.push_back(_A_3);
552 
554  // Main computation //
556  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(arrayOfPolytopes, sum0123) == TEST_OK );
558  // Load the polytope computed with the Shangai algorithm to compare //
560  boost::shared_ptr<Polytope_Rn> shangai0123(new Polytope_Rn());
561  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("shangaiHV0123.ptop"), shangai0123) == TEST_OK );
562  BOOST_REQUIRE( politopixAPI::checkEqualityOfVertices(sum0123, shangai0123) == TEST_OK );
563  }
564 
565  // cout << "/////////////////////" << endl;
566  // cout << "// FLAT POLYTOPES //" << endl;
567  // cout << "///////////////////" << endl;
568  // {
569  // Rn::setDimension(3);
570  // boost::shared_ptr<Polytope_Rn> ptop_0(new Polytope_Rn());
571  // std::vector< boost::shared_ptr<Hyperplane_Rn> > vectOfHyp0;
572  // politopixAPI::makeBox(ptop_0, Point_Rn(0., 0., 0.), Point_Rn(1000., 1000., 1000.));
573  // boost::shared_ptr<Hyperplane_Rn> he110(new Hyperplane_Rn(3));
574  // he110->setCoefficient(0,1.); he110->setCoefficient(1,1.); he110->setCoefficient(2,1.); he110->setConstant(-1.);
575  // vectOfHyp0.push_back(he110);
576  // //boost::shared_ptr<Hyperplane_Rn> he1100(new Hyperplane_Rn(3));
577  // //he1100->setCoefficient(0,1.); he1100->setCoefficient(1,1.); he1100->setCoefficient(2,1.); he1100->setConstant(-1.);
578  // //vectOfHyp0.push_back(he1100);
579  // boost::shared_ptr<Hyperplane_Rn> he1110(new Hyperplane_Rn(3));
580  // he1110->setCoefficient(0,-1.); he1110->setCoefficient(1,-1.); he1110->setCoefficient(2,1.); he1110->setConstant(0.);
581  // vectOfHyp0.push_back(he1110);
582  // boost::shared_ptr<Hyperplane_Rn> he11110(new Hyperplane_Rn(3));
583  // he11110->setCoefficient(0,-1.); he11110->setCoefficient(1,1.); he11110->setCoefficient(2,0.); he11110->setConstant(0.);
584  // vectOfHyp0.push_back(he11110);
585  // std::cout << "*************** computeFlatPolytope ***************" << std::endl;
586  // computeFlatPolytope(vectOfHyp0, ptop_0, path_test1 + "truncatedCube3.ptop", true);
587  // std::cout << "---------- 1 -----------" << std::endl;
588  // BOOST_CHECK( ptop_0->numberOfHalfSpaces() == 3 );
589  // std::cout << "---------- 2 -----------" << std::endl;
590  // //ptop_0->dump(std::cout);
591  // //exit(0);
592  // }
593 
594  // {
595  // Rn::setDimension(3);
596  // bool strongRedundancy = false;
597  // std::vector< boost::shared_ptr<Hyperplane_Rn> > vectOfHyp;
598 
599  // std::cout << "*************** New computation 1 ***************" << std::endl;
600  // boost::shared_ptr<Polytope_Rn> ptop_1(new Polytope_Rn());
601  // politopixAPI::makeBox(ptop_1, Point_Rn(0., 0., 0.), Point_Rn(1000., 1000., 1000.));
602  // boost::shared_ptr<Hyperplane_Rn> he11(new Hyperplane_Rn(3));
603  // he11->setCoefficient(0,1.); he11->setCoefficient(1,1.); he11->setCoefficient(2,1.); he11->setConstant(-1.);
604  // vectOfHyp.push_back(he11);
605  // computeFlatPolytope(vectOfHyp, ptop_1, path_test1 + "truncatedCube1.ptop", strongRedundancy);
606  // BOOST_CHECK( ptop_1->numberOfHalfSpaces() == 7 );
607 
608  // std::cout << "*************** New computation 2 ***************" << std::endl;
609  // boost::shared_ptr<Polytope_Rn> ptop_2(new Polytope_Rn());
610  // politopixAPI::makeBox(ptop_2, Point_Rn(0., 0., 0.), Point_Rn(1000., 1000., 1000.));
611  // boost::shared_ptr<Hyperplane_Rn> he111(new Hyperplane_Rn(3));
612  // he111->setCoefficient(0,-1.); he111->setCoefficient(1,-1.); he111->setCoefficient(2,1.); he111->setConstant(0.);
613  // vectOfHyp.push_back(he111);
614  // computeFlatPolytope(vectOfHyp, ptop_2, path_test1 + "truncatedCube2.ptop", strongRedundancy);
615  // BOOST_CHECK( ptop_2->numberOfHalfSpaces() == 8 );
616 
617  // std::cout << "*************** New computation 3 ***************" << std::endl;
618  // boost::shared_ptr<Polytope_Rn> ptop_3(new Polytope_Rn());
619  // politopixAPI::makeBox(ptop_3, Point_Rn(0., 0., 0.), Point_Rn(1000., 1000., 1000.));
620  // boost::shared_ptr<Hyperplane_Rn> he1111(new Hyperplane_Rn(3));
621  // he1111->setCoefficient(0,-1.); he1111->setCoefficient(1,1.); he1111->setCoefficient(2,0.); he1111->setConstant(0.);
622  // vectOfHyp.push_back(he1111);
623  // computeFlatPolytope(vectOfHyp, ptop_3, path_test1 + "truncatedCube3.ptop", strongRedundancy);
624  // BOOST_CHECK( ptop_3->numberOfHalfSpaces() == 9 );
625  // }
626 
627  // std::cout << "**************************************************" << std::endl;
628 
629  // {
630  // Rn::setDimension(3);
631  // bool strongRedundancy = true;
632  // std::vector< boost::shared_ptr<Hyperplane_Rn> > vectOfHyp;
633 
634  // std::cout << "*************** New computation 1 ***************" << std::endl;
635  // boost::shared_ptr<Polytope_Rn> ptop_1(new Polytope_Rn());
636  // politopixAPI::makeBox(ptop_1, Point_Rn(0., 0., 0.), Point_Rn(1000., 1000., 1000.));
637  // boost::shared_ptr<Hyperplane_Rn> he11(new Hyperplane_Rn(3));
638  // he11->setCoefficient(0,1.); he11->setCoefficient(1,1.); he11->setCoefficient(2,1.); he11->setConstant(-1.);
639  // vectOfHyp.push_back(he11);
640  // computeFlatPolytope(vectOfHyp, ptop_1, path_test1 + "truncatedCube1.ptop", strongRedundancy);
641  // BOOST_CHECK( ptop_1->numberOfHalfSpaces() == 4 );
642 
643  // std::cout << "*************** New computation 2 ***************" << std::endl;
644  // boost::shared_ptr<Polytope_Rn> ptop_2(new Polytope_Rn());
645  // politopixAPI::makeBox(ptop_2, Point_Rn(0., 0., 0.), Point_Rn(1000., 1000., 1000.));
646  // boost::shared_ptr<Hyperplane_Rn> he111(new Hyperplane_Rn(3));
647  // he111->setCoefficient(0,-1.); he111->setCoefficient(1,-1.); he111->setCoefficient(2,1.); he111->setConstant(0.);
648  // vectOfHyp.push_back(he111);
649  // computeFlatPolytope(vectOfHyp, ptop_2, path_test1 + "truncatedCube2.ptop", strongRedundancy);
650  // BOOST_CHECK( ptop_2->numberOfHalfSpaces() == 4 );
651 
652  // std::cout << "*************** New computation 3 ***************" << std::endl;
653  // boost::shared_ptr<Polytope_Rn> ptop_3(new Polytope_Rn());
654  // politopixAPI::makeBox(ptop_3, Point_Rn(0., 0., 0.), Point_Rn(1000., 1000., 1000.));
655  // boost::shared_ptr<Hyperplane_Rn> he1111(new Hyperplane_Rn(3));
656  // he1111->setCoefficient(0,-1.); he1111->setCoefficient(1,1.); he1111->setCoefficient(2,0.); he1111->setConstant(0.);
657  // vectOfHyp.push_back(he1111);
658  // computeFlatPolytope(vectOfHyp, ptop_3, path_test1 +"truncatedCube3.ptop", strongRedundancy);
659  // BOOST_CHECK( ptop_3->numberOfHalfSpaces() == 3 );
660  // }
661 
662 
663  Rn::setDimension(6);
664  Rn::setTolerance(0.000001);
665  std::vector< boost::shared_ptr<Polytope_Rn> > arrayOfPolytopes;
666  arrayOfPolytopes.resize(7);
667  path_test1 = string("test/DATA2/T1/");
668  string path_test2("test/DATA2/T2/");
669  string path_test3("test/DATA2/T3/");
670  string path_test4("test/DATA2/T4/");
671  string path_test5("test/DATA2/T5/");
672  std::vector< string > Ppath1;
673  std::vector< string > Ppath2;
674  std::vector< string > Ppath3;
675  std::vector< string > Ppath4;
676  std::vector< string > Ppath5;
677  //cout << "ok" << endl;
678  Ppath1.push_back( string("outputcthp_0_1-ctl_848_0.ptop") );
679  Ppath1.push_back( string("outputcthp_10_0-ctl_524_1.ptop") );
680  Ppath1.push_back( string("outputcthp_102_1-ctl_221_0.ptop") );
681  Ppath1.push_back( string("outputcthp_103_0-ctl_122_2.ptop") );
682  Ppath1.push_back( string("outputcthp_107_3-ctl_145_1.ptop") );
683  Ppath1.push_back( string("outputcthp_109_2-ctl_452_2.ptop") );
684  Ppath1.push_back( string("outputcthp_113_0-ctl_989_2.ptop") );
685  Ppath2.push_back( string("outputcthp_0_2-ctl_82_2.ptop") );
686  Ppath2.push_back( string("outputcthp_10_3-ctl_99_3.ptop") );
687  Ppath2.push_back( string("outputcthp_100_0-ctl_914_1.ptop") );
688  Ppath2.push_back( string("outputcthp_104_2-ctl_857_3.ptop") );
689  Ppath2.push_back( string("outputcthp_108_3-ctl_196_1.ptop") );
690  Ppath2.push_back( string("outputcthp_109_2-ctl_452_2.ptop") );
691  Ppath2.push_back( string("outputcthp_110_1-ctl_697_0.ptop") );
692  Ppath3.push_back( string("outputcthp_111_1-ctl_111_1.ptop") );
693  Ppath3.push_back( string("outputcthp_162_0-ctl_42_1.ptop") );
694  Ppath3.push_back( string("outputcthp_366_1-ctl_201_0.ptop") );
695  Ppath3.push_back( string("outputcthp_57_3-ctl_330_2.ptop") );
696  Ppath3.push_back( string("outputcthp_586_0-ctl_932_2.ptop") );
697  Ppath3.push_back( string("outputcthp_741_3-ctl_568_0.ptop") );
698  Ppath3.push_back( string("outputcthp_915_3-ctl_803_1.ptop") );
699  Ppath4.push_back( string("outputcthp_177_1-ctl_83_2.ptop") );
700  Ppath4.push_back( string("outputcthp_231_1-ctl_830_2.ptop") );
701  Ppath4.push_back( string("outputcthp_361_1-ctl_578_2.ptop") );
702  Ppath4.push_back( string("outputcthp_44_1-ctl_51_2.ptop") );
703  Ppath4.push_back( string("outputcthp_482_2-ctl_880_0.ptop") );
704  Ppath4.push_back( string("outputcthp_712_1-ctl_693_1.ptop") );
705  Ppath4.push_back( string("outputcthp_899_3-ctl_233_3.ptop") );
706  Ppath5.push_back( string("outputcthp_0_2-ctl_82_2.ptop") );
707  Ppath5.push_back( string("outputcthp_10_0-ctl_524_1.ptop") );
708  Ppath5.push_back( string("outputcthp_101_0-ctl_74_0.ptop") );
709  Ppath5.push_back( string("outputcthp_104_1-ctl_357_2.ptop") );
710  Ppath5.push_back( string("outputcthp_107_2-ctl_186_0.ptop") );
711  Ppath5.push_back( string("outputcthp_112_2-ctl_527_3.ptop") );
712  Ppath5.push_back( string("outputcthp_113_2-ctl_424_1.ptop") );
713  //cout << "ok" << endl;
714  {for (unsigned int i=0; i<7; ++i) {
715  //cout << "ok " << path_test1+Ppath1[i] << endl;
716  boost::shared_ptr<Polytope_Rn> T1(new Polytope_Rn());
717  boost::shared_ptr<Polytope_Rn> T2(new Polytope_Rn());
718  boost::shared_ptr<Polytope_Rn> T3(new Polytope_Rn());
719  boost::shared_ptr<Polytope_Rn> T4(new Polytope_Rn());
720  boost::shared_ptr<Polytope_Rn> T5(new Polytope_Rn());
721  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + Ppath1[i], T1) == TEST_OK );
722  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test2 + Ppath2[i], T2) == TEST_OK );
723  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + Ppath3[i], T3) == TEST_OK );
724  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test4 + Ppath4[i], T4) == TEST_OK );
725  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test5 + Ppath5[i], T5) == TEST_OK );
726  cout << "##################" << endl;
727  cout << "# DATA 2: sums ";
728  cout << i+1 << " #" << endl;
729  cout << "##################" << endl;
730  boost::shared_ptr<Polytope_Rn> T12(new Polytope_Rn());
731  boost::shared_ptr<Polytope_Rn> T123(new Polytope_Rn());
732  boost::shared_ptr<Polytope_Rn> T1234(new Polytope_Rn());
733  boost::shared_ptr<Polytope_Rn> T12345(new Polytope_Rn());
734  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T1, T2, T12) == TEST_OK );
735  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T12, T3, T123) == TEST_OK );
736  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T123, T4, T1234) == TEST_OK );
737  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T1234, T5, T12345) == TEST_OK );
738  boost::shared_ptr<Polytope_Rn> T54(new Polytope_Rn());
739  boost::shared_ptr<Polytope_Rn> T543(new Polytope_Rn());
740  boost::shared_ptr<Polytope_Rn> T5432(new Polytope_Rn());
741  boost::shared_ptr<Polytope_Rn> T54321(new Polytope_Rn());
742  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T5, T4, T54) == TEST_OK );
743  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T54, T3, T543) == TEST_OK );
744  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T543, T2, T5432) == TEST_OK );
745  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T5432, T1, T54321) == TEST_OK );
746  //BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(T12345, T54321) == TEST_OK );
747  arrayOfPolytopes[i] = T12345;
748  }}
749 
750 
751  Rn::setDimension(6);
752  cout << endl;
753  cout << "////////////////" << endl;
754  cout << "// SSS DISC1 //" << endl;
755  cout << "//////////////" << endl;
756  path_test1 = string("test/TM/Sss1_disc6/");
757  arrayOfPolytopes.clear();
758  arrayOfPolytopes.resize(12);
759  cout << "##########################" << endl;
760  cout << "# SSS DISC1: truncations #" << endl;
761  cout << "##########################" << endl;
762  {for (unsigned int i=0; i<12; ++i) {
763  ostringstream ss;
764  ss << (i+1);
765  string p_name = string("Polytope_") + ss.str() + string(".ptop");
766  arrayOfPolytopes[i].reset(new Polytope_Rn());
767  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + p_name, arrayOfPolytopes[i]) == TEST_OK );
768  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(arrayOfPolytopes[i], 1000.) == TEST_OK );
769  }}
770  cout << "############################" << endl;
771  cout << "# SSS DISC1: intersections #" << endl;
772  cout << "############################" << endl;
773  {for (unsigned int i=1; i<5 ; ++i) {
774  BOOST_REQUIRE( politopixAPI::computeIntersection(arrayOfPolytopes[0], arrayOfPolytopes[i]) == TEST_OK );
775  }}
776  {for (unsigned int i=6; i<10; ++i) {
777  BOOST_REQUIRE( politopixAPI::computeIntersection(arrayOfPolytopes[5], arrayOfPolytopes[i]) == TEST_OK );
778  }}
779  cout << "# intersections 11 & 12 #" << endl;
780  BOOST_REQUIRE( politopixAPI::computeIntersection(arrayOfPolytopes[0], arrayOfPolytopes[10]) == TEST_OK );
781  BOOST_REQUIRE( politopixAPI::computeIntersection(arrayOfPolytopes[5], arrayOfPolytopes[11]) == TEST_OK );
782  cout << "###################" << endl;
783  cout << "# SSS DISC1: sums #" << endl;
784  cout << "###################" << endl;
785  boost::shared_ptr<Polytope_Rn> C05(new Polytope_Rn());
786  boost::shared_ptr<Polytope_Rn> C50(new Polytope_Rn());
787  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(arrayOfPolytopes[0], arrayOfPolytopes[5], C05) == TEST_OK );
788  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(arrayOfPolytopes[5], arrayOfPolytopes[0], C50) == TEST_OK );
789  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(C05, C50) == TEST_OK );
790  BOOST_REQUIRE( politopixAPI::savePolytope(path_test1 + string("test_resultat12.ptop"), C05) == TEST_OK );
791  BOOST_REQUIRE( politopixAPI::savePolytope(path_test1 + string("test_resultat21.ptop"), C50) == TEST_OK );
792 
793 
794  cout << endl;
795  cout << "//////////////////" << endl;
796  cout << "// BBB_D_5.966 //" << endl;
797  cout << "////////////////" << endl;
798  path_test2 = string("test/TM/Interference_Bbb/BBB_D_5.966/");
799  arrayOfPolytopes.clear();
800  arrayOfPolytopes.resize(13);
801  {for (unsigned int i=1; i<=13; ++i) {
802  cout << "############################" << endl;
803  cout << "# BBB_D_5.966: truncations #" << endl;
804  cout << "############################" << endl;
805  ostringstream ss1;
806  ss1 << i;
807  std::vector< boost::shared_ptr<Polytope_Rn> > tmpArrayOfPtop(5);
808  {for (unsigned int j=1; j<=5; ++j) {
809  ostringstream ss2;
810  ss2 << j;
811  string p_name = string("ctl_") + ss1.str();
812  p_name += string("_") + ss2.str() + string(".ptop");
813  tmpArrayOfPtop[j-1].reset(new Polytope_Rn());
814  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test2 + p_name, tmpArrayOfPtop[j-1]) == TEST_OK );
815  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(tmpArrayOfPtop[j-1], 1000.) == TEST_OK );
816  }}
817  cout << "##############################" << endl;
818  cout << "# BBB_D_5.966: intersections #" << endl;
819  cout << "##############################" << endl;
820  {for (unsigned int j=1; j<=4; ++j) {
821  BOOST_REQUIRE( politopixAPI::computeIntersection(tmpArrayOfPtop[0], tmpArrayOfPtop[j]) == TEST_OK );
822  }}
823  arrayOfPolytopes.push_back( tmpArrayOfPtop[0] );
824  string checkPtop;
825  checkPtop += path_test2 + string("qhull_ctl_");
826  checkPtop += ss1.str() + string("_x.ptop");
827  boost::shared_ptr<Polytope_Rn> CP(new Polytope_Rn());
828  BOOST_REQUIRE( politopixAPI::loadPolytope(checkPtop, CP) == TEST_OK );
829  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(tmpArrayOfPtop[0], CP) == TEST_OK );
830  }}
831 
832 
833  cout << endl;
834  cout << "//////////////////" << endl;
835  cout << "// BBB_D_5.976 //" << endl;
836  cout << "////////////////" << endl;
837  path_test2 = string("test/TM/Interference_Bbb/BBB_D_5.976/");
838  arrayOfPolytopes.clear();
839  arrayOfPolytopes.resize(13);
840  {for (unsigned int i=1; i<=13; ++i) {
841  cout << "############################" << endl;
842  cout << "# BBB_D_5.976: truncations #" << endl;
843  cout << "############################" << endl;
844  ostringstream ss1;
845  ss1 << i;
846  std::vector< boost::shared_ptr<Polytope_Rn> > tmpArrayOfPtop(5);
847  {for (unsigned int j=1; j<=5; ++j) {
848  ostringstream ss2;
849  ss2 << j;
850  string p_name = string("ctl_") + ss1.str();
851  p_name += string("_") + ss2.str() + string(".ptop");
852  tmpArrayOfPtop[j-1].reset(new Polytope_Rn());
853  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test2 + p_name, tmpArrayOfPtop[j-1]) == TEST_OK );
854  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(tmpArrayOfPtop[j-1], 1000.) == TEST_OK );
855  }}
856  cout << "##############################" << endl;
857  cout << "# BBB_D_5.976: intersections #" << endl;
858  cout << "##############################" << endl;
859  {for (unsigned int j=1; j<=4; ++j) {
860  BOOST_REQUIRE( politopixAPI::computeIntersection(tmpArrayOfPtop[0], tmpArrayOfPtop[j]) == TEST_OK );
861  }}
862  arrayOfPolytopes.push_back( tmpArrayOfPtop[0] );
863  if (i != 10) {
864  string checkPtop;
865  checkPtop += path_test2 + string("qhull_ctl_");
866  checkPtop += ss1.str() + string("_x.ptop");
867  boost::shared_ptr<Polytope_Rn> CP(new Polytope_Rn());
868  BOOST_REQUIRE( politopixAPI::loadPolytope(checkPtop, CP) == TEST_OK );
869  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(tmpArrayOfPtop[0], CP) == TEST_OK );
870  }
871  }}
872 
873 
874  cout << endl;
875  cout << "/////////////////////" << endl;
876  cout << "// DTL_BPTL/D3-R6 //" << endl;
877  cout << "///////////////////" << endl;
878  path_test3 = string("test/TM/Interference_Bbb/DTL_BPTL/D3-R6/");
879  arrayOfPolytopes.resize(4);
880  arrayOfPolytopes[0].reset(new Polytope_Rn()); arrayOfPolytopes[1].reset(new Polytope_Rn());
881  arrayOfPolytopes[2].reset(new Polytope_Rn()); arrayOfPolytopes[3].reset(new Polytope_Rn());
882  cout << "###############################" << endl;
883  cout << "# DTL_BPTL/D3-R6: truncations #" << endl;
884  cout << "###############################" << endl;
885  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("BPHP_BPTL.ptop"), arrayOfPolytopes[0]) == TEST_OK );
886  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(arrayOfPolytopes[0], 1000.) == TEST_OK );
887  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("SPAR_BPHP.ptop"), arrayOfPolytopes[1]) == TEST_OK );
888  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(arrayOfPolytopes[1], 1000.) == TEST_OK );
889  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("CCCTL_CCCTHP_SPAR.ptop"), arrayOfPolytopes[2]) == TEST_OK );
890  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(arrayOfPolytopes[2], 1000.) == TEST_OK );
891  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("DTL2_CCCTL.ptop"), arrayOfPolytopes[3]) == TEST_OK );
892  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(arrayOfPolytopes[3], 1000.) == TEST_OK );
893  boost::shared_ptr<Polytope_Rn> BPHP_BPTL_v(new Polytope_Rn());
894  boost::shared_ptr<Polytope_Rn> SPAR_BPHP_v(new Polytope_Rn());
895  boost::shared_ptr<Polytope_Rn> CCCTL_CCCTHP_SPAR_v(new Polytope_Rn());
896  boost::shared_ptr<Polytope_Rn> DTL2_CCCTL_v(new Polytope_Rn());
897  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("BPHP_BPTL_v.ptop"), BPHP_BPTL_v) == TEST_OK );
898  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("SPAR_BPHP_v.ptop"), SPAR_BPHP_v) == TEST_OK );
899  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("CCCTL_CCCTHP_SPAR_v.ptop"), CCCTL_CCCTHP_SPAR_v) == TEST_OK );
900  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("DTL2_CCCTL_v.ptop"), DTL2_CCCTL_v) == TEST_OK );
901  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[0], BPHP_BPTL_v) == TEST_OK );
902  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[1], SPAR_BPHP_v) == TEST_OK );
903  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[2], CCCTL_CCCTHP_SPAR_v) == TEST_OK );
904  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[3], DTL2_CCCTL_v) == TEST_OK );
905  cout << "#####################################" << endl;
906  cout << "# DTL_BPTL/D3-R6: polar truncations #" << endl;
907  cout << "#####################################" << endl;
908  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("BPHP_BPTL.ptop"), arrayOfPolytopes[0]) == TEST_OK );
909  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("SPAR_BPHP.ptop"), arrayOfPolytopes[1]) == TEST_OK );
910  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("CCCTL_CCCTHP_SPAR.ptop"), arrayOfPolytopes[2]) == TEST_OK );
911  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("DTL2_CCCTL.ptop"), arrayOfPolytopes[3]) == TEST_OK );
912  {for (unsigned int i=0; i<4; ++i) {
913  boost::shared_ptr<Polytope_Rn> thisVPol(new Polytope_Rn());
914  // Get the V-description.
915  constIteratorOfListOfGeometricObjects< boost::shared_ptr<Generator_Rn> > iteGN1(arrayOfPolytopes[i]->getListOfGenerators());
916  {for (iteGN1.begin(); iteGN1.end()!=true; iteGN1.next()) {
917  thisVPol->addGenerator(iteGN1.current());
918  }}
919  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(thisVPol, 1000.) == TEST_OK );
920  arrayOfPolytopes[i] = thisVPol;
921  }}
922  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[0], BPHP_BPTL_v) == TEST_OK );
923  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[1], SPAR_BPHP_v) == TEST_OK );
924  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[2], CCCTL_CCCTHP_SPAR_v) == TEST_OK );
925  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[3], DTL2_CCCTL_v) == TEST_OK );
926  cout << "########################" << endl;
927  cout << "# DTL_BPTL/D3-R6: sums #" << endl;
928  cout << "########################" << endl;
929  boost::shared_ptr<Polytope_Rn> BPTL_SPAR12(new Polytope_Rn());
930  boost::shared_ptr<Polytope_Rn> BPTL_SPAR21(new Polytope_Rn());
931  boost::shared_ptr<Polytope_Rn> BPTL_CCCTL12(new Polytope_Rn());
932  boost::shared_ptr<Polytope_Rn> BPTL_CCCTL21(new Polytope_Rn());
933  boost::shared_ptr<Polytope_Rn> BPTL_DTL212(new Polytope_Rn());
934  boost::shared_ptr<Polytope_Rn> BPTL_DTL221(new Polytope_Rn());
935  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(arrayOfPolytopes[0], arrayOfPolytopes[1], BPTL_SPAR12) == TEST_OK );
936  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(arrayOfPolytopes[1], arrayOfPolytopes[0], BPTL_SPAR21) == TEST_OK );
937  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(arrayOfPolytopes[2], BPTL_SPAR12, BPTL_CCCTL12) == TEST_OK );
938  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(BPTL_SPAR21, arrayOfPolytopes[2], BPTL_CCCTL21) == TEST_OK );
939  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(arrayOfPolytopes[3], BPTL_CCCTL12, BPTL_DTL212) == TEST_OK );
940  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(BPTL_CCCTL21, arrayOfPolytopes[3], BPTL_DTL221) == TEST_OK );
941  boost::shared_ptr<Polytope_Rn> sumOfArray(new Polytope_Rn());
942  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(arrayOfPolytopes, sumOfArray) == TEST_OK );
943  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(BPTL_DTL221, sumOfArray) == TEST_OK );
944  boost::shared_ptr<Polytope_Rn> qhl_BPTL_SPAR12(new Polytope_Rn());
945  boost::shared_ptr<Polytope_Rn> qhl_BPTL_CCCTL21(new Polytope_Rn());
946  boost::shared_ptr<Polytope_Rn> qhl_BPTL_DTL221(new Polytope_Rn());
947  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("qhl_BPTL_SPAR12.ptop"), qhl_BPTL_SPAR12) == TEST_OK );
948  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("qhl_BPTL_CCCTL21.ptop"), qhl_BPTL_CCCTL21) == TEST_OK );
949  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("qhl_BPTL_DTL221.ptop"), qhl_BPTL_DTL221) == TEST_OK );
950  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(BPTL_SPAR12, BPTL_SPAR21) == TEST_OK );
951  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(BPTL_CCCTL12, BPTL_CCCTL21) == TEST_OK );
952  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(BPTL_DTL212, BPTL_DTL221) == TEST_OK );
953  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(BPTL_SPAR12, qhl_BPTL_SPAR12) == TEST_OK );
954  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(BPTL_CCCTL12, qhl_BPTL_CCCTL21) == TEST_OK );
955  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(BPTL_DTL221, qhl_BPTL_DTL221) == TEST_OK );
956  BOOST_REQUIRE( politopixAPI::savePolytope(path_test3 + string("test_BPTL_DTL221.ptop"), BPTL_DTL221) == TEST_OK );
957  Rn::setDimension(3);
958  boost::shared_ptr<Polytope_Rn> pol2polarize2(new Polytope_Rn()), polarizedPol2(new Polytope_Rn()), polarizedPolComp2(new Polytope_Rn());
959  BOOST_REQUIRE( politopixAPI::loadPolytope("test/DATA1/outputpolar.ptop", pol2polarize2) == TEST_OK );
960  BOOST_REQUIRE( politopixAPI::loadPolytope("test/DATA1/newpol.ptop", polarizedPolComp2) == TEST_OK );
961  BOOST_REQUIRE( politopixAPI::PolarPolytope(pol2polarize2, polarizedPol2) == TEST_OK );
962  BOOST_REQUIRE( politopixAPI::checkTopologyAndGeometry(polarizedPol2) == TEST_OK );
963  //BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(polarizedPol2, polarizedPolComp2) == TEST_OK );
964 
965  cout << endl;
966  cout << "//////////////////" << endl;
967  cout << "// SPECTOMETER //" << endl;
968  cout << "////////////////" << endl;
969  cout << "#########" << endl;
970  cout << "# SUM 1 #" << endl;
971  cout << "#########" << endl;
972  string SPEC_path_test = string("test/SPECTRO/");
973  Rn::setDimension(6);
974  Rn::setTolerance(0.000001);
975  boost::shared_ptr<Polytope_Rn> SPEC_sum12(new Polytope_Rn());
976  boost::shared_ptr<Polytope_Rn> SPEC_sum21(new Polytope_Rn());
977  boost::shared_ptr<Polytope_Rn> SPEC_polytope1(new Polytope_Rn());
978  boost::shared_ptr<Polytope_Rn> SPEC_polytope2(new Polytope_Rn());
979  boost::shared_ptr<Polytope_Rn> SPEC_polytope2test(new Polytope_Rn());
980  BOOST_REQUIRE( politopixAPI::loadPolytope(SPEC_path_test + string("P_10_20_FC2.ptop"), SPEC_polytope1) == TEST_OK );
981  BOOST_REQUIRE( politopixAPI::loadPolytope(SPEC_path_test + string("P_20_30_FC2.ptop"), SPEC_polytope2) == TEST_OK );
982  BOOST_REQUIRE( politopixAPI::loadPolytope(SPEC_path_test + string("comp_10_20_30.ptop"), SPEC_polytope2test) == TEST_OK );
983  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(SPEC_polytope1, SPEC_polytope2, SPEC_sum12) == TEST_OK );
984  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(SPEC_polytope2, SPEC_polytope1, SPEC_sum21) == TEST_OK );
985  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(SPEC_sum12, SPEC_polytope2test) == TEST_OK );
986  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(SPEC_sum21, SPEC_polytope2test) == TEST_OK );
987 
988  cout << endl;
989  cout << "//////////////////////" << endl;
990  cout << "// COMPUTE VOLUMES //" << endl;
991  cout << "////////////////////" << endl;
992  string Pvol_path_test = string("test/VOL/");
993  Rn::setDimension(3);
994  Rn::setTolerance(0.000001);
995  boost::shared_ptr<Polytope_Rn> Pvol1(new Polytope_Rn());
996  boost::shared_ptr<Polytope_Rn> Pvol2(new Polytope_Rn());
997  boost::shared_ptr<Polytope_Rn> Pvol3(new Polytope_Rn());
998  boost::shared_ptr<Polytope_Rn> Pvol4(new Polytope_Rn());
999  boost::shared_ptr<Polytope_Rn> Pvol5(new Polytope_Rn());
1000  boost::shared_ptr<Polytope_Rn> Pvol6(new Polytope_Rn());
1001  boost::shared_ptr<Polytope_Rn> Pvol7(new Polytope_Rn());
1002  boost::shared_ptr<Polytope_Rn> Pvol8(new Polytope_Rn());
1003  boost::shared_ptr<Polytope_Rn> Pvol9(new Polytope_Rn());
1004  boost::shared_ptr<Polytope_Rn> Pvol10(new Polytope_Rn());
1005  boost::shared_ptr<Polytope_Rn> Pvol11(new Polytope_Rn());
1006  boost::shared_ptr<Polytope_Rn> Pvol_cube3d(new Polytope_Rn());
1007  boost::shared_ptr<Polytope_Rn> Pvol_cube4d(new Polytope_Rn());
1008  boost::shared_ptr<Polytope_Rn> Pvol_cube5d(new Polytope_Rn());
1009  boost::shared_ptr<Polytope_Rn> Pvol_cube6d(new Polytope_Rn());
1010  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis1_3d.ptop"), Pvol1) == TEST_OK );
1011  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis2_3d.ptop"), Pvol2) == TEST_OK );
1012  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis3_3d.ptop"), Pvol3) == TEST_OK );
1013  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis4_3d.ptop"), Pvol4) == TEST_OK );
1014  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis5_3d.ptop"), Pvol5) == TEST_OK );
1015  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis6_3d.ptop"), Pvol6) == TEST_OK );
1016  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis7_3d.ptop"), Pvol7) == TEST_OK );
1017  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis8_3d.ptop"), Pvol8) == TEST_OK );
1018  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis9_3d.ptop"), Pvol9) == TEST_OK );
1019  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis10_3d.ptop"), Pvol10) == TEST_OK );
1020  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis11_3d.ptop"), Pvol11) == TEST_OK );
1021  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("cube3D.ptop"), Pvol_cube3d) == TEST_OK );
1022  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("cube4D.ptop"), Pvol_cube4d) == TEST_OK );
1023  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("cube5D.ptop"), Pvol_cube5d) == TEST_OK );
1024  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("cube6D.ptop"), Pvol_cube6d) == TEST_OK );
1025  double volume1 = politopixAPI::computeVolume(Pvol1);
1026  double volume2 = politopixAPI::computeVolume(Pvol2);
1027  double volume3 = politopixAPI::computeVolume(Pvol3);
1028  double volume4 = politopixAPI::computeVolume(Pvol4);
1029  double volume5 = politopixAPI::computeVolume(Pvol5);
1030  double volume6 = politopixAPI::computeVolume(Pvol6);
1031  double volume7 = politopixAPI::computeVolume(Pvol7);
1032  double volume8 = politopixAPI::computeVolume(Pvol8);
1033  double volume9 = politopixAPI::computeVolume(Pvol9);
1034  double volume10 = politopixAPI::computeVolume(Pvol10);
1035  double volume11 = politopixAPI::computeVolume(Pvol11);
1036  BOOST_REQUIRE(6.65110e-07 < volume1 && volume1 < 6.65112e-07);
1037  BOOST_REQUIRE(6.07855e-07 < volume2 && volume2 < 6.07857e-07);
1038  BOOST_REQUIRE(1.81130e-06 < volume3 && volume3 < 1.81132e-06);
1039  BOOST_REQUIRE(7.37121e-07 < volume4 && volume4 < 7.37123e-07);
1040  BOOST_REQUIRE(5.73780e-07 < volume5 && volume5 < 5.73782e-07);
1041  BOOST_REQUIRE(3.08791e-06 < volume6 && volume6 < 3.08793e-06);
1042  BOOST_REQUIRE(1.11362e-06 < volume7 && volume7 < 1.11364e-06);
1043  BOOST_REQUIRE(1.54424e-06 < volume8 && volume8 < 1.54426e-06);
1044  BOOST_REQUIRE(1.24113e-05 < volume9 && volume9 < 1.24116e-05);
1045  BOOST_REQUIRE(3.21623e-06 < volume10 && volume10 < 3.21625e-06);
1046  BOOST_REQUIRE(2.55674e-05 < volume11 && volume11 < 2.55676e-05);
1047  double volumeC1 = politopixAPI::computeVolume(Pvol_cube3d);
1048  Rn::setDimension(4);
1049  double volumeC2 = politopixAPI::computeVolume(Pvol_cube4d);
1050  Rn::setDimension(5);
1051  double volumeC3 = politopixAPI::computeVolume(Pvol_cube5d);
1052  Rn::setDimension(6);
1053  double volumeC4 = politopixAPI::computeVolume(Pvol_cube6d);
1054  BOOST_REQUIRE(volumeC1 == 1000);
1055  BOOST_REQUIRE(volumeC2 == 10000);
1056  BOOST_REQUIRE(volumeC3 == 100000);
1057  BOOST_REQUIRE(volumeC4 == 1000000);
1058 
1059  boost::shared_ptr<Polytope_Rn> Pvol_A1(new Polytope_Rn());
1060  boost::shared_ptr<Polytope_Rn> Pvol_A2(new Polytope_Rn());
1061  boost::shared_ptr<Polytope_Rn> Pvol_A3(new Polytope_Rn());
1062  boost::shared_ptr<Polytope_Rn> Pvol_A4(new Polytope_Rn());
1063  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("BIR3-4-6_v.ptop"), Pvol_A1) == TEST_OK );
1064  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("20D6_v.ptop"), Pvol_A2) == TEST_OK );
1065  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("DG1.ptop"), Pvol_A3) == TEST_OK );
1066  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("DG2.ptop"), Pvol_A4) == TEST_OK );
1067  Rn::setDimension(4);
1068  double volumeA1 = politopixAPI::computeVolume(Pvol_A1);
1069  Rn::setDimension(6);
1070  double volumeA2 = politopixAPI::computeVolume(Pvol_A2);
1071  double volumeA3 = politopixAPI::computeVolume(Pvol_A3);
1072  double volumeA4 = politopixAPI::computeVolume(Pvol_A4);
1073  BOOST_REQUIRE(0.124 < volumeA1 && volumeA1 < 0.126);
1074  BOOST_REQUIRE(0.0114730 < volumeA2 && volumeA2 < 0.0114733);
1075  BOOST_REQUIRE(0.015947725 < volumeA3 && volumeA3 < 0.015947727);
1076  BOOST_REQUIRE(38.8410 < volumeA4 && volumeA4 < 38.8412);
1077 
1078  boost::shared_ptr<Polytope_Rn> comp1_ptop(new Polytope_Rn());
1079  boost::shared_ptr<Polytope_Rn> comp1_ppld(new Polytope_Rn());
1080  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("comp1_ctop.ptop"), comp1_ptop) == TEST_OK );
1081  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("comp1_ppld.ptop"), comp1_ppld) == TEST_OK );
1082  Rn::setDimension(3);
1083  double volume_comp1_ptop = politopixAPI::computeVolume(comp1_ptop);
1084  double volume_comp1_ppld = politopixAPI::computeVolume(comp1_ppld);
1085  BOOST_REQUIRE(0.146472616 < volume_comp1_ptop && volume_comp1_ptop < 0.146472617);
1086  BOOST_REQUIRE(0.146472611 < volume_comp1_ppld && volume_comp1_ppld < 0.146472612);
1087 
1088  cout << endl;
1089  cout << "/////////////////" << endl;
1090  cout << "// TEST CUBES //" << endl;
1091  cout << "///////////////" << endl;
1092  Rn::setDimension(6);
1093  Rn::setTolerance(0.000001);
1094  boost::shared_ptr<Polytope_Rn> cube_0, cube_1, cube_2;
1095  boost::shared_ptr<Polytope_Rn> res_cube_a(new Polytope_Rn());
1096  boost::shared_ptr<Polytope_Rn> res_cube_b(new Polytope_Rn());
1097  BOOST_REQUIRE( politopixAPI::makeCube(cube_0, 1.) == TEST_OK );
1098  BOOST_REQUIRE( politopixAPI::makeCube(cube_1, 10.) == TEST_OK );
1099  BOOST_REQUIRE( politopixAPI::makeCube(cube_2, 100.) == TEST_OK );
1100  cube_0->checkTopologyAndGeometry();
1101  cube_1->checkTopologyAndGeometry();
1102  BOOST_REQUIRE( politopixAPI::computeIntersection(cube_0, cube_1, res_cube_a) == TEST_OK );
1103  res_cube_a->checkTopologyAndGeometry();
1104  BOOST_REQUIRE( politopixAPI::computeIntersection(res_cube_a, cube_2, res_cube_b) == TEST_OK );
1105 
1106  cout << endl;
1107  cout << "/////////////////////////////" << endl;
1108  cout << "// REMOVE CAP HALF-SPACES //" << endl;
1109  cout << "///////////////////////////" << endl;
1110  Rn::setDimension(5);
1111  Rn::setTolerance(0.000001);
1112  string ppiston = string("test/CAPS/PISTON/5D/");
1114  boost::shared_ptr<Polytope_Rn> P1_5D(new Polytope_Rn());
1115  boost::shared_ptr<Polytope_Rn> P2_5D(new Polytope_Rn());
1116  boost::shared_ptr<Polytope_Rn> P3_5D(new Polytope_Rn());
1117  boost::shared_ptr<Polytope_Rn> P4_5D(new Polytope_Rn());
1118  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("P1.ptop"), P1_5D) == TEST_OK );
1119  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P1_5D, 1000.) == TEST_OK );
1120  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("P2.ptop"), P2_5D) == TEST_OK );
1121  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P2_5D, 1000.) == TEST_OK );
1122  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("P3.ptop"), P3_5D) == TEST_OK );
1123  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P3_5D, 1000.) == TEST_OK );
1124  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("P4.ptop"), P4_5D) == TEST_OK );
1125  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P4_5D, 1000.) == TEST_OK );
1126  boost::shared_ptr<Polytope_Rn> ps_P12_5D_S1(new Polytope_Rn());
1127  boost::shared_ptr<Polytope_Rn> ps_P12_5D_S2(new Polytope_Rn());
1128  boost::shared_ptr<Polytope_Rn> ps_P123_5D_S1(new Polytope_Rn());
1129  boost::shared_ptr<Polytope_Rn> ps_P123_5D_S2(new Polytope_Rn());
1130  boost::shared_ptr<Polytope_Rn> ps_P1234_5D_S1(new Polytope_Rn());
1131  boost::shared_ptr<Polytope_Rn> ps_P1234_5D_S2(new Polytope_Rn());
1132  std::set< unsigned int > P1Caps, P2Caps, P3Caps, P4Caps;
1133  std::set< unsigned int > Sum12Caps, Sum123Caps, Sum1234Caps;
1134  {for (unsigned int i=0; i<2; ++i) {
1135  P2Caps.insert(i);
1136  P3Caps.insert(i);
1137  P4Caps.insert(i);
1138  }}
1139  {for (unsigned int i=0; i<4; ++i) {
1140  P1Caps.insert(i);
1141  }}
1142  cout << "############################" << endl;
1143  cout << "# pseudosum: P1 + P2 = P12 #" << endl;
1144  cout << "############################" << endl;
1145  BOOST_REQUIRE( politopixAPI::pseudoSum(P1_5D, P2_5D, ps_P12_5D_S1, P1Caps, P2Caps, Sum12Caps) == TEST_OK );
1146  BOOST_REQUIRE( politopixAPI::pseudoSum(P2_5D, P1_5D, ps_P12_5D_S2, P2Caps, P1Caps, Sum12Caps) == TEST_OK );
1147  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(ps_P12_5D_S1, ps_P12_5D_S2) == TEST_OK );
1148  cout << "##############################" << endl;
1149  cout << "# pseudosum: P12 + P3 = P123 #" << endl;
1150  cout << "##############################" << endl;
1151  BOOST_REQUIRE( politopixAPI::pseudoSum(ps_P12_5D_S1, P3_5D, ps_P123_5D_S1, Sum12Caps, P3Caps, Sum123Caps) == TEST_OK );
1152  BOOST_REQUIRE( politopixAPI::pseudoSum(P3_5D, ps_P12_5D_S1, ps_P123_5D_S2, P3Caps, Sum12Caps, Sum123Caps) == TEST_OK );
1153  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(ps_P123_5D_S1, ps_P123_5D_S2) == TEST_OK );
1154  cout << "################################" << endl;
1155  cout << "# pseudosum: P123 + P4 = P1234 #" << endl;
1156  cout << "################################" << endl;
1157  BOOST_REQUIRE( politopixAPI::pseudoSum(ps_P123_5D_S1, P4_5D, ps_P1234_5D_S1, Sum123Caps, P4Caps, Sum1234Caps) == TEST_OK );
1158  BOOST_REQUIRE( politopixAPI::pseudoSum(P4_5D, ps_P123_5D_S1, ps_P1234_5D_S2, P4Caps, Sum123Caps, Sum1234Caps) == TEST_OK );
1159  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(ps_P1234_5D_S1, ps_P1234_5D_S2) == TEST_OK );
1161  boost::shared_ptr<Polytope_Rn> polP12_5D(new Polytope_Rn());
1162  boost::shared_ptr<Polytope_Rn> shgP12_5D(new Polytope_Rn());
1163  boost::shared_ptr<Polytope_Rn> polP123_5D(new Polytope_Rn());
1164  boost::shared_ptr<Polytope_Rn> shgP123_5D(new Polytope_Rn());
1165  boost::shared_ptr<Polytope_Rn> polP1234_5D(new Polytope_Rn());
1166  boost::shared_ptr<Polytope_Rn> shgP1234_5D(new Polytope_Rn());
1167  cout << "############################" << endl;
1168  cout << "# with caps: P1 + P2 = P12 #" << endl;
1169  cout << "############################" << endl;
1170  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(P1_5D, P2_5D, polP12_5D) == TEST_OK );
1171  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("shgP12.ptop"), shgP12_5D) == TEST_OK );
1172  BOOST_REQUIRE( politopixAPI::checkEqualityOfVertices(polP12_5D, shgP12_5D) == TEST_OK );
1173  cout << "##############################" << endl;
1174  cout << "# with caps: P12 + P3 = P123 #" << endl;
1175  cout << "##############################" << endl;
1176  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(polP12_5D, P3_5D, polP123_5D) == TEST_OK );
1177  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("shgP123.ptop"), shgP123_5D) == TEST_OK );
1178  BOOST_REQUIRE( politopixAPI::checkEqualityOfVertices(polP123_5D, shgP123_5D) == TEST_OK );
1179  cout << "################################" << endl;
1180  cout << "# with caps: P123 + P4 = P1234 #" << endl;
1181  cout << "################################" << endl;
1182  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(polP123_5D, P4_5D, polP1234_5D) == TEST_OK );
1183  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("shgP1234.ptop"), shgP1234_5D) == TEST_OK );
1184  BOOST_REQUIRE( politopixAPI::checkEqualityOfVertices(polP1234_5D, shgP1234_5D) == TEST_OK );
1186  std::set< unsigned int > hyperplanes2project2D;
1187  hyperplanes2project2D.insert(3);
1188  hyperplanes2project2D.insert(4);
1189  boost::shared_ptr<Polytope_Rn> proj_polP1234_5D(new Polytope_Rn());
1190  boost::shared_ptr<Polytope_Rn> proj_ps_P1234_5D_S1(new Polytope_Rn());
1191  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project2D, ps_P1234_5D_S1, proj_ps_P1234_5D_S1);
1192  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project2D, polP1234_5D, proj_polP1234_5D);
1193  Rn::setDimension(2);
1194  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(proj_ps_P1234_5D_S1, proj_polP1234_5D) == TEST_OK );
1195  boost::shared_ptr<Polytope_Rn> finalP2D(new Polytope_Rn());
1196  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("P1234_2D.ptop"), finalP2D) == TEST_OK );
1197  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(proj_ps_P1234_5D_S1, finalP2D) == TEST_OK );
1199  string path_test_caps = string("test/CAPS/");
1200  {for (int i=1; i<argc; ++i) {
1201  if (strcmp(argv[i], "piston") == 0) {
1202  Rn::setDimension(6);
1203  Rn::setTolerance(0.000001);
1204  cout << "##########" << endl;
1205  cout << "# Piston #" << endl;
1206  cout << "##########" << endl;
1207  string path_test_caps_piston = path_test_caps+string("PISTON/");
1208  boost::shared_ptr<Polytope_Rn> pist1_TestCaps(new Polytope_Rn());
1209  boost::shared_ptr<Polytope_Rn> pist2_TestCaps(new Polytope_Rn());
1210  boost::shared_ptr<Polytope_Rn> pist_Sum_TestCaps(new Polytope_Rn());
1211  boost::shared_ptr<Polytope_Rn> pist_Sum_TestCaps_check(new Polytope_Rn());
1212  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps_piston + string("P1_6D_HV.ptop"), pist1_TestCaps) == TEST_OK );
1213  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps_piston + string("P2_6D_HV.ptop"), pist2_TestCaps) == TEST_OK );
1214  std::set< unsigned int > PO1Caps, PO2Caps, PSum_1Caps_;
1215  PO1Caps.insert(0); PO1Caps.insert(1); PO1Caps.insert(2); PO1Caps.insert(3);
1216  PO2Caps.insert(0); PO2Caps.insert(1); PO2Caps.insert(2); PO2Caps.insert(3);
1217  BOOST_REQUIRE( politopixAPI::pseudoSum(pist1_TestCaps, pist2_TestCaps, pist_Sum_TestCaps, PO1Caps, PO2Caps, PSum_1Caps_) == TEST_OK );
1218  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps_piston + string("Sum_6D_proj_HV.ptop"), pist_Sum_TestCaps_check) == TEST_OK );
1219  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(pist_Sum_TestCaps, pist_Sum_TestCaps_check) == TEST_OK );
1220  }
1221  }}
1222  Rn::setDimension(3);
1223  Rn::setTolerance(0.0001);
1224  cout << "#########" << endl;
1225  cout << "# R3 Ex #" << endl;
1226  cout << "#########" << endl;
1227  boost::shared_ptr<Polytope_Rn> p1_TestCaps(new Polytope_Rn());
1228  boost::shared_ptr<Polytope_Rn> p2_TestCaps(new Polytope_Rn());
1229  boost::shared_ptr<Polytope_Rn> Sum_TestCaps(new Polytope_Rn());
1230  boost::shared_ptr<Polytope_Rn> Sum_TestCaps_check(new Polytope_Rn());
1231  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps + string("cube3D.ptop"), p1_TestCaps) == TEST_OK );
1232  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps + string("lmp1_v.ptop"), p2_TestCaps) == TEST_OK );
1233  std::set< unsigned int > O1Caps, O2Caps, Sum_1Caps_;
1234  O1Caps.insert(0); O1Caps.insert(1); O1Caps.insert(3); O1Caps.insert(4);
1235  BOOST_REQUIRE( politopixAPI::pseudoSum(p1_TestCaps, p2_TestCaps, Sum_TestCaps, O1Caps, O2Caps, Sum_1Caps_) == TEST_OK );
1236  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps + string("lmp1_v_cube3D_testCaps.ptop"), Sum_TestCaps_check) == TEST_OK );
1237  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Sum_TestCaps, Sum_TestCaps_check) == TEST_OK );
1238 
1239  cout << "###########" << endl;
1240  cout << "# CIRP R6 #" << endl;
1241  cout << "###########" << endl;
1242  Rn::setDimension(6);
1243  Rn::setTolerance(0.000001);
1244  boost::shared_ptr<Polytope_Rn> p1_TestCaps_b(new Polytope_Rn());
1245  boost::shared_ptr<Polytope_Rn> p2_TestCaps_b(new Polytope_Rn());
1246  boost::shared_ptr<Polytope_Rn> Sum_TestCaps_b(new Polytope_Rn());
1247  boost::shared_ptr<Polytope_Rn> Sum_TestCaps_check_b(new Polytope_Rn());
1248  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps + string("P1_6D_HV.ptop"), p1_TestCaps_b) == TEST_OK );
1249  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps + string("P2_6D_HV.ptop"), p2_TestCaps_b) == TEST_OK );
1250  std::set< unsigned int > O1Caps_b, O2Caps_b, Sum_1Caps_b;
1251  O1Caps_b.insert(0); O1Caps_b.insert(1); O1Caps_b.insert(2); O1Caps_b.insert(3); O1Caps_b.insert(4); O1Caps_b.insert(5);
1252  O2Caps_b.insert(0); O2Caps_b.insert(1); O2Caps_b.insert(2); O2Caps_b.insert(3); O2Caps_b.insert(4); O2Caps_b.insert(5);
1253  BOOST_REQUIRE( politopixAPI::pseudoSum(p1_TestCaps_b, p2_TestCaps_b, Sum_TestCaps_b, O1Caps_b, O2Caps_b, Sum_1Caps_b) == TEST_OK );
1254  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps + string("P1_P2_testCaps.ptop"), Sum_TestCaps_check_b) == TEST_OK );
1255  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Sum_TestCaps_b, Sum_TestCaps_check_b) == TEST_OK );
1256 
1257  cout << "############" << endl;
1258  cout << "# SPEC CAP #" << endl;
1259  cout << "############" << endl;
1260  Rn::setDimension(6);
1261  Rn::setTolerance(0.000001);
1262  string path_test_caps2 = string("test/CAPS/spec_small_disc/");
1263  boost::shared_ptr<Polytope_Rn> Pc_21(new Polytope_Rn());
1264  boost::shared_ptr<Polytope_Rn> Pc_22(new Polytope_Rn());
1265  boost::shared_ptr<Polytope_Rn> Pc_23(new Polytope_Rn());
1266  boost::shared_ptr<Polytope_Rn> Pc_24(new Polytope_Rn());
1267  boost::shared_ptr<Polytope_Rn> Pc_25(new Polytope_Rn());
1268  boost::shared_ptr<Polytope_Rn> Pc_26(new Polytope_Rn());
1269  boost::shared_ptr<Polytope_Rn> Pg_37(new Polytope_Rn());
1270  boost::shared_ptr<Polytope_Rn> Pg_38(new Polytope_Rn());
1271  boost::shared_ptr<Polytope_Rn> Pg_14(new Polytope_Rn());
1272  cout << "#########################" << endl;
1273  cout << "# SPEC CAP: truncations #" << endl;
1274  cout << "#########################" << endl;
1275  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_10.ptop"), Pc_21) == TEST_OK );
1276  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pc_21, 1000.) == TEST_OK );
1277  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_11.ptop"), Pc_22) == TEST_OK );
1278  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pc_22, 1000.) == TEST_OK );
1279  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_3.ptop"), Pc_23) == TEST_OK );
1280  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pc_23, 1000.) == TEST_OK );
1281  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_4.ptop"), Pc_24) == TEST_OK );
1282  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pc_24, 1000.) == TEST_OK );
1283  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_12.ptop"), Pc_25) == TEST_OK );
1284  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pc_25, 1000.) == TEST_OK );
1285  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_13.ptop"), Pc_26) == TEST_OK );
1286  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pc_26, 1000.) == TEST_OK );
1287  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_7.ptop"), Pg_37) == TEST_OK );
1288  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pg_37, 1000.) == TEST_OK );
1289  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_8.ptop"), Pg_38) == TEST_OK );
1290  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pg_38, 1000.) == TEST_OK );
1291  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_9.ptop"), Pg_14) == TEST_OK );
1292  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pg_14, 1000.) == TEST_OK );
1293  std::set< unsigned int > Int_1Caps, Int_2Caps, Sum_1Caps, Sum_1_s2Caps, P_11_20_FC1Caps, P_20_30_FC1Caps;
1294  std::set< unsigned int > Pc_21Caps, Pc_22Caps, Pc_23Caps, Pc_24Caps, Pc_25Caps, Pc_26Caps, Pg_37Caps;
1295  {for (unsigned int i=0; i<8; ++i) {
1296  Pc_21Caps.insert(i);Pc_22Caps.insert(i);
1297  }}
1298  {for (unsigned int i=0; i<6; ++i) {
1299  Pc_23Caps.insert(i);Pc_24Caps.insert(i);
1300  }}
1301  {for (unsigned int i=0; i<4; ++i) {
1302  Pg_37Caps.insert(i);
1303  }}
1304  Pc_25Caps.insert(0);Pc_26Caps.insert(0);Pc_25Caps.insert(1);Pc_26Caps.insert(1);Pc_25Caps.insert(6);Pc_26Caps.insert(6);Pc_25Caps.insert(7);Pc_26Caps.insert(7);
1305  cout << endl;
1306  cout << "######################" << endl;
1307  cout << "# Operations for FC1 #" << endl;
1308  cout << "######################" << endl;
1309  boost::shared_ptr<Polytope_Rn> Int_1, Int_2, P_11_20_FC1, P_20_30_FC1;
1310  boost::shared_ptr<Polytope_Rn> Sum_1(new Polytope_Rn()); boost::shared_ptr<Polytope_Rn> Sum_1_s2(new Polytope_Rn());
1311  BOOST_REQUIRE( politopixAPI::pseudoIntersection(Pc_21, Pc_22, Int_1, Pc_21Caps, Pc_22Caps, Int_1Caps) == TEST_OK );
1312  BOOST_REQUIRE( politopixAPI::pseudoSum(Pc_23, Int_1, Sum_1, Pc_23Caps, Int_1Caps, Sum_1Caps) == TEST_OK );
1313  BOOST_REQUIRE( politopixAPI::pseudoSum(Int_1, Pc_23, Sum_1_s2, Int_1Caps, Pc_23Caps, Sum_1_s2Caps) == TEST_OK );
1314  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Sum_1, Sum_1_s2) == TEST_OK );
1315 
1316  Int_2.reset(new Polytope_Rn()); P_11_20_FC1.reset(new Polytope_Rn()); P_20_30_FC1.reset(new Polytope_Rn());
1317  BOOST_REQUIRE( politopixAPI::pseudoIntersection(Sum_1, Int_1, P_11_20_FC1, Sum_1Caps, Int_1Caps, P_11_20_FC1Caps) == TEST_OK );
1318  BOOST_REQUIRE( politopixAPI::pseudoIntersection(Pc_24, Pc_25, Int_2, Pc_24Caps, Pc_25Caps, Int_2Caps) == TEST_OK );
1319  BOOST_REQUIRE( politopixAPI::pseudoIntersection(Int_2, Pc_26, P_20_30_FC1, Int_2Caps, Pc_26Caps, P_20_30_FC1Caps) == TEST_OK );
1320 
1321  cout << "#########################################" << endl;
1322  cout << "# Polytope from node 1.0 to 3.0 for FC1 #" << endl;
1323  cout << "#########################################" << endl;
1324  boost::shared_ptr<Polytope_Rn> P_11_30_FC1_s1(new Polytope_Rn()); boost::shared_ptr<Polytope_Rn> P_11_30_FC1_s2(new Polytope_Rn());
1325  std::set< unsigned int > P_11_30_FC1_s2Caps, P_11_30_FC1_s1Caps;
1326  BOOST_REQUIRE( politopixAPI::pseudoSum(P_20_30_FC1, P_11_20_FC1, P_11_30_FC1_s2, P_20_30_FC1Caps, P_11_20_FC1Caps, P_11_30_FC1_s2Caps) == TEST_OK );
1327  BOOST_REQUIRE( politopixAPI::pseudoSum(P_11_20_FC1, P_20_30_FC1, P_11_30_FC1_s1, P_11_20_FC1Caps, P_20_30_FC1Caps, P_11_30_FC1_s1Caps) == TEST_OK );
1328  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(P_11_30_FC1_s1, P_11_30_FC1_s2) == TEST_OK );
1329 
1330  cout << "#####################" << endl;
1331  cout << "# Final sum for FC1 #" << endl;
1332  cout << "#####################" << endl;
1333  boost::shared_ptr<Polytope_Rn> Pfin_FC1_s1(new Polytope_Rn()); boost::shared_ptr<Polytope_Rn> Pfin_FC1_s2(new Polytope_Rn());
1334  std::set< unsigned int > Pfin_FC1_s1Caps, Pfin_FC1_s2Caps;
1335  BOOST_REQUIRE( politopixAPI::pseudoSum(P_11_30_FC1_s1, Pg_37, Pfin_FC1_s1, P_11_30_FC1_s1Caps, Pg_37Caps, Pfin_FC1_s1Caps) == TEST_OK );
1336  BOOST_REQUIRE( politopixAPI::pseudoSum(Pg_37, P_11_30_FC1_s1, Pfin_FC1_s2, Pg_37Caps, P_11_30_FC1_s1Caps, Pfin_FC1_s2Caps) == TEST_OK );
1337  //std::copy(Pfin_FC1_s1Caps.begin(), Pfin_FC1_s1Caps.end(), std::ostream_iterator<unsigned int>(std::cout, " ") );
1338  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pfin_FC1_s1, Pfin_FC1_s2) == TEST_OK );
1339  boost::shared_ptr<Polytope_Rn> final_sant(new Polytope_Rn());
1340  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("final_sant.ptop"), final_sant) == TEST_OK );
1341  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pfin_FC1_s1, final_sant) == TEST_OK );
1342  cout << endl;
1343 
1344 
1345 
1346  cout << "#############################" << endl;
1347  cout << "# Simulation cutting system #" << endl;
1348  cout << "#############################" << endl;
1349  Rn::setDimension(6);
1350  Rn::setTolerance(0.000001);
1351  string path_test_cutting = string("test/AFILADO/");
1352  boost::shared_ptr<Polytope_Rn> P11(new Polytope_Rn());
1353  boost::shared_ptr<Polytope_Rn> P33_43(new Polytope_Rn());
1354  boost::shared_ptr<Polytope_Rn> P34_44(new Polytope_Rn());
1355  boost::shared_ptr<Polytope_Rn> P41(new Polytope_Rn());
1356  cout << "########################" << endl;
1357  cout << "# CUTTING: truncations #" << endl;
1358  cout << "########################" << endl;
1359  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_cutting + string("Afilado_Polytope_1.ptop"), P11) == TEST_OK );
1360  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_cutting + string("Afilado_Polytope_6.ptop"), P33_43) == TEST_OK );
1361  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_cutting + string("Afilado_Polytope_10.ptop"), P34_44) == TEST_OK );
1362  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_cutting + string("Afilado_Polytope_11.ptop"), P41) == TEST_OK );
1363  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P11, 1000.) == TEST_OK );
1364  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P33_43, 1000.) == TEST_OK );
1365  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P34_44, 1000.) == TEST_OK );
1366  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P41, 1000.) == TEST_OK );
1367  boost::shared_ptr<Polytope_Rn> P30_40(new Polytope_Rn());
1368  boost::shared_ptr<Polytope_Rn> P11_41S2(new Polytope_Rn());
1369  boost::shared_ptr<Polytope_Rn> P11_41S1(new Polytope_Rn());
1370  boost::shared_ptr<Polytope_Rn> PfinS1(new Polytope_Rn());
1371  boost::shared_ptr<Polytope_Rn> PfinS2(new Polytope_Rn());
1372  boost::shared_ptr<Polytope_Rn> PfinS3(new Polytope_Rn());
1373  std::set< unsigned int > P11Caps, P33_43Caps, P34_44Caps, P41Caps;
1374  std::set< unsigned int > P30_40Caps, P11_41Caps, PfinCaps;
1375  {for (unsigned int i=0; i<10; ++i) {
1376  P34_44Caps.insert(i);
1377  }}
1378  {for (unsigned int i=0; i<4; ++i) {
1379  P11Caps.insert(i);
1380  P41Caps.insert(i);
1381  P33_43Caps.insert(i);
1382  }}
1383 
1384  cout << "##############" << endl;
1385  cout << "# Operations #" << endl;
1386  cout << "##############" << endl;
1387  BOOST_REQUIRE( politopixAPI::pseudoIntersection(P33_43, P34_44, P30_40, P33_43Caps, P34_44Caps, P30_40Caps) == TEST_OK );
1388  BOOST_REQUIRE( politopixAPI::pseudoSum(P11, P41, P11_41S1, P11Caps, P41Caps, P11_41Caps) == TEST_OK );
1389  BOOST_REQUIRE( politopixAPI::pseudoSum(P41, P11, P11_41S2, P41Caps, P11Caps, P11_41Caps) == TEST_OK );
1390  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(P11_41S1, P11_41S2) == TEST_OK );
1391  cout << "#############" << endl;
1392  cout << "# Final sum #" << endl;
1393  cout << "#############" << endl;
1394  BOOST_REQUIRE( politopixAPI::pseudoSum(P11_41S1, P30_40, PfinS1, P11_41Caps, P30_40Caps, PfinCaps) == TEST_OK );
1395  BOOST_REQUIRE( politopixAPI::pseudoSum(P30_40, P11_41S1, PfinS2, P30_40Caps, P11_41Caps, PfinCaps) == TEST_OK );
1396  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(PfinS1, PfinS2) == TEST_OK );
1397  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_cutting + string("Pfin.ptop"), PfinS3) == TEST_OK );
1398  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(PfinS1, PfinS3) == TEST_OK );
1399  cout << endl;
1400 
1401  cout << "###################" << endl;
1402  cout << "# DATA1: Lattices #" << endl;
1403  cout << "###################" << endl;
1404  Rn::setDimension(3);
1405  path_test1 = string("./test/DATA1/");
1406  _polytopeTest.reset(new Polytope_Rn());
1407  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("lmp1.ptop"), _polytopeTest) == TEST_OK );
1408  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
1409  FaceEnumeration FaceEnumLmp1(_polytopeTest);
1410  FaceEnumeration::Compute(_polytopeTest, FaceEnumLmp1);
1411  //FaceEnumLmp1.printFacesWithFacets(std::cout);
1412  //FaceEnumLmp1.printFacesWithVertices(std::cout);
1413  std::vector< std::vector< ListOfFaces > > Lattice2Compare;
1414  FaceEnumeration::load(path_test1 + string("lmp1.latt"), Lattice2Compare);
1415  //BOOST_REQUIRE(FaceEnumLmp1.getFacesWithVertices() == Lattice2Compare);
1416 
1417  Rn::setDimension(3);
1418  _polytopeTest.reset(new Polytope_Rn());
1419  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cube3D.ptop"), _polytopeTest) == TEST_OK );
1420  FaceEnumeration FaceEnumCube(_polytopeTest);
1421  FaceEnumeration::Compute(_polytopeTest, FaceEnumCube);
1422  //FaceEnumCube.printFacesWithFacets(std::cout);
1423  //FaceEnumCube.printFacesWithVertices(std::cout);
1424  Lattice2Compare.clear();
1425  FaceEnumeration::load(path_test1 + string("cube3d.latt"), Lattice2Compare);
1426  //BOOST_REQUIRE(FaceEnumCube.getFacesWithVertices() == Lattice2Compare);
1427 
1428  Rn::setDimension(6);
1429  _polytopeTest.reset(new Polytope_Rn());
1430  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("8D6.ptop"), _polytopeTest) == TEST_OK );
1431  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
1432  FaceEnumeration FaceEnum(_polytopeTest);
1433  FaceEnumeration::Compute(_polytopeTest, FaceEnum);
1434  //FaceEnum.printFacesWithFacets(std::cout);
1435  //FaceEnum.printFacesWithVertices(std::cout);
1436  Lattice2Compare.clear();
1437  FaceEnumeration::load(path_test1 + string("8D6.latt"), Lattice2Compare);
1438  //BOOST_REQUIRE(FaceEnum.getFacesWithVertices() == Lattice2Compare);
1439 
1440  Rn::setDimension(6);
1441  _polytopeTest.reset(new Polytope_Rn());
1442  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("10D6.ptop"), _polytopeTest) == TEST_OK );
1443  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
1444  FaceEnumeration FaceEnum2(_polytopeTest);
1445  FaceEnumeration::Compute(_polytopeTest, FaceEnum2);
1446  //FaceEnum2.printFacesWithFacets(std::cout);
1447  //FaceEnum2.printFacesWithVertices(std::cout);
1448  Lattice2Compare.clear();
1449  FaceEnumeration::load(path_test1 + string("10D6.latt"), Lattice2Compare);
1450  //BOOST_REQUIRE(FaceEnum2.getFacesWithVertices() == Lattice2Compare);
1451 
1452  Rn::setDimension(6);
1453  _polytopeTest.reset(new Polytope_Rn());
1454  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("P9.ptop"), _polytopeTest) == TEST_OK );
1455  FaceEnumeration FaceEnum_9(_polytopeTest);
1456  FaceEnumeration::Compute(_polytopeTest, FaceEnum_9);
1457  //FaceEnum_9.printFacesWithFacets(std::cout);
1458  //FaceEnum_9.printFacesWithVerticesToSage(std::cout);
1459  //FaceEnum_9.save(std::cout);
1460  Lattice2Compare.clear();
1461  FaceEnumeration::load(path_test1 + string("P9.latt"), Lattice2Compare);
1462  //BOOST_REQUIRE(FaceEnum_9.getFacesWithVertices() == Lattice2Compare);
1463  cout << endl;
1464 
1465  cout << "###############" << endl;
1466  cout << "# PROJECTIONS #" << endl;
1467  cout << "###############" << endl;
1468  Rn::setDimension(6);
1469  Rn::setTolerance(0.00001);
1470  boost::shared_ptr<HalfSpace_Rn> H1(new HalfSpace_Rn(6)), H2(new HalfSpace_Rn(6)), H3(new HalfSpace_Rn(6));
1471  {for (unsigned int i=0; i<6; ++i) {
1472  H1->setCoefficient(i,0);
1473  H2->setCoefficient(i,0);
1474  H3->setCoefficient(i,0);
1475  }}
1476  H1->setCoefficient(0,1);
1477  H2->setCoefficient(1,1);
1478  H3->setCoefficient(2,1);
1479  H1->setConstant(0);
1480  H2->setConstant(0);
1481  H3->setConstant(0);
1482  std::vector< boost::shared_ptr<HalfSpace_Rn> > arrayOfHS;
1483  arrayOfHS.push_back(H1);
1484  arrayOfHS.push_back(H2);
1485  arrayOfHS.push_back(H3);
1486  //{for (unsigned int i=0; i<arrayOfHS.size(); ++i) {
1487  //arrayOfHS[i]->dump(cout);
1488  //cout << endl;
1489  //}}
1490  string pcaps = string("test/PROJ/");
1491  boost::shared_ptr<Polytope_Rn> P2Test(new Polytope_Rn()), Pproj(new Polytope_Rn()), P2Compare(new Polytope_Rn()), transPol(new Polytope_Rn());
1492 
1493  P2Test.reset(new Polytope_Rn());
1494  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("P11_41.ptop"), P2Test) == TEST_OK );
1495  std::set< unsigned int > hyperplanes2project;
1496  hyperplanes2project.insert(1);hyperplanes2project.insert(2);hyperplanes2project.insert(3);
1497  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, P2Test, Pproj);
1498  P2Compare.reset(new Polytope_Rn());
1499  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("_P11_41_3D_H.ptop"), P2Compare) == TEST_OK );
1500  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1501  P2Compare.reset(new Polytope_Rn());
1502  transPol.reset(new Polytope_Rn());
1503  NormalFan_Rn NF(P2Test);
1504  NF.computeHyperplanesSeparationForProjection(arrayOfHS, transPol);
1505  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, transPol, P2Compare);
1506  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1507 
1508  cout << endl;
1509  P2Test.reset(new Polytope_Rn());
1510  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("P30_40.ptop"), P2Test) == TEST_OK );
1511  hyperplanes2project.clear();
1512  hyperplanes2project.insert(1);hyperplanes2project.insert(2);hyperplanes2project.insert(3);
1513  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, P2Test, Pproj);
1514  P2Compare.reset(new Polytope_Rn());
1515  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("_P30_40_3D_H.ptop"), P2Compare) == TEST_OK );
1516  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1517  P2Compare.reset(new Polytope_Rn());
1518  transPol.reset(new Polytope_Rn());
1519  NormalFan_Rn NF_P30_40(P2Test);
1520  NF_P30_40.computeHyperplanesSeparationForProjection(arrayOfHS, transPol);
1521  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, transPol, P2Compare);
1522  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1523 
1524  cout << endl;
1525  P2Test.reset(new Polytope_Rn());
1526  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("Polytope_1.ptop"), P2Test) == TEST_OK );
1527  hyperplanes2project.clear();
1528  hyperplanes2project.insert(1);hyperplanes2project.insert(2);hyperplanes2project.insert(3);
1529  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, P2Test, Pproj);
1530  P2Compare.reset(new Polytope_Rn());
1531  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("_Polytope_1_3D_H.ptop"), P2Compare) == TEST_OK );
1532  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1533  P2Compare.reset(new Polytope_Rn());
1534  transPol.reset(new Polytope_Rn());
1535  NormalFan_Rn NF_Polytope_1(P2Test);
1536  NF_Polytope_1.computeHyperplanesSeparationForProjection(arrayOfHS, transPol);
1537  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, transPol, P2Compare);
1538  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1539 
1540  cout << endl;
1541  P2Test.reset(new Polytope_Rn());
1542  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("Polytope_6.ptop"), P2Test) == TEST_OK );
1543  hyperplanes2project.clear();
1544  hyperplanes2project.insert(1);hyperplanes2project.insert(2);hyperplanes2project.insert(3);
1545  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, P2Test, Pproj);
1546  P2Compare.reset(new Polytope_Rn());
1547  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("_Polytope_6_3D_H.ptop"), P2Compare) == TEST_OK );
1548  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1549  P2Compare.reset(new Polytope_Rn());
1550  transPol.reset(new Polytope_Rn());
1551  NormalFan_Rn NF_Polytope_6(P2Test);
1552  NF_Polytope_6.computeHyperplanesSeparationForProjection(arrayOfHS, transPol);
1553  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, transPol, P2Compare);
1554  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1555 
1556  cout << endl;
1557  P2Test.reset(new Polytope_Rn());
1558  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("Polytope_10.ptop"), P2Test) == TEST_OK );
1559  hyperplanes2project.clear();
1560  hyperplanes2project.insert(1);hyperplanes2project.insert(2);hyperplanes2project.insert(3);
1561  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, P2Test, Pproj);
1562  P2Compare.reset(new Polytope_Rn());
1563  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("_Polytope_10_3D_H.ptop"), P2Compare) == TEST_OK );
1564  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1565  P2Compare.reset(new Polytope_Rn());
1566  transPol.reset(new Polytope_Rn());
1567  NormalFan_Rn NF_Polytope_10(P2Test);
1568  //NF_Polytope_10.dump(cout);
1569  NF_Polytope_10.computeHyperplanesSeparationForProjection(arrayOfHS, transPol);
1570  BOOST_REQUIRE( politopixAPI::savePolytope(string("step1.ptop"), transPol) == TEST_OK );
1571  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, transPol, P2Compare);
1572  BOOST_REQUIRE( politopixAPI::savePolytope(string("step2.ptop"), P2Compare) == TEST_OK );
1573  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1574 
1575  cout << endl;
1576  P2Test.reset(new Polytope_Rn());
1577  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("Polytope_11.ptop"), P2Test) == TEST_OK );
1578  hyperplanes2project.clear();
1579  hyperplanes2project.insert(1);hyperplanes2project.insert(2);hyperplanes2project.insert(3);
1580  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, P2Test, Pproj);
1581  P2Compare.reset(new Polytope_Rn());
1582  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("_Polytope_11_3D_H.ptop"), P2Compare) == TEST_OK );
1583  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1584  P2Compare.reset(new Polytope_Rn());
1585  transPol.reset(new Polytope_Rn());
1586  NormalFan_Rn NF_Polytope_11(P2Test);
1587  NF_Polytope_11.computeHyperplanesSeparationForProjection(arrayOfHS, transPol);
1588  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, transPol, P2Compare);
1589  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1590 
1591  cout << "#####################" << endl;
1592  cout << "# TRACING GENERATORS #" << endl;
1593  cout << "#####################" << endl;
1594  Rn::setDimension(6);
1595  Rn::setTolerance(0.000001);
1596  string tal_path("test/TALADRO/");
1597  boost::shared_ptr<Polytope_Rn> Tal_CP1(new Polytope_Rn()),Tal_CP2(new Polytope_Rn()),Tal_CP3(new Polytope_Rn()),Tal_SUM12(new Polytope_Rn());
1598  boost::shared_ptr<Polytope_Rn> Tal_checkSUM12(new Polytope_Rn()),Tal_SUM123(new Polytope_Rn());
1599  BOOST_REQUIRE( politopixAPI::loadPolytope(tal_path + string("CP1.ptop"), Tal_CP1) == TEST_OK );
1600  BOOST_REQUIRE( politopixAPI::loadPolytope(tal_path + string("CP2.ptop"), Tal_CP2) == TEST_OK );
1601  BOOST_REQUIRE( politopixAPI::loadPolytope(tal_path + string("CP3.ptop"), Tal_CP3) == TEST_OK );
1602  std::vector< std::vector<int> > genitorsOfTal_CP1(Tal_CP1->numberOfGenerators());
1603  std::vector< std::vector<int> > genitorsOfTal_CP2(Tal_CP2->numberOfGenerators());
1604  std::vector< std::vector<int> > genitorsOfTal_CP3(Tal_CP3->numberOfGenerators());
1605  std::vector< std::vector<int> > genitorsOfTal_CP_1_2,genitorsOfTal_CP_1_2_3;
1606  {
1607  for (unsigned int i=0; i<genitorsOfTal_CP1.size(); ++i)
1608  genitorsOfTal_CP1[i].push_back(i);
1609  for (unsigned int j=0; j<genitorsOfTal_CP2.size(); ++j)
1610  genitorsOfTal_CP2[j].push_back(j);
1611  for (unsigned int j=0; j<genitorsOfTal_CP3.size(); ++j)
1612  genitorsOfTal_CP3[j].push_back(j);
1613  }
1614  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(Tal_CP1, Tal_CP2, Tal_SUM12, genitorsOfTal_CP1, genitorsOfTal_CP2, genitorsOfTal_CP_1_2) == TEST_OK );
1615  BOOST_REQUIRE( politopixAPI::loadPolytope(tal_path + string("CP_1_2.ptop"), Tal_checkSUM12) == TEST_OK );
1616  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Tal_SUM12, Tal_checkSUM12) == TEST_OK );
1617  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(Tal_SUM12, Tal_CP3, Tal_SUM123, genitorsOfTal_CP_1_2, genitorsOfTal_CP3, genitorsOfTal_CP_1_2_3) == TEST_OK );
1618  {
1619  unsigned int thisDim = Rn::getDimension();
1620  double tol_2 = Rn::getTolerance()*Rn::getTolerance();
1621  for (unsigned int i=0; i<genitorsOfTal_CP_1_2.size(); ++i) {
1622  boost::shared_ptr<Generator_Rn> VX(new Generator_Rn(thisDim));
1623  VX->makeSum(Tal_CP1->getGenerator(genitorsOfTal_CP_1_2[i][0]), Tal_CP2->getGenerator(genitorsOfTal_CP_1_2[i][1]));
1624  BOOST_REQUIRE( VX->isEqual2(Tal_SUM12->getGenerator(i), thisDim, tol_2) == true );
1625  }
1626  for (unsigned int i=0; i<genitorsOfTal_CP_1_2_3.size(); ++i) {
1627  boost::shared_ptr<Generator_Rn> VX(new Generator_Rn(thisDim)), VX_1_2(new Generator_Rn(thisDim));
1628  VX_1_2->makeSum(Tal_CP1->getGenerator(genitorsOfTal_CP_1_2_3[i][0]), Tal_CP2->getGenerator(genitorsOfTal_CP_1_2_3[i][1]));
1629  VX->makeSum(VX_1_2, Tal_CP3->getGenerator(genitorsOfTal_CP_1_2_3[i][2]));
1630  BOOST_REQUIRE( VX->isEqual2(Tal_SUM123->getGenerator(i), thisDim, tol_2) == true );
1631  }
1632  }
1633 
1634 
1635 
1636  return TEST_OK;
1637 
1638 }
politopixAPI::savePolytope
static polito_EXPORT int savePolytope(const string &pathA, boost::shared_ptr< Polytope_Rn > &A)
Save a polytope in the corresponding file name.
Definition: politopixAPI.cpp:29
politopixAPI::makeBox
static polito_EXPORT int makeBox(boost::shared_ptr< Polytope_Rn > &A, Point_Rn Pmin, Point_Rn Pmax)
Create a box or rectangle parallelepiped whose corners are Pmin and Pmax.
Definition: politopixAPI.cpp:574
NormalFan_Rn::computeHyperplanesSeparationForProjection
void computeHyperplanesSeparationForProjection(const std::vector< boost::shared_ptr< HalfSpace_Rn > > &, boost::shared_ptr< Polytope_Rn > &)
Definition: NormalFan_Rn.cpp:74
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
TEST_OK
#define TEST_OK
Definition: politopixAPI.h:38
politopixAPI.h
politopixAPI::checkEqualityOfVertices
static polito_EXPORT bool checkEqualityOfVertices(const boost::shared_ptr< Polytope_Rn > &A, const boost::shared_ptr< Polytope_Rn > &B)
Check whether two V-polytopes are identical Check whether the sets of vertices of A and B are equal.
Definition: politopixAPI.cpp:500
Voronoi_Rn::CellByCellDist
@ CellByCellDist
Refers to the class CellByCellVoronoi.
Definition: Voronoi_Rn.h:47
Voronoi_Rn::CellByCellDistNgb_1pc
@ CellByCellDistNgb_1pc
Refers to the class CellByCellDistNgb (100% of the distances between seeds to be sorted)
Definition: Voronoi_Rn.h:49
PolyhedralCone_Rn
Model a polyhedral cone using its two equivalent definitions : the convex hull and the half-space int...
Definition: PolyhedralCone_Rn.h:47
politopixAPI::computeMinkowskiSumOfPolytopes
static polito_EXPORT int computeMinkowskiSumOfPolytopes(const boost::shared_ptr< Polytope_Rn > &A, const boost::shared_ptr< Polytope_Rn > &B, boost::shared_ptr< Polytope_Rn > &C)
Compute the Minkowski sum between two HV-polytopes.
Definition: politopixAPI.cpp:350
politopixAPI::pseudoIntersection
static polito_EXPORT int pseudoIntersection(const boost::shared_ptr< Polytope_Rn > &A, const boost::shared_ptr< Polytope_Rn > &B, boost::shared_ptr< Polytope_Rn > &C, const std::set< unsigned int > &firstOperandCaps, const std::set< unsigned int > &secondOperandCaps, std::set< unsigned int > &newCaps, double bb_size=1000.)
Remove all cap half-spaces and then compute the intersection of two capped polytopes.
Definition: politopixAPI.cpp:622
test_main
int test_main(int argc, char *argv[])
Definition: test_politopix.cpp:80
computeFlatPolytope
void computeFlatPolytope(const std::vector< boost::shared_ptr< Hyperplane_Rn > > &vectOfHyp, boost::shared_ptr< Polytope_Rn > fptop_1, std::string compPol, bool strongRedundancy)
Definition: test_politopix.cpp:37
politopixAPI::computeVoronoiDiagram
static polito_EXPORT int computeVoronoiDiagram(const boost::shared_ptr< Polytope_Rn > &inputSpace, const std::vector< Point_Rn > &listOfSeeds, std::vector< boost::shared_ptr< Polytope_Rn > > &VoronoiCells, Voronoi_Rn::TypeOfAlgorithm vorAlgo=Voronoi_Rn::Incremental)
Compute the Voronoi Diagram in a n-dimensional space i.e. a partitioning of an input space into regio...
Definition: politopixAPI.cpp:716
Rn::getDimension
static polito_EXPORT unsigned int getDimension()
Return the dimension of the cartesian space we work in.
Definition: Rn.cpp:29
politopixAPI::computeIntersection
static polito_EXPORT int computeIntersection(const boost::shared_ptr< Polytope_Rn > &A, const boost::shared_ptr< Polytope_Rn > &B, boost::shared_ptr< Polytope_Rn > &C)
Compute the intersection between two HV-polytopes with the Double Description algorithm.
Definition: politopixAPI.cpp:195
constIteratorOfListOfGeometricObjects::current
const GEOMETRIC_OBJECT current()
Return the current geometric element.
Definition: GeometricObjectIterator_Rn.h:177
FaceEnumeration
Combinatorial face enumeration for polytopes.
Definition: PolyhedralAlgorithms_Rn.h:44
Voronoi_Rn::CellByCellDistNgb_10pc
@ CellByCellDistNgb_10pc
Refers to the class CellByCellDistNgb ( 1% of the distances between seeds to be sorted)
Definition: Voronoi_Rn.h:50
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
politopixAPI::PolarPolytope
static polito_EXPORT int PolarPolytope(const boost::shared_ptr< Polytope_Rn > &original_pol, boost::shared_ptr< Polytope_Rn > &polar_pol)
Compute the polar polytope.
Definition: politopixAPI.cpp:614
Voronoi_Rn::CellByCellDistNgb
@ CellByCellDistNgb
Refers to the class CellByCellVoronoiDist.
Definition: Voronoi_Rn.h:48
Point_Rn
Creation of a n-coordinate geometric point designed to be shared by its neighbour faces.
Definition: Point_Rn.h:34
TopGeomTools::extrudeInCanonicalDirections
static int extrudeInCanonicalDirections(const std::set< unsigned int > &originalSpaceDirections, unsigned int dimensionOfTotalSpace, const boost::shared_ptr< Polytope_Rn > &original_polytope, boost::shared_ptr< PolyhedralCone_Rn > &extruded_polyhedron)
Compute the extrusion of a polytope belonging to a space S1 into a higher dimension space S2 followin...
Definition: PolyhedralAlgorithms_Rn.cpp:1390
NoRedundancyProcessing
Makes the assumption we do not need to process redundant half-spaces in a specific way.
Definition: UpdDoubleDescription_Rn.h:554
constIteratorOfListOfGeometricObjects
This class is designed to run the list of all geometric objects representing a polytope.
Definition: GeometricObjectIterator_Rn.h:142
UpdDoubleDescription
The algorithm implemented here is an incremental algorithm as mentioned in How Good are Convex Hull ...
Definition: UpdDoubleDescription_Rn.h:50
Voronoi_Rn::Incremental
@ Incremental
Definition: Voronoi_Rn.h:45
politopixAPI::loadPolyhedralCone
static polito_EXPORT int loadPolyhedralCone(const string &pathA, boost::shared_ptr< PolyhedralCone_Rn > &A)
Load a polyhedral cone from the corresponding file name.
Definition: politopixAPI.cpp:64
politopixAPI::computeVolume
static polito_EXPORT double computeVolume(const boost::shared_ptr< Polytope_Rn > P)
Return the volume of the given polytope P with its double description. The implemented algorithm can ...
Definition: politopixAPI.cpp:537
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
NormalFan_Rn
Model a normal fan.
Definition: NormalFan_Rn.h:37
TopGeomTools::projectPolytopeOnCanonicalHyperplanes
static int projectPolytopeOnCanonicalHyperplanes(const std::set< unsigned int > &listOfHyperplanes, const boost::shared_ptr< Polytope_Rn > &original_pol, boost::shared_ptr< Polytope_Rn > &proj_pol)
Compute the projection of a polytope on the intersection of canonical hyperplanes of the shape xi = 0
Definition: PolyhedralAlgorithms_Rn.cpp:1343
constIteratorOfListOfGeometricObjects::begin
void begin()
Move the iterator at the beginning of the list.
Definition: GeometricObjectIterator_Rn.h:150
politopixAPI::computeDoubleDescription
static polito_EXPORT int computeDoubleDescription(boost::shared_ptr< Polytope_Rn > &A, double bb_size)
Compute the HV-description for a given H-polytope or V-polytope with the Double Description algorithm...
Definition: politopixAPI.cpp:136
politopixAPI::checkTopologyAndGeometry
static polito_EXPORT int checkTopologyAndGeometry(const boost::shared_ptr< PolyhedralCone_Rn > &A, bool check_all=false)
Check whether a HV-polytopes is correct.
Definition: politopixAPI.cpp:564
politopixAPI::pseudoSum
static polito_EXPORT int pseudoSum(const boost::shared_ptr< Polytope_Rn > &A, const boost::shared_ptr< Polytope_Rn > &B, boost::shared_ptr< Polytope_Rn > &C, const std::set< unsigned int > &firstOperandCaps, const std::set< unsigned int > &secondOperandCaps, std::set< unsigned int > &newCaps, double bb_size=1000.)
Compute the Minkowski sum of two polytopes and then remove all cap half-spaces to truncate again.
Definition: politopixAPI.cpp:669
politopixAPI::makeCube
static polito_EXPORT int makeCube(boost::shared_ptr< Polytope_Rn > &A, double M)
Create a cube whose vertices will be (+-M, ..., +-M)
Definition: politopixAPI.cpp:568
politopixAPI::loadPolytope
static polito_EXPORT int loadPolytope(const string &pathA, boost::shared_ptr< Polytope_Rn > &A)
Load a polytope from the corresponding file name.
Definition: politopixAPI.cpp:40
Point_Rn::setCoordinate
void setCoordinate(unsigned int i, double val)
Definition: Point_Rn.cpp:61
StrongRedundancyProcessing
This class can be more time-consuming than WeakRedundancyProcessing or NoRedundancyProcessing because...
Definition: UpdDoubleDescription_Rn.h:623
Rn::setTolerance
static polito_EXPORT void setTolerance(double t)
Give the minimum distance between two points.
Definition: Rn.cpp:33
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
politopixAPI::Translate
static polito_EXPORT int Translate(boost::shared_ptr< Polytope_Rn > &pol, const boost::numeric::ublas::vector< double > &v2t)
Translate a polytope or polyhedral cone by the given vector.
Definition: politopixAPI.cpp:618
FaceEnumeration::load
static void load(const std::string &filename, std::vector< std::vector< ListOfFaces > > &latt)
Load the polytope lattice.
Definition: PolyhedralAlgorithms_Rn.cpp:261
FaceEnumeration::Compute
static void Compute(const boost::shared_ptr< Polytope_Rn > &A)
Definition: PolyhedralAlgorithms_Rn.cpp:43
Voronoi_Rn::CellByCell
@ CellByCell
Refers to the class IncrementalVoronoi.
Definition: Voronoi_Rn.h:46
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
politopixAPI::checkEqualityOfPolytopes
static polito_EXPORT int checkEqualityOfPolytopes(const boost::shared_ptr< Polytope_Rn > &A, const boost::shared_ptr< Polytope_Rn > &B, bool getFaceMapping=false)
Check whether two HV-polytopes are identical Check whether the vertices of A are inside B half-spaces...
Definition: politopixAPI.cpp:463