X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FMesh.cxx;h=2866967ae73376e7a4a508aa911ab5a1274e3f0b;hb=dba64a6906e88d6023b2e6c9632da9fd41bfeb53;hp=55114dd5ee26966471f3b4d52972e93d9737babd;hpb=7c7bc497af96e7b5845be9a2fc277036ec752be9;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/Mesh.cxx b/lib/cpPlugins/Interface/Mesh.cxx index 55114dd..2866967 100644 --- a/lib/cpPlugins/Interface/Mesh.cxx +++ b/lib/cpPlugins/Interface/Mesh.cxx @@ -4,75 +4,67 @@ // ------------------------------------------------------------------------- void cpPlugins::Interface::Mesh:: -SetVTKMesh( vtkPolyData* mesh ) +SetVTK( vtkObject* mesh ) { - this->m_VTKObject = mesh; + 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( ) -{ - return( dynamic_cast< vtkPolyData* >( this->m_VTKObject.GetPointer( ) ) ); -} - -// ------------------------------------------------------------------------- -const vtkPolyData* cpPlugins::Interface::Mesh:: -GetVTKMesh( ) const -{ - return( - dynamic_cast< const vtkPolyData* >( this->m_VTKObject.GetPointer( ) ) - ); -} - -/* void cpPlugins::Interface::Mesh:: -SetITKDataObject( itk::DataObject* o ) +CreateVTKActor( ) { - // TODO: conversion!!! - std::cout << "Mesh: SetITKDataObject " << std::endl; - std::exit( 1 ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Mesh:: -SetVTKDataObject( vtkDataObject* o ) -{ - if( dynamic_cast< vtkPolyData* >( o ) != NULL ) + vtkPolyData* pd = this->GetVTK< vtkPolyData >( ); + if( + pd != NULL && + ( + this->m_Mapper.GetPointer( ) == NULL || + this->m_Actor.GetPointer( ) == NULL + ) + ) { - this->m_VTKObject = o; - - // TODO: conversion!!! - } - else - this->m_VTKObject = NULL; + double range[ 2 ]; + pd->GetScalarRange( range ); + + this->m_Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); + this->m_Actor = vtkSmartPointer< vtkActor >::New( ); + this->m_Mapper->SetInputData( pd ); + this->m_Mapper->UseLookupTableScalarRangeOff( ); + this->m_Mapper->SetScalarRange( + range[ 0 ], ( ( range[ 1 ] - range[ 0 ] ) * 0.75 ) + range[ 0 ] + ); + this->m_Actor->SetMapper( this->m_Mapper ); + this->Modified( ); + + } // fi } // ------------------------------------------------------------------------- -vtkPolyData* cpPlugins::Interface::Mesh:: -GetVTKPolyData( ) +vtkActor* cpPlugins::Interface::Mesh:: +GetVTKActor( ) { - return( dynamic_cast< vtkPolyData* >( this->m_VTKObject.GetPointer( ) ) ); + return( this->m_Actor ); } // ------------------------------------------------------------------------- -const vtkPolyData* cpPlugins::Interface::Mesh:: -GetVTKPolyData( ) const +const vtkActor* cpPlugins::Interface::Mesh:: +GetVTKActor( ) const { - return( - dynamic_cast< const vtkPolyData* >( this->m_VTKObject.GetPointer( ) ) - ); + return( this->m_Actor ); } -*/ // ------------------------------------------------------------------------- cpPlugins::Interface::Mesh:: Mesh( ) - : Superclass( ) + : Superclass( ), + m_Mapper( NULL ), + m_Actor( NULL ) { - this->m_ClassName = "cpPlugins::Interface::Mesh"; - this->m_ClassCategory = "BasicObject"; } // ------------------------------------------------------------------------- @@ -81,34 +73,4 @@ cpPlugins::Interface::Mesh:: { } -// ------------------------------------------------------------------------- -/* TODO -template< unsigned int D > -void cpPlugins::Interface::Mesh:: -_ITK_2_VTK_0( itk::DataObject* o ) -{ -} - -// ------------------------------------------------------------------------- -template< class P, unsigned int D > -void cpPlugins::Interface::Mesh:: -_ITK_2_VTK_1( itk::DataObject* o ) -{ -} - -// ------------------------------------------------------------------------- -template< unsigned int D > -void cpPlugins::Interface::Mesh:: -_VTK_2_ITK_0( itk::DataObject* o ) -{ -} - -// ------------------------------------------------------------------------- -template< class P, unsigned int D > -void cpPlugins::Interface::Mesh:: -_VTK_2_ITK_1( itk::DataObject* o ) -{ -} -*/ - // eof - $RCSfile$