(self, mesh_points, filename, tolerance=None)
Writes a output file, called `filename`, copying all the structures
        from self.filename but the coordinates. `mesh_points` is a matrix
        that contains the new coordinates to write in the output file.

        :param numpy.ndarray mesh_points: it is a *n_points*-by-3 matrix
            containing the coordinates of the points of the mesh.
        :param str filename: name of the output file.
        :param float tolerance: tolerance for the construction of the faces
            and wires in the write function. If not given it uses
            `self.tolerance`.
Writes a output file, called `filename`, copying all the structures
        from self.filename but the coordinates. `mesh_points` is a matrix
        that contains the new coordinates to write in the output file.
Writes a output file called filename copying all the structures from self . filename but the coordinates . mesh_points is a matrix that contains the new coordinates to write in the output file .
def write(self, mesh_points, filename, tolerance=None):
        """
        Writes a output file, called `filename`, copying all the structures
        from self.filename but the coordinates. `mesh_points` is a matrix
        that contains the new coordinates to write in the output file.

        :param numpy.ndarray mesh_points: it is a *n_points*-by-3 matrix
            containing the coordinates of the points of the mesh.
        :param str filename: name of the output file.
        :param float tolerance: tolerance for the construction of the faces
            and wires in the write function. If not given it uses
            `self.tolerance`.
        """
        self._check_filename_type(filename)
        self._check_extension(filename)
        self._check_infile_instantiation()

        self.outfile = filename

        if tolerance is not None:
            self.tolerance = tolerance

        # cycle on the faces to update the control points position
        # init some quantities
        faces_explorer = TopExp_Explorer(self.shape, TopAbs_FACE)
        n_faces = 0
        control_point_position = self._control_point_position

        compound_builder = BRep_Builder()
        compound = TopoDS_Compound()
        compound_builder.MakeCompound(compound)

        while faces_explorer.More():
            # similar to the parser method
            face = topods_Face(faces_explorer.Current())
            nurbs_converter = BRepBuilderAPI_NurbsConvert(face)
            nurbs_converter.Perform(face)
            nurbs_face = nurbs_converter.Shape()
            face_aux = topods_Face(nurbs_face)
            brep_face = BRep_Tool.Surface(topods_Face(nurbs_face))
            bspline_face = geomconvert_SurfaceToBSplineSurface(brep_face)
            occ_face = bspline_face

            n_poles_u = occ_face.NbUPoles()
            n_poles_v = occ_face.NbVPoles()

            i = 0
            for pole_u_direction in range(n_poles_u):
                for pole_v_direction in range(n_poles_v):
                    control_point_coordinates = mesh_points[
                        i + control_point_position[n_faces], :]
                    point_xyz = gp_XYZ(*control_point_coordinates)

                    gp_point = gp_Pnt(point_xyz)
                    occ_face.SetPole(pole_u_direction + 1, pole_v_direction + 1,
                                     gp_point)
                    i += 1

            # construct the deformed wire for the trimmed surfaces
            wire_maker = BRepBuilderAPI_MakeWire()
            tol = ShapeFix_ShapeTolerance()
            brep = BRepBuilderAPI_MakeFace(occ_face,
                                           self.tolerance).Face()
            brep_face = BRep_Tool.Surface(brep)

            # cycle on the edges
            edge_explorer = TopExp_Explorer(nurbs_face, TopAbs_EDGE)
            while edge_explorer.More():
                edge = topods_Edge(edge_explorer.Current())
                # edge in the (u,v) coordinates
                edge_uv_coordinates = BRep_Tool.CurveOnSurface(edge, face_aux)
                # evaluating the new edge: same (u,v) coordinates, but
                # different (x,y,x) ones
                edge_phis_coordinates_aux = BRepBuilderAPI_MakeEdge(
                    edge_uv_coordinates[0], brep_face)
                edge_phis_coordinates = edge_phis_coordinates_aux.Edge()
                tol.SetTolerance(edge_phis_coordinates, self.tolerance)
                wire_maker.Add(edge_phis_coordinates)
                edge_explorer.Next()

            # grouping the edges in a wire
            wire = wire_maker.Wire()

            # trimming the surfaces
            brep_surf = BRepBuilderAPI_MakeFace(occ_face,
                                                wire).Shape()
            compound_builder.Add(compound, brep_surf)
            n_faces += 1
            faces_explorer.Next()
        self.write_shape_to_file(compound, self.outfile)
def write ( self , mesh_points , filename , tolerance = None ) : self . _check_filename_type ( filename ) self . _check_extension ( filename ) self . _check_infile_instantiation ( ) self . outfile = filename if tolerance is not None : self . tolerance = tolerance # cycle on the faces to update the control points position # init some quantities faces_explorer = TopExp_Explorer ( self . shape , TopAbs_FACE ) n_faces = 0 control_point_position = self . _control_point_position compound_builder = BRep_Builder ( ) compound = TopoDS_Compound ( ) compound_builder . MakeCompound ( compound ) while faces_explorer . More ( ) : # similar to the parser method face = topods_Face ( faces_explorer . Current ( ) ) nurbs_converter = BRepBuilderAPI_NurbsConvert ( face ) nurbs_converter . Perform ( face ) nurbs_face = nurbs_converter . Shape ( ) face_aux = topods_Face ( nurbs_face ) brep_face = BRep_Tool . Surface ( topods_Face ( nurbs_face ) ) bspline_face = geomconvert_SurfaceToBSplineSurface ( brep_face ) occ_face = bspline_face n_poles_u = occ_face . NbUPoles ( ) n_poles_v = occ_face . NbVPoles ( ) i = 0 for pole_u_direction in range ( n_poles_u ) : for pole_v_direction in range ( n_poles_v ) : control_point_coordinates = mesh_points [ i + control_point_position [ n_faces ] , : ] point_xyz = gp_XYZ ( * control_point_coordinates ) gp_point = gp_Pnt ( point_xyz ) occ_face . SetPole ( pole_u_direction + 1 , pole_v_direction + 1 , gp_point ) i += 1 # construct the deformed wire for the trimmed surfaces wire_maker = BRepBuilderAPI_MakeWire ( ) tol = ShapeFix_ShapeTolerance ( ) brep = BRepBuilderAPI_MakeFace ( occ_face , self . tolerance ) . Face ( ) brep_face = BRep_Tool . Surface ( brep ) # cycle on the edges edge_explorer = TopExp_Explorer ( nurbs_face , TopAbs_EDGE ) while edge_explorer . More ( ) : edge = topods_Edge ( edge_explorer . Current ( ) ) # edge in the (u,v) coordinates edge_uv_coordinates = BRep_Tool . CurveOnSurface ( edge , face_aux ) # evaluating the new edge: same (u,v) coordinates, but # different (x,y,x) ones edge_phis_coordinates_aux = BRepBuilderAPI_MakeEdge ( edge_uv_coordinates [ 0 ] , brep_face ) edge_phis_coordinates = edge_phis_coordinates_aux . Edge ( ) tol . SetTolerance ( edge_phis_coordinates , self . tolerance ) wire_maker . Add ( edge_phis_coordinates ) edge_explorer . Next ( ) # grouping the edges in a wire wire = wire_maker . Wire ( ) # trimming the surfaces brep_surf = BRepBuilderAPI_MakeFace ( occ_face , wire ) . Shape ( ) compound_builder . Add ( compound , brep_surf ) n_faces += 1 faces_explorer . Next ( ) self . write_shape_to_file ( compound , self . outfile )