]> Creatis software - clitk.git/blobdiff - itk/clitkAddRelativePositionConstraintToLabelImageFilter.txx
Explicit units for Angle (rad or deg)
[clitk.git] / itk / clitkAddRelativePositionConstraintToLabelImageFilter.txx
index 54f431109728bd8b31b4bdbd8b5d09cc9679e441..e25f98b829fa3c65ed497f5fb5ffd73de863a066 100644 (file)
@@ -22,6 +22,7 @@
 #include "clitkAutoCropFilter.h"
 #include "clitkResampleImageWithOptionsFilter.h"
 #include "clitkBooleanOperatorLabelImageFilter.h"
+#include "clitkCropLikeImageFilter.h"
 
 // itk
 #include <deque>
@@ -61,6 +62,7 @@ AddRelativePositionConstraintToLabelImageFilter():
   CombineWithOrFlagOff();
   VerboseStepFlagOff();
   WriteStepFlagOff();
+  FuzzyMapOnlyFlagOff();
 }
 //--------------------------------------------------------------------
 
@@ -121,22 +123,24 @@ clitk::AddRelativePositionConstraintToLabelImageFilter<ImageType>::
 AddOrientationTypeString(std::string t) 
 {
   m_OrientationTypeString.push_back(t);
-  switch (t[0]) {
-  case 'L' : AddOrientationType(AtLeftTo); break;
-  case 'R' : AddOrientationType(AtRightTo);break;
-  case 'A' : AddOrientationType(AntTo);break;
-  case 'P' : AddOrientationType(PostTo);break;
-  case 'S' : AddOrientationType(SupTo);break;
-  case 'I' : AddOrientationType(InfTo);break;
-  case 'N': 
-    if (t == "NotLeftTo") { AddOrientationType(AtLeftTo); InverseOrientationFlagOn(); break; }
-    if (t == "NotRightTo") { AddOrientationType(AtRightTo); InverseOrientationFlagOn(); break; }
-    if (t == "NotAntTo") { AddOrientationType(AntTo); InverseOrientationFlagOn(); break; }
-    if (t == "NotPostTo") { AddOrientationType(PostTo); InverseOrientationFlagOn(); break; }
-    if (t == "NotSupTo") { AddOrientationType(SupTo); InverseOrientationFlagOn(); break; }
-    if (t == "NotInfTo") { AddOrientationType(InfTo); InverseOrientationFlagOn(); break; }
-  default: clitkExceptionMacro("Error, you must provide L,R or A,P or S,I (or NotLeftTo, NotRightTo etc)");
-  }
+
+  if (t == "LeftTo") { AddOrientationType(LeftTo); return; }
+  if (t == "RightTo") { AddOrientationType(RightTo); return; }
+  if (t == "AntTo") { AddOrientationType(AntTo); return; }
+  if (t == "PostTo") { AddOrientationType(PostTo); return; }
+  if (t == "SupTo") { AddOrientationType(SupTo); return; }
+  if (t == "InfTo") { AddOrientationType(InfTo); return; }
+
+  if (t == "NotLeftTo") { AddOrientationType(LeftTo); InverseOrientationFlagOn(); return; }
+  if (t == "NotRightTo") { AddOrientationType(RightTo); InverseOrientationFlagOn(); return; }
+  if (t == "NotAntTo") { AddOrientationType(AntTo); InverseOrientationFlagOn(); return; }
+  if (t == "NotPostTo") { AddOrientationType(PostTo); InverseOrientationFlagOn(); return; }
+  if (t == "NotSupTo") { AddOrientationType(SupTo); InverseOrientationFlagOn(); return; }
+  if (t == "NotInfTo") { AddOrientationType(InfTo); InverseOrientationFlagOn(); return; }
+
+  if (t == "Angle") return;
+
+  clitkExceptionMacro("Error, you must provide LeftTo,RightTo or AntTo,PostTo or SupTo,InfTo (or NotLeftTo, NotRightTo etc) but you give " << t);
 }
 //--------------------------------------------------------------------
   
@@ -175,15 +179,27 @@ GenerateInputRequestedRegion()
 template <class ImageType>
 void 
 clitk::AddRelativePositionConstraintToLabelImageFilter<ImageType>::
-AddAngles(double a, double b) 
+AddAnglesInRad(double a, double b) 
 {
-  AddOrientationTypeString("Angle");
+  m_OrientationTypeString.push_back("Angle");
+  m_OrientationType.push_back(Angle);
   m_Angle1.push_back(a);
   m_Angle2.push_back(b);
 }
 //--------------------------------------------------------------------
 
 
+//--------------------------------------------------------------------
+template <class ImageType>
+void 
+clitk::AddRelativePositionConstraintToLabelImageFilter<ImageType>::
+AddAnglesInDeg(double a, double b) 
+{
+  AddAnglesInRad(clitk::deg2rad(a), clitk::deg2rad(b));
+}
+//--------------------------------------------------------------------
+
+
 //--------------------------------------------------------------------
 template <class ImageType>
 void 
@@ -192,11 +208,11 @@ AddOrientationType(OrientationTypeEnumeration orientation)
 {
   m_OrientationType.push_back(orientation);
   switch (orientation) {
-  case AtRightTo:   
+  case RightTo:   
     m_Angle1.push_back(clitk::deg2rad(0));   
     m_Angle2.push_back(clitk::deg2rad(0));
     break;
-  case AtLeftTo:  
+  case LeftTo:  
     m_Angle1.push_back(clitk::deg2rad(180)); 
     m_Angle2.push_back(clitk::deg2rad(0));
     break;
@@ -230,6 +246,26 @@ AddOrientationType(OrientationTypeEnumeration orientation)
 //--------------------------------------------------------------------
 
 
+//--------------------------------------------------------------------
+template <class ImageType>
+void 
+clitk::AddRelativePositionConstraintToLabelImageFilter<ImageType>::
+PrintOptions() 
+{
+  DD((int)this->GetBackgroundValue());
+  DD((int)this->GetObjectBackgroundValue());
+  DDV(this->GetOrientationTypeString(), (uint)this->GetNumberOfAngles());
+  DD(this->GetIntermediateSpacingFlag());
+  DD(this->GetIntermediateSpacing());
+  DD(this->GetFuzzyThreshold());
+  DD(this->GetAutoCropFlag());
+  DD(this->GetInverseOrientationFlag());
+  DD(this->GetRemoveObjectFlag());
+  DD(this->GetCombineWithOrFlag());
+}
+//--------------------------------------------------------------------
+
+
 //--------------------------------------------------------------------
 template <class ImageType>
 void 
@@ -240,6 +276,18 @@ GenerateData()
     clitkExceptionMacro("Add at least one orientation type");
   }  
 
+  if (GetVerboseOptionFlag()) {
+    for(int i=0; i<GetNumberOfAngles(); i++) {
+        std::cout << "Orientation    \t:" << GetOrientationTypeString(i) << std::endl;
+    }
+    std::cout << "Interm Spacing \t:" << GetIntermediateSpacingFlag() << " " << GetIntermediateSpacing() << "mm" << std::endl;
+    std::cout << "Fuzzy threshold\t:" << GetFuzzyThreshold() << std::endl;
+    std::cout << "AutoCrop       \t:" << GetAutoCropFlag() << std::endl;
+    std::cout << "InverseOrient  \t:" << GetInverseOrientationFlag() << std::endl;
+    std::cout << "RemoveObject   \t:" << GetRemoveObjectFlag() << std::endl;
+    std::cout << "CombineWithOr  \t:" << GetCombineWithOrFlag() << std::endl;
+  }
+
   // Get input pointer
   input = dynamic_cast<ImageType*>(itk::ProcessObject::GetInput(0));
   object = dynamic_cast<ImageType*>(itk::ProcessObject::GetInput(1));
@@ -329,7 +377,6 @@ GenerateData()
   typedef itk::RelativePositionPropImageFilter<ImageType, FloatImageType> RelPosFilterType;
   typename RelPosFilterType::Pointer relPosFilter;
 
-  typename FloatImageType::Pointer m_FuzzyMap;
   for(int i=0; i<GetNumberOfAngles(); i++) {
     // Compute fuzzy map
     relPosFilter = RelPosFilterType::New();
@@ -379,6 +426,7 @@ GenerateData()
 
   relPos = m_FuzzyMap;
   StopCurrentStep<FloatImageType>(relPos);
+  if (GetFuzzyMapOnlyFlag()) return;
                
   //--------------------------------------------------------------------
   //--------------------------------------------------------------------