00001 #ifndef BIVARIATE_POLYNOMIAL_H 00002 #define BIVARIATE_POLYNOMIAL_H 00003 00004 #include <fstream> 00005 #include <iostream> 00006 00007 namespace pcl { 00008 00011 template<typename real> 00012 class BivariatePolynomialT { 00013 00014 public: 00015 //-----CONSTRUCTOR&DESTRUCTOR----- 00017 BivariatePolynomialT (int new_degree=0); 00019 BivariatePolynomialT (const BivariatePolynomialT& other); 00021 ~BivariatePolynomialT (); 00022 00023 //-----OPERATORS----- 00025 BivariatePolynomialT& 00026 operator= (const BivariatePolynomialT& other) { deepCopy (other); return *this;} 00027 00028 //-----METHODS----- 00030 void 00031 setDegree (int new_degree); 00033 unsigned int 00034 getNoOfParameters () const { return getNoOfParametersFromDegree (degree);} 00036 real 00037 getValue (real x, real y) const; 00040 void 00041 calculateGradient (bool forceRecalc=false); 00043 void 00044 getValueOfGradient (real x, real y, real& gradX, real& gradY); 00045 00048 void 00049 findCriticalPoints (std::vector<real>& x_values, std::vector<real>& y_values, std::vector<int>& types) const; 00050 00052 void 00053 writeBinary (std::ostream& os) const; 00055 void 00056 writeBinary (const char* filename) const; 00058 void 00059 readBinary (std::istream& os); 00061 void 00062 readBinary (const char* filename); 00063 00065 static unsigned int 00066 getNoOfParametersFromDegree (int n) { return ((n+2)* (n+1))/2;} 00067 //-----VARIABLES----- 00068 int degree; 00069 real* parameters; 00070 BivariatePolynomialT<real>* gradient_x, * gradient_y; 00071 00072 protected: 00073 //-----METHODS----- 00075 void 00076 memoryCleanUp (); 00078 void 00079 deepCopy (const BivariatePolynomialT<real>& other); 00080 //-----VARIABLES----- 00081 }; 00082 00083 template<typename real> 00084 std::ostream& 00085 operator<< (std::ostream& os, const BivariatePolynomialT<real>& p); 00086 00087 typedef BivariatePolynomialT<double> BivariatePolynomiald; 00088 typedef BivariatePolynomialT<float> BivariatePolynomial; 00089 00090 } // end namespace 00091 00092 #include "pcl/common/bivariate_polynomial.hpp" 00093 00094 #endif