]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx
...
[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 #include <vtkPlane.h>
10
11 // -------------------------------------------------------------------------
12 cpPlugins::BasicFilters::Cutter::
13 Cutter( )
14   : Superclass( )
15 {
16   this->_AddInput( "InputMesh" );
17   this->_AddInput( "InputFunction" );
18   this->_AddOutput< cpPlugins::Interface::Mesh >( "Output" );
19 }
20
21 // -------------------------------------------------------------------------
22 cpPlugins::BasicFilters::Cutter::
23 ~Cutter( )
24 {
25 }
26
27 // -------------------------------------------------------------------------
28 std::string cpPlugins::BasicFilters::Cutter::
29 _GenerateData( )
30 {
31   // Get inputs
32   auto mesh = this->GetInputData< cpPlugins::Interface::Mesh >( "InputMesh" );
33   auto function =
34     this->GetInputData< cpPlugins::Interface::ImplicitFunction >(
35       "InputFunction"
36       );
37   if( function == NULL )
38     return( "Cutter: Input data 1 is not a valid implicit function." );
39
40   vtkCutter* cutter = this->_CreateVTK< vtkCutter >( );
41   cutter->DebugOn( );
42   cutter->SetInputData( mesh->GetVTK< vtkPolyData >( ) );
43   cutter->SetCutFunction( function->GetVTK< vtkImplicitFunction >( ) );
44   cutter->SetValue( 0, 1 );
45   cutter->GenerateTrianglesOff( );
46   cutter->Update( );
47
48   // Execute filter
49   auto out = this->GetOutputData< cpPlugins::Interface::Mesh >( "Output" );
50   out->SetVTK( cutter->GetOutput( ) );
51
52   return( "" );
53 }
54
55 // eof - $RCSfile$