MPQC 2.3.1

- Main Page
- Related Pages
- Classes
- Files

- File List

triangle.h

    00001 //
    00002 // triangle.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_triangle_h
    00029 #define _math_isosurf_triangle_h
    00030
    00031 #ifdef __GNUC__
    00032 #pragma interface
    00033 #endif
    00034
    00035 #include <math/isosurf/tricoef.h>
    00036 #include <math/isosurf/edge.h>
    00037
    00038 namespace sc {
    00039
    00040 class Triangle: public RefCount {
    00041   protected:
    00042     // these break gcc 2.5.8
    00043     //unsigned int _order:5;
    00044     //unsigned int _orientation0:1;
    00045     //unsigned int _orientation1:1;
    00046     //unsigned int _orientation2:1;
    00047     //unsigned char _order;
    00048     //unsigned char _orientation0;
    00049     //unsigned char _orientation1;
    00050     //unsigned char _orientation2;
    00051     unsigned int _order;
    00052     unsigned int _orientation0;
    00053     unsigned int _orientation1;
    00054     unsigned int _orientation2;
    00055     Ref<Edge> _edges[3];
    00056     Ref<Vertex> *_vertices;
    00057   public:
    00058     enum {max_order = 10};
    00059
    00060     Triangle(const Ref<Edge>& v1, const Ref<Edge>& v2, const Ref<Edge>& v3,
    00061              unsigned int orient0 = 0);
    00062     Ref<Edge> edge(int i) { return _edges[i]; };
    00063     int contains(const Ref<Edge>&) const;
    00064     unsigned int orientation(int i) const
    00065     {
    00066       return i==0?_orientation0:i==1?_orientation1:_orientation2;
    00067     }
    00068     unsigned int orientation(const Ref<Edge>&) const;
    00069     ~Triangle();
    00070     void add_edges(std::set<Ref<Edge> >&);
    00071     void add_vertices(std::set<Ref<Vertex> >&);
    00072
    00073     // returns the surface area element
    00074     // 0<=r<=1, 0<=s<=1, 0<=r+s<=1
    00075     // Ref<Vertex> is the intepolated vertex (both point and normal)
    00076     void interpolate(const Ref<TriInterpCoef>&,
    00077                      double r,double s,const Ref<Vertex>&v, SCVector3& dA);
    00078     void interpolate(double r,double s,const Ref<Vertex>&v, SCVector3& dA);
    00079     void interpolate(double r,double s,const Ref<Vertex>&v, SCVector3& dA,
    00080                      const Ref<Volume> &vol, double isovalue);
    00081
    00082     // returns a corner vertex from the triangle
    00083     // i = 0 is the (0,0) vertex (or L1 = 1, L2 = 0, L3 = 0)
    00084     // i = 1 is the (r=1,s=0) vertex (or L1 = 0, L2 = 1, L3 = 0)
    00085     // i = 2 is the (r=0,s=1) vertex (or L1 = 0, L2 = 0, L3 = 1)
    00086     Ref<Vertex> vertex(int i);
    00087
    00088     double flat_area();
    00089
    00090     // flip the orientation
    00091     void flip();
    00092
    00093     unsigned int order() const { return _order; }
    00094
    00095     void set_order(int order, const Ref<Volume>&vol,double isovalue);
    00096 };
    00097
    00098
    00099
    00100 class TriangleIntegrator: public DescribedClass {
    00101   private:
    00102     int _n;
    00103     double* _r;
    00104     double* _s;
    00105     double* _w;
    00106     // precomputed interpolation coefficients for triangles of various orders
    00107     Ref<TriInterpCoef> **coef_; // max_order by _n
    00108   protected:
    00109     void set_r(int i,double r);
    00110     void set_s(int i,double s);
    00111     void set_w(int i,double w);
    00112     void init_coef();
    00113     void clear_coef();
    00114   public:
    00115     TriangleIntegrator(const Ref<KeyVal>&);
    00116     TriangleIntegrator(int n);
    00117     virtual ~TriangleIntegrator();
    00118     inline double w(int i) { return _w[i]; }
    00119     inline double r(int i) { return _r[i]; }
    00120     inline double s(int i) { return _s[i]; }
    00121     inline int n() { return _n; }
    00122     virtual void set_n(int n);
    00123     Ref<TriInterpCoef> coef(int order, int i) { return coef_[order-1][i]; }
    00124 };
    00125
    00126
    00127 class GaussTriangleIntegrator: public TriangleIntegrator {
    00128   private:
    00129     void init_rw(int order);
    00130   public:
    00131     GaussTriangleIntegrator(const Ref<KeyVal>&);
    00132     GaussTriangleIntegrator(int order);
    00133     ~GaussTriangleIntegrator();
    00134     void set_n(int n);
    00135 };
    00136
    00137 }
    00138
    00139 #endif
    00140
    00141 // Local Variables:
    00142 // mode: c++
    00143 // c-file-style: "CLJ"
    00144 // End: