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 #include "IOstreams.H"
00028 #include "face.H"
00029 #include "triPointRef.H"
00030
00031
00032
00033 namespace Foam
00034 {
00035
00036
00037
00038
00039 inline triFace::triFace()
00040 {}
00041
00042
00043
00044 inline triFace::triFace
00045 (
00046 const label a,
00047 const label b,
00048 const label c
00049 )
00050 {
00051 operator[](0) = a;
00052 operator[](1) = b;
00053 operator[](2) = c;
00054 }
00055
00056
00057 inline triFace::triFace(Istream& is)
00058 :
00059 FixedList<label, 3>(is)
00060 {}
00061
00062
00063
00064
00065
00066 inline pointField triFace::points(const pointField& points) const
00067 {
00068 pointField p(3);
00069
00070 p[0] = points[operator[](0)];
00071 p[1] = points[operator[](1)];
00072 p[2] = points[operator[](2)];
00073
00074 return p;
00075 }
00076
00077
00078
00079 inline face triFace::triFaceFace() const
00080 {
00081 face f(3);
00082
00083 f[0] = operator[](0);
00084 f[1] = operator[](1);
00085 f[2] = operator[](2);
00086
00087 return f;
00088 }
00089
00090
00091 inline label triFace::nEdges() const
00092 {
00093 return 3;
00094 }
00095
00096
00097 inline edgeList triFace::edges() const
00098 {
00099 edgeList e(3);
00100
00101 e[0].start() = operator[](0);
00102 e[0].end() = operator[](1);
00103
00104 e[1].start() = operator[](1);
00105 e[1].end() = operator[](2);
00106
00107 e[2].start() = operator[](2);
00108 e[2].end() = operator[](0);
00109
00110 return e;
00111 }
00112
00113
00114 inline point triFace::centre(const pointField& points) const
00115 {
00116 return (1.0/3.0)*
00117 (
00118 points[operator[](0)]
00119 + points[operator[](1)]
00120 + points[operator[](2)]
00121 );
00122 }
00123
00124
00125 inline scalar triFace::mag(const pointField& points) const
00126 {
00127 return ::Foam::mag(normal(points));
00128 }
00129
00130
00131 inline vector triFace::normal(const pointField& points) const
00132 {
00133 return 0.5*
00134 (
00135 (points[operator[](1)] - points[operator[](0)])
00136 ^(points[operator[](2)] - points[operator[](0)])
00137 );
00138 }
00139
00140
00141 inline scalar triFace::sweptVol
00142 (
00143 const pointField& opts,
00144 const pointField& npts
00145 ) const
00146 {
00147 return (1.0/6.0)*
00148 (
00149 (
00150 (npts[operator[](0)] - opts[operator[](0)])
00151 & (
00152 (opts[operator[](1)] - opts[operator[](0)])
00153 ^ (opts[operator[](2)] - opts[operator[](0)])
00154 )
00155 )
00156 + (
00157 (npts[operator[](1)] - opts[operator[](1)])
00158 & (
00159 (opts[operator[](2)] - opts[operator[](1)])
00160 ^ (npts[operator[](0)] - opts[operator[](1)])
00161 )
00162 )
00163 + (
00164 (opts[operator[](2)] - npts[operator[](2)])
00165 & (
00166 (npts[operator[](1)] - npts[operator[](2)])
00167 ^ (npts[operator[](0)] - npts[operator[](2)])
00168 )
00169 )
00170 );
00171 }
00172
00173
00174 inline pointHit triFace::ray
00175 (
00176 const point& p,
00177 const vector& q,
00178 const pointField& points,
00179 const intersection::algorithm alg,
00180 const intersection::direction dir
00181 ) const
00182 {
00183 return triPointRef
00184 (
00185 points[operator[](0)],
00186 points[operator[](1)],
00187 points[operator[](2)]
00188 ).ray(p, q, alg, dir);
00189 }
00190
00191
00192 inline triPointRef triFace::tri(const pointField& points) const
00193 {
00194 return triPointRef
00195 (
00196 points[operator[](0)],
00197 points[operator[](1)],
00198 points[operator[](2)]
00199 );
00200 }
00201
00202
00203
00204
00205 inline bool operator==(const triFace& tf1, const triFace& tf2)
00206 {
00207 return
00208 (
00209 (tf1[0] == tf2[0] && tf1[1] == tf2[1] && tf1[2] == tf2[2])
00210 || (tf1[0] == tf2[1] && tf1[1] == tf2[2] && tf1[2] == tf2[0])
00211 || (tf1[0] == tf2[2] && tf1[1] == tf2[0] && tf1[2] == tf2[1])
00212 || (tf1[0] == tf2[2] && tf1[1] == tf2[1] && tf1[2] == tf2[0])
00213 || (tf1[0] == tf2[1] && tf1[1] == tf2[0] && tf1[2] == tf2[2])
00214 || (tf1[0] == tf2[0] && tf1[1] == tf2[2] && tf1[2] == tf2[1])
00215 );
00216 }
00217
00218
00219 inline bool operator!=(const triFace& tf1, const triFace& tf2)
00220 {
00221 return !(tf1 == tf2);
00222 }
00223
00224
00225
00226
00227 }
00228
00229
Copyright © 2000-2007 OpenCFD Ltd