Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • VTK VTK
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 830
    • Issues 830
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 240
    • Merge requests 240
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • VTKVTK
  • VTKVTK
  • Issues
  • #414
Closed
Open
Issue created Dec 01, 2003 by Kitware Robot@kwrobotOwner

STL Reader Binary/ASCII destinguishing wrong

This issue was created automatically from an original Mantis Issue. Further discussion may take place here.


I compiled VTK 4.2.2 with VS7 on XP Out of vtkstlreader.cxx, my comments start with -->

// Initialize // if ((fp = fopen(this->FileName, "r")) == NULL) --> this opens the file in ascii mode, and thus getstlfiletype will also use ascii mode to query the file { vtkErrorMacro(<< "File " << this->FileName << " not found"); return; }

newPts = vtkPoints::New(); newPts->Allocate(5000,10000); newPolys = vtkCellArray::New(); newPolys->Allocate(10000,20000);

// Depending upon file type, read differently // if ( this->GetSTLFileType(fp) == VTK_ASCII ) --> because fp is open in "r" mode, if there is a character 26 in a binary file, then this will be interpreted as EOF, giving maybe a wrong result, because no illegal character for ascii will be found. { if (ScalarTags) { newScalars = vtkFloatArray::New(); newScalars->Allocate(5000,10000); } if ( this->ReadASCIISTL(fp,newPts,newPolys,newScalars) ) { return; } } else { fclose(fp); fp = fopen(this->FileName, "rb");

if ( this-&gt;ReadBinarySTL(fp,newPts,newPolys) )
  {
  return;
  }
}

My proposed solution is obviously: // Initialize // if ((fp = fopen(this->FileName, "rb")) == NULL) { vtkErrorMacro(<< "File " << this->FileName << " not found"); return; }

newPts = vtkPoints::New(); newPts->Allocate(5000,10000); newPolys = vtkCellArray::New(); newPolys->Allocate(10000,20000);

// Depending upon file type, read differently // if ( this->GetSTLFileType(fp) == VTK_ASCII ) { fclose(fp); fp = fopen(this->FileName, "r"); if (ScalarTags) { newScalars = vtkFloatArray::New(); newScalars->Allocate(5000,10000); } if ( this->ReadASCIISTL(fp,newPts,newPolys,newScalars) ) { return; } } else {

if ( this-&gt;ReadBinarySTL(fp,newPts,newPolys) )
  {
  return;
  }
}

Greetings Gregi

Assignee
Assign to
Time tracking