Xmipp  v3.23.11-Nereus
rwSPE.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 "xmipp_image_base.h"
27 #include "xmipp_error.h"
28 #include "metadata_static.h"
29 #include "xmipp_funcs.h"
30 
33 
34 // I/O prototypes
38 int ImageBase::readSPE(size_t select_img,bool isStack)
39 {
40 
41  int _xDim,_yDim,_zDim;
42  size_t _nDim;
43 
44  short int aux;
45  fseek(fimg,42,SEEK_SET);
46  xmippFREAD(&aux, sizeof(short int), 1, fimg, swap );
47  _xDim = aux;
48  fseek(fimg,656,SEEK_SET);
49  xmippFREAD(&aux, sizeof(short int), 1, fimg, swap );
50  _yDim = aux;
51 
52  _zDim = 1;
53  _nDim = 1;
54 
55  // Map the parameters
56  setDimensions(_xDim, _yDim, _zDim, _nDim);
57 
58  offset = 4100;
60 
63  MDMainHeader.setValue(MDL_DATATYPE,(int)datatype);
64 
65  if (dataMode==HEADER) // Stop reading if not necessary
66  return 0;
67 
68  size_t imgStart = IMG_INDEX(select_img);
69  size_t imgEnd = (select_img != ALL_IMAGES) ? imgStart + 1 : _nDim;
70 
71  MD.clear();
72  for (size_t i = 0; i < imgEnd-imgStart; i++)
73  MD.push_back(std::unique_ptr<MDRowVec>(new MDRowVec(MDL::emptyHeaderVec())));
74  if( dataMode < DATA )
75  return 0;
76 
77  size_t pad = 0;
78 
79  readData(fimg, select_img, datatype, pad);
80 
81  return(0);
82 }
83 
84 int ImageBase::writeSPE(size_t select_img, bool isStack, int mode)
85 {
86  REPORT_ERROR(ERR_IMG_NOWRITE, "writeSPE is not implemented.");
87 }
sampling rate in A/pixel (double)
sampling rate in A/pixel (double)
DataMode dataMode
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
int writeSPE(size_t select_img, bool isStack=false, int mode=WRITE_OVERWRITE)
Definition: rwSPE.cpp:84
virtual void readData(FILE *fimg, size_t select_img, DataType datatype, size_t pad)=0
void setValue(const MDObject &object) override
std::vector< std::unique_ptr< MDRow > > MD
int readSPE(size_t select_img, bool isStack=false)
Definition: rwSPE.cpp:38
if read from file original image datatype, this is an struct defined in image
Cannot write image to file.
Definition: xmipp_error.h:129
#define i
virtual void setDimensions(int Xdim, int Ydim, int Zdim, size_t Ndim)=0
static MDRowVec emptyHeaderVec()
DataType
void mode
size_t xmippFREAD(void *dest, size_t size, size_t nitems, FILE *&fp, bool reverse)
MDRowVec MDMainHeader
DataType datatype() const
#define ALL_IMAGES
#define IMG_INDEX(select_img)