pythonCascade Sample Problems

Topological Operations: Cut of two shapes


        self.Initialize()

        self.interactive_context.EraseAll(0,1)

 

        theBox = BRepPrimAPI_MakeBox(200,60,60).Shape()

        ais1 = AIS_Shape(theBox)

        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)

 

        theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(100,20,20),80).Shape()

        ais2 = AIS_Shape(theSphere)

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

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

        self.interactive_context.SetColor(ais2,Quantity_NOC_YELLOW,0)

        self.interactive_context.Display(ais2,1)

   

        self.view.FitAll(0.01,0)

        self.view.ZFitAll(0.01)

        self.view.Redraw()

           

        raw_input("press enter")

 

        ShapeCut = BRepAlgoAPI_Cut(theSphere,theBox).Shape()

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

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

        aSection = AIS_Shape(ShapeCut)

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

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

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

        self.interactive_context.Display(aSection,1)

       

        self.view.FitAll(0.01,0)

        self.view.ZFitAll(0.01)

        self.view.Redraw()