// std
#include <iterator>
#include <sstream>
+#include <cctype>
+#include <functional>
//--------------------------------------------------------------------
clitk::AnatomicalFeatureDatabase::AnatomicalFeatureDatabase()
{
- SetFilename("noname.afdb");
+ SetFilename("default.afdb");
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
void clitk::AnatomicalFeatureDatabase::Load()
{
+ m_MapOfTag.clear();
// open file
std::ifstream is;
openFileForReading(is, GetFilename());
while (!is.fail()) {
std::string tag;
is >> tag;
- std::string value;
- std::getline(is,value,'\n');
- ltrim(value); // remove leading space
- m_MapOfTag[tag] = value;
+ if (tag != "") {
+ std::string value;
+ std::getline(is,value,'\n');
+ ltrim(value); // remove leading space
+ m_MapOfTag[tag] = value;
+ }
}
+ is.close();
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
+//--------------------------------------------------------------------
+double clitk::AnatomicalFeatureDatabase::GetPoint3D(std::string tag, int dim)
+{
+ PointType3D p;
+ GetPoint3D(tag, p);
+ return p[dim];
+}
+//--------------------------------------------------------------------
+
+
//--------------------------------------------------------------------
void clitk::AnatomicalFeatureDatabase::GetPoint3D(std::string tag, PointType3D & p)
{
// parse the string into 3 doubles
for(int i=0; i<3; i++) {
- p[i] = atof(results[i].c_str());
+
+ if (!clitk::fromString<double>(p[i], results[i].c_str())) {
+ clitkExceptionMacro("Error while reading Point3D, could not convert '"
+ << results[i].c_str() << "' into double.");
+ }
+
+ // p[i] = atof(results[i].c_str());
}
/*
}
//--------------------------------------------------------------------
+
+