]> Creatis software - FrontAlgorithms.git/blobdiff - plugins/Plugins/InvertCost.cxx
...
[FrontAlgorithms.git] / plugins / Plugins / InvertCost.cxx
diff --git a/plugins/Plugins/InvertCost.cxx b/plugins/Plugins/InvertCost.cxx
new file mode 100644 (file)
index 0000000..fe77e0f
--- /dev/null
@@ -0,0 +1,55 @@
+#include <plugins/Plugins/InvertCost.h>
+#include <cpPlugins/DataObjects/Image.h>
+
+#include <fpa/Base/Functors/Inverse.h>
+#include <fpa/Base/Functors/Inverse.hxx>
+
+// -------------------------------------------------------------------------
+fpaPlugins::InvertCost::
+InvertCost( )
+  : Superclass( )
+{
+  typedef cpPlugins::BaseObjects::DataObject _TData;
+  this->_ConfigureOutput< _TData >( "Output" );
+
+  std::vector< std::string > choices;
+  choices.push_back( "float" );
+  choices.push_back( "double" );
+  this->m_Parameters.ConfigureAsChoices( "ResultType", choices );
+  this->m_Parameters.SetSelectedChoice( "ResultType", "float" );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins::InvertCost::
+~InvertCost( )
+{
+}
+
+// -------------------------------------------------------------------------
+void fpaPlugins::InvertCost::
+_GenerateData( )
+{
+  auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
+  if     ( rtype == "float"  ) this->_GD0< float >( );
+  else if( rtype == "double" ) this->_GD0< double >( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TOutput >
+void fpaPlugins::InvertCost::
+_GD0( )
+{
+  typedef fpa::Base::Functors::Inverse< _TOutput, _TOutput > _TFunctor;
+
+  auto out = this->GetOutput( "Output" );
+  auto f = out->GetITK< _TFunctor >( );
+  if( f == NULL )
+  {
+    typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
+    f = ptr_f.GetPointer( );
+    out->SetITK( f );
+
+  } // fi
+}
+
+// eof - $RCSfile$