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_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
00043
00044
00045
00046
00047
00048
00049
00050
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
00074
00075
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
00083
00084
00085
00086 Ref<Vertex> vertex(int i);
00087
00088 double flat_area();
00089
00090
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
00107 Ref<TriInterpCoef> **coef_;
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
00142
00143
00144