pythonCascade Sample Problems

Topology Analysis: Compute volume properties

 

        self.Initialize()

        self.interactive_context.EraseAll(0,1)

 

        S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.).Shape()

        ais1 = AIS_Shape(S)

        self.interactive_context.SetDisplayMode(ais1,AIS_Shaded,0)

        self.interactive_context.SetMaterial(ais1,Graphic3d_NOM_PLASTIC,0)

        self.interactive_context.SetColor(ais1,Quantity_NOC_GREEN,0)

        self.interactive_context.Display(ais1,1)

 

 

        System = GProp_GProps()

        BRepGProp().VolumeProperties(S,System)

        G = System.CentreOfMass ()

        Area = System.Mass()

        I = System.MatrixOfInertia()

 

        print "Volume Of all the Shape =" + `Area`

        print "CenterOfMass :"

        print " X="+`G.X()`+" Y="+`G.Y()`+" Z="+`G.Z()`

        print "Matrix of Inertia :     "

        print "  "+`I.Value(1,1)`+"  "+`I.Value(1,2)`+"  "+`I.Value(1,3)`

        print "  "+`I.Value(2,1)`+"  "+`I.Value(2,2)`+"  "+`I.Value(2,3)`

        print "  "+`I.Value(3,1)`+"  "+`I.Value(3,2)`+"  "+`I.Value(3,3)`

 

        self.view.FitAll(0.01,0)

        self.view.ZFitAll(0.01)

        self.view.Redraw()