|
Open PaperOpt
|
00001 #ifndef SURFACC_H 00002 #define SURFACC_H 00003 00004 #include "utilities.h" 00005 #include "V2.h" 00006 #include <fstream> 00007 #include "Array2D.h" 00008 00009 namespace p3d{ 00015 class SurfAcc { 00016 public: 00017 00018 SurfAcc(){} 00019 ~SurfAcc(){} 00020 SurfAcc(double sizeX,double sizeY,int nSegX,int nSegY); //Nseg must be on form 2^n 00021 void ResetAccs(double value=0); //Can only be used with height operations!! 00022 void SetAccs(const SurfAcc* source); 00023 void SetAccs(const Array2D <float> *source); 00024 00025 //==========================Area based operations=========================== 00039 void CalcPollySupport(double totVal,V2 <double>* p1,V2 <double>* p2,V2 <double>* p3,V2 <double>* p4,double linSmpPerSq=5); 00040 00046 void AddSupportToAcc(); 00057 double Calc3DegIntegral(double c1,double c2,double c3) const; 00068 inline double CalcPiecLinIntegral(double g1,double g2,double k) const; 00069 00070 //========================Height based operations======================= 00086 void CalcPollyHeights(double h2,double h4,V2 <double>* p1,V2 <double>* p2,V2 <double>* p3,V2 <double>* p4,int useMin=1,double linSmpPerSq=5); 00092 double GetMinHeightSpan(); 00093 00094 00095 void AddHeightsToAcc(int keepMax=1); 00096 00102 void SaveSurfAccBinary(string filename); 00108 void ReadSurfAccFromBinary(string filename); 00109 //Sets base to max(support,base) 00110 //Accessors - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00111 00112 const double* GetAccumulator() {return mAccs;} 00113 double* GetAccumulatorModify() {return mAccs;} //You'd better know what you'r doing :) 00114 double GetBoxSizeX() {return mSizeX/mNSegX;} 00115 double GetBoxSizeY() {return mSizeY/mNSegY;} 00116 double GetTotal() const {return mTotal;} 00117 double GetMean() const; 00118 00119 private: 00120 double mSizeX,mSizeY; //um, size of entire area 00121 double mSWidX,mSWidY; //um, size of segments 00122 double mSWidXI,mSWidYI; //Inverse of above 00123 int mNSegX,mNSegY; //Number of segments 00124 double mSmalestSegInv; //1/min(mSegX,mSegY); 00125 double mTotal; //Total accumulated value / (max/min) height 00126 00127 unsigned int mBinMaskX,mBinMaskY,mBinShiftY; //(x,y)->Idx 00128 00129 00130 AutoDelete<double> mAccs; //Accumulator array 00131 AutoDelete<double> mSupport; //Current suport 00132 00133 int mSupXOfs,mSupYOfs; //x,y-ofsets in array 00134 int mSupXSize,mSupYSize; //Number of elements in each direction (safe included) 00135 int mSupCapacity; 00136 int mSupValid; //Validity flag 00137 double mSupTotal; //Total volume 00138 double mSupScaler; 00139 }; 00140 00141 } 00142 #endif;