PointHit.H
Go to the documentation of this file.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
00030
00031
00032
00033
00034
00035 #ifndef PointHit_H
00036 #define PointHit_H
00037
00038 #include "bool.H"
00039 #include "token.H"
00040
00041
00042
00043 namespace Foam
00044 {
00045
00046
00047
00048 class Ostream;
00049
00050
00051
00052
00053 template<class Point> class PointHit;
00054
00055 template<class Point>
00056 inline Ostream& operator<<(Ostream&, const PointHit<Point>&);
00057
00058
00059
00060
00061
00062
00063 template<class Point>
00064 class PointHit
00065 {
00066
00067
00068
00069 bool hit_;
00070
00071
00072 Point hitPoint_;
00073
00074
00075 scalar distance_;
00076
00077
00078 bool eligibleMiss_;
00079
00080
00081 public:
00082
00083
00084
00085
00086 PointHit
00087 (
00088 const bool hit,
00089 const Point& p,
00090 const scalar dist,
00091 const bool eligibleMiss
00092 )
00093 :
00094 hit_(hit),
00095 hitPoint_(p),
00096 distance_(dist),
00097 eligibleMiss_(eligibleMiss)
00098 {}
00099
00100
00101 PointHit(const Point& p)
00102 :
00103 hit_(false),
00104 hitPoint_(p),
00105 distance_(GREAT),
00106 eligibleMiss_(false)
00107 {}
00108
00109
00110
00111
00112
00113 bool hit() const
00114 {
00115 return hit_;
00116 }
00117
00118
00119 const Point& hitPoint() const
00120 {
00121 if (!hit_)
00122 {
00123 FatalErrorIn("const Point& PointHit::hitPoint() const")
00124 << "requested a hit point for a miss"
00125 << abort(FatalError);
00126 }
00127
00128 return hitPoint_;
00129 }
00130
00131
00132 scalar distance() const
00133 {
00134 return distance_;
00135 }
00136
00137
00138 const Point& missPoint() const
00139 {
00140 if (hit_)
00141 {
00142 FatalErrorIn("const Point& PointHit::missPoint() const")
00143 << "requested a miss point for a hit"
00144 << abort(FatalError);
00145 }
00146
00147 return hitPoint_;
00148 }
00149
00150
00151 const Point& rawPoint() const
00152 {
00153 return hitPoint_;
00154 }
00155
00156
00157 bool eligibleMiss() const
00158 {
00159 return eligibleMiss_;
00160 }
00161
00162 void setHit()
00163 {
00164 hit_ = true;
00165 eligibleMiss_ = false;
00166 }
00167
00168 void setMiss(const bool eligible)
00169 {
00170 hit_ = false;
00171 eligibleMiss_ = eligible;
00172 }
00173
00174 void setPoint(const Point& p)
00175 {
00176 hitPoint_ = p;
00177 }
00178
00179 void setDistance(const scalar d)
00180 {
00181 distance_ = d;
00182 }
00183
00184
00185
00186
00187 friend Ostream& operator<< <Point>
00188 (
00189 Ostream& os,
00190 const PointHit<Point>& b
00191 );
00192 };
00193
00194
00195 template<class Point>
00196 inline Ostream& operator<<(Ostream& os, const PointHit<Point>& b)
00197 {
00198 os << b.hit() << token::SPACE
00199 << b.rawPoint() << token::SPACE
00200 << b.distance() << token::SPACE
00201 << b.eligibleMiss();
00202
00203 return os;
00204 }
00205
00206
00207
00208
00209 }
00210
00211
00212
00213 #endif
00214
00215
Copyright © 2000-2009 OpenCFD Ltd