Xmipp
v3.23.11-Nereus
xmipp
libraries
reconstruction
ageo_transformer.h
Go to the documentation of this file.
1
/***************************************************************************
2
*
3
* Authors: David Strelak (davidstrelak@gmail.com)
4
*
5
* Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6
*
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20
* 02111-1307 USA
21
*
22
* All comments concerning this program package may be sent to the
23
* e-mail address 'xmipp@cnb.csic.es'
24
***************************************************************************/
25
26
#ifndef LIBRARIES_RECONSTRUCTION_AGEO_TRANSFORMER_H_
27
#define LIBRARIES_RECONSTRUCTION_AGEO_TRANSFORMER_H_
28
29
#include "
data/dimensions.h
"
30
#include "
core/xmipp_error.h
"
31
#include <memory>
32
#include "
data/hw.h
"
33
#include <vector>
34
38
enum class
InterpolationDegree
{
Linear
,
Cubic
};
39
enum class
InterpolationType
{
40
OneToN
,
// we have one original item, output are multiple items derived from the original one
41
NToN
// we have multiple original items, output are multiple items derived from respective original one
42
};
43
44
template
<
typename
T>
45
class
GeoTransformerSettings
{
46
public
:
47
virtual
~
GeoTransformerSettings
() =
default
;
48
std::vector<HW*>
hw
;
49
Dimensions
dims =
Dimensions
(0);
50
InterpolationDegree
degree
;
51
InterpolationType
type
;
52
bool
doWrap
;
53
T
defaultVal
;
54
55
virtual
void
check
()
const
{
56
if
(0 == hw.size()) {
57
REPORT_ERROR
(
ERR_VALUE_INCORRECT
,
"HW contains zero (0) devices"
);
58
}
59
if
( ! dims.
isValid
()) {
60
REPORT_ERROR
(
ERR_LOGIC_ERROR
,
"Dimensions are invalid"
);
61
}
62
}
63
};
64
65
template
<
typename
SettingsType,
typename
T>
66
class
AGeoTransformer
{
67
static_assert(std::is_base_of<
GeoTransformerSettings<T>
, SettingsType>::value,
68
"SettingsType must inherit from GeoTransformerSettings"
);
69
public
:
70
AGeoTransformer
() :
71
m_isInit(false),
72
m_isSrcSet(false) {};
73
virtual
~
AGeoTransformer
() =
default
;
74
75
void
init
(
const
SettingsType &s,
bool
reuse) {
76
s.check();
77
bool
skipAllocation = reuse && this->isInitialized() && canBeReused(s);
78
m_settings = s;
79
this->initialize( ! skipAllocation);
80
this->
check
();
81
m_isInit =
true
;
82
}
83
84
virtual
void
setSrc(
const
T *data) = 0;
85
virtual
const
T *getSrc()
const
= 0;
86
87
virtual
T *getDest()
const
= 0;
88
virtual
void
copySrcToDest() = 0;
89
90
inline
const
SettingsType &
getSettings
()
const
{
91
return
m_settings;
92
}
93
94
protected
:
95
virtual
void
check
() = 0;
96
virtual
void
initialize(
bool
allocate) = 0;
97
virtual
bool
canBeReused(
const
SettingsType &s)
const
= 0;
98
99
inline
constexpr
bool
isInitialized
()
const
{
100
return
m_isInit;
101
}
102
103
inline
constexpr
bool
isSrcSet
()
const
{
104
return
m_isSrcSet;
105
}
106
107
void
setIsSrcSet
(
bool
status) {
108
m_isSrcSet = status;
109
}
110
111
private
:
112
SettingsType m_settings;
113
bool
m_isInit;
114
bool
m_isSrcSet;
115
};
117
118
#endif
/* LIBRARIES_RECONSTRUCTION_AGEO_TRANSFORMER_H_ */
InterpolationDegree::Cubic
AGeoTransformer::getSettings
const SettingsType & getSettings() const
Definition:
ageo_transformer.h:90
REPORT_ERROR
#define REPORT_ERROR(nerr, ErrormMsg)
Definition:
xmipp_error.h:211
GeoTransformerSettings::doWrap
bool doWrap
Definition:
ageo_transformer.h:52
AGeoTransformer
Definition:
ageo_transformer.h:66
AGeoTransformer::init
void init(const SettingsType &s, bool reuse)
Definition:
ageo_transformer.h:75
AGeoTransformer::isSrcSet
constexpr bool isSrcSet() const
Definition:
ageo_transformer.h:103
GeoTransformerSettings::check
virtual void check() const
Definition:
ageo_transformer.h:55
InterpolationType
InterpolationType
Definition:
ageo_transformer.h:39
GeoTransformerSettings::degree
InterpolationDegree degree
Definition:
ageo_transformer.h:50
dimensions.h
AGeoTransformer::isInitialized
constexpr bool isInitialized() const
Definition:
ageo_transformer.h:99
hw.h
GeoTransformerSettings::hw
std::vector< HW * > hw
Definition:
ageo_transformer.h:48
AGeoTransformer::setIsSrcSet
void setIsSrcSet(bool status)
Definition:
ageo_transformer.h:107
InterpolationDegree
InterpolationDegree
Definition:
ageo_transformer.h:38
Dimensions
Definition:
dimensions.h:35
InterpolationType::NToN
Dimensions::isValid
constexpr bool isValid() const
Definition:
dimensions.h:138
GeoTransformerSettings::defaultVal
T defaultVal
Definition:
ageo_transformer.h:53
AGeoTransformer::AGeoTransformer
AGeoTransformer()
Definition:
ageo_transformer.h:70
InterpolationType::OneToN
xmipp_error.h
GeoTransformerSettings::type
InterpolationType type
Definition:
ageo_transformer.h:51
GeoTransformerSettings
Definition:
ageo_transformer.h:45
ERR_VALUE_INCORRECT
Incorrect value received.
Definition:
xmipp_error.h:195
InterpolationDegree::Linear
check
check(nparam, nf, nfsr, &Linfty, nineq, nineqn, neq, neqn, ncsrl, ncsrn, mode, &modem, eps, bgbnd, param)
ERR_LOGIC_ERROR
Some logical error in the pipeline.
Definition:
xmipp_error.h:147
Generated by
1.8.13