def read_stl_file(filename): """ opens a stl file, reads the content, and returns a BRep topods_shape object """ assert os.path.isfile(filename) stl_reader = StlAPI_Reader() the_shape = TopoDS_Shape() stl_reader.Read(the_shape, filename) assert not the_shape.IsNull() return the_shape
def read_stl(stl_filepath): """ This function reads STL format. Parameters ---------- stl_filepath : str The file path of the STL file. Returns ------- occtopology : OCCtopology The geometries from an STL file. """ from OCC.StlAPI import StlAPI_Reader from OCC.TopoDS import TopoDS_Shape stl_reader = StlAPI_Reader() the_shape = TopoDS_Shape() stl_reader.Read(the_shape, stl_filepath) assert not the_shape.IsNull() return the_shape