Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenMesh
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenMesh
OpenMesh
Commits
fc04bac1
Commit
fc04bac1
authored
Aug 15, 2016
by
Martin Schultz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made the stl reader check for ascii file keyword instead of computing binary size
parent
b792b0c6
Pipeline
#2432
failed with stage
in 53 minutes and 32 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
30 deletions
+28
-30
src/OpenMesh/Core/IO/reader/STLReader.cc
src/OpenMesh/Core/IO/reader/STLReader.cc
+28
-30
No files found.
src/OpenMesh/Core/IO/reader/STLReader.cc
View file @
fc04bac1
...
...
@@ -61,6 +61,13 @@
#include <OpenMesh/Core/IO/reader/STLReader.hh>
#include <OpenMesh/Core/IO/IOManager.hh>
//comppare strings crossplatform ignorign case
#ifdef _WIN32
#define strnicmp _strnicmp
#else
#define strnicmp strncasecmp
#endif
//=== NAMESPACES ==============================================================
...
...
@@ -447,41 +454,32 @@ _STLReader_::STL_Type
_STLReader_
::
check_stl_type
(
const
std
::
string
&
_filename
)
const
{
// assume it's binary stl, then file size is known from #triangles
// if size matches, it's really binary
// open file
FILE
*
in
=
fopen
(
_filename
.
c_str
(),
"rb"
);
if
(
!
in
)
return
NONE
;
// determine endian mode
union
{
unsigned
int
i
;
unsigned
char
c
[
4
];
}
endian_test
;
endian_test
.
i
=
1
;
bool
swapFlag
=
(
endian_test
.
c
[
3
]
==
1
);
// read number of triangles
char
dummy
[
100
];
fread
(
dummy
,
1
,
80
,
in
);
size_t
nT
=
read_int
(
in
,
swapFlag
);
// compute file size from nT
size_t
binary_size
=
84
+
nT
*
50
;
std
::
ifstream
ifs
(
_filename
.
c_str
(),
std
::
ifstream
::
binary
);
if
(
!
ifs
.
good
())
{
omerr
()
<<
"could not open file"
<<
_filename
<<
std
::
endl
;
return
NONE
;
}
// get actual file size
size_t
file_size
(
0
);
rewind
(
in
);
while
(
!
feof
(
in
))
file_size
+=
fread
(
dummy
,
1
,
100
,
in
);
fclose
(
in
);
//find first non whitespace character
std
::
string
line
=
""
;
std
::
size_t
firstChar
;
while
(
line
.
empty
()
&&
ifs
.
good
())
{
std
::
getline
(
ifs
,
line
);
firstChar
=
line
.
find_first_not_of
(
"
\t
"
);
}
//check for ascii keyword solid
if
(
strnicmp
(
"solid"
,
&
line
[
firstChar
],
5
)
==
0
)
{
return
STLA
;
}
//
if sizes match -> it'
s STLB
return
(
binary_size
==
file_size
?
STLB
:
STLA
)
;
//
if the file does not start with solid it i
s STLB
return
STLB
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment