Esempio n. 1
0
        //--------------------------------------------------------------------------------------------------

        public static Pnt CenterOfMass(this TopoDS_Shape shape)
        {
            GProp_GProps massProps = new GProp_GProps();

            BRepGProp.SurfaceProperties(shape, massProps);
            return(massProps.CentreOfMass());
        }
Esempio n. 2
0
        //--------------------------------------------------------------------------------------------------

        static string _CompareProperties(GProp_GProps gprops1, GProp_GProps gprops2, string message)
        {
            if (!gprops1.CentreOfMass().IsEqual(gprops2.CentreOfMass(), 0.00001))
            {
                return($"{message} CentreOfMass is not the same.");
            }
            if (!gprops1.Mass().IsEqual(gprops2.Mass(), 0.0001))
            {
                return($"{message} Mass is not the same.");
            }

            double ix1 = 0, iy1 = 0, iz1 = 0, ix2 = 0, iy2 = 0, iz2 = 0;

            gprops1.PrincipalProperties().Moments(ref ix1, ref iy1, ref iz1);
            gprops2.PrincipalProperties().Moments(ref ix2, ref iy2, ref iz2);
            if (!ix1.IsEqual(ix2, 0.0001))
            {
                return($"{message} MomentIx is not the same. Result: {ix1}  Reference: {ix2}");
            }
            if (!iy1.IsEqual(iy2, 0.0001))
            {
                return($"{message} MomentIy is not the same. Result: {iy1}  Reference: {iy2}");
            }
            if (!iz1.IsEqual(iz2, 0.0001))
            {
                return($"{message} MomentIz is not the same. Result: {iz1}  Reference: {iz2}");
            }

            return(_CompareMatrix(gprops1.MatrixOfInertia(), gprops2.MatrixOfInertia(), message + " MatrixOfInertia"));;
        }