politopix  4.1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Generator_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-2015 : 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 #include <iostream>
22 #include <sstream>
23 #include <string>
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include "Generator_Rn.h"
27 
28 Generator_Rn::Generator_Rn(unsigned int n) {
29  _coordinates.resize(n);
30 }
31 
33 }
34 
35 void Generator_Rn::removeFacet(unsigned int j) throw (std::out_of_range,std::domain_error) {
36  if (numberOfFacets() == 0) {
37  std::string errorMessage("List of neighbour vertices not allocated in Generator_Rn::removeNeighbourVertex");
38  throw std::domain_error(errorMessage);
39  }
40  else if (j >= numberOfFacets()) {
41  std::string errorMessage = Point_Rn::concatStrings(j, "Generator_Rn::removeNeighbourVertex");
42  throw std::out_of_range(errorMessage);
43  }
44  std::vector< boost::shared_ptr<HalfSpace_Rn> >::iterator itRemove = _supportFacets.begin() + j;
45  // Now, actually remove this element from the array
46  _supportFacets.erase(itRemove);
47 
48 }
49 
50 bool Generator_Rn::isFacetInside(boost::shared_ptr<HalfSpace_Rn> F) const {
51  std::vector< boost::shared_ptr<HalfSpace_Rn> >::const_iterator it = _supportFacets.begin();
52  {for (; it!=_supportFacets.end(); ++it) {
53  if (*it == F)
54  return true;
55  }}
56  return false;
57 }
std::vector< boost::shared_ptr< HalfSpace_Rn > > _supportFacets
Contain the list of all support facets.
Definition: Generator_Rn.h:218
bool isFacetInside(boost::shared_ptr< HalfSpace_Rn > F) const
Check whether the given half-space is inside the generator's list.
void removeFacet(unsigned int i)
Remove the i-th facet in list.
Generator_Rn(unsigned int n)
Creates a n-coordinates generator.
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
~Generator_Rn()
Destructor.
vector< double > _coordinates
The set of coordinates.
Definition: Generator_Rn.h:216