1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
28 This class describes the interaction of (usually) a face and a point.
29 It carries the info of a successful hit and (if successful),
30 returns the interaction point.
32 like pointHit but carries face (or cell, edge etc.) index
36 \*---------------------------------------------------------------------------*/
38 #ifndef PointIndexHit_H
39 #define PointIndexHit_H
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 /*---------------------------------------------------------------------------*\
50 Class PointIndexHit Declaration
51 \*---------------------------------------------------------------------------*/
61 //- Point of hit; invalid for misses
72 //- Construct from components
73 PointIndexHit(const bool success, const Point& p, const label index)
80 //- Construct from point. Hit and distance set later
81 PointIndexHit(const Point& p)
92 hitPoint_(vector::zero),
96 //- Construct from Istream
97 PointIndexHit(Istream& is)
118 const Point& hitPoint() const
122 FatalErrorIn("PointIndexHit::hitPoint() const")
123 << "requested a hit point for a miss"
124 << abort(FatalError);
130 //- Return miss point
131 const Point& missPoint() const
135 FatalErrorIn("PointIndexHit::missPoint() const")
136 << "requested a miss point for a hit"
137 << abort(FatalError);
143 //- Return point with no checking
144 const Point& rawPoint() const
164 void setPoint(const Point& p)
169 void setIndex(const label index)
174 bool operator==(const PointIndexHit& rhs) const
178 && hitPoint_ == rhs.rawPoint()
179 && index_ == rhs.index();
182 bool operator!=(const PointIndexHit& rhs) const
184 return !operator==(rhs);
187 void write(Ostream& os)
191 os << "hit:" << hitPoint() << " index:" << index();
195 os << "miss:" << missPoint() << " index:" << index();
199 friend Ostream& operator<< (Ostream& os, const PointIndexHit& pHit)
201 if (os.format() == IOstream::ASCII)
203 os << pHit.hit_ << token::SPACE << pHit.hitPoint_
204 << token::SPACE << pHit.index_;
210 reinterpret_cast<const char*>(&pHit),
211 sizeof(PointIndexHit)
215 // Check state of Ostream
216 os.check("Ostream& operator<<(Ostream&, const PointIndexHit&)");
221 friend Istream& operator>>(Istream& is, PointIndexHit& pHit)
223 if (is.format() == IOstream::ASCII)
225 return is >> pHit.hit_ >> pHit.hitPoint_ >> pHit.index_;
231 reinterpret_cast<char*>(&pHit),
232 sizeof(PointIndexHit)
236 // Check state of Istream
237 is.check("Istream& operator>>(Istream&, PointIndexHit&)");
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 } // End namespace Foam
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 // ************************************************************************* //