politopix  5.0.0
HalfSpace_Rn.cpp
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) 2011-2019 : Delos Vincent
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU 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 General Public License for more details.
13 //
14 // You should have received a copy of the GNU 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 #include <iostream>
22 #include <sstream>
23 #include <string>
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include "Point_Rn.h"
27 #include "HalfSpace_Rn.h"
28 #include "Generator_Rn.h"
29 
30 HalfSpace_Rn::HalfSpace_Rn(unsigned int n):_coefficients(n),_constant(0.) {
31 }
32 
33 double HalfSpace_Rn::getCoefficient(unsigned int i) const {
34  if (i < _coefficients.size()) {
35  return _coefficients[i];
36  }
37  else {
38  std::string newErrorMessage = Point_Rn::concatStrings(i, "HalfSpace_Rn::getCoefficient");
39  newErrorMessage += "\n";
40  throw std::out_of_range(newErrorMessage);
41  }
42 }
43 
44 void HalfSpace_Rn::setCoefficient(unsigned int i, double c) {
45  if (i < _coefficients.size()) {
46  _coefficients[i] = c;
47  }
48  else {
49  std::string newErrorMessage = Point_Rn::concatStrings(i, "HalfSpace_Rn::setCoefficient");
50  newErrorMessage += "\n";
51  throw std::out_of_range(newErrorMessage);
52  }
53 }
54 
56  if (state == HalfSpace_Rn::hs_ON)
57  return std::string("ON");
58  if (state == HalfSpace_Rn::hs_OUT)
59  return std::string("OUT");
60  if (state == HalfSpace_Rn::hs_IN)
61  return std::string("IN");
62  if (state == HalfSpace_Rn::hs_IN_OR_OUT)
63  return std::string("IN_OR_OUT");
64  if (state == HalfSpace_Rn::hs_OUT_TO_ON)
65  return std::string("OUT_TO_ON");
66  return std::string("UNKNOWN");
67 }
68 
69 // void Hyperplane_Rn::noGeneratorsOUT(std::vector< Segment_Rn >& allNeighbours) {
70 // //std::cout << "Flat DD" << std::endl;
71 // std::vector< std::vector< std::pair< Generator_Rn_SD, Generator_Rn_SD > >::iterator > arrayOfIteratorsToErase;
72 // {
73 // std::vector< std::pair< Generator_Rn_SD, Generator_Rn_SD > >::iterator pairOfNeighbours = allNeighbours.begin();
74 // for (; pairOfNeighbours != allNeighbours.end(); ++pairOfNeighbours) {
75 // if (pairOfNeighbours->getFirstGenerator()->getState() != hs_ON && pairOfNeighbours->getSecondGenerator()->getState() != hs_ON)
76 // arrayOfIteratorsToErase.push_back( pairOfNeighbours );
77 // }
78 // }
79 // for (auto it : arrayOfIteratorsToErase)
80 // arrayOfIteratorsToErase.erase( *it );
81 // }
82 
HalfSpace_Rn::hs_OUT
@ hs_OUT
Definition: HalfSpace_Rn.h:47
HalfSpace_Rn::getCoefficient
double getCoefficient(unsigned int i) const
Definition: HalfSpace_Rn.cpp:33
HalfSpace_Rn::hs_IN
@ hs_IN
Definition: HalfSpace_Rn.h:46
HalfSpace_Rn::hs_IN_OR_OUT
@ hs_IN_OR_OUT
Definition: HalfSpace_Rn.h:49
HalfSpace_Rn::HalfSpace_Rn
HalfSpace_Rn()
Constructor.
Definition: HalfSpace_Rn.h:53
HalfSpace_Rn::setCoefficient
void setCoefficient(unsigned int i, double c)
Definition: HalfSpace_Rn.cpp:44
Point_Rn.h
HalfSpace_Rn::_coefficients
boost::numeric::ublas::vector< double > _coefficients
The normal vector.
Definition: HalfSpace_Rn.h:165
Generator_Rn.h
HalfSpace_Rn::getStateAsText
static std::string getStateAsText(const HalfSpace_Rn::State &)
Definition: HalfSpace_Rn.cpp:55
HalfSpace_Rn::State
State
Definition: HalfSpace_Rn.h:44
Point_Rn::concatStrings
static std::string concatStrings(int i, const std::string &functionName)
Useful function to provide error message to the exception mechanism.
Definition: Point_Rn.cpp:79
HalfSpace_Rn::hs_ON
@ hs_ON
Definition: HalfSpace_Rn.h:45
HalfSpace_Rn::hs_OUT_TO_ON
@ hs_OUT_TO_ON
Definition: HalfSpace_Rn.h:50
HalfSpace_Rn.h