MPQC  3.0.0-alpha
triangle.h
1 //
2 // triangle.h
3 //
4 // Copyright (C) 1996 Limit Point Systems, Inc.
5 //
6 // Author: Curtis Janssen <cljanss@limitpt.com>
7 // Maintainer: LPS
8 //
9 // This file is part of the SC Toolkit.
10 //
11 // The SC Toolkit is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published by
13 // the Free Software Foundation; either version 2, or (at your option)
14 // any later version.
15 //
16 // The SC Toolkit is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // The U.S. Government is granted a limited license as per AL 91-7.
26 //
27 
28 #ifndef _math_isosurf_triangle_h
29 #define _math_isosurf_triangle_h
30 
31 #include <math/isosurf/tricoef.h>
32 #include <math/isosurf/edge.h>
33 
34 namespace sc {
35 
36 class Triangle: public RefCount {
37  protected:
38  // these break gcc 2.5.8
39  //unsigned int _order:5;
40  //unsigned int _orientation0:1;
41  //unsigned int _orientation1:1;
42  //unsigned int _orientation2:1;
43  //unsigned char _order;
44  //unsigned char _orientation0;
45  //unsigned char _orientation1;
46  //unsigned char _orientation2;
47  unsigned int _order;
48  unsigned int _orientation0;
49  unsigned int _orientation1;
50  unsigned int _orientation2;
51  Ref<Edge> _edges[3];
52  Ref<Vertex> *_vertices;
53  public:
54  enum {max_order = 10};
55 
56  Triangle(const Ref<Edge>& v1, const Ref<Edge>& v2, const Ref<Edge>& v3,
57  unsigned int orient0 = 0);
58  Ref<Edge> edge(int i) { return _edges[i]; };
59  int contains(const Ref<Edge>&) const;
60  unsigned int orientation(int i) const
61  {
62  return i==0?_orientation0:i==1?_orientation1:_orientation2;
63  }
64  unsigned int orientation(const Ref<Edge>&) const;
65  ~Triangle();
66  void add_edges(std::set<Ref<Edge> >&);
67  void add_vertices(std::set<Ref<Vertex> >&);
68 
69  // returns the surface area element
70  // 0<=r<=1, 0<=s<=1, 0<=r+s<=1
71  // Ref<Vertex> is the intepolated vertex (both point and normal)
72  void interpolate(const Ref<TriInterpCoef>&,
73  double r,double s,const Ref<Vertex>&v, SCVector3& dA);
74  void interpolate(double r,double s,const Ref<Vertex>&v, SCVector3& dA);
75  void interpolate(double r,double s,const Ref<Vertex>&v, SCVector3& dA,
76  const Ref<Volume> &vol, double isovalue);
77 
78  // returns a corner vertex from the triangle
79  // i = 0 is the (0,0) vertex (or L1 = 1, L2 = 0, L3 = 0)
80  // i = 1 is the (r=1,s=0) vertex (or L1 = 0, L2 = 1, L3 = 0)
81  // i = 2 is the (r=0,s=1) vertex (or L1 = 0, L2 = 0, L3 = 1)
82  Ref<Vertex> vertex(int i);
83 
84  double flat_area();
85 
86  // flip the orientation
87  void flip();
88 
89  unsigned int order() const { return _order; }
90 
91  void set_order(int order, const Ref<Volume>&vol,double isovalue);
92 };
93 
94 
95 
97  private:
98  int _n;
99  double* _r;
100  double* _s;
101  double* _w;
102  // precomputed interpolation coefficients for triangles of various orders
103  Ref<TriInterpCoef> **coef_; // max_order by _n
104  protected:
105  void set_r(int i,double r);
106  void set_s(int i,double s);
107  void set_w(int i,double w);
108  void init_coef();
109  void clear_coef();
110  public:
112  TriangleIntegrator(int n);
113  virtual ~TriangleIntegrator();
114  inline double w(int i) { return _w[i]; }
115  inline double r(int i) { return _r[i]; }
116  inline double s(int i) { return _s[i]; }
117  inline int n() { return _n; }
118  virtual void set_n(int n);
119  Ref<TriInterpCoef> coef(int order, int i) { return coef_[order-1][i]; }
120 };
121 
122 
124  private:
125  void init_rw(int order);
126  public:
128  GaussTriangleIntegrator(int order);
130  void set_n(int n);
131 };
132 
133 }
134 
135 #endif
136 
137 // Local Variables:
138 // mode: c++
139 // c-file-style: "CLJ"
140 // End:
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::Triangle
Definition: triangle.h:36
sc::TriangleIntegrator
Definition: triangle.h:96
sc::DescribedClass
Classes which need runtime information about themselves and their relationship to other classes can v...
Definition: class.h:233
sc::SCVector3
a 3-element version of SCVector
Definition: vector3.h:43
sc::RefCount
The base class for all reference counted objects.
Definition: ref.h:192
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
sc::GaussTriangleIntegrator
Definition: triangle.h:123

Generated at Sun Jan 26 2020 23:24:00 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.