]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx
32a7c5a3b1e3ad1af7c1a1cdb69d52df5ba279ca
[cpPlugins.git] / lib / cpPlugins / Plugins / BasicFilters / Cutter.cxx
1 #include "Cutter.h"
2 #include <cpPlugins/Interface/ImplicitFunction.h>
3 #include <cpPlugins/Interface/Mesh.h>
4
5 #include <vtkCutter.h>
6 #include <vtkProperty.h>
7
8 // -------------------------------------------------------------------------
9 cpPlugins::BasicFilters::Cutter::
10 Cutter( )
11   : Superclass( )
12 {
13   this->m_ClassName = "cpPlugins::BasicFilters::Cutter";
14   this->m_ClassCategory = "MeshToMeshFilter";
15
16   this->SetNumberOfInputs( 2 );
17   this->SetNumberOfOutputs( 1 );
18   this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
19
20   this->m_Parameters = this->m_DefaultParameters;
21 }
22
23 // -------------------------------------------------------------------------
24 cpPlugins::BasicFilters::Cutter::
25 ~Cutter( )
26 {
27 }
28
29 // -------------------------------------------------------------------------
30 std::string cpPlugins::BasicFilters::Cutter::
31 _GenerateData( )
32 {
33   // Get inputs
34   cpPlugins::Interface::Mesh* mesh =
35     this->GetInput< cpPlugins::Interface::Mesh >( 0 );
36   cpPlugins::Interface::ImplicitFunction* function =
37     this->GetInput< cpPlugins::Interface::ImplicitFunction >( 1 );
38   if( function == NULL )
39     return( "Cutter: Input data 1 is not a valid implicit function." );
40
41   vtkCutter* cutter = this->_CreateVTK< vtkCutter >( );
42   cutter->SetInputData( mesh->GetVTK< vtkPolyData >( ) );
43   cutter->SetCutFunction( function->GetVTK< vtkImplicitFunction >( ) );
44   cutter->GenerateTrianglesOff( );
45   cutter->Update( );
46
47   // Execute filter
48   cpPlugins::Interface::Mesh* out =
49     this->GetOutput< cpPlugins::Interface::Mesh >( 0 );
50   out->SetVTK( cutter->GetOutput( ) );
51
52   return( "" );
53 }
54
55 // eof - $RCSfile$