57 #define HEADER_FEATURE_SET "FEATURESET"
96 m_featureArray.
Clear();
106 m_contourPointArray.AddElement(element);
116 m_contourPointArray.AddElement(element);
121 m_contourPointArray.Clear();
127 FILE *f = fopen(pFileName,
"wb");
137 #ifdef IVT_BIG_ENDIAN
140 temp = (int) m_sName.length();
143 if (fwrite(&temp,
sizeof(
int), 1, f) != 1)
146 if (m_sName.length() > 0)
148 if (fwrite(m_sName.c_str(), m_sName.length(), 1, f) != 1)
153 const int nContourPoints = m_contourPointArray.GetSize();
155 #ifdef IVT_BIG_ENDIAN
158 temp = nContourPoints;
161 if (fwrite(&temp,
sizeof(
int), 1, f) != 1)
164 for (i = 0; i < nContourPoints; i++)
168 #ifdef IVT_BIG_ENDIAN
176 const float u = point.
point.
x;
177 const float v = point.
point.
y;
184 if (fwrite(&u,
sizeof(
float), 1, f) != 1)
187 if (fwrite(&v,
sizeof(
float), 1, f) != 1)
190 if (fwrite(&x,
sizeof(
float), 1, f) != 1)
193 if (fwrite(&y,
sizeof(
float), 1, f) != 1)
196 if (fwrite(&z,
sizeof(
float), 1, f) != 1)
199 if (fwrite(&nHas3dPoint,
sizeof(
int), 1, f) != 1)
204 const int nFeatures = m_featureArray.
GetSize();
206 #ifdef IVT_BIG_ENDIAN
212 if (fwrite(&temp,
sizeof(
int), 1, f) != 1)
215 for (i = 0; i < nFeatures; i++)
219 #ifdef IVT_BIG_ENDIAN
222 int type = pFeatureEntry->
GetType();
225 if (fwrite(&type,
sizeof(
int), 1, f) != 1)
239 m_featureArray.
Clear();
240 m_contourPointArray.Clear();
242 FILE *f = fopen(pFileName,
"rb");
258 if (fread(&nStringLength,
sizeof(
int), 1, f) != 1)
261 #ifdef IVT_BIG_ENDIAN
265 if (nStringLength < 0 || nStringLength > 4096)
270 if (nStringLength > 0)
273 char *pBuffer =
new char[nStringLength + 1];
276 if (fread(pBuffer, nStringLength, 1, f) != 1)
280 pBuffer[nStringLength] =
'\0';
293 if (fread(&nContourPoints,
sizeof(
int), 1, f) != 1)
299 #ifdef IVT_BIG_ENDIAN
303 if (nContourPoints < 0)
306 for (i = 0; i < nContourPoints; i++)
311 if (fread(&u,
sizeof(
float), 1, f) != 1)
317 if (fread(&v,
sizeof(
float), 1, f) != 1)
323 if (fread(&x,
sizeof(
float), 1, f) != 1)
329 if (fread(&y,
sizeof(
float), 1, f) != 1)
335 if (fread(&z,
sizeof(
float), 1, f) != 1)
341 if (fread(&nHas3dPoint,
sizeof(
int), 1, f) != 1)
347 #ifdef IVT_BIG_ENDIAN
361 m_contourPointArray.AddElement(point);
366 if (fread(&nFeatures,
sizeof(
int), 1, f) != 1)
375 #ifdef IVT_BIG_ENDIAN
379 for (i = 0; i < nFeatures; i++)
383 if (fread(&type,
sizeof(
int), 1, f) != 1)
389 #ifdef IVT_BIG_ENDIAN
403 printf(
"error: type %i in file '%s' is note supported\n", type, pFileName);
409 printf(
"error: ReadFromFile\n");
Data structure for the representation of a 2D vector.
float invert_byte_order_float(float x)
virtual CFeatureEntry * Clone() const =0
void AddElement(T *pElement)
Base class for the representation of local features.
virtual bool WriteToFile(FILE *pFile) const
unsigned int invert_byte_order_int(unsigned int x)
#define HEADER_FEATURE_SET
void AddFeature(const CFeatureEntry *pFeature)
bool LoadFromFile(const char *pFileName)
Data structure for the representation of SIFT features.
Data structure for the representation of a 3D vector.
virtual bool ReadFromFile(FILE *pFile)
void AddFeatureWithoutCloning(CFeatureEntry *pFeature)
virtual eFeatureType GetType() const =0
bool SaveToFile(const char *pFileName) const
void SetName(const char *pName)
void AddContourPoint(const Vec2d &point)
void ClearContourPointList()
void SetVec(Vec2d &vec, float x, float y)
void SetVec(Vec3d &vec, float x, float y, float z)