Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
d8f31da6
Commit
d8f31da6
authored
Sep 22, 2020
by
Kendrick, Coleman
Browse files
Link sum function, changed sphere tests to use it
parent
31ba4cb5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Framework/Geometry/inc/MantidGeometry/Objects/Track.h
View file @
d8f31da6
...
...
@@ -171,6 +171,8 @@ public:
const
Kernel
::
V3D
&
startPoint
()
const
{
return
m_line
.
getOrigin
();
}
/// Returns the direction as a unit vector
const
Kernel
::
V3D
&
direction
()
const
{
return
m_line
.
getDirect
();
}
/// Returns the sum of all the links distInsideObject in the track
double
totalDistInsideObject
()
const
;
/// Returns an interator to the start of the set of links
LType
::
iterator
begin
()
{
return
m_links
.
begin
();
}
/// Returns an interator to one-past-the-end of the set of links
...
...
Framework/Geometry/src/Objects/Track.cpp
View file @
d8f31da6
...
...
@@ -235,6 +235,13 @@ void Track::buildLink() {
m_surfPoints
.
clear
();
}
double
Track
::
totalDistInsideObject
()
const
{
return
std
::
accumulate
(
m_links
.
begin
(),
m_links
.
end
(),
0.
,
[](
double
total
,
const
auto
&
link
)
{
return
total
+
link
.
distInsideObject
;
});
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
TrackDirection
direction
)
{
switch
(
direction
)
{
case
TrackDirection
::
ENTERING
:
...
...
Framework/Geometry/test/CSGObjectTest.h
View file @
d8f31da6
...
...
@@ -859,41 +859,41 @@ public:
// Test center of sphere
Track
origin
(
V3D
{
0.0
,
0.0
,
0.0
},
BEAM_X
);
sphere
->
interceptSurface
(
origin
);
TS_ASSERT_EQUALS
(
origin
.
front
().
d
istInsideObject
,
RADIUS
);
TS_ASSERT_EQUALS
(
origin
.
totalD
istInsideObject
()
,
RADIUS
);
Track
front_midpoint
(
V3D
{
0.5
*
RADIUS
,
0.0
,
0.0
},
BEAM_X
);
sphere
->
interceptSurface
(
front_midpoint
);
TS_ASSERT_EQUALS
(
front_midpoint
.
front
().
d
istInsideObject
,
0.5
*
RADIUS
);
TS_ASSERT_EQUALS
(
front_midpoint
.
totalD
istInsideObject
()
,
0.5
*
RADIUS
);
Track
back_midpoint
(
V3D
{
-
0.5
*
RADIUS
,
0.0
,
0.0
},
BEAM_X
);
sphere
->
interceptSurface
(
back_midpoint
);
TS_ASSERT_EQUALS
(
back_midpoint
.
front
().
d
istInsideObject
,
1.5
*
RADIUS
);
TS_ASSERT_EQUALS
(
back_midpoint
.
totalD
istInsideObject
()
,
1.5
*
RADIUS
);
// Y axis tests
origin
=
Track
(
V3D
{
0.0
,
0.0
,
0.0
},
BEAM_Y
);
sphere
->
interceptSurface
(
origin
);
TS_ASSERT_EQUALS
(
origin
.
front
().
d
istInsideObject
,
RADIUS
);
TS_ASSERT_EQUALS
(
origin
.
totalD
istInsideObject
()
,
RADIUS
);
front_midpoint
=
Track
(
V3D
{
0.0
,
0.5
*
RADIUS
,
0.0
},
BEAM_Y
);
sphere
->
interceptSurface
(
front_midpoint
);
TS_ASSERT_EQUALS
(
front_midpoint
.
front
().
d
istInsideObject
,
0.5
*
RADIUS
);
TS_ASSERT_EQUALS
(
front_midpoint
.
totalD
istInsideObject
()
,
0.5
*
RADIUS
);
back_midpoint
=
Track
(
V3D
{
0.0
,
-
0.5
*
RADIUS
,
0.0
},
BEAM_Y
);
sphere
->
interceptSurface
(
back_midpoint
);
TS_ASSERT_EQUALS
(
back_midpoint
.
front
().
d
istInsideObject
,
1.5
*
RADIUS
);
TS_ASSERT_EQUALS
(
back_midpoint
.
totalD
istInsideObject
()
,
1.5
*
RADIUS
);
// Z axis tests
origin
=
Track
(
V3D
{
0.0
,
0.0
,
0.0
},
BEAM_Z
);
sphere
->
interceptSurface
(
origin
);
TS_ASSERT_EQUALS
(
origin
.
front
().
d
istInsideObject
,
RADIUS
);
TS_ASSERT_EQUALS
(
origin
.
totalD
istInsideObject
()
,
RADIUS
);
front_midpoint
=
Track
(
V3D
{
0.0
,
0.0
,
0.5
*
RADIUS
},
BEAM_Z
);
sphere
->
interceptSurface
(
front_midpoint
);
TS_ASSERT_EQUALS
(
front_midpoint
.
front
().
d
istInsideObject
,
0.5
*
RADIUS
);
TS_ASSERT_EQUALS
(
front_midpoint
.
totalD
istInsideObject
()
,
0.5
*
RADIUS
);
back_midpoint
=
Track
(
V3D
{
0.0
,
0.0
,
-
0.5
*
RADIUS
},
BEAM_Z
);
sphere
->
interceptSurface
(
back_midpoint
);
TS_ASSERT_EQUALS
(
back_midpoint
.
front
().
d
istInsideObject
,
1.5
*
RADIUS
);
TS_ASSERT_EQUALS
(
back_midpoint
.
totalD
istInsideObject
()
,
1.5
*
RADIUS
);
}
void
testGeneratePointInsideSphere
()
{
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment