Xmipp  v3.23.11-Nereus
ashift_estimator.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_ASHIFT_ESTIMATOR_H_
27 #define LIBRARIES_RECONSTRUCTION_ASHIFT_ESTIMATOR_H_
28 
29 #include "data/hw.h"
30 #include "data/dimensions.h"
31 #include "data/point2D.h"
32 #include "core/xmipp_error.h"
33 #include "align_type.h"
34 #include <vector>
35 
39 namespace Alignment {
40 
41 template<typename T>
43 public:
45  setDefault();
46  }
47  AShiftEstimator(const AShiftEstimator &)=delete;
48  AShiftEstimator(const AShiftEstimator &&)=delete;
49 
50  virtual ~AShiftEstimator() {
51  release();
52  }
53 
54  AShiftEstimator & operator=(const AShiftEstimator &)=delete;
55  AShiftEstimator & operator=(const AShiftEstimator &&)=delete;
56 
57  virtual void init2D(const std::vector<HW*> &hw, AlignType type,
58  const Dimensions &dims, size_t batch, size_t maxShift) = 0;
59 
60  virtual void load2DReferenceOneToN(const T *ref) = 0;
61 
62  virtual void computeShift2DOneToN(T *others) = 0; // FIXME DS it should erase m_shifts2D
63 
64  inline std::vector<Point2D<float>> getShifts2D() {
65  if ( ! m_is_shift_computed) {
66  REPORT_ERROR(ERR_LOGIC_ERROR, "Shift has not been yet computed or it has been already retrieved");
67  }
68  auto cpy = std::vector<Point2D<float>>();
69  cpy.swap(m_shifts2D);
70  m_is_shift_computed = false;
71  return cpy;
72  }
73 
74  virtual void release();
75 
76  constexpr bool isInitialized() const {
77  return m_isInit;
78  }
79 
80  constexpr Dimensions getDimensions() const {
81  return *m_dims;
82  }
83 
84  constexpr AlignType getAlignType() const {
85  return m_type;
86  }
87 
88  virtual HW& getHW() const = 0;
89 
90 protected:
91  // various
94  size_t m_batch;
95  size_t m_maxShift;
96 
97  // computed shifts
98  std::vector<Point2D<float>> m_shifts2D;
99 
100  // flags
103  bool m_isInit;
104 
105  virtual void setDefault();
106  virtual void init2D(AlignType type, const Dimensions &dims,
107  size_t batch, size_t maxShift);
108  virtual void check();
109 };
110 
111 } /* namespace Alignment */
113 #endif /* LIBRARIES_RECONSTRUCTION_ASHIFT_ESTIMATOR_H_ */
virtual void computeShift2DOneToN(T *others)=0
std::vector< Point2D< float > > getShifts2D()
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
std::vector< Point2D< float > > m_shifts2D
AShiftEstimator & operator=(const AShiftEstimator &)=delete
Definition: hw.h:35
virtual void init2D(const std::vector< HW *> &hw, AlignType type, const Dimensions &dims, size_t batch, size_t maxShift)=0
virtual HW & getHW() const =0
viol type
constexpr bool isInitialized() const
const Dimensions * m_dims
constexpr AlignType getAlignType() const
virtual void load2DReferenceOneToN(const T *ref)=0
constexpr Dimensions getDimensions() const
Some logical error in the pipeline.
Definition: xmipp_error.h:147