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 #ifndef SEGMENT_H
00028 #define SEGMENT_H
00029
00030 #include "Point.h"
00031 #include "Parallelepiped.h"
00032 #include "QGpCoreToolsDLLExport.h"
00033
00034 namespace QGpCoreTools {
00035
00036 class QGPCORETOOLS_EXPORT Segment
00037 {
00038 public:
00039 Segment() {}
00040 Segment(const Point& p1, const Point& p2) {set(p1,p2);}
00041 Segment(double x1, double y1, double z1,
00042 double x2, double y2, double z2) {set(x1, y1, z1,
00043 x2, y2, z2);}
00044 Segment(const Segment& o);
00045
00046 enum RelativePosition {Skew, Crossing, Parallel, Aligned,
00047 Continuous, SmallOverlap, StrongOverlap};
00048 bool intersects(const Segment& seg, Point& p) const;
00049 QVector<Segment> distanceTo(const Segment& seg, RelativePosition& relPos) const;
00050
00051 Point point(int index) const {return _point[index];}
00052 void set(const Point& p1, const Point& p2);
00053 void set(double x1, double y1, double z1,
00054 double x2, double y2, double z2);
00055 bool includes(const Point& p, double precision=1e-10) const;
00056 double length() const {return _point[0].distanceTo(_point[1]);}
00057 Point directionVector() const;
00058 bool parallelTo(const Segment& o) const;
00059
00060 bool isSimilar(const Segment& o, double precision) const;
00061 bool operator<(const Segment& o) const;
00062 private:
00063 inline Segment linkSegment(double sc, double tc,
00064 Point p, const Point& u,
00065 Point q, const Point& v) const;
00066
00067
00068 Point _point[2];
00069 Parallelepiped _limits;
00070 };
00071
00072 }
00073
00074 #endif // SEGMENT_H