]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Mesh.cxx
Widget integration (step 5/6): generic widget controller finished and tested on linux...
[cpPlugins.git] / lib / cpPlugins / Interface / Mesh.cxx
1 #include <cpPlugins/Interface/Mesh.h>
2
3 #include <vtkPolyData.h>
4
5 // -------------------------------------------------------------------------
6 void cpPlugins::Interface::Mesh::
7 SetVTK( vtkObject* mesh )
8 {
9   if( dynamic_cast< vtkPolyData* >( mesh ) != NULL )
10     this->m_VTKObject = mesh;
11   else
12     this->m_VTKObject = NULL;
13   this->m_Mapper = NULL;
14   this->m_Actor = NULL;
15   this->Modified( );
16 }
17
18 // -------------------------------------------------------------------------
19 void cpPlugins::Interface::Mesh::
20 CreateVTKActor( )
21 {
22   vtkPolyData* pd = this->GetVTK< vtkPolyData >( );
23   if(
24     pd != NULL &&
25     (
26       this->m_Mapper.GetPointer( ) == NULL ||
27       this->m_Actor.GetPointer( ) == NULL
28       )
29     )
30   {
31     double range[ 2 ];
32     pd->GetScalarRange( range );
33
34     this->m_Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
35     this->m_Actor = vtkSmartPointer< vtkActor >::New( );
36     this->m_Mapper->SetInputData( pd );
37     this->m_Mapper->UseLookupTableScalarRangeOff( );
38     this->m_Mapper->SetScalarRange(
39       range[ 0 ], ( ( range[ 1 ] - range[ 0 ] ) * 0.75 ) + range[ 0 ]
40       );
41     this->m_Actor->SetMapper( this->m_Mapper );
42     this->Modified( );
43
44   } // fi
45 }
46
47 // -------------------------------------------------------------------------
48 vtkActor* cpPlugins::Interface::Mesh::
49 GetVTKActor( )
50 {
51   return( this->m_Actor );
52 }
53
54 // -------------------------------------------------------------------------
55 const vtkActor* cpPlugins::Interface::Mesh::
56 GetVTKActor( ) const
57 {
58   return( this->m_Actor );
59 }
60
61 // -------------------------------------------------------------------------
62 cpPlugins::Interface::Mesh::
63 Mesh( )
64   : Superclass( ),
65     m_Mapper( NULL ),
66     m_Actor( NULL )
67 {
68 }
69
70 // -------------------------------------------------------------------------
71 cpPlugins::Interface::Mesh::
72 ~Mesh( )
73 {
74 }
75
76 // eof - $RCSfile$