|
@@ -146,27 +146,24 @@ var
|
|
|
P: Int64;
|
|
|
Header: TSTLHeader;
|
|
|
PHeader: ^TSTLHeader;
|
|
|
- begin
|
|
|
- Result := True;
|
|
|
- try
|
|
|
- if (AStream.Size - AStream.Position) < SizeOf(TSTLHeader) then Abort;
|
|
|
- P := AStream.Position;
|
|
|
- PHeader := @Header;
|
|
|
- AStream.Read(PHeader^, SizeOf(Header));
|
|
|
- AStream.Position := P;
|
|
|
- if not
|
|
|
- (
|
|
|
- (Header.Dummy[0] = 's') and
|
|
|
- (Header.Dummy[1] = 'o') and
|
|
|
- (Header.Dummy[2] = 'l') and
|
|
|
- (Header.Dummy[3] = 'i') and
|
|
|
- (Header.Dummy[4] = 'd')
|
|
|
- ) then Exit;
|
|
|
- if AStream.Size <> (SizeOf(TSTLHeader) + (Header.Faces * FACET_SIZE)) then Abort;
|
|
|
- Result := True;
|
|
|
- except
|
|
|
- Result := False;
|
|
|
- end;
|
|
|
+ begin
|
|
|
+ if (AStream.Size - AStream.Position) < SizeOf(TSTLHeader) then
|
|
|
+ raise Exception.Create('STL file is broken!');
|
|
|
+ P := AStream.Position;
|
|
|
+ PHeader := @Header;
|
|
|
+ AStream.Read(PHeader^, SizeOf(Header));
|
|
|
+ AStream.Position := P;
|
|
|
+ Result := not
|
|
|
+ (
|
|
|
+ (Header.Dummy[0] = 's') and
|
|
|
+ (Header.Dummy[1] = 'o') and
|
|
|
+ (Header.Dummy[2] = 'l') and
|
|
|
+ (Header.Dummy[3] = 'i') and
|
|
|
+ (Header.Dummy[4] = 'd')
|
|
|
+ );
|
|
|
+ if Result and
|
|
|
+ (AStream.Size <> (SizeOf(TSTLHeader) + (Header.Faces * FACET_SIZE))) then
|
|
|
+ raise Exception.Create('Binary STL file is broken!');
|
|
|
end;
|
|
|
|
|
|
begin
|
|
@@ -319,4 +316,4 @@ initialization
|
|
|
STLUseEmbeddedColors := False;
|
|
|
RegisterVectorFileFormat('stl', 'Stereolithography files', TGLSTLVectorFile);
|
|
|
|
|
|
-end.
|
|
|
+end.
|