Xmipp  v3.23.11-Nereus
multidim_array_generic.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Authors: Joaquin Oton (joton@cnb.csic.es)
3  *
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 "multidim_array_generic.h"
27 
29 {
30  im = array;
31  datatype = _datatype;
32  destroyData = false;
33 }
34 
36 {
37  init();
38  setDatatype(mdim.datatype);
39 
40 #define ALIAS(type) ((MultidimArray<type>*)(im))->aliasSlice(*((MultidimArray<type>*)mdim.im), select_slice);
41 
43 #undef ALIAS
44 }
45 
47 {
48  if (im != NULL && destroyData)
49  delete im;
50 }
52 {
53  im = NULL;
55  destroyData = true;
56 }
57 
59 {
60  if (im != NULL && destroyData)
61  {
62  im->clear();
63  delete im;
64  init();
65  }
66 }
67 
69 {
70  im = array;
71  destroyData = false;
72 }
73 
74 
76 {
77  clear();
78  datatype = imgType;
79  destroyData = true;
80 
81  switch (datatype)
82  {
83  case DT_Float:
84  {
86  im = imT;
87  }
88  break;
89  case DT_UInt:
90  {
92  im = imT;
93  }
94  break;
95  case DT_Int:
96  {
98  im = imT;
99  }
100  break;
101  case DT_UShort:
102  {
104  im = imT;
105  }
106  break;
107  case DT_Short:
108  {
110  im = imT;
111  }
112  break;
113  case DT_UHalfByte:
114  case DT_UChar:
115  {
117  im = imT;
118  }
119  break;
120  case DT_SChar:
121  {
123  im = imT;
124  }
125  break;
126  case DT_Unknown:
128  default:
129  REPORT_ERROR(ERR_NOT_IMPLEMENTED, "Datatype not implemented.");
130  }
131 }
132 
134 {
135  if (datatype != mdA.datatype)
136  {
137  return false;
138 
139  }
140 
141 #define COMPARE(type) return ( ((MultidimArray<type>*)im)->equal(*(MultidimArray<type>*)mdA.im) );
143 #undef COMPARE
144 }
145 
146 
148  double accuracy) const
149 {
150  if (datatype != op.datatype)
151  {
152  return false;
153  }
154 
155 #define COMPARE(type) return ((MultidimArray<type>*)im)->equal(*(MultidimArray<type>*)op.im,accuracy);
157 #undef COMPARE
158 }
159 
160 
161 
163 {
164  setDatatype(mdim.datatype);
165 
166 #define ALIAS(type) ((MultidimArray<type>*)(im))->aliasSlice(*((MultidimArray<type>*)mdim.im), select_slice);
167 
169 #undef ALIAS
170 }
Case or algorithm not implemented yet.
Definition: xmipp_error.h:177
void aliasSlice(MultidimArrayGeneric &mdim, int select_slice)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
Unknown image type.
Definition: xmipp_error.h:130
void setDatatype(DataType imgType)
#define ALIAS(type)
bool equal(const MultidimArrayGeneric &op, double accuracy=XMIPP_EQUAL_ACCURACY) const
DataType
void link(MultidimArrayBase *array)
bool operator==(const MultidimArrayGeneric &mdA) const
#define COMPARE(type)
virtual void clear()=0
#define SWITCHDATATYPE(datatype, OP)