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