Xmipp  v3.23.11-Nereus
ashift_estimator.cpp
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 #include "ashift_estimator.h"
27 
28 namespace Alignment {
29 
30 template<typename T>
32  delete m_dims;
33 
34  m_shifts2D.clear();
35 
37 }
38 
39 template<typename T>
41  m_type = AlignType::None;
42  m_dims = nullptr;
43  m_batch = 0;
44  m_maxShift = 0;
45 
46  // m_shifts2D.reserve(0); // COSS: This is not necessary (size=0), and it is causing some Sonarcloud bug
47 
48  m_isInit = false;
49  m_is_ref_loaded = false;
50  m_is_shift_computed = false;
51 }
52 
53 template<typename T>
55  size_t batch, size_t maxShift) {
56  m_type = type;
57  m_dims = new Dimensions(dims);
58  m_batch = std::min(batch, m_dims->n());
59  m_maxShift = maxShift;
60 
62 }
63 
64 template<typename T>
66  if (AlignType::None == m_type) {
67  REPORT_ERROR(ERR_LOGIC_ERROR, "'None' alignment type is set. This is invalid value");
68  }
69  if ((0 == m_dims->x()) || (0 == m_dims->y())
70  || (0 == m_dims->z()) || (0 == m_dims->n())) {
71  REPORT_ERROR(ERR_VALUE_INCORRECT, "One of the dimensions is zero (0)");
72  }
73  if (0 == m_batch) {
74  REPORT_ERROR(ERR_VALUE_INCORRECT, "Batch is zero (0)");
75  }
76  if (m_batch > m_dims->n()) {
77  REPORT_ERROR(ERR_VALUE_INCORRECT, "Batch is bigger than N");
78  }
79  if (0 == m_maxShift) {
80  REPORT_ERROR(ERR_VALUE_INCORRECT, "Max shift is zero (0)");
81  }
82 }
83 
84 // explicit instantiation
85 template class AShiftEstimator<float>;
86 template class AShiftEstimator<double>;
87 
88 } // namespace
void min(Image< double > &op1, const Image< double > &op2)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
virtual void init2D(const std::vector< HW *> &hw, AlignType type, const Dimensions &dims, size_t batch, size_t maxShift)=0
viol type
Incorrect value received.
Definition: xmipp_error.h:195
Some logical error in the pipeline.
Definition: xmipp_error.h:147