X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FMesh.cxx;h=2866967ae73376e7a4a508aa911ab5a1274e3f0b;hb=dba64a6906e88d6023b2e6c9632da9fd41bfeb53;hp=07bd28d434f87f9ae791e0e9c1877dbcb3b740b1;hpb=2d96cce7bcab0bdcd9e93e44ed413c47388151d9;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/Mesh.cxx b/lib/cpPlugins/Interface/Mesh.cxx index 07bd28d..2866967 100644 --- a/lib/cpPlugins/Interface/Mesh.cxx +++ b/lib/cpPlugins/Interface/Mesh.cxx @@ -1,118 +1,76 @@ #include -#include - -#include -#include - -// ------------------------------------------------------------------------- -cpPlugins::Interface::Mesh:: -Mesh( ) - : Superclass( ), - m_Mapper( NULL ) -{ -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::Mesh:: -~Mesh( ) -{ - if( this->m_Mapper != NULL ) this->m_Mapper->Delete( ); -} +#include // ------------------------------------------------------------------------- -std::string cpPlugins::Interface::Mesh:: -GetClassName( ) const +void cpPlugins::Interface::Mesh:: +SetVTK( vtkObject* mesh ) { - return( "cpPlugins::Interface::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( ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::Mesh:: -SetDataObject( itk::DataObject* dobj ) +CreateVTKActor( ) { - this->Superclass::SetDataObject( dobj ); - - // WARNING: Only 2 and 3 dimensions at this moment - typedef cpPlugins::Extensions::QuadEdgeMesh< float, 2 > _TF2; - typedef cpPlugins::Extensions::QuadEdgeMesh< double, 2 > _TD2; - typedef cpPlugins::Extensions::QuadEdgeMesh< float, 3 > _TF3; - typedef cpPlugins::Extensions::QuadEdgeMesh< double, 3 > _TD3; + vtkPolyData* pd = this->GetVTK< vtkPolyData >( ); + if( + pd != NULL && + ( + this->m_Mapper.GetPointer( ) == NULL || + this->m_Actor.GetPointer( ) == 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( ); - if ( dynamic_cast< _TF2* >( dobj ) ) this->_Map< _TF2 >( ); - else if( dynamic_cast< _TD2* >( dobj ) ) this->_Map< _TD2 >( ); - else if( dynamic_cast< _TF3* >( dobj ) ) this->_Map< _TF3 >( ); - else if( dynamic_cast< _TD3* >( dobj ) ) this->_Map< _TD3 >( ); + } // fi } // ------------------------------------------------------------------------- -vtkMapper* cpPlugins::Interface::Mesh:: -GetVTKMapper( ) const +vtkActor* cpPlugins::Interface::Mesh:: +GetVTKActor( ) { - return( this->m_Mapper ); + return( this->m_Actor ); } // ------------------------------------------------------------------------- -template< class M > -void cpPlugins::Interface::Mesh:: -_Map( ) +const vtkActor* cpPlugins::Interface::Mesh:: +GetVTKActor( ) const { - typedef cpPlugins::Extensions::OpenGLMeshMapper< M > _TMapper; - - if( this->m_Mapper != NULL ) this->m_Mapper->Delete( ); - M* mesh = dynamic_cast< M* >( this->Superclass::GetDataObject( ) ); - _TMapper* mapper = _TMapper::New( ); - mapper->SetInputData( mesh ); - mapper->Update( ); - this->m_Mapper = mapper; + return( this->m_Actor ); } // ------------------------------------------------------------------------- -/* TODO -template< unsigned int D > -void cpPlugins::Interface::Mesh:: -_ConnectToVTK_0( ) +cpPlugins::Interface::Mesh:: +Mesh( ) + : Superclass( ), + m_Mapper( NULL ), + m_Actor( NULL ) { - itk::DataObject* dobj = this->Superclass::GetDataObject( ); - - cpPlugins_Interface_Mesh_Pixel( char, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_Pixel( short, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_Pixel( int, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_Pixel( long, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_Pixel( unsigned char, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_Pixel( unsigned short, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_Pixel( unsigned int, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_Pixel( unsigned long, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_Pixel( float, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_Pixel( double, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_RGB( char, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_RGB( short, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_RGB( int, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_RGB( long, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_RGB( unsigned char, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_RGB( unsigned short, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_RGB( unsigned int, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_RGB( unsigned long, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_RGB( float, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Interface_Mesh_RGB( double, D, dobj, _ConnectToVTK_1 ); } // ------------------------------------------------------------------------- -template< class P, unsigned int D > -void cpPlugins::Interface::Mesh:: -_ConnectToVTK_1( ) +cpPlugins::Interface::Mesh:: +~Mesh( ) { - typedef itk::Mesh< P, D > _TMesh; - typedef itk::MeshToVTKMeshFilter< _TMesh > _TFilter; - - _TMesh* img = - dynamic_cast< _TMesh* >( this->Superclass::GetDataObject( ) ); - typename _TFilter::Pointer filter = _TFilter::New( ); - filter->SetInput( img ); - filter->Update( ); - this->m_VTKMeshData = filter->GetOutput( ); - this->m_Mesh2VTKMeshData = filter; } -*/ // eof - $RCSfile$