pythonCascade Sample Problems

Topology Building: Creation of wires

        self.Initialize()

        self.interactive_context.EraseAll(0,1)

 

#       The red wire is build from a single edge

        Elips = gp_Elips(gp_Ax2(gp_Pnt(250,0,0),gp_Dir(1,1,1)),160,90)

        Edge1 = BRepBuilderAPI_MakeEdge(Elips,0,math.pi/2).Edge()

        RedWire = BRepBuilderAPI_MakeWire(Edge1).Wire()

       

        red = AIS_Shape(RedWire)

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

        self.interactive_context.Display(red,1)

 

#       the yellow wire is build from an existing wire and an edge

 

        circle = gp_Circ(gp_Ax2(gp_Pnt(-300,0,0),gp_Dir(1,0,0)),80)

        Edge2 = BRepBuilderAPI_MakeEdge(circle,0,math.pi).Edge()

        ExistingWire = BRepBuilderAPI_MakeWire(Edge2).Wire()

        Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(-300,0,-80),gp_Pnt(-90,20,-30)).Edge()

        MW1 = BRepBuilderAPI_MakeWire(ExistingWire,Edge3)

        if MW1.IsDone():

            YellowWire = MW1.Wire()

 

        yellow = AIS_Shape(YellowWire)

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

        self.interactive_context.Display(yellow,1)

 

#       the white wire is built with an existing wire and 3 edges.

#       we use the methods Add, Edge and Vertex from BRepBuilderAPI_MakeWire.

 

        circle2 = gp_Circ(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,1,0)),200)

        Edge4 = BRepBuilderAPI_MakeEdge(circle2,0,math.pi).Edge()

 

        ExistingWire2 = BRepBuilderAPI_MakeWire(Edge4).Wire()

 

        P1 = gp_Pnt(0,0,-200)

        P2 = gp_Pnt(5,204,0)

        Edge5 = BRepBuilderAPI_MakeEdge(P1,P2).Edge()

        P3 = gp_Pnt(-15,20,15)

        Edge6 = BRepBuilderAPI_MakeEdge(P2,P3).Edge()

        P4 = gp_Pnt(15,20,0)

        Edge7 = BRepBuilderAPI_MakeEdge(P3,P4).Edge()

 

        MW = BRepBuilderAPI_MakeWire()

        MW.Add(ExistingWire2)

        MW.Add(Edge5)

        MW.Add(Edge6)

        MW.Add(Edge7)

 

        if MW.IsDone():

            WhiteWire = MW.Wire()

            LastEdge = MW.Edge()

            LastVertex = MW.Vertex()

       

        white = AIS_Shape(WhiteWire)

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

        self.interactive_context.Display(white,1)

 

        lastE = AIS_Shape(LastEdge)

        self.interactive_context.SetWidth(lastE,3)

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

        self.interactive_context.Display(lastE,1)

 

        lastV = AIS_Shape(LastVertex)

        self.interactive_context.Display(lastV,1)

       

        self.view.FitAll(0.01,0)

        self.view.ZFitAll(0.01)

        self.view.Redraw()