]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Mesh.cxx
3D MPR updated
[cpPlugins.git] / lib / cpPlugins / Interface / Mesh.cxx
1 #include <cpPlugins/Interface/Mesh.h>
2
3 #include <vtkMapper.h>
4
5 #include <cpPlugins/Extensions/DataStructures/QuadEdgeMesh.h>
6 #include <cpPlugins/Extensions/Visualization/OpenGLMeshMapper.h>
7
8 // -------------------------------------------------------------------------
9 std::string cpPlugins::Interface::Mesh::
10 GetClassName( ) const
11 {
12   return( "cpPlugins::Interface::Mesh" );
13 }
14
15 // -------------------------------------------------------------------------
16 void cpPlugins::Interface::Mesh::
17 SetRealDataObject( itk::DataObject* dobj )
18 {
19   this->Superclass::SetRealDataObject( dobj );
20
21   // NOTE: Only 2 and 3 dimensions at this moment
22   using namespace cpPlugins::Extensions;
23   typedef DataStructures::QuadEdgeMesh< float, 2 >  _TF2;
24   typedef DataStructures::QuadEdgeMesh< double, 2 > _TD2;
25   typedef DataStructures::QuadEdgeMesh< float, 3 >  _TF3;
26   typedef DataStructures::QuadEdgeMesh< double, 3 > _TD3;
27
28   if     ( dynamic_cast< _TF2* >( dobj ) ) this->_Map< _TF2 >( );
29   else if( dynamic_cast< _TD2* >( dobj ) ) this->_Map< _TD2 >( );
30   else if( dynamic_cast< _TF3* >( dobj ) ) this->_Map< _TF3 >( );
31   else if( dynamic_cast< _TD3* >( dobj ) ) this->_Map< _TD3 >( );
32 }
33
34 // -------------------------------------------------------------------------
35 vtkMapper* cpPlugins::Interface::Mesh::
36 GetVTKMapper( ) const
37 {
38   return( this->m_Mapper );
39 }
40
41 // -------------------------------------------------------------------------
42 cpPlugins::Interface::Mesh::
43 Mesh( )
44   : Superclass( ),
45     m_Mapper( NULL )
46 {
47 }
48
49 // -------------------------------------------------------------------------
50 cpPlugins::Interface::Mesh::
51 ~Mesh( )
52 {
53   if( this->m_Mapper != NULL ) this->m_Mapper->Delete( );
54 }
55
56 // -------------------------------------------------------------------------
57 template< class M >
58 void cpPlugins::Interface::Mesh::
59 _Map( )
60 {
61   typedef
62     cpPlugins::Extensions::Visualization::OpenGLMeshMapper< M >
63     _TMapper;
64
65   if( this->m_Mapper != NULL ) this->m_Mapper->Delete( );
66   M* mesh = dynamic_cast< M* >( this->Superclass::GetRealDataObject( ) );
67   _TMapper* mapper = _TMapper::New( );
68   mapper->SetInputData( mesh );
69   this->m_Mapper = mapper;
70 }
71
72 // eof - $RCSfile$