1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM 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 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 This class describes the interaction of (usually) a face and a point.
30 It carries the info of a successful hit and (if successful),
31 returns the interaction point.
33 like pointHit but carries face (or cell, edge etc.) index
37 \*---------------------------------------------------------------------------*/
39 #ifndef PointIndexHit_H
40 #define PointIndexHit_H
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 /*---------------------------------------------------------------------------*\
51 Class PointIndexHit Declaration
52 \*---------------------------------------------------------------------------*/
62 //- Point of hit; invalid for misses
73 //- Construct from components
74 PointIndexHit(const bool success, const Point& p, const label index)
81 //- Construct from point. Hit and distance set later
82 PointIndexHit(const Point& p)
93 hitPoint_(vector::zero),
97 //- Construct from Istream
98 PointIndexHit(Istream& is)
119 const Point& hitPoint() const
123 FatalErrorIn("PointIndexHit::hitPoint() const")
124 << "requested a hit point for a miss"
125 << abort(FatalError);
131 //- Return miss point
132 const Point& missPoint() const
136 FatalErrorIn("PointIndexHit::missPoint() const")
137 << "requested a miss point for a hit"
138 << abort(FatalError);
144 //- Return point with no checking
145 const Point& rawPoint() const
165 void setPoint(const Point& p)
170 void setIndex(const label index)
175 bool operator==(const PointIndexHit& rhs) const
179 && hitPoint_ == rhs.rawPoint()
180 && index_ == rhs.index();
183 bool operator!=(const PointIndexHit& rhs) const
185 return !operator==(rhs);
188 void write(Ostream& os)
192 os << "hit:" << hitPoint() << " index:" << index();
196 os << "miss:" << missPoint() << " index:" << index();
200 friend Ostream& operator<< (Ostream& os, const PointIndexHit& pHit)
202 if (os.format() == IOstream::ASCII)
204 os << pHit.hit_ << token::SPACE << pHit.hitPoint_
205 << token::SPACE << pHit.index_;
211 reinterpret_cast<const char*>(&pHit),
212 sizeof(PointIndexHit)
216 // Check state of Ostream
217 os.check("Ostream& operator<<(Ostream&, const PointIndexHit&)");
222 friend Istream& operator>>(Istream& is, PointIndexHit& pHit)
224 if (is.format() == IOstream::ASCII)
226 return is >> pHit.hit_ >> pHit.hitPoint_ >> pHit.index_;
232 reinterpret_cast<char*>(&pHit),
233 sizeof(PointIndexHit)
237 // Check state of Istream
238 is.check("Istream& operator>>(Istream&, PointIndexHit&)");
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 } // End namespace Foam
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 // ************************************************************************* //