1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
/// NewMetaVolume.cpp
/**
*/
#include <iostream>
#include <string>
#include <vector>
#include <wx/log.h>
#include "StringConvert.h"
#include "NewMetaVolume.h"
using namespace jcs;
///
/**
*/
NewMetaVolume::NewMetaVolume(const char* filename, const char* he, const char* re)
: BasicVolumeFormat(filename, he, re)
{
}
///
/** Opens header file, writes contents, and closes.
*/
void
NewMetaVolume::WriteHeader(Basic3DHeader* header_3d)
{
NewMetaHeader* header = dynamic_cast<NewMetaHeader*>(header_3d);
if (header == 0) {
wxLogError(_T("Object not meta header type"));
return;
}
if (!mOpenHeaderFile(std::ios::out)) {
wxLogError(_T("Cannot create meta image header file %s"), mFileName.GetFullName().c_str());
return;
}
mHeaderFile << "ObjectType = Image" << std::endl;
mHeaderFile << "NDims = " << header->nDims << std::endl;
mHeaderFile << "DimSize =";
for (int i = 0; i < header->nDims; ++i) {
mHeaderFile << " " << header->dimSize[i];
}
mHeaderFile << std::endl;
mHeaderFile << "ElementSpacing =";
for (int i = 0; i < header->nDims; ++i) {
mHeaderFile << " " << header->elementSpacing[i];
}
mHeaderFile << std::endl;
mHeaderFile << "Position =";
for (int i = 0; i < header->nDims; ++i) {
mHeaderFile << " " << header->origin[i];
}
mHeaderFile << std::endl;
mHeaderFile << "Orientation =";
for (unsigned int i = 0; i < header->orientation.size(); ++i) {
mHeaderFile << " " << header->orientation.at(i);
}
mHeaderFile << std::endl;
mHeaderFile << "CenterOfRotation = 0 0 0" << std::endl;
mHeaderFile << "AnatomicalOrientation = LPS" << std::endl;
mHeaderFile << "ElementByteOrderMSB = " << header->byteOrderMSB << std::endl;
mHeaderFile << "ElementNumberOfChannels = " << header->numberOfChannels << std::endl;
mHeaderFile << "ElementType = " << MET_ValueTypeName[header->elementType] << std::endl;
mHeaderFile << "HeaderSize = " << header->headerSize << std::endl;
std::vector<std::string>::const_iterator it = header->extraFields.begin();
std::vector<std::string>::const_iterator it_end = header->extraFields.end();
for (; it != it_end; it++) {
mHeaderFile << *it << std::endl;
}
mHeaderFile << "ElementDataFile = " << header->elementFile.c_str() << std::endl;
it = header->sourceFileVector.begin();
it_end = header->sourceFileVector.end();
for (; it != it_end; it++) {
mHeaderFile << *it << std::endl;
}
mCloseHeaderFile();
if (verbose && !quiet) {
std::cout << "Wrote " << mFileName.GetFullPath() << std::endl; //.mb_str(wxConvLocal) << std::endl;
}
}
|