42cf5bc1 |
1 | // Created on: 1992-02-14 |
2 | // Created by: Jean Claude VAUTHIER |
3 | // Copyright (c) 1992-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_PGProps_HeaderFile |
18 | #define _GProp_PGProps_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <GProp_GProps.hxx> |
25 | #include <Standard_Real.hxx> |
26 | #include <TColgp_Array1OfPnt.hxx> |
27 | #include <TColgp_Array2OfPnt.hxx> |
28 | #include <TColStd_Array1OfReal.hxx> |
29 | #include <TColStd_Array2OfReal.hxx> |
30 | class Standard_DimensionError; |
31 | class Standard_DomainError; |
32 | class gp_Pnt; |
33 | |
34 | |
35 | //! A framework for computing the global properties of a |
36 | //! set of points. |
37 | //! A point mass is attached to each point. The global |
38 | //! mass of the system is the sum of each individual |
39 | //! mass. By default, the point mass is equal to 1 and the |
40 | //! mass of a system composed of N points is equal to N. |
41 | //! Warning |
42 | //! A framework of this sort provides functions to handle |
43 | //! sets of points easily. But, like any GProp_GProps |
44 | //! object, by using the Add function, it can theoretically |
45 | //! bring together the computed global properties and |
46 | //! those of a system more complex than a set of points . |
47 | //! The mass of each point and the density of each |
48 | //! component of the composed system must be |
49 | //! coherent. Note that this coherence cannot be checked. |
50 | //! Nonetheless, you are advised to restrict your use of a |
51 | //! GProp_PGProps object to a set of points and to |
52 | //! create a GProp_GProps object in order to bring |
53 | //! together global properties of different systems. |
54 | class GProp_PGProps : public GProp_GProps |
55 | { |
56 | public: |
57 | |
58 | DEFINE_STANDARD_ALLOC |
59 | |
60 | |
61 | //! Initializes a framework to compute global properties |
62 | //! on a set of points. |
63 | //! The point relative to which the inertia of the system is |
64 | //! computed will be the origin (0, 0, 0) of the |
65 | //! absolute Cartesian coordinate system. |
66 | //! At initialization, the framework is empty, i.e. it retains |
67 | //! no dimensional information such as mass and inertia. |
68 | //! It is, however, now able to keep global properties of a |
69 | //! set of points while new points are added using the |
70 | //! AddPoint function. |
71 | //! The set of points whose global properties are brought |
72 | //! together by this framework will then be referred to as |
73 | //! the current system. The current system is, however, |
74 | //! not kept by this framework, which only keeps that |
75 | //! system's global properties. Note that the current |
76 | //! system may be more complex than a set of points. |
77 | Standard_EXPORT GProp_PGProps(); |
78 | |
79 | //! Brings together the global properties already |
80 | //! retained by this framework with those induced by |
81 | //! the point Pnt. Pnt may be the first point of the current system. |
82 | //! A point mass is attached to the point Pnt, it is either |
83 | //! equal to 1. or to Density. |
84 | Standard_EXPORT void AddPoint (const gp_Pnt& P); |
85 | |
86 | |
87 | //! Adds a new point P with its density in the system of points |
88 | //! Exceptions |
89 | //! Standard_DomainError if the mass value Density |
90 | //! is less than gp::Resolution(). |
91 | Standard_EXPORT void AddPoint (const gp_Pnt& P, const Standard_Real Density); |
92 | |
93 | |
94 | //! computes the global properties of the system of points Pnts. |
95 | //! The density of the points are defaulted to all being 1 |
96 | Standard_EXPORT GProp_PGProps(const TColgp_Array1OfPnt& Pnts); |
97 | |
98 | |
99 | //! computes the global properties of the system of points Pnts. |
100 | //! The density of the points are defaulted to all being 1 |
101 | Standard_EXPORT GProp_PGProps(const TColgp_Array2OfPnt& Pnts); |
102 | |
103 | |
104 | //! computes the global properties of the system of points Pnts. |
105 | //! A density is associated with each point. |
106 | //! |
107 | //! raises if a density is lower or equal to Resolution from package |
108 | //! gp. |
109 | //! |
110 | //! raises if the length of Pnts and the length of Density |
111 | //! is not the same. |
112 | Standard_EXPORT GProp_PGProps(const TColgp_Array1OfPnt& Pnts, const TColStd_Array1OfReal& Density); |
113 | |
114 | |
115 | //! computes the global properties of the system of points Pnts. |
116 | //! A density is associated with each point. |
117 | //! |
118 | //! Raised if a density is lower or equal to Resolution from package |
119 | //! gp. |
120 | //! |
121 | //! Raised if the length of Pnts and the length of Density |
122 | //! is not the same. |
123 | Standard_EXPORT GProp_PGProps(const TColgp_Array2OfPnt& Pnts, const TColStd_Array2OfReal& Density); |
124 | |
125 | |
126 | //! Computes the barycentre of a set of points. The density of the |
127 | //! points is defaulted to 1. |
128 | Standard_EXPORT static gp_Pnt Barycentre (const TColgp_Array1OfPnt& Pnts); |
129 | |
130 | |
131 | //! Computes the barycentre of a set of points. The density of the |
132 | //! points is defaulted to 1. |
133 | Standard_EXPORT static gp_Pnt Barycentre (const TColgp_Array2OfPnt& Pnts); |
134 | |
135 | |
136 | //! Computes the barycentre of a set of points. A density is associated |
137 | //! with each point. |
138 | //! |
139 | //! raises if a density is lower or equal to Resolution from package |
140 | //! gp. |
141 | //! |
142 | //! Raised if the length of Pnts and the length of Density |
143 | //! is not the same. |
144 | Standard_EXPORT static void Barycentre (const TColgp_Array1OfPnt& Pnts, const TColStd_Array1OfReal& Density, Standard_Real& Mass, gp_Pnt& G); |
145 | |
146 | |
147 | //! Computes the barycentre of a set of points. A density is associated |
148 | //! with each point. |
149 | //! |
150 | //! Raised if a density is lower or equal to Resolution from package |
151 | //! gp. |
152 | //! |
153 | //! Raised if the length of Pnts and the length of Density |
154 | //! is not the same. |
155 | Standard_EXPORT static void Barycentre (const TColgp_Array2OfPnt& Pnts, const TColStd_Array2OfReal& Density, Standard_Real& Mass, gp_Pnt& G); |
156 | |
157 | |
158 | |
159 | |
160 | protected: |
161 | |
162 | |
163 | |
164 | |
165 | |
166 | private: |
167 | |
168 | |
169 | |
170 | |
171 | |
172 | }; |
173 | |
174 | |
175 | |
176 | |
177 | |
178 | |
179 | |
180 | #endif // _GProp_PGProps_HeaderFile |