]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Mesh.cxx
...
[cpPlugins.git] / lib / cpPlugins / Interface / Mesh.cxx
index 07bd28d434f87f9ae791e0e9c1877dbcb3b740b1..55114dd5ee26966471f3b4d52972e93d9737babd 100644 (file)
 #include <cpPlugins/Interface/Mesh.h>
 
-#include <vtkMapper.h>
-
-#include <cpPlugins/Extensions/QuadEdgeMesh.h>
-#include <cpPlugins/Extensions/OpenGLMeshMapper.h>
+#include <vtkPolyData.h>
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Mesh::
-Mesh( )
-  : Superclass( ),
-    m_Mapper( NULL )
+void cpPlugins::Interface::Mesh::
+SetVTKMesh( vtkPolyData* mesh )
 {
+  this->m_VTKObject = mesh;
+  this->Modified( );
 }
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Mesh::
-~Mesh( )
+vtkPolyData* cpPlugins::Interface::Mesh::
+GetVTKMesh( )
 {
-  if( this->m_Mapper != NULL ) this->m_Mapper->Delete( );
+  return( dynamic_cast< vtkPolyData* >( this->m_VTKObject.GetPointer( ) ) );
 }
 
 // -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Mesh::
-GetClassName( ) const
+const vtkPolyData* cpPlugins::Interface::Mesh::
+GetVTKMesh( ) const
+{
+  return(
+    dynamic_cast< const vtkPolyData* >( this->m_VTKObject.GetPointer( ) )
+    );
+}
+
+/*
+void cpPlugins::Interface::Mesh::
+SetITKDataObject( itk::DataObject* o )
 {
-  return( "cpPlugins::Interface::Mesh" );
+  // TODO: conversion!!!
+  std::cout << "Mesh: SetITKDataObject " << std::endl;
+  std::exit( 1 );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Mesh::
-SetDataObject( itk::DataObject* dobj )
+SetVTKDataObject( vtkDataObject* o )
 {
-  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;
-
-  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 >( );
+  if( dynamic_cast< vtkPolyData* >( o ) != NULL )
+  {
+    this->m_VTKObject = o;
+
+    // TODO: conversion!!!
+  }
+  else
+    this->m_VTKObject = NULL;
 }
 
 // -------------------------------------------------------------------------
-vtkMapper* cpPlugins::Interface::Mesh::
-GetVTKMapper( ) const
+vtkPolyData* cpPlugins::Interface::Mesh::
+GetVTKPolyData( )
 {
-  return( this->m_Mapper );
+  return( dynamic_cast< vtkPolyData* >( this->m_VTKObject.GetPointer( ) ) );
 }
 
 // -------------------------------------------------------------------------
-template< class M >
-void cpPlugins::Interface::Mesh::
-_Map( )
+const vtkPolyData* cpPlugins::Interface::Mesh::
+GetVTKPolyData( ) const
+{
+  return(
+    dynamic_cast< const vtkPolyData* >( this->m_VTKObject.GetPointer( ) )
+    );
+}
+*/
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::Mesh::
+Mesh( )
+  : Superclass( )
+{
+  this->m_ClassName = "cpPlugins::Interface::Mesh";
+  this->m_ClassCategory = "BasicObject";
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::Mesh::
+~Mesh( )
 {
-  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;
 }
 
 // -------------------------------------------------------------------------
 /* TODO
 template< unsigned int D >
 void cpPlugins::Interface::Mesh::
-_ConnectToVTK_0( )
+_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 )
 {
-  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( )
+_VTK_2_ITK_1( itk::DataObject* o )
 {
-  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;
 }
 */