]> Creatis software - clitk.git/blobdiff - segmentation/clitkAnatomicalFeatureDatabase.txx
Debug RTStruct conversion with empty struc
[clitk.git] / segmentation / clitkAnatomicalFeatureDatabase.txx
index 02907716c64c198674b95699cc15b481a657a201..dc7c39a6652d9672e44543e317ec22860e1afd3d 100644 (file)
@@ -34,7 +34,10 @@ GetImage(std::string tag, bool reload)
     else {
       std::string s = m_MapOfTag[tag];
       // Read the file
-      image = readImage<ImageType>(s);
+      if (s[0] != '/')
+        image = readImage<ImageType>(GetPath() + "/" + s);
+      else
+        image = readImage<ImageType>(s);
       // I add a reference count because the cache is not a smartpointer
       image->SetReferenceCount(image->GetReferenceCount()+1);
       // Insert into the cache
@@ -47,6 +50,39 @@ GetImage(std::string tag, bool reload)
 //--------------------------------------------------------------------
 
 
+//--------------------------------------------------------------------
+template<class ImageType>
+bool AnatomicalFeatureDatabase::
+CheckImage(std::string tag)
+{
+  if (m_MapOfTag.find(tag) == m_MapOfTag.end()) {
+    return false;
+  }
+  else {
+    typename ImageType::Pointer image;
+    if (m_MapOfImage[tag]) {
+      image = static_cast<ImageType *>(m_MapOfImage[tag]);
+    }
+    else {
+      std::string s = m_MapOfTag[tag];
+      // Read the file
+      std::string n = GetPath()+"/"+s;
+      //      image = readImage<ImageType>();
+      typedef itk::ImageFileReader<ImageType> ReaderType;
+      typename ReaderType::Pointer reader = ReaderType::New();
+      reader->SetFileName(n.c_str());
+      try {
+        reader->Update();
+      } catch(itk::ExceptionObject & err) {
+        return false;
+      }
+    }
+  }
+  return true;
+}
+//--------------------------------------------------------------------
+
+
 //--------------------------------------------------------------------
 template<class ImageType>
 void AnatomicalFeatureDatabase::