The Fib multimedia system
Fib is a system for storing multimedia data (like images or films).
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cHyperplaneBody.h
Go to the documentation of this file.
1 /**
2  * @file cHyperplaneBody
3  * file name: cHyperplaneBody.h
4  * @author Betti Oesterholz
5  * @date 28.01.2011
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This header specifies a class for a body with hyperplanes as its borders.
11  * @pattern strategy
12  *
13  * Copyright (C) @c GPL3 2010 Betti Oesterholz
14  *
15  * This program is free software: you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License (GPL) as
17  * published by the Free Software Foundation, either version 3 of the
18  * License, or any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU Lesser General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program. If not, see <http://www.gnu.org/licenses/>.
27  *
28  *
29  * This header specifies a class for a body with hyperplanes as its borders.
30  * This body is defined by inequiations, all points wich fulfill the
31  * inequiations are part of the body.
32  *
33  * Beware of the curse of dimensions! The complexity of the body will
34  * grow exponential with the number of dimensions. For example, just the
35  * number of border points of a newly created body will be 2^uiDimensions .
36  *
37  * @see cHyperplane
38  * @see cInequation
39  */
40 /*
41 History:
42 28.01.2011 Oesterholz created
43 27.02.2011 Oesterholz method getNumberOfBorderPoints() added
44 03.04.2011 Oesterholz reimplemented with optimized algorithm
45 */
46 
47 #ifndef ___C_HYPERPLANE_BODY_H__
48 #define ___C_HYPERPLANE_BODY_H__
49 
50 
51 #include "version.h"
52 
53 #include "cHyperplane.h"
54 #include "cInequation.h"
55 
56 #include <vector>
57 #include <set>
58 #include <list>
59 #include <ostream>
60 
61 
62 
63 using namespace std;
64 using namespace fib::algorithms::nLinearInequation;
65 
66 
67 namespace fib{
68 
69 namespace algorithms{
70 
71 namespace nDn{
72 
73 
74 template <class tFactors>
76 protected:
77 
78  /**
79  * the dimensions of the space for the hyperbody;
80  * all added inequiations should have this much factors
81  *
82  * Beware of the curse of dimensions! The complexity of the body will
83  * grow exponential with the number of dimensions. For example, just the
84  * number of border points of a newly created body will be 2^uiDimensions .
85  */
86  const unsigned int uiDimensions;
87 
88 public:
89  /**
90  * standard constructor
91  *
92  * @param uiInDimensions the dimensions of the space for the hyperbody;
93  * all added inequiations should have this much factors
94  * @see uiDimensions
95  */
96  cHyperplaneBody( unsigned int uiInDimensions );
97 
98 
99  /**
100  * standard destructor
101  */
102  virtual ~cHyperplaneBody();
103 
104  /**
105  * With this method the hyperplane body can be restricted by the given
106  * inequiation, if the inequiation dosn't remove the body.
107  * If ther are points in this hyperplane body exists wich fulfill the
108  * inequiation, an hyperplane for the inequiation is created and added
109  * to this hyperplane body.
110  *
111  * @see addInequiations()
112  * @see cInequation
113  * @see cInequation::cHyperplane( const cInequation & inequation )
114  *
115  * @return if true this body was restricted by the given inequiation,
116  * else the inequiation would remove this body
117  */
118  virtual bool addInequiation( const cInequation< tFactors > & inequiation ) = 0;
119 
120  /**
121  * The inequiations of the given list of inequiations are added with
122  * @see addInequiation() till this method returns false or all
123  * inequiations are added.
124  * @see addInequiation()
125  * @see cInequation
126  *
127  * @return the number of inequiations added to this body, befor a
128  * inequiation (vecInequiation[ return - 1 ]) would remove this body
129  */
130  unsigned long addInequiations( const vector< cInequation< tFactors > > &
131  vecInequiations );
132 
133  /**
134  * @return the number of the dimensions for the hyperplane body
135  */
136  unsigned int getDimensions() const;
137 
138  /**
139  * @return the number of border points of the body
140  */
141  virtual unsigned long getNumberOfBorderPoints() const = 0;
142 
143  /**
144  * @return a vector with the border points of the body
145  */
146  virtual vector< vector< tFactors > > getBorderPoints() const = 0;
147 
148  /**
149  * This method checks if the given point is part of the hyperbody.
150  * If the point is on one of the borders of the hyperbody or inside it,
151  * it is part of the hyperbody.
152  *
153  * @param vecPoint the point to check
154  * @return true if the point vecPoint is part of the hyperbody, else false
155  */
156  virtual bool isPart( const vector< tFactors > & vecPoint ) const = 0;
157 
158  /**
159  * This method evalues a point in the body.
160  * This point will have:
161  * - as much as possible of its last elements set to 0
162  *
163  * @param uiMinBitsToStoreMantissa the minimal number of bits to store
164  * the mantissa of a vector element, when the element is in the
165  * form: mantissa * 2^exponent ;
166  * the method will try to reduce the bits, to store a element of the
167  * returned vector, to this value;
168  * if uiMinBitsToStoreMantissa is 0 the center points will be returned
169  * directly and no bits will be reduced
170  * @return a point in the body
171  */
172  vector< tFactors > getPointInBody(
173  const unsigned int uiMinBitsToStoreMantissa = 1 ) const;
174 
175 
176  /**
177  * This method print the hyperplane in a readebel form to the given
178  * output stream outputSream.
179  *
180  * @param outputSream the stream wher to print this inequation to
181  */
182  virtual void print( ostream & outputStream ) const = 0;
183 
184  /**
185  * This method duplicates this whole hyperplane body.
186  *
187  * @return the cloned/ duplicates hyperplane body
188  */
189  virtual cHyperplaneBody< tFactors > * clone() const = 0;
190 
191 };
192 
193 
194 };//end namespace nDn
195 };//end namespace algorithms
196 };//end namespace fib
197 
198 //include template implementation
199 #include "../src/cHyperplaneBody.cpp"
200 
201 
202 #endif //___C_HYPERPLANE_BODY_H__