(self, obj, dst=None)
This method performs the deformation on the CAD geometry. If `obj` is a
        TopoDS_Shape, the method returns a TopoDS_Shape containing the deformed
        geometry. If `obj` is a filename, the method deforms the geometry
        contained in the file and writes the deformed shape to `dst` (which has
        to be set).
        
        :param obj: the input geometry.
        :type obj: str or TopoDS_Shape
        :param str dst: if `obj` is a string containing the input filename,
            `dst` refers to the file where the deformed geometry is saved.
This method performs the deformation on the CAD geometry. If `obj` is a
        TopoDS_Shape, the method returns a TopoDS_Shape containing the deformed
        geometry. If `obj` is a filename, the method deforms the geometry
        contained in the file and writes the deformed shape to `dst` (which has
        to be set).
        
        :param obj: the input geometry.
        :type obj: str or TopoDS_Shape
        :param str dst: if `obj` is a string containing the input filename,
            `dst` refers to the file where the deformed geometry is saved.
This method performs the deformation on the CAD geometry . If obj is a TopoDS_Shape the method returns a TopoDS_Shape containing the deformed geometry . If obj is a filename the method deforms the geometry contained in the file and writes the deformed shape to dst ( which has to be set ) . : param obj : the input geometry . : type obj : str or TopoDS_Shape : param str dst : if obj is a string containing the input filename dst refers to the file where the deformed geometry is saved .
def __call__(self, obj, dst=None):
        """
        This method performs the deformation on the CAD geometry. If `obj` is a
        TopoDS_Shape, the method returns a TopoDS_Shape containing the deformed
        geometry. If `obj` is a filename, the method deforms the geometry
        contained in the file and writes the deformed shape to `dst` (which has
        to be set).
        
        :param obj: the input geometry.
        :type obj: str or TopoDS_Shape
        :param str dst: if `obj` is a string containing the input filename,
            `dst` refers to the file where the deformed geometry is saved.
        """
        # Manage input
        if isinstance(obj, str):  # if a input filename is passed
            if dst is None:
                raise ValueError(
                    'Source file is provided, but no destination specified')
            shape = self.read_shape(obj)
        elif isinstance(obj, TopoDS_Shape):
            shape = obj
        # Maybe do we need to handle also Compound?
        else:
            raise TypeError

        #create compound to store modified faces
        compound_builder = BRep_Builder()
        compound = TopoDS_Compound()
        compound_builder.MakeCompound(compound)

        # cycle on the faces to get the control points

        # iterator to faces (TopoDS_Shape) contained in the shape
        faces_explorer = TopExp_Explorer(shape, TopAbs_FACE)

        while faces_explorer.More():
            # performing some conversions to get the right
            # format (BSplineSurface)
            # TopoDS_Face obtained from iterator
            face = topods_Face(faces_explorer.Current())
            # performing some conversions to get the right
            # format (BSplineSurface)
            bspline_surface = self._bspline_surface_from_face(face)

            # add the required amount of poles in u and v directions
            self._enrich_surface_knots(bspline_surface)

            # deform the Bspline surface through FFD
            self._deform_bspline_surface(bspline_surface)

            # through moving the control points, we now changed the SURFACE
            # underlying FACE we are processing. we now need to obtain the
            # curves (actually, the WIRES) that define the bounds of the
            # surface and TRIM the surface with them, to obtain the new FACE

            #we now start really looping on the wires
            #we will create a single curve joining all the edges in the wire
            # the curve must be a bspline curve so we need to make conversions
            # through all the way

            # list that will contain the (single) outer wire of the face
            outer_wires = []
            # list that will contain all the inner wires (holes) of the face
            inner_wires = []
            # iterator to loop over TopoDS_Wire in the original (undeformed)
            # face
            wire_explorer = TopExp_Explorer(face, TopAbs_WIRE)
            while wire_explorer.More():
                # wire obtained from the iterator
                wire = topods_Wire(wire_explorer.Current())

                # getting a bpline curve joining all the edges of the wire
                composite_curve = self._bspline_curve_from_wire(wire)

                # adding all the required knots to the Bspline curve
                self._enrich_curve_knots(composite_curve)

                # deforming the Bspline curve through FFD
                self._deform_bspline_curve(composite_curve)

                # the GeomCurve corresponding to the whole edge has now
                # been deformed. Now we must make it become an proper
                # wire

                # list of shapes (needed by the wire generator)
                shapes_list = TopTools_ListOfShape()

                # edge (to be converted to wire) obtained from the modified
                # Bspline curve
                modified_composite_edge = \
                    BRepBuilderAPI_MakeEdge(composite_curve).Edge()
                # modified edge is added to shapes_list
                shapes_list.Append(modified_composite_edge)

                # wire builder
                wire_maker = BRepBuilderAPI_MakeWire()
                wire_maker.Add(shapes_list)
                # deformed wire is finally obtained
                modified_wire = wire_maker.Wire()

                # now, the wire can be outer or inner. we store the outer
                # and (possible) inner ones in different lists
                # this is because we first need to trim the surface
                # using the outer wire, and then we can trim it
                # with the wires corresponding to all the holes.
                # the wire order is important, in the trimming process
                if wire == breptools_OuterWire(face):
                    outer_wires.append(modified_wire)
                else:
                    inner_wires.append(modified_wire)
                wire_explorer.Next()

            # so once we finished looping on all the wires to modify them,
            # we first use the only outer one to trim the surface
            # face builder object
            face_maker = BRepBuilderAPI_MakeFace(bspline_surface,
                                                 outer_wires[0])

            # and then add all other inner wires for the holes
            for inner_wire in inner_wires:
                face_maker.Add(inner_wire)

            # finally, we get our trimmed face with all its holes
            trimmed_modified_face = face_maker.Face()

            # trimmed_modified_face is added to the modified faces compound
            compound_builder.Add(compound, trimmed_modified_face)

            # and move to the next face
            faces_explorer.Next()

        ## END SURFACES #################################################

        if isinstance(dst, str):  # if a input filename is passed
            # save the shape exactly to the filename, aka `dst`
            self.write_shape(dst, compound)
        else:
            return compound
def __call__ ( self , obj , dst = None ) : # Manage input if isinstance ( obj , str ) : # if a input filename is passed if dst is None : raise ValueError ( 'Source file is provided, but no destination specified' ) shape = self . read_shape ( obj ) elif isinstance ( obj , TopoDS_Shape ) : shape = obj # Maybe do we need to handle also Compound? else : raise TypeError #create compound to store modified faces compound_builder = BRep_Builder ( ) compound = TopoDS_Compound ( ) compound_builder . MakeCompound ( compound ) # cycle on the faces to get the control points # iterator to faces (TopoDS_Shape) contained in the shape faces_explorer = TopExp_Explorer ( shape , TopAbs_FACE ) while faces_explorer . More ( ) : # performing some conversions to get the right # format (BSplineSurface) # TopoDS_Face obtained from iterator face = topods_Face ( faces_explorer . Current ( ) ) # performing some conversions to get the right # format (BSplineSurface) bspline_surface = self . _bspline_surface_from_face ( face ) # add the required amount of poles in u and v directions self . _enrich_surface_knots ( bspline_surface ) # deform the Bspline surface through FFD self . _deform_bspline_surface ( bspline_surface ) # through moving the control points, we now changed the SURFACE # underlying FACE we are processing. we now need to obtain the # curves (actually, the WIRES) that define the bounds of the # surface and TRIM the surface with them, to obtain the new FACE #we now start really looping on the wires #we will create a single curve joining all the edges in the wire # the curve must be a bspline curve so we need to make conversions # through all the way # list that will contain the (single) outer wire of the face outer_wires = [ ] # list that will contain all the inner wires (holes) of the face inner_wires = [ ] # iterator to loop over TopoDS_Wire in the original (undeformed) # face wire_explorer = TopExp_Explorer ( face , TopAbs_WIRE ) while wire_explorer . More ( ) : # wire obtained from the iterator wire = topods_Wire ( wire_explorer . Current ( ) ) # getting a bpline curve joining all the edges of the wire composite_curve = self . _bspline_curve_from_wire ( wire ) # adding all the required knots to the Bspline curve self . _enrich_curve_knots ( composite_curve ) # deforming the Bspline curve through FFD self . _deform_bspline_curve ( composite_curve ) # the GeomCurve corresponding to the whole edge has now # been deformed. Now we must make it become an proper # wire # list of shapes (needed by the wire generator) shapes_list = TopTools_ListOfShape ( ) # edge (to be converted to wire) obtained from the modified # Bspline curve modified_composite_edge = BRepBuilderAPI_MakeEdge ( composite_curve ) . Edge ( ) # modified edge is added to shapes_list shapes_list . Append ( modified_composite_edge ) # wire builder wire_maker = BRepBuilderAPI_MakeWire ( ) wire_maker . Add ( shapes_list ) # deformed wire is finally obtained modified_wire = wire_maker . Wire ( ) # now, the wire can be outer or inner. we store the outer # and (possible) inner ones in different lists # this is because we first need to trim the surface # using the outer wire, and then we can trim it # with the wires corresponding to all the holes. # the wire order is important, in the trimming process if wire == breptools_OuterWire ( face ) : outer_wires . append ( modified_wire ) else : inner_wires . append ( modified_wire ) wire_explorer . Next ( ) # so once we finished looping on all the wires to modify them, # we first use the only outer one to trim the surface # face builder object face_maker = BRepBuilderAPI_MakeFace ( bspline_surface , outer_wires [ 0 ] ) # and then add all other inner wires for the holes for inner_wire in inner_wires : face_maker . Add ( inner_wire ) # finally, we get our trimmed face with all its holes trimmed_modified_face = face_maker . Face ( ) # trimmed_modified_face is added to the modified faces compound compound_builder . Add ( compound , trimmed_modified_face ) # and move to the next face faces_explorer . Next ( ) ## END SURFACES ################################################# if isinstance ( dst , str ) : # if a input filename is passed # save the shape exactly to the filename, aka `dst` self . write_shape ( dst , compound ) else : return compound