From: Leonardo Florez-Valencia Date: Wed, 21 Oct 2015 02:50:14 +0000 (-0500) Subject: Some minor changes X-Git-Tag: v0.1~326 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=2a49cca23489a3fc7a1b23bcedff79ac80cf8e9b;p=cpPlugins.git Some minor changes --- diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.cxx b/lib/cpExtensions/Visualization/ImageSliceActors.cxx index 4bafde1..8287399 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.cxx +++ b/lib/cpExtensions/Visualization/ImageSliceActors.cxx @@ -186,7 +186,6 @@ Clear( ) this->m_Cursor = vtkSmartPointer< vtkPolyData >::New( ); this->m_CursorMapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); this->m_CursorActor = vtkSmartPointer< vtkActor >::New( ); - this->m_PlaneFunction = vtkSmartPointer< vtkPlane >::New( ); this->m_Plane = vtkSmartPointer< vtkPolyData >::New( ); this->m_PlaneMapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); this->m_TextActor = vtkSmartPointer< vtkTextActor >::New( ); @@ -447,14 +446,14 @@ GetPlaneActor( ) const vtkPlane* cpExtensions::Visualization::ImageSliceActors:: GetPlaneFunction( ) { - return( this->m_PlaneFunction ); + return( this->m_SliceMappers[ 0 ]->GetSlicePlane( ) ); } // ------------------------------------------------------------------------- const vtkPlane* cpExtensions::Visualization::ImageSliceActors:: GetPlaneFunction( ) const { - return( this->m_PlaneFunction ); + return( this->m_SliceMappers[ 0 ]->GetSlicePlane( ) ); } // ------------------------------------------------------------------------- @@ -875,122 +874,59 @@ SetSliceNumber( const int& slice ) if( nImages == 0 ) return; - // Compute plane properties - int axis = this->m_SliceMappers[ 0 ]->GetOrientation( ); - vtkAlgorithm* algo = this->m_SliceMappers[ 0 ]->GetInputAlgorithm( ); - vtkInformation* info = algo->GetOutputInformation( 0 ); - int ext[ 6 ]; - double ori[ 3 ], spac[ 3 ], pos[ 3 ]; - info->Get( vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT( ), ext ); - info->Get( vtkDataObject::ORIGIN( ), ori ); - info->Get( vtkDataObject::SPACING( ), spac ); - this->m_SliceMappers[ 0 ]->GetSlicePlane( )->GetOrigin( pos ); - - // Update display extent - int d_ext[ 6 ] = - { - ext[ 0 ], ext[ 1 ], - ext[ 2 ], ext[ 3 ], - ext[ 4 ], ext[ 5 ] - }; - d_ext[ axis << 1 ] = slice; - d_ext[ ( axis << 1 ) + 1 ] = slice; - - std::cout - << d_ext[ 0 ] << " " - << d_ext[ 1 ] << " " - << d_ext[ 2 ] << " " - << d_ext[ 3 ] << " " - << d_ext[ 4 ] << " " - << d_ext[ 5 ] << " : " - << axis << std::endl; - // Change visualization extent for( unsigned int i = 0; i < nImages; ++i ) { this->m_SliceMappers[ i ]->SetSliceNumber( slice ); - this->m_ImageActors[ i ]->SetDisplayExtent( d_ext ); this->m_SliceMappers[ i ]->Modified( ); this->m_ImageActors[ i ]->Modified( ); this->m_SliceMappers[ i ]->Update( ); } // rof - // Prevent obscuring voxels by offsetting the plane geometry - double xbnds[ ] = - { - ori[ 0 ] + ( spac[ 0 ] * double( d_ext[ 0 ] ) ), - ori[ 0 ] + ( spac[ 0 ] * double( d_ext[ 1 ] ) ) - }; - double ybnds[ ] = - { - ori[ 1 ] + ( spac[ 1 ] * double( d_ext[ 2 ] ) ), - ori[ 1 ] + ( spac[ 1 ] * double( d_ext[ 3 ] ) ) - }; - double zbnds[ ] = - { - ori[ 2 ] + ( spac[ 2 ] * double( d_ext[ 4 ] ) ), - ori[ 2 ] + ( spac[ 2 ] * double( d_ext[ 5 ] ) ) - }; - - if( spac[ 0 ] < double( 0 ) ) + double bnds[ 6 ]; + this->m_SliceMappers[ 0 ]->GetBounds( bnds ); + double x0[][ 3 ] = { - double t = xbnds[ 0 ]; - xbnds[ 0 ] = xbnds[ 1 ]; - xbnds[ 1 ] = t; - - } // fi - if( spac[ 1 ] < double( 0 ) ) - { - double t = ybnds[ 0 ]; - ybnds[ 0 ] = ybnds[ 1 ]; - ybnds[ 1 ] = t; - - } // fi - if( spac[ 2 ] < double( 0 ) ) - { - double t = zbnds[ 0 ]; - zbnds[ 0 ] = zbnds[ 1 ]; - zbnds[ 1 ] = t; - - } // fi - - // Plane function origin - this->m_PlaneFunction->SetOrigin( pos ); + { bnds[ 0 ], bnds[ 2 ], bnds[ 4 ] }, + { bnds[ 1 ], bnds[ 3 ], bnds[ 5 ] } + }; + double p0[ 2 ][ 3 ]; + + vtkPlane* plane = this->m_SliceMappers[ 0 ]->GetSlicePlane( ); + plane->GeneralizedProjectPoint( x0[ 0 ], p0[ 0 ] ); + plane->GeneralizedProjectPoint( x0[ 1 ], p0[ 1 ] ); + + int axis = this->GetAxis( ); + bnds[ 0 ] = p0[ 0 ][ 0 ]; + bnds[ 1 ] = p0[ 1 ][ 0 ]; + bnds[ 2 ] = p0[ 0 ][ 1 ]; + bnds[ 3 ] = p0[ 1 ][ 1 ]; + bnds[ 4 ] = p0[ 0 ][ 2 ]; + bnds[ 5 ] = p0[ 1 ][ 2 ]; // Configure visualization and implicit plane orientation this->m_PlaneActor->GetProperty( )->SetRepresentationToWireframe( ); - this->m_PlaneActor->GetProperty( )->SetLineWidth( 2 ); + this->m_PlaneActor->GetProperty( )->SetLineWidth( 3 ); vtkPoints* plane_points = this->m_Plane->GetPoints( ); - if( axis == 0 ) // YZ, x-normal + plane_points->SetPoint( 0, bnds[ 0 ], bnds[ 2 ], bnds[ 4 ] ); + plane_points->SetPoint( 2, bnds[ 1 ], bnds[ 3 ], bnds[ 5 ] ); + if( axis == 0 || axis == 2 ) // YZ, x-normal { - this->m_PlaneFunction->SetNormal( 1, 0, 0 ); - plane_points->SetPoint( 0, pos[ 0 ], ybnds[ 0 ], zbnds[ 0 ] ); - plane_points->SetPoint( 1, pos[ 0 ], ybnds[ 1 ], zbnds[ 0 ] ); - plane_points->SetPoint( 2, pos[ 0 ], ybnds[ 1 ], zbnds[ 1 ] ); - plane_points->SetPoint( 3, pos[ 0 ], ybnds[ 0 ], zbnds[ 1 ] ); - this->m_PlaneActor->GetProperty( )->SetColor( 1, 0, 0 ); + plane_points->SetPoint( 1, bnds[ 1 ], bnds[ 2 ], bnds[ 5 ] ); + plane_points->SetPoint( 3, bnds[ 0 ], bnds[ 3 ], bnds[ 4 ] ); + if( axis == 0 ) + this->m_PlaneActor->GetProperty( )->SetColor( 1, 0, 0 ); + else + this->m_PlaneActor->GetProperty( )->SetColor( 0, 0, 1 ); } else if( axis == 1 ) // ZX, y-normal { - this->m_PlaneFunction->SetNormal( 0, 1, 0 ); - plane_points->SetPoint( 0, xbnds[ 0 ], pos[ 1 ], zbnds[ 0 ] ); - plane_points->SetPoint( 1, xbnds[ 0 ], pos[ 1 ], zbnds[ 1 ] ); - plane_points->SetPoint( 2, xbnds[ 1 ], pos[ 1 ], zbnds[ 1 ] ); - plane_points->SetPoint( 3, xbnds[ 1 ], pos[ 1 ], zbnds[ 0 ] ); + plane_points->SetPoint( 1, bnds[ 0 ], bnds[ 2 ], bnds[ 5 ] ); + plane_points->SetPoint( 3, bnds[ 1 ], bnds[ 3 ], bnds[ 4 ] ); this->m_PlaneActor->GetProperty( )->SetColor( 0, 1, 0 ); - } - else // XY, z-normal - { - this->m_PlaneFunction->SetNormal( 0, 0, 1 ); - plane_points->SetPoint( 0, xbnds[ 0 ], ybnds[ 0 ], pos[ 2 ] ); - plane_points->SetPoint( 1, xbnds[ 1 ], ybnds[ 0 ], pos[ 2 ] ); - plane_points->SetPoint( 2, xbnds[ 1 ], ybnds[ 1 ], pos[ 2 ] ); - plane_points->SetPoint( 3, xbnds[ 0 ], ybnds[ 1 ], pos[ 2 ] ); - this->m_PlaneActor->GetProperty( )->SetColor( 0, 0, 1 ); } // fi - this->m_PlaneFunction->Modified( ); this->m_Plane->Modified( ); this->m_PlaneMapper->Modified( ); this->m_PlaneActor->Modified( ); diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.h b/lib/cpExtensions/Visualization/ImageSliceActors.h index f24bc7e..5349dac 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.h +++ b/lib/cpExtensions/Visualization/ImageSliceActors.h @@ -189,7 +189,6 @@ namespace cpExtensions vtkSmartPointer< vtkPolyData > m_Cursor; vtkSmartPointer< vtkPolyDataMapper > m_CursorMapper; vtkSmartPointer< vtkActor > m_CursorActor; - vtkSmartPointer< vtkPlane > m_PlaneFunction; vtkSmartPointer< vtkPolyData > m_Plane; vtkSmartPointer< vtkPolyDataMapper > m_PlaneMapper; char m_TextBuffer[ 1024 ]; diff --git a/lib/cpExtensions/Visualization/MPRActors.cxx b/lib/cpExtensions/Visualization/MPRActors.cxx index 6419daa..d814fe7 100644 --- a/lib/cpExtensions/Visualization/MPRActors.cxx +++ b/lib/cpExtensions/Visualization/MPRActors.cxx @@ -215,22 +215,35 @@ PushActorsInto( this->Slices[ 1 ][ 1 ]->PushActorsInto( w, false ); this->Slices[ 1 ][ 2 ]->PushActorsInto( w, false ); - /* + vtkRenderer* xren = + ( x != NULL )? x->GetRenderers( )->GetFirstRenderer( ): NULL; + vtkRenderer* yren = + ( y != NULL )? y->GetRenderers( )->GetFirstRenderer( ): NULL; + vtkRenderer* zren = + ( z != NULL )? z->GetRenderers( )->GetFirstRenderer( ): NULL; + vtkRenderer* wren = + ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL; - this->Slices[ 0 ][ 0 ]->PushActorsInto( y, false ); - this->Slices[ 0 ][ 0 ]->PushActorsInto( z, false ); + if( xren != NULL ) + { + xren->AddActor( this->Slices[ 0 ][ 1 ]->GetPlaneActor( ) ); + xren->AddActor( this->Slices[ 0 ][ 2 ]->GetPlaneActor( ) ); - this->Slices[ 0 ][ 1 ]->PushActorsInto( x, false ); - this->Slices[ 0 ][ 1 ]->PushActorsInto( z, false ); + } // fi + if( yren != NULL ) + { + yren->AddActor( this->Slices[ 0 ][ 0 ]->GetPlaneActor( ) ); + yren->AddActor( this->Slices[ 0 ][ 2 ]->GetPlaneActor( ) ); - this->Slices[ 0 ][ 2 ]->PushActorsInto( x, false ); - this->Slices[ 0 ][ 2 ]->PushActorsInto( y, false ); + } // fi + if( zren != NULL ) + { + zren->AddActor( this->Slices[ 0 ][ 0 ]->GetPlaneActor( ) ); + zren->AddActor( this->Slices[ 0 ][ 1 ]->GetPlaneActor( ) ); - vtkRenderer* wren = - ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL; + } // fi if( wren != NULL ) wren->AddActor( this->ImageOutlineActor ); - */ } // ------------------------------------------------------------------------- @@ -357,7 +370,7 @@ ResetSlices( ) for( unsigned int i = 0; i < 2; ++i ) for( unsigned int j = 0; j < 3; ++j ) this->Slices[ i ][ j ]->SetSliceNumber( - this->Slices[ i ][ j ]->GetSliceNumberMinValue( ) + this->Slices[ i ][ j ]->GetSliceNumberMaxValue( ) ); }