NLToolbox
src/include/Hpolyhedron.h
00001 /*
00002  * Hpolyhedron.h
00003  *
00004  *  Created on: Nov 20, 2012
00005  *      Author: romain
00006  */
00007 
00008 #ifndef HPOLYHEDRON_H_
00009 #define HPOLYHEDRON_H_
00010 
00011 #include "Set.h"
00012 #include "utils.h"
00013 #include "Box.h"
00014 #include "Simplex.h"
00015 
00016 namespace nltool {
00017 
00018 class Hpolyhedron: public Set {
00019 public:
00023         Hpolyhedron();
00024 
00033         Hpolyhedron(int dim, Template& mat, Vector& vec);
00034 
00035         Hpolyhedron(int dim, Template& mat, Vector& vec, Box& box);
00036 
00041         Hpolyhedron(Simplex& simplex);
00042 
00047         Hpolyhedron(Box& box);
00048 
00052         virtual ~Hpolyhedron();
00053 
00059         bool includes(Hpolyhedron& poly);
00060 
00064         Number optimize(const Vector & direction, Vector & optPoint,
00065                         bool max = true) {
00066                 return 0;
00067         }
00068 
00074         bool includes(Vector& point);
00075 
00080         std::vector<Hpolyhedron> split();
00081 
00086         int clean();
00087 
00094         Number support(Vector& a);
00095 
00096         /*
00097          * ##########################################
00098          * GETTTERS and SETTERS
00099          * ##########################################
00100          */
00101 
00102         Vector getCoefficients() const;
00103         Template getTemplates() const;
00104 
00105         void setCoefficients(Vector coefficients);
00106         void setTemplates(Template templates);
00107 
00108         Template getAllTemplates();
00109         Vector getAllCoefficients();
00110 
00111         Vertices getVertices();
00112 
00113         void inflate(Number inflat);
00114 
00115         const Box& getBbox() const {
00116                 return bbox;
00117         }
00118 
00119         void setBbox(const Box& bbox) {
00120                 this->bbox = bbox;
00121         }
00122 
00123 private:
00124         Template templates;
00125         Vector coefficients;
00126         Box bbox; //Optional information
00127         Vertices vertices; //Optional information
00128 };
00129 
00130 inline std::ostream& operator<<(std::ostream& out, Hpolyhedron poly) {
00131         for (unsigned int i = 0; i < poly.getTemplates().size(); i++) {
00132                 for (unsigned int j = 0; j < poly.getDimension() - 1; j++) {
00133                         out << poly.getTemplates()[i][j] << "x" << j << " + ";
00134                 }
00135                 out << poly.getTemplates()[i][poly.getDimension() - 1] << "x"
00136                                 << poly.getDimension() - 1 << " <= "
00137                                 << poly.getCoefficients()[i] << std::endl;
00138         }
00139         out << std::endl;
00140         return out;
00141 }
00142 
00143 } // namespace nltool
00144 
00145 #endif /* HPOLYHEDRON_H_ */
 All Classes Namespaces Functions