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
00040
00041
00042
00043
00044
00045 #ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PLANE_3D_INL
00046 #define LASS_GUARDIAN_OF_INCLUSION_PRIM_PLANE_3D_INL
00047
00048 #include "prim_common.h"
00049 #include "plane_3d.h"
00050
00051 namespace lass
00052 {
00053 namespace prim
00054 {
00055
00056
00057
00058 template<typename T, typename EP, typename NP>
00059 Plane3D<T, EP, NP>::Plane3D():
00060 TImpl()
00061 {
00062 }
00063
00064
00065
00066
00067 template<typename T, typename EP, typename NP>
00068 Plane3D<T, EP, NP>::Plane3D(const TPoint& iSupport,
00069 const TPoint& iPointU,
00070 const TPoint& iPointV):
00071 TImpl(iSupport, iPointU, iPointV)
00072 {
00073 }
00074
00075
00076
00077 template<typename T, typename EP, typename NP>
00078 Plane3D<T, EP, NP>::Plane3D(const TPoint& iSupport,
00079 const TVector& iDirU,
00080 const TVector& iDirV):
00081 TImpl(iSupport, iDirU, iDirV)
00082 {
00083 }
00084
00085
00086
00087 template<typename T, typename EP, typename NP>
00088 Plane3D<T, EP, NP>::Plane3D(const TVector& iNormal, const TPoint& iSupport):
00089 TImpl(iNormal, iSupport)
00090 {
00091 }
00092
00093
00094
00095 template<typename T, typename EP, typename NP>
00096 Plane3D<T, EP, NP>::Plane3D(const TVector& iNormal, TParam iD):
00097 TImpl(iNormal, iD)
00098 {
00099 }
00100
00101
00102
00103
00104
00105 template<typename T, typename EP, typename NP>
00106 const Side Plane3D<T, EP, NP>::classify(const TPoint& iPoint) const
00107 {
00108 const TValue eq = this->equation(iPoint);
00109 return eq > TNumTraits::zero ? sFront : (eq < TNumTraits::zero ? sBack : sSurface);
00110 }
00111
00112
00113
00114
00115
00116
00117 template<typename T, typename EP, typename NP>
00118 const typename Plane3D<T, EP, NP>::TValue
00119 Plane3D<T, EP, NP>::signedDistance(const TPoint& iPoint) const
00120 {
00121 return NP::divideByNorm(this->equation(iPoint), this->normal());
00122 }
00123
00124
00125
00126
00127
00128 template<typename T, typename EP, typename NP>
00129 const typename Plane3D<T, EP, NP>::TValue
00130 Plane3D<T, EP, NP>::squaredDistance(const TPoint& iPoint) const
00131 {
00132 return num::sqr(this->signedDistance(iPoint));
00133 }
00134
00135
00136
00137
00138
00139 template<typename T, typename EP, typename NP>
00140 const Side Plane3D<T, EP, NP>::classify(const TPoint& iPoint, TParam iRelativeTolerance) const
00141 {
00142 const TValue eq = this->equation(iPoint, iRelativeTolerance);
00143 return eq > TNumTraits::zero ? sFront : (eq < TNumTraits::zero ? sBack : sSurface);
00144 }
00145
00146
00147
00148
00149
00150
00151 template<typename T, typename EP, typename NP>
00152 const typename Plane3D<T, EP, NP>::TValue
00153 Plane3D<T, EP, NP>::signedDistance(const TPoint& iPoint, TParam iRelativeTolerance) const
00154 {
00155 return NP::divideByNorm(equation(iPoint, iRelativeTolerance), this->normal());
00156 }
00157
00158
00159
00160
00161
00162 template<typename T, typename EP, typename NP>
00163 const typename Plane3D<T, EP, NP>::TValue
00164 Plane3D<T, EP, NP>::squaredDistance(const TPoint& iPoint, TParam iRelativeTolerance) const
00165 {
00166 return num::sqr(signedDistance(iPoint, iRelativeTolerance));
00167 }
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 template<typename T, typename EP, typename NP>
00179 const XYZ Plane3D<T, EP, NP>::majorAxis() const
00180 {
00181 const TVector absNormal = this->normal().transform(num::abs);
00182 if (absNormal.x > absNormal.y && absNormal.x > absNormal.z)
00183 {
00184 return 0;
00185 }
00186 else if (absNormal.y > absNormal.z)
00187 {
00188 return 1;
00189 }
00190 else
00191 {
00192 return 2;
00193 }
00194 LASS_ASSERT(false);
00195 return 0;
00196 }
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213 template <typename T>
00214 io::XmlOStream& operator<<(io::XmlOStream& ioOStream, const Plane3D<T, Cartesian>& iPlane)
00215 {
00216 LASS_ENFORCE_STREAM(ioOStream)
00217 << "<Plane3D>\n"
00218 << "<normal>" << iPlane.normal() << "</normal>\n"
00219 << "<d>" << iPlane.d() << "</d>\n"
00220 << "</Plane3D>\n";
00221
00222 return ioOStream;
00223 }
00224
00225
00226
00227
00228
00229 template <typename T>
00230 io::XmlOStream& operator<<(io::XmlOStream& ioOStream, const Plane3D<T, Parametric>& iPlane)
00231 {
00232 LASS_ENFORCE_STREAM(ioOStream)
00233 << "<Plane3D>\n"
00234 << "<support>" << iPlane.support() << "</support>\n"
00235 << "<directionU>" << iPlane.directionU() << "</directionU>\n"
00236 << "<directionV>" << iPlane.directionV() << "</directionV>\n"
00237 << "</Plane3D>\n";
00238
00239 return ioOStream;
00240 }
00241
00242
00243
00244
00245
00246 template <typename T>
00247 io::XmlOStream& operator<<(io::XmlOStream& ioOStream, const Plane3D<T, Combined>& iPlane)
00248 {
00249 LASS_ENFORCE_STREAM(ioOStream)
00250 << "<Plane3D>\n"
00251 << "<support>" << iPlane.support() << "</support>\n"
00252 << "<directionU>" << iPlane.directionU() << "</directionU>\n"
00253 << "<directionV>" << iPlane.directionV() << "</directionV>\n"
00254 << "<normal>" << iPlane.normal() << "</normal>\n"
00255 << "<d>" << iPlane.d() << "</d>\n"
00256 << "</Plane3D>\n";
00257
00258 return ioOStream;
00259 }
00260
00261
00262
00263 }
00264
00265 }
00266
00267 #endif
00268
00269