Menu

Improve Mesh file (STL) loading time

2023-01-12
2023-01-12
  • shine world

    shine world - 2023-01-12

    In my case I've a lot of STL files to open.
    With latest GLScene, HEAD 0eb11bb1aae7f7110e79064a92ed5b597594921,
    it will take 2500ms to load all of them.

    Changing GLS.VectorFileObjects.pas code from:

    procedure TGLBaseMesh.LoadFromFile(const filename: string);
    var
      fs: TFileStream;
    begin
      FLastLoadedFilename := '';
      if fileName <> '' then
      begin
        try
          fs := TFileStream.Create(fileName, fmOpenRead + fmShareDenyWrite);
          LoadFromStream(fileName, fs);
          FLastLoadedFilename := filename;
        finally
          fs.Free;
        end;
      end;
    end;
    

    to:

    procedure TGLBaseMesh.LoadFromFile(const filename: string);
    var
      fs: TFileStream;
    begin
      FLastLoadedFilename := '';
      if fileName <> '' then
      begin
        fs := TBufferedFileStream.Create(fileName, fmOpenRead + fmShareDenyWrite); {SID}
        try
          LoadFromStream(fileName, fs);
          FLastLoadedFilename := filename;
        finally
          fs.Free;
        end;
      end;
    end;
    

    the loading time decrease to 922ms.

    TBufferedFileStream is entered in SysUtils from Delphi 10.1

     
  • Pavel Vassiliev

    Pavel Vassiliev - 2023-01-12

    Hi Shine World,
    Indeed your BedSTL now loading five times faster. But rotation on my case still no more then 20 FPS. Thanks.
    Pavel

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.