]> Creatis software - clitk.git/blobdiff - segmentation/clitkFilterWithAnatomicalFeatureDatabaseManagement.cxx
Debug RTStruct conversion with empty struc
[clitk.git] / segmentation / clitkFilterWithAnatomicalFeatureDatabaseManagement.cxx
index 6e3e5946c7228f0f3b5be1fc73c43d5e47aa6893..4d96ba3a7e3cbcd2ba19167715105a184f98137a 100644 (file)
@@ -25,6 +25,8 @@ FilterWithAnatomicalFeatureDatabaseManagement()
 {
   m_AFDB = NULL; 
   SetAFDBFilename("default.afdb");
+  SetAFDBPath("./");
+  DisplayUsedStructuresOnlyFlagOff();
 }
 //--------------------------------------------------------------------
 
@@ -42,10 +44,11 @@ void clitk::FilterWithAnatomicalFeatureDatabaseManagement::WriteAFDB()
 void clitk::FilterWithAnatomicalFeatureDatabaseManagement::LoadAFDB() 
 {
   GetAFDB()->SetFilename(GetAFDBFilename());
+  GetAFDB()->SetPath(GetAFDBPath());
   try {
     GetAFDB()->Load();
   } catch (clitk::ExceptionObject e) {
-    std::cout << "Could not read '" << GetAFDBFilename() << "', create one AFDB." << std::endl;
+    std::cout << "******* Could not read '" << GetAFDBFilename() << "', create one AFDB. ********" << std::endl;
     GetAFDB();
   }
 }
@@ -53,11 +56,33 @@ void clitk::FilterWithAnatomicalFeatureDatabaseManagement::LoadAFDB()
 
 
 //--------------------------------------------------------------------
-clitk::AnatomicalFeatureDatabase * clitk::FilterWithAnatomicalFeatureDatabaseManagement::GetAFDB() 
+clitk::AnatomicalFeatureDatabase::Pointer clitk::FilterWithAnatomicalFeatureDatabaseManagement::GetAFDB() 
 {
-  if (m_AFDB == NULL) {
-    m_AFDB = new clitk::AnatomicalFeatureDatabase;
+  if (!m_AFDB) {
+    m_AFDB = clitk::AnatomicalFeatureDatabase::New();
   }
   return m_AFDB;
 }
 //--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+void clitk::FilterWithAnatomicalFeatureDatabaseManagement::
+AddUsedStructures(std::string station, std::string structure)
+{
+  if (!GetDisplayUsedStructuresOnlyFlag()) return;
+  std::cout << station << "\t" << structure;
+  bool founded = true;
+  bool tag = GetAFDB()->TagExist(structure);
+  if (tag) {
+    typedef itk::Image<uchar, 3> ImageType;
+    founded = GetAFDB()->CheckImage<ImageType>(structure);
+    if (!founded) { 
+      std::cout << " \t Image not exist in DB ";
+      std::cout << "<" << GetAFDB()->GetTagValue(structure) << "> ";
+    }
+  }
+  if (!tag) std::cout << " \t Tag not found in DB";
+  std::cout << std::endl;
+}
+//--------------------------------------------------------------------