32 boost::shared_ptr<PolyhedralCone_Rn> primalCone;
33 for (
unsigned int u=0; u<A->numberOfGenerators(); u++) {
34 boost::shared_ptr<Generator_Rn> vx1 = A->getGenerator(u);
40 for (
unsigned int i=0; i<vx1->numberOfFacets(); i++)
41 primalCone->addHalfSpace(vx1->getFacet(i));
45 boost::shared_ptr<PolyhedralCone_Rn> dualCone = primalCone->computeDualPolyhedralCone();
75 const std::vector< boost::shared_ptr<HalfSpace_Rn> >& allHS,
76 boost::shared_ptr<Polytope_Rn>& Pol) {
81 std::vector< double > arrayOfNorms(allHS.size());
82 std::vector< boost::shared_ptr<HalfSpace_Rn> >::const_iterator iteHS;
84 {
for (iteHS = allHS.begin(), hs=0; iteHS!=allHS.end(); ++iteHS, ++hs) {
85 double halfSpaceNorm = std::inner_product((*iteHS)->begin(), (*iteHS)->end(), (*iteHS)->begin(), 0.);
86 arrayOfNorms[hs] = sqrt(halfSpaceNorm);
88 unsigned int cone = 0;
89 std::vector< boost::shared_ptr<PolyhedralCone_Rn> >::iterator itePC;
95 std::vector< bool > arrayOfEgdesOKforHS(allHS.size());
96 {
for (
unsigned int i=0; i<arrayOfEgdesOKforHS.size(); ++i)
97 arrayOfEgdesOKforHS[i] =
false;
99 bool coneOKforHS =
true;
100 {
for (iteHS = allHS.begin(), hs=0; iteHS!=allHS.end() && coneOKforHS==
true; ++iteHS, ++hs) {
101 unsigned int countON = 0;
102 bool IN =
false, OUT =
false;
104 double scalarProduct = std::inner_product(iteGN.
current()->begin(), iteGN.
current()->end(), (*iteHS)->begin(), 0.);
105 double distanceToHyperplane = scalarProduct / arrayOfNorms[hs];
121 if (distanceToHyperplane > TOL) {
129 else if (distanceToHyperplane < -TOL) {
146 if ((IN==
true && OUT==
true) || (countON>=1))
147 arrayOfEgdesOKforHS[hs] =
true;
154 {
for (
unsigned int i=0; i<arrayOfEgdesOKforHS.size(); ++i) {
157 if (arrayOfEgdesOKforHS[i] ==
false)
176 std::cout << std::endl <<
"NormalFan_Rn::computeCommonRefinement()" << std::endl;
179 unsigned int currentCone1Nb=0,currentCone2Nb=0;
184 std::vector< boost::shared_ptr<Generator_Rn> >::const_iterator LVX1=NF1.
getListOfGenerators().begin();
185 std::vector< boost::shared_ptr<Generator_Rn> >::const_iterator LVX2=NF2.
getListOfGenerators().begin();
186 {
for (; LPC1!=endLPC1; ++LPC1, ++LVX1) {
187 {
for (; LPC2!=endLPC2; ++LPC2, ++LVX2) {
189 boost::shared_ptr<PolyhedralCone_Rn> Ca = *LPC1;
190 boost::shared_ptr<PolyhedralCone_Rn> Cb = *LPC2;
193 {
for (iteGNA.begin(); iteGNA.end()!=
true; iteGNA.next()) {
195 boost::shared_ptr<Generator_Rn> gn(
new Generator_Rn( *(iteGNA.current()) ));
196 intersectionCone->addGenerator(gn);
199 for (iteHSB.begin(); iteHSB.end()!=
true; iteHSB.next())
200 intersectionCone->addHalfSpace(iteHSB.current());
202 std::cout <<
"=== Cone from A number " << currentCone1Nb << std::endl;
203 std::cout <<
"=== Cone from B number " << currentCone2Nb << std::endl;
211 bool notEmpty = !DD.getIsEmpty();
213 std::cout <<
"@@@ nbEDG=" << intersectionCone->numberOfGenerators() <<
"( ";
216 if (notEmpty ==
true && intersectionCone->numberOfGenerators() >= RnDIM) {
218 boost::shared_ptr<Generator_Rn> VX(
new Generator_Rn(RnDIM));
219 VX->makeSum((*LVX1),(*LVX2));
221 for (
unsigned int k=0; k<RnDIM; ++k)
222 std::cout << (*LVX1)->getCoordinate(k) <<
"+" << (*LVX2)->getCoordinate(k) <<
"=" << VX->getCoordinate(k) <<
"\t";
227 const std::vector< std::pair< StatusAfter, int > >& res = trackerVdesc.
getResultToOperator();
228 std::vector< std::pair< StatusAfter, int > >::const_iterator iteGN_INTER=res.begin();
229 unsigned int counterV=0;
232 {
for ( ; iteGN_INTER!=res.end(); ++iteGN_INTER) {
234 Ca->addGenerator(intersectionCone->getGenerator(counterV));
237 int nbModGEN = iteGN_INTER->second;
239 std::set< boost::shared_ptr<HalfSpace_Rn> > setOfFacets1,setOfFacets2;
240 Ca->getGenerator(nbModGEN)->exportFacets(setOfFacets1);
241 intersectionCone->getGenerator(counterV)->exportFacets(setOfFacets2);
242 setOfFacets1.insert(setOfFacets2.begin(), setOfFacets2.end());
243 Ca->getGenerator(nbModGEN)->clearFacets();
244 Ca->getGenerator(nbModGEN)->importFacets(setOfFacets1);
248 const std::vector< std::pair< StatusAfter, int > >& resH = trackerHdesc.
getResultToOperator();
249 std::vector< std::pair< StatusAfter, int > >::const_iterator iteHS_INTER=resH.begin();
250 unsigned int counterH=0;
252 {
for ( ; iteHS_INTER!=res.end(); ++iteHS_INTER) {
254 Ca->addHalfSpace(intersectionCone->getHalfSpace(counterH));
260 std::cout <<
")" << std::endl;
270 out << std::endl <<
"#NORMAL FAN" << std::endl;
272 std::vector< boost::shared_ptr<Generator_Rn> >::const_iterator iteVX=
_listOfVertices.begin();
275 out <<
"#" << nb << std::endl;
278 out << (*iteVX)->getCoordinate(k) <<
" ";
279 out <<
")" << std::endl;
280 (*itePC)->dump(std::cout);
void computeCommonRefinement(const NormalFan_Rn &NA, const NormalFan_Rn &NB)
Compute .
Model a polyhedral cone using its two equivalent definitions : the convex hull and the half-space int...
const std::vector< std::pair< StatusAfter, int > > & getResultToOperator() const
const GEOMETRIC_OBJECT current()
Return the current geometric element.
void begin()
Move the iterator at the beginning of the list.
std::vector< boost::shared_ptr< PolyhedralCone_Rn > > _listOfPolyhedralCones
The list of polyhedral cones partitioning the whole space.
static polito_EXPORT void setTolerance(double t)
Give the minimum distance between two points.
static polito_EXPORT double getTolerance()
Give the minimum distance between two points.
bool end() const
Tell whether we have reached the end of the list.
This class stores static function that dispatch the main geometric values we use. ...
const std::vector< boost::shared_ptr< PolyhedralCone_Rn > > & getListOfPolyhedralCones() const
static polito_EXPORT unsigned int getDimension()
Return the dimension of the cartesian space we work in.
This class can be more time-consuming than WeakRedundancyProcessing or NoRedundancyProcessing because...
const std::vector< boost::shared_ptr< Generator_Rn > > & getListOfGenerators() const
std::vector< boost::shared_ptr< Generator_Rn > > _listOfVertices
The list of vertices attached to their respective dual polyhedral cones.
A n-coordinates generator, which can be a vertex or an edge whether it is contained by a polytope or ...
This class is designed to run the list of all geometric objects representing a polytope.
void next()
Move the iterator one step forward.
This class is designed to contain the list of all generators or half-spaces representing a polytope o...
bool checkTopologyAndGeometry() const
void dump(std::ostream &out) const
Dump the polyhedral structure on std::cout.
NormalFan_Rn()
Constructor.
void computeHyperplanesSeparationForProjection(const std::vector< boost::shared_ptr< HalfSpace_Rn > > &, boost::shared_ptr< Polytope_Rn > &)
The algorithm implemented here is an incremental algorithm as mentioned in How Good are Convex Hull ...