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.");
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);
109 static void load(std::istream& this_stream, std::vector< std::vector< ListOfFaces > >& latt);
117 static void save(std::ostream& this_stream,
const std::vector< std::vector< ListOfFaces > >& latt);
119 void save(std::ostream& this_stream)
const {
save(this_stream, _allFacesWithVertices); }
123 static void ComputeWithFacets(
const boost::shared_ptr<Polytope_Rn>& A,
FaceEnumeration& FaceEnum);
125 static void ComputeWithVertices(
const boost::shared_ptr<Polytope_Rn>& A,
FaceEnumeration& FaceEnum);
148 const boost::shared_ptr<Polytope_Rn>& A,
149 const boost::shared_ptr<Polytope_Rn>& B):_firstOperand(A),_secondOperand(B)
154 const boost::shared_ptr<Polytope_Rn>& A,
155 const boost::shared_ptr<Polytope_Rn>& B,
156 boost::shared_ptr<Polytope_Rn>& C):_firstOperand(A),_secondOperand(B),_sum(C)
161 const std::vector< boost::shared_ptr<Polytope_Rn> >& arrayOfPolytopes,
162 boost::shared_ptr<Polytope_Rn>& C);
166 const boost::shared_ptr<Polytope_Rn>& A,
167 const boost::shared_ptr<Polytope_Rn>& B,
168 boost::shared_ptr<Polytope_Rn>& C,
169 const std::vector< std::vector<int> >& genitorsOfGeneratorsA,
170 const std::vector< std::vector<int> >& genitorsOfGeneratorsB,
171 std::vector< std::vector<int> >& traceGenerators):_firstOperand(A),_secondOperand(B),_sum(C)
174 traceGenerators.clear();
176 unsigned int countOK=0;
177 {
for (
unsigned int i=0; i<_MinkowskiDecomposition.size(); ++i) {
178 if (_MinkowskiDecompositionOK[i] ==
true) {
180 unsigned int a = _MinkowskiDecomposition[i].first;
181 unsigned int b = _MinkowskiDecomposition[i].second;
182 std::vector<int> genitorsAB;
183 genitorsAB.insert(genitorsAB.end(), genitorsOfGeneratorsA[a].begin(), genitorsOfGeneratorsA[a].end());
184 genitorsAB.insert(genitorsAB.end(), genitorsOfGeneratorsB[b].begin(), genitorsOfGeneratorsB[b].end());
185 traceGenerators.push_back(genitorsAB);
193 boost::shared_ptr<Polytope_Rn> rebuildSum(
194 const std::set< unsigned int >& firstOperandCaps,
195 const std::set< unsigned int >& secondOperandCaps,
196 std::set< unsigned int >& newCaps,
197 double bb_size=1000.);
201 boost::shared_ptr<Polytope_Rn> compute();
204 void computeCommonRefinement(
205 const std::vector< boost::shared_ptr<Generator_Rn> >& listOfGenerators_A,
206 const std::vector< boost::shared_ptr<Generator_Rn> >& listOfGenerators_B,
207 std::vector< boost::shared_ptr<Generator_Rn> >& listOfGenerators_C,
208 const std::vector< boost::shared_ptr<PolyhedralCone_Rn> >& listOfDualCones_A,
209 const std::vector< boost::shared_ptr<PolyhedralCone_Rn> >& listOfDualCones_B,
210 std::vector< boost::shared_ptr<PolyhedralCone_Rn> >& listOfDualCones_C);
213 void processNormalFan0();
216 void processNormalFan1();
219 void processNormalFan2();
222 void computeCapHalfSpaces(
223 const std::set< unsigned int >& firstOperandCaps,
224 const std::set< unsigned int >& secondOperandCaps,
225 std::set< unsigned int >& sumCaps)
const;
230 boost::shared_ptr<Polytope_Rn>
_sum;
237 std::vector< std::vector<unsigned int> >
_A2C;
239 std::vector< std::vector<unsigned int> >
_B2C;
258 std::vector< boost::shared_ptr<PolyhedralCone_Rn> >
_NF_Cones;
273 const boost::shared_ptr<Polytope_Rn>& A,
274 const boost::shared_ptr<Polytope_Rn>& B,
275 boost::shared_ptr<Polytope_Rn>& C,
276 const std::set< unsigned int >& firstOperandCaps,
277 const std::set< unsigned int >& secondOperandCaps,
278 std::set< unsigned int >& newCaps,
280 { C = rebuildSum(firstOperandCaps, secondOperandCaps, newCaps, bb_size); }
287 boost::shared_ptr<Polytope_Rn> rebuildSum(
288 const std::set< unsigned int >& firstOperandCaps,
289 const std::set< unsigned int >& secondOperandCaps,
290 std::set< unsigned int >& newCaps,
291 double bb_size=1000.);
294 void computeCapHalfSpaces(
295 const std::set< unsigned int >& firstOperandCaps,
296 const std::set< unsigned int >& secondOperandCaps,
297 std::set< unsigned int >& sumCaps);
310 const boost::shared_ptr<Polytope_Rn>& A,
311 const boost::shared_ptr<Polytope_Rn>& B,
312 boost::shared_ptr<Polytope_Rn>& C,
313 const std::set< unsigned int >& firstOperandCaps,
314 const std::set< unsigned int >& secondOperandCaps,
315 std::set< unsigned int >& newCaps,
316 double bb_size=1000.);
331 static int Translate(boost::shared_ptr<Polytope_Rn>& pol,
const boost::numeric::ublas::vector<double>& v2t);
337 static int GravityCenter(boost::shared_ptr<Polytope_Rn>& pol, boost::numeric::ublas::vector<double>& gravity_center);
344 static int computeScalingFactorForInclusion(boost::shared_ptr<Polytope_Rn>& pol1, boost::shared_ptr<Polytope_Rn>& pol2,
double& sfactor);
350 static int scalingFactor(boost::shared_ptr<Polytope_Rn>& pol,
double sfactor);
356 static int scalingFactor(boost::shared_ptr<PolyhedralCone_Rn>& pol,
double sfactor);
362 static int PolarPolytope(
363 const boost::shared_ptr<Polytope_Rn>& original_pol,
364 boost::shared_ptr<Polytope_Rn>& polar_pol,
365 bool forceComputation =
true,
double bb_size=1000.);
372 static int projectPolytopeOnCanonicalHyperplanes(
373 const std::set< unsigned int >& listOfHyperplanes,
374 const boost::shared_ptr<Polytope_Rn>& original_pol,
375 boost::shared_ptr<Polytope_Rn>& proj_pol);
382 static int extrudeInCanonicalDirections(
383 const std::set< unsigned int >& originalSpaceDirections,
384 unsigned int dimensionOfTotalSpace,
385 const boost::shared_ptr<Polytope_Rn>& original_polytope,
386 boost::shared_ptr<PolyhedralCone_Rn>& extruded_polyhedron);
400 static int Compute(boost::shared_ptr<Polytope_Rn>& pol,
double bb_size=1000.);
410 NormedHS(
const boost::numeric::ublas::vector<double>& nv,
double cst,
unsigned int nb) {
411 _currentNormedVector = nv;
413 _numberOfNormedHS = nb;
416 const boost::numeric::ublas::vector<double>&
getNormedVector()
const {
return _currentNormedVector;}
422 void dump(std::ostream &this_ostream)
const {
423 this_ostream <<
"{" << _numberOfNormedHS <<
": " << _constant <<
" " << _currentNormedVector <<
"}" << std::endl;
441 void dump(std::ostream &this_ostream,
const std::vector< std::pair<double, NormedHS > >& listOfNormedVectors)
const {
442 std::vector< std::pair<double, NormedHS > >::const_iterator iteV = listOfNormedVectors.begin();
443 for (; iteV != listOfNormedVectors.end(); ++iteV) {
444 this_ostream << iteV->first <<
" ";
445 iteV->second.dump(this_ostream);
462 static void gnuplot2D(
const boost::shared_ptr<Polytope_Rn>& polygon,
const std::string& name,
double col, std::ostream& out);
466 #endif // INC_POLY_ALGO