4b114473 |
1 | // Copyright (c) 2018 OPEN CASCADE SAS |
2 | // This file is part of commercial software by OPEN CASCADE SAS, |
3 | // furnished in accordance with the terms and conditions of the contract |
4 | // and with the inclusion of this copyright notice. |
5 | // This file or any part thereof may not be provided or otherwise |
6 | // made available to any third party. |
7 | // |
8 | // No ownership title to the software is transferred hereby. |
9 | // |
10 | // OPEN CASCADE SAS makes no representation or warranties with respect to the |
11 | // performance of this software, and specifically disclaims any responsibility |
12 | // for any damages, special or consequential, connected with its use. |
13 | |
14 | #ifndef _BRepGProp_MeshProps_HeaderFile |
15 | #define _BRepGProp_MeshProps_HeaderFile |
16 | |
17 | #include <Standard.hxx> |
18 | #include <Standard_DefineAlloc.hxx> |
19 | #include <Standard_Handle.hxx> |
20 | #include <Standard_Type.hxx> |
21 | #include <GProp_GProps.hxx> |
22 | #include <TopAbs_Orientation.hxx> |
23 | #include <Poly_Array1OfTriangle.hxx> |
24 | #include <TColgp_Array1OfPnt.hxx> |
25 | |
26 | class Poly_Triangulation; |
27 | class TopLoc_Location; |
28 | class gp_Pnt; |
29 | |
30 | |
31 | //! Computes the global properties of a surface mesh. The mesh can be |
32 | //! interpreted as just a surface or as a piece of volume limited by this surface. |
33 | class BRepGProp_MeshProps : public GProp_GProps |
34 | { |
35 | public: |
36 | |
37 | DEFINE_STANDARD_ALLOC |
38 | |
39 | //! Describes types of geometric objects. |
40 | //! - Vinert is 3D closed region of space delimited with |
41 | //! Point and surface mesh; |
42 | //! - Sinert is surface mesh in 3D space. |
43 | typedef enum { Vinert = 0, Sinert } BRepGProp_MeshObjType; |
44 | |
45 | //! Constructor takes the type of object. |
46 | BRepGProp_MeshProps(const BRepGProp_MeshObjType theType) : |
47 | myType(theType) |
48 | {} |
49 | |
50 | //! Sets the point relative which the calculation is to be done |
51 | void SetLocation(const gp_Pnt& theLocation) { loc = theLocation; } |
52 | |
53 | //! Computes the global properties of a surface mesh of 3D space. |
54 | //! Calculation of surface properties is performed by numerical integration |
55 | //! over triangle surfaces using Gauss cubature formulas. |
56 | //! Depending on the mesh object type used in constructor this method can |
57 | //! calculate the surface or volume properties of the mesh. |
58 | Standard_EXPORT void Perform(const Handle(Poly_Triangulation)& theMesh, |
59 | const TopLoc_Location& theLoc, |
60 | const TopAbs_Orientation theOri); |
61 | |
62 | Standard_EXPORT void Perform(const TColgp_Array1OfPnt& theNodes, |
63 | const Poly_Array1OfTriangle& theTriangles, |
64 | const TopAbs_Orientation theOri); |
65 | |
66 | //! Computes the global properties of triangle {p1, p2, p3} relatively |
67 | //! point Apex |
68 | //! If isVolume = true, volume properties are calculated |
69 | //! otherwise - surface ones |
70 | Standard_EXPORT static void CalculateProps(const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, |
71 | const gp_Pnt& Apex, |
72 | const Standard_Boolean isVolume, |
73 | Standard_Real GProps[10], |
74 | const Standard_Integer NbGaussPoints, |
75 | const Standard_Real* GaussPnts); |
76 | |
77 | //! Get type of mesh object |
78 | BRepGProp_MeshObjType GetMeshObjType() const |
79 | { |
80 | return myType; |
81 | } |
82 | |
83 | private: //! @name private fields |
84 | |
85 | |
86 | BRepGProp_MeshObjType myType; //!< Type of geometric object |
87 | |
88 | }; |
89 | |
90 | #endif // _BRepGProp_MeshProps_HeaderFile |