There is a bug in the STL reader method named
Handle_StlMesh_Mesh RWStl::ReadAscii(const OSD_Path& aPath)
that is located in the file named RWStl.cxx.
The code as it stands now will not correctly read an ASCII STL file that contains more that one "solid." (See the STL file format documentation for a description of solids.) STL files with more than one solid are rare, but when they are encountered, OCC will create a BRep with a lot of garbage in it. Shown below is my fix.
Jim
Handle_StlMesh_Mesh RWStl::ReadAscii(const OSD_Path& aPath)
{
TCollection_AsciiString filename;
long ipos;
Standard_Integer nbLines = 0;
Standard_Integer nbTris = 0;
Standard_Integer iTri;
Standard_ShortReal x[4],y[4],z[4];
Standard_Integer i1,i2,i3;
fpos_t pos; //NEW CODE
char C; //NEW CODE
Handle(StlMesh_Mesh) ReadMesh;
...
// skip the keywords "endloop"
fscanf(file,"%*s");
// skip the keywords "endfacet"
fscanf(file,"%*s");
//NEW CODE START
//skip any 'endsolid' and 'solid' delimiters
fgetpos(file, &pos);
C = getc(file);C = getc(file);
if( C==EOF ) {
break;
}
else if( C=='e' ) {
while (getc(file) != '\n');
C = getc(file);
if( C==EOF )
break;
while (getc(file) != '\n');
}
else {
fsetpos(file, &pos);
}
//NEW CODE END
}
cout
fclose(file);
return ReadMesh;
}