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
00058 class SbLine {
00059 public:
00063 SbLine() {}
00064
00071 SbLine(const SbVec3f &p0, const SbVec3f &p1);
00072
00076 void setValue(const SbVec3f &p0, const SbVec3f &p1);
00077
00085 void setPosDir( const SbVec3f &position, const SbVec3f &direction );
00086
00090 void setValue( const SbLined& line );
00091
00097 SbBool getClosestPoints(const SbLine &line2,
00098 SbVec3f &ptOnThis,
00099 SbVec3f &ptOnLine2 ) const;
00100
00104 SbVec3f getClosestPoint(const SbVec3f &point) const;
00105
00109 inline const SbVec3f &getPosition() const { return pos; }
00110
00114 inline const SbVec3f &getDirection() const { return dir; }
00115
00119 static void setIntersectEpsilon(const float epsilon);
00120
00121 private:
00122
00126 SbBool intersect(const SbBox3f &box, SbVec3f &enter, SbVec3f &exit) const;
00127
00131 SbBool intersect(const SbXfBox3f &xbox, SbVec3f &enter, SbVec3f &exit) const;
00132
00136 SbBool intersect(float angle, const SbBox3f &box) const;
00137
00141 SbBool intersect(float angle, const SbVec3f &point) const;
00142
00146 SbBool intersect(float angle, const SbVec3f &v0, const SbVec3f &v1, SbVec3f &pt) const;
00147
00151 SbBool intersect(
00152 const SbVec3f &v0, const SbVec3f &v1, const SbVec3f &v2,
00153 SbVec3f &pt, SbVec3f &barycentric, SbBool &front
00154 ) const;
00155
00156 private:
00157
00158
00159 SbVec3f pos;
00160 SbVec3f dir;
00161 };
00162
00163
00164
00184 class SbLined {
00185 public:
00189 SbLined() {}
00190
00197 SbLined(const SbVec3d &p0, const SbVec3d &p1);
00198
00202 void setValue(const SbVec3d &p0, const SbVec3d &p1);
00203
00211 void setPosDir( const SbVec3d &position, const SbVec3d &direction );
00212
00216 void setValue( const SbLine& line );
00217
00223 SbBool getClosestPoints(const SbLined &line2,
00224 SbVec3d &ptOnThis,
00225 SbVec3d &ptOnLine2 ) const;
00226
00230 SbVec3d getClosestPoint(const SbVec3d &point) const;
00231
00232
00236 inline const SbVec3d &getPosition() const { return pos; }
00237
00241 inline const SbVec3d &getDirection() const { return dir; }
00242
00246 static void setIntersectEpsilon(const double epsilon);
00247
00248 private:
00249
00250 SbBool intersect(const SbBox3d &box,
00251 SbVec3d &enter, SbVec3d &exit) const;
00252 SbBool intersect(double angle, const SbBox3d &box) const;
00253 SbBool intersect(double angle, const SbVec3d &point) const;
00254 SbBool intersect(double angle, const SbVec3d &v0,
00255 const SbVec3d &v1, SbVec3d &pt) const;
00256 SbBool intersect(const SbVec3d &v0,
00257 const SbVec3d &v1,
00258 const SbVec3d &v2,
00259 SbVec3d &pt, SbVec3d &barycentric,
00260 SbBool &front) const;
00261
00262 SbVec3d getClosestPoint_( const SbVec3d &point,
00263 double &projlen ) const;
00264
00265 bool getClosestPoints_( const SbLined &line2,
00266 SbVec3d &ptOnThis,
00267 SbVec3d &ptOnLine2,
00268 double &s,
00269 double &t) const;
00270
00271 static
00272 bool isPointInsidePlanarRec( const SbVec3d &point, const SbVec3d &recOrig,
00273 const SbVec3d &xvers, const SbVec3d &yvers,
00274 const double extx, const double exty,
00275 double &dx, double &dy);
00276
00277 private:
00278
00279
00280 SbVec3d pos;
00281 SbVec3d dir;
00282 };
00283
00284
00285
00286 inline void SbLine::setValue( const SbLined& line )
00287 {
00288 pos.setValue( line.getPosition() );
00289 dir.setValue( line.getDirection() );
00290 }
00291
00292 inline void SbLined::setValue( const SbLine& line )
00293 {
00294 pos.setValue( line.getPosition() );
00295 dir.setValue( line.getDirection() );
00296 }
00297
00298 #endif
00299
00300
00301