pythonCascade Sample Problems

Topology Local Operations: Prism


 

        self.Initialize()

        self.interactive_context.EraseAll(0,1)

 

        S = BRepPrimAPI_MakeBox(400,250,300).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)

        self.view.FitAll(0.01,0)

        Ex = TopExp_Explorer()

        Ex.Init(S,TopAbs_FACE);

        Ex.Next()

        F = TopoDS().Face(Ex.Current())

        surf = BRep_Tool().Surface(F)

        Pl = Geom_Plane().DownCast(surf)

        D = Pl.Pln().Axis().Direction()

        D.Reverse()

       

        MW = BRepBuilderAPI_MakeWire()

        p1 = gp_Pnt2d(200.,-100.)

        p2 = gp_Pnt2d(100.,-100.)

        aline = GCE2d_MakeLine(p1,p2).Value()

        MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)).Edge())

        p1 = p2;

        p2 = gp_Pnt2d(100.,-200.)

        aline = GCE2d_MakeLine(p1,p2).Value()

        MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)).Edge())

        p1 = p2

        p2 = gp_Pnt2d(200.,-200.)

        aline = GCE2d_MakeLine(p1,p2).Value()

        MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)).Edge())

        p1 = p2

        p2 = gp_Pnt2d(200.,-100.)

        aline = GCE2d_MakeLine(p1,p2).Value()

        MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)).Edge())

       

        MKF = BRepBuilderAPI_MakeFace()

        MKF.Init(surf,0)

        MKF.Add(MW.Wire())

 

        FP = MKF.Face()

        BRepLib().BuildCurves3d(FP)

        MKP = BRepFeat_MakePrism(S,FP,F,D,0,1)

        MKP.Perform(200.)

        res1 = MKP.Shape()

   

        ais1.Set(res1)

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

 

        Ex.Next()

        F2 = TopoDS().Face(Ex.Current())

        surf = BRep_Tool().Surface(F2)

        Pl = Geom_Plane().DownCast(surf)

        D = Pl.Pln().Axis().Direction()

        D.Reverse()

 

        MW2 = BRepBuilderAPI_MakeWire()

        p1 = gp_Pnt2d(100.,100.)

        p2 = gp_Pnt2d(200.,100.)

        aline = GCE2d_MakeLine(p1,p2).Value()

        MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)).Edge())

        p1 = p2

        p2 = gp_Pnt2d(150.,200.)

        aline = GCE2d_MakeLine(p1,p2).Value()

        MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)).Edge())

        p1 = p2

        p2 = gp_Pnt2d(100.,100.)

        aline = GCE2d_MakeLine(p1,p2).Value();

        MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)).Edge())

 

        MKF2 = BRepBuilderAPI_MakeFace()

        MKF2.Init(surf,0)

        MKF2.Add(MW2.Wire())

 

        FP = MKF2.Face()

        BRepLib().BuildCurves3d(FP)

        MKP2 = BRepFeat_MakePrism(res1,FP,F2,D,1,1)

        MKP2.Perform(100.)

        res2 = MKP2.Shape()

   

        ais1.Set(res2)

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

 

 

       

        self.view.FitAll(0.01,0)

        self.view.ZFitAll(0.01)

        self.view.Redraw()