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-2022 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 00064 class SbPlane { 00065 public: 00069 SbPlane() {} 00070 00075 SbPlane(const SbVec3f &p0, const SbVec3f &p1, const SbVec3f &p2); 00076 00082 SbPlane(const SbVec3f &normal, float distance); 00083 00089 SbPlane(const SbVec3f &normal, const SbVec3f &point); 00090 00094 void offset(float d); 00095 00100 SbBool intersect(const SbLine &l, 00101 SbVec3f &intersection) const; 00102 00106 void transform(const SbMatrix &matrix); 00107 00111 SbBool isInHalfSpace(const SbVec3f &point) const; 00112 00113 00117 const SbVec3f &getNormal() const { return normalVec; } 00121 float getDistanceFromOrigin() const { return distance; } 00122 00126 friend int operator ==(const SbPlane &p1, const SbPlane &p2); 00130 friend int operator !=(const SbPlane &p1, const SbPlane &p2) 00131 { return !(p1 == p2); } 00132 00136 float getDistance(const SbVec3f &point) const; 00137 00138 private: 00142 enum PlanePlaneIntersectionResult 00143 { 00144 DISJOINT_PARALLEL_PLANES = 0, 00145 COINCIDENT_PLANES = 1, 00146 INCIDENT_PLANES = 2, 00147 }; 00148 00155 PlanePlaneIntersectionResult intersect( const SbPlane &p, SbLine &intersection, float angTol = 10.e-3f ) const; 00156 00157 private: 00158 // Plane is all p such that normalVec . p - distance = 0 00159 00160 // Normal to the plane 00161 SbVec3f normalVec; 00162 00163 // Distance from origin to plane: distance * normalVec is on the plane 00164 float distance; 00165 00166 }; 00167 00168 00169 #endif /* _SB_PLANE_ */ 00170 00171 00172