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