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
00036
00037
00038
00039 #ifndef pointIndexHit_H
00040 #define pointIndexHit_H
00041
00042 #include "bool.H"
00043 #include "point.H"
00044
00045
00046
00047 namespace Foam
00048 {
00049
00050
00051
00052
00053
00054 class pointIndexHit
00055 {
00056
00057
00058
00059 bool hit_;
00060
00061
00062 point hitPoint_;
00063
00064
00065 label index_;
00066
00067
00068 public:
00069
00070
00071
00072
00073 pointIndexHit(const bool success, const point& p, const label index)
00074 :
00075 hit_(success),
00076 hitPoint_(p),
00077 index_(index)
00078 {}
00079
00080
00081 pointIndexHit(const point& p)
00082 :
00083 hit_(false),
00084 hitPoint_(p),
00085 index_(-1)
00086 {}
00087
00088
00089 pointIndexHit()
00090 :
00091 hit_(false),
00092 hitPoint_(vector::zero),
00093 index_(-1)
00094 {}
00095
00096
00097
00098
00099
00100 bool hit() const
00101 {
00102 return hit_;
00103 }
00104
00105
00106 label index() const
00107 {
00108 return index_;
00109 }
00110
00111
00112 const point& hitPoint() const
00113 {
00114 if (!hit_)
00115 {
00116 FatalErrorIn("point pointIndexHit::hitPoint() const")
00117 << "requested a hit point for a miss"
00118 << abort(FatalError);
00119 }
00120
00121 return hitPoint_;
00122 }
00123
00124
00125 const point& missPoint() const
00126 {
00127 if (hit_)
00128 {
00129 FatalErrorIn("pointIndexHit::missPoint() const")
00130 << "requested a miss point for a hit"
00131 << abort(FatalError);
00132 }
00133
00134 return hitPoint_;
00135 }
00136
00137
00138 const point& rawPoint() const
00139 {
00140 return hitPoint_;
00141 }
00142
00143 void setHit()
00144 {
00145 hit_ = true;
00146 }
00147
00148 void setMiss()
00149 {
00150 hit_ = false;
00151 }
00152
00153 void setPoint(const point& p)
00154 {
00155 hitPoint_ = p;
00156 }
00157
00158 void setIndex(const label index)
00159 {
00160 index_ = index;
00161 }
00162
00163 void write(Ostream& os)
00164 {
00165 if (hit())
00166 {
00167 os << "hit:" << hitPoint() << " index:" << index();
00168 }
00169 else
00170 {
00171 os << "miss:" << missPoint() << " index:" << index();
00172 }
00173 }
00174
00175 friend Ostream& operator<< (Ostream& os, const pointIndexHit& pHit)
00176 {
00177 return os << pHit.hit_ << token::SPACE << pHit.hitPoint_
00178 << token::SPACE << pHit.index_;
00179 }
00180 };
00181
00182
00183
00184
00185 }
00186
00187
00188
00189 #endif
00190
00191