X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FDataObjects%2FMesh.cxx;h=c40bb021baa4c3a592424a9a8b0bda63b215379e;hb=65e11480407fe343b2b56098257e0bb837f75df3;hp=94c4087922b6a84e3b10f7091399cb6ec4d60c11;hpb=6a541441b605b00b77d8f8e2b024cc709fda20b9;p=cpPlugins.git diff --git a/lib/cpPlugins/DataObjects/Mesh.cxx b/lib/cpPlugins/DataObjects/Mesh.cxx index 94c4087..c40bb02 100644 --- a/lib/cpPlugins/DataObjects/Mesh.cxx +++ b/lib/cpPlugins/DataObjects/Mesh.cxx @@ -5,99 +5,103 @@ void cpPlugins::DataObjects::Mesh:: SetITK( itk::LightObject* o ) { - this->Superclass::SetITK( o ); - bool s = false; - cpPlugins_Demangle_Meshes_Dims( o, _ITK_2_VTK ); + /* TODO + this->Superclass::SetITK( o ); + bool s = false; + cpPlugins_Demangle_Meshes_Dims( o, _ITK_2_VTK ); + */ } // ------------------------------------------------------------------------- void cpPlugins::DataObjects::Mesh:: SetVTK( vtkObjectBase* o ) { - typedef itk::Mesh< double, 3 > _TMesh; - typedef _TMesh::CellType _TCell; - typedef _TCell::CellAutoPointer _TCellAutoPointer; - typedef itk::LineCell< _TCell > _TLine; - typedef itk::TriangleCell< _TCell > _TTriangle; - typedef itk::PolygonCell< _TCell > _TPolygon; - - vtkPolyData* mesh = dynamic_cast< vtkPolyData* >( o ); - if( mesh == NULL ) - { - this->m_ITK = NULL; - this->Modified( ); - return; - - } // fi - - if( this->m_VTK.GetPointer( ) != mesh ) - { - this->m_VTK = mesh; - - // Copy points - _TMesh::Pointer imesh = _TMesh::New( ); - double point[ 3 ]; - for( long i = 0; i < mesh->GetNumberOfPoints( ); ++i ) - { - mesh->GetPoint( i, point ); - _TMesh::PointType ipoint; - ipoint[ 0 ] = point[ 0 ]; - ipoint[ 1 ] = point[ 1 ]; - ipoint[ 2 ] = point[ 2 ]; - imesh->SetPoint( i, ipoint ); - - } // rof - - // Copy cells - vtkCellArray* arrays[ 4 ]; - arrays[ 0 ] = mesh->GetLines( ); - arrays[ 1 ] = mesh->GetPolys( ); - arrays[ 2 ] = NULL; // TODO: mesh->GetStrips( ); - arrays[ 3 ] = mesh->GetVerts( ); - - for( unsigned int c = 0; c < 4; c++ ) - { - if( arrays[ c ] != NULL ) - { - vtkSmartPointer< vtkIdList > ids = - vtkSmartPointer< vtkIdList >::New( ); - arrays[ c ]->InitTraversal( ); - while( arrays[ c ]->GetNextCell( ids ) == 1 ) - { - long nPoints = ids->GetNumberOfIds( ); - _TCellAutoPointer icell; - if( nPoints == 2 ) - { - icell.TakeOwnership( new _TLine ); - icell->SetPointId( 0, ids->GetId( 0 ) ); - icell->SetPointId( 1, ids->GetId( 1 ) ); - } - else if( nPoints == 3 ) - { - icell.TakeOwnership( new _TTriangle ); - icell->SetPointId( 0, ids->GetId( 0 ) ); - icell->SetPointId( 1, ids->GetId( 1 ) ); - icell->SetPointId( 2, ids->GetId( 2 ) ); - } - else if( nPoints > 3 ) - { - _TPolygon* polygon = new _TPolygon( ); - for( long j = 0; j < nPoints; ++j ) - polygon->AddPointId( ids->GetId( j ) ); - icell.TakeOwnership( polygon ); - - } // fi - imesh->SetCell( imesh->GetNumberOfCells( ), icell ); - - } // elihw - - } // fi - - } // rof - this->m_ITK = imesh; - this->Modified( ); - - } // fi + /* TODO + typedef itk::Mesh< double, 3 > _TMesh; + typedef _TMesh::CellType _TCell; + typedef _TCell::CellAutoPointer _TCellAutoPointer; + typedef itk::LineCell< _TCell > _TLine; + typedef itk::TriangleCell< _TCell > _TTriangle; + typedef itk::PolygonCell< _TCell > _TPolygon; + + vtkPolyData* mesh = dynamic_cast< vtkPolyData* >( o ); + if( mesh == NULL ) + { + this->m_ITK = NULL; + this->Modified( ); + return; + + } // fi + + if( this->m_VTK.GetPointer( ) != mesh ) + { + this->m_VTK = mesh; + + // Copy points + _TMesh::Pointer imesh = _TMesh::New( ); + double point[ 3 ]; + for( long i = 0; i < mesh->GetNumberOfPoints( ); ++i ) + { + mesh->GetPoint( i, point ); + _TMesh::PointType ipoint; + ipoint[ 0 ] = point[ 0 ]; + ipoint[ 1 ] = point[ 1 ]; + ipoint[ 2 ] = point[ 2 ]; + imesh->SetPoint( i, ipoint ); + + } // rof + + // Copy cells + vtkCellArray* arrays[ 4 ]; + arrays[ 0 ] = mesh->GetLines( ); + arrays[ 1 ] = mesh->GetPolys( ); + arrays[ 2 ] = NULL; // TODO: mesh->GetStrips( ); + arrays[ 3 ] = mesh->GetVerts( ); + + for( unsigned int c = 0; c < 4; c++ ) + { + if( arrays[ c ] != NULL ) + { + vtkSmartPointer< vtkIdList > ids = + vtkSmartPointer< vtkIdList >::New( ); + arrays[ c ]->InitTraversal( ); + while( arrays[ c ]->GetNextCell( ids ) == 1 ) + { + long nPoints = ids->GetNumberOfIds( ); + _TCellAutoPointer icell; + if( nPoints == 2 ) + { + icell.TakeOwnership( new _TLine ); + icell->SetPointId( 0, ids->GetId( 0 ) ); + icell->SetPointId( 1, ids->GetId( 1 ) ); + } + else if( nPoints == 3 ) + { + icell.TakeOwnership( new _TTriangle ); + icell->SetPointId( 0, ids->GetId( 0 ) ); + icell->SetPointId( 1, ids->GetId( 1 ) ); + icell->SetPointId( 2, ids->GetId( 2 ) ); + } + else if( nPoints > 3 ) + { + _TPolygon* polygon = new _TPolygon( ); + for( long j = 0; j < nPoints; ++j ) + polygon->AddPointId( ids->GetId( j ) ); + icell.TakeOwnership( polygon ); + + } // fi + imesh->SetCell( imesh->GetNumberOfCells( ), icell ); + + } // elihw + + } // fi + + } // rof + this->m_ITK = imesh; + this->Modified( ); + + } // fi + */ } // -------------------------------------------------------------------------