00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SB_LINE_
00024 #define _SB_LINE_
00025
00026 #include <Inventor/SbBase.h>
00027 #include <Inventor/SbVec.h>
00028 #include <Inventor/SbBox.h>
00029
00030
00032
00033
00034
00035
00036
00038
00039 class SbLined;
00040
00057 class SbLine {
00058 public:
00062 SbLine() {}
00063
00070 SbLine(const SbVec3f &p0, const SbVec3f &p1);
00071
00075 void setValue(const SbVec3f &p0, const SbVec3f &p1);
00076
00084 void setPosDir( const SbVec3f &position, const SbVec3f &direction );
00085
00089 void setValue( const SbLined& line );
00090
00096 SbBool getClosestPoints(const SbLine &line2,
00097 SbVec3f &ptOnThis,
00098 SbVec3f &ptOnLine2 ) const;
00099
00103 SbVec3f getClosestPoint(const SbVec3f &point) const;
00104
00108 inline const SbVec3f &getPosition() const { return pos; }
00109
00113 inline const SbVec3f &getDirection() const { return dir; }
00114
00118 static void setIntersectEpsilon(const float epsilon);
00119
00120 private:
00121
00125 SbBool intersect(const SbBox3f &box, SbVec3f &enter, SbVec3f &exit) const;
00126
00130 SbBool intersect(const SbXfBox3f &xbox, SbVec3f &enter, SbVec3f &exit) const;
00131
00135 SbBool intersect(float angle, const SbBox3f &box) const;
00136
00140 SbBool intersect(float angle, const SbVec3f &point) const;
00141
00145 SbBool intersect(float angle, const SbVec3f &v0, const SbVec3f &v1, SbVec3f &pt) const;
00146
00150 SbBool intersect(
00151 const SbVec3f &v0, const SbVec3f &v1, const SbVec3f &v2,
00152 SbVec3f &pt, SbVec3f &barycentric, SbBool &front
00153 ) const;
00154
00155 private:
00156
00157
00158 SbVec3f pos;
00159 SbVec3f dir;
00160 };
00161
00162
00163
00182 class SbLined {
00183 public:
00187 SbLined() {}
00188
00195 SbLined(const SbVec3d &p0, const SbVec3d &p1);
00196
00200 void setValue(const SbVec3d &p0, const SbVec3d &p1);
00201
00209 void setPosDir( const SbVec3d &position, const SbVec3d &direction );
00210
00214 void setValue( const SbLine& line );
00215
00221 SbBool getClosestPoints(const SbLined &line2,
00222 SbVec3d &ptOnThis,
00223 SbVec3d &ptOnLine2 ) const;
00224
00228 SbVec3d getClosestPoint(const SbVec3d &point) const;
00229
00230
00234 inline const SbVec3d &getPosition() const { return pos; }
00235
00239 inline const SbVec3d &getDirection() const { return dir; }
00240
00244 static void setIntersectEpsilon(const double epsilon);
00245
00246 private:
00247
00248 SbBool intersect(const SbBox3d &box,
00249 SbVec3d &enter, SbVec3d &exit) const;
00250 SbBool intersect(double angle, const SbBox3d &box) const;
00251 SbBool intersect(double angle, const SbVec3d &point) const;
00252 SbBool intersect(double angle, const SbVec3d &v0,
00253 const SbVec3d &v1, SbVec3d &pt) const;
00254 SbBool intersect(const SbVec3d &v0,
00255 const SbVec3d &v1,
00256 const SbVec3d &v2,
00257 SbVec3d &pt, SbVec3d &barycentric,
00258 SbBool &front) const;
00259
00260 SbVec3d getClosestPoint_( const SbVec3d &point,
00261 double &projlen ) const;
00262
00263 bool getClosestPoints_( const SbLined &line2,
00264 SbVec3d &ptOnThis,
00265 SbVec3d &ptOnLine2,
00266 double &s,
00267 double &t) const;
00268
00269 private:
00270
00271
00272 SbVec3d pos;
00273 SbVec3d dir;
00274 };
00275
00276
00277
00278 inline void SbLine::setValue( const SbLined& line )
00279 {
00280 pos.setValue( line.getPosition() );
00281 dir.setValue( line.getDirection() );
00282 }
00283
00284 inline void SbLined::setValue( const SbLine& line )
00285 {
00286 pos.setValue( line.getPosition() );
00287 dir.setValue( line.getDirection() );
00288 }
00289
00290 #endif
00291
00292
00293