]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx
e3b582dfbf7bfcb788f5735e448b72bfc61fa41a
[cpPlugins.git] / lib / cpPlugins / Plugins / BasicFilters / SphereMeshSource.cxx
1 #include "SphereMeshSource.h"
2 #include <cpPlugins/Interface/Image.h>
3 #include <cpPlugins/Interface/Mesh.h>
4
5 #include <vtkSphereSource.h>
6 #include <itkPoint.h>
7
8 // -------------------------------------------------------------------------
9 cpPlugins::BasicFilters::SphereMeshSource::
10 SphereMeshSource( )
11   : Superclass( )
12 {
13   this->m_ClassName = "cpPlugins::BasicFilters::SphereMeshSource";
14   this->m_ClassCategory = "MeshSource";
15
16   this->SetNumberOfInputs( 0 );
17   this->SetNumberOfOutputs( 1 );
18   this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
19
20   using namespace cpPlugins::Interface;
21   this->m_DefaultParameters.Configure( Parameters::Point, "Center" );
22   this->m_DefaultParameters.Configure( Parameters::Real, "Radius" );
23   this->m_DefaultParameters.Configure( Parameters::Uint, "PhiResolution" );
24   this->m_DefaultParameters.Configure( Parameters::Uint, "ThetaResolution" );
25   this->m_DefaultParameters.SetValueAsPoint( "Center", 3, 0, 0, 0 );
26   this->m_DefaultParameters.SetValueAsReal( "Radius", 1 );
27   this->m_DefaultParameters.SetValueAsUint( "PhiResolution", 10 );
28   this->m_DefaultParameters.SetValueAsUint( "ThetaResolution", 10 );
29   this->m_Parameters = this->m_DefaultParameters;
30 }
31
32 // -------------------------------------------------------------------------
33 cpPlugins::BasicFilters::SphereMeshSource::
34 ~SphereMeshSource( )
35 {
36 }
37
38 // -------------------------------------------------------------------------
39 std::string cpPlugins::BasicFilters::SphereMeshSource::
40 _GenerateData( )
41 {
42   itk::Point< double, 3 > center =
43     this->m_Parameters.GetValueAsPoint< itk::Point< double, 3 > >( "Center" );
44   double radius = this->m_Parameters.GetValueAsReal( "Radius" );
45   unsigned int phi = this->m_Parameters.GetValueAsUint( "PhiResolution" );
46   unsigned int theta = this->m_Parameters.GetValueAsUint( "ThetaResolution" );
47
48   vtkSphereSource* src = this->_CreateVTK< vtkSphereSource >( );
49   src->SetCenter( center[ 0 ], center[ 1 ], center[ 2 ] );
50   src->SetRadius( radius );
51   src->SetPhiResolution( phi );
52   src->SetThetaResolution( theta );
53   src->Update( );
54
55   // Execute filter
56   cpPlugins::Interface::Mesh* out =
57     this->GetOutput< cpPlugins::Interface::Mesh >( 0 );
58   out->SetVTK( src->GetOutput( ) );
59   return( "" );
60 }
61
62 // eof - $RCSfile$