00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : VSG (MMM YYYY) 00022 **=======================================================================*/ 00023 #ifndef _SB_PLANE_ 00024 #define _SB_PLANE_ 00025 00026 #include <Inventor/SbVec.h> 00027 00028 class SbLine; 00029 class SbMatrix; 00030 00032 // 00033 // Class: SbPlane 00034 // 00035 // Represents an oriented plane in 3D space. The plane is defined by 00036 // a plane normal and a distance from the origin along that normal. 00037 // SbPlanes may be used to represent either planes or half-spaces. In 00038 // the latter case (as for the isInHalfSpace() method), the 00039 // half-space is defined to be all points on the plane or on the side 00040 // of the plane in the direction of the plane normal. 00041 // 00042 // The 4 coefficients of the plane equation of an SbPlane can be 00043 // obtained easily as the 3 coordinates of the plane normal and the 00044 // distance, in that order. 00045 // 00047 00048 00065 class SbPlane { 00066 public: 00070 SbPlane() {} 00071 00076 SbPlane(const SbVec3f &p0, const SbVec3f &p1, const SbVec3f &p2); 00077 00083 SbPlane(const SbVec3f &normal, float distance); 00084 00090 SbPlane(const SbVec3f &normal, const SbVec3f &point); 00091 00095 void offset(float d); 00096 00101 SbBool intersect(const SbLine &l, 00102 SbVec3f &intersection) const; 00103 00107 void transform(const SbMatrix &matrix); 00108 00112 SbBool isInHalfSpace(const SbVec3f &point) const; 00113 00114 00118 const SbVec3f &getNormal() const { return normalVec; } 00122 float getDistanceFromOrigin() const { return distance; } 00123 00127 friend int operator ==(const SbPlane &p1, const SbPlane &p2); 00131 friend int operator !=(const SbPlane &p1, const SbPlane &p2) 00132 { return !(p1 == p2); } 00133 00137 float getDistance(const SbVec3f &point) const; 00138 00139 private: 00143 enum PlanePlaneIntersectionResult 00144 { 00145 DISJOINT_PARALLEL_PLANES = 0, 00146 COINCIDENT_PLANES = 1, 00147 INCIDENT_PLANES = 2, 00148 }; 00149 00156 PlanePlaneIntersectionResult intersect( const SbPlane &p, SbLine &intersection, float angTol = 10.e-3 ) const; 00157 00158 private: 00159 // Plane is all p such that normalVec . p - distance = 0 00160 00161 // Normal to the plane 00162 SbVec3f normalVec; 00163 00164 // Distance from origin to plane: distance * normalVec is on the plane 00165 float distance; 00166 00167 }; 00168 00169 00170 #endif /* _SB_PLANE_ */ 00171 00172 00173