politopix  4.1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
politopixAPI.h
Go to the documentation of this file.
1 // politopix allows to make computations on polytopes such as finding vertices, intersecting, Minkowski sums, ...
2 // Copyright (C) 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 // I2M (UMR CNRS 5295 / University of Bordeaux)
20 
21 #ifndef INC_polAPI
22 #define INC_polAPI
23 
24 #include "polito_Export.h"
25 #include "Rn.h"
26 #include "Voronoi_Rn.h"
27 #include "Polytope_Rn.h"
28 #include "IO_Polytope.h"
29 #include "Generator_Rn.h"
30 #include "HalfSpace_Rn.h"
31 #include "VolumeOfPolytopes_Rn.h"
32 #include "DoubleDescription_Rn.h"
35 
36 using namespace std;
37 
38 #define TEST_OK 0
39 #define TEST_KO -1
40 
43 class politopixAPI {
44 
45  public:
46 
51  static polito_EXPORT int savePolytope(const string& pathA, boost::shared_ptr<Polytope_Rn>& A) throw (ios_base::failure);
52 
57  static polito_EXPORT int savePolyhedralCone(const string& pathA, boost::shared_ptr<PolyhedralCone_Rn>& A) throw (ios_base::failure);
58 
63  static polito_EXPORT int loadPolytope(const string& pathA, boost::shared_ptr<Polytope_Rn>& A) throw (ios_base::failure);
64 
69  static polito_EXPORT int loadPolyhedralCone(const string& pathA, boost::shared_ptr<PolyhedralCone_Rn>& A) throw (ios_base::failure);
70 
75  static polito_EXPORT int addHalfspace(boost::shared_ptr<Polytope_Rn>& A, const boost::shared_ptr<HalfSpace_Rn>& HS);
76 
81  static polito_EXPORT int addGenerator(boost::shared_ptr<Polytope_Rn>& A, const boost::shared_ptr<Generator_Rn>& GN);
82 
87  static polito_EXPORT int computeDoubleDescription(boost::shared_ptr<Polytope_Rn>& A, double bb_size=1000.)
88  throw (invalid_argument, out_of_range, ios_base::failure, logic_error);
89 
93  static polito_EXPORT int computeDoubleDescriptionWithoutCheck(boost::shared_ptr<Polytope_Rn>& A, double bb_size=1000.)
94  throw (invalid_argument, out_of_range, ios_base::failure, logic_error);
95 
101  static polito_EXPORT int computeIntersection(const boost::shared_ptr<Polytope_Rn>& A, const boost::shared_ptr<Polytope_Rn>& B,
102  boost::shared_ptr<Polytope_Rn>& C)
103  throw (invalid_argument, out_of_range, ios_base::failure, logic_error);
104 
109  static polito_EXPORT int computeIntersection(boost::shared_ptr<Polytope_Rn>& A, const boost::shared_ptr<Polytope_Rn>& B)
110  throw (invalid_argument, out_of_range, ios_base::failure, logic_error);
111 
116  static polito_EXPORT int computeIntersectionWithoutCheck(boost::shared_ptr<Polytope_Rn>& A,
117  const boost::shared_ptr<Polytope_Rn>& B)
118  throw (invalid_argument, out_of_range, ios_base::failure, logic_error);
119 
124  static polito_EXPORT bool isIncluded(const boost::shared_ptr<Polytope_Rn>& A,
125  const boost::shared_ptr<Polytope_Rn>& B)
126  throw (invalid_argument, out_of_range, ios_base::failure, logic_error);
127 
133  static polito_EXPORT int computeMinkowskiSumOfPolytopes(const boost::shared_ptr<Polytope_Rn>& A,
134  const boost::shared_ptr<Polytope_Rn>& B, boost::shared_ptr<Polytope_Rn>& C)
135  throw (invalid_argument, out_of_range, ios_base::failure, logic_error);
136 
141  static polito_EXPORT int computeMinkowskiSumOfPolytopes(
142  const std::vector< boost::shared_ptr<Polytope_Rn> >& arrayOfPol,
143  boost::shared_ptr<Polytope_Rn>& C)
144  throw (invalid_argument, out_of_range, ios_base::failure, logic_error);
145 
152  static polito_EXPORT int computeMinkowskiSumOfPolytopes(const boost::shared_ptr<Polytope_Rn>& A,
153  const boost::shared_ptr<Polytope_Rn>& B,
154  boost::shared_ptr<Polytope_Rn>& C,
155  const std::vector< std::vector<int> >& genitorsOfGeneratorsA,
156  const std::vector< std::vector<int> >& genitorsOfGeneratorsB,
157  std::vector< std::vector<int> >& traceGenerators)
158  throw (invalid_argument, out_of_range, ios_base::failure, logic_error);
159 
166  static polito_EXPORT int checkEqualityOfPolytopes(const boost::shared_ptr<Polytope_Rn>& A,
167  const boost::shared_ptr<Polytope_Rn>& B,
168  bool getFaceMapping=false)
169  throw (invalid_argument, out_of_range, ios_base::failure, logic_error);
170 
176  static polito_EXPORT bool checkEqualityOfVertices(const boost::shared_ptr<Polytope_Rn>& A,
177  const boost::shared_ptr<Polytope_Rn>& B)
178  throw (invalid_argument, out_of_range, ios_base::failure, logic_error);
179 
183  static polito_EXPORT int checkTopologyAndGeometry(const boost::shared_ptr<PolyhedralCone_Rn>& A);
184 
189  static polito_EXPORT int makeCube(boost::shared_ptr<Polytope_Rn>& A, double M);
190 
196  static polito_EXPORT int makeBox(boost::shared_ptr<Polytope_Rn>& A, Point_Rn Pmin, Point_Rn Pmax);
197 
202  static polito_EXPORT int PolarPolytope(const boost::shared_ptr<Polytope_Rn>& original_pol, boost::shared_ptr<Polytope_Rn>& polar_pol);
203 
208  static polito_EXPORT int Translate(boost::shared_ptr<Polytope_Rn>& pol, const boost::numeric::ublas::vector<double>& v2t);
209 
213  static polito_EXPORT double computeVolume(const boost::shared_ptr<Polytope_Rn> P)
214  throw (invalid_argument, out_of_range, ios_base::failure);
215 
221  static polito_EXPORT int pseudoIntersection(
222  const boost::shared_ptr<Polytope_Rn>& A,
223  const boost::shared_ptr<Polytope_Rn>& B,
224  boost::shared_ptr<Polytope_Rn>& C,
225  const std::set< unsigned int >& firstOperandCaps,
226  const std::set< unsigned int >& secondOperandCaps,
227  std::set< unsigned int >& newCaps,
228  double bb_size=1000.) throw (invalid_argument,out_of_range,ios_base::failure,logic_error);
229 
235  static polito_EXPORT int pseudoSum(
236  const boost::shared_ptr<Polytope_Rn>& A,
237  const boost::shared_ptr<Polytope_Rn>& B,
238  boost::shared_ptr<Polytope_Rn>& C,
239  const std::set< unsigned int >& firstOperandCaps,
240  const std::set< unsigned int >& secondOperandCaps,
241  std::set< unsigned int >& newCaps,
242  double bb_size=1000.) throw (invalid_argument,out_of_range,ios_base::failure,logic_error);
243 
250  static polito_EXPORT int computeVoronoiDiagram(
251  const boost::shared_ptr<Polytope_Rn>& inputSpace,
252  const std::vector<Point_Rn>& listOfSeeds,
253  std::vector< boost::shared_ptr<Polytope_Rn> >& VoronoiCells,
254  Voronoi_Rn::TypeOfAlgorithm vorAlgo=Voronoi_Rn::Incremental) throw (std::invalid_argument);
255 
256 
257 };
258 
259 #endif // INC_polAPI
Creation of a n-coordinate geometric point designed to be shared by its neighbour faces...
Definition: Point_Rn.h:34
The main class to run the basic API.
Definition: politopixAPI.h:43
#define polito_EXPORT
Definition: polito_Export.h:15
TypeOfAlgorithm
Choose the kind of algorithm to be run.
Definition: Voronoi_Rn.h:44