KRVRSW/service/ConvertService.py
def write_stl_file(self,
                       a_shape,
                       filename,
                       mode="ascii",
                       linear_deflection=0.9,
                       angular_deflection=0.5):
        """ export the shape to a STL file
        Be careful, the shape first need to be explicitely meshed using BRepMesh_IncrementalMesh
        a_shape: the topods_shape to export
        filename: the filename
        mode: optional, "ascii" by default. Can either be "binary"
        linear_deflection: optional, default to 0.001. Lower, more occurate mesh
        angular_deflection: optional, default to 0.5. Lower, more accurate_mesh
        """
        if a_shape.IsNull():
            raise AssertionError("Shape is null.")
        if mode not in ["ascii", "binary"]:
            raise AssertionError("mode should be either ascii or binary")
        if os.path.isfile(filename):
            print("Warning: %s file already exists and will be replaced" %
                  filename)
        # first mesh the shape
        mesh = BRepMesh_IncrementalMesh(a_shape, linear_deflection, False,
                                        angular_deflection, True)
        # mesh.SetDeflection(0.05)
        mesh.Perform()
        if not mesh.IsDone():
            raise AssertionError("Mesh is not done.")

        stl_exporter = StlAPI_Writer()
        if mode == "ascii":
            stl_exporter.SetASCIIMode(True)
        else:  # binary, just set the ASCII flag to False
            stl_exporter.SetASCIIMode(False)
        stl_exporter.Write(a_shape, filename)

        if not os.path.isfile(filename):
            raise IOError("File not written to disk.")
 export the shape to a STL file
        Be careful, the shape first need to be explicitely meshed using BRepMesh_IncrementalMesh
        a_shape: the topods_shape to export
        filename: the filename
        mode: optional, "ascii" by default. Can either be "binary"
        linear_deflection: optional, default to 0.001. Lower, more occurate mesh
        angular_deflection: optional, default to 0.5. Lower, more accurate_mesh
        
export the shape to a STL file
Be careful, the shape first need to be explicitely meshed using BRepMesh_IncrementalMesh
a_shape: the topods_shape to export
filename: the filename
mode: optional, "ascii" by default. Can either be "binary"
linear_deflection: optional, default to 0.001. Lower, more occurate mesh
angular_deflection: optional, default to 0.5.
export the shape to a STL file Be careful the shape first need to be explicitely meshed using BRepMesh_IncrementalMesh a_shape : the topods_shape to export filename : the filename mode : optional " ascii " by default . Can either be " binary " linear_deflection : optional default to 0 . 001 . Lower more occurate mesh angular_deflection : optional default to 0 . 5 .
def write_stl_file(self,
                       a_shape,
                       filename,
                       mode="ascii",
                       linear_deflection=0.9,
                       angular_deflection=0.5):
        if a_shape.IsNull():
            raise AssertionError("Shape is null.")
        if mode not in ["ascii", "binary"]:
            raise AssertionError("mode should be either ascii or binary")
        if os.path.isfile(filename):
            print("Warning: %s file already exists and will be replaced" %
                  filename)
        mesh = BRepMesh_IncrementalMesh(a_shape, linear_deflection, False,
                                        angular_deflection, True)
        mesh.Perform()
        if not mesh.IsDone():
            raise AssertionError("Mesh is not done.")
        stl_exporter = StlAPI_Writer()
        if mode == "ascii":
            stl_exporter.SetASCIIMode(True)
        else:  
            stl_exporter.SetASCIIMode(False)
        stl_exporter.Write(a_shape, filename)
        if not os.path.isfile(filename):
            raise IOError("File not written to disk.")
def write_stl_file ( self , a_shape , filename , mode = "ascii" , linear_deflection = 0.9 , angular_deflection = 0.5 ) : if a_shape . IsNull ( ) : raise AssertionError ( "Shape is null." ) if mode not in [ "ascii" , "binary" ] : raise AssertionError ( "mode should be either ascii or binary" ) if os . path . isfile ( filename ) : print ( "Warning: %s file already exists and will be replaced" % filename ) mesh = BRepMesh_IncrementalMesh ( a_shape , linear_deflection , False , angular_deflection , True ) mesh . Perform ( ) if not mesh . IsDone ( ) : raise AssertionError ( "Mesh is not done." ) stl_exporter = StlAPI_Writer ( ) if mode == "ascii" : stl_exporter . SetASCIIMode ( True ) else : stl_exporter . SetASCIIMode ( False ) stl_exporter . Write ( a_shape , filename ) if not os . path . isfile ( filename ) : raise IOError ( "File not written to disk." )
export the shape to a STL file
Be careful, the shape first need to be explicitely meshed using BRepMesh_IncrementalMesh
a_shape: the topods_shape to export
filename: the filename
mode: optional, "ascii" by default.
export the shape to a STL file Be careful the shape first need to be explicitely meshed using BRepMesh_IncrementalMesh a_shape : the topods_shape to export filename : the filename mode : optional " ascii " by default .
""" export the shape to a STL file
        Be careful, the shape first need to be explicitely meshed using BRepMesh_IncrementalMesh
        a_shape: the topods_shape to export
        filename: the filename
        mode: optional, "ascii" by default. Can either be "binary"
        linear_deflection: optional, default to 0.001. Lower, more occurate mesh
        angular_deflection: optional, default to 0.5. Lower, more accurate_mesh
        """ # first mesh the shape # mesh.SetDeflection(0.05) # binary, just set the ASCII flag to False
self
a_shape
filename
mode
linear_deflection
angular_deflection