24 #include <boost/numeric/ublas/vector.hpp>
73 static void Compute(
const boost::shared_ptr<Polytope_Rn>& A);
75 static void Compute(
const boost::shared_ptr<Polytope_Rn>& A,
FaceEnumeration& FE);
78 if (_allFacesWithVertices.empty() ==
false)
79 return _allFacesWithVertices;
80 throw std::domain_error(
"FaceEnumeration::getFacesWithVertices() empty DS allFacesWithVertices.");
83 const std::vector< std::vector< ListOfFaces > >&
getFacesWithFacets() throw (std::domain_error) {
84 if (_allFacesWithFacets.empty() ==
false)
85 return _allFacesWithFacets;
86 throw std::domain_error(
"FaceEnumeration::getFacesWithFacets() empty DS allFacesWithFacets.");
89 void clear() {_allFacesWithFacets.clear(); _allFacesWithVertices.clear();}
91 void printFacesWithVerticesToSage(std::ostream &this_ostream)
const;
93 void printFacesWithVertices(std::ostream &this_ostream)
const;
95 void printFacesWithFacets(std::ostream &this_ostream)
const;
98 static void save(
const std::string& filename,
const std::vector< std::vector< ListOfFaces > >& latt);
101 static void load(
const std::string& filename, std::vector< std::vector< ListOfFaces > >& latt)
102 throw (std::ios_base::failure);
110 static
void load(std::istream& this_stream, std::vector< std::vector<
ListOfFaces > >& latt)
111 throw (std::out_of_range);
119 static
void save(std::ostream& this_stream, const std::vector< std::vector<
ListOfFaces > >& latt);
121 void save(std::ostream& this_stream)
const {
save(this_stream, _allFacesWithVertices); }
125 static void ComputeWithFacets(
const boost::shared_ptr<Polytope_Rn>& A,
FaceEnumeration& FaceEnum);
127 static void ComputeWithVertices(
const boost::shared_ptr<Polytope_Rn>& A,
FaceEnumeration& FaceEnum);
150 const boost::shared_ptr<Polytope_Rn>& A,
151 const boost::shared_ptr<Polytope_Rn>& B):_firstOperand(A),_secondOperand(B)
156 const boost::shared_ptr<Polytope_Rn>& A,
157 const boost::shared_ptr<Polytope_Rn>& B,
158 boost::shared_ptr<Polytope_Rn>& C):_firstOperand(A),_secondOperand(B),_sum(C)
163 const std::vector< boost::shared_ptr<Polytope_Rn> >& arrayOfPolytopes,
164 boost::shared_ptr<Polytope_Rn>& C);
168 const boost::shared_ptr<Polytope_Rn>& A,
169 const boost::shared_ptr<Polytope_Rn>& B,
170 boost::shared_ptr<Polytope_Rn>& C,
171 const std::vector< std::vector<int> >& genitorsOfGeneratorsA,
172 const std::vector< std::vector<int> >& genitorsOfGeneratorsB,
173 std::vector< std::vector<int> >& traceGenerators):_firstOperand(A),_secondOperand(B),_sum(C)
176 traceGenerators.clear();
178 unsigned int countOK=0;
179 {
for (
unsigned int i=0; i<_MinkowskiDecomposition.size(); ++i) {
180 if (_MinkowskiDecompositionOK[i] ==
true) {
182 unsigned int a = _MinkowskiDecomposition[i].first;
183 unsigned int b = _MinkowskiDecomposition[i].second;
184 std::vector<int> genitorsAB;
185 genitorsAB.insert(genitorsAB.end(), genitorsOfGeneratorsA[a].begin(), genitorsOfGeneratorsA[a].end());
186 genitorsAB.insert(genitorsAB.end(), genitorsOfGeneratorsB[b].begin(), genitorsOfGeneratorsB[b].end());
187 traceGenerators.push_back(genitorsAB);
195 boost::shared_ptr<Polytope_Rn> rebuildSum(
196 const std::set< unsigned int >& firstOperandCaps,
197 const std::set< unsigned int >& secondOperandCaps,
198 std::set< unsigned int >& newCaps,
199 double bb_size=1000.);
203 boost::shared_ptr<Polytope_Rn> compute() throw (std::domain_error);
206 void computeCommonRefinement(
207 const std::vector< boost::shared_ptr<
Generator_Rn> >& listOfGenerators_A,
208 const std::vector< boost::shared_ptr<
Generator_Rn> >& listOfGenerators_B,
209 std::vector< boost::shared_ptr<
Generator_Rn> >& listOfGenerators_C,
212 std::vector< boost::shared_ptr<
PolyhedralCone_Rn> >& listOfDualCones_C) throw (std::domain_error);
215 void processNormalFan0();
218 void processNormalFan1();
221 void processNormalFan2();
224 void computeCapHalfSpaces(
225 const std::set<
unsigned int >& firstOperandCaps,
226 const std::set<
unsigned int >& secondOperandCaps,
227 std::set<
unsigned int >& sumCaps) const throw (std::domain_error);
239 std::vector< std::vector<
unsigned int> > _A2C;
241 std::vector< std::vector<
unsigned int> > _B2C;
245 std::vector< std::vector<
unsigned int> > _neighboursA;
248 std::vector< std::vector<
unsigned int> > _neighboursB;
255 std::vector< std::pair<
unsigned int,
unsigned int > > _MinkowskiDecomposition;
257 std::vector<
bool > _MinkowskiDecompositionOK;
275 const boost::shared_ptr<Polytope_Rn>& A,
276 const boost::shared_ptr<Polytope_Rn>& B,
277 boost::shared_ptr<Polytope_Rn>& C,
278 const std::set< unsigned int >& firstOperandCaps,
279 const std::set< unsigned int >& secondOperandCaps,
280 std::set< unsigned int >& newCaps,
281 double bb_size=1000.):MinkowskiSum(A,B,C)
282 { C = rebuildSum(firstOperandCaps, secondOperandCaps, newCaps, bb_size); }
289 boost::shared_ptr<Polytope_Rn> rebuildSum(
290 const std::set< unsigned int >& firstOperandCaps,
291 const std::set< unsigned int >& secondOperandCaps,
292 std::set< unsigned int >& newCaps,
293 double bb_size=1000.);
296 void computeCapHalfSpaces(
297 const std::set< unsigned int >& firstOperandCaps,
298 const std::set< unsigned int >& secondOperandCaps,
299 std::set< unsigned int >& sumCaps)
throw (std::domain_error);
312 const boost::shared_ptr<Polytope_Rn>& A,
313 const boost::shared_ptr<Polytope_Rn>& B,
314 boost::shared_ptr<Polytope_Rn>& C,
315 const std::set< unsigned int >& firstOperandCaps,
316 const std::set< unsigned int >& secondOperandCaps,
317 std::set< unsigned int >& newCaps,
318 double bb_size=1000.);
333 static int Translate(boost::shared_ptr<Polytope_Rn>& pol,
const boost::numeric::ublas::vector<double>& v2t);
339 static int GravityCenter(boost::shared_ptr<Polytope_Rn>& pol, boost::numeric::ublas::vector<double>& gravity_center);
345 static int scalingFactor(boost::shared_ptr<Polytope_Rn>& pol,
double factor);
351 static int PolarPolytope(
352 const boost::shared_ptr<Polytope_Rn>& original_pol,
353 boost::shared_ptr<Polytope_Rn>& polar_pol,
354 bool forceComputation =
true,
double bb_size=1000.)
throw (invalid_argument);
361 static int projectPolytopeOnCanonicalHyperplanes(
362 const std::set< unsigned int >& listOfHyperplanes,
363 const boost::shared_ptr<Polytope_Rn>& original_pol,
364 boost::shared_ptr<Polytope_Rn>& proj_pol)
throw (invalid_argument);
371 static int extrudeInCanonicalDirections(
372 const std::set< unsigned int >& originalSpaceDirections,
373 unsigned int dimensionOfTotalSpace,
374 const boost::shared_ptr<Polytope_Rn>& original_polytope,
375 boost::shared_ptr<PolyhedralCone_Rn>& extruded_polyhedron)
throw (invalid_argument);
389 static int Compute(boost::shared_ptr<Polytope_Rn>& pol,
double bb_size=1000.)
390 throw (invalid_argument, out_of_range, ios_base::failure, logic_error);
405 static void gnuplot2D(
const boost::shared_ptr<Polytope_Rn>& polygon,
const std::string& name,
double col, std::ostream& out)
throw (std::domain_error);
409 #endif // INC_POLY_ALGO
MinkowskiSum(const boost::shared_ptr< Polytope_Rn > &A, const boost::shared_ptr< Polytope_Rn > &B, boost::shared_ptr< Polytope_Rn > &C, const std::vector< std::vector< int > > &genitorsOfGeneratorsA, const std::vector< std::vector< int > > &genitorsOfGeneratorsB, std::vector< std::vector< int > > &traceGenerators)
Compute the Minkowski sum of two polytopes.
MinkowskiSum(const boost::shared_ptr< Polytope_Rn > &A, const boost::shared_ptr< Polytope_Rn > &B)
Sets up the data structure for the computation of the Minkowski sum of two polytopes.
PseudoSumWithoutCaps(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 std::vector< std::vector< ListOfFaces > > & getFacesWithFacets()
Compute the Minkowski sum of two polytopes and then remove all cap half-spaces to truncate again...
MinkowskiSum()
Sets up the data structure for the computation of the Minkowski sum of two polytopes.
Model a polytope using its two equivalent definitions : the convex hull and the half-space intersecti...
std::vector< std::vector< ListOfFaces > > _allFacesWithFacets
Model a polyhedral cone using its two equivalent definitions : the convex hull and the half-space int...
Compute the Minkowski sum of two polytopes.
std::vector< std::vector< ListOfFaces > > _allFacesWithVertices
Remove all cap half-spaces and then compute the intersection of two capped polytopes.
std::vector< unsigned int > ListOfFaces
Compute the V-description from the H-description.
const boost::shared_ptr< Polytope_Rn > & _polytope
Combinatorial face enumeration for polytopes.
FaceEnumeration(const boost::shared_ptr< Polytope_Rn > &A)
General Face Enumeration Algorithm.
A n-coordinates generator, which can be a vertex or an edge whether it is contained by a polytope or ...
const std::vector< std::vector< ListOfFaces > > & getFacesWithVertices()
MinkowskiSum(const boost::shared_ptr< Polytope_Rn > &A, const boost::shared_ptr< Polytope_Rn > &B, boost::shared_ptr< Polytope_Rn > &C)
Compute the Minkowski sum of two polytopes.
void save(std::ostream &this_stream) const