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