Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-27 09:17:47

0001 // Created on: 1992-02-14
0002 // Created by: Jean Claude VAUTHIER
0003 // Copyright (c) 1992-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _GProp_PGProps_HeaderFile
0018 #define _GProp_PGProps_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <GProp_GProps.hxx>
0024 #include <gp_Pnt.hxx>
0025 #include <NCollection_Array1.hxx>
0026 #include <NCollection_Array2.hxx>
0027 
0028 //! Computes global properties (mass, barycentre, inertia matrix) of a
0029 //! weighted set of 3D points.
0030 //!
0031 //! Each point carries a mass; by default the mass is unit. Contributions are
0032 //! accumulated incrementally via AddPoint() or from arrays passed to a
0033 //! constructor. As a GProp_GProps subclass, an instance can be composed
0034 //! into a larger system via GProp_GProps::Add().
0035 //!
0036 //! Inertia is accumulated at the absolute origin and stored in the inherited
0037 //! GProp_GProps::inertia member, matching the legacy contract of this class.
0038 class GProp_PGProps : public GProp_GProps
0039 {
0040 public:
0041   DEFINE_STANDARD_ALLOC
0042 
0043   //! Creates an empty point set, located at the origin, with zero mass.
0044   Standard_EXPORT GProp_PGProps();
0045 
0046   //! Creates a point set from an array of points (unit mass each).
0047   Standard_EXPORT explicit GProp_PGProps(const NCollection_Array1<gp_Pnt>& thePnts);
0048 
0049   //! Creates a point set from a 2D array of points (unit mass each).
0050   Standard_EXPORT explicit GProp_PGProps(const NCollection_Array2<gp_Pnt>& thePnts);
0051 
0052   //! Creates a point set from points and corresponding densities.
0053   //! @param[in] thePnts    point array
0054   //! @param[in] theDensity per-point mass array (same length as thePnts)
0055   //! @throws Standard_DomainError if a density <= gp::Resolution() or if the
0056   //!         arrays have different lengths.
0057   Standard_EXPORT GProp_PGProps(const NCollection_Array1<gp_Pnt>& thePnts,
0058                                 const NCollection_Array1<double>& theDensity);
0059 
0060   //! Creates a point set from 2D arrays of points and corresponding densities.
0061   //! @param[in] thePnts    point array
0062   //! @param[in] theDensity per-point mass array (same dimensions as thePnts)
0063   //! @throws Standard_DomainError on dimension mismatch or non-positive density.
0064   Standard_EXPORT GProp_PGProps(const NCollection_Array2<gp_Pnt>& thePnts,
0065                                 const NCollection_Array2<double>& theDensity);
0066 
0067   //! Adds a point with unit mass.
0068   Standard_EXPORT void AddPoint(const gp_Pnt& thePnt);
0069 
0070   //! Adds a point with a given mass.
0071   //! @throws Standard_DomainError if theDensity <= gp::Resolution().
0072   Standard_EXPORT void AddPoint(const gp_Pnt& thePnt, double theDensity);
0073 
0074   //! Computes the barycentre of a set of points (unit mass).
0075   Standard_EXPORT static gp_Pnt Barycentre(const NCollection_Array1<gp_Pnt>& thePnts);
0076 
0077   //! Computes the barycentre of a 2D array of points (unit mass).
0078   Standard_EXPORT static gp_Pnt Barycentre(const NCollection_Array2<gp_Pnt>& thePnts);
0079 
0080   //! Computes the weighted barycentre and total mass of a set of points.
0081   //! @param[in]  thePnts    point array
0082   //! @param[in]  theDensity per-point mass array
0083   //! @param[out] theMass    total mass (sum of densities)
0084   //! @param[out] theG       weighted barycentre
0085   //! @throws Standard_DimensionError on length mismatch.
0086   Standard_EXPORT static void Barycentre(const NCollection_Array1<gp_Pnt>& thePnts,
0087                                          const NCollection_Array1<double>& theDensity,
0088                                          double&                           theMass,
0089                                          gp_Pnt&                           theG);
0090 
0091   //! Computes the weighted barycentre and total mass for a 2D point array.
0092   //! @throws Standard_DimensionError on dimension mismatch.
0093   Standard_EXPORT static void Barycentre(const NCollection_Array2<gp_Pnt>& thePnts,
0094                                          const NCollection_Array2<double>& theDensity,
0095                                          double&                           theMass,
0096                                          gp_Pnt&                           theG);
0097 };
0098 
0099 #endif // _GProp_PGProps_HeaderFile