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
a5c14981
Commit
a5c14981
authored
6 years ago
by
Owen Arnold
Browse files
Options
Downloads
Patches
Plain Diff
Various improvements to NexusGeometryParser
parent
90952630
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Framework/NexusGeometry/src/NexusGeometryParser.cpp
+16
-17
16 additions, 17 deletions
Framework/NexusGeometry/src/NexusGeometryParser.cpp
with
16 additions
and
17 deletions
Framework/NexusGeometry/src/NexusGeometryParser.cpp
+
16
−
17
View file @
a5c14981
...
...
@@ -112,8 +112,6 @@ std::vector<ValueType> extractVector(const DataSet &data) {
values
.
resize
(
dataSpace
.
getSelectNpoints
());
// Read data into vector
data
.
read
(
values
.
data
(),
data
.
getDataType
(),
dataSpace
);
// Return the data vector
return
values
;
}
...
...
@@ -121,7 +119,6 @@ std::vector<ValueType> extractVector(const DataSet &data) {
template
<
typename
ValueType
>
std
::
vector
<
ValueType
>
get1DDataset
(
const
H5std_string
&
dataset
,
const
H5
::
Group
&
group
)
{
// Open data set
DataSet
data
=
group
.
openDataSet
(
dataset
);
return
extractVector
<
ValueType
>
(
data
);
}
...
...
@@ -218,7 +215,9 @@ Pixels getPixelOffsets(const Group &detectorGroup) {
// Initialise matrix
Pixels
offsetData
;
std
::
vector
<
double
>
xValues
,
yValues
,
zValues
;
std
::
vector
<
double
>
xValues
;
std
::
vector
<
double
>
yValues
;
std
::
vector
<
double
>
zValues
;
for
(
unsigned
int
i
=
0
;
i
<
detectorGroup
.
getNumObjs
();
i
++
)
{
H5std_string
objName
=
detectorGroup
.
getObjnameByIdx
(
i
);
if
(
objName
==
X_PIXEL_OFFSET
)
{
...
...
@@ -267,7 +266,7 @@ Pixels getPixelOffsets(const Group &detectorGroup) {
}
/**
* Creates a Homoge
m
ous transfomation for nexus groups
* Creates a Homoge
ne
ous transfomation for nexus groups
*
* Walks the chain of transformations described in the file where W1 is first
*transformation and Wn is last and assembles them as
...
...
@@ -297,11 +296,8 @@ getTransformations(const H5File &file, const Group &detectorGroup) {
return
Eigen
::
Transform
<
double
,
3
,
Eigen
::
Affine
>::
Identity
();
}
// Initialise transformation holder as zero-degree rotation
Eigen
::
Transform
<
double
,
3
,
Eigen
::
Affine
>
transforms
;
Eigen
::
Vector3d
axis
(
1.0
,
0.0
,
0.0
);
transforms
=
Eigen
::
AngleAxisd
(
0.0
,
axis
);
// Initialise transformation holder as identity matrix
auto
transforms
=
Eigen
::
Transform
<
double
,
3
,
Eigen
::
Affine
>::
Identity
();
// Breaks when no more dependencies (dependency = ".")
// Transformations must be applied in the order of direction of discovery
// (they are _passive_ transformations)
...
...
@@ -365,15 +361,18 @@ getTransformations(const H5File &file, const Group &detectorGroup) {
}
Eigen
::
AngleAxisd
rotation
(
angle
,
transformVector
);
transforms
=
rotation
*
transforms
;
}
else
{
throw
std
::
runtime_error
(
"Unknown Transform type in Nexus Geometry Parsing"
);
}
}
return
transforms
;
}
// Function to return the detector ids in the same order as the offsets
std
::
vector
<
in
t
>
getDetectorIds
(
const
Group
&
detectorGroup
)
{
std
::
vector
<
Mantid
::
detid_
t
>
getDetectorIds
(
const
Group
&
detectorGroup
)
{
std
::
vector
<
in
t
>
detIds
;
std
::
vector
<
Mantid
::
detid_
t
>
detIds
;
for
(
unsigned
int
i
=
0
;
i
<
detectorGroup
.
getNumObjs
();
++
i
)
{
H5std_string
objName
=
detectorGroup
.
getObjnameByIdx
(
i
);
...
...
@@ -381,9 +380,10 @@ std::vector<int> getDetectorIds(const Group &detectorGroup) {
const
auto
data
=
detectorGroup
.
openDataSet
(
objName
);
if
(
data
.
getDataType
().
getSize
()
==
8
)
{
// Note the narrowing here!
detIds
=
convertVector
<
int64_t
,
int32_t
>
(
extractVector
<
int64_t
>
(
data
));
detIds
=
convertVector
<
int64_t
,
Mantid
::
detid_t
>
(
extractVector
<
int64_t
>
(
data
));
}
else
{
detIds
=
extractVector
<
int32
_t
>
(
data
);
detIds
=
extractVector
<
Mantid
::
detid
_t
>
(
data
);
}
}
}
...
...
@@ -443,7 +443,7 @@ void extractFacesAndIDs(const std::vector<uint16_t> &detFaces,
detVerts
.
reserve
(
vertsPerFace
);
detWinding
.
reserve
(
vertsPerFace
);
for
(
size_t
v
=
0
;
v
<
vertsPerFace
;
++
v
)
{
auto
vi
=
windingOrder
[
i
+
v
]
*
vertStride
;
const
auto
vi
=
windingOrder
[
i
+
v
]
*
vertStride
;
detVerts
.
emplace_back
(
vertices
[
vi
],
vertices
[
vi
+
1
],
vertices
[
vi
+
2
]);
detWinding
.
push_back
(
static_cast
<
uint16_t
>
(
detWinding
.
size
()));
}
...
...
@@ -590,8 +590,7 @@ void parseMonitors(const H5::Group &root, InstrumentBuilder &builder) {
for
(
auto
&
monitor
:
monitorGroups
)
{
auto
detectorId
=
get1DDataset
<
int64_t
>
(
DETECTOR_ID
,
monitor
)[
0
];
bool
proxy
=
false
;
boost
::
shared_ptr
<
const
Geometry
::
IObject
>
monitorShape
=
parseNexusShape
(
monitor
,
proxy
);
auto
monitorShape
=
parseNexusShape
(
monitor
,
proxy
);
builder
.
addMonitor
(
std
::
to_string
(
detectorId
),
static_cast
<
int32_t
>
(
detectorId
),
Eigen
::
Vector3d
{
0
,
0
,
0
},
monitorShape
);
...
...
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