For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

How get center of mass of a closed wire or face ?

Marco Balen's picture


I have to get the center point (barycenter) of a closed plane wire or of a face builder from this wire.
Is there any api that can do this ?

Thank you

Rob Bachrach's picture

Check out the BRepGProp class. The static functions fill in a GProp_GProps object with the mass properties.

Marco Balen's picture


Thank for your answer,
I have tried the GProp_PGProps::Barycentre(Pnts,Density,Mass,Centre) method to approximate the solution using the vertex of the edge of the wire but I have the problem that the number of points from one side of the shape add a weight to this side of the shape moving the baricenter near the side.

Do you know a function that calculates the geometrical baricentre of a plane shape ?

Thank you

Rob Bachrach's picture

Have you just tried the GProp_GProps::CenterOfMass() function?

Marco Balen's picture

No , I haven't,

But I cannot undestand very well how can I use this function.
Can you provide me 3 sample line of code to use it with a wire or face ?

Rob Bachrach's picture

This example uses SurfaceProperties to compute the values for a face. In theory, you could use LinearProperties for a wire, but I have not tried it.

GProp_GProps massProps;
BRepGProp::SurfaceProperties(myShape, massProps);
gp_Pnt gPt = massProps.CentreOfMass();

Marco Balen's picture

Thank you Rob,

It works well on the face. I will try with the wire.

Thank you very much for the support,


Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.