Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
3850c227
Commit
3850c227
authored
6 years ago
by
Sam Jenkins
Browse files
Options
Downloads
Patches
Plain Diff
Re #23574 made constant names consistent
parent
4808ea1e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h
+3
-2
3 additions, 2 deletions
...ework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h
Framework/DataHandling/src/LoadBinaryStl.cpp
+5
-6
5 additions, 6 deletions
Framework/DataHandling/src/LoadBinaryStl.cpp
with
8 additions
and
8 deletions
Framework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h
+
3
−
2
View file @
3850c227
...
@@ -10,8 +10,9 @@ namespace DataHandling {
...
@@ -10,8 +10,9 @@ namespace DataHandling {
class
DLLExport
LoadBinaryStl
{
class
DLLExport
LoadBinaryStl
{
public:
public:
static
constexpr
int
HEADER_SIZE
=
80
;
static
constexpr
int
HEADER_SIZE
=
80
;
static
constexpr
uint32_t
SIZE_OF_TRIANGLE
=
50
;
static
constexpr
uint32_t
TRIANGLE_DATA_SIZE
=
50
;
static
constexpr
uint32_t
NUM_OF_TRIANGLES
=
4
;
static
constexpr
uint32_t
TRIANGLE_COUNT_DATA_SIZE
=
4
;
static
constexpr
uint32_t
VECTOR_DATA_SIZE
=
12
;
LoadBinaryStl
(
std
::
string
filename
)
:
m_filename
(
filename
)
{}
LoadBinaryStl
(
std
::
string
filename
)
:
m_filename
(
filename
)
{}
std
::
unique_ptr
<
Geometry
::
MeshObject
>
readStl
();
std
::
unique_ptr
<
Geometry
::
MeshObject
>
readStl
();
bool
isBinarySTL
();
bool
isBinarySTL
();
...
...
This diff is collapsed.
Click to expand it.
Framework/DataHandling/src/LoadBinaryStl.cpp
+
5
−
6
View file @
3850c227
...
@@ -12,7 +12,7 @@ namespace DataHandling {
...
@@ -12,7 +12,7 @@ namespace DataHandling {
bool
LoadBinaryStl
::
isBinarySTL
()
{
bool
LoadBinaryStl
::
isBinarySTL
()
{
Poco
::
File
stlFile
=
Poco
::
File
(
m_filename
);
Poco
::
File
stlFile
=
Poco
::
File
(
m_filename
);
auto
fileSize
=
stlFile
.
getSize
();
auto
fileSize
=
stlFile
.
getSize
();
if
(
fileSize
<
HEADER_SIZE
+
NUM_OF_
TRIANGLE
S
)
{
if
(
fileSize
<
HEADER_SIZE
+
TRIANGLE
_COUNT_DATA_SIZE
)
{
// File is smaller than header plus number of triangles, cannot be binary
// File is smaller than header plus number of triangles, cannot be binary
// format stl
// format stl
return
false
;
return
false
;
...
@@ -22,8 +22,8 @@ bool LoadBinaryStl::isBinarySTL() {
...
@@ -22,8 +22,8 @@ bool LoadBinaryStl::isBinarySTL() {
Kernel
::
BinaryStreamReader
streamReader
=
Kernel
::
BinaryStreamReader
(
myFile
);
Kernel
::
BinaryStreamReader
streamReader
=
Kernel
::
BinaryStreamReader
(
myFile
);
numberTrianglesLong
=
getNumberTriangles
(
streamReader
);
numberTrianglesLong
=
getNumberTriangles
(
streamReader
);
myFile
.
close
();
myFile
.
close
();
if
(
!
(
fileSize
==
(
HEADER_SIZE
+
NUM_OF_
TRIANGLE
S
+
if
(
!
(
fileSize
==
(
HEADER_SIZE
+
TRIANGLE
_COUNT_DATA_SIZE
+
(
numberTrianglesLong
*
SIZE_OF_TRIANGL
E
))))
{
(
numberTrianglesLong
*
TRIANGLE_DATA_SIZ
E
))))
{
// File is not the Header plus the number of triangles it claims to be long,
// File is not the Header plus the number of triangles it claims to be long,
// invalid binary Stl
// invalid binary Stl
return
false
;
return
false
;
...
@@ -45,18 +45,17 @@ LoadBinaryStl::getNumberTriangles(Kernel::BinaryStreamReader streamReader) {
...
@@ -45,18 +45,17 @@ LoadBinaryStl::getNumberTriangles(Kernel::BinaryStreamReader streamReader) {
std
::
unique_ptr
<
Geometry
::
MeshObject
>
LoadBinaryStl
::
readStl
()
{
std
::
unique_ptr
<
Geometry
::
MeshObject
>
LoadBinaryStl
::
readStl
()
{
std
::
ifstream
myFile
(
m_filename
.
c_str
(),
std
::
ios
::
in
|
std
::
ios
::
binary
);
std
::
ifstream
myFile
(
m_filename
.
c_str
(),
std
::
ios
::
in
|
std
::
ios
::
binary
);
const
uint32_t
SIZE_OF_NORMAL
=
12
;
Kernel
::
BinaryStreamReader
streamReader
=
Kernel
::
BinaryStreamReader
(
myFile
);
Kernel
::
BinaryStreamReader
streamReader
=
Kernel
::
BinaryStreamReader
(
myFile
);
const
auto
numberTrianglesLong
=
getNumberTriangles
(
streamReader
);
const
auto
numberTrianglesLong
=
getNumberTriangles
(
streamReader
);
uint32_t
nextToRead
=
HEADER_SIZE
+
NUM_OF_
TRIANGLE
S
+
SIZE_OF_NORMAL
;
uint32_t
nextToRead
=
HEADER_SIZE
+
TRIANGLE
_COUNT_DATA_SIZE
+
VECTOR_DATA_SIZE
;
// now read in all the triangles
// now read in all the triangles
for
(
uint32_t
i
=
0
;
i
<
numberTrianglesLong
;
i
++
)
{
for
(
uint32_t
i
=
0
;
i
<
numberTrianglesLong
;
i
++
)
{
// find next triangle, skipping the normal and attribute
// find next triangle, skipping the normal and attribute
streamReader
.
moveStreamToPosition
(
nextToRead
);
streamReader
.
moveStreamToPosition
(
nextToRead
);
readTriangle
(
streamReader
);
readTriangle
(
streamReader
);
nextToRead
+=
SIZE_OF_TRIANGL
E
;
nextToRead
+=
TRIANGLE_DATA_SIZ
E
;
}
}
myFile
.
close
();
myFile
.
close
();
std
::
unique_ptr
<
Geometry
::
MeshObject
>
retVal
=
std
::
unique_ptr
<
Geometry
::
MeshObject
>
retVal
=
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment