+/*# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+# pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+# This software is governed by the CeCILL-B license under French law and
+# abiding by the rules of distribution of free software. You can use,
+# modify and/ or redistribute the software under the terms of the CeCILL-B
+# license as circulated by CEA, CNRS and INRIA at the following URL
+# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+# or in the file LICENSE.txt.
+#
+# As a counterpart to the access to the source code and rights to copy,
+# modify and redistribute granted by the license, users are provided only
+# with a limited warranty and the software's author, the holder of the
+# economic rights, and the successive licensors have only limited
+# liability.
+#
+# The fact that you are presently reading this means that you have had
+# knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------ */
+
#include "vtkPlane2DView.h"
#include "vtkCellArray.h"
_imageResult = NULL;
// line horizontal
- _pts = NULL;
- _lineActor = NULL;
- _lineMapper = NULL;
- _pd = NULL;
+ _pts = NULL;
+ _lineActor = NULL;
+ _lineMapper = NULL;
+ _pd = NULL;
- _interactorstyleplane2D = false;
+ _interactorstyleplane2D = NULL;
}
//-------------------------------------------------------------------
vtkPlane2DView::~vtkPlane2DView()
{
ResetPlane();
-
// Horizontal Line
if (_pts != NULL) { _pts -> Delete(); }
if (_lineActor != NULL) { _lineActor -> Delete(); }
if (_lineMapper != NULL) { _lineMapper -> Delete(); }
if (_pd != NULL) { _pd -> Delete(); }
-
_transform1 -> Delete();
_transform2 -> Delete();
}
}
//-------------------------------------------------------------------
-void vtkPlane2DView::ResetPlane(){
+void vtkPlane2DView::ResetPlane()
+{
if (_pSource !=NULL) { _pSource -> Delete(); }
if (_3Dslices !=NULL) { _3Dslices -> Delete(); }
if (_stPoints !=NULL) { _stPoints -> Delete(); }
if (_change !=NULL) { _change -> Delete(); }
}
+
//-------------------------------------------------------------------
vtkMPRBaseData *vtkPlane2DView::GetVtkmprbasedata()
{
//-------------------------------------------------------------------
void vtkPlane2DView::ExtractPlane()
{
-
double x = GetVtkmprbasedata()->GetX();
double y = GetVtkmprbasedata()->GetY();
double z = GetVtkmprbasedata()->GetZ();
}
//-------------------------------------------------------------------
-
void vtkPlane2DView::Extract_One_PlaneVTK()
{
vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
SetPSource(_sizeIma);
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
_3Dslices -> SetInput( ( vtkDataSet* )_pSource->GetOutput( ) );
_3Dslices -> SetSource( imagedata );
+#else
+ _3Dslices -> SetInputData( ( vtkDataSet* )_pSource->GetOutput( ) );
+ _3Dslices -> SetSourceData( imagedata );
+#endif
+
_3Dslices -> Update( );
_stPoints -> GetPointData( )->SetScalars( _3Dslices->GetOutput()->GetPointData()->GetScalars() );
_stPoints -> SetDimensions( _sizeIma, _sizeIma, 1 );
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
_stPoints -> SetScalarType( imagedata->GetScalarType() );
_stPoints -> SetScalarTypeToShort();
_stPoints -> Update();
// _change -> SetInput( _stPoints );
// _change -> Update(); //important
_imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _stPoints );
+#else
+printf("EED Warning! vtkPlane2DView::Extract_One_PlaneVTK VTK 5->7 ???? SetScalarTypeToShort \n");
+printf("EED Warning! vtkPlane2DView::Extract_One_PlaneVTK VTK 5->7 ???? SetScalarTypeToShort \n");
+printf("EED Warning! vtkPlane2DView::Extract_One_PlaneVTK VTK 5->7 ???? SetScalarTypeToShort \n");
+printf("EED Warning! vtkPlane2DView::Extract_One_PlaneVTK VTK 5->7 ???? SetScalarTypeToShort \n");
+printf("EED Warning! vtkPlane2DView::Extract_One_PlaneVTK VTK 5->7 ???? SetScalarTypeToShort \n");
+ vtkInformation* info=_stPoints->GetInformation();
+ vtkDataObject::SetPointDataActiveScalarInfo(info, VTK_SHORT, 1);
+ _imageViewer2XYZ->GetVtkImageViewer2()->SetInputData( _stPoints );
+
+#endif
+
+
// _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _change->GetOutput() );
// vtkImageActor *imageActor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor();
}
//-------------------------------------------------------------------
-
void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ )
{
-
int mipWidth;
double sp;
int sizeWidth = (_mip_width*2)+1 ;
int deltaPixel;
int iWidth,itmp,tmpSizeWith;
-
double spc[3];
vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
SetPSource(_sizeIma);
imagedata->GetSpacing(spc);
-
bool heightDefinition=false;
if (_mip_width<3)
{
heightDefinition=true;
}
-
if (heightDefinition==true)
{
mipWidth = _mip_width;
sizeWidth = tmpSizeWith;
deltaPixel = 4;
}
-
-
-
std::vector< vtkProbeFilter* > slicesLST;
-
_pSource->Push( -mipWidth * sp );
_pSource->Update();
-
for ( iWidth=0 ; iWidth<sizeWidth ; iWidth++ )
{
vtkProbeFilter *slice = vtkProbeFilter::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
slice -> SetInput( ( vtkDataSet* )_pSource->GetOutput( ) );
slice -> SetSource( imagedata );
+#else
+ slice -> SetInputData( ( vtkDataSet* )_pSource->GetOutput( ) );
+ slice -> SetSourceData( imagedata );
+#endif
slice -> Update( );
slicesLST.push_back( slice );
_pSource->Push( sp );
}
-
if (_imageResult ==NULL)
{
_imageResult = vtkImageData::New();
_imageResult -> SetDimensions(_sizeIma,_sizeIma,1);
_imageResult -> SetSpacing(1,1,1);
- _imageResult -> SetScalarType( imagedata->GetScalarType() );
_imageResult -> SetExtent(0,_sizeIma-1,0,_sizeIma-1,0,0);
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+ _imageResult -> SetScalarType( imagedata->GetScalarType() );
_imageResult -> SetWholeExtent(0,_sizeIma-1,0,_sizeIma-1,0,0);
_imageResult -> AllocateScalars();
_imageResult -> Update();
- }
+#else
+ _imageResult -> AllocateScalars(imagedata->GetScalarType(),1);
+#endif
+ }
unsigned short *pTemp;
unsigned short *pResult;
pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 );
-
int iPixels , sizePixels = _sizeIma*_sizeIma;
for(iPixels=0 ; iPixels<sizePixels ; iPixels=iPixels+deltaPixel)
{
-
pTemp = (unsigned short*)slicesLST[0]->GetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0);
-
pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 );
pResult[iPixels] = pTemp[iPixels];
-
for (iWidth=1;iWidth<sizeWidth;iWidth++)
{
pTemp = (unsigned short*)slicesLST[iWidth]->GetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0);
pResult[iPixels] = pTemp[iPixels];
}
}
-
if (deltaPixel!=1)
{
for (itmp=1;itmp<deltaPixel;itmp++)
pResult[iPixels+itmp] = pResult[iPixels];
}
}
-
}
-
for (iWidth=0;iWidth<sizeWidth;iWidth++)
{
slicesLST[iWidth]->Delete();
}
-
_imageResult->Modified();
- _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _imageResult );
-
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+ _imageViewer2XYZ->GetVtkImageViewer2()->SetInput( _imageResult );
+#else
+ _imageViewer2XYZ->GetVtkImageViewer2()->SetInputData( _imageResult );
+#endif
}
//-------------------------------------------------------------------
_stPoints = vtkStructuredPoints::New( );
_change = vtkImageChangeInformation::New();
- wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
+ crea::wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
ExtractPlane();
// SetActive(false);
_imageViewer2XYZ -> GetVtkImageViewer2() -> SetupInteractor ( iren );
//
// Actual version
vtkInteractorStyleBaseView2D *style2D = vtkInteractorStyleBaseView2D::New();
-
manualInteractorWindowLevel *_manualinteractorwindowlevel= new manualInteractorWindowLevel();
style2D->SetInteractorWindowLevel( _manualinteractorwindowlevel );
-
vtkInteractorScrollZ *_vtkInteractorScrollZ = new vtkInteractorScrollZ();
style2D->SetInteractorScrollZ(_vtkInteractorScrollZ);
-
SetInteractorStyleImage( style2D );
// RaC
_vtkInfoTextImageInteractorPlane2D->SetModelVtkInfoTextImage(_vtkInfoTextImage);
_vtkInfoTextImage->Configure();
((vtkInteractorStyleBaseView*)this->GetInteractorStyleBaseView())->AddInteractorStyleMaracas(_vtkInfoTextImageInteractorPlane2D);
-
-
}
//-------------------------------------------------------------------
lines->Delete(); //do not delete lines ??
_lineActor = vtkActor::New();
_lineMapper = vtkPolyDataMapper::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
_lineMapper->SetInput(_pd);
_lineMapper->ImmediateModeRenderingOn();
+#else
+ _lineMapper->SetInputData(_pd);
+#endif
_lineActor->SetMapper(_lineMapper);
_lineActor->GetProperty()->BackfaceCullingOn();
_lineActor->GetProperty()->SetDiffuseColor(0,0,1);
vtkTransform *transform = mprbasedata->GetTransformOrientation();
_transform1->SetMatrix( transform->GetMatrix() );
}
+
//-------------------------------------------------------------------
void vtkPlane2DView::RotationDrag(double vx, double vy, bool ok_v, bool ok_ang)
{
void vtkPlane2DView::Refresh( )
{
ExtractPlane();
+ UpdateColorWindowLevel();
wxVtkBaseView::Refresh();
}
//-------------------------------------------------------------------
}
_lineActor->GetProperty()->SetOpacity(opacity);
}
+
// ----------------------------------------------------------------------------
void vtkPlane2DView::TransfromCoordViewWorld2(double &X, double &Y, double &Z)
{
double spc[3];
GetVtkmprbasedata()->GetImageData()->GetSpacing(spc);
-
double xx = X;
double yy = Y;
double zz = 0;
-
TransFromCoordScreenToWorld(xx,yy,zz);
-
-
vtkTransform *transf1 = vtkTransform::New();
transf1->Identity();
vtkTransform *transf2 = GetVtkmprbasedata()->GetTransformOrientation();
in[1] = xx - center;
in[2] = yy - center;
in[3] = 0;
-
transf1->MultiplyPoint(in,out);
transf1->Delete();
-
X = out[0] + GetVtkmprbasedata()->GetX() ;
Y = out[1] + GetVtkmprbasedata()->GetY() ;
Z = out[2] + GetVtkmprbasedata()->GetZ() ;
-
}