pythonCascade Sample Problems

Topological Operations: Variable fillet creation

        self.Initialize()

        self.interactive_context.EraseAll(0,1)

 

        theBox = BRepPrimAPI_MakeBox(200,200,200).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_BROWN,0)

        self.interactive_context.Display(ais1,1)

        self.view.FitAll(0.01,0)

 

        raw_input("press enter")

 

 

        Rake = BRepFilletAPI_MakeFillet(theBox)

        

        ex = TopExp_Explorer(theBox,TopAbs_EDGE)

        ex.Next()

        ex.Next()

        ex.Next()

        ex.Next()

        Rake.Add(8,50,TopoDS().Edge(ex.Current()))

        Rake.Build()

        if Rake.IsDone():

            evolvedBox = Rake.Shape();

            ais1.Set(evolvedBox)

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

 

        raw_input("press enter")

 

        theCylinder = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-300,0,0),gp_Dir(0,0,1)),100,200).Shape()

        ais3 = AIS_Shape(theCylinder)

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

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

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

        self.interactive_context.Display(ais3,1)

        self.view.FitAll(0.01,0)

 

        raw_input("press enter")

        fillet = BRepFilletAPI_MakeFillet(theCylinder)

 

        TabPoint2 = []

        for i in range(0,20):

            Point2d = gp_Pnt2d(i*2*math.pi/19,60*math.cos(i*math.pi/19-math.pi/2)+10)

            TabPoint2.append(Point2d)

 

        exp2 = TopExp_Explorer(theCylinder,TopAbs_EDGE)

        fillet.Add(TabPoint2,TopoDS().Edge(exp2.Current()))

        fillet.Build()

       

        if fillet.IsDone():

            LawEvolvedCylinder = fillet.Shape()

            ais3.Set(LawEvolvedCylinder)

            self.interactive_context.Redisplay(ais3,1,0)

 

        raw_input("press enter")

 

        P = gp_Pnt(350,0,0)

        theBox2 = BRepPrimAPI_MakeBox(P,200,200,200).Shape()

        ais2 = AIS_Shape(theBox2)

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

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

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

        self.interactive_context.Display(ais2,1)

        self.view.FitAll(0.01,0)

 

        raw_input("press enter")

        afillet = BRepFilletAPI_MakeFillet(theBox2)

 

        TabPoint = []

 

        P1 = gp_Pnt2d(0.,8.)

        P2 = gp_Pnt2d(0.2,16.)

        P3 = gp_Pnt2d(0.4,25.)

        P4 = gp_Pnt2d(0.6,55.)

        P5 = gp_Pnt2d(0.8,28.)

        P6 = gp_Pnt2d(1.,20.)

        TabPoint.append(P1)

        TabPoint.append(P2)

        TabPoint.append(P3)

        TabPoint.append(P4)

        TabPoint.append(P5)

        TabPoint.append(P6)

       

        exp = TopExp_Explorer(theBox2,TopAbs_EDGE)

        exp.Next()

        exp.Next()

        exp.Next()

        exp.Next()

 

        afillet.Add(TabPoint, TopoDS().Edge(exp.Current()))

       

        afillet.Build()

       

        if afillet.IsDone():

            LawEvolvedBox = afillet.Shape()

            ais2.Set(LawEvolvedBox)

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

 

 

        self.view.FitAll(0.01,0)

        self.view.ZFitAll(0.01)

        self.view.Redraw()