00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _math_isosurf_tricoef_h
00029 #define _math_isosurf_tricoef_h
00030
00031 #ifdef __GNUC__
00032 #pragma interface
00033 #endif
00034
00035 #include <util/ref/ref.h>
00036
00037 class TriInterpCoefKey {
00038 private:
00039 int order_;
00040 double L2_;
00041 double L3_;
00042 public:
00043 TriInterpCoefKey(int order, double L2, double L3):
00044 order_(order), L2_(L2), L3_(L3) {}
00045 int order() const { return order_; }
00046 double L1() const { return 1.0 - L2_ - L3_; }
00047 double L2() const { return L2_; }
00048 double L3() const { return L3_; }
00049 int cmp(const TriInterpCoefKey&t) const {
00050 if (order_ < t.order_) return -1;
00051 if (order_ > t.order_) return 1;
00052 if (L2_ < t.L2_) return -1;
00053 if (L2_ > t.L2_) return 1;
00054 if (L3_ < t.L3_) return -1;
00055 if (L3_ > t.L3_) return 1;
00056 return 0;
00057 }
00058 };
00059
00060 #define TriInterpCoefKeyEQ(k1,k2) ((k1).cmp(k2)==0)
00061 #define TriInterpCoefKeyCMP(k1,k2) ((k1).cmp(k2))
00062
00063 class TriInterpCoef: public RefCount {
00064 double *coef_;
00065 double *rderiv_;
00066 double *sderiv_;
00067 public:
00068 TriInterpCoef(const TriInterpCoefKey& key);
00069 ~TriInterpCoef();
00070 double& coef(int i, int j, int k) {return coef_[ijk_to_index(i,j,k)];}
00071 double& rderiv(int i, int j, int k) {return rderiv_[ijk_to_index(i,j,k)];}
00072 double& sderiv(int i, int j, int k) {return sderiv_[ijk_to_index(i,j,k)];}
00073
00074 static int
00075 ijk_to_index(int i, int j, int k)
00076 {
00077 int n = i + j + k;
00078 int ir = n - i;
00079 return (ir*(ir+1)>>1) + j;
00080 }
00081
00082 static int
00083 order_to_nvertex(int order)
00084 {
00085 return ((order+1)*(order+2)>>1);
00086 }
00087 };
00088
00089
00090
00091 #endif
00092
00093
00094
00095
00096