|
UniSet
1.7.0
|
00001 #ifndef Calibration_H_ 00002 #define Calibration_H_ 00003 // ----------------------------------------------------------------------------- 00004 #include <cmath> 00005 #include <string> 00006 #include <list> 00007 #include <ostream> 00008 // ----------------------------------------------------------------------------- 00024 class Calibration 00025 { 00026 public: 00027 Calibration(); 00028 Calibration( const std::string name, const std::string confile="calibration.xml" ); 00029 Calibration( xmlNode* node ); 00030 ~Calibration(); 00031 00033 static const int outOfRange=-1; 00034 00041 long getValue( long raw, bool crop_raw=false ); 00042 00044 inline long getMinVal(){ return minVal; } 00046 inline long getMaxVal(){ return maxVal; } 00047 00049 inline long getLeftVal(){ return leftVal; } 00051 inline long getRightVal(){ return rightVal; } 00052 00060 long getRawValue( long cal, bool range=false ); 00061 00063 inline long getMinRaw(){ return minRaw; } 00065 inline long getMaxRaw(){ return maxRaw; } 00066 00068 inline long getLeftRaw(){ return leftRaw; } 00070 inline long getRightRaw(){ return rightRaw; } 00071 00072 00078 void build( const std::string name, const std::string confile, xmlNode* node=0 ); 00079 00080 00082 typedef float TypeOfValue; 00083 00087 inline long tRound( const TypeOfValue& val ) 00088 { 00089 return lround(val); 00090 } 00091 00092 friend std::ostream& operator<<(std::ostream& os, Calibration& c ); 00093 friend std::ostream& operator<<(std::ostream& os, Calibration* c ); 00094 00095 protected: 00096 00098 struct Point 00099 { 00100 Point( TypeOfValue _x, TypeOfValue _y ): 00101 x(_x),y(_y){} 00102 00103 TypeOfValue x; 00104 TypeOfValue y; 00105 00106 inline bool operator < ( const Point& p ) const 00107 { 00108 return ( x < p.x ); 00109 } 00110 }; 00111 00113 class Part 00114 { 00115 public: 00116 Part( Point& pleft, Point& pright ); 00117 ~Part(){}; 00118 00120 bool check( Point& p ); 00121 00123 bool checkX( TypeOfValue x ); 00124 00126 bool checkY( TypeOfValue y ); 00127 00128 // функции могут вернуть OutOfRange 00129 TypeOfValue getY( TypeOfValue x ); 00130 TypeOfValue getX( TypeOfValue y ); 00132 TypeOfValue calcY( TypeOfValue x ); 00133 TypeOfValue calcX( TypeOfValue y ); 00135 inline bool operator < ( const Part& p ) const 00136 { 00137 return (p_right < p.p_right); 00138 } 00139 00140 inline Point leftPoint(){ return p_left; } 00141 inline Point rightPoint(){ return p_right; } 00142 inline TypeOfValue getK(){ return k; } 00143 inline TypeOfValue left_x(){ return p_left.x; } 00144 inline TypeOfValue left_y(){ return p_left.y; } 00145 inline TypeOfValue right_x(){ return p_right.x; } 00146 inline TypeOfValue right_y(){ return p_right.y; } 00147 00148 protected: 00149 Point p_left; 00150 Point p_right; 00151 TypeOfValue k; 00152 }; 00153 00154 // список надо отсортировать по x! 00155 typedef std::list<Part> PartsList; 00156 00157 long minRaw, maxRaw, minVal, maxVal, rightVal, leftVal, rightRaw, leftRaw; 00158 00159 private: 00160 PartsList plist; 00161 std::string myname; 00162 }; 00163 // ----------------------------------------------------------------------------- 00164 #endif // Calibration_H_ 00165 // -----------------------------------------------------------------------------
1.7.6.1