Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Corryvreckan
Corryvreckan
Commits
e05c99f2
Commit
e05c99f2
authored
Jun 03, 2021
by
Jens Kroeger
Browse files
Cluster: remove fallback from getSeedPixel()
parent
bc2c393c
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/objects/Cluster.cpp
View file @
e05c99f2
...
...
@@ -51,29 +51,20 @@ std::vector<const Pixel*> Cluster::pixels() const {
const
Pixel
*
Cluster
::
getSeedPixel
()
const
{
Pixel
*
seed
=
nullptr
;
// If cluster has non-zero charge, return pixel with largest charge,
// else return earliest pixel.
double
maxcharge
=
-
1
;
// If charge != 0 (use epsilon to avoid errors in floating-point arithmetic):
if
(
m_charge
>
std
::
numeric_limits
<
double
>::
epsilon
())
{
// loop overall pixels and find the one with the largest charge:
for
(
auto
&
px
:
m_pixels
)
{
auto
pxl
=
dynamic_cast
<
Pixel
*>
(
px
.
GetObject
());
if
(
pxl
==
nullptr
)
{
throw
MissingReferenceException
(
typeid
(
*
this
),
typeid
(
Pixel
));
}
if
(
pxl
->
charge
()
>
maxcharge
)
{
maxcharge
=
pxl
->
charge
();
seed
=
pxl
;
}
// loop overall pixels and find the one with the largest charge:
for
(
auto
&
px
:
m_pixels
)
{
auto
pxl
=
dynamic_cast
<
Pixel
*>
(
px
.
GetObject
());
if
(
pxl
==
nullptr
)
{
throw
MissingReferenceException
(
typeid
(
*
this
),
typeid
(
Pixel
));
}
return
seed
;
}
else
{
// return the earliest pixel:
return
Cluster
::
getEarliestPixel
();
if
(
pxl
->
charge
()
>
maxcharge
)
{
maxcharge
=
pxl
->
charge
();
seed
=
pxl
;
}
}
return
seed
;
}
const
Pixel
*
Cluster
::
getEarliestPixel
()
const
{
...
...
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