![]()
|
tricoef.h00001 //
00002 // tricoef.h
00003 //
00004 // Copyright (C) 1996 Limit Point Systems, Inc.
00005 //
00006 // Author: Curtis Janssen <cljanss@limitpt.com>
00007 // Maintainer: LPS
00008 //
00009 // This file is part of the SC Toolkit.
00010 //
00011 // The SC Toolkit is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Library General Public License as published by
00013 // the Free Software Foundation; either version 2, or (at your option)
00014 // any later version.
00015 //
00016 // The SC Toolkit is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 // GNU Library General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Library General Public License
00022 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00024 //
00025 // The U.S. Government is granted a limited license as per AL 91-7.
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 namespace sc {
00038
00039 class TriInterpCoefKey {
00040 private:
00041 int order_;
00042 double L2_;
00043 double L3_;
00044 public:
00045 TriInterpCoefKey(int order, double L2, double L3):
00046 order_(order), L2_(L2), L3_(L3) {}
00047 int order() const { return order_; }
00048 double L1() const { return 1.0 - L2_ - L3_; }
00049 double L2() const { return L2_; }
00050 double L3() const { return L3_; }
00051 int cmp(const TriInterpCoefKey&t) const {
00052 if (order_ < t.order_) return -1;
00053 if (order_ > t.order_) return 1;
00054 if (L2_ < t.L2_) return -1;
00055 if (L2_ > t.L2_) return 1;
00056 if (L3_ < t.L3_) return -1;
00057 if (L3_ > t.L3_) return 1;
00058 return 0;
00059 }
00060 };
00061
00062 #define TriInterpCoefKeyEQ(k1,k2) ((k1).cmp(k2)==0)
00063 #define TriInterpCoefKeyCMP(k1,k2) ((k1).cmp(k2))
00064
00065 class TriInterpCoef: public RefCount {
00066 double *coef_;
00067 double *rderiv_;
00068 double *sderiv_;
00069 public:
00070 TriInterpCoef(const TriInterpCoefKey& key);
00071 ~TriInterpCoef();
00072 double& coef(int i, int j, int k) {return coef_[ijk_to_index(i,j,k)];}
00073 double& rderiv(int i, int j, int k) {return rderiv_[ijk_to_index(i,j,k)];}
00074 double& sderiv(int i, int j, int k) {return sderiv_[ijk_to_index(i,j,k)];}
00075
00076 static int
00077 ijk_to_index(int i, int j, int k)
00078 {
00079 int n = i + j + k;
00080 int ir = n - i;
00081 return (ir*(ir+1)>>1) + j;
00082 }
00083
00084 static int
00085 order_to_nvertex(int order)
00086 {
00087 return ((order+1)*(order+2)>>1);
00088 }
00089 };
00090
00091 }
00092
00093 #endif
00094
00095 // Local Variables:
00096 // mode: c++
00097 // c-file-style: "CLJ"
00098 // End:
Generated at Fri Jan 10 08:14:10 2003 for MPQC 2.1.3 using the documentation package Doxygen 1.2.14. |