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
3e45549a
Commit
3e45549a
authored
8 years ago
by
Simon Heybrock
Browse files
Options
Downloads
Patches
Plain Diff
Re #18659. Improved performance of Instrument::makeLegacyParameterMap.
parent
f480d3cd
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Framework/Geometry/src/Instrument.cpp
+31
-16
31 additions, 16 deletions
Framework/Geometry/src/Instrument.cpp
with
31 additions
and
16 deletions
Framework/Geometry/src/Instrument.cpp
+
31
−
16
View file @
3e45549a
...
@@ -1266,36 +1266,51 @@ boost::shared_ptr<ParameterMap> Instrument::makeLegacyParameterMap() const {
...
@@ -1266,36 +1266,51 @@ boost::shared_ptr<ParameterMap> Instrument::makeLegacyParameterMap() const {
constexpr
double
L
=
1000.0
;
constexpr
double
L
=
1000.0
;
constexpr
double
safety_factor
=
2.0
;
constexpr
double
safety_factor
=
2.0
;
const
double
imag_norm_max
=
sin
(
d_max
/
(
2.0
*
L
*
safety_factor
));
const
double
imag_norm_max
=
sin
(
d_max
/
(
2.0
*
L
*
safety_factor
));
const
IComponent
*
oldParent
{
nullptr
};
Eigen
::
Quaterniond
invParentRot
;
Eigen
::
Affine3d
transformation
;
for
(
size_t
i
=
0
;
i
<
m_detectorInfo
->
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
m_detectorInfo
->
size
();
++
i
)
{
const
auto
&
det
=
std
::
get
<
1
>
(
baseInstr
.
m_detectorCache
[
i
]);
const
auto
&
det
=
std
::
get
<
1
>
(
baseInstr
.
m_detectorCache
[
i
]);
if
(
m_detectorInfo
->
isMasked
(
i
))
{
if
(
m_detectorInfo
->
isMasked
(
i
))
{
pmap
->
forceUnsafeSetMasked
(
det
.
get
(),
true
);
pmap
->
forceUnsafeSetMasked
(
det
.
get
(),
true
);
}
}
// Compare detector position with position based on pmap. Note that we
// Obtain parent position/rotation/scale.
// previously stripped the DetectorInfo from pmap so we do not get positions
const
auto
parent
=
det
->
getParent
();
// from the DetectorInfo but only those directly stored in pmap.
if
(
parent
.
get
()
!=
oldParent
)
{
const
auto
parDet
=
ParComponentFactory
::
create
(
det
,
pmap
.
get
());
oldParent
=
parent
.
get
();
auto
relPos
=
m_detectorInfo
->
position
(
i
);
const
auto
parParent
=
ParComponentFactory
::
create
(
parent
,
pmap
.
get
());
auto
relRot
=
m_detectorInfo
->
rotation
(
i
);
const
auto
parentPos
=
toVector3d
(
parParent
->
getPos
());
if
(
const
auto
parent
=
parDet
->
getParent
())
{
invParentRot
=
toQuaterniond
(
parParent
->
getRotation
()).
conjugate
();
relPos
-=
toVector3d
(
parent
->
getPos
());
transformation
=
invParentRot
;
const
auto
invParentRot
=
transformation
.
translate
(
-
parentPos
);
toQuaterniond
(
parent
->
getRotation
()).
conjugate
();
// Special case: scaling for RectangularDetectorPixel
relPos
=
invParentRot
*
relPos
;
if
(
boost
::
dynamic_pointer_cast
<
const
RectangularDetectorPixel
>
(
det
))
{
// Note the unusual order, see Component.cpp
const
auto
*
panel
=
det
->
getParent
()
->
getParent
().
get
();
relRot
=
invParentRot
*
relRot
;
Eigen
::
Vector3d
scale
(
1
,
1
,
1
);
if
(
auto
scalex
=
pmap
->
get
(
panel
,
"scalex"
))
scale
[
0
]
=
1.0
/
scalex
->
value
<
double
>
();
if
(
auto
scaley
=
pmap
->
get
(
panel
,
"scaley"
))
scale
[
1
]
=
1.0
/
scaley
->
value
<
double
>
();
transformation
.
prescale
(
scale
);
}
}
}
// Undo parent transformation to obtain relative position/rotation.
auto
relPos
=
transformation
*
m_detectorInfo
->
position
(
i
);
auto
relRot
=
invParentRot
*
m_detectorInfo
->
rotation
(
i
);
// Tolerance 1e-9 m as in Beamline::DetectorInfo::isEquivalent.
// Tolerance 1e-9 m as in Beamline::DetectorInfo::isEquivalent.
if
((
relPos
-
toVector3d
(
parD
et
->
getRelativePos
())).
norm
()
>=
1e-9
)
{
if
((
relPos
-
toVector3d
(
d
et
->
getRelativePos
())).
norm
()
>=
1e-9
)
{
if
(
boost
::
dynamic_pointer_cast
<
const
RectangularDetectorPixel
>
(
parD
et
))
if
(
boost
::
dynamic_pointer_cast
<
const
RectangularDetectorPixel
>
(
d
et
))
throw
std
::
runtime_error
(
"Cannot create legacy ParameterMap: Position "
throw
std
::
runtime_error
(
"Cannot create legacy ParameterMap: Position "
"parameters for RectangularDetectorPixel are "
"parameters for RectangularDetectorPixel are "
"not supported"
);
"not supported"
);
pmap
->
addV3D
(
det
->
getComponentID
(),
ParameterMap
::
pos
(),
toV3D
(
relPos
));
pmap
->
addV3D
(
det
->
getComponentID
(),
ParameterMap
::
pos
(),
toV3D
(
relPos
));
}
}
if
((
relRot
*
toQuaterniond
(
parD
et
->
getRelativeRot
()).
conjugate
())
if
((
relRot
*
toQuaterniond
(
d
et
->
getRelativeRot
()).
conjugate
())
.
vec
()
.
vec
()
.
norm
()
>=
imag_norm_max
)
.
norm
()
>=
imag_norm_max
)
pmap
->
addQuat
(
det
->
getComponentID
(),
ParameterMap
::
rot
(),
toQuat
(
relRot
));
pmap
->
addQuat
(
det
->
getComponentID
(),
ParameterMap
::
rot
(),
toQuat
(
relRot
));
...
...
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