]> Creatis software - cpPlugins.git/commitdiff
Widget integration (step 3/6).
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Sun, 4 Oct 2015 04:43:56 +0000 (06:43 +0200)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Sun, 4 Oct 2015 04:43:56 +0000 (06:43 +0200)
lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx [new file with mode: 0644]
lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.h [new file with mode: 0644]

diff --git a/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx b/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx
new file mode 100644 (file)
index 0000000..e3b582d
--- /dev/null
@@ -0,0 +1,62 @@
+#include "SphereMeshSource.h"
+#include <cpPlugins/Interface/Image.h>
+#include <cpPlugins/Interface/Mesh.h>
+
+#include <vtkSphereSource.h>
+#include <itkPoint.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::BasicFilters::SphereMeshSource::
+SphereMeshSource( )
+  : Superclass( )
+{
+  this->m_ClassName = "cpPlugins::BasicFilters::SphereMeshSource";
+  this->m_ClassCategory = "MeshSource";
+
+  this->SetNumberOfInputs( 0 );
+  this->SetNumberOfOutputs( 1 );
+  this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
+
+  using namespace cpPlugins::Interface;
+  this->m_DefaultParameters.Configure( Parameters::Point, "Center" );
+  this->m_DefaultParameters.Configure( Parameters::Real, "Radius" );
+  this->m_DefaultParameters.Configure( Parameters::Uint, "PhiResolution" );
+  this->m_DefaultParameters.Configure( Parameters::Uint, "ThetaResolution" );
+  this->m_DefaultParameters.SetValueAsPoint( "Center", 3, 0, 0, 0 );
+  this->m_DefaultParameters.SetValueAsReal( "Radius", 1 );
+  this->m_DefaultParameters.SetValueAsUint( "PhiResolution", 10 );
+  this->m_DefaultParameters.SetValueAsUint( "ThetaResolution", 10 );
+  this->m_Parameters = this->m_DefaultParameters;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::BasicFilters::SphereMeshSource::
+~SphereMeshSource( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::BasicFilters::SphereMeshSource::
+_GenerateData( )
+{
+  itk::Point< double, 3 > center =
+    this->m_Parameters.GetValueAsPoint< itk::Point< double, 3 > >( "Center" );
+  double radius = this->m_Parameters.GetValueAsReal( "Radius" );
+  unsigned int phi = this->m_Parameters.GetValueAsUint( "PhiResolution" );
+  unsigned int theta = this->m_Parameters.GetValueAsUint( "ThetaResolution" );
+
+  vtkSphereSource* src = this->_CreateVTK< vtkSphereSource >( );
+  src->SetCenter( center[ 0 ], center[ 1 ], center[ 2 ] );
+  src->SetRadius( radius );
+  src->SetPhiResolution( phi );
+  src->SetThetaResolution( theta );
+  src->Update( );
+
+  // Execute filter
+  cpPlugins::Interface::Mesh* out =
+    this->GetOutput< cpPlugins::Interface::Mesh >( 0 );
+  out->SetVTK( src->GetOutput( ) );
+  return( "" );
+}
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.h b/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.h
new file mode 100644 (file)
index 0000000..6ea0aae
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef __CPPLUGINS__PLUGINS__SPHEREMESHSOURCE__H__
+#define __CPPLUGINS__PLUGINS__SPHEREMESHSOURCE__H__
+
+#include <cpPlugins/BasicFilters/cpPluginsBasicFilters_Export.h>
+#include <cpPlugins/Interface/BaseProcessObjects.h>
+
+namespace cpPlugins
+{
+  namespace BasicFilters
+  {
+    /**
+     */
+    class cpPluginsBasicFilters_EXPORT SphereMeshSource
+      : public cpPlugins::Interface::MeshSource
+    {
+    public:
+      typedef SphereMeshSource                 Self;
+      typedef cpPlugins::Interface::MeshSource Superclass;
+      typedef itk::SmartPointer< Self >        Pointer;
+      typedef itk::SmartPointer< const Self >  ConstPointer;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( SphereMeshSource, cpPluginsInterfaceMeshSource );
+
+    protected:
+      SphereMeshSource( );
+      virtual ~SphereMeshSource( );
+
+      virtual std::string _GenerateData( );
+
+    private:
+      // Purposely not implemented
+      SphereMeshSource( const Self& );
+      Self& operator=( const Self& );
+    };
+
+    // ---------------------------------------------------------------------
+    CPPLUGINS_INHERIT_PROVIDER( SphereMeshSource );
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__PLUGINS__SPHEREMESHSOURCE__H__
+
+// eof - $RCSfile$