]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx
8ba50cc7459a0a0aaccf21a01a3c817f8f73fa80
[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   using namespace cpPlugins::Interface;
18   this->m_DefaultParameters.Configure( Parameters::Point, "Center" );
19   this->m_DefaultParameters.Configure( Parameters::Real, "Radius" );
20   this->m_DefaultParameters.Configure( Parameters::Uint, "PhiResolution" );
21   this->m_DefaultParameters.Configure( Parameters::Uint, "ThetaResolution" );
22   this->m_DefaultParameters.SetValueAsPoint( "Center", 3, 0, 0, 0 );
23   this->m_DefaultParameters.SetValueAsReal( "Radius", 1 );
24   this->m_DefaultParameters.SetValueAsUint( "PhiResolution", 10 );
25   this->m_DefaultParameters.SetValueAsUint( "ThetaResolution", 10 );
26   this->m_Parameters = this->m_DefaultParameters;
27 }
28
29 // -------------------------------------------------------------------------
30 cpPlugins::BasicFilters::SphereMeshSource::
31 ~SphereMeshSource( )
32 {
33 }
34
35 // -------------------------------------------------------------------------
36 std::string cpPlugins::BasicFilters::SphereMeshSource::
37 _GenerateData( )
38 {
39   itk::Point< double, 3 > center =
40     this->m_Parameters.GetValueAsPoint< itk::Point< double, 3 > >( "Center" );
41   center.Fill( double( 0 ) ); // TODO
42   double radius = this->m_Parameters.GetValueAsReal( "Radius" );
43   unsigned int phi = this->m_Parameters.GetValueAsUint( "PhiResolution" );
44   unsigned int theta = this->m_Parameters.GetValueAsUint( "ThetaResolution" );
45
46   vtkSphereSource* src = this->_CreateVTK< vtkSphereSource >( );
47   src->SetCenter( center[ 0 ], center[ 1 ], center[ 2 ] );
48   src->SetRadius( radius );
49   src->SetPhiResolution( phi );
50   src->SetThetaResolution( theta );
51   src->Update( );
52
53   // Execute filter
54   cpPlugins::Interface::Mesh* out =
55     this->GetOutput< cpPlugins::Interface::Mesh >( 0 );
56   out->SetVTK( src->GetOutput( ) );
57   return( "" );
58 }
59
60 // eof - $RCSfile$