politopix  4.1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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-2017 : Delos Vincent
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser 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 <vector>
31 #include <cmath>
32 #include "politopixAPI.h"
33 #include "NormalFan_Rn.h"
34 
35 using namespace std;
36 
37 
38 int test_main(int argc, char* argv[]) {
39 
40  cout << "####################" << endl;
41  cout << "# VORONOI DIAGRAMS #" << endl;
42  cout << "####################" << endl;
44  Rn::setTolerance(0.000001);
45  boost::shared_ptr<Polytope_Rn> inputSpace(new Polytope_Rn());
46  inputSpace->createBoundingBox(10);
47  Point_Rn P1(2), P2(2), P3(2), P4(2), P5(2);
48  P1.setCoordinate(0,1);
49  P1.setCoordinate(1,1);
50  P2.setCoordinate(0,8);
51  P2.setCoordinate(1,4);
52  P3.setCoordinate(0,-7);
53  P3.setCoordinate(1,7);
54  P4.setCoordinate(0,-4);
55  P4.setCoordinate(1,-2);
56  P5.setCoordinate(0,3);
57  P5.setCoordinate(1,-3);
58  std::vector<Point_Rn> listOfPoints;
59  listOfPoints.push_back(P1);listOfPoints.push_back(P2);listOfPoints.push_back(P3);listOfPoints.push_back(P4);listOfPoints.push_back(P5);
60  std::vector< boost::shared_ptr<Polytope_Rn> > allVoronoiCells;
61  BOOST_REQUIRE( politopixAPI::computeVoronoiDiagram(inputSpace, listOfPoints, allVoronoiCells) == TEST_OK );
62  string vorPath = string("./test/VORONOI/2D/");
63  boost::shared_ptr<Polytope_Rn> Vor_Test(new Polytope_Rn());
64  Vor_Test.reset(new Polytope_Rn());
65  BOOST_REQUIRE( politopixAPI::loadPolytope(vorPath + string("cell0.ptop"), Vor_Test) == TEST_OK );
66  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells[0], Vor_Test) == TEST_OK );
67  Vor_Test.reset(new Polytope_Rn());
68  BOOST_REQUIRE( politopixAPI::loadPolytope(vorPath + string("cell1.ptop"), Vor_Test) == TEST_OK );
69  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells[1], Vor_Test) == TEST_OK );
70  Vor_Test.reset(new Polytope_Rn());
71  BOOST_REQUIRE( politopixAPI::loadPolytope(vorPath + string("cell2.ptop"), Vor_Test) == TEST_OK );
72  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells[2], Vor_Test) == TEST_OK );
73  Vor_Test.reset(new Polytope_Rn());
74  BOOST_REQUIRE( politopixAPI::loadPolytope(vorPath + string("cell3.ptop"), Vor_Test) == TEST_OK );
75  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells[3], Vor_Test) == TEST_OK );
76  Vor_Test.reset(new Polytope_Rn());
77  BOOST_REQUIRE( politopixAPI::loadPolytope(vorPath + string("cell4.ptop"), Vor_Test) == TEST_OK );
78  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells[4], Vor_Test) == TEST_OK );
79 
81  Rn::setTolerance(0.000001);
82  boost::shared_ptr<Polytope_Rn> inputSpaceAngers(new Polytope_Rn());
83  inputSpaceAngers->createBoundingBox(0.5);
84  //Point_Rn P1(2), P2(2), P3(2), P4(2), P5(2);
85  string vorPath3DAngers = string("./test/VORONOI/3D/Angers/");
86  // Load the list of 3D germs as the V-description of a polytope.
87  boost::shared_ptr<Polytope_Rn> listOfPointsAsVDesc(new Polytope_Rn());
88  BOOST_REQUIRE( politopixAPI::loadPolytope(vorPath3DAngers + string("seedsAngers.txt"), listOfPointsAsVDesc) == TEST_OK );
89  std::vector<Point_Rn> listOfPoints3DAngers;
90  constIteratorOfListOfGeometricObjects< boost::shared_ptr<Generator_Rn> > iteGN(listOfPointsAsVDesc->getListOfGenerators());
91  {for (iteGN.begin(); iteGN.end()!=true; iteGN.next()) {
92  listOfPoints3DAngers.push_back(
93  Point_Rn(iteGN.current()->getCoordinate(0), iteGN.current()->getCoordinate(1), iteGN.current()->getCoordinate(2)) );
94  }}
95  // Incremental algorithm
96  std::vector< boost::shared_ptr<Polytope_Rn> > allVoronoiCells_Angers0;
97  BOOST_REQUIRE( politopixAPI::computeVoronoiDiagram(inputSpaceAngers, listOfPoints3DAngers, allVoronoiCells_Angers0, Voronoi_Rn::Incremental) == TEST_OK );
98  // Cell by cell algorithm
99  std::vector< boost::shared_ptr<Polytope_Rn> > allVoronoiCells_Angers1;
100  BOOST_REQUIRE( politopixAPI::computeVoronoiDiagram(inputSpaceAngers, listOfPoints3DAngers, allVoronoiCells_Angers1, Voronoi_Rn::CellByCell) == TEST_OK );
101  // Cell by cell algorithm with distances between seeds
102  std::vector< boost::shared_ptr<Polytope_Rn> > allVoronoiCells_Angers2;
103  BOOST_REQUIRE( politopixAPI::computeVoronoiDiagram(inputSpaceAngers, listOfPoints3DAngers, allVoronoiCells_Angers2, Voronoi_Rn::CellByCellDist) == TEST_OK );
104  // Cell by cell algorithm with distances and neighbours between seeds
105  std::vector< boost::shared_ptr<Polytope_Rn> > allVoronoiCells_Angers3;
106  BOOST_REQUIRE( politopixAPI::computeVoronoiDiagram(inputSpaceAngers, listOfPoints3DAngers, allVoronoiCells_Angers3, Voronoi_Rn::CellByCellDistNgb) == TEST_OK );
107  // Cell by cell algorithm with distances and neighbours between seeds with 1% of partial sorting
108  std::vector< boost::shared_ptr<Polytope_Rn> > allVoronoiCells_Angers4;
109  BOOST_REQUIRE( politopixAPI::computeVoronoiDiagram(inputSpaceAngers, listOfPoints3DAngers, allVoronoiCells_Angers4, Voronoi_Rn::CellByCellDistNgb_1pc) == TEST_OK );
110  // Cell by cell algorithm with distances and neighbours between seeds with 10% of partial sorting
111  std::vector< boost::shared_ptr<Polytope_Rn> > allVoronoiCells_Angers5;
112  BOOST_REQUIRE( politopixAPI::computeVoronoiDiagram(inputSpaceAngers, listOfPoints3DAngers, allVoronoiCells_Angers5, Voronoi_Rn::CellByCellDistNgb_10pc) == TEST_OK );
113  BOOST_CHECK( allVoronoiCells_Angers0.size() == allVoronoiCells_Angers1.size() );
114  BOOST_CHECK( allVoronoiCells_Angers1.size() == allVoronoiCells_Angers2.size() );
115  BOOST_CHECK( allVoronoiCells_Angers2.size() == allVoronoiCells_Angers3.size() );
116  BOOST_CHECK( allVoronoiCells_Angers3.size() == allVoronoiCells_Angers4.size() );
117  BOOST_CHECK( allVoronoiCells_Angers4.size() == allVoronoiCells_Angers5.size() );
118  for (unsigned int cellCounter=0; cellCounter<allVoronoiCells_Angers0.size(); ++cellCounter)
119  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells_Angers0[cellCounter], allVoronoiCells_Angers1[cellCounter]) == TEST_OK );
120  for (unsigned int cellCounter=0; cellCounter<allVoronoiCells_Angers1.size(); ++cellCounter)
121  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells_Angers1[cellCounter], allVoronoiCells_Angers2[cellCounter]) == TEST_OK );
122  for (unsigned int cellCounter=0; cellCounter<allVoronoiCells_Angers2.size(); ++cellCounter)
123  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells_Angers2[cellCounter], allVoronoiCells_Angers3[cellCounter]) == TEST_OK );
124  for (unsigned int cellCounter=0; cellCounter<allVoronoiCells_Angers3.size(); ++cellCounter)
125  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells_Angers3[cellCounter], allVoronoiCells_Angers4[cellCounter]) == TEST_OK );
126  for (unsigned int cellCounter=0; cellCounter<allVoronoiCells_Angers4.size(); ++cellCounter)
127  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(allVoronoiCells_Angers4[cellCounter], allVoronoiCells_Angers5[cellCounter]) == TEST_OK );
128  std::cout << "allVoronoiCells_Angers0.size() = " << allVoronoiCells_Angers0.size() << std::endl;
129  std::cout << "allVoronoiCells_Angers1.size() = " << allVoronoiCells_Angers1.size() << std::endl;
130  std::cout << "allVoronoiCells_Angers2.size() = " << allVoronoiCells_Angers2.size() << std::endl;
131  std::cout << "allVoronoiCells_Angers3.size() = " << allVoronoiCells_Angers3.size() << std::endl;
132  std::cout << "allVoronoiCells_Angers4.size() = " << allVoronoiCells_Angers4.size() << std::endl;
133  std::cout << "allVoronoiCells_Angers5.size() = " << allVoronoiCells_Angers5.size() << std::endl;
134 
135  Rn::setDimension(6);
136  Rn::setTolerance(0.000001);
137 
138  cout << endl;
139  cout << "////////////" << endl;
140  cout << "// DATA1 //" << endl;
141  cout << "//////////" << endl;
142  string path_test1("test/DATA1/");
143  boost::shared_ptr<Polytope_Rn> _polytopeTest(new Polytope_Rn());
144  cout << "######################" << endl;
145  cout << "# DATA1: truncations #" << endl;
146  cout << "######################" << endl;
147  Rn::setDimension(3);
148  _polytopeTest.reset(new Polytope_Rn());
149  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("lmp1.ptop"), _polytopeTest) == TEST_OK );
150  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
151  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 6 );
152  _polytopeTest.reset(new Polytope_Rn());
153  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("lmp2.ptop"), _polytopeTest) == TEST_OK );
154  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
155  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 6 );
156  _polytopeTest.reset(new Polytope_Rn());
157  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("lmp3.ptop"), _polytopeTest) == TEST_OK );
158  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
159  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 12 );
160  _polytopeTest.reset(new Polytope_Rn());
161  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("SharirCube.ptop"), _polytopeTest) == TEST_OK );
162  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
163  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 8 );
164  _polytopeTest.reset(new Polytope_Rn());
165  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("CUT3-3-4.ptop"), _polytopeTest) == TEST_OK );
166  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
167  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 4 );
168  _polytopeTest.reset(new Polytope_Rn());
169  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("CR0-3-6.ptop"), _polytopeTest) == TEST_OK );
170  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
171  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 6 );
172  Rn::setDimension(4);
173  _polytopeTest.reset(new Polytope_Rn());
174  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("neighborly_4_8.ptop"), _polytopeTest) == TEST_OK );
175  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
176  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 8 );
177  _polytopeTest.reset(new Polytope_Rn());
178  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cyclic.ptop"), _polytopeTest) == TEST_OK );
179  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 10000.) == TEST_OK );
180  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 8 );
181  _polytopeTest.reset(new Polytope_Rn());
182  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("BIR3-4-6.ptop"), _polytopeTest) == TEST_OK );
183  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
184  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 6 );
185  _polytopeTest.reset(new Polytope_Rn());
186  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("p4_7_simplicial_1.ptop"), _polytopeTest) == TEST_OK );
187  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
188  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 7 );
189  _polytopeTest.reset(new Polytope_Rn());
190  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("p4_7_nonsimplicial_01.ptop"), _polytopeTest) == TEST_OK );
191  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
192  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 7 );
193  _polytopeTest.reset(new Polytope_Rn());
194  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("120-cell.ptop"), _polytopeTest) == TEST_OK );
195  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
196  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 600 );
197  _polytopeTest.reset(new Polytope_Rn());
198  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("not-cubical4.ptop"), _polytopeTest) == TEST_OK );
199  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
200  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 32 );
201  Rn::setDimension(6);
202  _polytopeTest.reset(new Polytope_Rn());
203  boost::shared_ptr<Polytope_Rn> _polytope2(new Polytope_Rn());
204  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("8D6.ptop"), _polytopeTest) == TEST_OK );
205  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
206  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("8D6_v.ptop"), _polytope2) == TEST_OK );
207  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(_polytopeTest, _polytope2) == TEST_OK );
208  _polytope2.reset(new Polytope_Rn());
209  _polytopeTest.reset(new Polytope_Rn());
210  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("10D6.ptop"), _polytopeTest) == TEST_OK );
211  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
212  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("10D6_v.ptop"), _polytope2) == TEST_OK );
213  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(_polytopeTest, _polytope2) == TEST_OK );
214  _polytope2.reset(new Polytope_Rn());
215  _polytopeTest.reset(new Polytope_Rn());
216  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("20D6.ptop"), _polytopeTest) == TEST_OK );
217  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
218  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("20D6_v.ptop"), _polytope2) == TEST_OK );
219  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(_polytopeTest, _polytope2) == TEST_OK );
220  Rn::setDimension(10);
221  _polytopeTest.reset(new Polytope_Rn());
222  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("CF-10-11.ptop"), _polytopeTest) == TEST_OK );
223  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
224  cout << "########################" << endl;
225  cout << "# DATA1: intersections #" << endl;
226  cout << "########################" << endl;
227  Rn::setDimension(3);
228  _polytope2.reset(new Polytope_Rn());
229  _polytopeTest.reset(new Polytope_Rn());
230  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("lmp1_v.ptop"), _polytopeTest) == TEST_OK );
231  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("SharirCube_v.ptop"), _polytope2) == TEST_OK );
232  BOOST_REQUIRE( politopixAPI::computeIntersection(_polytopeTest, _polytope2) == TEST_OK );
233  BOOST_REQUIRE( _polytopeTest->numberOfGenerators() == 8 );
234  cout << "###############" << endl;
235  cout << "# DATA1: sums #" << endl;
236  cout << "###############" << endl;
237  Rn::setDimension(3);
238  Rn::setTolerance(0.0001);
239  boost::shared_ptr<Polytope_Rn> _sum;
240  _sum.reset(new Polytope_Rn());
241  _polytope2.reset(new Polytope_Rn());
242  _polytopeTest.reset(new Polytope_Rn());
243  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("lmp1_v.ptop"), _polytopeTest) == TEST_OK );
244  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cube3D.ptop"), _polytope2) == TEST_OK );
245  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytopeTest, _polytope2, _sum) == TEST_OK );
246  BOOST_REQUIRE( _sum->numberOfGenerators() == 24 );
247  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 26 );
248  _sum.reset(new Polytope_Rn());
249  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytope2, _polytopeTest, _sum) == TEST_OK );
250  BOOST_REQUIRE( _sum->numberOfGenerators() == 24 );
251  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 26 );
252  _sum.reset(new Polytope_Rn());
253  _polytope2.reset(new Polytope_Rn());
254  _polytopeTest.reset(new Polytope_Rn());
255  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cyclic_v.ptop"), _polytopeTest) == TEST_OK );
256  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("120-cell_v.ptop"), _polytope2) == TEST_OK );
257  //BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytopeTest, _polytope2, _sum) == TEST_OK );
258  _polytope2.reset(new Polytope_Rn());
259  _polytopeTest.reset(new Polytope_Rn());
260  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cube_1.ptop"), _polytopeTest) == TEST_OK );
261  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cube_2.ptop"), _polytope2) == TEST_OK );
262  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytope2, 1000.) == TEST_OK );
263  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
264  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(_polytope2, _polytopeTest, true) == TEST_OK );
265  //BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytope2, _polytopeTest, _sum) == TEST_OK );
266  Rn::setTolerance(0.000001);
267  _sum.reset(new Polytope_Rn());
268  _polytope2.reset(new Polytope_Rn());
269  _polytopeTest.reset(new Polytope_Rn());
270  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("tetra3D_v_1.ptop"), _polytopeTest) == TEST_OK );
271  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("tetra3D_v_2.ptop"), _polytope2) == TEST_OK );
272  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytopeTest, _polytope2, _sum) == TEST_OK );
273  BOOST_REQUIRE( _sum->numberOfGenerators() == 9 );
274  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 7 );
275  _sum.reset(new Polytope_Rn());
276  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytope2, _polytopeTest, _sum) == TEST_OK );
277  BOOST_REQUIRE( _sum->numberOfGenerators() == 9 );
278  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 7 );
279  _sum.reset(new Polytope_Rn());
280  _polytope2.reset(new Polytope_Rn());
281  _polytopeTest.reset(new Polytope_Rn());
282  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("tetra3D_v_3.ptop"), _polytopeTest) == TEST_OK );
283  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("tetra3D_v_4.ptop"), _polytope2) == TEST_OK );
284  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytopeTest, _polytope2, _sum) == TEST_OK );
285  BOOST_REQUIRE( _sum->numberOfGenerators() == 17 );
286  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 17 );
287  _sum.reset(new Polytope_Rn());
288  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytope2, _polytopeTest, _sum) == TEST_OK );
289  BOOST_REQUIRE( _sum->numberOfGenerators() == 17 );
290  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 17 );
291  Rn::setDimension(4);
292  Rn::setTolerance(0.0001);
293  _sum.reset(new Polytope_Rn());
294  _polytope2.reset(new Polytope_Rn());
295  _polytopeTest.reset(new Polytope_Rn());
296  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("_p4s.ptop"), _polytopeTest) == TEST_OK );
297  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("_p4ns.ptop"), _polytope2) == TEST_OK );
298  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytopeTest, _polytope2, _sum) == TEST_OK );
299  BOOST_REQUIRE( _sum->numberOfGenerators() == 25 );
300  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 33 );
301  _sum.reset(new Polytope_Rn());
302  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytope2, _polytopeTest, _sum) == TEST_OK );
303  BOOST_REQUIRE( _sum->numberOfGenerators() == 25 );
304  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 33 );
305  Rn::setTolerance(0.000001);
306  _sum.reset(new Polytope_Rn());
307  _polytope2.reset(new Polytope_Rn());
308  _polytopeTest.reset(new Polytope_Rn());
309  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("neighborly_4_8_v.ptop"), _polytopeTest) == TEST_OK );
310  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("BIR3-4-6_v.ptop"), _polytope2) == TEST_OK );
311  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytopeTest, _polytope2, _sum) == TEST_OK );
312  BOOST_REQUIRE( _sum->numberOfGenerators() == 34 );
313  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 40 );
314  _sum.reset(new Polytope_Rn());
315  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytope2, _polytopeTest, _sum) == TEST_OK );
316  BOOST_REQUIRE( _sum->numberOfGenerators() == 34 );
317  BOOST_REQUIRE( _sum->numberOfHalfSpaces() == 40 );
318  Rn::setDimension(6);
319  Rn::setTolerance(0.000001);
320  _sum.reset(new Polytope_Rn());
321  _polytope2.reset(new Polytope_Rn());
322  _polytopeTest.reset(new Polytope_Rn());
323  boost::shared_ptr<Polytope_Rn> _pol2compare;
324  _pol2compare.reset(new Polytope_Rn());
325  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cube15pts.ptop"), _polytopeTest) == TEST_OK );
326  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("sph10D6.ptop"), _polytope2) == TEST_OK );
327  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(_polytopeTest, _polytope2, _sum) == TEST_OK );
328  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cube15-sph10_D6.ptop"), _pol2compare) == TEST_OK );
329  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(_sum, _pol2compare) == TEST_OK );
330  std::cout << "* Extrusions *" << std::endl;
331  boost::shared_ptr<Polytope_Rn> polytope2extrude(new Polytope_Rn());
332  boost::shared_ptr<PolyhedralCone_Rn> extruded_polyedron(new PolyhedralCone_Rn()), extruded_polyedron_comp(new PolyhedralCone_Rn());
333  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("P1_3D.ptop"), polytope2extrude) == TEST_OK );
334  std::set< unsigned int > originalSpaceDirections;
335  originalSpaceDirections.insert(1);originalSpaceDirections.insert(2);originalSpaceDirections.insert(6);
336  TopGeomTools::extrudeInCanonicalDirections(originalSpaceDirections, 6, polytope2extrude, extruded_polyedron);
337  BOOST_REQUIRE( politopixAPI::loadPolyhedralCone(path_test1 + string("P1_6D.pcon"), extruded_polyedron_comp) == TEST_OK );
338  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > iteHS1(extruded_polyedron->getListOfHalfSpaces());
339  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > iteHS2(extruded_polyedron_comp->getListOfHalfSpaces());
340  for (iteHS1.begin(),iteHS2.begin(); iteHS1.end()!=true&&iteHS2.end()!=true; iteHS1.next(),iteHS2.next()) {
341  for (unsigned int i=0; i<6; ++i)
342  BOOST_REQUIRE( iteHS1.current()->getCoefficient(i) == iteHS2.current()->getCoefficient(i) );
343  }
344  Rn::setDimension(2);
345  polytope2extrude.reset(new Polytope_Rn());
346  extruded_polyedron.reset(new PolyhedralCone_Rn());
347  extruded_polyedron_comp.reset(new PolyhedralCone_Rn());
348  originalSpaceDirections.clear();
349  originalSpaceDirections.insert(1);originalSpaceDirections.insert(2);
350  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("P10_20_2D.ptop"), polytope2extrude) == TEST_OK );
351  TopGeomTools::extrudeInCanonicalDirections(originalSpaceDirections, 6, polytope2extrude, extruded_polyedron);
352  BOOST_REQUIRE( politopixAPI::loadPolyhedralCone(path_test1 + string("P10_20_6D.pcon"), extruded_polyedron_comp) == TEST_OK );
353  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > iteHS1_2D(extruded_polyedron->getListOfHalfSpaces());
354  constIteratorOfListOfGeometricObjects< boost::shared_ptr<HalfSpace_Rn> > iteHS2_2D(extruded_polyedron_comp->getListOfHalfSpaces());
355  for (iteHS1_2D.begin(),iteHS2_2D.begin(); iteHS1_2D.end()!=true&&iteHS2_2D.end()!=true; iteHS1_2D.next(),iteHS2_2D.next()) {
356  for (unsigned int i=0; i<6; ++i)
357  BOOST_REQUIRE( iteHS1_2D.current()->getCoefficient(i) == iteHS2_2D.current()->getCoefficient(i) );
358  }
359  std::cout << "* Box *" << std::endl;
360  Rn::setDimension(3);
361  Point_Rn Pmin(1., 2., 3.), Pmax(4., 5., 6.);
362  boost::shared_ptr<Polytope_Rn> box3D(new Polytope_Rn()), box3D_comp(new Polytope_Rn());
363  politopixAPI::makeBox(box3D, Pmin, Pmax);
364  box3D->dump(std::cout);
365  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("box3D.ptop"), box3D_comp) == TEST_OK );
366  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(box3D, box3D_comp) == TEST_OK );
367  std::cout << "* Scaling factor *" << std::endl;
368  TopGeomTools::scalingFactor(box3D, 2.);
369  box3D->checkTopologyAndGeometry();
370  box3D_comp.reset(new Polytope_Rn());
371  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("box3D_x2.ptop"), box3D_comp) == TEST_OK );
372  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(box3D, box3D_comp) == TEST_OK );
373  // Equivalent to a direct scaling factor of 2 * 0.25 = 0.5
374  TopGeomTools::scalingFactor(box3D, 0.25);
375  box3D->checkTopologyAndGeometry();
376  box3D_comp.reset(new Polytope_Rn());
377  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("box3D_x0_5.ptop"), box3D_comp) == TEST_OK );
378  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(box3D, box3D_comp) == TEST_OK );
379 
380 
381  cout << endl;
382  cout << "/////////////" << endl;
383  cout << "// DATA 2 //" << endl;
384  cout << "///////////" << endl;
385  Rn::setTolerance(0.000001);
386  Rn::setDimension(3);
387  path_test1 = string("test/DATA2/");
388  boost::shared_ptr<Polytope_Rn> v2h(new Polytope_Rn()), comp_v2h(new Polytope_Rn());
389  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("v_lmp1.ptop"), v2h) == TEST_OK );
390  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(v2h, 1000.) == TEST_OK );
391  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("comp_v_lmp1.ptop"), comp_v2h) == TEST_OK );
392  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(v2h, comp_v2h) == TEST_OK );
393  v2h.reset(new Polytope_Rn()); comp_v2h.reset(new Polytope_Rn());
394  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("v_lmp2.ptop"), v2h) == TEST_OK );
395  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(v2h, 1000.) == TEST_OK );
396  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("comp_v_lmp2.ptop"), comp_v2h) == TEST_OK );
397  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(v2h, comp_v2h) == TEST_OK );
398  v2h.reset(new Polytope_Rn()); comp_v2h.reset(new Polytope_Rn());
399  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("v_lmp3.ptop"), v2h) == TEST_OK );
400  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(v2h, 1000.) == TEST_OK );
401  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("comp_v_lmp3.ptop"), comp_v2h) == TEST_OK );
402  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(v2h, comp_v2h) == TEST_OK );
403 
404  Rn::setDimension(6);
405  Rn::setTolerance(0.000001);
406  std::vector< boost::shared_ptr<Polytope_Rn> > arrayOfPolytopes;
407  arrayOfPolytopes.resize(7);
408  path_test1 = string("test/DATA2/T1/");
409  string path_test2("test/DATA2/T2/");
410  string path_test3("test/DATA2/T3/");
411  string path_test4("test/DATA2/T4/");
412  string path_test5("test/DATA2/T5/");
413  std::vector< string > Ppath1;
414  std::vector< string > Ppath2;
415  std::vector< string > Ppath3;
416  std::vector< string > Ppath4;
417  std::vector< string > Ppath5;
418  //cout << "ok" << endl;
419  Ppath1.push_back( string("outputcthp_0_1-ctl_848_0.ptop") );
420  Ppath1.push_back( string("outputcthp_10_0-ctl_524_1.ptop") );
421  Ppath1.push_back( string("outputcthp_102_1-ctl_221_0.ptop") );
422  Ppath1.push_back( string("outputcthp_103_0-ctl_122_2.ptop") );
423  Ppath1.push_back( string("outputcthp_107_3-ctl_145_1.ptop") );
424  Ppath1.push_back( string("outputcthp_109_2-ctl_452_2.ptop") );
425  Ppath1.push_back( string("outputcthp_113_0-ctl_989_2.ptop") );
426  Ppath2.push_back( string("outputcthp_0_2-ctl_82_2.ptop") );
427  Ppath2.push_back( string("outputcthp_10_3-ctl_99_3.ptop") );
428  Ppath2.push_back( string("outputcthp_100_0-ctl_914_1.ptop") );
429  Ppath2.push_back( string("outputcthp_104_2-ctl_857_3.ptop") );
430  Ppath2.push_back( string("outputcthp_108_3-ctl_196_1.ptop") );
431  Ppath2.push_back( string("outputcthp_109_2-ctl_452_2.ptop") );
432  Ppath2.push_back( string("outputcthp_110_1-ctl_697_0.ptop") );
433  Ppath3.push_back( string("outputcthp_111_1-ctl_111_1.ptop") );
434  Ppath3.push_back( string("outputcthp_162_0-ctl_42_1.ptop") );
435  Ppath3.push_back( string("outputcthp_366_1-ctl_201_0.ptop") );
436  Ppath3.push_back( string("outputcthp_57_3-ctl_330_2.ptop") );
437  Ppath3.push_back( string("outputcthp_586_0-ctl_932_2.ptop") );
438  Ppath3.push_back( string("outputcthp_741_3-ctl_568_0.ptop") );
439  Ppath3.push_back( string("outputcthp_915_3-ctl_803_1.ptop") );
440  Ppath4.push_back( string("outputcthp_177_1-ctl_83_2.ptop") );
441  Ppath4.push_back( string("outputcthp_231_1-ctl_830_2.ptop") );
442  Ppath4.push_back( string("outputcthp_361_1-ctl_578_2.ptop") );
443  Ppath4.push_back( string("outputcthp_44_1-ctl_51_2.ptop") );
444  Ppath4.push_back( string("outputcthp_482_2-ctl_880_0.ptop") );
445  Ppath4.push_back( string("outputcthp_712_1-ctl_693_1.ptop") );
446  Ppath4.push_back( string("outputcthp_899_3-ctl_233_3.ptop") );
447  Ppath5.push_back( string("outputcthp_0_2-ctl_82_2.ptop") );
448  Ppath5.push_back( string("outputcthp_10_0-ctl_524_1.ptop") );
449  Ppath5.push_back( string("outputcthp_101_0-ctl_74_0.ptop") );
450  Ppath5.push_back( string("outputcthp_104_1-ctl_357_2.ptop") );
451  Ppath5.push_back( string("outputcthp_107_2-ctl_186_0.ptop") );
452  Ppath5.push_back( string("outputcthp_112_2-ctl_527_3.ptop") );
453  Ppath5.push_back( string("outputcthp_113_2-ctl_424_1.ptop") );
454  //cout << "ok" << endl;
455  {for (unsigned int i=0; i<7; ++i) {
456  //cout << "ok " << path_test1+Ppath1[i] << endl;
457  boost::shared_ptr<Polytope_Rn> T1(new Polytope_Rn());
458  boost::shared_ptr<Polytope_Rn> T2(new Polytope_Rn());
459  boost::shared_ptr<Polytope_Rn> T3(new Polytope_Rn());
460  boost::shared_ptr<Polytope_Rn> T4(new Polytope_Rn());
461  boost::shared_ptr<Polytope_Rn> T5(new Polytope_Rn());
462  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + Ppath1[i], T1) == TEST_OK );
463  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test2 + Ppath2[i], T2) == TEST_OK );
464  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + Ppath3[i], T3) == TEST_OK );
465  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test4 + Ppath4[i], T4) == TEST_OK );
466  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test5 + Ppath5[i], T5) == TEST_OK );
467  cout << "##################" << endl;
468  cout << "# DATA 2: sums ";
469  cout << i+1 << " #" << endl;
470  cout << "##################" << endl;
471  boost::shared_ptr<Polytope_Rn> T12(new Polytope_Rn());
472  boost::shared_ptr<Polytope_Rn> T123(new Polytope_Rn());
473  boost::shared_ptr<Polytope_Rn> T1234(new Polytope_Rn());
474  boost::shared_ptr<Polytope_Rn> T12345(new Polytope_Rn());
475  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T1, T2, T12) == TEST_OK );
476  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T12, T3, T123) == TEST_OK );
477  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T123, T4, T1234) == TEST_OK );
478  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T1234, T5, T12345) == TEST_OK );
479  boost::shared_ptr<Polytope_Rn> T54(new Polytope_Rn());
480  boost::shared_ptr<Polytope_Rn> T543(new Polytope_Rn());
481  boost::shared_ptr<Polytope_Rn> T5432(new Polytope_Rn());
482  boost::shared_ptr<Polytope_Rn> T54321(new Polytope_Rn());
483  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T5, T4, T54) == TEST_OK );
484  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T54, T3, T543) == TEST_OK );
485  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T543, T2, T5432) == TEST_OK );
486  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(T5432, T1, T54321) == TEST_OK );
487  //BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(T12345, T54321) == TEST_OK );
488  arrayOfPolytopes[i] = T12345;
489  }}
490 
491 
492  Rn::setDimension(6);
493  cout << endl;
494  cout << "////////////////" << endl;
495  cout << "// SSS DISC1 //" << endl;
496  cout << "//////////////" << endl;
497  path_test1 = string("test/TM/Sss1_disc6/");
498  arrayOfPolytopes.clear();
499  arrayOfPolytopes.resize(12);
500  cout << "##########################" << endl;
501  cout << "# SSS DISC1: truncations #" << endl;
502  cout << "##########################" << endl;
503  {for (unsigned int i=0; i<12; ++i) {
504  ostringstream ss;
505  ss << (i+1);
506  string p_name = string("Polytope_") + ss.str() + string(".ptop");
507  arrayOfPolytopes[i].reset(new Polytope_Rn());
508  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + p_name, arrayOfPolytopes[i]) == TEST_OK );
509  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(arrayOfPolytopes[i], 1000.) == TEST_OK );
510  }}
511  cout << "############################" << endl;
512  cout << "# SSS DISC1: intersections #" << endl;
513  cout << "############################" << endl;
514  {for (unsigned int i=1; i<5 ; ++i) {
515  BOOST_REQUIRE( politopixAPI::computeIntersection(arrayOfPolytopes[0], arrayOfPolytopes[i]) == TEST_OK );
516  }}
517  {for (unsigned int i=6; i<10; ++i) {
518  BOOST_REQUIRE( politopixAPI::computeIntersection(arrayOfPolytopes[5], arrayOfPolytopes[i]) == TEST_OK );
519  }}
520  cout << "# intersections 11 & 12 #" << endl;
521  BOOST_REQUIRE( politopixAPI::computeIntersection(arrayOfPolytopes[0], arrayOfPolytopes[10]) == TEST_OK );
522  BOOST_REQUIRE( politopixAPI::computeIntersection(arrayOfPolytopes[5], arrayOfPolytopes[11]) == TEST_OK );
523  cout << "###################" << endl;
524  cout << "# SSS DISC1: sums #" << endl;
525  cout << "###################" << endl;
526  boost::shared_ptr<Polytope_Rn> C05(new Polytope_Rn());
527  boost::shared_ptr<Polytope_Rn> C50(new Polytope_Rn());
528  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(arrayOfPolytopes[0], arrayOfPolytopes[5], C05) == TEST_OK );
529  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(arrayOfPolytopes[5], arrayOfPolytopes[0], C50) == TEST_OK );
530  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(C05, C50) == TEST_OK );
531  BOOST_REQUIRE( politopixAPI::savePolytope(path_test1 + string("test_resultat12.ptop"), C05) == TEST_OK );
532  BOOST_REQUIRE( politopixAPI::savePolytope(path_test1 + string("test_resultat21.ptop"), C50) == TEST_OK );
533 
534 
535  cout << endl;
536  cout << "//////////////////" << endl;
537  cout << "// BBB_D_5.966 //" << endl;
538  cout << "////////////////" << endl;
539  path_test2 = string("test/TM/Interference_Bbb/BBB_D_5.966/");
540  arrayOfPolytopes.clear();
541  arrayOfPolytopes.resize(13);
542  {for (unsigned int i=1; i<=13; ++i) {
543  cout << "############################" << endl;
544  cout << "# BBB_D_5.966: truncations #" << endl;
545  cout << "############################" << endl;
546  ostringstream ss1;
547  ss1 << i;
548  std::vector< boost::shared_ptr<Polytope_Rn> > tmpArrayOfPtop(5);
549  {for (unsigned int j=1; j<=5; ++j) {
550  ostringstream ss2;
551  ss2 << j;
552  string p_name = string("ctl_") + ss1.str();
553  p_name += string("_") + ss2.str() + string(".ptop");
554  tmpArrayOfPtop[j-1].reset(new Polytope_Rn());
555  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test2 + p_name, tmpArrayOfPtop[j-1]) == TEST_OK );
556  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(tmpArrayOfPtop[j-1], 1000.) == TEST_OK );
557  }}
558  cout << "##############################" << endl;
559  cout << "# BBB_D_5.966: intersections #" << endl;
560  cout << "##############################" << endl;
561  {for (unsigned int j=1; j<=4; ++j) {
562  BOOST_REQUIRE( politopixAPI::computeIntersection(tmpArrayOfPtop[0], tmpArrayOfPtop[j]) == TEST_OK );
563  }}
564  arrayOfPolytopes.push_back( tmpArrayOfPtop[0] );
565  string checkPtop;
566  checkPtop += path_test2 + string("qhull_ctl_");
567  checkPtop += ss1.str() + string("_x.ptop");
568  boost::shared_ptr<Polytope_Rn> CP(new Polytope_Rn());
569  BOOST_REQUIRE( politopixAPI::loadPolytope(checkPtop, CP) == TEST_OK );
570  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(tmpArrayOfPtop[0], CP) == TEST_OK );
571  }}
572 
573 
574  cout << endl;
575  cout << "//////////////////" << endl;
576  cout << "// BBB_D_5.976 //" << endl;
577  cout << "////////////////" << endl;
578  path_test2 = string("test/TM/Interference_Bbb/BBB_D_5.976/");
579  arrayOfPolytopes.clear();
580  arrayOfPolytopes.resize(13);
581  {for (unsigned int i=1; i<=13; ++i) {
582  cout << "############################" << endl;
583  cout << "# BBB_D_5.976: truncations #" << endl;
584  cout << "############################" << endl;
585  ostringstream ss1;
586  ss1 << i;
587  std::vector< boost::shared_ptr<Polytope_Rn> > tmpArrayOfPtop(5);
588  {for (unsigned int j=1; j<=5; ++j) {
589  ostringstream ss2;
590  ss2 << j;
591  string p_name = string("ctl_") + ss1.str();
592  p_name += string("_") + ss2.str() + string(".ptop");
593  tmpArrayOfPtop[j-1].reset(new Polytope_Rn());
594  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test2 + p_name, tmpArrayOfPtop[j-1]) == TEST_OK );
595  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(tmpArrayOfPtop[j-1], 1000.) == TEST_OK );
596  }}
597  cout << "##############################" << endl;
598  cout << "# BBB_D_5.976: intersections #" << endl;
599  cout << "##############################" << endl;
600  {for (unsigned int j=1; j<=4; ++j) {
601  BOOST_REQUIRE( politopixAPI::computeIntersection(tmpArrayOfPtop[0], tmpArrayOfPtop[j]) == TEST_OK );
602  }}
603  arrayOfPolytopes.push_back( tmpArrayOfPtop[0] );
604  if (i != 10) {
605  string checkPtop;
606  checkPtop += path_test2 + string("qhull_ctl_");
607  checkPtop += ss1.str() + string("_x.ptop");
608  boost::shared_ptr<Polytope_Rn> CP(new Polytope_Rn());
609  BOOST_REQUIRE( politopixAPI::loadPolytope(checkPtop, CP) == TEST_OK );
610  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(tmpArrayOfPtop[0], CP) == TEST_OK );
611  }
612  }}
613 
614 
615  cout << endl;
616  cout << "/////////////////////" << endl;
617  cout << "// DTL_BPTL/D3-R6 //" << endl;
618  cout << "///////////////////" << endl;
619  path_test3 = string("test/TM/Interference_Bbb/DTL_BPTL/D3-R6/");
620  arrayOfPolytopes.resize(4);
621  arrayOfPolytopes[0].reset(new Polytope_Rn()); arrayOfPolytopes[1].reset(new Polytope_Rn());
622  arrayOfPolytopes[2].reset(new Polytope_Rn()); arrayOfPolytopes[3].reset(new Polytope_Rn());
623  cout << "###############################" << endl;
624  cout << "# DTL_BPTL/D3-R6: truncations #" << endl;
625  cout << "###############################" << endl;
626  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("BPHP_BPTL.ptop"), arrayOfPolytopes[0]) == TEST_OK );
627  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(arrayOfPolytopes[0], 1000.) == TEST_OK );
628  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("SPAR_BPHP.ptop"), arrayOfPolytopes[1]) == TEST_OK );
629  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(arrayOfPolytopes[1], 1000.) == TEST_OK );
630  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("CCCTL_CCCTHP_SPAR.ptop"), arrayOfPolytopes[2]) == TEST_OK );
631  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(arrayOfPolytopes[2], 1000.) == TEST_OK );
632  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("DTL2_CCCTL.ptop"), arrayOfPolytopes[3]) == TEST_OK );
633  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(arrayOfPolytopes[3], 1000.) == TEST_OK );
634  boost::shared_ptr<Polytope_Rn> BPHP_BPTL_v(new Polytope_Rn());
635  boost::shared_ptr<Polytope_Rn> SPAR_BPHP_v(new Polytope_Rn());
636  boost::shared_ptr<Polytope_Rn> CCCTL_CCCTHP_SPAR_v(new Polytope_Rn());
637  boost::shared_ptr<Polytope_Rn> DTL2_CCCTL_v(new Polytope_Rn());
638  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("BPHP_BPTL_v.ptop"), BPHP_BPTL_v) == TEST_OK );
639  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("SPAR_BPHP_v.ptop"), SPAR_BPHP_v) == TEST_OK );
640  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("CCCTL_CCCTHP_SPAR_v.ptop"), CCCTL_CCCTHP_SPAR_v) == TEST_OK );
641  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("DTL2_CCCTL_v.ptop"), DTL2_CCCTL_v) == TEST_OK );
642  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[0], BPHP_BPTL_v) == TEST_OK );
643  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[1], SPAR_BPHP_v) == TEST_OK );
644  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[2], CCCTL_CCCTHP_SPAR_v) == TEST_OK );
645  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[3], DTL2_CCCTL_v) == TEST_OK );
646  cout << "#####################################" << endl;
647  cout << "# DTL_BPTL/D3-R6: polar truncations #" << endl;
648  cout << "#####################################" << endl;
649  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("BPHP_BPTL.ptop"), arrayOfPolytopes[0]) == TEST_OK );
650  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("SPAR_BPHP.ptop"), arrayOfPolytopes[1]) == TEST_OK );
651  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("CCCTL_CCCTHP_SPAR.ptop"), arrayOfPolytopes[2]) == TEST_OK );
652  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("DTL2_CCCTL.ptop"), arrayOfPolytopes[3]) == TEST_OK );
653  {for (unsigned int i=0; i<4; ++i) {
654  boost::shared_ptr<Polytope_Rn> thisVPol(new Polytope_Rn());
655  // Get the V-description.
656  constIteratorOfListOfGeometricObjects< boost::shared_ptr<Generator_Rn> > iteGN1(arrayOfPolytopes[i]->getListOfGenerators());
657  {for (iteGN1.begin(); iteGN1.end()!=true; iteGN1.next()) {
658  thisVPol->addGenerator(iteGN1.current());
659  }}
660  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(thisVPol, 1000.) == TEST_OK );
661  arrayOfPolytopes[i] = thisVPol;
662  }}
663  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[0], BPHP_BPTL_v) == TEST_OK );
664  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[1], SPAR_BPHP_v) == TEST_OK );
665  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[2], CCCTL_CCCTHP_SPAR_v) == TEST_OK );
666  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(arrayOfPolytopes[3], DTL2_CCCTL_v) == TEST_OK );
667  cout << "########################" << endl;
668  cout << "# DTL_BPTL/D3-R6: sums #" << endl;
669  cout << "########################" << endl;
670  boost::shared_ptr<Polytope_Rn> BPTL_SPAR12(new Polytope_Rn());
671  boost::shared_ptr<Polytope_Rn> BPTL_SPAR21(new Polytope_Rn());
672  boost::shared_ptr<Polytope_Rn> BPTL_CCCTL12(new Polytope_Rn());
673  boost::shared_ptr<Polytope_Rn> BPTL_CCCTL21(new Polytope_Rn());
674  boost::shared_ptr<Polytope_Rn> BPTL_DTL212(new Polytope_Rn());
675  boost::shared_ptr<Polytope_Rn> BPTL_DTL221(new Polytope_Rn());
676  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(arrayOfPolytopes[0], arrayOfPolytopes[1], BPTL_SPAR12) == TEST_OK );
677  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(arrayOfPolytopes[1], arrayOfPolytopes[0], BPTL_SPAR21) == TEST_OK );
678  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(arrayOfPolytopes[2], BPTL_SPAR12, BPTL_CCCTL12) == TEST_OK );
679  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(BPTL_SPAR21, arrayOfPolytopes[2], BPTL_CCCTL21) == TEST_OK );
680  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(arrayOfPolytopes[3], BPTL_CCCTL12, BPTL_DTL212) == TEST_OK );
681  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(BPTL_CCCTL21, arrayOfPolytopes[3], BPTL_DTL221) == TEST_OK );
682  boost::shared_ptr<Polytope_Rn> sumOfArray(new Polytope_Rn());
683  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(arrayOfPolytopes, sumOfArray) == TEST_OK );
684  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(BPTL_DTL221, sumOfArray) == TEST_OK );
685  boost::shared_ptr<Polytope_Rn> qhl_BPTL_SPAR12(new Polytope_Rn());
686  boost::shared_ptr<Polytope_Rn> qhl_BPTL_CCCTL21(new Polytope_Rn());
687  boost::shared_ptr<Polytope_Rn> qhl_BPTL_DTL221(new Polytope_Rn());
688  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("qhl_BPTL_SPAR12.ptop"), qhl_BPTL_SPAR12) == TEST_OK );
689  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("qhl_BPTL_CCCTL21.ptop"), qhl_BPTL_CCCTL21) == TEST_OK );
690  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test3 + string("qhl_BPTL_DTL221.ptop"), qhl_BPTL_DTL221) == TEST_OK );
691  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(BPTL_SPAR12, BPTL_SPAR21) == TEST_OK );
692  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(BPTL_CCCTL12, BPTL_CCCTL21) == TEST_OK );
693  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(BPTL_DTL212, BPTL_DTL221) == TEST_OK );
694  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(BPTL_SPAR12, qhl_BPTL_SPAR12) == TEST_OK );
695  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(BPTL_CCCTL12, qhl_BPTL_CCCTL21) == TEST_OK );
696  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(BPTL_DTL221, qhl_BPTL_DTL221) == TEST_OK );
697  BOOST_REQUIRE( politopixAPI::savePolytope(path_test3 + string("test_BPTL_DTL221.ptop"), BPTL_DTL221) == TEST_OK );
698  Rn::setDimension(3);
699  boost::shared_ptr<Polytope_Rn> pol2polarize2(new Polytope_Rn()), polarizedPol2(new Polytope_Rn()), polarizedPolComp2(new Polytope_Rn());
700  BOOST_REQUIRE( politopixAPI::loadPolytope("test/DATA1/outputpolar.ptop", pol2polarize2) == TEST_OK );
701  BOOST_REQUIRE( politopixAPI::loadPolytope("test/DATA1/newpol.ptop", polarizedPolComp2) == TEST_OK );
702  BOOST_REQUIRE( politopixAPI::PolarPolytope(pol2polarize2, polarizedPol2) == TEST_OK );
703  BOOST_REQUIRE( politopixAPI::checkTopologyAndGeometry(polarizedPol2) == TEST_OK );
704  //BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(polarizedPol2, polarizedPolComp2) == TEST_OK );
705 
706  cout << endl;
707  cout << "//////////////////" << endl;
708  cout << "// SPECTOMETER //" << endl;
709  cout << "////////////////" << endl;
710  cout << "#########" << endl;
711  cout << "# SUM 1 #" << endl;
712  cout << "#########" << endl;
713  string SPEC_path_test = string("test/SPECTRO/");
714  Rn::setDimension(6);
715  Rn::setTolerance(0.000001);
716  boost::shared_ptr<Polytope_Rn> SPEC_sum12(new Polytope_Rn());
717  boost::shared_ptr<Polytope_Rn> SPEC_sum21(new Polytope_Rn());
718  boost::shared_ptr<Polytope_Rn> SPEC_polytope1(new Polytope_Rn());
719  boost::shared_ptr<Polytope_Rn> SPEC_polytope2(new Polytope_Rn());
720  boost::shared_ptr<Polytope_Rn> SPEC_polytope2test(new Polytope_Rn());
721  BOOST_REQUIRE( politopixAPI::loadPolytope(SPEC_path_test + string("P_10_20_FC2.ptop"), SPEC_polytope1) == TEST_OK );
722  BOOST_REQUIRE( politopixAPI::loadPolytope(SPEC_path_test + string("P_20_30_FC2.ptop"), SPEC_polytope2) == TEST_OK );
723  BOOST_REQUIRE( politopixAPI::loadPolytope(SPEC_path_test + string("comp_10_20_30.ptop"), SPEC_polytope2test) == TEST_OK );
724  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(SPEC_polytope1, SPEC_polytope2, SPEC_sum12) == TEST_OK );
725  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(SPEC_polytope2, SPEC_polytope1, SPEC_sum21) == TEST_OK );
726  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(SPEC_sum12, SPEC_polytope2test) == TEST_OK );
727  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(SPEC_sum21, SPEC_polytope2test) == TEST_OK );
728 
729  cout << endl;
730  cout << "//////////////////////" << endl;
731  cout << "// COMPUTE VOLUMES //" << endl;
732  cout << "////////////////////" << endl;
733  string Pvol_path_test = string("test/VOL/");
734  Rn::setDimension(3);
735  Rn::setTolerance(0.000001);
736  boost::shared_ptr<Polytope_Rn> Pvol1(new Polytope_Rn());
737  boost::shared_ptr<Polytope_Rn> Pvol2(new Polytope_Rn());
738  boost::shared_ptr<Polytope_Rn> Pvol3(new Polytope_Rn());
739  boost::shared_ptr<Polytope_Rn> Pvol4(new Polytope_Rn());
740  boost::shared_ptr<Polytope_Rn> Pvol5(new Polytope_Rn());
741  boost::shared_ptr<Polytope_Rn> Pvol6(new Polytope_Rn());
742  boost::shared_ptr<Polytope_Rn> Pvol7(new Polytope_Rn());
743  boost::shared_ptr<Polytope_Rn> Pvol8(new Polytope_Rn());
744  boost::shared_ptr<Polytope_Rn> Pvol9(new Polytope_Rn());
745  boost::shared_ptr<Polytope_Rn> Pvol10(new Polytope_Rn());
746  boost::shared_ptr<Polytope_Rn> Pvol11(new Polytope_Rn());
747  boost::shared_ptr<Polytope_Rn> Pvol_cube3d(new Polytope_Rn());
748  boost::shared_ptr<Polytope_Rn> Pvol_cube4d(new Polytope_Rn());
749  boost::shared_ptr<Polytope_Rn> Pvol_cube5d(new Polytope_Rn());
750  boost::shared_ptr<Polytope_Rn> Pvol_cube6d(new Polytope_Rn());
751  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis1_3d.ptop"), Pvol1) == TEST_OK );
752  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis2_3d.ptop"), Pvol2) == TEST_OK );
753  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis3_3d.ptop"), Pvol3) == TEST_OK );
754  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis4_3d.ptop"), Pvol4) == TEST_OK );
755  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis5_3d.ptop"), Pvol5) == TEST_OK );
756  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis6_3d.ptop"), Pvol6) == TEST_OK );
757  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis7_3d.ptop"), Pvol7) == TEST_OK );
758  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis8_3d.ptop"), Pvol8) == TEST_OK );
759  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis9_3d.ptop"), Pvol9) == TEST_OK );
760  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis10_3d.ptop"), Pvol10) == TEST_OK );
761  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("teis11_3d.ptop"), Pvol11) == TEST_OK );
762  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("cube3D.ptop"), Pvol_cube3d) == TEST_OK );
763  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("cube4D.ptop"), Pvol_cube4d) == TEST_OK );
764  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("cube5D.ptop"), Pvol_cube5d) == TEST_OK );
765  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("cube6D.ptop"), Pvol_cube6d) == TEST_OK );
766  double volume1 = politopixAPI::computeVolume(Pvol1);
767  double volume2 = politopixAPI::computeVolume(Pvol2);
768  double volume3 = politopixAPI::computeVolume(Pvol3);
769  double volume4 = politopixAPI::computeVolume(Pvol4);
770  double volume5 = politopixAPI::computeVolume(Pvol5);
771  double volume6 = politopixAPI::computeVolume(Pvol6);
772  double volume7 = politopixAPI::computeVolume(Pvol7);
773  double volume8 = politopixAPI::computeVolume(Pvol8);
774  double volume9 = politopixAPI::computeVolume(Pvol9);
775  double volume10 = politopixAPI::computeVolume(Pvol10);
776  double volume11 = politopixAPI::computeVolume(Pvol11);
777  BOOST_REQUIRE(6.65110e-07 < volume1 && volume1 < 6.65112e-07);
778  BOOST_REQUIRE(6.07855e-07 < volume2 && volume2 < 6.07857e-07);
779  BOOST_REQUIRE(1.81130e-06 < volume3 && volume3 < 1.81132e-06);
780  BOOST_REQUIRE(7.37121e-07 < volume4 && volume4 < 7.37123e-07);
781  BOOST_REQUIRE(5.73780e-07 < volume5 && volume5 < 5.73782e-07);
782  BOOST_REQUIRE(3.08791e-06 < volume6 && volume6 < 3.08793e-06);
783  BOOST_REQUIRE(1.11362e-06 < volume7 && volume7 < 1.11364e-06);
784  BOOST_REQUIRE(1.54424e-06 < volume8 && volume8 < 1.54426e-06);
785  BOOST_REQUIRE(1.24113e-05 < volume9 && volume9 < 1.24116e-05);
786  BOOST_REQUIRE(3.21623e-06 < volume10 && volume10 < 3.21625e-06);
787  BOOST_REQUIRE(2.55674e-05 < volume11 && volume11 < 2.55676e-05);
788  double volumeC1 = politopixAPI::computeVolume(Pvol_cube3d);
789  Rn::setDimension(4);
790  double volumeC2 = politopixAPI::computeVolume(Pvol_cube4d);
791  Rn::setDimension(5);
792  double volumeC3 = politopixAPI::computeVolume(Pvol_cube5d);
793  Rn::setDimension(6);
794  double volumeC4 = politopixAPI::computeVolume(Pvol_cube6d);
795  BOOST_REQUIRE(volumeC1 == 1000);
796  BOOST_REQUIRE(volumeC2 == 10000);
797  BOOST_REQUIRE(volumeC3 == 100000);
798  BOOST_REQUIRE(volumeC4 == 1000000);
799 
800  boost::shared_ptr<Polytope_Rn> Pvol_A1(new Polytope_Rn());
801  boost::shared_ptr<Polytope_Rn> Pvol_A2(new Polytope_Rn());
802  boost::shared_ptr<Polytope_Rn> Pvol_A3(new Polytope_Rn());
803  boost::shared_ptr<Polytope_Rn> Pvol_A4(new Polytope_Rn());
804  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("BIR3-4-6_v.ptop"), Pvol_A1) == TEST_OK );
805  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("20D6_v.ptop"), Pvol_A2) == TEST_OK );
806  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("DG1.ptop"), Pvol_A3) == TEST_OK );
807  BOOST_REQUIRE( politopixAPI::loadPolytope(Pvol_path_test + string("DG2.ptop"), Pvol_A4) == TEST_OK );
808  Rn::setDimension(4);
809  double volumeA1 = politopixAPI::computeVolume(Pvol_A1);
810  Rn::setDimension(6);
811  double volumeA2 = politopixAPI::computeVolume(Pvol_A2);
812  double volumeA3 = politopixAPI::computeVolume(Pvol_A3);
813  double volumeA4 = politopixAPI::computeVolume(Pvol_A4);
814  BOOST_REQUIRE(0.124 < volumeA1 && volumeA1 < 0.126);
815  BOOST_REQUIRE(0.0114730 < volumeA2 && volumeA2 < 0.0114733);
816  BOOST_REQUIRE(0.015947725 < volumeA3 && volumeA3 < 0.015947727);
817  BOOST_REQUIRE(38.8410 < volumeA4 && volumeA4 < 38.8412);
818 
819  cout << endl;
820  cout << "/////////////////" << endl;
821  cout << "// TEST CUBES //" << endl;
822  cout << "///////////////" << endl;
823  Rn::setDimension(6);
824  Rn::setTolerance(0.000001);
825  boost::shared_ptr<Polytope_Rn> cube_0, cube_1, cube_2;
826  boost::shared_ptr<Polytope_Rn> res_cube_a(new Polytope_Rn());
827  boost::shared_ptr<Polytope_Rn> res_cube_b(new Polytope_Rn());
828  BOOST_REQUIRE( politopixAPI::makeCube(cube_0, 1.) == TEST_OK );
829  BOOST_REQUIRE( politopixAPI::makeCube(cube_1, 10.) == TEST_OK );
830  BOOST_REQUIRE( politopixAPI::makeCube(cube_2, 100.) == TEST_OK );
831  cube_0->checkTopologyAndGeometry();
832  cube_1->checkTopologyAndGeometry();
833  BOOST_REQUIRE( politopixAPI::computeIntersection(cube_0, cube_1, res_cube_a) == TEST_OK );
834  res_cube_a->checkTopologyAndGeometry();
835  BOOST_REQUIRE( politopixAPI::computeIntersection(res_cube_a, cube_2, res_cube_b) == TEST_OK );
836 
837  cout << endl;
838  cout << "/////////////////////////////" << endl;
839  cout << "// REMOVE CAP HALF-SPACES //" << endl;
840  cout << "///////////////////////////" << endl;
841  Rn::setDimension(5);
842  Rn::setTolerance(0.000001);
843  string ppiston = string("test/CAPS/PISTON/5D/");
845  boost::shared_ptr<Polytope_Rn> P1_5D(new Polytope_Rn());
846  boost::shared_ptr<Polytope_Rn> P2_5D(new Polytope_Rn());
847  boost::shared_ptr<Polytope_Rn> P3_5D(new Polytope_Rn());
848  boost::shared_ptr<Polytope_Rn> P4_5D(new Polytope_Rn());
849  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("P1.ptop"), P1_5D) == TEST_OK );
850  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P1_5D, 1000.) == TEST_OK );
851  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("P2.ptop"), P2_5D) == TEST_OK );
852  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P2_5D, 1000.) == TEST_OK );
853  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("P3.ptop"), P3_5D) == TEST_OK );
854  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P3_5D, 1000.) == TEST_OK );
855  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("P4.ptop"), P4_5D) == TEST_OK );
856  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P4_5D, 1000.) == TEST_OK );
857  boost::shared_ptr<Polytope_Rn> ps_P12_5D_S1(new Polytope_Rn());
858  boost::shared_ptr<Polytope_Rn> ps_P12_5D_S2(new Polytope_Rn());
859  boost::shared_ptr<Polytope_Rn> ps_P123_5D_S1(new Polytope_Rn());
860  boost::shared_ptr<Polytope_Rn> ps_P123_5D_S2(new Polytope_Rn());
861  boost::shared_ptr<Polytope_Rn> ps_P1234_5D_S1(new Polytope_Rn());
862  boost::shared_ptr<Polytope_Rn> ps_P1234_5D_S2(new Polytope_Rn());
863  std::set< unsigned int > P1Caps, P2Caps, P3Caps, P4Caps;
864  std::set< unsigned int > Sum12Caps, Sum123Caps, Sum1234Caps;
865  {for (unsigned int i=0; i<2; ++i) {
866  P2Caps.insert(i);
867  P3Caps.insert(i);
868  P4Caps.insert(i);
869  }}
870  {for (unsigned int i=0; i<4; ++i) {
871  P1Caps.insert(i);
872  }}
873  cout << "############################" << endl;
874  cout << "# pseudosum: P1 + P2 = P12 #" << endl;
875  cout << "############################" << endl;
876  BOOST_REQUIRE( politopixAPI::pseudoSum(P1_5D, P2_5D, ps_P12_5D_S1, P1Caps, P2Caps, Sum12Caps) == TEST_OK );
877  BOOST_REQUIRE( politopixAPI::pseudoSum(P2_5D, P1_5D, ps_P12_5D_S2, P2Caps, P1Caps, Sum12Caps) == TEST_OK );
878  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(ps_P12_5D_S1, ps_P12_5D_S2) == TEST_OK );
879  cout << "##############################" << endl;
880  cout << "# pseudosum: P12 + P3 = P123 #" << endl;
881  cout << "##############################" << endl;
882  BOOST_REQUIRE( politopixAPI::pseudoSum(ps_P12_5D_S1, P3_5D, ps_P123_5D_S1, Sum12Caps, P3Caps, Sum123Caps) == TEST_OK );
883  BOOST_REQUIRE( politopixAPI::pseudoSum(P3_5D, ps_P12_5D_S1, ps_P123_5D_S2, P3Caps, Sum12Caps, Sum123Caps) == TEST_OK );
884  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(ps_P123_5D_S1, ps_P123_5D_S2) == TEST_OK );
885  cout << "################################" << endl;
886  cout << "# pseudosum: P123 + P4 = P1234 #" << endl;
887  cout << "################################" << endl;
888  BOOST_REQUIRE( politopixAPI::pseudoSum(ps_P123_5D_S1, P4_5D, ps_P1234_5D_S1, Sum123Caps, P4Caps, Sum1234Caps) == TEST_OK );
889  BOOST_REQUIRE( politopixAPI::pseudoSum(P4_5D, ps_P123_5D_S1, ps_P1234_5D_S2, P4Caps, Sum123Caps, Sum1234Caps) == TEST_OK );
890  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(ps_P1234_5D_S1, ps_P1234_5D_S2) == TEST_OK );
892  boost::shared_ptr<Polytope_Rn> polP12_5D(new Polytope_Rn());
893  boost::shared_ptr<Polytope_Rn> shgP12_5D(new Polytope_Rn());
894  boost::shared_ptr<Polytope_Rn> polP123_5D(new Polytope_Rn());
895  boost::shared_ptr<Polytope_Rn> shgP123_5D(new Polytope_Rn());
896  boost::shared_ptr<Polytope_Rn> polP1234_5D(new Polytope_Rn());
897  boost::shared_ptr<Polytope_Rn> shgP1234_5D(new Polytope_Rn());
898  cout << "############################" << endl;
899  cout << "# with caps: P1 + P2 = P12 #" << endl;
900  cout << "############################" << endl;
901  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(P1_5D, P2_5D, polP12_5D) == TEST_OK );
902  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("shgP12.ptop"), shgP12_5D) == TEST_OK );
903  BOOST_REQUIRE( politopixAPI::checkEqualityOfVertices(polP12_5D, shgP12_5D) == TEST_OK );
904  cout << "##############################" << endl;
905  cout << "# with caps: P12 + P3 = P123 #" << endl;
906  cout << "##############################" << endl;
907  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(polP12_5D, P3_5D, polP123_5D) == TEST_OK );
908  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("shgP123.ptop"), shgP123_5D) == TEST_OK );
909  BOOST_REQUIRE( politopixAPI::checkEqualityOfVertices(polP123_5D, shgP123_5D) == TEST_OK );
910  cout << "################################" << endl;
911  cout << "# with caps: P123 + P4 = P1234 #" << endl;
912  cout << "################################" << endl;
913  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(polP123_5D, P4_5D, polP1234_5D) == TEST_OK );
914  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("shgP1234.ptop"), shgP1234_5D) == TEST_OK );
915  BOOST_REQUIRE( politopixAPI::checkEqualityOfVertices(polP1234_5D, shgP1234_5D) == TEST_OK );
917  std::set< unsigned int > hyperplanes2project2D;
918  hyperplanes2project2D.insert(3);
919  hyperplanes2project2D.insert(4);
920  boost::shared_ptr<Polytope_Rn> proj_polP1234_5D(new Polytope_Rn());
921  boost::shared_ptr<Polytope_Rn> proj_ps_P1234_5D_S1(new Polytope_Rn());
922  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project2D, ps_P1234_5D_S1, proj_ps_P1234_5D_S1);
923  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project2D, polP1234_5D, proj_polP1234_5D);
924  Rn::setDimension(2);
925  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(proj_ps_P1234_5D_S1, proj_polP1234_5D) == TEST_OK );
926  boost::shared_ptr<Polytope_Rn> finalP2D(new Polytope_Rn());
927  BOOST_REQUIRE( politopixAPI::loadPolytope(ppiston + string("P1234_2D.ptop"), finalP2D) == TEST_OK );
928  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(proj_ps_P1234_5D_S1, finalP2D) == TEST_OK );
930  string path_test_caps = string("test/CAPS/");
931  {for (int i=1; i<argc; ++i) {
932  if (strcmp(argv[i], "piston") == 0) {
933  Rn::setDimension(6);
934  Rn::setTolerance(0.000001);
935  cout << "##########" << endl;
936  cout << "# Piston #" << endl;
937  cout << "##########" << endl;
938  string path_test_caps_piston = path_test_caps+string("PISTON/");
939  boost::shared_ptr<Polytope_Rn> pist1_TestCaps(new Polytope_Rn());
940  boost::shared_ptr<Polytope_Rn> pist2_TestCaps(new Polytope_Rn());
941  boost::shared_ptr<Polytope_Rn> pist_Sum_TestCaps(new Polytope_Rn());
942  boost::shared_ptr<Polytope_Rn> pist_Sum_TestCaps_check(new Polytope_Rn());
943  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps_piston + string("P1_6D_HV.ptop"), pist1_TestCaps) == TEST_OK );
944  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps_piston + string("P2_6D_HV.ptop"), pist2_TestCaps) == TEST_OK );
945  std::set< unsigned int > PO1Caps, PO2Caps, PSum_1Caps_;
946  PO1Caps.insert(0); PO1Caps.insert(1); PO1Caps.insert(2); PO1Caps.insert(3);
947  PO2Caps.insert(0); PO2Caps.insert(1); PO2Caps.insert(2); PO2Caps.insert(3);
948  BOOST_REQUIRE( politopixAPI::pseudoSum(pist1_TestCaps, pist2_TestCaps, pist_Sum_TestCaps, PO1Caps, PO2Caps, PSum_1Caps_) == TEST_OK );
949  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps_piston + string("Sum_6D_proj_HV.ptop"), pist_Sum_TestCaps_check) == TEST_OK );
950  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(pist_Sum_TestCaps, pist_Sum_TestCaps_check) == TEST_OK );
951  }
952  }}
953  Rn::setDimension(3);
954  Rn::setTolerance(0.0001);
955  cout << "#########" << endl;
956  cout << "# R3 Ex #" << endl;
957  cout << "#########" << endl;
958  boost::shared_ptr<Polytope_Rn> p1_TestCaps(new Polytope_Rn());
959  boost::shared_ptr<Polytope_Rn> p2_TestCaps(new Polytope_Rn());
960  boost::shared_ptr<Polytope_Rn> Sum_TestCaps(new Polytope_Rn());
961  boost::shared_ptr<Polytope_Rn> Sum_TestCaps_check(new Polytope_Rn());
962  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps + string("cube3D.ptop"), p1_TestCaps) == TEST_OK );
963  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps + string("lmp1_v.ptop"), p2_TestCaps) == TEST_OK );
964  std::set< unsigned int > O1Caps, O2Caps, Sum_1Caps_;
965  O1Caps.insert(0); O1Caps.insert(1); O1Caps.insert(3); O1Caps.insert(4);
966  BOOST_REQUIRE( politopixAPI::pseudoSum(p1_TestCaps, p2_TestCaps, Sum_TestCaps, O1Caps, O2Caps, Sum_1Caps_) == TEST_OK );
967  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps + string("lmp1_v_cube3D_testCaps.ptop"), Sum_TestCaps_check) == TEST_OK );
968  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Sum_TestCaps, Sum_TestCaps_check) == TEST_OK );
969 
970  cout << "###########" << endl;
971  cout << "# CIRP R6 #" << endl;
972  cout << "###########" << endl;
973  Rn::setDimension(6);
974  Rn::setTolerance(0.000001);
975  boost::shared_ptr<Polytope_Rn> p1_TestCaps_b(new Polytope_Rn());
976  boost::shared_ptr<Polytope_Rn> p2_TestCaps_b(new Polytope_Rn());
977  boost::shared_ptr<Polytope_Rn> Sum_TestCaps_b(new Polytope_Rn());
978  boost::shared_ptr<Polytope_Rn> Sum_TestCaps_check_b(new Polytope_Rn());
979  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps + string("P1_6D_HV.ptop"), p1_TestCaps_b) == TEST_OK );
980  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps + string("P2_6D_HV.ptop"), p2_TestCaps_b) == TEST_OK );
981  std::set< unsigned int > O1Caps_b, O2Caps_b, Sum_1Caps_b;
982  O1Caps_b.insert(0); O1Caps_b.insert(1); O1Caps_b.insert(2); O1Caps_b.insert(3); O1Caps_b.insert(4); O1Caps_b.insert(5);
983  O2Caps_b.insert(0); O2Caps_b.insert(1); O2Caps_b.insert(2); O2Caps_b.insert(3); O2Caps_b.insert(4); O2Caps_b.insert(5);
984  BOOST_REQUIRE( politopixAPI::pseudoSum(p1_TestCaps_b, p2_TestCaps_b, Sum_TestCaps_b, O1Caps_b, O2Caps_b, Sum_1Caps_b) == TEST_OK );
985  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps + string("P1_P2_testCaps.ptop"), Sum_TestCaps_check_b) == TEST_OK );
986  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Sum_TestCaps_b, Sum_TestCaps_check_b) == TEST_OK );
987 
988  cout << "############" << endl;
989  cout << "# SPEC CAP #" << endl;
990  cout << "############" << endl;
991  Rn::setDimension(6);
992  Rn::setTolerance(0.000001);
993  string path_test_caps2 = string("test/CAPS/spec_small_disc/");
994  boost::shared_ptr<Polytope_Rn> Pc_21(new Polytope_Rn());
995  boost::shared_ptr<Polytope_Rn> Pc_22(new Polytope_Rn());
996  boost::shared_ptr<Polytope_Rn> Pc_23(new Polytope_Rn());
997  boost::shared_ptr<Polytope_Rn> Pc_24(new Polytope_Rn());
998  boost::shared_ptr<Polytope_Rn> Pc_25(new Polytope_Rn());
999  boost::shared_ptr<Polytope_Rn> Pc_26(new Polytope_Rn());
1000  boost::shared_ptr<Polytope_Rn> Pg_37(new Polytope_Rn());
1001  boost::shared_ptr<Polytope_Rn> Pg_38(new Polytope_Rn());
1002  boost::shared_ptr<Polytope_Rn> Pg_14(new Polytope_Rn());
1003  cout << "#########################" << endl;
1004  cout << "# SPEC CAP: truncations #" << endl;
1005  cout << "#########################" << endl;
1006  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_10.ptop"), Pc_21) == TEST_OK );
1007  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pc_21, 1000.) == TEST_OK );
1008  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_11.ptop"), Pc_22) == TEST_OK );
1009  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pc_22, 1000.) == TEST_OK );
1010  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_3.ptop"), Pc_23) == TEST_OK );
1011  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pc_23, 1000.) == TEST_OK );
1012  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_4.ptop"), Pc_24) == TEST_OK );
1013  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pc_24, 1000.) == TEST_OK );
1014  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_12.ptop"), Pc_25) == TEST_OK );
1015  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pc_25, 1000.) == TEST_OK );
1016  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_13.ptop"), Pc_26) == TEST_OK );
1017  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pc_26, 1000.) == TEST_OK );
1018  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_7.ptop"), Pg_37) == TEST_OK );
1019  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pg_37, 1000.) == TEST_OK );
1020  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_8.ptop"), Pg_38) == TEST_OK );
1021  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pg_38, 1000.) == TEST_OK );
1022  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("Polytope_9.ptop"), Pg_14) == TEST_OK );
1023  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(Pg_14, 1000.) == TEST_OK );
1024  std::set< unsigned int > Int_1Caps, Int_2Caps, Sum_1Caps, Sum_1_s2Caps, P_11_20_FC1Caps, P_20_30_FC1Caps;
1025  std::set< unsigned int > Pc_21Caps, Pc_22Caps, Pc_23Caps, Pc_24Caps, Pc_25Caps, Pc_26Caps, Pg_37Caps;
1026  {for (unsigned int i=0; i<8; ++i) {
1027  Pc_21Caps.insert(i);Pc_22Caps.insert(i);
1028  }}
1029  {for (unsigned int i=0; i<6; ++i) {
1030  Pc_23Caps.insert(i);Pc_24Caps.insert(i);
1031  }}
1032  {for (unsigned int i=0; i<4; ++i) {
1033  Pg_37Caps.insert(i);
1034  }}
1035  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);
1036  cout << endl;
1037  cout << "######################" << endl;
1038  cout << "# Operations for FC1 #" << endl;
1039  cout << "######################" << endl;
1040  boost::shared_ptr<Polytope_Rn> Int_1, Int_2, P_11_20_FC1, P_20_30_FC1;
1041  boost::shared_ptr<Polytope_Rn> Sum_1(new Polytope_Rn()); boost::shared_ptr<Polytope_Rn> Sum_1_s2(new Polytope_Rn());
1042  BOOST_REQUIRE( politopixAPI::pseudoIntersection(Pc_21, Pc_22, Int_1, Pc_21Caps, Pc_22Caps, Int_1Caps) == TEST_OK );
1043  BOOST_REQUIRE( politopixAPI::pseudoSum(Pc_23, Int_1, Sum_1, Pc_23Caps, Int_1Caps, Sum_1Caps) == TEST_OK );
1044  BOOST_REQUIRE( politopixAPI::pseudoSum(Int_1, Pc_23, Sum_1_s2, Int_1Caps, Pc_23Caps, Sum_1_s2Caps) == TEST_OK );
1045  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Sum_1, Sum_1_s2) == TEST_OK );
1046 
1047  Int_2.reset(new Polytope_Rn()); P_11_20_FC1.reset(new Polytope_Rn()); P_20_30_FC1.reset(new Polytope_Rn());
1048  BOOST_REQUIRE( politopixAPI::pseudoIntersection(Sum_1, Int_1, P_11_20_FC1, Sum_1Caps, Int_1Caps, P_11_20_FC1Caps) == TEST_OK );
1049  BOOST_REQUIRE( politopixAPI::pseudoIntersection(Pc_24, Pc_25, Int_2, Pc_24Caps, Pc_25Caps, Int_2Caps) == TEST_OK );
1050  BOOST_REQUIRE( politopixAPI::pseudoIntersection(Int_2, Pc_26, P_20_30_FC1, Int_2Caps, Pc_26Caps, P_20_30_FC1Caps) == TEST_OK );
1051 
1052  cout << "#########################################" << endl;
1053  cout << "# Polytope from node 1.0 to 3.0 for FC1 #" << endl;
1054  cout << "#########################################" << endl;
1055  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());
1056  std::set< unsigned int > P_11_30_FC1_s2Caps, P_11_30_FC1_s1Caps;
1057  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 );
1058  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 );
1059  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(P_11_30_FC1_s1, P_11_30_FC1_s2) == TEST_OK );
1060 
1061  cout << "#####################" << endl;
1062  cout << "# Final sum for FC1 #" << endl;
1063  cout << "#####################" << endl;
1064  boost::shared_ptr<Polytope_Rn> Pfin_FC1_s1(new Polytope_Rn()); boost::shared_ptr<Polytope_Rn> Pfin_FC1_s2(new Polytope_Rn());
1065  std::set< unsigned int > Pfin_FC1_s1Caps, Pfin_FC1_s2Caps;
1066  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 );
1067  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 );
1068  //std::copy(Pfin_FC1_s1Caps.begin(), Pfin_FC1_s1Caps.end(), std::ostream_iterator<unsigned int>(std::cout, " ") );
1069  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pfin_FC1_s1, Pfin_FC1_s2) == TEST_OK );
1070  boost::shared_ptr<Polytope_Rn> final_sant(new Polytope_Rn());
1071  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_caps2 + string("final_sant.ptop"), final_sant) == TEST_OK );
1072  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pfin_FC1_s1, final_sant) == TEST_OK );
1073  cout << endl;
1074 
1075 
1076 
1077  cout << "#############################" << endl;
1078  cout << "# Simulation cutting system #" << endl;
1079  cout << "#############################" << endl;
1080  Rn::setDimension(6);
1081  Rn::setTolerance(0.000001);
1082  string path_test_cutting = string("test/AFILADO/");
1083  boost::shared_ptr<Polytope_Rn> P11(new Polytope_Rn());
1084  boost::shared_ptr<Polytope_Rn> P33_43(new Polytope_Rn());
1085  boost::shared_ptr<Polytope_Rn> P34_44(new Polytope_Rn());
1086  boost::shared_ptr<Polytope_Rn> P41(new Polytope_Rn());
1087  cout << "########################" << endl;
1088  cout << "# CUTTING: truncations #" << endl;
1089  cout << "########################" << endl;
1090  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_cutting + string("Afilado_Polytope_1.ptop"), P11) == TEST_OK );
1091  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_cutting + string("Afilado_Polytope_6.ptop"), P33_43) == TEST_OK );
1092  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_cutting + string("Afilado_Polytope_10.ptop"), P34_44) == TEST_OK );
1093  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_cutting + string("Afilado_Polytope_11.ptop"), P41) == TEST_OK );
1094  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P11, 1000.) == TEST_OK );
1095  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P33_43, 1000.) == TEST_OK );
1096  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P34_44, 1000.) == TEST_OK );
1097  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(P41, 1000.) == TEST_OK );
1098  boost::shared_ptr<Polytope_Rn> P30_40(new Polytope_Rn());
1099  boost::shared_ptr<Polytope_Rn> P11_41S2(new Polytope_Rn());
1100  boost::shared_ptr<Polytope_Rn> P11_41S1(new Polytope_Rn());
1101  boost::shared_ptr<Polytope_Rn> PfinS1(new Polytope_Rn());
1102  boost::shared_ptr<Polytope_Rn> PfinS2(new Polytope_Rn());
1103  boost::shared_ptr<Polytope_Rn> PfinS3(new Polytope_Rn());
1104  std::set< unsigned int > P11Caps, P33_43Caps, P34_44Caps, P41Caps;
1105  std::set< unsigned int > P30_40Caps, P11_41Caps, PfinCaps;
1106  {for (unsigned int i=0; i<10; ++i) {
1107  P34_44Caps.insert(i);
1108  }}
1109  {for (unsigned int i=0; i<4; ++i) {
1110  P11Caps.insert(i);
1111  P41Caps.insert(i);
1112  P33_43Caps.insert(i);
1113  }}
1114 
1115  cout << "##############" << endl;
1116  cout << "# Operations #" << endl;
1117  cout << "##############" << endl;
1118  BOOST_REQUIRE( politopixAPI::pseudoIntersection(P33_43, P34_44, P30_40, P33_43Caps, P34_44Caps, P30_40Caps) == TEST_OK );
1119  BOOST_REQUIRE( politopixAPI::pseudoSum(P11, P41, P11_41S1, P11Caps, P41Caps, P11_41Caps) == TEST_OK );
1120  BOOST_REQUIRE( politopixAPI::pseudoSum(P41, P11, P11_41S2, P41Caps, P11Caps, P11_41Caps) == TEST_OK );
1121  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(P11_41S1, P11_41S2) == TEST_OK );
1122  cout << "#############" << endl;
1123  cout << "# Final sum #" << endl;
1124  cout << "#############" << endl;
1125  BOOST_REQUIRE( politopixAPI::pseudoSum(P11_41S1, P30_40, PfinS1, P11_41Caps, P30_40Caps, PfinCaps) == TEST_OK );
1126  BOOST_REQUIRE( politopixAPI::pseudoSum(P30_40, P11_41S1, PfinS2, P30_40Caps, P11_41Caps, PfinCaps) == TEST_OK );
1127  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(PfinS1, PfinS2) == TEST_OK );
1128  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test_cutting + string("Pfin.ptop"), PfinS3) == TEST_OK );
1129  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(PfinS1, PfinS3) == TEST_OK );
1130  cout << endl;
1131 
1132  cout << "###################" << endl;
1133  cout << "# DATA1: Lattices #" << endl;
1134  cout << "###################" << endl;
1135  Rn::setDimension(3);
1136  path_test1 = string("./test/DATA1/");
1137  _polytopeTest.reset(new Polytope_Rn());
1138  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("lmp1.ptop"), _polytopeTest) == TEST_OK );
1139  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
1140  FaceEnumeration FaceEnumLmp1(_polytopeTest);
1141  FaceEnumeration::Compute(_polytopeTest, FaceEnumLmp1);
1142  //FaceEnumLmp1.printFacesWithFacets(std::cout);
1143  //FaceEnumLmp1.printFacesWithVertices(std::cout);
1144  std::vector< std::vector< ListOfFaces > > Lattice2Compare;
1145  FaceEnumeration::load(path_test1 + string("lmp1.latt"), Lattice2Compare);
1146  BOOST_REQUIRE(FaceEnumLmp1.getFacesWithVertices() == Lattice2Compare);
1147 
1148  Rn::setDimension(3);
1149  _polytopeTest.reset(new Polytope_Rn());
1150  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("cube3D.ptop"), _polytopeTest) == TEST_OK );
1151  FaceEnumeration FaceEnumCube(_polytopeTest);
1152  FaceEnumeration::Compute(_polytopeTest, FaceEnumCube);
1153  //FaceEnumCube.printFacesWithFacets(std::cout);
1154  //FaceEnumCube.printFacesWithVertices(std::cout);
1155  Lattice2Compare.clear();
1156  FaceEnumeration::load(path_test1 + string("cube3d.latt"), Lattice2Compare);
1157  BOOST_REQUIRE(FaceEnumCube.getFacesWithVertices() == Lattice2Compare);
1158 
1159  Rn::setDimension(6);
1160  _polytopeTest.reset(new Polytope_Rn());
1161  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("8D6.ptop"), _polytopeTest) == TEST_OK );
1162  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
1163  FaceEnumeration FaceEnum(_polytopeTest);
1164  FaceEnumeration::Compute(_polytopeTest, FaceEnum);
1165  //FaceEnum.printFacesWithFacets(std::cout);
1166  //FaceEnum.printFacesWithVertices(std::cout);
1167  Lattice2Compare.clear();
1168  FaceEnumeration::load(path_test1 + string("8D6.latt"), Lattice2Compare);
1169  BOOST_REQUIRE(FaceEnum.getFacesWithVertices() == Lattice2Compare);
1170 
1171  Rn::setDimension(6);
1172  _polytopeTest.reset(new Polytope_Rn());
1173  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("10D6.ptop"), _polytopeTest) == TEST_OK );
1174  BOOST_REQUIRE( politopixAPI::computeDoubleDescription(_polytopeTest, 1000.) == TEST_OK );
1175  FaceEnumeration FaceEnum2(_polytopeTest);
1176  FaceEnumeration::Compute(_polytopeTest, FaceEnum2);
1177  //FaceEnum2.printFacesWithFacets(std::cout);
1178  //FaceEnum2.printFacesWithVertices(std::cout);
1179  Lattice2Compare.clear();
1180  FaceEnumeration::load(path_test1 + string("10D6.latt"), Lattice2Compare);
1181  BOOST_REQUIRE(FaceEnum2.getFacesWithVertices() == Lattice2Compare);
1182 
1183  Rn::setDimension(6);
1184  _polytopeTest.reset(new Polytope_Rn());
1185  BOOST_REQUIRE( politopixAPI::loadPolytope(path_test1 + string("P9.ptop"), _polytopeTest) == TEST_OK );
1186  FaceEnumeration FaceEnum_9(_polytopeTest);
1187  FaceEnumeration::Compute(_polytopeTest, FaceEnum_9);
1188  //FaceEnum_9.printFacesWithFacets(std::cout);
1189  //FaceEnum_9.printFacesWithVerticesToSage(std::cout);
1190  //FaceEnum_9.save(std::cout);
1191  Lattice2Compare.clear();
1192  FaceEnumeration::load(path_test1 + string("P9.latt"), Lattice2Compare);
1193  BOOST_REQUIRE(FaceEnum_9.getFacesWithVertices() == Lattice2Compare);
1194  cout << endl;
1195 
1196  cout << "###############" << endl;
1197  cout << "# PROJECTIONS #" << endl;
1198  cout << "###############" << endl;
1199  Rn::setDimension(6);
1200  Rn::setTolerance(0.00001);
1201  boost::shared_ptr<HalfSpace_Rn> H1(new HalfSpace_Rn(6)), H2(new HalfSpace_Rn(6)), H3(new HalfSpace_Rn(6));
1202  {for (unsigned int i=0; i<6; ++i) {
1203  H1->setCoefficient(i,0);
1204  H2->setCoefficient(i,0);
1205  H3->setCoefficient(i,0);
1206  }}
1207  H1->setCoefficient(0,1);
1208  H2->setCoefficient(1,1);
1209  H3->setCoefficient(2,1);
1210  H1->setConstant(0);
1211  H2->setConstant(0);
1212  H3->setConstant(0);
1213  std::vector< boost::shared_ptr<HalfSpace_Rn> > arrayOfHS;
1214  arrayOfHS.push_back(H1);
1215  arrayOfHS.push_back(H2);
1216  arrayOfHS.push_back(H3);
1217  //{for (unsigned int i=0; i<arrayOfHS.size(); ++i) {
1218  //arrayOfHS[i]->dump(cout);
1219  //cout << endl;
1220  //}}
1221  string pcaps = string("test/PROJ/");
1222  boost::shared_ptr<Polytope_Rn> P2Test(new Polytope_Rn()), Pproj(new Polytope_Rn()), P2Compare(new Polytope_Rn()), transPol(new Polytope_Rn());
1223 
1224  P2Test.reset(new Polytope_Rn());
1225  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("P11_41.ptop"), P2Test) == TEST_OK );
1226  std::set< unsigned int > hyperplanes2project;
1227  hyperplanes2project.insert(1);hyperplanes2project.insert(2);hyperplanes2project.insert(3);
1228  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, P2Test, Pproj);
1229  P2Compare.reset(new Polytope_Rn());
1230  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("_P11_41_3D_H.ptop"), P2Compare) == TEST_OK );
1231  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1232  P2Compare.reset(new Polytope_Rn());
1233  transPol.reset(new Polytope_Rn());
1234  NormalFan_Rn NF(P2Test);
1235  NF.computeHyperplanesSeparationForProjection(arrayOfHS, transPol);
1236  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, transPol, P2Compare);
1237  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1238 
1239  cout << endl;
1240  P2Test.reset(new Polytope_Rn());
1241  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("P30_40.ptop"), P2Test) == TEST_OK );
1242  hyperplanes2project.clear();
1243  hyperplanes2project.insert(1);hyperplanes2project.insert(2);hyperplanes2project.insert(3);
1244  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, P2Test, Pproj);
1245  P2Compare.reset(new Polytope_Rn());
1246  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("_P30_40_3D_H.ptop"), P2Compare) == TEST_OK );
1247  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1248  P2Compare.reset(new Polytope_Rn());
1249  transPol.reset(new Polytope_Rn());
1250  NormalFan_Rn NF_P30_40(P2Test);
1251  NF_P30_40.computeHyperplanesSeparationForProjection(arrayOfHS, transPol);
1252  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, transPol, P2Compare);
1253  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1254 
1255  cout << endl;
1256  P2Test.reset(new Polytope_Rn());
1257  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("Polytope_1.ptop"), P2Test) == TEST_OK );
1258  hyperplanes2project.clear();
1259  hyperplanes2project.insert(1);hyperplanes2project.insert(2);hyperplanes2project.insert(3);
1260  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, P2Test, Pproj);
1261  P2Compare.reset(new Polytope_Rn());
1262  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("_Polytope_1_3D_H.ptop"), P2Compare) == TEST_OK );
1263  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1264  P2Compare.reset(new Polytope_Rn());
1265  transPol.reset(new Polytope_Rn());
1266  NormalFan_Rn NF_Polytope_1(P2Test);
1267  NF_Polytope_1.computeHyperplanesSeparationForProjection(arrayOfHS, transPol);
1268  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, transPol, P2Compare);
1269  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1270 
1271  cout << endl;
1272  P2Test.reset(new Polytope_Rn());
1273  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("Polytope_6.ptop"), P2Test) == TEST_OK );
1274  hyperplanes2project.clear();
1275  hyperplanes2project.insert(1);hyperplanes2project.insert(2);hyperplanes2project.insert(3);
1276  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, P2Test, Pproj);
1277  P2Compare.reset(new Polytope_Rn());
1278  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("_Polytope_6_3D_H.ptop"), P2Compare) == TEST_OK );
1279  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1280  P2Compare.reset(new Polytope_Rn());
1281  transPol.reset(new Polytope_Rn());
1282  NormalFan_Rn NF_Polytope_6(P2Test);
1283  NF_Polytope_6.computeHyperplanesSeparationForProjection(arrayOfHS, transPol);
1284  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, transPol, P2Compare);
1285  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1286 
1287  cout << endl;
1288  P2Test.reset(new Polytope_Rn());
1289  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("Polytope_10.ptop"), P2Test) == TEST_OK );
1290  hyperplanes2project.clear();
1291  hyperplanes2project.insert(1);hyperplanes2project.insert(2);hyperplanes2project.insert(3);
1292  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, P2Test, Pproj);
1293  P2Compare.reset(new Polytope_Rn());
1294  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("_Polytope_10_3D_H.ptop"), P2Compare) == TEST_OK );
1295  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1296  P2Compare.reset(new Polytope_Rn());
1297  transPol.reset(new Polytope_Rn());
1298  NormalFan_Rn NF_Polytope_10(P2Test);
1299  //NF_Polytope_10.dump(cout);
1300  NF_Polytope_10.computeHyperplanesSeparationForProjection(arrayOfHS, transPol);
1301  BOOST_REQUIRE( politopixAPI::savePolytope(string("step1.ptop"), transPol) == TEST_OK );
1302  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, transPol, P2Compare);
1303  BOOST_REQUIRE( politopixAPI::savePolytope(string("step2.ptop"), P2Compare) == TEST_OK );
1304  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1305 
1306  cout << endl;
1307  P2Test.reset(new Polytope_Rn());
1308  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("Polytope_11.ptop"), P2Test) == TEST_OK );
1309  hyperplanes2project.clear();
1310  hyperplanes2project.insert(1);hyperplanes2project.insert(2);hyperplanes2project.insert(3);
1311  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, P2Test, Pproj);
1312  P2Compare.reset(new Polytope_Rn());
1313  BOOST_REQUIRE( politopixAPI::loadPolytope(pcaps + string("_Polytope_11_3D_H.ptop"), P2Compare) == TEST_OK );
1314  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1315  P2Compare.reset(new Polytope_Rn());
1316  transPol.reset(new Polytope_Rn());
1317  NormalFan_Rn NF_Polytope_11(P2Test);
1318  NF_Polytope_11.computeHyperplanesSeparationForProjection(arrayOfHS, transPol);
1319  TopGeomTools::projectPolytopeOnCanonicalHyperplanes(hyperplanes2project, transPol, P2Compare);
1320  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Pproj, P2Compare) == TEST_OK );
1321 
1322  cout << "#####################" << endl;
1323  cout << "# TRACING GENERATORS #" << endl;
1324  cout << "#####################" << endl;
1325  Rn::setDimension(6);
1326  Rn::setTolerance(0.000001);
1327  string tal_path("test/TALADRO/");
1328  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());
1329  boost::shared_ptr<Polytope_Rn> Tal_checkSUM12(new Polytope_Rn()),Tal_SUM123(new Polytope_Rn());
1330  BOOST_REQUIRE( politopixAPI::loadPolytope(tal_path + string("CP1.ptop"), Tal_CP1) == TEST_OK );
1331  BOOST_REQUIRE( politopixAPI::loadPolytope(tal_path + string("CP2.ptop"), Tal_CP2) == TEST_OK );
1332  BOOST_REQUIRE( politopixAPI::loadPolytope(tal_path + string("CP3.ptop"), Tal_CP3) == TEST_OK );
1333  std::vector< std::vector<int> > genitorsOfTal_CP1(Tal_CP1->numberOfGenerators());
1334  std::vector< std::vector<int> > genitorsOfTal_CP2(Tal_CP2->numberOfGenerators());
1335  std::vector< std::vector<int> > genitorsOfTal_CP3(Tal_CP3->numberOfGenerators());
1336  std::vector< std::vector<int> > genitorsOfTal_CP_1_2,genitorsOfTal_CP_1_2_3;
1337  {
1338  for (unsigned int i=0; i<genitorsOfTal_CP1.size(); ++i)
1339  genitorsOfTal_CP1[i].push_back(i);
1340  for (unsigned int j=0; j<genitorsOfTal_CP2.size(); ++j)
1341  genitorsOfTal_CP2[j].push_back(j);
1342  for (unsigned int j=0; j<genitorsOfTal_CP3.size(); ++j)
1343  genitorsOfTal_CP3[j].push_back(j);
1344  }
1345  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(Tal_CP1, Tal_CP2, Tal_SUM12, genitorsOfTal_CP1, genitorsOfTal_CP2, genitorsOfTal_CP_1_2) == TEST_OK );
1346  BOOST_REQUIRE( politopixAPI::loadPolytope(tal_path + string("CP_1_2.ptop"), Tal_checkSUM12) == TEST_OK );
1347  BOOST_REQUIRE( politopixAPI::checkEqualityOfPolytopes(Tal_SUM12, Tal_checkSUM12) == TEST_OK );
1348  BOOST_REQUIRE( politopixAPI::computeMinkowskiSumOfPolytopes(Tal_SUM12, Tal_CP3, Tal_SUM123, genitorsOfTal_CP_1_2, genitorsOfTal_CP3, genitorsOfTal_CP_1_2_3) == TEST_OK );
1349  {
1350  unsigned int thisDim = Rn::getDimension();
1351  double tol_2 = Rn::getTolerance()*Rn::getTolerance();
1352  for (unsigned int i=0; i<genitorsOfTal_CP_1_2.size(); ++i) {
1353  boost::shared_ptr<Generator_Rn> VX(new Generator_Rn(thisDim));
1354  VX->makeSum(Tal_CP1->getGenerator(genitorsOfTal_CP_1_2[i][0]), Tal_CP2->getGenerator(genitorsOfTal_CP_1_2[i][1]));
1355  BOOST_REQUIRE( VX->isEqual2(Tal_SUM12->getGenerator(i), thisDim, tol_2) == true );
1356  }
1357  for (unsigned int i=0; i<genitorsOfTal_CP_1_2_3.size(); ++i) {
1358  boost::shared_ptr<Generator_Rn> VX(new Generator_Rn(thisDim)), VX_1_2(new Generator_Rn(thisDim));
1359  VX_1_2->makeSum(Tal_CP1->getGenerator(genitorsOfTal_CP_1_2_3[i][0]), Tal_CP2->getGenerator(genitorsOfTal_CP_1_2_3[i][1]));
1360  VX->makeSum(VX_1_2, Tal_CP3->getGenerator(genitorsOfTal_CP_1_2_3[i][2]));
1361  BOOST_REQUIRE( VX->isEqual2(Tal_SUM123->getGenerator(i), thisDim, tol_2) == true );
1362  }
1363  }
1364 
1365 
1366  return TEST_OK;
1367 
1368 }
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.
static polito_EXPORT int savePolytope(const string &pathA, boost::shared_ptr< Polytope_Rn > &A)
Save a polytope in the corresponding file name.
Creation of a n-coordinate geometric point designed to be shared by its neighbour faces...
Definition: Point_Rn.h:34
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.
static polito_EXPORT void setDimension(unsigned int dim)
Set the dimension for the cartesian space we work in.
Definition: Rn.cpp:27
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...
Model a polytope using its two equivalent definitions : the convex hull and the half-space intersecti...
Definition: Polytope_Rn.h:34
A half-space whose frontier is a linear (n-1) dimension space. _constant + _coefficients[0].x1 + ... + _coefficients[n-1].xn >= 0.
Definition: HalfSpace_Rn.h:37
Model a polyhedral cone using its two equivalent definitions : the convex hull and the half-space int...
Refers to the class CellByCellDistNgb (100% of the distances between seeds to be sorted) ...
Definition: Voronoi_Rn.h:49
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 ...
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...
static polito_EXPORT int makeCube(boost::shared_ptr< Polytope_Rn > &A, double M)
Create a cube whose vertices will be (+-M, ..., +-M)
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...
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...
const GEOMETRIC_OBJECT current()
Return the current geometric element.
static int scalingFactor(boost::shared_ptr< Polytope_Rn > &pol, double factor)
Multiply a polytope by a given real number.
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...
Refers to the class CellByCellVoronoi.
Definition: Voronoi_Rn.h:47
static polito_EXPORT int checkTopologyAndGeometry(const boost::shared_ptr< PolyhedralCone_Rn > &A)
Check whether a HV-polytopes is correct.
Refers to the class CellByCellDistNgb ( 1% of the distances between seeds to be sorted) ...
Definition: Voronoi_Rn.h:50
static polito_EXPORT int loadPolytope(const string &pathA, boost::shared_ptr< Polytope_Rn > &A)
Load a polytope from the corresponding file name.
void begin()
Move the iterator at the beginning of the list.
static polito_EXPORT int PolarPolytope(const boost::shared_ptr< Polytope_Rn > &original_pol, boost::shared_ptr< Polytope_Rn > &polar_pol)
Compute the polar polytope.
int test_main(int argc, char *argv[])
static polito_EXPORT int computeDoubleDescription(boost::shared_ptr< Polytope_Rn > &A, double bb_size=1000.)
Compute the HV-description for a given H-polytope or V-polytope with the Double Description algorithm...
static polito_EXPORT void setTolerance(double t)
Give the minimum distance between two points.
Definition: Rn.cpp:33
static polito_EXPORT double getTolerance()
Give the minimum distance between two points.
Definition: Rn.cpp:31
bool end() const
Tell whether we have reached the end of the list.
Combinatorial face enumeration for polytopes.
static polito_EXPORT unsigned int getDimension()
Return the dimension of the cartesian space we work in.
Definition: Rn.cpp:29
A n-coordinates generator, which can be a vertex or an edge whether it is contained by a polytope or ...
Definition: Generator_Rn.h:38
static polito_EXPORT int loadPolyhedralCone(const string &pathA, boost::shared_ptr< PolyhedralCone_Rn > &A)
Load a polyhedral cone from the corresponding file name.
Refers to the class CellByCellVoronoiDist.
Definition: Voronoi_Rn.h:48
Refers to the class IncrementalVoronoi.
Definition: Voronoi_Rn.h:46
This class is designed to run the list of all geometric objects representing a polytope.
Model a normal fan.
Definition: NormalFan_Rn.h:37
void next()
Move the iterator one step forward.
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...
static void Compute(const boost::shared_ptr< Polytope_Rn > &A)
const std::vector< std::vector< ListOfFaces > > & getFacesWithVertices()
void computeHyperplanesSeparationForProjection(const std::vector< boost::shared_ptr< HalfSpace_Rn > > &, boost::shared_ptr< Polytope_Rn > &)
void setCoordinate(unsigned int i, double val)
Definition: Point_Rn.cpp:61
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.
static void load(const std::string &filename, std::vector< std::vector< ListOfFaces > > &latt)
Load the polytope lattice.
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.
#define TEST_OK
Definition: politopixAPI.h:38