]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx
Merge branch 'master' of ssh://git.creatis.insa-lyon.fr/cpPlugins
[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->SetNumberOfInputs( 0 );
14   this->SetNumberOfOutputs( 1 );
15   this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
16
17   double point[ 3 ] = { double( 0 ) };
18   this->m_Parameters->ConfigureAsPoint( "Center", 3, point );
19   this->m_Parameters->ConfigureAsReal( "Radius", 1 );
20   this->m_Parameters->ConfigureAsUint( "PhiResolution", 8 );
21   this->m_Parameters->ConfigureAsUint( "ThetaResolution", 8 );
22 }
23
24 // -------------------------------------------------------------------------
25 cpPlugins::BasicFilters::SphereMeshSource::
26 ~SphereMeshSource( )
27 {
28 }
29
30 // -------------------------------------------------------------------------
31 std::string cpPlugins::BasicFilters::SphereMeshSource::
32 _GenerateData( )
33 {
34   itk::Point< double, 3 > center =
35     this->m_Parameters->GetPoint< itk::Point< double, 3 > >( "Center", 3 );
36   // TODO: center.Fill( double( 0 ) ); // TODO
37   double radius = this->m_Parameters->GetReal( "Radius" );
38   unsigned int phi = this->m_Parameters->GetUint( "PhiResolution" );
39   unsigned int theta = this->m_Parameters->GetUint( "ThetaResolution" );
40
41   vtkSphereSource* src = this->_CreateVTK< vtkSphereSource >( );
42   src->SetCenter( center[ 0 ], center[ 1 ], center[ 2 ] );
43   src->SetRadius( radius );
44   src->SetPhiResolution( phi );
45   src->SetThetaResolution( theta );
46   src->Update( );
47
48   // Execute filter
49   cpPlugins::Interface::Mesh* out =
50     this->GetOutput< cpPlugins::Interface::Mesh >( 0 );
51   out->SetVTK( src->GetOutput( ) );
52   return( "" );
53 }
54
55 // eof - $RCSfile$