pythonCascade Sample Problems

Topology Building: Shapes explorer

 


        self.Initialize()

        self.interactive_context.EraseAll(0,1)

 

        aBox = BRepPrimAPI_MakeBox(100,100,100).Shape()

        theBox = AIS_Shape(aBox)

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

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

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

        self.interactive_context.Display(theBox,0)

       

        j = 8

        exp = TopExp_Explorer(aBox,TopAbs_FACE)

        while exp.More():

            aCurrentFace = TopoDS().Face(exp.Current())

 

#           test the orientation of the current face

            orient = aCurrentFace.Orientation()

 

#                          Recover the geometric plane

            aGeometricSurface = BRep_Tool().Surface(aCurrentFace)

            aPlane = Geom_Plane().DownCast(aGeometricSurface)

 

            theMovingFace = AIS_Shape(aCurrentFace)

            aCurrentColor = j

            self.interactive_context.SetColor(theMovingFace,aCurrentColor,0)

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

 

            agpPlane = aPlane.Pln()

            norm = agpPlane.Axis()

            dir = norm.Direction()

            move = gp_Vec(dir)

 

            aLocation = TopLoc_Location()       

            theTransformedDisplay = AIS_ConnectedInteractive()

            theTransformedDisplay.Connect(theMovingFace, aLocation)

            theMove = Geom_Transformation(aLocation.Transformation())

            self.interactive_context.Display(theTransformedDisplay,0)

            for i in range(1,31):

                theMove.SetTranslation(move*i)

                if orient == TopAbs_FORWARD:

                    self.interactive_context.SetLocation(theTransformedDisplay,TopLoc_Location(theMove.Trsf()))

                else:

                    self.interactive_context.SetLocation(theTransformedDisplay,TopLoc_Location(theMove.Inverted().Trsf()))

               

 

            j = j + 15

           

 

            exp.Next()

 

        self.view.FitAll(0.01,0)

        self.view.ZFitAll(0.01)

        self.view.Redraw()