]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Visualization/MeshActor.cxx
ca6f1f9dcfa65724818919a3a95119af879272ff
[cpPlugins.git] / lib / cpExtensions / Visualization / MeshActor.cxx
1 #include <cpExtensions/Visualization/MeshActor.h>
2
3 #include <vtkActor.h>
4 #include <vtkPolyData.h>
5 #include <vtkPolyDataMapper.h>
6 #include <vtkQuadricLODActor.h>
7
8 // -------------------------------------------------------------------------
9 cpExtensions::Visualization::MeshActor::
10 MeshActor( )
11 {
12 }
13
14 // -------------------------------------------------------------------------
15 cpExtensions::Visualization::MeshActor::
16 ~MeshActor( )
17 {
18 }
19
20 // -------------------------------------------------------------------------
21 void cpExtensions::Visualization::MeshActor::
22 SetMesh( vtkPolyData* mesh )
23 {
24   static unsigned long MAX = std::numeric_limits< unsigned short >::max( );
25
26   this->m_Mesh = mesh;
27   this->m_Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
28   unsigned long c = mesh->GetNumberOfPolys( ) + mesh->GetNumberOfStrips( );
29   if( c >= MAX )
30   {
31     vtkSmartPointer< vtkQuadricLODActor > q =
32       vtkSmartPointer< vtkQuadricLODActor >::New( );
33     q->DeferLODConstructionOff( );
34     this->m_Actor = q.GetPointer( );
35   }
36   else
37     this->m_Actor = vtkSmartPointer< vtkActor >::New( );
38   this->m_Mapper->SetInputData( this->m_Mesh );
39   this->m_Actor->SetMapper( this->m_Mapper );
40 }
41
42 // -------------------------------------------------------------------------
43 vtkActor* cpExtensions::Visualization::MeshActor::
44 GetActor( )
45 {
46   return( this->m_Actor.GetPointer( ) );
47 }
48
49 // -------------------------------------------------------------------------
50 const vtkActor* cpExtensions::Visualization::MeshActor::
51 GetActor( ) const
52 {
53   return( this->m_Actor.GetPointer( ) );
54 }
55
56 // eof - $RCSfile$