0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / GProp / GProp_PEquation.hxx
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 Standard_NoSuchObject;
31 class gp_Pln;
32 class gp_Lin;
33 class gp_Pnt;
34 class gp_Vec;
35
36
37 //! A framework to analyze a collection - or cloud
38 //! - of points and to verify if they are coincident,
39 //! collinear or coplanar within a given precision. If
40 //! so, it also computes the mean point, the mean
41 //! line or the mean plane of the points. If not, it
42 //! computes the minimal box which includes all the points.
43 class GProp_PEquation 
44 {
45 public:
46
47   DEFINE_STANDARD_ALLOC
48
49   
50   //! Constructs a framework to analyze the
51   //! collection of points Pnts and computes:
52   //! -   the mean point if the points in question are
53   //! considered to be coincident within the precision Tol, or
54   //! -   the mean line if they are considered to be
55   //! collinear within the precision Tol, or
56   //! -   the mean plane if they are considered to be
57   //! coplanar within the precision Tol, or
58   //! -   the minimal box which contains all the points. Use :
59   //! -   the functions IsPoint, IsLinear, IsPlanar
60   //! and IsSpace to find the result of the analysis, and
61   //! -   the function Point, Line, Plane or Box to
62   //! access the computed result.
63   Standard_EXPORT GProp_PEquation(const TColgp_Array1OfPnt& Pnts, const Standard_Real Tol);
64   
65   //! Returns true if, according to the given
66   //! tolerance, the points analyzed by this framework are  coplanar.
67   //! Use the function  Plane  to access the computed result.
68   Standard_EXPORT Standard_Boolean IsPlanar() const;
69   
70   //! Returns true if, according to the given
71   //! tolerance, the points analyzed by this framework are  colinear.
72   //! Use the function  Line  to access the computed result.
73   Standard_EXPORT Standard_Boolean IsLinear() const;
74   
75   //! Returns true if, according to the given
76   //! tolerance, the points analyzed by this framework are  coincident.
77   //! Use the function  Point  to access the computed result.
78   Standard_EXPORT Standard_Boolean IsPoint() const;
79   
80   //! Returns true if, according to the given
81   //! tolerance value, the points analyzed by this
82   //! framework are neither coincident, nor collinear, nor coplanar.
83   //! Use the function Box to query the smallest box
84   //! that includes the collection of points.
85   Standard_EXPORT Standard_Boolean IsSpace() const;
86   
87   //! Returns the mean plane passing near all the
88   //! points analyzed by this framework if, according
89   //! to the given precision, the points are considered to be coplanar.
90   //! Exceptions
91   //! Standard_NoSuchObject if, according to the
92   //! given precision value, the points analyzed by
93   //! this framework are considered to be:
94   //! -   coincident, or
95   //! -   collinear, or
96   //! -   not coplanar.
97   Standard_EXPORT gp_Pln Plane() const;
98   
99   //! Returns the mean line passing near all the
100   //! points analyzed by this framework if, according
101   //! to the given precision value, the points are considered to be collinear.
102   //! Exceptions
103   //! Standard_NoSuchObject if, according to the
104   //! given precision, the points analyzed by this
105   //! framework are considered to be:
106   //! -   coincident, or
107   //! -   not collinear.
108   Standard_EXPORT gp_Lin Line() const;
109   
110   //! Returns the mean point of all the points
111   //! analyzed by this framework if, according to the
112   //! given precision, the points are considered to be coincident.
113   //! Exceptions
114   //! Standard_NoSuchObject if, according to the
115   //! given precision, the points analyzed by this
116   //! framework are not considered to be coincident.
117   Standard_EXPORT gp_Pnt Point() const;
118   
119   //! Returns the definition of the smallest box which
120   //! contains all the points analyzed by this
121   //! framework if, according to the given precision
122   //! value, the points are considered to be neither
123   //! coincident, nor collinear and nor coplanar.
124   //! This box is centered on the barycenter P of the
125   //! collection of points. Its sides are parallel to the
126   //! three vectors V1, V2 and V3, the length of
127   //! which is the length of the box in the corresponding direction.
128   //! Note: Vectors V1, V2 and V3 are parallel to
129   //! the three axes of principal inertia of the system
130   //! composed of the collection of points where each point is of equal mass.
131   //! Exceptions
132   //! Standard_NoSuchObject if, according to the given precision,
133   //! the points analyzed by this framework are considered to be coincident, collinear or coplanar.
134   Standard_EXPORT void Box (gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const;
135
136
137
138
139 protected:
140
141
142
143
144
145 private:
146
147
148
149   GProp_EquaType type;
150   gp_Pnt g;
151   gp_Vec v1;
152   gp_Vec v2;
153   gp_Vec v3;
154
155
156 };
157
158
159
160
161
162
163
164 #endif // _GProp_PEquation_HeaderFile