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
2642f968
Commit
2642f968
authored
6 years ago
by
Sam Jenkins
Browse files
Options
Downloads
Patches
Plain Diff
Re #23807 why is it slower now?!
parent
dabc806b
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
+2
-1
2 additions, 1 deletion
...ework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h
Framework/DataHandling/src/LoadBinaryStl.cpp
+47
-28
47 additions, 28 deletions
Framework/DataHandling/src/LoadBinaryStl.cpp
with
49 additions
and
29 deletions
Framework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h
+
2
−
1
View file @
2642f968
...
...
@@ -24,9 +24,10 @@ public:
bool
isBinarySTL
();
private
:
Kernel
::
V3D
LoadBinaryStl
::
makeV3D
(
char
*
facet
,
int
index
);
Kernel
::
V3D
makeV3D
(
char
*
facet
,
int
index
);
uint32_t
getNumberTriangles
(
Kernel
::
BinaryStreamReader
);
void
readTriangle
(
Kernel
::
BinaryStreamReader
);
void
add3Vertex
(
Kernel
::
V3D
vec1
,
Kernel
::
V3D
vec2
,
Kernel
::
V3D
vec3
);
};
}
// namespace DataHandling
...
...
This diff is collapsed.
Click to expand it.
Framework/DataHandling/src/LoadBinaryStl.cpp
+
47
−
28
View file @
2642f968
...
...
@@ -5,11 +5,14 @@
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include
"MantidDataHandling/LoadBinaryStl.h"
#include
"MantidKernel/MultiThreaded.h"
#include
<Poco/File.h>
#include
<fstream>
#include
<string>
#include
<vector>
#include
<string>
#include
<boost/make_shared.hpp>
#include
<chrono>
namespace
Mantid
{
namespace
DataHandling
{
...
...
@@ -47,38 +50,51 @@ LoadBinaryStl::getNumberTriangles(Kernel::BinaryStreamReader streamReader) {
}
std
::
unique_ptr
<
Geometry
::
MeshObject
>
LoadBinaryStl
::
readStl
()
{
std
::
ifstream
myFile
(
m_filename
.
c_str
(),
std
::
ios
::
in
|
std
::
ios
::
binary
);
myFile
.
seekg
(
0
,
std
::
ios_base
::
end
);
std
::
size_t
size
=
myFile
.
tellg
();
myFile
.
seekg
(
0
,
std
::
ios_base
::
beg
);
char
Header
[
80
];
char
buffer
[
size
-
84
];
char
temp
[
4
];
myFile
.
read
(
Header
,
80
);
myFile
.
read
(
temp
,
4
);
myFile
.
read
(
buffer
,
size
);
uint32_t
nTriLong
=
*
((
uint32_t
*
)
temp
)
;
for
(
int
i
=
0
;
i
++
;
i
<
nTriLong
){
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
auto
vec
=
makeV3D
(
buffer
,(
12
+
(
i
*
50
)
+
(
j
*
12
)));
m_triangle
.
emplace_back
(
addSTLVertex
(
vec
));
}
}
m_verticies
.
shrink_to_fit
();
m_triangle
.
shrink_to_fit
();
// Close the file
myFile
.
close
();
std
::
unique_ptr
<
Geometry
::
MeshObject
>
retVal
=
std
::
unique_ptr
<
Geometry
::
MeshObject
>
(
new
Geometry
::
MeshObject
(
std
::
move
(
m_triangle
),
std
::
move
(
m_verticies
),
Mantid
::
Kernel
::
Material
()));
return
retVal
;
}
// std::unique_ptr<Geometry::MeshObject> LoadBinaryStl::readStl() {
// std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
// std::ifstream myFile(m_filename.c_str(), std::ios::in | std::ios::binary);
// myFile.seekg(0, std::ios_base::end);
// const std::size_t size=myFile.tellg();
// myFile.seekg(0, std::ios_base::beg);
// char Header[80];
// std::unique_ptr<char[]> buffer(new char[size-84]);
// char temp[4];
// myFile.read(Header, 80);
// myFile.read(temp,4);
// myFile.read(buffer.get(), size);
// const uint32_t nTriLong = *((uint32_t*)temp);
// g_logstl.debug(std::to_string(nTriLong) + " Triangles to read");
// PARALLEL_FOR_NO_WSP_CHECK()
// for(uint32_t i = 0;i<nTriLong;i++){
// auto vec1 = makeV3D(buffer.get(),((i*TRIANGLE_DATA_SIZE)+(VECTOR_DATA_SIZE)));
// auto vec2 = makeV3D(buffer.get(),((i*TRIANGLE_DATA_SIZE)+(2*VECTOR_DATA_SIZE)));
// auto vec3 = makeV3D(buffer.get(),((i*TRIANGLE_DATA_SIZE)+(3*VECTOR_DATA_SIZE)));
// #pragma omp critical
// add3Vertex(vec1, vec2, vec3);
// }
// m_verticies.shrink_to_fit();
// m_triangle.shrink_to_fit();
// // Close the file
// myFile.close();
// std::unique_ptr<Geometry::MeshObject> retVal =
// std::unique_ptr<Geometry::MeshObject>(new Geometry::MeshObject(
// std::move(m_triangle), std::move(m_verticies),
// Mantid::Kernel::Material()));
// std::chrono::high_resolution_clock::time_point t2 = std::chrono::high_resolution_clock::now();
// auto duration = std::chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count();
// g_logstl.information("Took "+ std::to_string(duration)+" microseconds");
// return retVal;
// }
// void LoadBinaryStl::add3Vertex(Kernel::V3D vec1, Kernel::V3D vec2, Kernel::V3D vec3){
// m_triangle.emplace_back(addSTLVertex(vec1));
// m_triangle.emplace_back(addSTLVertex(vec2));
// m_triangle.emplace_back(addSTLVertex(vec3));
// }
std
::
unique_ptr
<
Geometry
::
MeshObject
>
LoadBinaryStl
::
readStl
()
{
std
::
chrono
::
high_resolution_clock
::
time_point
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
std
::
ifstream
myFile
(
m_filename
.
c_str
(),
std
::
ios
::
in
|
std
::
ios
::
binary
);
Kernel
::
BinaryStreamReader
streamReader
=
Kernel
::
BinaryStreamReader
(
myFile
);
...
...
@@ -103,6 +119,9 @@ std::unique_ptr<Geometry::MeshObject> LoadBinaryStl::readStl() {
std
::
unique_ptr
<
Geometry
::
MeshObject
>
(
new
Geometry
::
MeshObject
(
std
::
move
(
m_triangle
),
std
::
move
(
m_verticies
),
Mantid
::
Kernel
::
Material
()));
std
::
chrono
::
high_resolution_clock
::
time_point
t2
=
std
::
chrono
::
high_resolution_clock
::
now
();
auto
duration
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
t2
-
t1
).
count
();
g_logstl
.
information
(
"Took "
+
std
::
to_string
(
duration
)
+
" microseconds"
);
return
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