1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of cfMesh.
11 cfMesh is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 3 of the License, or (at your
14 option) any later version.
16 cfMesh is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
26 \*---------------------------------------------------------------------------*/
29 #include "tetrahedron.H"
30 #include "IOstreams.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 inline partTet::partTet()
43 inline partTet::partTet
57 inline partTet::~partTet()
61 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
63 inline label partTet::a() const
68 inline label partTet::b() const
73 inline label partTet::c() const
78 inline label partTet::d() const
83 inline label partTet::size() const
88 inline label partTet::whichPosition(const label pointI) const
90 for(label i=0;i<4;++i)
91 if( data_[i] == pointI )
97 template<class PointField>
98 inline vector partTet::Sa(const PointField& points) const
100 triangle<point, point> tria
107 return tria.normal();
108 //return triangle<point, point>(b_, c_, d_).normal();
111 template<class PointField>
112 inline vector partTet::Sb(const PointField& points) const
114 triangle<point, point> tria
121 return tria.normal();
122 //return triangle<point, point>(a_, d_, c_).normal();
125 template<class PointField>
126 inline vector partTet::Sc(const PointField& points) const
128 triangle<point, point> tria
135 return tria.normal();
136 //return triangle<point, point>(a_, b_, d_).normal();
139 template<class PointField>
140 inline vector partTet::Sd(const PointField& points) const
142 triangle<point, point> tria
149 return tria.normal();
150 //return triangle<point, point>(a_, c_, b_).normal();
153 template<class PointField>
154 inline scalar partTet::mag(const PointField& points) const
156 tetrahedron<point, point> tet
165 //return (1.0/6.0)*(((b_ - a_) ^ (c_ - a_)) & (d_ - a_));
168 template<class PointField>
169 inline point partTet::crcmCentre(const PointField& points) const
171 tetrahedron<point, point> tet
179 return tet.circumCentre();
182 template<class PointField>
183 inline scalar partTet::crcmRadius(const PointField& points) const
185 tetrahedron<point, point> tet
193 return tet.circumRadius();
196 template<class PointField>
197 inline point partTet::centroid(const PointField& points) const
199 point p = points[data_[0]];
200 for(label i=1;i<4;++i)
201 p += points[data_[i]];
207 inline FixedList<edge, 6> partTet::edges() const
209 FixedList<edge, 6> edges;
210 edges[0] = edge(data_[0], data_[1]);
211 edges[1] = edge(data_[0], data_[2]);
212 edges[2] = edge(data_[0], data_[3]);
213 edges[3] = edge(data_[3], data_[1]);
214 edges[4] = edge(data_[1], data_[2]);
215 edges[5] = edge(data_[3], data_[2]);
220 inline edge partTet::getEdge(const label eI) const
226 return edge(data_[0], data_[1]);
230 return edge(data_[0], data_[2]);
234 return edge(data_[0], data_[3]);
238 return edge(data_[3], data_[1]);
242 return edge(data_[1], data_[2]);
246 return edge(data_[3], data_[2]);
250 FatalErrorIn("inline edge partTet::getEdge(const label) const")
251 << "Invalid edge index given " << eI << abort(FatalError);
256 inline label partTet::operator[](const label i) const
261 inline void partTet::operator=(const partTet& tet)
263 for(label i=0;i<4;++i)
264 data_[i] = tet.data_[i];
267 inline bool partTet::operator==(const partTet& tet) const
269 if( this->a() != tet.a() )
271 if( this->b() != tet.b() )
273 if( this->c() != tet.c() )
275 if( this->d() != tet.d() )
281 inline bool partTet::operator!=(const partTet& tet) const
283 return !this->operator==(tet);
286 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
288 inline Ostream& operator<<(Ostream& os, const partTet& t)
292 << t.a() << token::SPACE << t.b()
293 << token::SPACE << t.c() << token::SPACE << t.d()
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 } // End namespace Foam
303 // ************************************************************************* //