X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FMesh.cxx;h=e179c8ed61e4b0e34b7fcd391b6c92d2cf73309c;hb=d1d816d1eaf980d5cd266798b8f7a0bbb089a383;hp=8507a4b52a2e0f385b3b60c306a0d4428e1afc5a;hpb=4f6c47b5d9994cd1bbb601bfe8bc087a0a619e72;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/Mesh.cxx b/lib/cpPlugins/Interface/Mesh.cxx index 8507a4b..e179c8e 100644 --- a/lib/cpPlugins/Interface/Mesh.cxx +++ b/lib/cpPlugins/Interface/Mesh.cxx @@ -4,33 +4,37 @@ // ------------------------------------------------------------------------- void cpPlugins::Interface::Mesh:: -SetVTKMesh( vtkPolyData* mesh ) +SetVTK( vtkObject* mesh ) { - this->m_VTKObject = mesh; - - this->m_Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); - this->m_Actor = vtkSmartPointer< vtkActor >::New( ); - - this->m_Mapper->SetInputData( mesh ); - this->m_Actor->SetMapper( this->m_Mapper ); - + if( dynamic_cast< vtkPolyData* >( mesh ) != NULL ) + this->m_VTKObject = mesh; + else + this->m_VTKObject = NULL; + this->m_Mapper = NULL; + this->m_Actor = NULL; this->Modified( ); } // ------------------------------------------------------------------------- -vtkPolyData* cpPlugins::Interface::Mesh:: -GetVTKMesh( ) +void cpPlugins::Interface::Mesh:: +CreateVTKActor( ) { - return( dynamic_cast< vtkPolyData* >( this->m_VTKObject.GetPointer( ) ) ); -} + vtkPolyData* pd = this->GetVTK< vtkPolyData >( ); + if( + pd != NULL && + ( + this->m_Mapper.GetPointer( ) == NULL || + this->m_Actor.GetPointer( ) == NULL + ) + ) + { + this->m_Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); + this->m_Actor = vtkSmartPointer< vtkActor >::New( ); + this->m_Mapper->SetInputData( pd ); + this->m_Actor->SetMapper( this->m_Mapper ); + this->Modified( ); -// ------------------------------------------------------------------------- -const vtkPolyData* cpPlugins::Interface::Mesh:: -GetVTKMesh( ) const -{ - return( - dynamic_cast< const vtkPolyData* >( this->m_VTKObject.GetPointer( ) ) - ); + } // fi } // ------------------------------------------------------------------------- @@ -50,7 +54,9 @@ GetVTKActor( ) const // ------------------------------------------------------------------------- cpPlugins::Interface::Mesh:: Mesh( ) - : Superclass( ) + : Superclass( ), + m_Mapper( NULL ), + m_Actor( NULL ) { this->m_ClassName = "cpPlugins::Interface::Mesh"; this->m_ClassCategory = "BasicObject";