1 // Created on: 1993-06-16 2 // Created by: Isabelle GRIGNON 3 // Copyright (c) 1993-1999 Matra Datavision 4 // Copyright (c) 1999-2014 OPEN CASCADE SAS 5 // 6 // This file is part of Open CASCADE Technology software library. 7 // 8 // This library is free software; you can redistribute it and/or modify it under 9 // the terms of the GNU Lesser General Public License version 2.1 as published 10 // by the Free Software Foundation, with special exception defined in the file 11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 12 // distribution for complete text of the license and disclaimer of any warranty. 13 // 14 // Alternatively, this file may be used under the terms of Open CASCADE 15 // commercial license or contractual agreement. 16 17 #ifndef _GProp_PEquation_HeaderFile 18 #define _GProp_PEquation_HeaderFile 19 20 #include <Standard.hxx> 21 #include <Standard_DefineAlloc.hxx> 22 #include <Standard_Handle.hxx> 23 24 #include <GProp_EquaType.hxx> 25 #include <gp_Pnt.hxx> 26 #include <gp_Vec.hxx> 27 #include <TColgp_Array1OfPnt.hxx> 28 #include <Standard_Real.hxx> 29 #include <Standard_Boolean.hxx> 30 class gp_Pln; 31 class gp_Lin; 32 33 34 //! A framework to analyze a collection - or cloud 35 //! - of points and to verify if they are coincident, 36 //! collinear or coplanar within a given precision. If 37 //! so, it also computes the mean point, the mean 38 //! line or the mean plane of the points. If not, it 39 //! computes the minimal box which includes all the points. 40 class GProp_PEquation 41 { 42 public: 43 44 DEFINE_STANDARD_ALLOC 45 46 47 //! Constructs a framework to analyze the 48 //! collection of points Pnts and computes: 49 //! - the mean point if the points in question are 50 //! considered to be coincident within the precision Tol, or 51 //! - the mean line if they are considered to be 52 //! collinear within the precision Tol, or 53 //! - the mean plane if they are considered to be 54 //! coplanar within the precision Tol, or 55 //! - the minimal box which contains all the points. Use : 56 //! - the functions IsPoint, IsLinear, IsPlanar 57 //! and IsSpace to find the result of the analysis, and 58 //! - the function Point, Line, Plane or Box to 59 //! access the computed result. 60 Standard_EXPORT GProp_PEquation(const TColgp_Array1OfPnt& Pnts, const Standard_Real Tol); 61 62 //! Returns true if, according to the given 63 //! tolerance, the points analyzed by this framework are coplanar. 64 //! Use the function Plane to access the computed result. 65 Standard_EXPORT Standard_Boolean IsPlanar() const; 66 67 //! Returns true if, according to the given 68 //! tolerance, the points analyzed by this framework are colinear. 69 //! Use the function Line to access the computed result. 70 Standard_EXPORT Standard_Boolean IsLinear() const; 71 72 //! Returns true if, according to the given 73 //! tolerance, the points analyzed by this framework are coincident. 74 //! Use the function Point to access the computed result. 75 Standard_EXPORT Standard_Boolean IsPoint() const; 76 77 //! Returns true if, according to the given 78 //! tolerance value, the points analyzed by this 79 //! framework are neither coincident, nor collinear, nor coplanar. 80 //! Use the function Box to query the smallest box 81 //! that includes the collection of points. 82 Standard_EXPORT Standard_Boolean IsSpace() const; 83 84 //! Returns the mean plane passing near all the 85 //! points analyzed by this framework if, according 86 //! to the given precision, the points are considered to be coplanar. 87 //! Exceptions 88 //! Standard_NoSuchObject if, according to the 89 //! given precision value, the points analyzed by 90 //! this framework are considered to be: 91 //! - coincident, or 92 //! - collinear, or 93 //! - not coplanar. 94 Standard_EXPORT gp_Pln Plane() const; 95 96 //! Returns the mean line passing near all the 97 //! points analyzed by this framework if, according 98 //! to the given precision value, the points are considered to be collinear. 99 //! Exceptions 100 //! Standard_NoSuchObject if, according to the 101 //! given precision, the points analyzed by this 102 //! framework are considered to be: 103 //! - coincident, or 104 //! - not collinear. 105 Standard_EXPORT gp_Lin Line() const; 106 107 //! Returns the mean point of all the points 108 //! analyzed by this framework if, according to the 109 //! given precision, the points are considered to be coincident. 110 //! Exceptions 111 //! Standard_NoSuchObject if, according to the 112 //! given precision, the points analyzed by this 113 //! framework are not considered to be coincident. 114 Standard_EXPORT gp_Pnt Point() const; 115 116 //! Returns the definition of the smallest box which 117 //! contains all the points analyzed by this 118 //! framework if, according to the given precision 119 //! value, the points are considered to be neither 120 //! coincident, nor collinear and nor coplanar. 121 //! This box is centered on the barycenter P of the 122 //! collection of points. Its sides are parallel to the 123 //! three vectors V1, V2 and V3, the length of 124 //! which is the length of the box in the corresponding direction. 125 //! Note: Vectors V1, V2 and V3 are parallel to 126 //! the three axes of principal inertia of the system 127 //! composed of the collection of points where each point is of equal mass. 128 //! Exceptions 129 //! Standard_NoSuchObject if, according to the given precision, 130 //! the points analyzed by this framework are considered to be coincident, collinear or coplanar. 131 Standard_EXPORT void Box (gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const; 132 133 134 135 136 protected: 137 138 139 140 141 142 private: 143 144 145 146 GProp_EquaType type; 147 gp_Pnt g; 148 gp_Vec v1; 149 gp_Vec v2; 150 gp_Vec v3; 151 152 153 }; 154 155 156 157 158 159 160 161 #endif // _GProp_PEquation_HeaderFile 162