pythonCascade Sample Problems

Topological Operations: Section of shapes


 

        self.Initialize()

        self.interactive_context.EraseAll(0,1)

 

        atorus = BRepPrimAPI_MakeTorus(120,20).Shape()

 

        ashape = AIS_Shape(atorus)

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

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

        self.interactive_context.SetColor(ashape,Quantity_NOC_RED,0)

        self.interactive_context.SetTransparency(ashape,0.1,1)

        self.interactive_context.Display(ashape,1)

 

        V1 = gp_Vec(1,1,1)

        radius = 120

        for i in range(-3,4):

            asphere = BRepPrimAPI_MakeSphere(gp_Pnt(26*3*i,0,0),radius).Shape()

 

            theShape = AIS_Shape (asphere)

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

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

            self.interactive_context.SetColor(theShape,Quantity_NOC_WHITE,0)

            self.interactive_context.SetTransparency(theShape,0.1,1)

            self.interactive_context.Display(theShape,1)

 

            PerformNow = 0

            section = BRepAlgoAPI_Section(atorus,asphere,PerformNow)

            section.ComputePCurveOn1(1)

            section.Approximation(TopOpeBRepTool_APPROX)

            section.Build()

            

            asection = AIS_Shape(section.Shape())

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

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

            self.interactive_context.SetColor(asection,Quantity_NOC_WHITE,0)

            self.interactive_context.Display(asection,1)

            if i<3:

                self.interactive_context.Erase(theShape,1,0)

 

            self.view.FitAll(0.01,0)

            raw_input("press enter")

 

 

        self.view.FitAll(0.01,0)

        self.view.ZFitAll(0.01)

        self.view.Redraw()