Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
f9ff2b71
Commit
f9ff2b71
authored
2 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
merge two vectors
parent
949e97ce
No related branches found
No related tags found
1 merge request
!887
simplify DetectorMask API
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Device/Mask/DetectorMask.cpp
+24
-20
24 additions, 20 deletions
Device/Mask/DetectorMask.cpp
Device/Mask/DetectorMask.h
+5
-2
5 additions, 2 deletions
Device/Mask/DetectorMask.h
auto/Wrap/doxygenDevice.i
+10
-0
10 additions, 0 deletions
auto/Wrap/doxygenDevice.i
with
39 additions
and
22 deletions
Device/Mask/DetectorMask.cpp
+
24
−
20
View file @
f9ff2b71
...
@@ -16,6 +16,17 @@
...
@@ -16,6 +16,17 @@
#include
"Base/Axis/IAxis.h"
#include
"Base/Axis/IAxis.h"
#include
"Device/Histo/Histogram2D.h"
#include
"Device/Histo/Histogram2D.h"
#include
"Device/Mask/IShape2D.h"
#include
"Device/Mask/IShape2D.h"
#include
"Base/Types/ICloneable.h"
class
MaskPattern
:
public
ICloneable
{
public:
MaskPattern
(
IShape2D
*
shape_
,
bool
doMask_
)
:
shape
(
shape_
),
doMask
(
doMask_
)
{}
~
MaskPattern
()
{
delete
shape
;
}
MaskPattern
*
clone
()
const
{
return
new
MaskPattern
(
shape
->
clone
(),
doMask
);
}
IShape2D
*
shape
;
// owning
bool
doMask
;
};
DetectorMask
::
DetectorMask
()
DetectorMask
::
DetectorMask
()
:
m_number_of_masked_channels
(
0
)
:
m_number_of_masked_channels
(
0
)
...
@@ -24,7 +35,6 @@ DetectorMask::DetectorMask()
...
@@ -24,7 +35,6 @@ DetectorMask::DetectorMask()
DetectorMask
::
DetectorMask
(
const
IAxis
&
xAxis
,
const
IAxis
&
yAxis
)
DetectorMask
::
DetectorMask
(
const
IAxis
&
xAxis
,
const
IAxis
&
yAxis
)
{
{
ASSERT
(
m_shapes
.
size
()
==
m_mask_of_shape
.
size
());
m_mask_data
.
clear
();
m_mask_data
.
clear
();
m_mask_data
.
addAxis
(
xAxis
);
m_mask_data
.
addAxis
(
xAxis
);
...
@@ -36,8 +46,7 @@ DetectorMask::DetectorMask(const IAxis& xAxis, const IAxis& yAxis)
...
@@ -36,8 +46,7 @@ DetectorMask::DetectorMask(const IAxis& xAxis, const IAxis& yAxis)
DetectorMask
::~
DetectorMask
()
=
default
;
DetectorMask
::~
DetectorMask
()
=
default
;
DetectorMask
::
DetectorMask
(
const
DetectorMask
&
other
)
DetectorMask
::
DetectorMask
(
const
DetectorMask
&
other
)
:
m_shapes
(
other
.
m_shapes
)
:
m_stack
(
other
.
m_stack
)
,
m_mask_of_shape
(
other
.
m_mask_of_shape
)
,
m_number_of_masked_channels
(
other
.
m_number_of_masked_channels
)
,
m_number_of_masked_channels
(
other
.
m_number_of_masked_channels
)
{
{
m_mask_data
.
copyFrom
(
other
.
m_mask_data
);
m_mask_data
.
copyFrom
(
other
.
m_mask_data
);
...
@@ -46,27 +55,22 @@ DetectorMask::DetectorMask(const DetectorMask& other)
...
@@ -46,27 +55,22 @@ DetectorMask::DetectorMask(const DetectorMask& other)
DetectorMask
&
DetectorMask
::
operator
=
(
const
DetectorMask
&
other
)
DetectorMask
&
DetectorMask
::
operator
=
(
const
DetectorMask
&
other
)
{
{
if
(
this
!=
&
other
)
{
if
(
this
!=
&
other
)
{
m_shapes
=
other
.
m_shapes
;
m_stack
=
other
.
m_stack
;
m_mask_of_shape
=
other
.
m_mask_of_shape
;
m_mask_data
.
copyFrom
(
other
.
m_mask_data
);
m_mask_data
.
copyFrom
(
other
.
m_mask_data
);
m_number_of_masked_channels
=
other
.
m_number_of_masked_channels
;
m_number_of_masked_channels
=
other
.
m_number_of_masked_channels
;
// DetectorMask tmp(other);
// tmp.swapContent(*this);
}
}
return
*
this
;
return
*
this
;
}
}
void
DetectorMask
::
addMask
(
const
IShape2D
&
shape
,
bool
mask_value
)
void
DetectorMask
::
addMask
(
const
IShape2D
&
shape
,
bool
mask_value
)
{
{
m_shapes
.
emplace_back
(
shape
.
clone
());
m_stack
.
emplace_back
(
new
MaskPattern
(
shape
.
clone
(),
mask_value
));
m_mask_of_shape
.
push_back
(
mask_value
);
m_mask_data
.
clear
();
m_mask_data
.
clear
();
m_number_of_masked_channels
=
0
;
m_number_of_masked_channels
=
0
;
}
}
void
DetectorMask
::
initMaskData
(
const
IAxis
&
xAxis
,
const
IAxis
&
yAxis
)
void
DetectorMask
::
initMaskData
(
const
IAxis
&
xAxis
,
const
IAxis
&
yAxis
)
{
{
ASSERT
(
m_shapes
.
size
()
==
m_mask_of_shape
.
size
());
m_mask_data
.
clear
();
m_mask_data
.
clear
();
m_mask_data
.
addAxis
(
xAxis
);
m_mask_data
.
addAxis
(
xAxis
);
...
@@ -91,26 +95,26 @@ Histogram2D* DetectorMask::createHistogram() const
...
@@ -91,26 +95,26 @@ Histogram2D* DetectorMask::createHistogram() const
bool
DetectorMask
::
hasMasks
()
const
bool
DetectorMask
::
hasMasks
()
const
{
{
return
!
m_s
hapes
.
empty
();
return
!
m_s
tack
.
empty
();
}
}
size_t
DetectorMask
::
numberOfMasks
()
const
size_t
DetectorMask
::
numberOfMasks
()
const
{
{
return
m_s
hapes
.
size
();
return
m_s
tack
.
size
();
}
}
const
IShape2D
*
DetectorMask
::
getMaskShape
(
size_t
mask_index
,
bool
&
mask_value
)
const
const
IShape2D
*
DetectorMask
::
getMaskShape
(
size_t
mask_index
,
bool
&
mask_value
)
const
{
{
if
(
mask_index
>=
numberOfMasks
())
if
(
mask_index
>=
numberOfMasks
())
return
nullptr
;
return
nullptr
;
mask_value
=
m_
mask_of_shape
[
mask_index
];
mask_value
=
m_
stack
[
mask_index
]
->
doMask
;
return
m_s
hapes
[
mask_index
];
return
m_s
tack
[
mask_index
]
->
shape
;
}
}
void
DetectorMask
::
process_masks
()
void
DetectorMask
::
process_masks
()
{
{
m_mask_data
.
setAllTo
(
false
);
m_mask_data
.
setAllTo
(
false
);
if
(
!!
m_s
hapes
.
empty
())
if
(
!!
m_s
tack
.
empty
())
return
;
return
;
m_number_of_masked_channels
=
0
;
m_number_of_masked_channels
=
0
;
...
@@ -119,12 +123,12 @@ void DetectorMask::process_masks()
...
@@ -119,12 +123,12 @@ void DetectorMask::process_masks()
Bin1D
biny
=
m_mask_data
.
getAxisBin
(
index
,
1
);
Bin1D
biny
=
m_mask_data
.
getAxisBin
(
index
,
1
);
// setting mask to the data starting from last shape added
// setting mask to the data starting from last shape added
bool
is_masked
(
false
);
bool
is_masked
(
false
);
for
(
size_t
i_shape
=
m_s
hapes
.
size
();
i_shape
>
0
;
--
i_shape
)
{
for
(
size_t
k
=
m_s
tack
.
size
();
k
>
0
;
--
k
)
{
const
IShape2D
*
const
shape
=
m_s
hapes
[
i_shape
-
1
];
const
MaskPattern
*
const
pat
=
m_s
tack
[
k
-
1
];
if
(
shape
->
contains
(
binx
,
biny
))
{
if
(
pat
->
shape
->
contains
(
binx
,
biny
))
{
if
(
m_mask_of_shape
[
i_shape
-
1
]
)
if
(
pat
->
doMask
)
is_masked
=
true
;
is_masked
=
true
;
m_mask_data
[
index
]
=
m_mask_of_shape
[
i_shape
-
1
]
;
m_mask_data
[
index
]
=
pat
->
doMask
;
break
;
// index is covered by the shape, stop looking further
break
;
// index is covered by the shape, stop looking further
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Device/Mask/DetectorMask.h
+
5
−
2
View file @
f9ff2b71
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
class
Histogram2D
;
class
Histogram2D
;
class
IAxis
;
class
IAxis
;
class
IShape2D
;
class
IShape2D
;
class
MaskPattern
;
template
<
class
T
>
template
<
class
T
>
class
Powerfield
;
class
Powerfield
;
...
@@ -65,10 +66,12 @@ public:
...
@@ -65,10 +66,12 @@ public:
private
:
private
:
void
process_masks
();
void
process_masks
();
// primary data:
#ifndef SWIG
#ifndef SWIG
OwningVector
<
IShape2D
>
m_shapes
;
OwningVector
<
MaskPattern
>
m_stack
;
#endif
#endif
std
::
vector
<
bool
>
m_mask_of_shape
;
// cached secondary data:
Powerfield
<
bool
>
m_mask_data
;
Powerfield
<
bool
>
m_mask_data
;
int
m_number_of_masked_channels
;
int
m_number_of_masked_channels
;
};
};
...
...
This diff is collapsed.
Click to expand it.
auto/Wrap/doxygenDevice.i
+
10
−
0
View file @
f9ff2b71
...
@@ -1884,6 +1884,16 @@ C++ includes: LLData.h
...
@@ -1884,6 +1884,16 @@ C++ includes: LLData.h
"
;
"
;
// File: classMaskPattern.xml
%
feature
(
"
docstring
"
)
MaskPattern
""
;
%
feature
(
"
docstring
"
)
MaskPattern
::~
MaskPattern
"
MaskPattern::~MaskPattern()
"
;
%
feature
(
"
docstring
"
)
MaskPattern
::
clone
"
MaskPattern* MaskPattern::clone() const
"
;
// File: classOffSpecularCoordinates.xml
// File: classOffSpecularCoordinates.xml
%
feature
(
"
docstring
"
)
OffSpecularCoordinates
"
%
feature
(
"
docstring
"
)
OffSpecularCoordinates
"
...
...
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