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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
/*============================================================================
MetaIO
Copyright 2000-2010 Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#include "metaGaussian.h"
#ifdef _MSC_VER
# pragma warning(disable : 4702)
#endif
#if (METAIO_USE_NAMESPACE)
namespace METAIO_NAMESPACE
{
#endif
//
// MedImage Constructors
//
MetaGaussian::MetaGaussian()
{
META_DEBUG_PRINT( "MetaGaussian()" );
MetaGaussian::Clear();
}
//
MetaGaussian::MetaGaussian(const char * _headerName)
{
META_DEBUG_PRINT( "MetaGaussian()" );
MetaGaussian::Clear();
MetaGaussian::Read(_headerName);
}
//
MetaGaussian::MetaGaussian(const MetaGaussian * _gaussian)
{
META_DEBUG_PRINT( "MetaGaussian()" );
MetaGaussian::Clear();
MetaGaussian::CopyInfo(_gaussian);
}
MetaGaussian::MetaGaussian(unsigned int dim)
: MetaObject(dim)
{
META_DEBUG_PRINT( "MetaGaussian()" );
MetaGaussian::Clear();
}
//
MetaGaussian::~MetaGaussian()
{
MetaObject::M_Destroy();
}
//
void
MetaGaussian::PrintInfo() const
{
MetaObject::PrintInfo();
std::cout << "\n"
<< "Maximum = " << m_Maximum << "\n"
<< "Radius = " << m_Radius << "Sigma = " << m_Sigma << std::endl;
}
void
MetaGaussian::CopyInfo(const MetaObject * _object)
{
MetaObject::CopyInfo(_object);
}
/** Clear gaussian information */
void
MetaGaussian::Clear()
{
META_DEBUG_PRINT( "MetaGaussian: Clear" );
MetaObject::Clear();
strcpy(m_ObjectTypeName, "Gaussian");
m_Maximum = 1;
m_Radius = 1;
m_Sigma = 1;
}
/** Set Read fields */
void
MetaGaussian::M_SetupReadFields()
{
META_DEBUG_PRINT( "MetaGaussian: M_SetupReadFields" );
MetaObject::M_SetupReadFields();
MET_FieldRecordType * mF;
MET_GetFieldRecordNumber("NDims", &m_Fields);
mF = new MET_FieldRecordType;
MET_InitReadField(mF, "Maximum", MET_FLOAT, true);
m_Fields.push_back(mF);
mF = new MET_FieldRecordType;
MET_InitReadField(mF, "Radius", MET_FLOAT, true);
m_Fields.push_back(mF);
mF = new MET_FieldRecordType;
MET_InitReadField(mF, "Sigma", MET_FLOAT, true);
m_Fields.push_back(mF);
}
void
MetaGaussian::M_SetupWriteFields()
{
MetaObject::M_SetupWriteFields();
MET_FieldRecordType * mF;
mF = new MET_FieldRecordType;
MET_InitWriteField(mF, "Maximum", MET_FLOAT, m_Maximum);
m_Fields.push_back(mF);
mF = new MET_FieldRecordType;
MET_InitWriteField(mF, "Radius", MET_FLOAT, m_Radius);
m_Fields.push_back(mF);
mF = new MET_FieldRecordType;
MET_InitWriteField(mF, "Sigma", MET_FLOAT, m_Sigma);
m_Fields.push_back(mF);
}
bool
MetaGaussian::M_Read()
{
META_DEBUG_PRINT( "MetaGaussian: M_Read: Loading Header" );
if (!MetaObject::M_Read())
{
std::cout << "MetaGaussian: M_Read: Error parsing file" << std::endl;
return false;
}
META_DEBUG_PRINT( "MetaGaussian: M_Read: Parsing Header" );
MET_FieldRecordType * mF;
mF = MET_GetFieldRecord("Maximum", &m_Fields);
if (mF->defined)
{
m_Maximum = static_cast<float>(mF->value[0]);
}
mF = MET_GetFieldRecord("Radius", &m_Fields);
if (mF->defined)
{
m_Radius = static_cast<float>(mF->value[0]);
}
mF = MET_GetFieldRecord("Sigma", &m_Fields);
if (mF->defined)
{
m_Sigma = static_cast<float>(mF->value[0]);
}
return true;
}
#if (METAIO_USE_NAMESPACE)
};
#endif
|