diff --git a/Modules/CMakeLists.txt b/Modules/CMakeLists.txt index bac394edeb..325c893441 100644 --- a/Modules/CMakeLists.txt +++ b/Modules/CMakeLists.txt @@ -1,79 +1,78 @@ # Modules must be listed according to their dependencies set(module_dirs DataTypesExt AlgorithmsExt MapperExt IOExt DICOMReader DICOMTesting Qt4Qt5TestModule SceneSerializationBase PlanarFigure ImageDenoising ImageExtraction ImageStatistics LegacyAdaptors IpPicSupport - Ext SceneSerialization GraphAlgorithms ContourModel SurfaceInterpolation Segmentation PlanarFigureSegmentation OpenViewCore QmlItems QtWidgets QtWidgetsExt SegmentationUI DiffusionImaging GPGPU IGTBase IGT CameraCalibration RigidRegistration RigidRegistrationUI DeformableRegistration DeformableRegistrationUI OpenCL OpenCVVideoSupport Overlays InputDevices ToFHardware ToFProcessing ToFUI US USUI DicomUI Simulation Remeshing Python Persistence IGTUI VtkShaders ) if(MITK_ENABLE_PIC_READER) list(APPEND module_dirs IpPicSupportIO) endif() set(MITK_DEFAULT_SUBPROJECTS MITK-Modules) foreach(module_dir ${module_dirs}) add_subdirectory(${module_dir}) endforeach() if(MITK_PRIVATE_MODULES) file(GLOB all_subdirs RELATIVE ${MITK_PRIVATE_MODULES} ${MITK_PRIVATE_MODULES}/*) foreach(subdir ${all_subdirs}) string(FIND ${subdir} "." _result) if(_result EQUAL -1) if(EXISTS ${MITK_PRIVATE_MODULES}/${subdir}/CMakeLists.txt) message(STATUS "Found private module ${subdir}") add_subdirectory(${MITK_PRIVATE_MODULES}/${subdir} private_modules/${subdir}) endif() endif() endforeach() endif(MITK_PRIVATE_MODULES) diff --git a/Modules/Ext/Algorithms/mitkAltInstantiateAccessFunctions.h b/Modules/Ext/Algorithms/mitkAltInstantiateAccessFunctions.h deleted file mode 100644 index c7cedfbc16..0000000000 --- a/Modules/Ext/Algorithms/mitkAltInstantiateAccessFunctions.h +++ /dev/null @@ -1,172 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKALTINSTANTIATEACCESSFUNCTIONS_H_HEADER_INCLUDED -#define MITKALTINSTANTIATEACCESSFUNCTIONS_H_HEADER_INCLUDED - -#include -#include - -#ifndef DOXYGEN_SKIP -//--------------------------------- instantiation functions ------------------------------ -//##Documentation -//## @brief Instantiate access function without additional parammeters -//## for all datatypes and dimensions -//## -//## Use this macro once after the definition of your access function. -//## Some compilers have memory problems without the explicit instantiation. -//## You may need to move the access function to a separate file. -//## \sa AltInstantiateAccessFunction_1 -//## \sa AltInstantiateAccessFunction_2 -//## @ingroup Adaptor -#define AltInstantiateAccessFunction(itkImgFunc) \ - AltInstantiateAccessFunctionForFixedDimension(itkImgFunc, 2) \ - AltInstantiateAccessFunctionForFixedDimension(itkImgFunc, 3) - -//##Documentation -//## @brief Instantiate access function with one additional parammeter -//## for all datatypes and dimensions -//## -//## Use this macro once after the definition of your access function. -//## Some compilers have memory problems without the explicit instantiation. -//## You may need to move the access function to a separate file. -//## \sa AltInstantiateAccessFunction -//## \sa AltInstantiateAccessFunction_2 -//## @ingroup Adaptor -#define AltInstantiateAccessFunction_1(itkImgFunc, param1Type) \ - AltInstantiateAccessFunctionForFixedDimension_1(itkImgFunc, 2, param1Type) \ - AltInstantiateAccessFunctionForFixedDimension_1(itkImgFunc, 3, param1Type) - -//##Documentation -//## @brief Instantiate access function with two additional parammeters -//## for all datatypes and dimensions -//## -//## Use this macro once after the definition of your access function. -//## Some compilers have memory problems without the explicit instantiation. -//## You may need to move the access function to a separate file. -//## \sa AltInstantiateAccessFunction -//## \sa AltInstantiateAccessFunction_1 -//## @ingroup Adaptor -#define AltInstantiateAccessFunction_2(itkImgFunc, param1Type, param2Type) \ - AltInstantiateAccessFunctionForFixedDimension_2(itkImgFunc, 2, param1Type, param2Type) \ - AltInstantiateAccessFunctionForFixedDimension_2(itkImgFunc, 3, param1Type, param2Type) - -//##Documentation -//## @brief Instantiate access function without additional parammeters -//## for all datatypes, but fixed dimension -//## -//## Use this macro once after the definition of your access function. -//## Some compilers have memory problems without the explicit instantiation. -//## You may need to move the access function to a separate file. -//## \sa AltInstantiateAccessFunctionForFixedDimension_1 -//## \sa AltInstantiateAccessFunctionForFixedDimension_2 -//## @ingroup Adaptor -#define AltInstantiateAccessFunctionForFixedDimension(itkImgFunc, dimension) \ -template void itkImgFunc(itk::Image*); \ -template void itkImgFunc(itk::Image*); \ -template void itkImgFunc(itk::Image*); \ -template void itkImgFunc(itk::Image*); \ -template void itkImgFunc(itk::Image*); \ -template void itkImgFunc(itk::Image*); \ -template void itkImgFunc(itk::Image*); \ -template void itkImgFunc(itk::Image*); - -//##Documentation -//## @brief Instantiate access function with one additional parammeter -//## for all datatypes, but fixed dimension -//## -//## Use this macro once after the definition of your access function. -//## Some compilers have memory problems without the explicit instantiation. -//## You may need to move the access function to a separate file. -//## \sa AltInstantiateAccessFunctionForFixedDimension -//## \sa AltInstantiateAccessFunctionForFixedDimension_2 -//## @ingroup Adaptor -#define AltInstantiateAccessFunctionForFixedDimension_1(itkImgFunc, dimension, param1Type)\ -template void itkImgFunc(itk::Image*, param1Type); \ -template void itkImgFunc(itk::Image*, param1Type); \ -template void itkImgFunc(itk::Image*, param1Type); \ -template void itkImgFunc(itk::Image*, param1Type); \ -template void itkImgFunc(itk::Image*, param1Type); \ -template void itkImgFunc(itk::Image*, param1Type); \ -template void itkImgFunc(itk::Image*, param1Type); \ -template void itkImgFunc(itk::Image*, param1Type); - -//##Documentation -//## @brief Instantiate access function with two additional parammeters -//## for all datatypes, but fixed dimension -//## -//## Use this macro once after the definition of your access function. -//## Some compilers have memory problems without the explicit instantiation. -//## You may need to move the access function to a separate file. -//## \sa AltInstantiateAccessFunctionForFixedDimension -//## \sa AltInstantiateAccessFunctionForFixedDimension_1 -//## @ingroup Adaptor -#define AltInstantiateAccessFunctionForFixedDimension_2(itkImgFunc, dimension, param1Type, param2Type)\ -template void itkImgFunc(itk::Image*, param1Type, param2Type); \ -template void itkImgFunc(itk::Image*, param1Type, param2Type); \ -template void itkImgFunc(itk::Image*, param1Type, param2Type); \ -template void itkImgFunc(itk::Image*, param1Type, param2Type); \ -template void itkImgFunc(itk::Image*, param1Type, param2Type); \ -template void itkImgFunc(itk::Image*, param1Type, param2Type); \ -template void itkImgFunc(itk::Image*, param1Type, param2Type); \ -template void itkImgFunc(itk::Image*, param1Type, param2Type); - -//##Documentation -//## @brief Instantiate access function without additional parammeters -//## for a fixed datatype, but all dimensions -//## -//## Use this macro once after the definition of your access function. -//## Some compilers have memory problems without the explicit instantiation. -//## You may need to move the access function to a separate file. -//## \sa AltInstantiateAccessFunctionForFixedPixelType_1 -//## \sa AltInstantiateAccessFunctionForFixedPixelType_2 -//## @ingroup Adaptor -#define AltInstantiateAccessFunctionForFixedPixelType(itkImgFunc, pixelType) \ -template void itkImgFunc(itk::Image*); \ -template void itkImgFunc(itk::Image*); - -//##Documentation -//## @brief Instantiate access function with one additional parammeter -//## for a fixed datatype, but all dimensions -//## -//## Use this macro once after the definition of your access function. -//## Some compilers have memory problems without the explicit instantiation. -//## You may need to move the access function to a separate file. -//## \sa AltInstantiateAccessFunctionForFixedPixelType -//## \sa AltInstantiateAccessFunctionForFixedPixelType_2 -//## @ingroup Adaptor -#define AltInstantiateAccessFunctionForFixedPixelType_1(itkImgFunc, pixelType, param1Type) \ -template void itkImgFunc(itk::Image*, param1Type); \ -template void itkImgFunc(itk::Image*, param1Type); - -//##Documentation -//## @brief Instantiate access function with two additional parammeters -//## for a fixed datatype, but all dimensions -//## -//## Use this macro once after the definition of your access function. -//## Some compilers have memory problems without the explicit instantiation. -//## You may need to move the access function to a separate file. -//## \sa AltInstantiateAccessFunctionForFixedPixelType -//## \sa AltInstantiateAccessFunctionForFixedPixelType_1 -//## @ingroup Adaptor -#define AltInstantiateAccessFunctionForFixedPixelType_2(itkImgFunc, pixelType, param1Type, param2Type)\ -template void itkImgFunc(itk::Image*, param1Type, param2Type); \ -template void itkImgFunc(itk::Image*, param1Type, param2Type); - -#endif DOXYGEN_SKIP - -#endif // of MITKALTINSTANTIATEACCESSFUNCTIONS_H_HEADER_INCLUDED diff --git a/Modules/Ext/Algorithms/mitkAngleCorrectByPointFilter.cpp b/Modules/Ext/Algorithms/mitkAngleCorrectByPointFilter.cpp deleted file mode 100644 index 01bb587e8d..0000000000 --- a/Modules/Ext/Algorithms/mitkAngleCorrectByPointFilter.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkAngleCorrectByPointFilter.h" -#include "mitkIpPic.h" -#include "mitkImageTimeSelector.h" -#include "mitkProperties.h" -#include "mitkImageReadAccessor.h" -#include - -mitk::AngleCorrectByPointFilter::AngleCorrectByPointFilter() : m_PreferTransducerPositionFromProperty(true) -{ - m_Center.Fill(0); - m_TransducerPosition.Fill(0); -} - -mitk::AngleCorrectByPointFilter::~AngleCorrectByPointFilter() -{ -} - -void mitk::AngleCorrectByPointFilter::GenerateOutputInformation() -{ - mitk::Image::ConstPointer input = this->GetInput(); - mitk::Image::Pointer output = this->GetOutput(); - - if ((output->IsInitialized()) && (this->GetMTime() <= m_TimeOfHeaderInitialization.GetMTime())) - return; - - itkDebugMacro(<<"GenerateOutputInformation()"); - - unsigned int i; - unsigned int *tmpDimensions = new unsigned int[input->GetDimension()]; - - for(i=0;iGetDimension();++i) - tmpDimensions[i]=input->GetDimension(i); - - //@todo maybe we should shift the following somehow in ImageToImageFilter - mitk::PixelType scalarPType = MakeScalarPixelType(); - output->Initialize(scalarPType, - input->GetDimension(), - tmpDimensions, - input->GetNumberOfChannels()); - - output->GetSlicedGeometry()->SetSpacing(input->GetSlicedGeometry()->GetSpacing()); - - //output->GetSlicedGeometry()->SetPlaneGeometry(mitk::Image::BuildStandardPlanePlaneGeometry(output->GetSlicedGeometry(), tmpDimensions).GetPointer(), 0); - //output->GetSlicedGeometry()->SetEvenlySpaced(); - //set the timebounds - after SetPlaneGeometry, so that the already created PlaneGeometry will also receive this timebounds. - //@fixme!!! will not work for not evenly timed data! - - ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New(); - timeGeometry->Initialize(output->GetSlicedGeometry(), output->GetTimeGeometry()->CountTimeSteps()); - timeGeometry->SetFirstTimePoint(output->GetTimeGeometry()->GetMinimumTimePoint()); - TimePointType stepDuration = input->GetTimeGeometry()->GetMaximumTimePoint(0) -input->GetTimeGeometry()->GetMinimumTimePoint(0); - timeGeometry->SetStepDuration(stepDuration); - output->SetTimeGeometry(timeGeometry); - - output->SetPropertyList(input->GetPropertyList()->Clone()); - - - delete [] tmpDimensions; - - m_TimeOfHeaderInitialization.Modified(); -} - -void mitk::AngleCorrectByPointFilter::GenerateData() -{ - mitk::Image::ConstPointer input = this->GetInput(); - mitk::Image::Pointer output = this->GetOutput(); - - - if(m_PreferTransducerPositionFromProperty) - { - mitk::Point3iProperty::Pointer pointProp; - pointProp = dynamic_cast(input->GetProperty("ORIGIN").GetPointer()); - if (pointProp.IsNotNull() ) - { - const itk::Point & p = pointProp->GetValue(); - m_TransducerPosition[0] = p[0]; - m_TransducerPosition[1] = p[1]; - m_TransducerPosition[2] = p[2]; - } - } - - itkDebugMacro( << "compute angle corrected image .... " ); - itkDebugMacro( << " Center[0]=" << m_Center[0] << " Center[1]=" << m_Center[1] << " Center[2]=" << m_Center[2] ); - itkDebugMacro( << " TransducerPosition[0]=" << m_TransducerPosition[0] << " TransducerPosition[1]=" << m_TransducerPosition[1] << " TransducerPosition[2]=" << m_TransducerPosition[2] ); - - const Vector3D & spacing = input->GetSlicedGeometry()->GetSpacing(); - // MITK_INFO << " in: xres=" << spacing[0] << " yres=" << spacing[1] << " zres=" << spacing[2] << std::endl; - - if((spacing[0]!=spacing[1]) || (spacing[0]!=spacing[2])) - { - itkExceptionMacro("filter does not work for uninsotropic data: spacing: ("<< spacing[0] << "," << spacing[1] << "," << spacing[2] << ")"); - } - - Vector3D p; - Vector3D tx_direction; - Vector3D tx_position = m_TransducerPosition.GetVectorFromOrigin(); - Vector3D center = m_Center.GetVectorFromOrigin(); - Vector3D assumed_direction; - ScalarType &x=p[0]; - ScalarType &y=p[1]; - ScalarType &z=p[2]; - Vector3D down; - FillVector3D(down,0.0,0.0,-1.0); - - int xDim = input->GetDimension(0); - int yDim = input->GetDimension(1); - int zDim = input->GetDimension(2); - - mitkIpPicDescriptor* pic_out; - pic_out = mitkIpPicNew(); - pic_out->dim = 3; - pic_out->bpe = output->GetPixelType().GetBpe(); - //pic_out->type = output->GetPixelType().GetType(); - pic_out->n[0] = xDim; - pic_out->n[1] = yDim; - pic_out->n[2] = zDim; - pic_out->data = malloc(_mitkIpPicSize(pic_out)); - - //go! - mitk::ImageTimeSelector::Pointer timeSelector=mitk::ImageTimeSelector::New(); - timeSelector->SetInput(input); - - int nstart, nmax; - int tstart, tmax; - - tstart=output->GetRequestedRegion().GetIndex(3); - nstart=output->GetRequestedRegion().GetIndex(4); - - tmax=tstart+output->GetRequestedRegion().GetSize(3); - nmax=nstart+output->GetRequestedRegion().GetSize(4); - - int n,t; - for(n=nstart;nGetNumberOfChannels();++n) - { - timeSelector->SetChannelNr(n); - - for(t=tstart;tSetTimeNr(t); - - timeSelector->Update(); - - typedef unsigned char InputImagePixelType; - typedef ScalarType OutputImagePixelType; - - if(input->GetPixelType().GetPixelType() != itk::ImageIOBase::SCALAR || - input->GetPixelType().GetComponentType()!= MapPixelComponentType::value) - { - itkExceptionMacro("only implemented for " << typeid(PixelType).name() ); - } - - InputImagePixelType *in; - OutputImagePixelType *out; - - mitk::ImageReadAccessor tsOutAcc(timeSelector->GetOutput()); - in = (InputImagePixelType *)tsOutAcc.GetData(); - out = (OutputImagePixelType*)pic_out->data; - - for (z=0 ; zvnl_math::pi_over_4) - { - assumed_direction = center-p; - assumed_direction.Normalize(); - ScalarType cos_factor = tx_direction*assumed_direction; - - if(fabs(cos_factor)>eps) - *out=((ScalarType)(*in)-128.0)/cos_factor; - else - *out=((ScalarType)(*in)-128.0)/eps; - } - //else - // *out=0; - } - } - } - //output->SetPicVolume(pic_out, t, n); - } - } -} - -void mitk::AngleCorrectByPointFilter::GenerateInputRequestedRegion() -{ - Superclass::GenerateInputRequestedRegion(); - - mitk::ImageToImageFilter::InputImagePointer input = - const_cast< mitk::ImageToImageFilter::InputImageType * > ( this->GetInput() ); - mitk::Image::Pointer output = this->GetOutput(); - - Image::RegionType requestedRegion; - requestedRegion = output->GetRequestedRegion(); - requestedRegion.SetIndex(0, 0); - requestedRegion.SetIndex(1, 0); - requestedRegion.SetIndex(2, 0); - //requestedRegion.SetIndex(3, 0); - //requestedRegion.SetIndex(4, 0); - requestedRegion.SetSize(0, input->GetDimension(0)); - requestedRegion.SetSize(1, input->GetDimension(1)); - requestedRegion.SetSize(2, input->GetDimension(2)); - //requestedRegion.SetSize(3, output->GetDimension(3)); - //requestedRegion.SetSize(4, output->GetNumberOfChannels()); - - input->SetRequestedRegion( & requestedRegion ); -} diff --git a/Modules/Ext/Algorithms/mitkAngleCorrectByPointFilter.h b/Modules/Ext/Algorithms/mitkAngleCorrectByPointFilter.h deleted file mode 100644 index af548cf69d..0000000000 --- a/Modules/Ext/Algorithms/mitkAngleCorrectByPointFilter.h +++ /dev/null @@ -1,75 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKANGLECORRECTBYPOINTFILTER_H_HEADER_INCLUDED_C1F48A22 -#define MITKANGLECORRECTBYPOINTFILTER_H_HEADER_INCLUDED_C1F48A22 - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkImageToImageFilter.h" -#include "mitkVector.h" - -namespace mitk { - -//##Documentation -//## @brief -//## @ingroup Process -class MitkExt_EXPORT AngleCorrectByPointFilter : public ImageToImageFilter -{ -public: - mitkClassMacro(AngleCorrectByPointFilter, ImageToImageFilter); - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - itkSetMacro(Center, Point3D); - itkGetConstReferenceMacro(Center, Point3D); - - itkSetMacro(TransducerPosition, Point3D); - itkGetConstReferenceMacro(TransducerPosition, Point3D); - - itkSetMacro(PreferTransducerPositionFromProperty, bool); - itkGetMacro(PreferTransducerPositionFromProperty, bool); - -protected: - - //##Description - //## @brief Time when Header was last initialized - itk::TimeStamp m_TimeOfHeaderInitialization; - -protected: - AngleCorrectByPointFilter(); - - ~AngleCorrectByPointFilter(); - - virtual void GenerateData(); - - virtual void GenerateOutputInformation(); - - virtual void GenerateInputRequestedRegion(); - - Point3D m_TransducerPosition; - Point3D m_Center; - - bool m_PreferTransducerPositionFromProperty; -}; - -} // namespace mitk - -#endif /* MITKANGLECORRECTBYPOINTFILTER_H_HEADER_INCLUDED_C1F48A22 */ - - diff --git a/Modules/Ext/Algorithms/mitkCylindricToCartesianFilter.cpp b/Modules/Ext/Algorithms/mitkCylindricToCartesianFilter.cpp deleted file mode 100644 index 45ac8276fd..0000000000 --- a/Modules/Ext/Algorithms/mitkCylindricToCartesianFilter.cpp +++ /dev/null @@ -1,504 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkCylindricToCartesianFilter.h" -#include "mitkImageTimeSelector.h" -#include "mitkSlicedGeometry3D.h" -#include "mitkPlaneGeometry.h" -#include "mitkProperties.h" - -#include "mitkLegacyAdaptors.h" -#include -#include - -template -void _transform(mitkIpPicDescriptor *pic, mitkIpPicDescriptor *dest, float _outsideValue, float *fr, float *fphi, float *fz, short *rt, unsigned int *phit, unsigned int *zt, mitkIpPicDescriptor *coneCutOff_pic) //...t=truncated -{ - T outsideValue = static_cast(_outsideValue); - register float f, ft, f0, f1, f2, f3; - - mitkIpInt2_t ox_size; - mitkIpInt2_t nx_size, ny_size, nz_size; - int oxy_size, nxy_size; - - T* orig, *dp, *dest_start; - - mitkIpInt2_t* coneCutOff=(mitkIpInt2_t*)coneCutOff_pic->data; - - orig=(T*)pic->data; - ox_size=pic->n[0]; - oxy_size=ox_size*pic->n[1]; - - nx_size=dest->n[0]; - ny_size=dest->n[1]; - nxy_size=nx_size*ny_size; - nz_size=dest->n[2]; - - /*nx_size=360; - ny_size=360; - nxy_size=nx_size*ny_size; - nz_size=256;*/ - - dest_start=dp=((T*)dest->data)+nxy_size*(nz_size-1); - - mitkIpInt2_t y; - // int size=_mitkIpPicElements(pic); - - register mitkIpInt2_t x,z; - for(y=0;y=0) - { - x_start=0; x_end=nx_size; - } - else - { - x_start=-r0plusphi0; x_end=nx_size+r0plusphi0; - - for(z=0;ztype=mitkIpPicInt; - rt_pic->bpe=16; - rt_pic->dim=2; - rt_pic->n[0]=rt_pic->n[1]=new_xsize; - rt_pic->data=malloc(_mitkIpPicSize(rt_pic)); - - phit_pic=mitkIpPicNew(); - phit_pic->type=mitkIpPicUInt; - phit_pic->bpe=32; - phit_pic->dim=2; - phit_pic->n[0]=phit_pic->n[1]=new_xsize; - phit_pic->data=malloc(_mitkIpPicSize(phit_pic)); - - fr_pic=mitkIpPicNew(); - fr_pic->type=mitkIpPicFloat; - fr_pic->bpe=32; - fr_pic->dim=2; - fr_pic->n[0]=fr_pic->n[1]=new_xsize; - fr_pic->data=malloc(_mitkIpPicSize(fr_pic)); - - fphi_pic=mitkIpPicNew(); - fphi_pic->type=mitkIpPicFloat; - fphi_pic->bpe=32; - fphi_pic->dim=2; - fphi_pic->n[0]=fphi_pic->n[1]=new_xsize; - fphi_pic->data=malloc(_mitkIpPicSize(fphi_pic)); - - mitkIpInt2_t *rtp=(mitkIpInt2_t*)rt_pic->data, *rt_xzero, rt, phit; - mitkIpUInt4_t *phitp=(mitkIpUInt4_t*)phit_pic->data; - mitkIpFloat4_t *fr=(mitkIpFloat4_t *)fr_pic->data; - mitkIpFloat4_t *fphi=(mitkIpFloat4_t *)fphi_pic->data; - - mitkIpFloat4_t r, phi, scale=(double)orig_xsize/(double)new_xsize; - - int x,y,xy0,xy0_orig, oxy_size, new_zsize; - oxy_size=orig_xsize*orig_ysize; - xy0=(int)(((double)new_xsize)/2+0.5); - xy0_orig=(int)(((double)orig_xsize)/2+0.5); - - new_zsize=(int)(orig_ysize/scale); - // \bug y compared to x - for(y=0;yanfangen bei -rt+1!*/ - // if((x>=-rt) && (xxy0?1.0:-1.0)*scale+xy0_orig; - else - r=r*(x>xy0?-1.0:1.0)*scale+xy0_orig; - rt=(mitkIpInt2_t)r; - int xtmp=x; - if(x>xy0) - xtmp=new_xsize-x; - if(rt<0) - { - r=rt=0; - if(xtmp>-*rt_xzero) - *rt_xzero=-xtmp; - *fr=0; - } - else - if(rt>orig_xsize-1) - { - r=rt=orig_xsize-1; - if(xtmp>-*rt_xzero) - *rt_xzero=-xtmp; - *fr=0; - } - else - *fr=r-rt; - if(*fr<0) - *fr=0; - } - // else - // *fr=0; - - phi=orig_zsize-(yq==0?1:-atan((float)xq/yq)/M_PI+0.5)*orig_zsize; - phit=(mitkIpUInt4_t)phi; - *fphi=phi-phit; - - *rtp=rt; - *phitp=phit*oxy_size; - } - } - - zt=(unsigned int *)malloc(sizeof(unsigned int)*new_zsize); - fz=(float *)malloc(sizeof(float)*new_zsize); - - float *fzp=fz; - unsigned int *ztp=zt; - - int z; - float z_step=orig_ysize/(orig_ysize*((float)new_xsize)/orig_xsize); - for(z=0;ztype=mitkIpPicInt; - coneCutOff_pic->bpe=16; - coneCutOff_pic->dim=2; - coneCutOff_pic->n[0]=coneCutOff_pic->n[1]=rt_pic->n[0]; - coneCutOff_pic->data=malloc(_mitkIpPicSize(coneCutOff_pic)); - - int i, size=_mitkIpPicElements(rt_pic); - mitkIpInt2_t *rt, *ccop, ohx_size, nz_size; - mitkIpFloat4_t *fr; - - a*=(float)rt_pic->n[0]/orig_xsize; - b*=(float)rt_pic->n[0]/orig_xsize; - - ohx_size=orig_xsize/2; - nz_size=orig_ysize*rt_pic->n[0]/orig_xsize; - - rt=(mitkIpInt2_t *)rt_pic->data; fr=(mitkIpFloat4_t*)fr_pic->data; ccop=(mitkIpInt2_t *)coneCutOff_pic->data; - - for(i=0; i=nz_size) - cco=nz_size; - *ccop=cco; - } -} - -void mitk::CylindricToCartesianFilter::GenerateOutputInformation() -{ - mitk::Image::Pointer output = this->GetOutput(); - if ((output->IsInitialized()) && (output->GetPipelineMTime() <= m_TimeOfHeaderInitialization.GetMTime())) - return; - - mitk::Image::ConstPointer input = this->GetInput(); - - itkDebugMacro(<<"GenerateOutputInformation()"); - - unsigned int i, *tmpDimensions=new unsigned int[std::max(3u,input->GetDimension())]; - - tmpDimensions[0]=m_TargetXSize; - if(tmpDimensions[0]==0) - tmpDimensions[0] = input->GetDimension(0); - - float scale=((float)tmpDimensions[0])/input->GetDimension(0); - - tmpDimensions[1] = tmpDimensions[0]; - tmpDimensions[2] = (unsigned int)(scale*input->GetDimension(1)); - - for(i=3;iGetDimension();++i) - tmpDimensions[i]=input->GetDimension(i); - - output->Initialize(input->GetPixelType(), - input->GetDimension(), - tmpDimensions, - input->GetNumberOfChannels()); - - // initialize the spacing of the output - Vector3D spacing = input->GetSlicedGeometry()->GetSpacing(); - if(input->GetDimension()>=2) - spacing[2]=spacing[1]; - else - spacing[2] = 1.0; - spacing[1] = spacing[0]; - spacing *= 1.0/scale; - output->GetSlicedGeometry()->SetSpacing(spacing); - - mitk::Point3iProperty::Pointer pointProp; - pointProp = dynamic_cast(input->GetProperty("ORIGIN").GetPointer()); - if (pointProp.IsNotNull() ) - { - itk::Point tp = pointProp->GetValue(); - tp[2] = (int)(tmpDimensions[2]-tp[1] * scale-1); - tp[0] = tmpDimensions[0]/2; - tp[1] = tmpDimensions[0]/2; - mitk::Point3iProperty::Pointer pointProp = mitk::Point3iProperty::New(tp); - output->SetProperty("ORIGIN", pointProp); - } - delete [] tmpDimensions; - - //output->GetSlicedGeometry()->SetPlaneGeometry(mitk::Image::BuildStandardPlanePlaneGeometry(output->GetSlicedGeometry(), tmpDimensions).GetPointer(), 0); - //set the timebounds - after SetPlaneGeometry, so that the already created PlaneGeometry will also receive this timebounds. - //@fixme!!! will not work for not evenly timed data! - - ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New(); - timeGeometry->Initialize(output->GetSlicedGeometry(), output->GetTimeGeometry()->CountTimeSteps()); - timeGeometry->Initialize(output->GetSlicedGeometry(), output->GetTimeGeometry()->CountTimeSteps()); - timeGeometry->SetFirstTimePoint(input->GetTimeGeometry()->GetMinimumTimePoint()); - TimePointType stepDuration = input->GetTimeGeometry()->GetMaximumTimePoint(0) -input->GetTimeGeometry()->GetMinimumTimePoint(0); - timeGeometry->SetStepDuration(stepDuration); - output->SetTimeGeometry(timeGeometry); - - output->SetPropertyList(input->GetPropertyList()->Clone()); - m_TimeOfHeaderInitialization.Modified(); -} - -void mitk::CylindricToCartesianFilter::GenerateData() -{ - mitk::Image::ConstPointer input = this->GetInput(); - mitk::Image::Pointer output = this->GetOutput(); - - mitk::ImageTimeSelector::Pointer timeSelector=mitk::ImageTimeSelector::New(); - timeSelector->SetInput(input); - - mitkIpPicDescriptor* pic_transformed=NULL; - pic_transformed = mitkIpPicNew(); - pic_transformed->dim=3; - pic_transformed->bpe = output->GetPixelType().GetBpe(); - //pic_transformed->type = output->GetPixelType().GetType(); - pic_transformed->n[0] = output->GetDimension(0); - pic_transformed->n[1] = output->GetDimension(1); - pic_transformed->n[2] = output->GetDimension(2); - pic_transformed->data=malloc(_mitkIpPicSize(pic_transformed)); - - int nstart, nmax; - int tstart, tmax; - - tstart=output->GetRequestedRegion().GetIndex(3); - nstart=output->GetRequestedRegion().GetIndex(4); - - tmax=tstart+output->GetRequestedRegion().GetSize(3); - nmax=nstart+output->GetRequestedRegion().GetSize(4); - - if(zt==NULL) - { - timeSelector->SetChannelNr(nstart); - timeSelector->SetTimeNr(tstart); - - buildTransformShortCuts(input->GetDimension(0),input->GetDimension(1), input->GetDimension(2), output->GetDimension(0), rt_pic, phit_pic, fr_pic, fphi_pic, zt, fz); - - // query the line limiting the sector - a=b=0; - mitk::FloatProperty::Pointer prop; - - prop = dynamic_cast(input->GetProperty("SECTOR LIMITING LINE SLOPE").GetPointer()); - if (prop.IsNotNull() ) - a = prop->GetValue(); - prop = dynamic_cast(input->GetProperty("SECTOR LIMITING LINE OFFSET").GetPointer()); - if (prop.IsNotNull() ) - b = prop->GetValue(); - - buildConeCutOffShortCut(input->GetDimension(0),input->GetDimension(1), rt_pic, fr_pic, a, b, coneCutOff_pic); - // mitkIpPicPut("C:\\temp\\rt_90.pic",rt_pic); - //mitkIpPicPut("C:\\temp\\coneCutOff.pic", coneCutOff_pic); - } - - int n,t; - for(n=nstart;nGetNumberOfChannels();++n) - { - timeSelector->SetChannelNr(n); - - for(t=tstart;tSetTimeNr(t); - - timeSelector->Update(); - - // Cast to pic descriptor for the timeSelector image - mitkIpPicDescriptor* timeSelectorPic = mitkIpPicNew(); - mitk::ImageWriteAccessor imageAccess(timeSelector->GetOutput()); - CastToIpPicDescriptor( timeSelector->GetOutput(), &imageAccess, timeSelectorPic ); - - _mitkIpPicFreeTags(pic_transformed->info->tags_head); - pic_transformed->info->tags_head = _mitkIpPicCloneTags(timeSelectorPic->info->tags_head); - - if(input->GetDimension(2)>1) - { - mitkIpPicTypeMultiplex9(_transform, timeSelectorPic , pic_transformed, m_OutsideValue, (float*)fr_pic->data, (float*)fphi_pic->data, fz, (short *)rt_pic->data, (unsigned int *)phit_pic->data, zt, coneCutOff_pic); - // mitkIpPicPut("1trf.pic",pic_transformed); - } - else - { - mitkIpPicDescriptor *doubleSlice = mitkIpPicCopyHeader( timeSelectorPic , NULL); - doubleSlice->dim=3; - doubleSlice->n[2]=2; - doubleSlice->data=malloc(_mitkIpPicSize(doubleSlice)); - memcpy(doubleSlice->data, timeSelectorPic->data, _mitkIpPicSize(doubleSlice)/2); - mitkIpPicTypeMultiplex9(_transform, doubleSlice, pic_transformed, m_OutsideValue, (float*)fr_pic->data, (float*)fphi_pic->data, fz, (short *)rt_pic->data, (unsigned int *)phit_pic->data, zt, coneCutOff_pic); - mitkIpPicFree(doubleSlice); - } - output->SetVolume(pic_transformed->data, t, n); - } - } - //mitkIpPicPut("outzzzzzzzz.pic",pic_transformed); - mitkIpPicFree(pic_transformed); - - m_TimeOfHeaderInitialization.Modified(); -} - -mitk::CylindricToCartesianFilter::CylindricToCartesianFilter() -: m_OutsideValue(0.0), m_TargetXSize(0) -{ - rt_pic = NULL; phit_pic = NULL; fr_pic = NULL; fphi_pic = NULL; coneCutOff_pic = NULL; - zt = NULL; fz = NULL; - a=b=0.0; -} - -mitk::CylindricToCartesianFilter::~CylindricToCartesianFilter() -{ - if(rt_pic!=NULL) mitkIpPicFree(rt_pic); - if(phit_pic!=NULL) mitkIpPicFree(phit_pic); - if(fr_pic!=NULL) mitkIpPicFree(fr_pic); - if(fphi_pic!=NULL) mitkIpPicFree(fphi_pic); - if(coneCutOff_pic!=NULL) mitkIpPicFree(coneCutOff_pic); - if(zt != NULL) free(zt); - if(fz != NULL) free (fz); -} - -void mitk::CylindricToCartesianFilter::GenerateInputRequestedRegion() -{ - Superclass::GenerateInputRequestedRegion(); - - mitk::ImageToImageFilter::InputImagePointer input = - const_cast< mitk::ImageToImageFilter::InputImageType * > ( this->GetInput() ); - mitk::Image::Pointer output = this->GetOutput(); - - Image::RegionType requestedRegion; - requestedRegion = output->GetRequestedRegion(); - requestedRegion.SetIndex(0, 0); - requestedRegion.SetIndex(1, 0); - requestedRegion.SetIndex(2, 0); - requestedRegion.SetSize(0, input->GetDimension(0)); - requestedRegion.SetSize(1, input->GetDimension(1)); - requestedRegion.SetSize(2, input->GetDimension(2)); - - input->SetRequestedRegion( & requestedRegion ); -} diff --git a/Modules/Ext/Algorithms/mitkCylindricToCartesianFilter.h b/Modules/Ext/Algorithms/mitkCylindricToCartesianFilter.h deleted file mode 100644 index 1de3bbfc7f..0000000000 --- a/Modules/Ext/Algorithms/mitkCylindricToCartesianFilter.h +++ /dev/null @@ -1,109 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKCYLINDRICTOCARTESIANFILTER_H_HEADER_INCLUDED_C1F48A22 -#define MITKCYLINDRICTOCARTESIANFILTER_H_HEADER_INCLUDED_C1F48A22 - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkImageToImageFilter.h" -#include "mitkIpPic.h" - -#ifndef M_PI - #define M_PI 3.14159265358979323846 -#endif - -//#endif -namespace mitk { -//##Documentation -//## @brief Filter to convert a cylindric image into a cartesian image -//## -//## @todo position of input image is not yet used to calculate position of the output -//## @todo tag with transducer position not yet transformed. -//## @todo the line limiting the sector is assumed to be available as a pic tag. Is this ok? -//## @ingroup Process -class MitkExt_EXPORT CylindricToCartesianFilter : public ImageToImageFilter -{ -public: - mitkClassMacro(CylindricToCartesianFilter, ImageToImageFilter); - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - //##Documentation - //## @brief Set background grey level - itkSetMacro(OutsideValue, float); - //##Documentation - //## @brief Get background grey level - itkGetMacro(OutsideValue, float); - - //##Documentation - //## @brief Set the size in x-direction of the converted image. - //## - //## A value of 0 (default) means that the filter uses the x-size of the input image. - itkSetMacro(TargetXSize, unsigned int); - //##Documentation - //## @brief Get the size in x-direction of the converted image. - itkGetMacro(TargetXSize, unsigned int); - - //##Documentation - //## @brief Build some tables to speed up transformation, e.g., to avoid repeated calulations of the same sinus/cosinus. - //## @todo Free tables if they were already previously allocated - void buildTransformShortCuts(int orig_xsize, int orig_ysize, int orig_zsize, int new_xsize, mitkIpPicDescriptor * &rt_pic, mitkIpPicDescriptor * &phit_pic, mitkIpPicDescriptor * &fr_pic, mitkIpPicDescriptor * &fphi_pic, unsigned int * &zt, float * &fz); - - //##Documentation - //## @brief Build some tables to speed up transformation of images that only contain data within a sector - //## @todo Free tables if they were already previously allocated - void buildConeCutOffShortCut(int orig_xsize, int orig_ysize, mitkIpPicDescriptor *rt_pic, mitkIpPicDescriptor *fr_pic, float a, float b, mitkIpPicDescriptor * &coneCutOff_pic); -protected: - mitkIpPicDescriptor * rt_pic, * phit_pic, *fr_pic, * fphi_pic, * coneCutOff_pic; - float * fz; - unsigned int * zt; - //##Description - //## @brief Cut off line for images that only contain data within a sector - //## - //## y=a x+b - float a; - //##Description - //## @brief Cut off line for images that only contain data within a sector - //## - //## y=a x+b - float b; - - //##Description - //## @brief Time when Header was last initialized - itk::TimeStamp m_TimeOfHeaderInitialization; -protected: - virtual void GenerateData(); - - virtual void GenerateOutputInformation(); - - virtual void GenerateInputRequestedRegion(); - - CylindricToCartesianFilter(); - - ~CylindricToCartesianFilter(); - - float m_OutsideValue; - unsigned int m_TargetXSize; -}; - -} // namespace mitk - -#endif /* MITKCYLINDRICTOCARTESIANFILTER_H_HEADER_INCLUDED_C1F48A22 */ - - diff --git a/Modules/Ext/Algorithms/mitkGeometryDataSource.cpp b/Modules/Ext/Algorithms/mitkGeometryDataSource.cpp deleted file mode 100644 index f4fc140e50..0000000000 --- a/Modules/Ext/Algorithms/mitkGeometryDataSource.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkGeometryDataSource.h" -#include "mitkGeometryData.h" - -mitk::GeometryDataSource::GeometryDataSource() -{ - // Create the output. - itk::DataObject::Pointer output = this->MakeOutput(0); - Superclass::SetNumberOfRequiredOutputs(1); - Superclass::SetNthOutput(0, output); -} - -mitk::GeometryDataSource::~GeometryDataSource() -{ -} - -itk::DataObject::Pointer mitk::GeometryDataSource::MakeOutput ( DataObjectPointerArraySizeType /*idx*/ ) -{ - return OutputType::New().GetPointer(); -} - -itk::DataObject::Pointer mitk::GeometryDataSource::MakeOutput( const DataObjectIdentifierType & name ) -{ - itkDebugMacro("MakeOutput(" << name << ")"); - if( this->IsIndexedOutputName(name) ) - { - return this->MakeOutput( this->MakeIndexFromOutputName(name) ); - } - return OutputType::New().GetPointer(); -} - -mitkBaseDataSourceGetOutputDefinitions(mitk::GeometryDataSource) diff --git a/Modules/Ext/Algorithms/mitkGeometryDataSource.h b/Modules/Ext/Algorithms/mitkGeometryDataSource.h deleted file mode 100644 index c67ca5a7af..0000000000 --- a/Modules/Ext/Algorithms/mitkGeometryDataSource.h +++ /dev/null @@ -1,77 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKGEOMETRYDATASOURCE_H_HEADER_INCLUDED_C10B4740 -#define MITKGEOMETRYDATASOURCE_H_HEADER_INCLUDED_C10B4740 - -#include "mitkBaseDataSource.h" -#include "MitkExtExports.h" - -namespace mitk { - -class GeometryData; - -/** - * @brief Superclass of all classes generating GeometryData (instances of class - * GeometryData) as output. - * - * In itk and vtk the generated result of a ProcessObject is only guaranteed - * to be up-to-date, when Update() of the ProcessObject or the generated - * DataObject is called immediately before access of the data stored in the - * DataObject. This is also true for subclasses of mitk::BaseProcess and thus - * for mitk::GeometryDataSource. - * @ingroup Process - */ -class MitkExt_EXPORT GeometryDataSource : public BaseDataSource -{ -public: - - mitkClassMacro(GeometryDataSource, BaseDataSource) - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - typedef mitk::GeometryData OutputType; - - mitkBaseDataSourceGetOutputDeclarations - - /** - * Allocates a new output object and returns it. Currently the - * index idx is not evaluated. - * @param idx the index of the output for which an object should be created - * @returns the new object - */ - virtual itk::DataObject::Pointer MakeOutput ( DataObjectPointerArraySizeType idx ); - - /** - * This is a default implementation to make sure we have something. - * Once all the subclasses of ProcessObject provide an appopriate - * MakeOutput(), then ProcessObject::MakeOutput() can be made pure - * virtual. - */ - virtual itk::DataObject::Pointer MakeOutput(const DataObjectIdentifierType &name); - -protected: - - GeometryDataSource(); - virtual ~GeometryDataSource(); -}; - -} // namespace mitk - - - -#endif /* MITKGEOMETRYDATASOURCE_H_HEADER_INCLUDED_C10B4740 */ diff --git a/Modules/Ext/Algorithms/mitkImageToItkMultiplexer.h b/Modules/Ext/Algorithms/mitkImageToItkMultiplexer.h deleted file mode 100644 index 2ce6000a78..0000000000 --- a/Modules/Ext/Algorithms/mitkImageToItkMultiplexer.h +++ /dev/null @@ -1,203 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKIMAGETOITKMULTIPLEXER_H_HEADER_INCLUDED -#define MITKIMAGETOITKMULTIPLEXER_H_HEADER_INCLUDED - -#include -#include - -/*! -* \brief method creates a cast image filter and casts the image of ItkInputImageType -* to type ItkOutputImageType. The method needs to be called via the -* mitkImageToItkMultiplexer -* -* \code -* mitk::Image::Pointer inputMitkImage; -* ... // set inputMitkImage -* ITKImageType::Pointer resultItkImage = ITKImageType::New(); -* FixedInputDimensionMitkToItkFunctionMultiplexer(resultItkImage, ITKImageType, inputMitkImage, dimension, MakeCastImageFilter); -* -* \endcode -*/ -template < typename ItkInputImageType, typename ItkOutputImageType > -typename itk::ImageSource < ItkOutputImageType > ::Pointer -MakeCastImageFilter( ItkInputImageType* inputImage ) -{ - typedef itk::CastImageFilter < ItkInputImageType , - ItkOutputImageType > myFilterType; - typename myFilterType::Pointer myFilter = myFilterType::New(); - myFilter->SetInput( inputImage ); - return myFilter.GetPointer(); -} - -#define _calculateItkPipelineFunction(result, mitksource, itkpipelinefunction, type, dimension) \ - if ( typeId == typeid(type) ) \ -{ \ - typedef itk::Image ImageType; \ - typedef mitk::ImageToItk ImageToItkType; \ - typedef itk::SmartPointer ImageToItkTypePointer; \ - typedef itk::ImageSource ImageFilterType; \ - typedef itk::SmartPointer ImageFilterTypePointer; \ - \ - ImageToItkTypePointer myImageToItkFilter = ImageToItkType::New(); \ - myImageToItkFilter ->SetInput(mitksource); \ - \ - ImageFilterTypePointer itkpipeline = \ - itkpipelinefunction(myImageToItkFilter->GetOutput()).GetPointer(); \ - itkpipeline->Update(); \ - \ - result->InitializeByItk(itkpipeline->GetOutput()); \ - result->SetVolume(itkpipeline->GetOutput()->GetBufferPointer()); \ -} -// _calculateItkPipelineFunction(result, mitkimage, itkpipeline::New()); - -#define ItkFunctionMultiplexer(result, mitkSourceImage, itkfunction) \ -{ \ - const std::type_info& typeId=*mitkSourceImage->GetPixelType().GetTypeId(); \ - switch (mitkSourceImage->GetDimension()) \ -{ \ - case 2: \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, double, 2) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, float, 2) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, long, 2) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, unsigned long, 2) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, int, 2) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, unsigned int, 2) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, short, 2) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, unsigned short, 2) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, char, 2) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, unsigned char, 2) \ - break; \ - case 3: \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, double, 3) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, float, 3) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, long, 3) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, unsigned long, 3) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, int, 3) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, unsigned int, 3) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, short, 3) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, unsigned short, 3) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, char, 3) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, unsigned char, 3) \ - break; \ - case 4: \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, double, 4) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, float, 4) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, long, 4) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, unsigned long, 4) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, int, 4) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, unsigned int, 4) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, short, 4) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, unsigned short, 4) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, char, 4) else \ - _calculateItkPipelineFunction(result, mitkSourceImage, itkfunction, unsigned char, 4) \ - break; \ - default: break; \ -} \ -} -/////////////////////////////////////////////// - -#define _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitksource, itkpipelinefunction, type, dimension) \ - if ( typeId == typeid(type) ) \ -{ \ - typedef itk::Image ImageType; \ - typedef mitk::ImageToItk ImageToItkType; \ - typedef itk::SmartPointer ImageToItkTypePointer; \ - typedef itk::ImageSource ImageFilterType; \ - typedef itk::SmartPointer ImageFilterTypePointer; \ - \ - ImageToItkTypePointer myImageToItkFilter = ImageToItkType::New(); \ - myImageToItkFilter->SetInput(mitksource); \ - \ - ImageFilterTypePointer itkpipeline = \ - itkpipelinefunction(myImageToItkFilter->GetOutput()).GetPointer(); \ - itkpipeline->Update(); \ - \ - resultItkImage = itkpipeline->GetOutput(); \ -} - -//##Documentation -//## @brief multiplexes a mitk image to an itkFilter with inputs of dimensions 2-4 and all data types (the itkFilter must allow to do this!). -#define AllInputDimensionMitkToItkFunctionMultiplexer(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction) \ -{ \ - const std::type_info& typeId=*mitkSourceImage->GetPixelType().GetTypeId(); \ - switch (mitkSourceImage->GetDimension()) \ -{ \ - case 2: \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, double, 2) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, float, 2) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, long, 2) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned long, 2) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, int, 2) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned int, 2) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, short, 2) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned short, 2) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, char, 2) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned char, 2) \ - break; \ - case 3: \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, double, 3) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, float, 3) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, long, 3) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned long, 3) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, int, 3) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned int, 3) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, short, 3) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned short, 3) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, char, 3) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned char, 3) \ - break; \ - case 4: \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, double, 4) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, float, 4) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, long, 4) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned long, 4) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, int, 4) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned int, 4) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, short, 4) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned short, 4) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, char, 4) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned char, 4) \ - break; \ - default: break; \ -} \ -} - -//##Documentation -//## @brief multiplexes a mitk image to an itkFilter with inputs of fixed dimensions @a inputDimension and all data types (the itkFilter must allow to do this!). -#define FixedInputDimensionMitkToItkFunctionMultiplexer(resultItkImage, resultItkImageType, mitkSourceImage, inputDimension, itkfunction) \ -{ \ - const std::type_info& typeId=*mitkSourceImage->GetPixelType().GetTypeId(); \ - if (mitkSourceImage->GetDimension() == inputDimension) \ - { \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, double, inputDimension) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, float, inputDimension) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, long, inputDimension) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned long, inputDimension) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, int, inputDimension) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned int, inputDimension) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, short, inputDimension) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned short, inputDimension) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, char, inputDimension) else \ - _calculateMitkToItkPipelineFunction(resultItkImage, resultItkImageType, mitkSourceImage, itkfunction, unsigned char, inputDimension) \ - } \ -} - -//for compatibility -#include "mitkImageCast.h" -#endif // of MITKIMAGETOITKMULTIPLEXER_H_HEADER_INCLUDED diff --git a/Modules/Ext/Algorithms/mitkImageToLookupTableFilter.cpp b/Modules/Ext/Algorithms/mitkImageToLookupTableFilter.cpp deleted file mode 100644 index 5d7fc7a7e5..0000000000 --- a/Modules/Ext/Algorithms/mitkImageToLookupTableFilter.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkImageToLookupTableFilter.h" -#include "mitkImageToItk.h" -#include "itkImage.h" -#include "itkVector.h" -#include "itkImageRegionIterator.h" -#include "itkNumericTraits.h" -#include - -mitk::ImageToLookupTableFilter::ImageToLookupTableFilter() -{ - this->SetNumberOfRequiredInputs(1); -} - - - - -mitk::ImageToLookupTableFilter::~ImageToLookupTableFilter() -{ - -} - - - - -void mitk::ImageToLookupTableFilter::SetInput( const mitk::ImageToLookupTableFilter::InputImageType *input) -{ - // Process object is not const-correct so the const_cast is required here - this->itk::ProcessObject::SetNthInput( 0, const_cast< InputImageType * >( input ) ); - -} - - - - -void mitk::ImageToLookupTableFilter::SetInput( unsigned int index, const mitk::ImageToLookupTableFilter::InputImageType * input) -{ - if ( index + 1 > this->GetNumberOfInputs() ) - { - this->SetNumberOfRequiredInputs( index + 1 ); - } - // Process object is not const-correct so the const_cast is required here - this->ProcessObject::SetNthInput( index, const_cast< InputImageType *>( input ) ); -} - - - - -const mitk::ImageToLookupTableFilter::InputImageType * mitk::ImageToLookupTableFilter::GetInput(void) -{ - if ( this->GetNumberOfInputs() < 1 ) - { - return 0; - } - return static_cast( this->ProcessObject::GetInput( 0 ) ); -} - - - - -const mitk::ImageToLookupTableFilter::InputImageType * mitk::ImageToLookupTableFilter::GetInput(unsigned int idx) -{ - return static_cast< const InputImageType * >( this->ProcessObject::GetInput( idx ) ); -} - - - - -void mitk::ImageToLookupTableFilter::GenerateData() -{ - this->SetNumberOfIndexedOutputs( this->GetNumberOfInputs() ); - for (unsigned int inputIdx = 0; inputIdx < this->GetNumberOfInputs() ; ++inputIdx) - { - InputImagePointer image = const_cast(this->GetInput( inputIdx )); - OutputTypePointer output = dynamic_cast(this->MakeOutput( inputIdx ).GetPointer()); - - this->ProcessObject::SetNthOutput( inputIdx, output.GetPointer() ); - if (image.IsNull()) - { - itkWarningMacro(<< inputIdx<<"'th input image is null!"); - return; - } - - // the default vtkLookupTable has range=[0,1]; and hsv ranges set - // up for rainbow color table (from red to blue). - - vtkSmartPointer vtkLut = vtkSmartPointer::New(); - /* - if ( ( image->GetPixelType().GetNumberOfComponents() == 3 ) && ( image->GetDimension() == 3 ) ) - { - - // some typedefs for conversion to an iterable itk image - const unsigned int VectorDimension = 3; - typedef float VectorComponentType; - typedef itk::Vector< VectorComponentType, VectorDimension > VectorType; - typedef itk::Image< VectorType, VectorDimension > VectorFieldType; - typedef itk::ImageRegionIterator< VectorFieldType > VectorFieldIteratorType; - typedef mitk::ImageToItk ImageConverterType; - - // some local variables - float minValue = itk::NumericTraits::max(); - float maxValue = itk::NumericTraits::NonpositiveMin(); - float norm = 0.0f; - - //determine the range of the vector magnitudes in the image - ImageConverterType::Pointer imageConverter = ImageConverterType::New(); - imageConverter->SetInput(image); - VectorFieldType::Pointer itkImage = imageConverter->GetOutput(); - VectorFieldIteratorType it( itkImage, itkImage->GetRequestedRegion() ); - it.GoToBegin(); - while ( !it.IsAtEnd() ) - { - norm = it.Get().GetNorm(); - minValue = std::min(norm, minValue); - maxValue = std::max(norm, maxValue); - } - MITK_INFO << "Range of vector magnitudes: [" << minValue << ", "<< maxValue << "]." << std::endl; - vtkLut->SetRange(minValue, maxValue); - } - else - { - itkWarningMacro(<< "Sorry, only 3d vector images are currently supported!"); - }*/ - vtkLut->SetRange(0, 10); - output->SetVtkLookupTable( vtkLut ); - } -} diff --git a/Modules/Ext/Algorithms/mitkImageToLookupTableFilter.h b/Modules/Ext/Algorithms/mitkImageToLookupTableFilter.h deleted file mode 100644 index ec2c2043b4..0000000000 --- a/Modules/Ext/Algorithms/mitkImageToLookupTableFilter.h +++ /dev/null @@ -1,66 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef _MITK_IMAGE_TO_LOOKUP_TABLE_FILTER__H_ -#define _MITK_IMAGE_TO_LOOKUP_TABLE_FILTER__H_ - -#include -#include "MitkExtExports.h" -#include - -namespace mitk -{ - -/** -* Creates a mitk::LookupTable from an image. This may be used to -* create a default coloring scheme for vector images... -*/ -class MitkExt_EXPORT ImageToLookupTableFilter : public LookupTableSource -{ -public: - - mitkClassMacro( ImageToLookupTableFilter, LookupTableSource ); - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - // typedefs for setting an image as input - typedef mitk::Image InputImageType; - typedef InputImageType::Pointer InputImagePointer; - typedef InputImageType::ConstPointer InputImageConstPointer; - - virtual void SetInput( const InputImageType *image); - - virtual void SetInput( unsigned int, const InputImageType * image); - - const InputImageType * GetInput(void); - - const InputImageType * GetInput(unsigned int idx); - -protected: - - virtual void GenerateData(); - - ImageToLookupTableFilter(); - - virtual ~ImageToLookupTableFilter(); - -}; - - -} //end of namespace mitk - -#endif diff --git a/Modules/Ext/Algorithms/mitkInterpolateLinesFilter.cpp b/Modules/Ext/Algorithms/mitkInterpolateLinesFilter.cpp deleted file mode 100644 index 0a124c1776..0000000000 --- a/Modules/Ext/Algorithms/mitkInterpolateLinesFilter.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkInterpolateLinesFilter.h" -#include "mitkMesh.h" -#include "mitkSurface.h" - -#include -#include -#include -#include - -#include - - -mitk::InterpolateLinesFilter::InterpolateLinesFilter() -: m_SplineResolution(10), m_GeometryForInterpolation(NULL), m_Length(0.0) -{ - m_SpX=vtkCardinalSpline::New(); - m_SpY=vtkCardinalSpline::New(); - m_SpZ=vtkCardinalSpline::New(); - -} - -mitk::InterpolateLinesFilter::~InterpolateLinesFilter() -{ - m_SpX->Delete(); - m_SpY->Delete(); - m_SpZ->Delete(); -} - -void mitk::InterpolateLinesFilter::GenerateOutputInformation() -{ - mitk::Mesh::ConstPointer input = this->GetInput(); - mitk::Surface::Pointer output = this->GetOutput(0); - - itkDebugMacro(<<"GenerateOutputInformation()"); - - if(input.IsNull()) return; - - if(m_GeometryForInterpolation.IsNotNull()) - output->SetGeometry(static_cast(m_GeometryForInterpolation->Clone().GetPointer())); - else - output->SetGeometry(static_cast(input->GetGeometry()->Clone().GetPointer())); -} - -void mitk::InterpolateLinesFilter::GenerateData() -{ - mitk::Mesh::ConstPointer input = this->GetInput(); - mitk::Surface::Pointer output = this->GetOutput(0); - - vtkPolyData *polyData = vtkPolyData::New(); - vtkPoints *points = vtkPoints::New(); - vtkCellArray *cellarray = vtkCellArray::New(); - - mitk::Mesh::PointType thisPoint; - - m_Length = 0.0; - - //iterate through all cells and build tubes - Mesh::ConstCellIterator cellIt, cellEnd; - cellEnd = input->GetMesh()->GetCells()->End(); - for( cellIt = input->GetMesh()->GetCells()->Begin(); cellIt != cellEnd; ++cellIt ) - { - if(((*cellIt->Value()).GetType()==mitk::Mesh::CellType::POLYGON_CELL) - && ((*cellIt->Value()).GetNumberOfPoints()>=2)) - BuildPointAndVectorList(*cellIt->Value(), points, cellarray); - } - - polyData->SetPoints( points ); - points->Delete(); - polyData->SetLines( cellarray ); - cellarray->Delete(); - - output->SetVtkPolyData(polyData); - - polyData->Delete(); -} - -void mitk::InterpolateLinesFilter::BuildPointAndVectorList(mitk::Mesh::CellType& cell, vtkPoints* points, vtkCellArray* cellarray) -{ - const mitk::Mesh* input = GetInput(); - - Mesh::PointIdIterator ptIt; - Mesh::PointIdIterator ptEnd; - - ptEnd = cell.PointIdsEnd(); - - Point3D pt; - - int i, size=cell.GetNumberOfPoints(); - - int closed_loop_pre_load=0;//m_SplineResolution; - if(m_GeometryForInterpolation.IsNull()) - { - //when the contour is closed: first point insert behind two last points for smooth crossing - ptIt = ptEnd; ptIt-=closed_loop_pre_load+1; - for(i=0;iGetPoint(*ptIt); - m_SpX->AddPoint(i, pt[0]); m_SpY->AddPoint(i, pt[1]); m_SpZ->AddPoint(i, pt[2]); - } - //insert points - for(ptIt = cell.PointIdsBegin();iGetPoint(*ptIt); - m_SpX->AddPoint(i, pt[0]); m_SpY->AddPoint(i, pt[1]); m_SpZ->AddPoint(i, pt[2]); - } - //when the contour is closed: after the last point insert two first points for smooth crossing - int j; - for(j=0,ptIt = cell.PointIdsBegin();jGetPoint(*ptIt); - m_SpX->AddPoint(i, pt[0]); m_SpY->AddPoint(i, pt[1]); m_SpZ->AddPoint(i, pt[2]); - } - //bool first = true; - Point3D lastPt, firstPt; - Vector3D vec; - float t, step=1.0f/m_SplineResolution; - size=(size-1)*m_SplineResolution; - i=closed_loop_pre_load; - - cellarray->InsertNextCell(size); - for(t=closed_loop_pre_load;iEvaluate(t), m_SpY->Evaluate(t), m_SpZ->Evaluate(t)); - cellarray->InsertCellPoint(points->InsertNextPoint(pt)); - } - } - else //m_GeometryForInterpolation!=NULL - { - Point2D pt2d; - //when the contour is closed: before the first point insert two last points for smooth crossing - ptIt = ptEnd; ptIt-=closed_loop_pre_load+1; - for(i=0;iMap(input->GetPoint(*ptIt), pt2d); - m_SpX->AddPoint(i, pt2d[0]); m_SpY->AddPoint(i, pt2d[1]); - } - //insert points - for(ptIt = cell.PointIdsBegin();iMap(input->GetPoint(*ptIt), pt2d); - m_SpX->AddPoint(i, pt2d[0]); m_SpY->AddPoint(i, pt2d[1]); - } - //when the contour is closed: after the last point insert two first points for smooth crossing - int j; - for(j=0,ptIt = cell.PointIdsBegin();jMap(input->GetPoint(*ptIt), pt2d); - m_SpX->AddPoint(i, pt2d[0]); m_SpY->AddPoint(i, pt2d[1]); - } - bool first = true; - Point3D lastPt; lastPt.Fill(0); - Vector3D vec; - float t, step=1.0f/m_SplineResolution; - size=(size-1)*m_SplineResolution; - i=closed_loop_pre_load; - - cellarray->InsertNextCell(size); - for(t=closed_loop_pre_load;iEvaluate(t); pt2d[1] = m_SpY->Evaluate(t); - m_GeometryForInterpolation->Map(pt2d, pt); - - if(first==false) - { - vec=pt-lastPt; - m_Length+=vec.GetNorm(); - } - first=false; - - float pvtk[3]; - itk2vtk(pt, pvtk); - cellarray->InsertCellPoint(points->InsertNextPoint(pvtk)); - lastPt = pt; - } - } -} - -const mitk::Mesh *mitk::InterpolateLinesFilter::GetInput(void) -{ - if (this->GetNumberOfInputs() < 1) - { - return 0; - } - - return static_cast - (this->ProcessObject::GetInput(0) ); -} - -void mitk::InterpolateLinesFilter::SetInput(const mitk::Mesh *input) -{ - // Process object is not const-correct so the const_cast is required here - this->ProcessObject::SetNthInput(0, - const_cast< mitk::Mesh * >( input ) ); -} diff --git a/Modules/Ext/Algorithms/mitkInterpolateLinesFilter.h b/Modules/Ext/Algorithms/mitkInterpolateLinesFilter.h deleted file mode 100644 index c4936fcc75..0000000000 --- a/Modules/Ext/Algorithms/mitkInterpolateLinesFilter.h +++ /dev/null @@ -1,105 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef MITKINTERPOLATELINESFILTER_H_HEADER_INCLUDED_C10B22CD -#define MITKINTERPOLATELINESFILTER_H_HEADER_INCLUDED_C10B22CD - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkSurfaceSource.h" -#include "mitkMesh.h" -#include "mitkPlaneGeometry.h" - -class vtkPolyData; -class vtkPoints; -class vtkCardinalSpline; -class vtkPoints; -class vtkCellArray; - - -namespace mitk { - -//##Documentation -//## @brief Interpolate additional points on lines -//## -//## If a PlaneGeometry is set (by SetGeometryForInterpolation), -//## we do an interpolation in the 2D-space of the PlaneGeometry: -//## Map two neighboring original points on -//## the PlaneGeometry, resulting in two 2D-points, interpolate -//## in 2D between them, and map them back via the -//## PlaneGeometry in the 3D-world. -//## @ingroup Process -class MitkExt_EXPORT InterpolateLinesFilter : public SurfaceSource -{ -public: - mitkClassMacro(InterpolateLinesFilter, SurfaceSource); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - virtual void GenerateOutputInformation(); - - virtual void GenerateData(); - - const mitk::Mesh *GetInput(void); - - virtual void SetInput(const mitk::Mesh *image); - - //##Documentation - //## @brief Get spline resolution - //## - itkGetMacro(SplineResolution, unsigned int); - //##Documentation - //## @brief Set spline resolution - //## - itkSetMacro(SplineResolution, unsigned int); - - //##Documentation - //## @brief Get/set geometry for interpolation - //## - //## If this is set (not NULL), we do an interpolation in the - //## 2D-space of the PlaneGeometry: Map two neighboring original - //## points on the PlaneGeometry, resulting in two 2D-points, - //## interpolate in 2D between them, and map them back via the - //## PlaneGeometry in the 3D-world. - itkGetConstObjectMacro(GeometryForInterpolation, mitk::PlaneGeometry); - itkSetObjectMacro(GeometryForInterpolation, mitk::PlaneGeometry); - - //##Documentation - //## @brief Get the overall length of the interpolated lines - //## - //## @warning valid only after Update() - itkGetMacro(Length, ScalarType); -protected: - - InterpolateLinesFilter(); - virtual ~InterpolateLinesFilter(); - - void BuildPointAndVectorList(mitk::Mesh::CellType& cell, vtkPoints* points, vtkCellArray* cellarray); - - //##Documentation - //## @brief Spline resolution of created Surface - //## - unsigned int m_SplineResolution; - - mitk::PlaneGeometry::Pointer m_GeometryForInterpolation; - vtkCardinalSpline *m_SpX, *m_SpY, *m_SpZ; - - ScalarType m_Length; -}; - -} // namespace mitk - -#endif /* MITKINTERPOLATELINESFILTER_H_HEADER_INCLUDED_C10B22CD */ diff --git a/Modules/Ext/Algorithms/mitkItkImageToImageFilterAdapter.h b/Modules/Ext/Algorithms/mitkItkImageToImageFilterAdapter.h deleted file mode 100644 index 685a1fa3fa..0000000000 --- a/Modules/Ext/Algorithms/mitkItkImageToImageFilterAdapter.h +++ /dev/null @@ -1,70 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef ITKIMAGETOIMAGEFILTERADAPTER_H_HEADER_INCLUDED_C1E5E869 -#define ITKIMAGETOIMAGEFILTERADAPTER_H_HEADER_INCLUDED_C1E5E869 - -#include "mitkCommon.h" -#include "mitkImageToImageFilter.h" - -#include "itkImage.h" -#include "itkImageToImageFilter.h" - -namespace mitk { - -//##Documentation -//## @brief adapter class, that encapsulates any itk::ImageToImageFilter -//## -//## This filter converts a mitk::Image to an itk::Image, executes the -//## itkFilter and converts the itk::Image back to a mitk::Image as output. -//## Either call SetSingleFilter() to encapsulate one itk::ImageToImageFilter, -//## or SetFirstFilter() and SetLastFilter() to encapsulate a whole itk pipeline. -//## @ingroup Process -template -class ItkImageToImageFilterAdapter : public ImageToImageFilter -{ -public: - typedef TPixel PixelType; - typedef itk::Image ItkImageType; - typedef itk::ImageToImageFilter ImageToImageFilterType; - - mitkClassMacro(ItkImageToImageFilterAdapter,ImageSource); - /** Method for creation through the object factory. */ - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - itkSetObjectMacro(FirstFilter, ImageToImageFilterType); - itkGetObjectMacro(FirstFilter, ImageToImageFilterType); - itkSetObjectMacro(LastFilter, ImageToImageFilterType); - itkGetObjectMacro(LastFilter, ImageToImageFilterType); - void SetSingleFilter(typename ImageToImageFilterType::Pointer filter); - - virtual void GenerateOutputInformation(); - virtual void GenerateData(); - -protected: - ItkImageToImageFilterAdapter(); - virtual ~ItkImageToImageFilterAdapter(); - - typename ImageToImageFilterType::Pointer m_FirstFilter; // Start of Filter Pipeline - typename ImageToImageFilterType::Pointer m_LastFilter; // End of Filter Pipeline -}; -} // namespace mitk - -#include "mitkItkImageToImageFilterAdapter.txx" // because it is a template - -#endif /* ITKIMAGETOIMAGEFILTERADAPTER_H_HEADER_INCLUDED_C1E5E869 */ diff --git a/Modules/Ext/Algorithms/mitkItkImageToImageFilterAdapter.txx b/Modules/Ext/Algorithms/mitkItkImageToImageFilterAdapter.txx deleted file mode 100644 index fb0f1317b0..0000000000 --- a/Modules/Ext/Algorithms/mitkItkImageToImageFilterAdapter.txx +++ /dev/null @@ -1,112 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef MITKITKIMAGETOIMAGEFILTERADAPTER_TXX -#define MITKITKIMAGETOIMAGEFILTERADAPTER_TXX - -#include "mitkItkImageToImageFilterAdapter.h" -#include "mitkImageToItkMultiplexer.h" -#include "mitkImage.h" -#include - -namespace mitk -{ - -template -ItkImageToImageFilterAdapter< TPixel>::ItkImageToImageFilterAdapter() -: m_FirstFilter(NULL), m_LastFilter(NULL) -{ -} - -template -ItkImageToImageFilterAdapter< TPixel>::~ItkImageToImageFilterAdapter() -{ -} - -/** - * \todo check if this is no conflict to the ITK filter writing rules -> ITK SoftwareGuide p.512 - */ -template -void ItkImageToImageFilterAdapter< TPixel>::GenerateOutputInformation() -{ - itkDebugMacro(<<"GenerateOutputInformation()"); -} - -template -void ItkImageToImageFilterAdapter< TPixel>::GenerateData() -{ - mitk::Image::Pointer outputImage = this->GetOutput(); - typename ImageToImageFilter::InputImageConstPointer inputImage = this->GetInput(); - if(inputImage.IsNull()) - { - outputImage = NULL; - return; - } - /* Check if there is an input Filter */ - if(m_FirstFilter.IsNull() || m_LastFilter.IsNull()) - { - outputImage = const_cast(inputImage.GetPointer()); - return; - } - /* convert input mitk image to itk image */ - mitk::Image::Pointer inputImageMitk = const_cast(inputImage.GetPointer()); // const away cast, because FixedInput...Multiplexer Macro needs non const Pointer - typename ItkImageType::Pointer itkImage = ItkImageType::New(); - //FixedInputDimensionMitkToItkFunctionMultiplexer(itkImage, ItkImageType , inputImageMitk, 3, MakeCastImageFilter); - CastToItkImage(inputImageMitk, itkImage); - /* check if image conversion failed */ - if (itkImage.IsNull()) - { - std::cout << " can't convert input image to itk" << std::endl; - outputImage = const_cast(inputImage.GetPointer()); - return; - } - //m_ItkImageToImageFilter->SetInput(itkImage); - m_FirstFilter->SetInput(itkImage); - try - { - //m_ItkImageToImageFilter->Update(); - m_LastFilter->UpdateLargestPossibleRegion(); - } - catch( itk::ExceptionObject & excep ) - { - std::cerr << "mitk::ItkImageToImageFilterAdapter: Exception while executing ITK filter" << std::endl; - std::cerr << excep << std::endl; - } - /* convert the itk image back to an mitk image and set it as output for this filter */ - //outputImage->InitializeByItk(m_LastFilter->GetOutput()); - //outputImage->SetVolume(m_LastFilter->GetOutput()->GetBufferPointer()); - //ItkImageType::Pointer itkOutputImage = m_LastFilter->GetOutput(); - //CastToMitkImage(itkOutputImage, outputImage); - - - typename ItkImageType::Pointer itkOutputImage; - itkOutputImage = m_LastFilter->GetOutput(); - - - CastToMitkImage(itkOutputImage, outputImage); - /* copy the transform from source to result image */ - outputImage->SetGeometry(static_cast(inputImage->GetGeometry()->Clone().GetPointer())); -} - - -template -void ItkImageToImageFilterAdapter::SetSingleFilter(typename ImageToImageFilterType::Pointer filter) -{ - SetFirstFilter(filter); - SetLastFilter(filter); -} -} -#endif // of MITKITKIMAGETOIMAGEFILTERADAPTER_TXX diff --git a/Modules/Ext/Algorithms/mitkMeshSource.cpp b/Modules/Ext/Algorithms/mitkMeshSource.cpp deleted file mode 100644 index 474790fa86..0000000000 --- a/Modules/Ext/Algorithms/mitkMeshSource.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkMeshSource.h" - - -mitk::MeshSource::MeshSource() -{ - // Create the output. - OutputType::Pointer output = dynamic_cast ( this->MakeOutput( 0 ).GetPointer() ); - assert (output.IsNotNull()); - this->SetNumberOfRequiredInputs(0); - this->SetNumberOfIndexedOutputs( 1 ); - this->SetOutput(0, output.GetPointer()); -} - -mitk::MeshSource::~MeshSource() -{ -} - -itk::DataObject::Pointer mitk::MeshSource::MakeOutput ( DataObjectPointerArraySizeType /*idx*/ ) -{ - return OutputType::New().GetPointer(); -} - - -itk::DataObject::Pointer mitk::MeshSource::MakeOutput( const DataObjectIdentifierType & name ) -{ - itkDebugMacro("MakeOutput(" << name << ")"); - if( this->IsIndexedOutputName(name) ) - { - return this->MakeOutput( this->MakeIndexFromOutputName(name) ); - } - return static_cast(OutputType::New().GetPointer()); -} - -mitk::MeshSource::OutputType* mitk::MeshSource::GetOutput(const itk::ProcessObject::DataObjectIdentifierType &key) -{ - return static_cast(Superclass::GetOutput(key)); -} - -const mitk::MeshSource::OutputType* mitk::MeshSource::GetOutput(const itk::ProcessObject::DataObjectIdentifierType &key) const -{ - return static_cast(Superclass::GetOutput(key)); -} - -mitk::MeshSource::OutputType* mitk::MeshSource::GetOutput(itk::ProcessObject::DataObjectPointerArraySizeType idx) -{ - return static_cast(Superclass::GetOutput(idx)); -} - -const mitk::MeshSource::OutputType* mitk::MeshSource::GetOutput(itk::ProcessObject::DataObjectPointerArraySizeType idx) const -{ - return static_cast(Superclass::GetOutput(idx)); -} diff --git a/Modules/Ext/Algorithms/mitkMeshSource.h b/Modules/Ext/Algorithms/mitkMeshSource.h deleted file mode 100644 index 76b7fd474c..0000000000 --- a/Modules/Ext/Algorithms/mitkMeshSource.h +++ /dev/null @@ -1,79 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef _MITKMESHSOURCE_H -#define _MITKMESHSOURCE_H - -#include "itkProcessObject.h" -#include "MitkExtExports.h" -#include "mitkMesh.h" - -namespace mitk -{ -/** - * @brief Superclass of all classes generating point sets (instances of class - * mitk::Mesh) as output. - * - * In itk and vtk the generated result of a ProcessObject is only guaranteed - * to be up-to-date, when Update() of the ProcessObject or the generated - * DataObject is called immediately before access of the data stored in the - * DataObject. - * @ingroup Process - */ -class MitkExt_EXPORT MeshSource : public itk::ProcessObject -{ -public: - mitkClassMacro( MeshSource, itk::ProcessObject ); - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - typedef mitk::Mesh OutputType; - - typedef OutputType::Pointer OutputTypePointer; - - /** - * Allocates a new output object and returns it. Currently the - * index idx is not evaluated. - * @param idx the index of the output for which an object should be created - * @returns the new object - */ - virtual itk::DataObject::Pointer MakeOutput ( DataObjectPointerArraySizeType idx ); - - /** - * This is a default implementation to make sure we have something. - * Once all the subclasses of ProcessObject provide an appopriate - * MakeOutput(), then ProcessObject::MakeOutput() can be made pure - * virtual. - */ - virtual itk::DataObject::Pointer MakeOutput(const DataObjectIdentifierType &name); - - OutputType* GetOutput(const DataObjectIdentifierType & key); - const OutputType* GetOutput(const DataObjectIdentifierType & key) const; - OutputType* GetOutput(DataObjectPointerArraySizeType idx); - const OutputType* GetOutput(DataObjectPointerArraySizeType idx) const; - -protected: - - MeshSource(); - - virtual ~MeshSource(); - -}; - -} -#endif // #define _MITKMESHSOURCE_H diff --git a/Modules/Ext/Algorithms/mitkPlaneCutFilter.cpp b/Modules/Ext/Algorithms/mitkPlaneCutFilter.cpp deleted file mode 100644 index 2efbca082f..0000000000 --- a/Modules/Ext/Algorithms/mitkPlaneCutFilter.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkPlaneCutFilter.h" -#include "mitkImageReadAccessor.h" -#include -#include - -#define roundf(x) ((x - floor(x)) > 0.5f ? ceil(x) : floor(x)) - -void mitk::PlaneCutFilter::GenerateData() -{ - if (!this->m_Plane) - { - return; - } - - InputImageType *input = const_cast(this->GetInput()); - - if (!input) - { - return; - } - - //Allocate output. - OutputImageType *output = this->GetOutput(); - - mitk::ImageReadAccessor inputAcc(input); - output->Initialize(input); - output->SetImportVolume(const_cast(inputAcc.GetData())); - - //Do the intersection. - AccessByItk_2(output, _computeIntersection, this->m_Plane, input->GetGeometry()); -} - -mitk::PlaneCutFilter::PlaneCutFilter() - : m_BackgroundLevel(0.0f), m_Plane(0), m_FillMode(FILL) -{ -} - -mitk::PlaneCutFilter::~PlaneCutFilter() -{ -} - -template -void mitk::PlaneCutFilter::_computeIntersection(itk::Image *image, const PlaneGeometry *plane, const BaseGeometry *geometry) -{ - typedef itk::Image ImageType; - - const typename ImageType::RegionType &image_region = image->GetLargestPossibleRegion(); - const typename ImageType::SizeValueType - max_x = image_region.GetSize(0ul), - max_y = image_region.GetSize(1ul), - max_z = image_region.GetSize(2ul), - img_size = max_x * max_y; - TPixel *data = image->GetBufferPointer(); - Point3D p1, p2; - - //TODO: Better solution required! - TPixel casted_background_level = static_cast(this->m_BackgroundLevel); - - p1[0] = 0; - p2[0] = max_x - 1ul; - - if (FILL == this->m_FillMode) - { - for (unsigned long z = 0ul; z < max_z; ++z) - { - p1[2] = z; - p2[2] = z; - - for (unsigned long y = 0ul; y < max_y; ++y) - { - p1[1] = y; - p2[1] = y; - - Point3D p1_t, p2_t; - - geometry->IndexToWorld(p1, p1_t); - geometry->IndexToWorld(p2, p2_t); - - if (plane->IsAbove(p1_t)) - { - if (plane->IsAbove(p2_t)) - { - if (0.0f == this->m_BackgroundLevel) - { - memset(&data[(y * max_x) + (z * img_size)], 0, max_x * sizeof(TPixel)); - } - else - { - TPixel *subdata = &data[(y * max_x) + (z * img_size)]; - - for (unsigned long x = 0; x < max_x; ++x) - { - subdata[x] = casted_background_level; - } - } - } - else - { - Point3D intersection; - Line3D line; - - line.SetPoints(p1_t, p2_t); - plane->IntersectionPoint(line, intersection); - geometry->WorldToIndex(intersection, intersection); - - if (0.0f == this->m_BackgroundLevel) - { - memset(&data[(y * max_x) + (z * img_size)], 0, (static_cast(roundf(intersection[0])) + 1u) * sizeof(TPixel)); - } - else - { - - TPixel *subdata = &data[(y * max_x) + (z * img_size)]; - const unsigned long x_size = static_cast(roundf(intersection[0])) + 1u; - - for (unsigned long x = 0; x < x_size; ++x) - { - subdata[x] = casted_background_level; - } - } - } - } - else if (plane->IsAbove(p2_t)) - { - Point3D intersection; - Line3D line; - - line.SetPoints(p1_t, p2_t); - plane->IntersectionPoint(line, intersection); - geometry->WorldToIndex(intersection, intersection); - - if (0.0f == this->m_BackgroundLevel) - { - unsigned long x = static_cast(roundf(intersection[0])); - - memset(&data[x + (y * max_x) + (z * img_size)], 0, (max_x - x) * sizeof(TPixel)); - } - else - { - unsigned long x = static_cast(roundf(intersection[0])); - TPixel *subdata = &data[x + (y * max_x) + (z * img_size)]; - const unsigned long x_size = max_x - x; - - for (x = 0; x < x_size; ++x) - { - subdata[x] = casted_background_level; - } - } - } - } - } - } - else - { - for (unsigned long z = 0ul; z < max_z; ++z) - { - p1[2] = z; - p2[2] = z; - - for (unsigned long y = 0ul; y < max_y; ++y) - { - p1[1] = y; - p2[1] = y; - - Point3D p1_t, p2_t; - - geometry->IndexToWorld(p1, p1_t); - geometry->IndexToWorld(p2, p2_t); - - if (!plane->IsAbove(p1_t)) - { - if (!plane->IsAbove(p2_t)) - { - if (0.0f == this->m_BackgroundLevel) - { - memset(&data[(y * max_x) + (z * img_size)], 0, max_x * sizeof(TPixel)); - } - else - { - TPixel *subdata = &data[(y * max_x) + (z * img_size)]; - - for (unsigned long x = 0; x < max_x; ++x) - { - subdata[x] = casted_background_level; - } - } - } - else - { - Point3D intersection; - Line3D line; - - line.SetPoints(p1_t, p2_t); - plane->IntersectionPoint(line, intersection); - geometry->WorldToIndex(intersection, intersection); - - if (0.0f == this->m_BackgroundLevel) - { - memset(&data[(y * max_x) + (z * img_size)], 0, (static_cast(roundf(intersection[0])) + 1u) * sizeof(TPixel)); - } - else - { - - TPixel *subdata = &data[(y * max_x) + (z * img_size)]; - const unsigned long x_size = static_cast(roundf(intersection[0])) + 1u; - - for (unsigned long x = 0; x < x_size; ++x) - { - subdata[x] = casted_background_level; - } - } - } - } - else if (!plane->IsAbove(p2_t)) - { - Point3D intersection; - Line3D line; - - line.SetPoints(p1_t, p2_t); - plane->IntersectionPoint(line, intersection); - geometry->WorldToIndex(intersection, intersection); - - if (0.0f == this->m_BackgroundLevel) - { - unsigned long x = static_cast(roundf(intersection[0])); - - memset(&data[x + (y * max_x) + (z * img_size)], 0, (max_x - x) * sizeof(TPixel)); - } - else - { - unsigned long x = static_cast(roundf(intersection[0])); - TPixel *subdata = &data[x + (y * max_x) + (z * img_size)]; - const unsigned long x_size = max_x - x; - - for (x = 0; x < x_size; ++x) - { - subdata[x] = casted_background_level; - } - } - } - } - } - } -} diff --git a/Modules/Ext/Algorithms/mitkPlaneCutFilter.h b/Modules/Ext/Algorithms/mitkPlaneCutFilter.h deleted file mode 100644 index 345b8e75a4..0000000000 --- a/Modules/Ext/Algorithms/mitkPlaneCutFilter.h +++ /dev/null @@ -1,77 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef PLANECUTFILTER_H_HEADER_INCLUDED_C1F48A22 -#define PLANECUTFILTER_H_HEADER_INCLUDED_C1F48A22 - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkImageToImageFilter.h" -#include "mitkPlaneGeometry.h" - -namespace itk -{ - template class ITK_EXPORT Image; -} - -namespace mitk { - -/** - \brief Filter to cut an image with a plane. - - Everything in the direction of the normal - of the planes (if fill mode is set to "FILL") will be set to a specified value. - */ -class MitkExt_EXPORT PlaneCutFilter : public ImageToImageFilter -{ -public: - mitkClassMacro(PlaneCutFilter, ImageToImageFilter); - - /** Method for creation through the object factory. */ - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - typedef enum {FILL, FILL_INVERSE} FillMode; - - //##Documentation - //## @brief Set background grey level - itkSetMacro(BackgroundLevel, float); - itkGetMacro(BackgroundLevel, float); - - itkSetEnumMacro(FillMode, FillMode); - itkGetEnumMacro(FillMode, FillMode); - - itkSetObjectMacro(Plane, const PlaneGeometry); - itkGetObjectMacro(Plane, const PlaneGeometry); -protected: - float m_BackgroundLevel; - PlaneGeometry::ConstPointer m_Plane; - FillMode m_FillMode; - - PlaneCutFilter(); - ~PlaneCutFilter(); - virtual void GenerateData(); - - template - void _computeIntersection(itk::Image *itkImage, const PlaneGeometry *plane, const BaseGeometry *geometry); -}; - -} // namespace mitk - -#endif /* PLANECUTFILTER_H_HEADER_INCLUDED_C1F48A22 */ - - diff --git a/Modules/Ext/Algorithms/mitkPlaneFit.cpp b/Modules/Ext/Algorithms/mitkPlaneFit.cpp deleted file mode 100644 index cba794f3e0..0000000000 --- a/Modules/Ext/Algorithms/mitkPlaneFit.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkPlaneFit.h" - -#include "mitkPlaneGeometry.h" -#include "mitkGeometryData.h" -#include - -#include -#include - - -mitk::PlaneFit::PlaneFit() -: m_PointSet( NULL ) -{ - m_TimeGeometry = mitk::ProportionalTimeGeometry::New(); -} - -mitk::PlaneFit::~PlaneFit() -{ -} - - -void mitk::PlaneFit::GenerateOutputInformation() -{ - mitk::PointSet::ConstPointer input = this->GetInput(); - mitk::GeometryData::Pointer output = this->GetOutput(); - - itkDebugMacro(<<"GenerateOutputInformation()"); - - if (input.IsNull()) return; - - if ( m_PointSet == NULL ) - { - return; - } - - bool update = false; - if ( output->GetGeometry() == NULL || output->GetTimeGeometry() == NULL ) - update = true; - if ( ( ! update ) && ( output->GetTimeGeometry()->CountTimeSteps() != input->GetTimeGeometry()->CountTimeSteps() ) ) - update = true; - if ( update ) - { - mitk::PlaneGeometry::Pointer planeGeometry = mitk::PlaneGeometry::New(); - - ProportionalTimeGeometry::Pointer timeGeometry = dynamic_cast(m_TimeGeometry.GetPointer()); - timeGeometry->Initialize(planeGeometry, m_PointSet->GetPointSetSeriesSize()); - //m_TimeGeometry->InitializeEvenlyTimed( - // planeGeometry, m_PointSet->GetPointSetSeriesSize() ); - - TimeStepType timeStep; - for ( timeStep = 0; - (timeStep < m_PointSet->GetPointSetSeriesSize()) - && (timeStep < m_Planes.size()); - ++timeStep ) - { - timeGeometry->SetTimeStepGeometry( m_Planes[timeStep], timeStep ); - } - - output->SetTimeGeometry( m_TimeGeometry ); - } -} - -void mitk::PlaneFit::GenerateData() -{ - unsigned int t; - for ( t = 0; t < m_PointSet->GetPointSetSeriesSize(); ++t ) - { - // check number of data points - less then 3points isn't enough - if ( m_PointSet->GetSize( t ) >= 3 ) - { - this->CalculateCentroid( t ); - - this->ProcessPointSet( t ); - - this->InitializePlane( t ); - } - } -} - -void mitk::PlaneFit::SetInput( const mitk::PointSet* pointSet ) -{ - // Process object is not const-correct so the const_cast is required here - this->ProcessObject::SetNthInput(0, - const_cast< mitk::PointSet * >( pointSet ) ); - - m_PointSet = pointSet; - unsigned int pointSetSize = pointSet->GetPointSetSeriesSize(); - - m_Planes.resize( pointSetSize ); - m_Centroids.resize( pointSetSize ); - m_PlaneVectors.resize( pointSetSize ); - - unsigned int t; - for ( t = 0; t < pointSetSize; ++t ) - { - m_Planes[t] = mitk::PlaneGeometry::New(); - } -} - -const mitk::PointSet* mitk::PlaneFit::GetInput() -{ - if (this->GetNumberOfInputs() < 1) - { - return 0; - } - - return static_cast (this->ProcessObject::GetInput(0) ); -} - - -void mitk::PlaneFit::CalculateCentroid( int t ) -{ - if ( m_PointSet == NULL ) return; - - int ps_total = m_PointSet->GetSize( t ); - - m_Centroids[t][0] = m_Centroids[t][1] = m_Centroids[t][2] = 0.0; - - for (int i=0; iGetPoint(i,t); - m_Centroids[t][0] += p3d[0]; - m_Centroids[t][1] += p3d[1]; - m_Centroids[t][2] += p3d[2]; - } - - // calculation of centroid - m_Centroids[t][0] /= ps_total; - m_Centroids[t][1] /= ps_total; - m_Centroids[t][2] /= ps_total; -} - - -void mitk::PlaneFit::ProcessPointSet( int t ) -{ - if (m_PointSet == NULL ) return; - - // int matrix with POINTS x (X,Y,Z) - vnl_matrix dataM( m_PointSet->GetSize( t ), 3); - - int ps_total = m_PointSet->GetSize( t ); - for (int i=0; iGetPoint(i,t); - dataM[i][0] = p3d[0] - m_Centroids[t][0]; - dataM[i][1] = p3d[1] - m_Centroids[t][1]; - dataM[i][2] = p3d[2] - m_Centroids[t][2]; - } - // process the SVD (singular value decomposition) from ITK - // the vector will be orderd descending - vnl_svd svd(dataM, 0.0); - - // calculate the SVD of A - vnl_vector v = svd.nullvector(); - - - // Avoid erratic normal sign switching when the plane changes minimally - // by negating the vector for negative x values. - if ( v[0] < 0 ) - { - v = -v; - } - - m_PlaneVectors[t][0] = v[0]; - m_PlaneVectors[t][1] = v[1]; - m_PlaneVectors[t][2] = v[2]; - -} - -mitk::PlaneGeometry::Pointer mitk::PlaneFit::GetPlaneGeometry( int t ) -{ - return m_Planes[t]; -} - -const mitk::Vector3D &mitk::PlaneFit::GetPlaneNormal( int t ) const -{ - return m_PlaneVectors[t]; -} - -const mitk::Point3D &mitk::PlaneFit::GetCentroid( int t ) const -{ - return m_Centroids[t]; -} - -void mitk::PlaneFit::InitializePlane( int t ) -{ - m_Planes[t]->InitializePlane( m_Centroids[t], m_PlaneVectors[t] ); -} - diff --git a/Modules/Ext/Algorithms/mitkPlaneFit.h b/Modules/Ext/Algorithms/mitkPlaneFit.h deleted file mode 100644 index 9930a3ce35..0000000000 --- a/Modules/Ext/Algorithms/mitkPlaneFit.h +++ /dev/null @@ -1,148 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#if !defined(MITK_PLANEFIT_H__INCLUDED_) -#define MITK_PLANEFIT_H__INCLUDED_ - -#include "mitkPointSet.h" -#include "MitkExtExports.h" -#include "mitkTimeGeometry.h" -#include "mitkPlaneGeometry.h" -#include "mitkGeometryDataSource.h" - -namespace mitk { - - //! - // kind regards to dr. math! - // function [x0, a, d, normd] = lsplane(X) - // --------------------------------------------------------------------- - // LSPLANE.M Least-squares plane (orthogonal distance - // regression). - // - // Version 1.0 - // Last amended I M Smith 27 May 2002. - // Created I M Smith 08 Mar 2002 - // --------------------------------------------------------------------- - // Input - // X Array [x y z] where x = vector of x-coordinates, - // y = vector of y-coordinates and z = vector of - // z-coordinates. - // Dimension: m x 3. - // - // Output - // x0 Centroid of the data = point on the best-fit plane. - // Dimension: 3 x 1. - // - // a Direction cosines of the normal to the best-fit - // plane. - // Dimension: 3 x 1. - // - // - // - // [x0, a <, d, normd >] = lsplane(X) - // --------------------------------------------------------------------- - - class MitkExt_EXPORT PlaneFit : public GeometryDataSource - { - public: - - mitkClassMacro( PlaneFit, GeometryDataSource); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - typedef mitk::PointSet::PointDataType PointDataType; - typedef mitk::PointSet::PointDataIterator PointDataIterator; - - virtual void GenerateOutputInformation(); - - virtual void GenerateData(); - - /*!Getter for point set. - * - */ - const mitk::PointSet *GetInput(); - - /*! filter initialisation. - * - */ - virtual void SetInput( const mitk::PointSet *ps ); - - /*! returns the center of gravity of the point set. - * - */ - virtual const mitk::Point3D &GetCentroid( int t = 0 ) const; - - /*! returns the plane geometry which represents the point set. - * - */ - virtual mitk::PlaneGeometry::Pointer GetPlaneGeometry( int t = 0 ); - - /*! returns the normal of the plane which represents the point set. - * - */ - virtual const mitk::Vector3D &GetPlaneNormal( int t = 0 ) const; - - protected: - PlaneFit(); - virtual ~PlaneFit(); - - /*! Calculates the centroid of the point set. - * the center of gravity is calculated through the mean value of the whole point set - */ - void CalculateCentroid( int t = 0 ); - - /*! working with an SVD algorithm form matrix dataM. - * ITK suplies the vnl_svd to solve an plan fit eigentvector problem - * points are processed in the SVD matrix. The normal vector is the - * singular vector of dataM corresponding to its smalest singular value. - * The mehtod uses VNL library from ITK and at least the mehtod nullvector() - * to extract the normalvector. - */ - void ProcessPointSet( int t = 0 ); - - /*! Initialize Plane and configuration. - * - */ - void InitializePlane( int t = 0 ); - - - private: - - /*!keeps a copy of the pointset.*/ - const mitk::PointSet* m_PointSet; - - /* output object - a time sliced geometry.*/ - mitk::TimeGeometry::Pointer m_TimeGeometry; - - std::vector< mitk::PlaneGeometry::Pointer > m_Planes; - - /*! the calculatet center point of all points in the point set.*/ - std::vector< mitk::Point3D > m_Centroids; - - /* the normal vector to descrie a plane gemoetry.*/ - std::vector< mitk::Vector3D > m_PlaneVectors; - }; -}//namespace mitk -#endif //MITK_PLANFIT_INCLUDE_ - - diff --git a/Modules/Ext/Algorithms/mitkPlanesPerpendicularToLinesFilter.cpp b/Modules/Ext/Algorithms/mitkPlanesPerpendicularToLinesFilter.cpp deleted file mode 100644 index 2f95d42e41..0000000000 --- a/Modules/Ext/Algorithms/mitkPlanesPerpendicularToLinesFilter.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkPlanesPerpendicularToLinesFilter.h" - -#include -#include -#include - -mitk::PlanesPerpendicularToLinesFilter::PlanesPerpendicularToLinesFilter() - : m_Plane(NULL), m_UseAllPoints(false), m_CreatedGeometries(NULL), normal(3), targetRight(3) -{ - m_CreatedGeometries = mitk::SlicedGeometry3D::New(); -} - -mitk::PlanesPerpendicularToLinesFilter::~PlanesPerpendicularToLinesFilter() -{ -} - -void mitk::PlanesPerpendicularToLinesFilter::GenerateOutputInformation() -{ - mitk::Mesh::ConstPointer input = this->GetInput(); - mitk::GeometryData::Pointer output = this->GetOutput(); - - itkDebugMacro(<<"GenerateOutputInformation()"); - - if(input.IsNull()) return; - - output->SetGeometry(m_CreatedGeometries); -} - -void mitk::PlanesPerpendicularToLinesFilter::CreatePlane(const mitk::Point3D& curr) -{ - int j; - for(j=0;j<3;++j) - normal[j] = last[j]-curr[j]; //@todo globally define normal direction of display xxx - normal.normalize(); - - down = vnl_cross_3d(normal, targetRight); - down.normalize(); - right = vnl_cross_3d(down, normal); - right.normalize(); - - itk2vtk(last.GetVnlVector()-right*halfWidthInMM-down*halfHeightInMM, origin); - right *= targetSpacing[0]; - down *= targetSpacing[1]; - normal *= targetSpacing[2]; - - mitk::Matrix3D matrix; - matrix.GetVnlMatrix().set_column(0, right); - matrix.GetVnlMatrix().set_column(1, down); - matrix.GetVnlMatrix().set_column(2, normal); - - PlaneGeometry::Pointer plane = PlaneGeometry::New(); - plane->GetIndexToWorldTransform()->SetMatrix(matrix); - plane->SetOrigin(origin); - plane->SetBounds(bounds); - - planes.push_back(plane); - - last = curr; -} - -void mitk::PlanesPerpendicularToLinesFilter::GenerateData() -{ - mitk::Mesh::ConstPointer input = this->GetInput(); - mitk::GeometryData::Pointer output = this->GetOutput(); - - if(m_Plane.IsNotNull()) - { - targetRight = m_Plane->GetMatrixColumn(0); - targetSpacing = m_Plane->GetSpacing(); - bounds = m_Plane->GetBoundingBox()->GetBounds(); - halfWidthInMM = m_Plane->GetExtentInMM(0)*0.5; - halfHeightInMM = m_Plane->GetExtentInMM(1)*0.5; - } - else - { - FillVector3D(targetRight, 1.0, 0.0, 0.0); - targetSpacing.Fill(1.0); - halfWidthInMM=halfHeightInMM=100.0; - ScalarType stdBounds[6] = {0.0, 2.0*halfWidthInMM, 0.0, 2.0*halfHeightInMM, 0.0, 0.0}; - bounds = stdBounds; - } - - if(m_UseAllPoints==false) - { - int i, size; - //iterate through all cells and build planes - Mesh::ConstCellIterator cellIt, cellEnd; - cellEnd = input->GetMesh()->GetCells()->End(); - for( cellIt = input->GetMesh()->GetCells()->Begin(); cellIt != cellEnd; ++cellIt ) - { - Mesh::CellType& cell = *cellIt->Value(); - - Mesh::PointIdIterator ptIt, ptEnd; - ptEnd = cell.PointIdsEnd(); - - size=cell.GetNumberOfPoints(); - if(size<=1) - continue; - - ptIt = cell.PointIdsBegin(); - last = input->GetPoint(*ptIt); - ++ptIt; - for(i=1;iGetPoint(*ptIt)); - } - } - } - else //m_UseAllPoints==true - { - //iterate through all points and build planes - mitk::PointSet::PointsConstIterator it, pend = input->GetPointSet()->GetPoints()->End(); - it=input->GetPointSet()->GetPoints()->Begin(); - last = it.Value(); - ++it; - for(;it!=pend;++it) - { - CreatePlane(it.Value()); - } - } - - if(planes.size()>0) - { - //initialize sliced-geometry for the number of created planes - m_CreatedGeometries->InitializeSlicedGeometry(planes.size()+1); - - //set last plane at last point with same normal as the one before the last - PlaneGeometry::Pointer plane = static_cast((*planes.rbegin())->Clone().GetPointer()); - itk2vtk(last.GetVnlVector()-right*halfWidthInMM-down*halfHeightInMM, origin); - plane->SetOrigin(origin); - m_CreatedGeometries->SetPlaneGeometry(plane, planes.size()); - - //add all planes to sliced-geometry - int s; - for(s=0; planes.empty()==false; planes.pop_front(), ++s) - { - m_CreatedGeometries->SetPlaneGeometry(planes.front(), s); - } - - m_CreatedGeometries->SetEvenlySpaced(false); - - if(m_FrameGeometry.IsNotNull()) - { - m_CreatedGeometries->SetIndexToWorldTransform(m_FrameGeometry->GetIndexToWorldTransform()); - m_CreatedGeometries->SetBounds(m_FrameGeometry->GetBounds()); - m_CreatedGeometries->SetReferenceGeometry(m_FrameGeometry); - } - } - - output->SetGeometry(m_CreatedGeometries); -} - -void mitk::PlanesPerpendicularToLinesFilter::SetPlane(const mitk::PlaneGeometry* aPlane) -{ - if(aPlane!=NULL) - { - m_Plane = static_cast(aPlane->Clone().GetPointer()); - } - else - { - if(m_Plane.IsNull()) - return; - m_Plane=NULL; - } - Modified(); -} - -const mitk::Mesh *mitk::PlanesPerpendicularToLinesFilter::GetInput(void) -{ - if (this->GetNumberOfInputs() < 1) - { - return 0; - } - - return static_cast - (this->ProcessObject::GetInput(0) ); -} - -void mitk::PlanesPerpendicularToLinesFilter::SetInput(const mitk::Mesh *input) -{ - // Process object is not const-correct so the const_cast is required here - this->ProcessObject::SetNthInput(0, - const_cast< mitk::Mesh * >( input ) ); -} - -void mitk::PlanesPerpendicularToLinesFilter::SetFrameGeometry(const mitk::BaseGeometry* frameGeometry) -{ - if((frameGeometry != NULL) && (frameGeometry->IsValid())) - { - m_FrameGeometry = static_cast(frameGeometry->Clone().GetPointer()); - } - else - { - m_FrameGeometry = NULL; - } -} diff --git a/Modules/Ext/Algorithms/mitkPlanesPerpendicularToLinesFilter.h b/Modules/Ext/Algorithms/mitkPlanesPerpendicularToLinesFilter.h deleted file mode 100644 index f213ea24e1..0000000000 --- a/Modules/Ext/Algorithms/mitkPlanesPerpendicularToLinesFilter.h +++ /dev/null @@ -1,145 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef MITKPLANESPERPENDICULARTOLINES_H_HEADER_INCLUDED_C10B22CD -#define MITKPLANESPERPENDICULARTOLINES_H_HEADER_INCLUDED_C10B22CD - -#include "mitkGeometryDataSource.h" -#include "MitkExtExports.h" -#include "mitkMesh.h" -#include "mitkGeometryData.h" -#include "mitkPlaneGeometry.h" -#include "mitkSlicedGeometry3D.h" - -namespace mitk { - -//##Documentation -//## @brief Create Planes perpendicular to lines contained in a Mesh. The planes data is generated as one SlicedGeometry3D data. -//## To create the planes as input a -//## mitk::mesh (for example a pointSet) and as geometry hint a geometry (for example from the original image) must be given. -//## -//## mitk::Mesh::Pointer mesh = mitk::Mesh::New(); -//## mesh->SetMesh(pointSet->GetPointSet()); -//## mitk::Image* currentImage = dynamic_cast (myDataStorage->GetNamedNode(IMAGE)->GetData()); -//## const mitk::Geometry3D* imagegeometry = currentImage->GetUpdatedGeometry(); -//## mitk::PlanesPerpendicularToLinesFilter::Pointer perpendicularPlanes = mitk::PlanesPerpendicularToLinesFilter::New(); -//## perpendicularPlanes->SetInput(mesh); -//## perpendicularPlanes->SetUseAllPoints(true); -//## perpendicularPlanes->SetFrameGeometry(imagegeometry); -//## perpendicularPlanes->Update(); -//## -//## To get one single plane out of these use SlicedGeometry3D->GetPlaneGeometry(int slicenumber). - - - -//## @ingroup Process -class MitkExt_EXPORT PlanesPerpendicularToLinesFilter : public GeometryDataSource -{ -public: - mitkClassMacro(PlanesPerpendicularToLinesFilter, GeometryDataSource); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - virtual void GenerateOutputInformation(); - - virtual void GenerateData(); - - const mitk::Mesh *GetInput(void); - - //## @brief Set the input mesh that is used to create the planes. - virtual void SetInput(const mitk::Mesh *image); - - //##Documentation - //## @brief Set plane to be used as an example of the planes to move - //## along the lines in the input mesh. - //## - //## The size and spacing are copied from the plane. The in-plane - //## orientation (right-vector) of the created planes are set as - //## parallel as possible to the orientation (right-vector) of the - //## the plane set using this method. - //## @note The PlaneGeometry is cloned, @em not linked/referenced. - virtual void SetPlane(const mitk::PlaneGeometry* aPlane); - - //##Documentation - //## @brief Set if all points in the mesh should be interpreted as - //## one long line. - //## - //## Cells are not used in this mode, but all points in the order - //## of their indices form the line. - //## Default is @a false. - itkGetConstMacro(UseAllPoints, bool); - - //##Documentation - //## @brief Set if all points of the mesh shall be used (true) or the cells (false) - //## Default is @a false. - itkSetMacro(UseAllPoints, bool); - itkBooleanMacro(UseAllPoints); - - //##Documentation - //## @brief Set an explicit frame of the created sliced geometry - //## - //## Set an explicit framegeometry for the created sliced geometry. This framegeometry is - //## used as geometry for all created planes. - //## Uses the IndexToWorldTransform and bounding box of the - //## provided geometry. - //## \sa CalculateFrameGeometry - virtual void SetFrameGeometry(const mitk::BaseGeometry* frameGeometry); - -protected: - PlanesPerpendicularToLinesFilter(); - - virtual ~PlanesPerpendicularToLinesFilter(); - - //## @brief Creates the plane at point curr - //## - //## Creates the plane at point curr. To create this plane, the last point must - //## must be renowned. - //## \sa SetPlane - void CreatePlane(const Point3D& curr); - - //## @brief Plane to be used as an example of the planes to move - //## along the lines in the input mesh. - //## - //## The size and spacing are copied from the m_Plane. The in-plane - //## orientation (right-vector) of the created planes are set as - //## parallel as possible to the orientation (right-vector) of m_Plane. - //## \sa SetPlane - mitk::PlaneGeometry::Pointer m_Plane; - - bool m_UseAllPoints; - - //##Documentation - //## @brief SlicedGeometry3D containing the created planes - //## - SlicedGeometry3D::Pointer m_CreatedGeometries; - - mitk::BaseGeometry::Pointer m_FrameGeometry; - -private: - std::deque planes; - Point3D last; - VnlVector normal; - VnlVector right, down; - VnlVector targetRight; - Vector3D targetSpacing; - ScalarType halfWidthInMM, halfHeightInMM; - mitk::BaseGeometry::BoundsArrayType bounds; - Point3D origin; -}; - -} // namespace mitk - -#endif /* MITKPLANESPERPENDICULARTOLINES_H_HEADER_INCLUDED_C10B22CD */ diff --git a/Modules/Ext/Algorithms/mitkPointSetIndexToWorldTransformFilter.cpp b/Modules/Ext/Algorithms/mitkPointSetIndexToWorldTransformFilter.cpp deleted file mode 100644 index 53625fea75..0000000000 --- a/Modules/Ext/Algorithms/mitkPointSetIndexToWorldTransformFilter.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkPointSetIndexToWorldTransformFilter.h" - - -mitk::PointSetIndexToWorldTransformFilter::PointSetIndexToWorldTransformFilter() -{ - -} - -mitk::PointSetIndexToWorldTransformFilter::~PointSetIndexToWorldTransformFilter() -{ - -} - -void mitk::PointSetIndexToWorldTransformFilter::GenerateData() -{ - mitk::PointSet::ConstPointer input = this->GetInput(); - mitk::PointSet::Pointer output = this->GetOutput(); - - typedef std::vector PointContainer; - PointContainer points; - int pointNo = 0; - - while(pointNo!= input->GetSize()) - { - mitk::Point3D current = input->GetPoint(pointNo); - points.push_back(current); - pointNo++; - } - output->GetGeometry()->SetIdentity(); - PointContainer::iterator pointsIter = points.begin(); - - pointNo = 0; - while(pointsIter != points.end()) - { - output->SetPoint(pointNo,(*pointsIter)); - pointNo++; - pointsIter++; - } - -} diff --git a/Modules/Ext/Algorithms/mitkPointSetIndexToWorldTransformFilter.h b/Modules/Ext/Algorithms/mitkPointSetIndexToWorldTransformFilter.h deleted file mode 100644 index acfb4cae60..0000000000 --- a/Modules/Ext/Algorithms/mitkPointSetIndexToWorldTransformFilter.h +++ /dev/null @@ -1,64 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef _MITKPOINTSETINDEXTOWORLDTRANSFORMFILTER_H__ -#define _MITKPOINTSETINDEXTOWORLDTRANSFORMFILTER_H__ - -#include "mitkPointSetToPointSetFilter.h" -#include "mitkPointSet.h" - -#include "MitkExtExports.h" - -namespace mitk -{ - //##Documentation - //## @brief Transforms a point set object from index to world coordinates. - //## Transposes the points coordinates with the object's mitk::Geometry3D to display - //## correct scene coordinates. - //## - //## @ingroup Algorithms -class MitkExt_EXPORT PointSetIndexToWorldTransformFilter : public PointSetToPointSetFilter -{ -public: - /** - * Standard mitk class macro - */ - mitkClassMacro ( PointSetIndexToWorldTransformFilter, PointSetToPointSetFilter ); - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - -protected: - - /** - * Protected constructor. Use ::New instead() - */ - PointSetIndexToWorldTransformFilter(); - - /** - * Protected destructor. Instances are destroyed when reference count is zero - */ - virtual ~PointSetIndexToWorldTransformFilter(); - /** - * method executed when calling Update(); - */ - virtual void GenerateData(); - -}; - -} - -#endif diff --git a/Modules/Ext/Algorithms/mitkPointSetToCurvedGeometryFilter.cpp b/Modules/Ext/Algorithms/mitkPointSetToCurvedGeometryFilter.cpp deleted file mode 100644 index 77c36f225c..0000000000 --- a/Modules/Ext/Algorithms/mitkPointSetToCurvedGeometryFilter.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkPointSetToCurvedGeometryFilter.h" -#include "mitkThinPlateSplineCurvedGeometry.h" -#include "mitkPlaneGeometry.h" -#include "mitkImage.h" -#include "mitkDataNode.h" -#include "mitkGeometryData.h" -#include "mitkPlaneGeometryData.h" -#include "mitkProperties.h" -#include "itkMesh.h" -#include "itkPointSet.h" - -mitk::PointSetToCurvedGeometryFilter::PointSetToCurvedGeometryFilter() -{ - m_ProjectionMode = YZPlane; - m_PCAPlaneCalculator = mitk::PlaneFit::New(); - m_ImageToBeMapped = NULL; - m_Sigma = 1000; - mitk::PlaneGeometryData::Pointer output = static_cast ( this->MakeOutput ( 0 ).GetPointer() ); - output->Initialize(); - Superclass::SetNumberOfRequiredOutputs ( 1 ); - Superclass::SetNthOutput ( 0, output.GetPointer() ); -} - - - -mitk::PointSetToCurvedGeometryFilter::~PointSetToCurvedGeometryFilter() -{} - -void mitk::PointSetToCurvedGeometryFilter::GenerateOutputInformation() -{ - mitk::PointSet::ConstPointer input = this->GetInput(); - mitk::PlaneGeometryData::Pointer output = dynamic_cast ( this->GetOutput() ); - - if ( input.IsNull() ) - itkGenericExceptionMacro ( "Input point set is NULL!" ); - - if ( input->GetTimeGeometry()->CountTimeSteps() != 1 ) - itkWarningMacro ( "More than one time step is not yet supported!" ); - - if ( output.IsNull() ) - itkGenericExceptionMacro ( "Output is NULL!" ); - - if ( m_ImageToBeMapped.IsNull() ) - itkGenericExceptionMacro ( "Image to be mapped is NULL!" ); - - bool update = false; - if ( output->GetGeometry() == NULL || output->GetPlaneGeometry() == NULL || output->GetTimeGeometry() == NULL ) - update = true; - if ( ( ! update ) && ( output->GetTimeGeometry()->CountTimeSteps() != input->GetTimeGeometry()->CountTimeSteps() ) ) - update = true; - if ( update ) - { - mitk::ThinPlateSplineCurvedGeometry::Pointer curvedGeometry = mitk::ThinPlateSplineCurvedGeometry::New(); - output->SetGeometry(curvedGeometry); - } -} - -void mitk::PointSetToCurvedGeometryFilter::GenerateData() -{ - mitk::PointSet::ConstPointer input = this->GetInput(); - mitk::GeometryData::Pointer output = this->GetOutput(); - - // - // check preconditions - // - if ( input.IsNull() ) - itkGenericExceptionMacro ( "Input point set is NULL!" ); - if ( output.IsNull() ) - itkGenericExceptionMacro ( "output geometry data is NULL!" ); - if ( output->GetTimeGeometry() == NULL ) - itkGenericExceptionMacro ( "Output time sliced geometry is NULL!" ); - if ( output->GetTimeGeometry()->GetGeometryForTimeStep ( 0 ).IsNull() ) - itkGenericExceptionMacro ( "Output geometry3d is NULL!" ); - mitk::ThinPlateSplineCurvedGeometry::Pointer curvedGeometry = dynamic_cast ( output->GetTimeGeometry()->GetGeometryForTimeStep( 0 ).GetPointer() ); - if ( curvedGeometry.IsNull() ) - itkGenericExceptionMacro ( "Output geometry3d is not an instance of mitk::ThinPlateSPlineCurvedGeometry!" ); - if ( m_ImageToBeMapped.IsNull() ) - itkGenericExceptionMacro ( "Image to be mapped is NULL!" ); - - // - // initialize members if needed - // - if ( m_XYPlane.IsNull() || m_XZPlane.IsNull() || m_YZPlane.IsNull() ) - { - m_ImageToBeMapped->UpdateOutputInformation(); - const mitk::BaseGeometry* imageGeometry = m_ImageToBeMapped->GetUpdatedGeometry(); - imageGeometry = m_ImageToBeMapped->GetUpdatedGeometry(); - m_XYPlane = mitk::PlaneGeometry::New(); - m_XZPlane = mitk::PlaneGeometry::New(); - m_YZPlane = mitk::PlaneGeometry::New(); - m_XYPlane->InitializeStandardPlane ( imageGeometry, mitk::PlaneGeometry::Axial ); - m_YZPlane->InitializeStandardPlane ( imageGeometry, mitk::PlaneGeometry::Sagittal ); - m_XZPlane->InitializeStandardPlane ( imageGeometry, mitk::PlaneGeometry::Frontal ); - } - if ( m_PlaneLandmarkProjector.IsNull() ) - { - m_PlaneLandmarkProjector = mitk::PlaneLandmarkProjector::New(); - m_SphereLandmarkProjector = mitk::SphereLandmarkProjector::New(); - } - - // - // set up geometry according to the current settings - // - if ( m_ProjectionMode == Sphere ) - { - curvedGeometry->SetLandmarkProjector ( m_SphereLandmarkProjector ); - } - else - { - if ( m_ProjectionMode == XYPlane ) - m_PlaneLandmarkProjector->SetProjectionPlane ( m_XYPlane ); - else if ( m_ProjectionMode == XZPlane ) - m_PlaneLandmarkProjector->SetProjectionPlane ( m_XZPlane ); - else if ( m_ProjectionMode == YZPlane ) - m_PlaneLandmarkProjector->SetProjectionPlane ( m_YZPlane ); - else if ( m_ProjectionMode == PCAPlane ) - { - itkExceptionMacro ( "PCAPlane not yet implemented!" ); - m_PCAPlaneCalculator->SetInput ( input ); - m_PCAPlaneCalculator->Update(); - - const PlaneGeometry *planarFigureGeometry = - dynamic_cast< const PlaneGeometry * >( m_PCAPlaneCalculator->GetOutput() ); - const AbstractTransformGeometry *abstrTransfGeometry = - dynamic_cast< const AbstractTransformGeometry * >( m_PCAPlaneCalculator->GetOutput() ); - - if ( !planarFigureGeometry || abstrTransfGeometry ) - { - m_PlaneLandmarkProjector->SetProjectionPlane ( NULL ); - } - else - { - m_PlaneLandmarkProjector->SetProjectionPlane ( planarFigureGeometry ); - } - } - else - itkExceptionMacro ( "Unknown projection mode" ); - - curvedGeometry->SetLandmarkProjector ( m_PlaneLandmarkProjector ); - } - //curvedGeometry->SetReferenceGeometry( m_ImageToBeMapped->GetGeometry() ); - curvedGeometry->SetTargetLandmarks ( input->GetPointSet ( 0 )->GetPoints() ); - curvedGeometry->SetSigma ( m_Sigma ); - curvedGeometry->ComputeGeometry(); - curvedGeometry->SetOversampling ( 1.0 ); - -} - - -void mitk::PointSetToCurvedGeometryFilter::SetDefaultCurvedGeometryProperties ( mitk::DataNode* node ) -{ - if ( node == NULL ) - { - itkGenericOutputMacro ( "Warning: node is NULL!" ); - return; - } - node->SetIntProperty ( "xresolution", 50 ); - node->SetIntProperty ( "yresolution", 50 ); - node->SetProperty ( "name", mitk::StringProperty::New ( "Curved Plane" ) ); - // exclude extent of this plane when calculating DataStorage bounding box - node->SetProperty ( "includeInBoundingBox", mitk::BoolProperty::New ( false ) ); -} diff --git a/Modules/Ext/Algorithms/mitkPointSetToCurvedGeometryFilter.h b/Modules/Ext/Algorithms/mitkPointSetToCurvedGeometryFilter.h deleted file mode 100644 index f91a52d5c7..0000000000 --- a/Modules/Ext/Algorithms/mitkPointSetToCurvedGeometryFilter.h +++ /dev/null @@ -1,114 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef _MITK_POINT_SET_TO_CURVED_GEOMETRY_FILTER_H__ -#define _MITK_POINT_SET_TO_CURVED_GEOMETRY_FILTER_H__ - -#include "mitkPointSetToGeometryDataFilter.h" -#include "MitkExtExports.h" -#include -#include -#include -#include -#include -#include - -namespace mitk -{ - -class MitkExt_EXPORT PointSetToCurvedGeometryFilter : public PointSetToGeometryDataFilter -{ -public: - /** - * Standard mitk class macro - */ - mitkClassMacro ( PointSetToCurvedGeometryFilter, PointSetToGeometryDataFilter ); - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - /** - * Defines the geometry, onto which the input landmarks are - * projected. Currently, Plane and Sphere are supported, whilest plane - * is differentiated into 4 different planes, the xy, xz, and yz plane, - * as well a plane which is calculated by a principal component analysis - * of the input point set. - */ - enum ProjectionMode {Sphere, XYPlane, XZPlane, YZPlane, PCAPlane}; - - /** - * Fills a data tree node with appropriate properties - * for mapping the output geometry surface - */ - static void SetDefaultCurvedGeometryProperties( mitk::DataNode* node ); - - /** - * Sets / Gets whether the input land marks are projected onto a plane - * or sphere - */ - itkSetMacro ( ProjectionMode, ProjectionMode ); - - /** - * Sets / Gets whether the input land marks are projected onto a plane - * or sphere - */ - itkGetMacro ( ProjectionMode, ProjectionMode ); - - itkSetObjectMacro( ImageToBeMapped, mitk::Image ); - itkGetObjectMacro( ImageToBeMapped, mitk::Image ); - - itkSetMacro( Sigma, float); - itkGetMacro( Sigma, float); - -protected: - - /** - * Protected constructor. Use ::New instead() - */ - PointSetToCurvedGeometryFilter(); - - /** - * Protected destructor. Instances are destroyed when reference count is zero - */ - virtual ~PointSetToCurvedGeometryFilter(); - - virtual void GenerateOutputInformation(); - - virtual void GenerateData(); - - ProjectionMode m_ProjectionMode; - - mitk::PlaneGeometry::Pointer m_XYPlane; - - mitk::PlaneGeometry::Pointer m_XZPlane; - - mitk::PlaneGeometry::Pointer m_YZPlane; - - mitk::PlaneFit::Pointer m_PCAPlaneCalculator; - - mitk::Image::Pointer m_ImageToBeMapped; - - mitk::PlaneLandmarkProjector::Pointer m_PlaneLandmarkProjector; - - mitk::SphereLandmarkProjector::Pointer m_SphereLandmarkProjector; - - float m_Sigma; - -}; - -} - -#endif diff --git a/Modules/Ext/Algorithms/mitkPointSetToGeometryDataFilter.cpp b/Modules/Ext/Algorithms/mitkPointSetToGeometryDataFilter.cpp deleted file mode 100644 index 609cd7d953..0000000000 --- a/Modules/Ext/Algorithms/mitkPointSetToGeometryDataFilter.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkPointSetToGeometryDataFilter.h" -#include - -void mitk::PointSetToGeometryDataFilter::SetInput ( const mitk::PointSetToGeometryDataFilter::InputType* input ) -{ - this->SetInput( 0, input ); -} - - -void mitk::PointSetToGeometryDataFilter::SetInput ( const unsigned int& idx, const mitk::PointSetToGeometryDataFilter::InputType* input ) -{ - if ( idx + 1 > this->GetNumberOfInputs() ) - { - this->SetNumberOfRequiredInputs(idx + 1); - } - if ( input != static_cast ( this->ProcessObject::GetInput ( idx ) ) ) - { - this->ProcessObject::SetNthInput ( idx, const_cast ( input ) ); - this->Modified(); - } -} - - -mitk::PointSetToGeometryDataFilter::InputType* mitk::PointSetToGeometryDataFilter::GetInput() -{ - return this->GetInput( 0 ); -} - - -mitk::PointSetToGeometryDataFilter::InputType* mitk::PointSetToGeometryDataFilter::GetInput ( const unsigned int& idx ) -{ - if ( this->GetNumberOfInputs() < 1 ) - return 0; - - return static_cast ( this->ProcessObject::GetInput ( idx ) ); -} - - -mitk::PointSetToGeometryDataFilter::PointSetToGeometryDataFilter() -{} - -mitk::PointSetToGeometryDataFilter::~PointSetToGeometryDataFilter() -{} - diff --git a/Modules/Ext/Algorithms/mitkPointSetToGeometryDataFilter.h b/Modules/Ext/Algorithms/mitkPointSetToGeometryDataFilter.h deleted file mode 100644 index 9145a196eb..0000000000 --- a/Modules/Ext/Algorithms/mitkPointSetToGeometryDataFilter.h +++ /dev/null @@ -1,77 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef _mitk_Point_Set_To_Geometry_Data_Filter__h_ -#define _mitk_Point_Set_To_Geometry_Data_Filter__h_ - -#include -#include "MitkExtExports.h" -#include - -namespace mitk -{ - -/** - * Common superclass for all algorithms having one or more point - * sets as input and producing one or more geometry datas as output - */ -class MitkExt_EXPORT PointSetToGeometryDataFilter : public GeometryDataSource -{ -public: - /** - * Standard mitk class macro - */ - mitkClassMacro( PointSetToGeometryDataFilter, GeometryDataSource ); - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - /** - * Common typdedefs for the input type and corresponding pointers - */ - typedef mitk::PointSet InputType; - typedef InputType::Pointer InputTypePointer; - typedef InputType::ConstPointer InputTypeConstPointer; - - /** - * Set and Get input methods. - */ - virtual void SetInput( const InputType* input ); - virtual void SetInput( const unsigned int& idx, const InputType* input ); - virtual InputType* GetInput(); - virtual InputType* GetInput(const unsigned int& idx); - -protected: - - /** - * Protected constructor. Use ::New instead() - */ - PointSetToGeometryDataFilter(); - - /** - * Protected destructor. Instances are destroyed when reference count is zero - */ - virtual ~PointSetToGeometryDataFilter(); - - -}; - -} //end of namespace mitk - - -#endif - - diff --git a/Modules/Ext/Algorithms/mitkPolygonToRingFilter.cpp b/Modules/Ext/Algorithms/mitkPolygonToRingFilter.cpp deleted file mode 100644 index 8fc7b9f744..0000000000 --- a/Modules/Ext/Algorithms/mitkPolygonToRingFilter.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkPolygonToRingFilter.h" -#include "mitkMesh.h" -#include "mitkSurface.h" -#include "mitkPlaneGeometry.h" - -#include -#include -#include - -#include -#include -#include -#include - -#include - - -mitk::PolygonToRingFilter::PolygonToRingFilter() -: m_RingRadius(3.5f), m_RingResolution(30), m_SplineResolution(20) -{ - m_SplineX = vtkCardinalSpline::New(); - m_SplineY = vtkCardinalSpline::New(); - m_SplineZ = vtkCardinalSpline::New(); -} - -mitk::PolygonToRingFilter::~PolygonToRingFilter() -{ - m_SplineX->Delete(); - m_SplineY->Delete(); - m_SplineZ->Delete(); -} - -void mitk::PolygonToRingFilter::GenerateOutputInformation() -{ - mitk::Mesh::ConstPointer input = this->GetInput(); - mitk::Surface::Pointer output = this->GetOutput(0); - - itkDebugMacro(<<"GenerateOutputInformation()"); - - if(input.IsNull()) return; - - output->SetGeometry(static_cast(input->GetGeometry()->Clone().GetPointer())); - - output->Expand( input->GetPointSetSeriesSize() ); -} - -void mitk::PolygonToRingFilter::GenerateData() -{ - mitk::Mesh::ConstPointer input = this->GetInput(); - mitk::Surface::Pointer output = this->GetOutput(0); - - unsigned int t; - for ( t = 0; t < input->GetPointSetSeriesSize(); ++t ) - { - - vtkPolyData *polyData = vtkPolyData::New(); - vtkPoints *vPoints = vtkPoints::New(); - vtkCellArray *polys = vtkCellArray::New(); - - mitk::Mesh::PointType thisPoint; - - // iterate through all cells and build tubes - Mesh::ConstCellIterator cellIt, cellEnd; - cellEnd = input->GetMesh( t )->GetCells()->End(); - for ( cellIt = input->GetMesh( t )->GetCells()->Begin(); - cellIt != cellEnd; - ++cellIt ) - { - m_PointList.clear(); - m_VectorList.clear(); - - this->BuildPointAndVectorList( - *cellIt->Value(), m_PointList, m_VectorList, t ); - this->BuildVtkTube( vPoints, polys, m_PointList, m_VectorList ); - } - - polyData->SetPoints( vPoints ); - vPoints->Delete(); - polyData->SetPolys( polys ); - polys->Delete(); - - output->SetVtkPolyData( polyData, t ); - polyData->Delete(); - - } - -} - - -//sl: last star -//sc: current star -//idmax: Id of the current star ray (sc), which matchs proberly to the first ray of the last star (sl). -//last_p: center of the last star -//cur_p: center of the current star -void mitk::PolygonToRingFilter::DrawCyl(vtkPoints *vPoints, vtkCellArray *polys, - VectorListType &sl, VectorListType &sc, int idmax, Point3D & last_p, Point3D & cur_p) -{ - unsigned int i; - //now we finished:sl0 will be connected with sc->at(idmax) - VectorListType::iterator slit=sl.begin(), scit=sc.begin(), scend=sc.end(); - scit+=idmax; - Point3D a,b; - Point3D a_first,b_first; - int a_firstID = 0, b_firstID = 0; - - vtkIdType front[4]; - for(i=0;iInsertNextPoint(v0[0],v0[1],v0[2]); - front[2]=vPoints->InsertNextPoint(v1[0],v1[1],v1[2]); - front[1]=vPoints->InsertNextPoint(v2[0],v2[1],v2[2]); - front[0]=vPoints->InsertNextPoint(v3[0],v3[1],v3[2]); - polys->InsertNextCell( (vtkIdType) 4, front ); - if(i==1) - { - a_firstID=front[3]; b_firstID=front[2]; //continue; - } - } - - ++slit; ++scit; if(scit==scend) scit=sc.begin(); - } - front[3]=front[0]; - front[2]=front[1]; - front[1]=b_firstID; - front[0]=a_firstID; - polys->InsertNextCell( 4, front ); -} - - -void mitk::PolygonToRingFilter::BuildVtkTube(vtkPoints *vPoints, vtkCellArray *polys, PointListType& ptList, VectorListType& vecList) -{ - PointListType::iterator pit = ptList.begin(), pend = ptList.end(); - VectorListType::iterator vit = vecList.begin(); - - Vector3D axis, last_v, next_v, s; - Point3D cur_p,last_p; - - //lists for the star - VectorListType *sl, *sc, *swp, sfirst, buf1, buf2; - sl=&buf1; sc=&buf2; - - Vector3D a,b; - Matrix3D m; - //Initialization for the first point - //alternative1: - // last_v=*(vl.getLast()); next_v=*vit.current(); axis=last_v+next_v; s.cross(last_v,next_v); s.normalize(); - //alternative2: - // last_v=*(vl.getLast()); next_v=*vit.current(); s.cross(last_v,next_v); s.normalize(); - // axis=next_v-last_v; axis.normalize(); aa.set(s, M_PI/2.0); m.set(aa); m.transform(&axis); - //alternative3: - last_v=vecList.back(); next_v=*vit; s.SetVnlVector( vnl_cross_3d(last_v.GetVnlVector(),next_v.GetVnlVector()) ); s.Normalize(); - a=last_v; b=next_v; a.Normalize(); b.Normalize(); axis=a+b; axis.Normalize(); - - //build the star at the first point - m = vnl_quaternion(axis.GetVnlVector(),2*vnl_math::pi/(double)m_RingResolution).rotation_matrix_transpose(); - unsigned int i; - for(i=0;ibegin()); - m = vnl_quaternion(axis.GetVnlVector(),2*vnl_math::pi/(double)m_RingResolution).rotation_matrix_transpose(); - for(i=0;ipush_back(s); - double tmp=s*sl0; - if(tmp>max) - { - max=tmp; - idmax=i; - } - s=m*s; - } - - //sl: last star - //sc: current star - //idmax: Id of the current star ray (sc), which matchs proberly to the first ray of the last star (sl). - //last_p: center of the last star - //cur_p: center of the current star - DrawCyl(vPoints, polys, *sl, *sc, idmax, last_p, cur_p); - - //Crossover to the next - last_p=cur_p; - swp=sl; sl=sc; sc=swp; sc->clear(); - } - - //calcutate idmax for connection: - double max=0; int idmax=0; Vector3D sl0=*(sl->begin()); - for(i=0;imax) - { - max=tmp; - idmax=i; - } - } - cur_p=*ptList.begin(); - DrawCyl(vPoints, polys, *sl, sfirst, idmax, last_p, cur_p); -} - -void -mitk::PolygonToRingFilter -::BuildPointAndVectorList( mitk::Mesh::CellType& cell, - PointListType& ptList, VectorListType& vecList, int timeStep ) -{ - // This method constructs a spline from the given point list and retrieves - // a number of interpolated points from it to form a ring-like structure. - // - // To make the spline "closed", the end point is connected to the start - // point. For ensuring smoothness at the start-end-point transition, the - // (intrinsically non-circular) spline array is extended on both sides - // by wrapping a number of points from the respective other side. - // - // The used VTK filters do principally support this kind of "closed" spline, - // but it does not produce results as consistent as with the method used - // here. Also, the spline class of VTK 4.4 has only poor support for - // arbitrary parametric coordinates (t values in vtkSpline). VTK 5.0 has - // better support, and also provides a new class vtkParametricSpline for - // directly calculating 3D splines. - - - // Remove points from previous call of this method - m_SplineX->RemoveAllPoints(); - m_SplineY->RemoveAllPoints(); - m_SplineZ->RemoveAllPoints(); - - int numberOfPoints = cell.GetNumberOfPoints(); - - Mesh::PointType inputPoint; - double t, tStart(0), tEnd(0); - - // Add input points to the spline and assign each the parametric value t - // derived from the point euclidean distances. - int i; - Mesh::PointIdIterator pit = cell.PointIdsEnd() - 3; - for ( i = -3, t = 0.0; i < numberOfPoints + 3; ++i ) - { - if ( i == 0 ) { tStart = t; } - if ( i == numberOfPoints ) { tEnd = t; } - - inputPoint = this->GetInput()->GetPoint( *pit, timeStep ); - m_SplineX->AddPoint( t, inputPoint[0] ); - m_SplineY->AddPoint( t, inputPoint[1] ); - m_SplineZ->AddPoint( t, inputPoint[2] ); - - ++pit; - if ( pit == cell.PointIdsEnd() ) - { - pit = cell.PointIdsBegin(); - } - - t += inputPoint.EuclideanDistanceTo( - this->GetInput()->GetPoint( *pit, timeStep ) ); - } - - // Evaluate the spline for the desired number of points - // (number of input points) * (spline resolution) - Point3D point, firstPoint, lastPoint; - firstPoint.Fill(0); - lastPoint.Fill(0); - int numberOfSegments = numberOfPoints * m_SplineResolution; - double step = (tEnd - tStart) / numberOfSegments; - for ( i = 0, t = tStart; i < numberOfSegments; ++i, t += step ) - { - FillVector3D( point, - m_SplineX->Evaluate(t), m_SplineY->Evaluate(t), m_SplineZ->Evaluate(t) - ); - - ptList.push_back( point ); - - if ( i == 0 ) - { - firstPoint = point; - } - else - { - vecList.push_back( point - lastPoint ); - } - lastPoint = point; - } - vecList.push_back( firstPoint - lastPoint ); -} - - -const mitk::Mesh *mitk::PolygonToRingFilter::GetInput(void) -{ - if (this->GetNumberOfInputs() < 1) - { - return 0; - } - - return static_cast - (this->ProcessObject::GetInput(0) ); -} - -void mitk::PolygonToRingFilter::SetInput(const mitk::Mesh *input) -{ - // Process object is not const-correct so the const_cast is required here - this->ProcessObject::SetNthInput(0, - const_cast< mitk::Mesh * >( input ) ); -} diff --git a/Modules/Ext/Algorithms/mitkPolygonToRingFilter.h b/Modules/Ext/Algorithms/mitkPolygonToRingFilter.h deleted file mode 100644 index ad7391425f..0000000000 --- a/Modules/Ext/Algorithms/mitkPolygonToRingFilter.h +++ /dev/null @@ -1,104 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef MITKPOLYGONTORINGFILTER_H_HEADER_INCLUDED_C10B22CD -#define MITKPOLYGONTORINGFILTER_H_HEADER_INCLUDED_C10B22CD - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkSurfaceSource.h" -#include "mitkMesh.h" - -class vtkPolyData; -class vtkPoints; -class vtkCardinalSpline; -class vtkPoints; -class vtkCellArray; - - -namespace mitk { - -/** - * \brief Create ring around polygons contained in a Mesh - * \ingroup Process - */ -class MitkExt_EXPORT PolygonToRingFilter : public SurfaceSource -{ -public: - mitkClassMacro(PolygonToRingFilter, SurfaceSource); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - virtual void GenerateOutputInformation(); - - virtual void GenerateData(); - - const mitk::Mesh *GetInput(void); - - virtual void SetInput(const mitk::Mesh *image); - - /** \brief Get ring radius */ - itkGetMacro(RingRadius, float); - - /* \brief Set ring radius */ - itkSetMacro(RingRadius, float); - - /** \brief Get ring resolution of created Surface */ - itkGetMacro(RingResolution, unsigned int); - - /** \brief Set ring resolution of created Surface */ - itkSetMacro(RingResolution, unsigned int); - - /** \brief Get spline resolution */ - itkGetMacro(SplineResolution, unsigned int); - - /** \brief Set spline resolution */ - itkSetMacro(SplineResolution, unsigned int); - -protected: - typedef std::vector VectorListType; - typedef std::vector PointListType; - - PolygonToRingFilter(); - - virtual ~PolygonToRingFilter(); - - void BuildVtkTube( vtkPoints *vPoints, vtkCellArray *polys, - PointListType& ptList, VectorListType& vecList ); - void BuildPointAndVectorList( mitk::Mesh::CellType& cell, - PointListType& ptList, VectorListType& vecList, int timeStep = 0 ); - void DrawCyl(vtkPoints *vPoints, vtkCellArray *polys, - VectorListType &sl, VectorListType &sc, int idmax, - Point3D & last_p, Point3D & cur_p); - - /** \brief Ring radius */ - float m_RingRadius; - - /** \brief Ring resolution of created Surface */ - unsigned int m_RingResolution; - - /** \brief Spline resolution of created Surface */ - unsigned int m_SplineResolution; - - vtkCardinalSpline *m_SplineX, *m_SplineY, *m_SplineZ; - - PointListType m_PointList; - VectorListType m_VectorList; -}; - -} // namespace mitk - -#endif /* MITKPOLYGONTORINGFILTER_H_HEADER_INCLUDED_C10B22CD */ diff --git a/Modules/Ext/Algorithms/mitkProbeFilter.cpp b/Modules/Ext/Algorithms/mitkProbeFilter.cpp deleted file mode 100644 index 42a0b6e4a5..0000000000 --- a/Modules/Ext/Algorithms/mitkProbeFilter.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkProbeFilter.h" -#include "mitkSurface.h" -#include "mitkImage.h" - -#include -#include -#include -#include -#include - -mitk::ProbeFilter::ProbeFilter() -{ -} - -mitk::ProbeFilter::~ProbeFilter() -{ -} - -const mitk::Surface *mitk::ProbeFilter::GetInput(void) -{ - if (this->GetNumberOfInputs() < 1) - { - return 0; - } - return static_cast< const mitk::Surface * >(this->ProcessObject::GetInput(0) ); -} - -const mitk::Image *mitk::ProbeFilter::GetSource(void) -{ - return static_cast< const mitk::Image * >(this->ProcessObject::GetInput(1)); -} - -void mitk::ProbeFilter::SetInput(const mitk::Surface *input) -{ - this->ProcessObject::SetNthInput( 0, const_cast< mitk::Surface * >( input ) ); -} - -void mitk::ProbeFilter::SetSource(const mitk::Image *source) -{ - this->ProcessObject::SetNthInput( 1, const_cast< mitk::Image * >( source ) ); -} - -void mitk::ProbeFilter::GenerateOutputInformation() -{ - mitk::Surface::ConstPointer input = this->GetInput(); - mitk::Image::ConstPointer source = this->GetSource(); - mitk::Surface::Pointer output = this->GetOutput(); - - if(input.IsNull()) return; - if(source.IsNull()) return; - - if(input->GetGeometry()==NULL) return; - if(source->GetGeometry()==NULL) return; - - if( (input->GetTimeGeometry()->CountTimeSteps()==1) && (source->GetTimeGeometry()->CountTimeSteps()>1) ) - { - Geometry3D::Pointer geo3D = Geometry3D::New(); - BaseGeometry::Pointer geometry3D = dynamic_cast(geo3D.GetPointer()); - geometry3D->Initialize(); - geometry3D->SetBounds(source->GetTimeGeometry()->GetBoundsInWorld()); - - ProportionalTimeGeometry::Pointer outputTimeGeometry = ProportionalTimeGeometry::New(); - outputTimeGeometry->Initialize(geometry3D, source->GetTimeGeometry()->CountTimeSteps()); - outputTimeGeometry->SetFirstTimePoint(source->GetTimeGeometry()->GetMinimumTimePoint()); - TimePointType stepDuration = source->GetTimeGeometry()->GetMaximumTimePoint(0) - source->GetTimeGeometry()->GetMinimumTimePoint(0); - outputTimeGeometry->SetStepDuration(stepDuration); - - output->Expand(outputTimeGeometry->CountTimeSteps()); - output->SetTimeGeometry( outputTimeGeometry ); - } - else - output->SetGeometry( static_cast(input->GetGeometry()->Clone().GetPointer()) ); - - itkDebugMacro(<<"GenerateOutputInformation()"); -} - -void mitk::ProbeFilter::GenerateData() -{ - mitk::Surface *input = const_cast< mitk::Surface * >(this->GetInput()); - mitk::Image *source = const_cast< mitk::Image * >(this->GetSource()); - mitk::Surface::Pointer output = this->GetOutput(); - - itkDebugMacro(<<"Generating Data"); - - if(output.IsNull()) - { - itkDebugMacro(<<"Output is NULL."); - return; - } - - mitk::Surface::RegionType outputRegion = output->GetRequestedRegion(); - const TimeGeometry *outputTimeGeometry = output->GetTimeGeometry(); - const TimeGeometry *inputTimeGeometry = input->GetTimeGeometry(); - const TimeGeometry *sourceTimeGeometry = source->GetTimeGeometry(); - TimePointType timeInMS; - int timestep=0; - - int tstart, tmax; - - tstart=outputRegion.GetIndex(3); - tmax=tstart+outputRegion.GetSize(3); - - int t; - for(t=tstart;tTimeStepToTimePoint( t ); - - vtkProbeFilter* probe = vtkProbeFilter::New(); - - timestep = inputTimeGeometry->TimePointToTimeStep( timeInMS ); - probe->SetInputData( input->GetVtkPolyData(timestep) ); - - timestep = sourceTimeGeometry->TimePointToTimeStep( timeInMS ); - probe->SetSourceData( source->GetVtkImageData(timestep) ); - - output->SetVtkPolyData( probe->GetPolyDataOutput(), t ); - - probe->Update(); - probe->Delete(); - } -} - -void mitk::ProbeFilter::GenerateInputRequestedRegion() -{ - Superclass::GenerateInputRequestedRegion(); - - mitk::Surface *input = const_cast< mitk::Surface * >( this->GetInput() ); - mitk::Image *source = const_cast< mitk::Image * >( this->GetSource() ); - - if(input==NULL) return; - if(source==NULL) return; - - mitk::Surface::Pointer output = this->GetOutput(); - mitk::Surface::RegionType outputRegion = output->GetRequestedRegion(); - const TimeGeometry *outputTimeGeometry = output->GetTimeGeometry(); - - mitk::Surface::RegionType inputSurfaceRegion = outputRegion; - Image::RegionType sourceImageRegion = source->GetLargestPossibleRegion(); - - if(outputRegion.GetSize(3)<1) - { - mitk::Surface::RegionType::SizeType surfacesize; - surfacesize.Fill(0); - inputSurfaceRegion.SetSize(surfacesize); - input->SetRequestedRegion( &inputSurfaceRegion ); - mitk::Image::RegionType::SizeType imagesize; - imagesize.Fill(0); - sourceImageRegion.SetSize(imagesize); - source->SetRequestedRegion( &sourceImageRegion ); - return; - } - - //create and set input requested region for the input surface - const TimeGeometry *inputTimeGeometry = input->GetTimeGeometry(); - - ScalarType timeInMS; - int timestep=0; - - // convert the start-index-time of output in start-index-time of input via millisecond-time - timeInMS = outputTimeGeometry->TimeStepToTimePoint(outputRegion.GetIndex(3)); - timestep = inputTimeGeometry->TimePointToTimeStep( timeInMS ); - if( ( timeInMS > itk::NumericTraits::NonpositiveMin() ) && ( inputTimeGeometry->IsValidTimeStep( timestep ) ) ) - inputSurfaceRegion.SetIndex( 3, timestep ); - else - inputSurfaceRegion.SetIndex( 3, 0 ); - // convert the end-index-time of output in end-index-time of input via millisecond-time - timeInMS = outputTimeGeometry->TimeStepToTimePoint(outputRegion.GetIndex(3)+outputRegion.GetSize(3)-1); - timestep = inputTimeGeometry->TimePointToTimeStep( timeInMS ); - if( ( timeInMS > itk::NumericTraits::NonpositiveMin() ) && ( outputTimeGeometry->IsValidTimeStep( timestep ) ) ) - inputSurfaceRegion.SetSize( 3, timestep - inputSurfaceRegion.GetIndex(3) + 1 ); - else - inputSurfaceRegion.SetSize( 3, 1 ); - - input->SetRequestedRegion( &inputSurfaceRegion ); - - //create and set input requested region for the source image - const TimeGeometry *sourceTimeGeometry = source->GetTimeGeometry(); - - // convert the start-index-time of output in start-index-time of source via millisecond-time - timeInMS = outputTimeGeometry->TimeStepToTimePoint(outputRegion.GetIndex(3)); - timestep = sourceTimeGeometry->TimePointToTimeStep( timeInMS ); - if( ( timeInMS > itk::NumericTraits::NonpositiveMin() ) && ( sourceTimeGeometry->IsValidTimeStep( timestep ) ) ) - sourceImageRegion.SetIndex( 3, timestep ); - else - sourceImageRegion.SetIndex( 3, 0 ); - // convert the end-index-time of output in end-index-time of source via millisecond-time - timeInMS = outputTimeGeometry->TimeStepToTimePoint(outputRegion.GetIndex(3)+outputRegion.GetSize(3)-1); - timestep = sourceTimeGeometry->TimePointToTimeStep( timeInMS ); - if( ( timeInMS > itk::NumericTraits::NonpositiveMin() ) && ( outputTimeGeometry->IsValidTimeStep( timestep ) ) ) - sourceImageRegion.SetSize( 3, timestep - sourceImageRegion.GetIndex(3) + 1 ); - else - sourceImageRegion.SetSize( 3, 1 ); - - sourceImageRegion.SetIndex( 4, 0 ); - sourceImageRegion.SetSize( 4, 1 ); - - source->SetRequestedRegion( &sourceImageRegion ); -} diff --git a/Modules/Ext/Algorithms/mitkProbeFilter.h b/Modules/Ext/Algorithms/mitkProbeFilter.h deleted file mode 100644 index afc111ffbb..0000000000 --- a/Modules/Ext/Algorithms/mitkProbeFilter.h +++ /dev/null @@ -1,62 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef MITKPROBEFILTER_H_HEADER_INCLUDED_C10B22CD -#define MITKPROBEFILTER_H_HEADER_INCLUDED_C10B22CD - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkSurfaceSource.h" - -class vtkPlaneSource; -class vtkTransformPolyDataFilter; -class vtkDataSetToPolyDataFilter; - -namespace mitk { - -class Surface; -class Image; - -//##Documentation -//## @brief Adapter for vtkProbeFilter, making it a 3D+t filter -//## -//## @ingroup Process -class MitkExt_EXPORT ProbeFilter : public SurfaceSource -{ -public: - mitkClassMacro(ProbeFilter, SurfaceSource); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - virtual void GenerateOutputInformation(); - virtual void GenerateInputRequestedRegion(); - virtual void GenerateData(); - - const mitk::Surface *GetInput(void); - const mitk::Image *GetSource(void); - - virtual void SetInput(const mitk::Surface *input); - virtual void SetSource(const mitk::Image *source); - -protected: - ProbeFilter(); - - virtual ~ProbeFilter(); -}; - -} // namespace mitk - -#endif /* MITKPROBEFILTER_H_HEADER_INCLUDED_C10B22CD */ diff --git a/Modules/Ext/Algorithms/mitkSurfaceIndexToWorldTransformFilter.cpp b/Modules/Ext/Algorithms/mitkSurfaceIndexToWorldTransformFilter.cpp deleted file mode 100644 index 28ee053ddc..0000000000 --- a/Modules/Ext/Algorithms/mitkSurfaceIndexToWorldTransformFilter.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkSurfaceIndexToWorldTransformFilter.h" - -#include "vtkPoints.h" -#include "vtkPolyData.h" - -mitk::SurfaceIndexToWorldTransformFilter::SurfaceIndexToWorldTransformFilter() -{ -} - -mitk::SurfaceIndexToWorldTransformFilter::~SurfaceIndexToWorldTransformFilter() -{ -} - -void mitk::SurfaceIndexToWorldTransformFilter::GenerateData() -{ - mitk::Surface* input = const_cast( this->GetInput()); - mitk::Surface::Pointer output = this->GetOutput(); - - mitk::Point3D current, transformed; - vtkPoints* surfacePoints = vtkPoints::New(); - vtkPoints* newSurfacePoints = vtkPoints::New(); - int pointIter = 0; - - surfacePoints = input->GetVtkPolyData()->GetPoints(); - - while(pointIter != surfacePoints->GetNumberOfPoints()) - { - double* intermed = surfacePoints->GetPoint(pointIter); - current[0] = intermed[0]; - current[1] = intermed[1]; - current[2] = intermed[2]; - - input->GetGeometry()->IndexToWorld(current, transformed); - newSurfacePoints->InsertPoint( pointIter, transformed[0], transformed[1], transformed[2] ); - pointIter++; - } - - output->GetVtkPolyData()->SetPoints(newSurfacePoints); - output->GetVtkPolyData()->SetPolys(input->GetVtkPolyData()->GetPolys()); - output->GetGeometry()->SetIdentity(); - output->Modified(); - output->Update(); -} - - diff --git a/Modules/Ext/Algorithms/mitkSurfaceIndexToWorldTransformFilter.h b/Modules/Ext/Algorithms/mitkSurfaceIndexToWorldTransformFilter.h deleted file mode 100644 index 8a3d2c3324..0000000000 --- a/Modules/Ext/Algorithms/mitkSurfaceIndexToWorldTransformFilter.h +++ /dev/null @@ -1,66 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef _mitkSurfaceIndexToWorldTransformFilter_h__ -#define _mitkSurfaceIndexToWorldTransformFilter_h__ - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkSurfaceToSurfaceFilter.h" -#include "mitkSurface.h" - -namespace mitk { - - //##Documentation - //## @brief Transforms a surface object from index to world coordinates. - //## Transposes the surface point coordinates with the object's mitk::Geometry3D to display - //## correct scene coordinates. - //## - //## @ingroup Algorithms - - class MitkExt_EXPORT SurfaceIndexToWorldTransformFilter : public SurfaceToSurfaceFilter -{ -public: - - /** - * Standard mitk class macro - */ - mitkClassMacro(SurfaceIndexToWorldTransformFilter, SurfaceToSurfaceFilter); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - -protected: - - /** - * Protected constructor. Use ::New instead() - */ - SurfaceIndexToWorldTransformFilter(); - - /** - * Protected destructor. Instances are destroyed when reference count is zero - */ - virtual ~SurfaceIndexToWorldTransformFilter(); - - /** - * method executed when calling Update(); - */ - virtual void GenerateData(); - -}; - -} // namespace mitk - -#endif /* _mitkSurfaceIndexToWorldTransformFilter_h__*/ diff --git a/Modules/Ext/Algorithms/mitkUnstructuredGridHistogram.cpp b/Modules/Ext/Algorithms/mitkUnstructuredGridHistogram.cpp deleted file mode 100644 index fd1ff53e1b..0000000000 --- a/Modules/Ext/Algorithms/mitkUnstructuredGridHistogram.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include - -#include -#include -#include - -#include "mitkUnstructuredGridHistogram.h" - - - -mitk::UnstructuredGridHistogram::~UnstructuredGridHistogram() -{ -} - -void mitk::UnstructuredGridHistogram::Initialize(mitk::UnstructuredGrid* ugrid) -{ - - const int numBins = 20; - - vtkUnstructuredGrid* vtkUGrid = ugrid->GetVtkUnstructuredGrid(); - - double* range = vtkUGrid->GetScalarRange(); - - SizeType size; - MeasurementVectorType lowerBound; - MeasurementVectorType upperBound; - - size.Fill(numBins); - lowerBound[0] = range[0]; - upperBound[0] = range[1]; - double length = upperBound[0] - lowerBound[0]; - - this->Superclass::Initialize(size, lowerBound, upperBound); - - vtkDataArray* data; - if (m_UsePointData) data = vtkUGrid->GetPointData()->GetScalars(); - else data = vtkUGrid->GetCellData()->GetScalars(); - - if (data == 0) return; - - if (m_UsePointData) - { - vtkIdList* cellIds = vtkIdList::New(); - for (vtkIdType pointId = 0; pointId < vtkUGrid->GetNumberOfPoints(); pointId++) { - vtkUGrid->GetPointCells(pointId, cellIds); - double numIds = (double)cellIds->GetNumberOfIds(); - double scalar = data->GetComponent(pointId, 0); - //MITK_INFO << "scalar value: " << scalar; - int bin = numBins - 1; - if (scalar != upperBound[0]) - bin = (int)(((double)numBins)*(scalar-lowerBound[0])/length); - //MITK_INFO << " bin: " << bin << std::endl; - this->IncreaseFrequency(bin, 1.0/(double)numIds); - cellIds->Reset(); - } - cellIds->Delete(); - } - else - { - for (vtkIdType cellId = 0; cellId < vtkUGrid->GetNumberOfCells(); cellId++) { - double scalar = data->GetComponent(cellId, 0); - //MITK_INFO << "scalar value: " << scalar; - int bin = numBins - 1; - if (scalar != upperBound[0]) - bin = (int)(((double)numBins)*(scalar-lowerBound[0])/length); - //MITK_INFO << " bin: " << bin << std::endl; - this->IncreaseFrequency(bin, 1.0); - } - } -} diff --git a/Modules/Ext/Algorithms/mitkUnstructuredGridHistogram.h b/Modules/Ext/Algorithms/mitkUnstructuredGridHistogram.h deleted file mode 100644 index 276f65e338..0000000000 --- a/Modules/Ext/Algorithms/mitkUnstructuredGridHistogram.h +++ /dev/null @@ -1,52 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef UNSTRUCTURED_GIRD_HISTOGRAM_H_HEADER_INCLUDED -#define UNSTRUCTURED_GIRD_HISTOGRAM_H_HEADER_INCLUDED - -#include -#include "MitkExtExports.h" -#include "mitkUnstructuredGrid.h" - -namespace mitk { - -//##Documentation -//## @brief Subclass of itk::Histogram, specialized for a mitk::UnstructuredGrid -//## -class MitkExt_EXPORT UnstructuredGridHistogram : public itk::Statistics::Histogram -{ -public: - mitkClassMacro(UnstructuredGridHistogram,itk::Statistics::Histogram) - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - void Initialize(mitk::UnstructuredGrid*); - - void SetUsePointData() { m_UsePointData = true; } - void SetUseCellData() { m_UsePointData = false; } - -protected: - UnstructuredGridHistogram() : m_UsePointData(true) {} - - virtual ~UnstructuredGridHistogram(); - - bool m_UsePointData; -}; - -} // namespace mitk - -#endif /* UNSTRUCTURED_GIRD_HISTOGRAM_H_HEADER_INCLUDED */ diff --git a/Modules/Ext/Algorithms/mitkVolumeVisualizationImagePreprocessor.cpp b/Modules/Ext/Algorithms/mitkVolumeVisualizationImagePreprocessor.cpp deleted file mode 100644 index 13abc43f1f..0000000000 --- a/Modules/Ext/Algorithms/mitkVolumeVisualizationImagePreprocessor.cpp +++ /dev/null @@ -1,652 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkVolumeVisualizationImagePreprocessor.h" - -#include -#include - -#include - -#define VVP_INFO MITK_INFO << "Mem Usage: " << mitk::MemoryUtilities::GetProcessMemoryUsage() << " " - -namespace mitk -{ - -VolumeVisualizationImagePreprocessor::VolumeVisualizationImagePreprocessor() -: m_OutOfLiverValue(-512), - m_surfaceValue(-256), - m_realSurfaceValue(0), - m_EstimatedThreshold( 150.0 ), - m_MinThreshold( 0.0 ), - m_MaxThreshold( 250.0 ) -{ -} - -VolumeVisualizationImagePreprocessor::~VolumeVisualizationImagePreprocessor() -{ -} - - - -TransferFunction::Pointer -VolumeVisualizationImagePreprocessor::GetInitialTransferFunction( ) -{ - int treshold = m_EstimatedThreshold; - - double opacity = 0.005; - - double maskValue = m_OutOfLiverValue; - double surfaceValue = m_surfaceValue; - double realSurfaceValue = m_realSurfaceValue; - - //double surfaceSteepness = 0.0; - - VVP_INFO << "using threshold of " << treshold << " and opacity of " << opacity; - - TransferFunction::Pointer tf = TransferFunction::New(); - - // grayvalue->opacity - { - vtkPiecewiseFunction *f=tf->GetScalarOpacityFunction(); - f->RemoveAllPoints(); - f->AddPoint(maskValue,0); - f->AddPoint(maskValue+1,0); - f->AddPoint(surfaceValue,0.05); - f->AddPoint(realSurfaceValue,opacity); - f->AddPoint(treshold-1,opacity); - f->AddPoint(treshold+4,0.8); - f->AddPoint(m_MaxThreshold+1,0.8); - f->ClampingOn(); - f->Modified(); - } - - // gradient at grayvalue->opacity - { - vtkPiecewiseFunction *f=tf->GetGradientOpacityFunction(); - f->RemoveAllPoints(); - f->AddPoint( -1000.0, 1.0 ); - f->AddPoint( 1000, 1.0 ); - f->ClampingOn(); - f->Modified(); - } - - // grayvalue->color - { - vtkColorTransferFunction *ctf=tf->GetColorTransferFunction(); - ctf->RemoveAllPoints(); - ctf->AddRGBPoint( maskValue, 0.5, 0.0, 0.0 ); - ctf->AddRGBPoint( maskValue+1, 0.5, 0.0, 0.0 ); - ctf->AddRGBPoint( surfaceValue, 1.0, 0.0, 0.0 ); //0.5 - ctf->AddRGBPoint( realSurfaceValue, 0.2, 0.0, 0.0 ); - - ctf->AddRGBPoint( treshold-32, 0.2, 0.0, 0.0 ); - ctf->AddRGBPoint( treshold, 251/255.0, 1.0, 0.0 ); - ctf->AddRGBPoint( m_MaxThreshold+1, 251/255.0, 1.0, 0.0 ); - - ctf->ClampingOn(); - ctf->Modified(); - } - - m_LastUsedTreshold = treshold; - - return tf; -} - - -void VolumeVisualizationImagePreprocessor::UpdateTransferFunction( TransferFunction::Pointer tf, int treshold ) -{ - double opacity = 0.005; - - //double maskValue = m_OutOfLiverValue; - //double surfaceValue = m_surfaceValue; - //double realSurfaceValue = m_realSurfaceValue; - - //double surfaceSteepness = 0.0; - - //VVP_INFO << "changing to threshold of " << treshold << " and opacity of " << opacity; - - // grayvalue->opacity - { - vtkPiecewiseFunction *f=tf->GetScalarOpacityFunction(); - - f->RemovePoint( m_LastUsedTreshold-1 ); - f->AddPoint(treshold-1,opacity); - - f->RemovePoint( m_LastUsedTreshold+4 ); - f->AddPoint(treshold+4,0.8); - } - - // grayvalue->color - { - vtkColorTransferFunction *ctf=tf->GetColorTransferFunction(); - - ctf->RemovePoint( m_LastUsedTreshold-32 ); - ctf->AddRGBPoint( treshold-32, 0.2, 0.0, 0.0 ); - - ctf->RemovePoint( m_LastUsedTreshold ); - ctf->AddRGBPoint( treshold, 251/255.0, 1.0, 0.0 ); - } - - m_LastUsedTreshold = treshold; -} - -VolumeVisualizationImagePreprocessor::LabelImage::Pointer -VolumeVisualizationImagePreprocessor::ConnectComponents(BinImage::Pointer src) -{ - VVP_INFO << "Connect Components..."; - - LabelImage::Pointer dst = LabelImage::New(); - - typedef itk::ConnectedComponentImageFilter< BinImage, LabelImage > myFilterType; - - myFilterType::Pointer myFilter = myFilterType::New(); - - myFilter->SetInput(src); - myFilter->Update(); - dst = myFilter->GetOutput(); - dst->DisconnectPipeline(); - - return dst; -} - -VolumeVisualizationImagePreprocessor::BinImage::Pointer -VolumeVisualizationImagePreprocessor::Threshold(CTImage::Pointer src, int threshold) -{ - VVP_INFO << "thresholding..."; - - BinImage::Pointer dst = BinImage::New(); - - typedef itk::ThresholdLabelerImageFilter< CTImage, BinImage > myFilterType; - - myFilterType::Pointer myFilter = myFilterType::New(); - - myFilter->SetInput(src); - - myFilterType::ThresholdVector tv; - tv.push_back(threshold); - myFilter->SetThresholds(tv); - - myFilter->Update(); - dst = myFilter->GetOutput(); - dst->DisconnectPipeline(); - - return dst; -} - -VolumeVisualizationImagePreprocessor::LabelImage::Pointer -VolumeVisualizationImagePreprocessor::RelabelComponents(LabelImage::Pointer src) -{ - VVP_INFO << "Relabeling Components..."; - - LabelImage::Pointer dst = LabelImage::New(); - - typedef itk::RelabelComponentImageFilter< LabelImage, LabelImage > myFilterType; - - myFilterType::Pointer myFilter = myFilterType::New(); - - myFilter->SetInput(src); - myFilter->Update(); - dst = myFilter->GetOutput(); - dst->DisconnectPipeline(); - - return dst; -} - -VolumeVisualizationImagePreprocessor::BinImage::Pointer -VolumeVisualizationImagePreprocessor::Dilate(BinImage::Pointer src) -{ - VVP_INFO << "Dilating..."; - - BinImage::Pointer dst = BinImage::New(); - - typedef itk::BinaryDilateImageFilter< BinImage, BinImage,itk::BinaryBallStructuringElement< unsigned char, 3> > BinaryDilateImageType; - BinaryDilateImageType::KernelType myKernel; - myKernel.SetRadius(1); - myKernel.CreateStructuringElement(); - BinaryDilateImageType::Pointer DilateFilter = BinaryDilateImageType::New(); - DilateFilter->SetInput(src); - DilateFilter->SetKernel(myKernel); - DilateFilter->SetDilateValue(1); //to be dilated to - DilateFilter->Update(); - dst = DilateFilter->GetOutput(); - dst->DisconnectPipeline(); - - return dst; -} - -VolumeVisualizationImagePreprocessor::BinImage::Pointer -VolumeVisualizationImagePreprocessor::Erode(BinImage::Pointer src) -{ - VVP_INFO << "Eroding..."; - - BinImage::Pointer dst = BinImage::New(); - - typedef itk::BinaryErodeImageFilter< BinImage, BinImage,itk::BinaryBallStructuringElement< unsigned char, 3> > BinaryErodeImageType; - BinaryErodeImageType::KernelType myKernel; - myKernel.SetRadius(1); - myKernel.CreateStructuringElement(); - BinaryErodeImageType::Pointer ErodeFilter = BinaryErodeImageType::New(); - ErodeFilter->SetInput(src); - ErodeFilter->SetKernel(myKernel); - ErodeFilter->SetErodeValue(0); //to be Eroded to - ErodeFilter->Update(); - dst = ErodeFilter->GetOutput(); - dst->DisconnectPipeline(); - - return dst; -} - - -VolumeVisualizationImagePreprocessor::CTImage::Pointer -VolumeVisualizationImagePreprocessor::Gaussian(CTImage::Pointer src) -{ - VVP_INFO << "Gaussian..."; - - typedef itk::DiscreteGaussianImageFilter< CTImage, CTImage> GaussianFilterType; - - GaussianFilterType::Pointer gaussianFilter = GaussianFilterType::New(); - gaussianFilter->SetInput( src ); - gaussianFilter->SetVariance( 1 ); - // gaussianFilter->SetMaximumError( 0.1 ); - - gaussianFilter->SetMaximumKernelWidth ( 8 ); - gaussianFilter->UpdateLargestPossibleRegion(); - - CTImage::Pointer dst = gaussianFilter->GetOutput(); - dst->DisconnectPipeline(); - - return dst; - -} - -VolumeVisualizationImagePreprocessor::CTImage::Pointer VolumeVisualizationImagePreprocessor::Crop(VolumeVisualizationImagePreprocessor::CTImage::Pointer src ) -{ - VVP_INFO << "Cropping 16bit..."; - - typedef itk::RegionOfInterestImageFilter FilterType; - - FilterType::Pointer cropFilter = FilterType::New(); - - cropFilter->SetInput( src ); - - CTImage::RegionType region; - CTImage::SizeType size; - CTImage::IndexType index; - - index.SetElement(0,m_MinX); - index.SetElement(1,m_MinY); - index.SetElement(2,m_MinZ); - - size.SetElement(0,m_MaxX-m_MinX+1); - size.SetElement(1,m_MaxY-m_MinY+1); - size.SetElement(2,m_MaxZ-m_MinZ+1); - - region.SetIndex(index); - region.SetSize(size); - - cropFilter->SetRegionOfInterest(region); - cropFilter->Update(); - - CTImage::Pointer dst = cropFilter->GetOutput(); - dst->DisconnectPipeline(); - - return dst; -} - - - -VolumeVisualizationImagePreprocessor::BinImage::Pointer VolumeVisualizationImagePreprocessor::Crop(VolumeVisualizationImagePreprocessor::BinImage::Pointer src ) -{ - VVP_INFO << "Cropping 8bit..."; - - typedef itk::RegionOfInterestImageFilter FilterType; - - FilterType::Pointer cropFilter = FilterType::New(); - - cropFilter->SetInput( src ); - - BinImage::RegionType region; - BinImage::SizeType size; - BinImage::IndexType index; - - index.SetElement(0,m_MinX); - index.SetElement(1,m_MinY); - index.SetElement(2,m_MinZ); - - size.SetElement(0,m_MaxX-m_MinX+1); - size.SetElement(1,m_MaxY-m_MinY+1); - size.SetElement(2,m_MaxZ-m_MinZ+1); - - region.SetIndex(index); - region.SetSize(size); - - cropFilter->SetRegionOfInterest(region); - cropFilter->Update(); - - BinImage::Pointer dst = cropFilter->GetOutput(); - dst->DisconnectPipeline(); - - return dst; -} - - -/* - CTImage::Pointer CTImageWork = CTImage::New(); -CastToItkImage( imageOrg, CTImageWork ); - -BinImage::Pointer BinImageMask = BinImage::New(); -CastToItkImage( imageMask, BinImageMask ); - -BinImage::Pointer BinImageMaskDilate = BinImage::New(); -BinImage::Pointer BinImageMaskErode = BinImage::New(); -*/ - -int mitk::VolumeVisualizationImagePreprocessor::GetHistogrammValueFromBottom( double part ) -{ - int unteren = total * part; - for( int r = -32768 ; r <= 32767 ; r++ ) - if( (unteren -= histogramm[32768+(int)r]) <= 0 ) - return r; - return 0; // will be never reached -} - - -int mitk::VolumeVisualizationImagePreprocessor::GetHistogrammValueFromTop( double part ) -{ - int oberen = total * part; - for( int r = 32767 ; r >= -32768 ; r-- ) - if( (oberen -= histogramm[32768+(int)r]) <= 0 ) - return r; - return 0; // will be never reached -} - - -void VolumeVisualizationImagePreprocessor::DetermineBoundingBox( BinImage::Pointer mask ) -{ - VVP_INFO << "determining Bounding Box..."; - - BinIteratorIndexType maskIt( mask, mask->GetRequestedRegion() ); - - maskIt.GoToBegin(); - - int totalMinX; - int totalMinY; - int totalMinZ; - - int totalMaxX; - int totalMaxY; - int totalMaxZ; - - // Initialize Bounding Box - { - m_MinX=m_MinY=m_MinZ = 1000000; - m_MaxX=m_MaxY=m_MaxZ = -1000000; - - totalMinX=totalMinY=totalMinZ = 1000000; - totalMaxX=totalMaxY=totalMaxZ = -1000000; - } - - while ( ! maskIt.IsAtEnd() ) - { - BinIteratorIndexType::IndexType idx = maskIt.GetIndex(); - int x=idx.GetElement(0); - int y=idx.GetElement(1); - int z=idx.GetElement(2); - - if(xtotalMaxX) totalMaxX=x; - if(y>totalMaxY) totalMaxY=y; - if(z>totalMaxZ) totalMaxZ=z; - - if(maskIt.Get()) - { - if(xm_MaxX) m_MaxX=x; - if(y>m_MaxY) m_MaxY=y; - if(z>m_MaxZ) m_MaxZ=z; - } - ++maskIt; - } - - int border = 3; - - m_MinX -= border; if(m_MinX < totalMinX ) m_MinX = totalMinX; - m_MinY -= border; if(m_MinY < totalMinY ) m_MinY = totalMinY; - m_MinZ -= border; if(m_MinZ < totalMinZ ) m_MinZ = totalMinZ; - - m_MaxX += border; if(m_MaxX > totalMaxX ) m_MaxX = totalMaxX; - m_MaxY += border; if(m_MaxY > totalMaxY ) m_MaxY = totalMaxY; - m_MaxZ += border; if(m_MaxZ > totalMaxZ ) m_MaxZ = totalMaxZ; - - VVP_INFO << "Bounding box" << " m_MinX: " << m_MinX << " m_MaxX: " << m_MaxX - << "\n m_MinY: " << m_MinY << " m_MaxY: " << m_MaxY - << "\n m_MinZ: " << m_MinZ << " m_MaxZ: " << m_MaxZ; - - -} - -mitk::VolumeVisualizationImagePreprocessor::CTImage::Pointer VolumeVisualizationImagePreprocessor::Composite( CTImage::Pointer work, - BinImage::Pointer mask, - BinImage::Pointer dilated, - BinImage::Pointer eroded) -{ - VVP_INFO << "Compositing..."; - - /* - itk::OrImageFilter::Pointer nullFilter= itk::OrImageFilter::New(); - nullFilter->SetInput1( input ); - nullFilter->SetInput2( input ); - nullFilter->UpdateLargestPossibleRegion(); - CTImage::Pointer work = nullFilter->GetOutput(); - */ - - CTIteratorIndexType workIt( work, work->GetRequestedRegion() ); - BinIteratorType maskIt( mask, mask->GetRequestedRegion() ); - BinIteratorType dilateIt( dilated, dilated->GetRequestedRegion() ); - BinIteratorType erodeIt( eroded, eroded->GetRequestedRegion() ); - - workIt.GoToBegin(); - maskIt.GoToBegin(); - dilateIt.GoToBegin(); - erodeIt.GoToBegin(); - - double sum=0; - int num=0; - - double sumIn=0; - int numIn=0; - - int _min=32767,_max=-32768; - - total=0; - memset(histogramm,0,sizeof(int)*65536); - - while ( ! ( workIt.IsAtEnd() || maskIt.IsAtEnd() || dilateIt.IsAtEnd() || erodeIt.IsAtEnd() ) ) - { - int value = workIt.Get(); - unsigned char mask = maskIt.Get(); - unsigned char dilate = dilateIt.Get(); - unsigned char erode = erodeIt.Get(); - //build barchart of internal of the liver - if(mask != 0) - { - sumIn+=value; - numIn++; - histogramm[32768+(int)value]++; - total++; - } - //average of the exterior layer - if(erode != 0 && mask != 0 ) - { - sum+=value; - num++; - if(value>_max) _max=value; - if(value<_min) _min=value; - } - - //mark the surface of the liver with -1024 and update bounding box - if(erode == 0 && dilate != 0 ) - { - value = -1024; - - } - else if( erode != 0 && mask != 0 )//Keep the gray values of internal of the liver - { - - } - else//mark the exterior with -2048 - { - value = -2048; - } - - workIt.Set(value); - - ++workIt; - ++maskIt; - ++dilateIt; - ++erodeIt; - } - - VVP_INFO << "liver consists of " << total << " samples."; - - m_GreatestStructureThreshold = GetHistogrammValueFromTop(0.20); - m_EstimatedThreshold = GetHistogrammValueFromTop(0.10); - m_MaxThreshold=GetHistogrammValueFromTop(0.001); - m_MinThreshold=GetHistogrammValueFromBottom(0.20); - - VVP_INFO << "threshold range: (" << m_MinThreshold << ";" << m_MaxThreshold << ") estimated vessel threshold: " << m_EstimatedThreshold ; - VVP_INFO << "m_GreatestStructureThreshold: " << m_GreatestStructureThreshold; - -// BinImage::Pointer binImageThreshold= Threshold(work,m_GreatestStructureThreshold ); -// LabelImage::Pointer LabelImageunsorted=ConnectComponents(binImageThreshold); -// LabelImage::Pointer LabelImageSorted= RelabelComponents(LabelImageunsorted); - - - if(num>0) - m_realSurfaceValue=sum/num; - else - m_realSurfaceValue=0; - - if(numIn>0) - m_realInLiverValue=sumIn/numIn; - else - m_realInLiverValue=0; - - m_surfaceValue = _min - 40; - m_OutOfLiverValue = m_surfaceValue - 40; - -// LabelIteratorType labelIt( LabelImageSorted, LabelImageSorted->GetRequestedRegion() ); - - workIt.GoToBegin(); -// labelIt.GoToBegin(); - - //int numGesetzt=0; - //int numGelassen=0; - - - while ( ! workIt.IsAtEnd() ) - { - int value = workIt.Get(); -// int label = labelIt.Get(); - - if(value == -1024 ) - { - value = m_surfaceValue; - } - else if( value == -2048 ) - { - value = m_OutOfLiverValue; - } - else - {//In the space of the liver - //Label unequal 1 --> set value on minimum -/* - if (label != 1){ - numGesetzt++; - value=m_realInLiverValue; - } - else - { - //value=m_EstimatedThreshold; - numGelassen++; - } - */ - } - - workIt.Set(value); - - ++workIt; -// ++labelIt; - - } - - //VVP_INFO << "set: " << numGesetzt << " --- unvaried: " << numGelassen; - - VVP_INFO << "OutOfLiver value: " << m_OutOfLiverValue; - VVP_INFO << "surface value: " << m_surfaceValue; - VVP_INFO << "real surface value: " << m_realSurfaceValue; - VVP_INFO << "real inLiver value:" << m_realInLiverValue; - - work->DisconnectPipeline(); - - return work; -} - - - -Image::Pointer -VolumeVisualizationImagePreprocessor::Process( - Image::Pointer m_originalCT, Image::Pointer m_originalLiverMask) -{ - VVP_INFO << "Processing..."; - - // converting mitk image -> itk image - CTImage::Pointer CTImageWork = CTImage::New(); - CastToItkImage( m_originalCT, CTImageWork ); - - // converting mitk image -> itk image - BinImage::Pointer BinImageMask = BinImage::New(); - CastToItkImage( m_originalLiverMask, BinImageMask ); - - DetermineBoundingBox( BinImageMask ); - - if( m_MaxX < m_MinX - || m_MaxY < m_MinY - || m_MaxZ < m_MinZ ) - return 0; - - CTImageWork = Gaussian(Crop( CTImageWork )); - BinImageMask = Crop( BinImageMask ); - - CTImage::Pointer itkResult =Composite(CTImageWork,BinImageMask,Dilate(BinImageMask),Erode(BinImageMask)); - - mitk::Image::Pointer mitkResult= mitk::Image::New(); - mitk::CastToMitkImage( itkResult, mitkResult ); //TODO here we can perhaps save memory - - VVP_INFO << "Finished..."; - - return mitkResult; -} - -} diff --git a/Modules/Ext/Algorithms/mitkVolumeVisualizationImagePreprocessor.h b/Modules/Ext/Algorithms/mitkVolumeVisualizationImagePreprocessor.h deleted file mode 100644 index a93b3edb53..0000000000 --- a/Modules/Ext/Algorithms/mitkVolumeVisualizationImagePreprocessor.h +++ /dev/null @@ -1,184 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkVolumeVisualizationImagePreprocessor_h_include -#define mitkVolumeVisualizationImagePreprocessor_h_include - - -#include "mitkCommon.h" -#include "MitkExtExports.h" - - -#include "mitkImageCast.h" -#include "mitkITKImageImport.h" -#include "mitkTransferFunctionProperty.h" - -#include -#include "mitkMaskImageFilter.h" -#include "mitkAutoCropImageFilter.h" -#include "mitkSurface.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -namespace mitk -{ - -class MitkExt_EXPORT VolumeVisualizationImagePreprocessor : public itk::Object -{ -public: - - mitkClassMacro(VolumeVisualizationImagePreprocessor, itk::Object); - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - - mitk::Image::Pointer Process( mitk::Image::Pointer originalCT, - mitk::Image::Pointer originalLiverMask ); - - - double GetEstimatedThreshold() const - { - return m_EstimatedThreshold; - } - - double GetMinThreshold() const - { - return m_MinThreshold; - } - - double GetMaxThreshold() const - { - return m_MaxThreshold; - } - - double GetLastUsedThreshold() const - { - return m_LastUsedTreshold; - } - - mitk::TransferFunction::Pointer GetInitialTransferFunction( ); - void UpdateTransferFunction( mitk::TransferFunction::Pointer tf , int treshold ); - - -protected: - - typedef itk::Image CTImage; - typedef itk::ImageRegionIterator< CTImage > CTIteratorType; - typedef itk::ImageRegionIteratorWithIndex< CTImage > CTIteratorIndexType; - - typedef itk::Image BinImage; - typedef itk::ImageRegionIterator< BinImage > BinIteratorType; - typedef itk::ImageRegionIteratorWithIndex< BinImage > BinIteratorIndexType; - - typedef itk::Image LabelImage; - typedef itk::ImageRegionIterator< LabelImage > LabelIteratorType; - - - VolumeVisualizationImagePreprocessor(); - - ~VolumeVisualizationImagePreprocessor(); - - - CTImage::Pointer Composite( CTImage::Pointer work, - BinImage::Pointer mask, - BinImage::Pointer dilated, - BinImage::Pointer eroded ); - - - void DetermineBoundingBox( BinImage::Pointer mask ); - - CTImage::Pointer Crop(CTImage::Pointer src ); - BinImage::Pointer Crop(BinImage::Pointer src ); - - - - - /**the original mask is decrease by 1 Voxel*/ - BinImage::Pointer Dilate(BinImage::Pointer src); - BinImage::Pointer Erode(BinImage::Pointer src); - CTImage::Pointer Gaussian(CTImage::Pointer src); - LabelImage::Pointer ConnectComponents(BinImage::Pointer src); - LabelImage::Pointer RelabelComponents(LabelImage::Pointer src); - BinImage::Pointer Threshold(CTImage::Pointer src, int threshold); - - - - - // grayvalue of voxel out of liver - double m_OutOfLiverValue; - - // grayvalue liver surface will be set to - double m_surfaceValue; - - // average of all grayvalues located on the liver surface - double m_realSurfaceValue; - - double m_realInLiverValue; - - //estimated treshold value - double m_EstimatedThreshold; - - double m_GreatestStructureThreshold; - - - //minimum treshold value - double m_MinThreshold; - - //maximum treshold value - double m_MaxThreshold; - - int m_MinX; - int m_MinY; - int m_MinZ; - - int m_MaxX; - int m_MaxY; - int m_MaxZ; - - int m_LastUsedTreshold; - - int histogramm[65536]; - int total; - - - int GetHistogrammValueFromTop( double part ); - int GetHistogrammValueFromBottom( double part ); - - -}; - - -} - -#endif // #define mitkVolumeVisualizationImagePreprocessor_h_include diff --git a/Modules/Ext/Algorithms/mitkvtkImageStencilRaster.h b/Modules/Ext/Algorithms/mitkvtkImageStencilRaster.h deleted file mode 100644 index 9e6ee0088b..0000000000 --- a/Modules/Ext/Algorithms/mitkvtkImageStencilRaster.h +++ /dev/null @@ -1,113 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkImageStencilData.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -// .NAME vtkImageStencilData - efficient description of an image stencil -// .SECTION Description -// vtkImageStencilData describes an image stencil in a manner which is -// efficient both in terms of speed and storage space. The stencil extents -// are stored for each x-row across the image (multiple extents per row if -// necessary) and can be retrieved via the GetNextExtent() method. -// .SECTION see also -// vtkImageStencilSource vtkImageStencil - -#ifndef __vtkImageStencilRaster_h -#define __vtkImageStencilRaster_h - -#include "vtkImageStencilData.h" -#include "vtkDataObject.h" -#include "MitkExtExports.h" - - -//BTX -// Description: -// This is a helper class for stencil creation. It is a raster with -// infinite resolution in the X direction (approximately, since it uses -// double precision). Lines that represent polygon edges can be drawn -// into this raster, and then filled given a tolerance. -class MitkExt_EXPORT vtkImageStencilRaster -{ -public: - // Description: - // Create a raster with the specified whole y extent. - vtkImageStencilRaster(const int wholeExtent[2]); - - // Description: - // Destructor. - ~vtkImageStencilRaster(); - - // Description: - // Reset the raster to its original state, but keep the same whole - // extent. Pre-allocate the specified 1D allocateExtent, which must be - // within the whole extent. - void PrepareForNewData(const int allocateExtent[2] = 0); - - // Description: - // Insert a line into the raster, given the two end points. - // The "inflect1" and "inflect2" should be set if you want - // to add a small vertical tolerance to either endpoints. - void InsertLine(const double p1[2], const double p2[2], - bool inflect1, bool inflect2); - - // Description: - // Fill the specified extent of a vtkImageStencilData with the raster, - // after permuting the raster according to xj and yj. - void FillStencilData(vtkImageStencilData *data, const int extent[6], - int xj = 0, int yj = 1); - - // Description: - // The tolerance for float-to-int conversions. - void SetTolerance(double tol) { this->Tolerance = tol; } - double GetTolerance() { return this->Tolerance; } - -protected: - // Description: - // Ensure that the raster is initialized for the specified range - // of y values, which must be within the Extent. - void PrepareExtent(int ymin, int ymax); - - // Description: - // Insert an x point into the raster. If the y value is larger - // than the y extent, the extent will grow automatically. - void InsertPoint(int y, double x); - - int Extent[2]; - int UsedExtent[2]; - double **Raster; - double Tolerance; - -private: - vtkImageStencilRaster(const vtkImageStencilRaster&); // Not implemented. - void operator=(const vtkImageStencilRaster&); // Not implemented. -}; -//ETX - -#endif - - - diff --git a/Modules/Ext/Algorithms/mitkvtkLassoStencilSource.h b/Modules/Ext/Algorithms/mitkvtkLassoStencilSource.h deleted file mode 100644 index 89d70d21a1..0000000000 --- a/Modules/Ext/Algorithms/mitkvtkLassoStencilSource.h +++ /dev/null @@ -1,122 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkLassoStencilSource.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -// .NAME vtkLassoStencilSource - Create a stencil from a contour -// .SECTION Description -// vtkLassoStencilSource will create an image stencil from a -// set of points that define a contour. Its output can be -// used with vtkImageStecil or other vtk classes that apply -// a stencil to an image. -// .SECTION See Also -// vtkROIStencilSource vtkPolyDataToImageStencil -// .SECTION Thanks -// Thanks to David Gobbi for contributing this class to VTK. - -#ifndef __vtkLassoStencilSource_h -#define __vtkLassoStencilSource_h - - -#include "vtkImageStencilSource.h" -#include "MitkExtExports.h" - -class vtkPoints; -class vtkSpline; -class vtkLSSPointMap; - -class MitkExt_EXPORT vtkLassoStencilSource : public vtkImageStencilSource -{ -public: - static vtkLassoStencilSource *New(); - vtkTypeMacro(vtkLassoStencilSource, vtkImageStencilSource); - void PrintSelf(ostream& os, vtkIndent indent); - -//BTX - enum { - POLYGON = 0, - SPLINE = 1, - }; -//ETX - - // Description: - // The shape to use, default is "Polygon". The spline is a - // cardinal spline. Bezier splines are not yet supported. - vtkGetMacro(Shape, int); - vtkSetClampMacro(Shape, int, POLYGON, SPLINE); - void SetShapeToPolygon() { this->SetShape(POLYGON); }; - void SetShapeToSpline() { this->SetShape(SPLINE); }; - virtual const char *GetShapeAsString(); - - // Description: - // The points that make up the lassoo. The loop does not - // have to be closed, the last point will automatically be - // connected to the first point by a straight line segment. - virtual void SetPoints(vtkPoints *points); - vtkGetObjectMacro(Points, vtkPoints); - - // Description: - // The slice orientation. The default is 2, which is XY. - // Other values are 0, which is YZ, and 1, which is XZ. - vtkGetMacro(SliceOrientation, int); - vtkSetClampMacro(SliceOrientation, int, 0, 2); - - // Description: - // The points for a particular slice. This will override the - // points that were set by calling SetPoints() for the slice. - // To clear the setting, call SetSlicePoints(slice, NULL). - virtual void SetSlicePoints(int i, vtkPoints *points); - virtual vtkPoints *GetSlicePoints(int i); - - // Description: - // Remove points from all slices. - virtual void RemoveAllSlicePoints(); - - // Description: - // Overload GetMTime() to include the timestamp on the points. - unsigned long GetMTime(); - -protected: - vtkLassoStencilSource(); - ~vtkLassoStencilSource(); - - virtual int RequestData(vtkInformation *, vtkInformationVector **, - vtkInformationVector *); - - int Shape; - int SliceOrientation; - vtkPoints *Points; - vtkSpline *SplineX; - vtkSpline *SplineY; - vtkLSSPointMap *PointMap; - -private: - vtkLassoStencilSource(const vtkLassoStencilSource&); // Not implemented. - void operator=(const vtkLassoStencilSource&); // Not implemented. -}; - -#endif diff --git a/Modules/Ext/Algorithms/vtkImageStencilRaster.cxx b/Modules/Ext/Algorithms/vtkImageStencilRaster.cxx deleted file mode 100644 index 43d62a862c..0000000000 --- a/Modules/Ext/Algorithms/vtkImageStencilRaster.cxx +++ /dev/null @@ -1,453 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkImageStencilData.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -#include "mitkvtkImageStencilRaster.h" - -#include "vtkImageStencilSource.h" -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkDemandDrivenPipeline.h" -#include "vtkDataSetAttributes.h" -#include "vtkDataArray.h" -#include "vtkObjectFactory.h" -#include "vtkMath.h" - -#include -#include - -//---------------------------------------------------------------------------- -// tolerance for float-to-int conversion in stencil operations - -#define VTK_STENCIL_TOL 7.62939453125e-06 - -//---------------------------------------------------------------------------- -vtkImageStencilRaster::vtkImageStencilRaster(const int extent[2]) -{ - int rsize = extent[1] - extent[0] + 1; - - // the "raster" is a sequence of pointer-pairs, where the first pointer - // points to the first value in the raster line, and the second pointer - // points to one location past the last vale in the raster line. The - // difference is the number of x values stored in the raster line. - this->Raster = new double*[2*static_cast(rsize)]; - - // the extent is the range of y values (one line per y) - this->Extent[0] = extent[0]; - this->Extent[1] = extent[1]; - - // tolerance should be larger than expected roundoff errors - this->Tolerance = VTK_STENCIL_TOL; - - // no extent is used initially - this->UsedExtent[0] = 0; - this->UsedExtent[1] = -1; -} - -//---------------------------------------------------------------------------- -vtkImageStencilRaster::~vtkImageStencilRaster() -{ - if (this->UsedExtent[1] >= this->UsedExtent[0]) - { - size_t i = 2*static_cast(this->UsedExtent[0] - this->Extent[0]); - size_t imax = 2*static_cast(this->UsedExtent[1] - this->Extent[0]); - - do - { - if (this->Raster[i]) - { - delete [] this->Raster[i]; - } - i += 2; - } - while (i <= imax); - } - delete [] this->Raster; -} - -//---------------------------------------------------------------------------- -void vtkImageStencilRaster::PrepareForNewData(const int allocateExtent[2]) -{ - if (this->UsedExtent[1] >= this->UsedExtent[0]) - { - // reset and re-use the allocated raster lines - size_t i = 2*static_cast(this->UsedExtent[0]-this->Extent[0]); - size_t imax=2*static_cast(this->UsedExtent[1]-this->Extent[0]); - do - { - this->Raster[i+1] = this->Raster[i]; - i += 2; - } - while (i <= imax); - } - - if (allocateExtent && allocateExtent[1] >= allocateExtent[1]) - { - this->PrepareExtent(allocateExtent[0], allocateExtent[1]); - } -} - -//---------------------------------------------------------------------------- -void vtkImageStencilRaster::PrepareExtent(int ymin, int ymax) -{ - // this does not do any allocation, it just initializes any - // raster lines are not already part of the UsedExtent, and - // then expands the UsedExtent to include [ymin, ymax] - - if (this->UsedExtent[1] < this->UsedExtent[0]) - { - size_t i = 2*static_cast(ymin - this->Extent[0]); - size_t imax = 2*static_cast(ymax - this->Extent[0]); - - do - { - this->Raster[i] = 0; - } - while (++i <= imax); - - this->UsedExtent[0] = ymin; - this->UsedExtent[1] = ymax; - - return; - } - - if (ymin < this->UsedExtent[0]) - { - size_t i = 2*static_cast(ymin - this->Extent[0]); - size_t imax = 2*static_cast(this->UsedExtent[0]-this->Extent[0]-1); - - do - { - this->Raster[i] = 0; - } - while (++i <= imax); - - this->UsedExtent[0] = ymin; - } - - if (ymax > this->UsedExtent[1]) - { - size_t i = 2*static_cast(this->UsedExtent[1]+1 - this->Extent[0]); - size_t imax = 2*static_cast(ymax - this->Extent[0]); - - do - { - this->Raster[i] = 0; - } - while (++i <= imax); - - this->UsedExtent[1] = ymax; - } -} - -//---------------------------------------------------------------------------- -void vtkImageStencilRaster::InsertPoint(int y, double x) -{ - size_t pos = 2*static_cast(y - this->Extent[0]); - double* &rhead = this->Raster[pos]; - double* &rtail = this->Raster[pos+1]; - - // current size is the diff between the tail and the head - size_t n = rtail - rhead; - - // no allocation on this raster line yet - if (rhead == 0) - { - rhead = new double[2]; - rtail = rhead; - } - // grow whenever size reaches a power of two - else if (n > 1 && (n & (n-1)) == 0) - { - double *ptr = new double[2*n]; - for (size_t i = 0; i < n; i++) - { - ptr[i] = rhead[i]; - } - delete [] rhead; - rhead = ptr; - rtail = ptr + n; - } - - // insert the value - *rtail++ = x; -} - -//---------------------------------------------------------------------------- -void vtkImageStencilRaster::InsertLine( - const double pt1[2], const double pt2[2], - bool inflection1, bool inflection2) -{ - double x1 = pt1[0]; - double x2 = pt2[0]; - double y1 = pt1[1]; - double y2 = pt2[1]; - - // swap end points if necessary - if (y1 > y2) - { - x1 = pt2[0]; - x2 = pt1[0]; - y1 = pt2[1]; - y2 = pt1[1]; - bool tmp = inflection1; - inflection1 = inflection2; - inflection2 = tmp; - } - - // find min and max of x values - double xmin = x1; - double xmax = x2; - if (x1 > x2) - { - xmin = x2; - xmax = x1; - } - - // check for parallel to the x-axis - if (y1 == y2) - { - return; - } - - double ymin = y1; - double ymax = y2; - - // if an end is an inflection point, include a tolerance - ymin -= inflection1*this->Tolerance; - ymax += inflection2*this->Tolerance; - - // Integer y values for start and end of line - int iy1, iy2; - iy1 = this->Extent[0]; - iy2 = this->Extent[1]; - - // Check for out of bounds - if (ymax < iy1 || ymin >= iy2) - { - return; - } - - // Guard against extentY - if (ymin >= iy1) - { - iy1 = vtkMath::Floor(ymin) + 1; - } - if (ymax < iy2) - { - iy2 = vtkMath::Floor(ymax); - } - - // Expand allocated extent if necessary - if (iy1 < this->UsedExtent[0] || - iy2 > this->UsedExtent[1]) - { - this->PrepareExtent(iy1, iy2); - } - - // Precompute values for a Bresenham-like line algorithm - double grad = (x2 - x1)/(y2 - y1); - double delta = (iy1 - y1)*grad; - - // Go along y and place each x in the proper raster line - for (int y = iy1; y <= iy2; y++) - { - double x = x1 + delta; - // incrementing delta has less roundoff error than incrementing x, - // since delta will typically be smaller than x - delta += grad; - - // clamp x (because of tolerance, it might not be in range) - if (x < xmin) - { - x = xmin; - } - else if (x > xmax) - { - x = xmax; - } - - this->InsertPoint(y, x); - } -} - -//---------------------------------------------------------------------------- -void vtkImageStencilRaster::FillStencilData( - vtkImageStencilData *data, const int extent[6], int xj, int yj) -{ - if (xj != 0) - { - // slices are stacked in the x direction - int xmin = extent[2*xj]; - int xmax = extent[2*xj+1]; - int ymin = this->UsedExtent[0]; - int ymax = this->UsedExtent[1]; - int zmin = extent[0]; - int zmax = extent[1]; - - for (int idY = ymin; idY <= ymax; idY++) - { - size_t pos = 2*static_cast(idY - this->Extent[0]); - double *rline = this->Raster[pos]; - double *rlineEnd = this->Raster[pos+1]; - - if (rline == 0) - { - continue; - } - - vtkstd::sort(rline, rlineEnd); - - int xy[2]; - xy[2-xj] = idY; - - int lastr = VTK_INT_MIN; - - size_t l = rlineEnd - rline; - l = l - (l & 1); // force l to be an even number - for (size_t k = 0; k < l; k += 2) - { - double x1 = rline[k] - this->Tolerance; - double x2 = rline[k+1] + this->Tolerance; - - // make sure one of the ends is in bounds - if (x2 < xmin || x1 >= xmax) - { - continue; - } - - // clip the line segment with the bounds - int r1 = xmin; - int r2 = xmax; - - if (x1 >= xmin) - { - r1 = vtkMath::Floor(x1) + 1; - } - if (x2 < xmax) - { - r2 = vtkMath::Floor(x2); - } - - // ensure no overlap occurs with previous - if (r1 <= lastr) - { - r1 = lastr + 1; - } - lastr = r2; - - for (int idX = r1; idX <= r2; idX++) - { - xy[xj-1] = idX; - data->InsertNextExtent(zmin, zmax, xy[0], xy[1]); - } - } - } - } - else - { - // slices stacked in the y or z direction - int zj = 3 - yj; - int xmin = extent[0]; - int xmax = extent[1]; - int ymin = this->UsedExtent[0]; - int ymax = this->UsedExtent[1]; - int zmin = extent[2*zj]; - int zmax = extent[2*zj+1]; - - // convert each raster line into extents for the stencil - for (int idY = ymin; idY <= ymax; idY++) - { - size_t pos = 2*static_cast(idY - this->Extent[0]); - double *rline = this->Raster[pos]; - double *rlineEnd = this->Raster[pos+1]; - - if (rline == 0) - { - continue; - } - - vtkstd::sort(rline, rlineEnd); - - int lastr = VTK_INT_MIN; - - // go through each raster line and fill the stencil - size_t l = rlineEnd - rline; - l = l - (l & 1); // force l to be an even number - for (size_t k = 0; k < l; k += 2) - { - int yz[2]; - - yz[yj-1] = idY; - yz[2-yj] = zmin; - - double x1 = rline[k] - this->Tolerance; - double x2 = rline[k+1] + this->Tolerance; - - if (x2 < xmin || x1 >= xmax) - { - continue; - } - - int r1 = xmin; - int r2 = xmax; - - if (x1 >= xmin) - { - r1 = vtkMath::Floor(x1) + 1; - } - if (x2 < xmax) - { - r2 = vtkMath::Floor(x2); - } - - // ensure no overlap occurs between extents - if (r1 <= lastr) - { - r1 = lastr + 1; - } - lastr = r2; - - if (r2 >= r1) - { - data->InsertNextExtent(r1, r2, yz[0], yz[1]); - } - } - } - - // copy the result to all other slices - if (zmin < zmax) - { - for (int idY = ymin; idY <= ymax; idY++) - { - int r1, r2; - int yz[2]; - - yz[yj-1] = idY; - yz[2-yj] = zmin; - - int iter = 0; - while (data->GetNextExtent(r1, r2, xmin, xmax, yz[0], yz[1], iter)) - { - for (int idZ = zmin + 1; idZ <= zmax; idZ++) - { - yz[2-yj] = idZ; - data->InsertNextExtent(r1, r2, yz[0], yz[1]); - } - yz[2-yj] = zmin; - } - } - } - } -} diff --git a/Modules/Ext/Algorithms/vtkLassoStencilSource.cxx b/Modules/Ext/Algorithms/vtkLassoStencilSource.cxx deleted file mode 100644 index e86d4ad535..0000000000 --- a/Modules/Ext/Algorithms/vtkLassoStencilSource.cxx +++ /dev/null @@ -1,610 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkLassoStencilSource.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -#include "mitkvtkLassoStencilSource.h" - -#include "vtkMath.h" -#include "vtkPoints.h" -#include "vtkCardinalSpline.h" -#include "vtkDataArray.h" -#include "vtkImageData.h" -#include "vtkImageStencilData.h" -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkObjectFactory.h" -#include "vtkStreamingDemandDrivenPipeline.h" -#include "vtkSmartPointer.h" - -#include "mitkvtkImageStencilRaster.h" - -#include -#include - -vtkStandardNewMacro(vtkLassoStencilSource); -vtkCxxSetObjectMacro(vtkLassoStencilSource, Points, vtkPoints); - -//---------------------------------------------------------------------------- -class vtkLSSPointMap : public vtkstd::map > -{ -}; - -//---------------------------------------------------------------------------- -vtkLassoStencilSource::vtkLassoStencilSource() -{ - this->SetNumberOfInputPorts(0); - - this->Shape = vtkLassoStencilSource::POLYGON; - this->SliceOrientation = 2; - this->Points = NULL; - this->SplineX = vtkCardinalSpline::New(); - this->SplineY = vtkCardinalSpline::New(); - - this->PointMap = new vtkLSSPointMap(); -} - -//---------------------------------------------------------------------------- -vtkLassoStencilSource::~vtkLassoStencilSource() -{ - this->SetPoints(NULL); - if (this->SplineX) - { - this->SplineX->Delete(); - this->SplineX = NULL; - } - if (this->SplineY) - { - this->SplineY->Delete(); - this->SplineY = NULL; - } - if (this->PointMap) - { - delete this->PointMap; - this->PointMap = NULL; - } -} - -//---------------------------------------------------------------------------- -void vtkLassoStencilSource::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); - - os << indent << "Shape: " << this->GetShapeAsString() << "\n"; - os << indent << "Points: " << this->Points << "\n"; - os << indent << "SliceOrientation: " << this->GetSliceOrientation() << "\n"; - os << indent << "SlicePoints: " << this->PointMap->size() << "\n"; -} - -//---------------------------------------------------------------------------- -const char *vtkLassoStencilSource::GetShapeAsString() -{ - switch (this->Shape) - { - case vtkLassoStencilSource::POLYGON: - return "Polygon"; - case vtkLassoStencilSource::SPLINE: - return "Spline"; - } - return ""; -} - -//---------------------------------------------------------------------------- -unsigned long int vtkLassoStencilSource::GetMTime() -{ - unsigned long mTime = this->vtkImageStencilSource::GetMTime(); - - if ( this->Points != NULL ) - { - unsigned long t = this->Points->GetMTime(); - if (t > mTime) - { - mTime = t; - } - } - - if ( !this->PointMap->empty() ) - { - vtkLSSPointMap::iterator iter = this->PointMap->begin(); - while ( iter != this->PointMap->end() ) - { - unsigned long t = iter->second->GetMTime(); - if (t > mTime) - { - mTime = t; - } - iter++; - } - } - - return mTime; -} - -//---------------------------------------------------------------------------- -void vtkLassoStencilSource::SetSlicePoints(int i, vtkPoints *points) -{ - vtkLSSPointMap::iterator iter = this->PointMap->find(i); - if (iter != this->PointMap->end()) - { - if (iter->second == points) - { - return; - } - else if (points == 0) - { - this->PointMap->erase(iter); - } - else - { - iter->second = points; - } - } - else - { - if (points == NULL) - { - return; - } - else - { - this->PointMap->insert(iter, vtkLSSPointMap::value_type(i, points)); - } - } - - this->Modified(); -} - -//---------------------------------------------------------------------------- -void vtkLassoStencilSource::RemoveAllSlicePoints() -{ - this->PointMap->clear(); -} - -//---------------------------------------------------------------------------- -vtkPoints *vtkLassoStencilSource::GetSlicePoints(int i) -{ - vtkLSSPointMap::iterator iter = this->PointMap->find(i); - if (iter != this->PointMap->end()) - { - return iter->second; - } - return NULL; -} - -//---------------------------------------------------------------------------- -// tolerance for stencil operations - -#define VTK_STENCIL_TOL 7.62939453125e-06 - -//---------------------------------------------------------------------------- -// Compute a reduced extent based on the bounds of the shape. -static void vtkLassoStencilSourceSubExtent( - vtkPoints *points, - const double origin[3], const double spacing[3], - const int extent[6], int subextent[6]) -{ - double bounds[6]; - points->GetBounds(bounds); - - for (int i = 0; i < 3; i++) - { - double emin = (bounds[2*i] - origin[i])/spacing[i] - VTK_STENCIL_TOL; - double emax = (bounds[2*i+1] - origin[i])/spacing[i] + VTK_STENCIL_TOL; - - subextent[2*i] = extent[2*i]; - subextent[2*i+1] = extent[2*i+1]; - - if (extent[2*i] < emin) - { - subextent[2*i] = VTK_INT_MAX; - if (extent[2*i+1] >= emin) - { - subextent[2*i] = vtkMath::Floor(emin) + 1; - } - } - - if (extent[2*i+1] > emax) - { - subextent[2*i+1] = VTK_INT_MIN; - if (extent[2*i] <= emax) - { - subextent[2*i+1] = vtkMath::Floor(emax); - } - } - - } -} - -//---------------------------------------------------------------------------- -// Rasterize a polygon into the stencil -static int vtkLassoStencilSourcePolygon( - vtkPoints *points, vtkImageStencilData *data, vtkImageStencilRaster *raster, - const int extent[6], const double origin[3], const double spacing[3], - int xj, int yj) -{ - // get the bounds of the polygon - int subextent[6]; - vtkLassoStencilSourceSubExtent(points, origin, spacing, extent, subextent); - - // allocate the raster - raster->PrepareForNewData(&subextent[2*yj]); - - // rasterize each line - vtkIdType n = points->GetNumberOfPoints(); - double p[3]; - double p0[2], p1[2], p2[2], p3[2]; - - points->GetPoint(n-1, p); - p0[0] = (p[xj] - origin[xj])/spacing[xj]; - p0[1] = (p[yj] - origin[yj])/spacing[yj]; - - points->GetPoint(0, p); - p1[0] = (p[xj] - origin[xj])/spacing[xj]; - p1[1] = (p[yj] - origin[yj])/spacing[yj]; - - double dx = p1[0] - p0[0]; - double dy = p1[1] - p0[1]; - if (dx*dx + dy*dy <= VTK_STENCIL_TOL*VTK_STENCIL_TOL) - { - n -= 1; - points->GetPoint(n-1, p); - p0[0] = (p[xj] - origin[xj])/spacing[xj]; - p0[1] = (p[yj] - origin[yj])/spacing[yj]; - } - - points->GetPoint(1, p); - p2[0] = (p[xj] - origin[xj])/spacing[xj]; - p2[1] = (p[yj] - origin[yj])/spacing[yj]; - - // inflection means the line changes vertical direction - bool inflection1, inflection2; - inflection1 = ( (p1[1] - p0[1])*(p2[1] - p1[1]) <= 0 ); - - for (vtkIdType i = 0; i < n; i++) - { - points->GetPoint((i+2)%n, p); - p3[0] = (p[xj] - origin[xj])/spacing[xj]; - p3[1] = (p[yj] - origin[yj])/spacing[yj]; - - inflection2 = ( (p2[1] - p1[1])*(p3[1] - p2[1]) <= 0 ); - - raster->InsertLine(p1, p2, inflection1, inflection2); - - p0[0] = p1[0]; p0[1] = p1[1]; - p1[0] = p2[0]; p1[1] = p2[1]; - p2[0] = p3[0]; p2[1] = p3[1]; - inflection1 = inflection2; - } - - raster->FillStencilData(data, extent, xj, yj); - - return 1; -} - - -//---------------------------------------------------------------------------- -// Generate the splines for the given set of points. The splines -// will be closed if the final point is equal to the first point. -// The parametric value for the resulting spline will be valid over -// the range [0, tmax] where the tmax value is returned by reference. -static void vtkLassoStencilSourceCreateSpline(vtkPoints *points, - const double origin[3], const double spacing[3], - int xj, int yj, vtkSpline *xspline, vtkSpline *yspline, - double &tmax, double &dmax) -{ - // initialize the spline - xspline->RemoveAllPoints(); - yspline->RemoveAllPoints(); - xspline->ClosedOff(); - yspline->ClosedOff(); - - // get the number of points and the first/last point - vtkIdType n = points->GetNumberOfPoints(); - double p[3]; - double p0[2], p1[2]; - - points->GetPoint(n-1, p); - p0[0] = (p[xj] - origin[xj])/spacing[xj]; - p0[1] = (p[yj] - origin[yj])/spacing[yj]; - - points->GetPoint(0, p); - p1[0] = (p[xj] - origin[xj])/spacing[xj]; - p1[1] = (p[yj] - origin[yj])/spacing[yj]; - - // factor between real distance and parametric distance - double f = 1.0; - // the length of the implicit segment for closed loops - double lastd = 0; - - // aspect ratio - double xf = 1.0; - double yf = 1.0; - if (spacing[xj] > spacing[yj]) - { - xf = spacing[xj]/spacing[yj]; - } - else - { - yf = spacing[yj]/spacing[xj]; - } - - // if first and last point are same, spline is closed - double dx = (p1[0] - p0[0])*xf; - double dy = (p1[1] - p0[1])*yf; - double d2 = dx*dx + dy*dy; - while (d2 <= VTK_STENCIL_TOL*VTK_STENCIL_TOL && n > 1) - { - n -= 1; - points->GetPoint(n-1, p); - p0[0] = (p[xj] - origin[xj])/spacing[xj]; - p0[1] = (p[yj] - origin[yj])/spacing[yj]; - - xspline->ClosedOn(); - yspline->ClosedOn(); - - // vtkSpline considers the parametric length of the implicit - // segment of closed loops to be unity, so set "f" so that - // multiplying the real length of that segment by "f" gives unity. - dx = (p1[0] - p0[0])*xf; - dy = (p1[1] - p0[1])*yf; - d2 = dx*dx + dy*dy; - lastd = sqrt(d2); - if (lastd > 0) - { - f = 1.0/lastd; - } - } - - // Add all the points to the spline. - double d = 0.0; - for (vtkIdType i = 0; i < n; i++) - { - p0[0] = p1[0]; p0[1] = p1[1]; - - points->GetPoint(i, p); - p1[0] = (p[xj] - origin[xj])/spacing[xj]; - p1[1] = (p[yj] - origin[yj])/spacing[yj]; - - dx = (p1[0] - p0[0])*xf; - dy = (p1[1] - p0[1])*yf; - - d += sqrt(dx*dx + dy*dy); - - double t = f*d; - - xspline->AddPoint(t, p1[0]); - yspline->AddPoint(t, p1[1]); - } - - // Do the spline precomputations - xspline->Compute(); - yspline->Compute(); - - // The spline is valid over t = [0, tmax] - d += lastd; - tmax = f*d; - dmax = d; -} - -//---------------------------------------------------------------------------- -// Rasterize a spline contour into the stencil -static int vtkLassoStencilSourceSpline( - vtkPoints *points, vtkImageStencilData *data, vtkImageStencilRaster *raster, - const int extent[6], const double origin[3], const double spacing[3], - int xj, int yj, vtkSpline *xspline, vtkSpline *yspline) -{ - // create the splines - double tmax, dmax; - vtkLassoStencilSourceCreateSpline( - points, origin, spacing, xj, yj, xspline, yspline, tmax, dmax); - - if (dmax <= VTK_STENCIL_TOL) - { - return 1; - } - - // get the bounds of the polygon as a first guess of the spline bounds - int subextent[6]; - vtkLassoStencilSourceSubExtent(points, origin, spacing, extent, subextent); - - // allocate the raster - raster->PrepareForNewData(&subextent[2*yj]); - - // go around the spline - vtkIdType n = vtkMath::Floor(dmax)+1; - double delta = tmax/n; - - double p0[2], p1[2], p2[2], p3[2]; - - double t = tmax; - if (xspline->GetClosed()) - { - t = (n-1)*tmax/n; - } - else - { - n = n + 1; - } - - p0[0] = xspline->Evaluate(t); - p0[1] = yspline->Evaluate(t); - - t = 0; - p1[0] = xspline->Evaluate(t); - p1[1] = yspline->Evaluate(t); - - t = delta; - p2[0] = xspline->Evaluate(t); - p2[1] = yspline->Evaluate(t); - - // inflection means the line changes vertical direction - bool inflection1, inflection2; - inflection1 = ( (p1[1] - p0[1])*(p2[1] - p1[1]) <= 0 ); - - for (vtkIdType i = 0; i < n; i++) - { - t += delta; - if (i == n-2) - { - t = 0; - } - - p3[0] = xspline->Evaluate(t); - p3[1] = yspline->Evaluate(t); - - inflection2 = ( (p2[1] - p1[1])*(p3[1] - p2[1]) <= 0 ); - - raster->InsertLine(p1, p2, inflection1, inflection2); - - p0[0] = p1[0]; p0[1] = p1[1]; - p1[0] = p2[0]; p1[1] = p2[1]; - p2[0] = p3[0]; p2[1] = p3[1]; - inflection1 = inflection2; - } - - raster->FillStencilData(data, extent, xj, yj); - - return 1; -} - -//---------------------------------------------------------------------------- -static int vtkLassoStencilSourceExecute( - vtkPoints *points, vtkImageStencilData *data, vtkImageStencilRaster *raster, - int extent[6], double origin[3], double spacing[3], int shape, - int xj, int yj, vtkSpline *xspline, vtkSpline *yspline) -{ - int result = 1; - - if (points == 0 || points->GetNumberOfPoints() < 3) - { - return 1; - } - - switch (shape) - { - case vtkLassoStencilSource::POLYGON: - result = vtkLassoStencilSourcePolygon( - points, data, raster, extent, origin, spacing, xj, yj); - break; - case vtkLassoStencilSource::SPLINE: - result = vtkLassoStencilSourceSpline( - points, data, raster, extent, origin, spacing, xj, yj, - xspline, yspline); - break; - } - - return result; -} - - -//---------------------------------------------------------------------------- -int vtkLassoStencilSource::RequestData( - vtkInformation *request, - vtkInformationVector **inputVector, - vtkInformationVector *outputVector) -{ - int extent[6]; - double origin[3]; - double spacing[3]; - int result = 1; - - this->Superclass::RequestData(request, inputVector, outputVector); - - vtkInformation *outInfo = outputVector->GetInformationObject(0); - vtkImageStencilData *data = vtkImageStencilData::SafeDownCast( - outInfo->Get(vtkDataObject::DATA_OBJECT())); - - outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(), extent); - outInfo->Get(vtkDataObject::ORIGIN(), origin); - outInfo->Get(vtkDataObject::SPACING(), spacing); - - int slabExtent[6]; - slabExtent[0] = extent[0]; slabExtent[1] = extent[1]; - slabExtent[2] = extent[2]; slabExtent[3] = extent[3]; - slabExtent[4] = extent[4]; slabExtent[5] = extent[5]; - - int xj = 0; - int yj = 1; - int zj = 2; - - if (this->SliceOrientation == 0) - { - xj = 1; - yj = 2; - zj = 0; - } - else if (this->SliceOrientation == 1) - { - xj = 0; - yj = 2; - zj = 1; - } - - vtkImageStencilRaster raster(&extent[2*yj]); - raster.SetTolerance(VTK_STENCIL_TOL); - - int zmin = extent[2*zj]; - int zmax = extent[2*zj+1]; - - vtkLSSPointMap::iterator iter = this->PointMap->lower_bound(zmin); - vtkLSSPointMap::iterator maxiter = this->PointMap->upper_bound(zmax); - - while (iter != maxiter && result != 0) - { - this->SetProgress((slabExtent[2*zj] - zmin)*1.0/(zmax - zmin + 1)); - - int i = iter->first; - vtkPoints *points = iter->second; - - // fill in the slices with no SlicePoints - if (this->Points && i > slabExtent[2*zj]) - { - slabExtent[2*zj+1] = i-1; - - result = vtkLassoStencilSourceExecute( - this->Points, data, &raster, slabExtent, origin, spacing, - this->Shape, xj, yj, this->SplineX, this->SplineY); - } - - // do the slice with its SlicePoints - if (result) - { - slabExtent[2*zj] = i; - slabExtent[2*zj+1] = i; - - result = vtkLassoStencilSourceExecute( - points, data, &raster, slabExtent, origin, spacing, - this->Shape, xj, yj, this->SplineX, this->SplineY); - - slabExtent[2*zj] = slabExtent[2*zj+1] + 1; - } - - ++iter; - } - - this->SetProgress((slabExtent[2*zj] - zmin)*1.0/(zmax - zmin + 1)); - - // fill in the rest - if (result && slabExtent[2*zj] <= zmax) - { - slabExtent[2*zj+1] = zmax; - - result = vtkLassoStencilSourceExecute( - this->Points, data, &raster, slabExtent, origin, spacing, - this->Shape, xj, yj, this->SplineX, this->SplineY); - - this->SetProgress(1.0); - } - - return result; -} diff --git a/Modules/Ext/Algorithms/vtkPointSetSlicer.cxx b/Modules/Ext/Algorithms/vtkPointSetSlicer.cxx deleted file mode 100644 index 9b816fc9da..0000000000 --- a/Modules/Ext/Algorithms/vtkPointSetSlicer.cxx +++ /dev/null @@ -1,818 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#include -#include - -#include "vtkPointSetSlicer.h" - -#include "vtkCellArray.h" -#include "vtkCellData.h" -#include "vtkDataSet.h" -#include "vtkDoubleArray.h" -#include "vtkFloatArray.h" -#include "vtkGenericCell.h" -#include "vtkMergePoints.h" -#include "vtkObjectFactory.h" -#include "vtkPointData.h" -#include "vtkPolyData.h" -#include "vtkPlane.h" -#include "vtkCutter.h" - -#include "vtkUnstructuredGrid.h" - -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkStreamingDemandDrivenPipeline.h" - -vtkStandardNewMacro(vtkPointSetSlicer); - -// Construct with user-specified implicit function; initial value of 0.0; and -// generating cut scalars turned off. -vtkPointSetSlicer::vtkPointSetSlicer(vtkPlane *cf) -{ - this->SlicePlane = cf; - this->GenerateCutScalars = 0; - this->Locator = 0; - - this->Cutter = vtkCutter::New(); - this->Cutter->GenerateValues( 1, 0, 1 ); - -} - -vtkPointSetSlicer::~vtkPointSetSlicer() -{ - this->SetSlicePlane(0); - if ( this->Locator ) - { - this->Locator->UnRegister(this); - this->Locator = NULL; - } - - this->Cutter->Delete(); -} - -void vtkPointSetSlicer::SetSlicePlane(vtkPlane* plane) -{ - if ( this->SlicePlane == plane ) - { - return; - } - if ( this->SlicePlane ) - { - this->SlicePlane->UnRegister(this); - this->SlicePlane = 0; - } - if ( plane ) - { - plane->Register(this); - this->Cutter->SetCutFunction(plane); - } - this->SlicePlane = plane; - this->Modified(); -} - -// Overload standard modified time function. If cut functions is modified, -// or contour values modified, then this object is modified as well. -unsigned long vtkPointSetSlicer::GetMTime() -{ - unsigned long mTime=this->Superclass::GetMTime(); - unsigned long time; - - if ( this->SlicePlane != 0 ) - { - time = this->SlicePlane->GetMTime(); - mTime = ( time > mTime ? time : mTime ); - } - - if ( this->Locator != 0 ) - { - time = this->Locator->GetMTime(); - mTime = ( time > mTime ? time : mTime ); - } - - return mTime; -} - -int vtkPointSetSlicer::RequestData( - vtkInformation * /*request*/, - vtkInformationVector **inputVector, - vtkInformationVector *outputVector) -{ - // get the info objects - vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); - vtkInformation *outInfo = outputVector->GetInformationObject(0); - - // get the input and ouptut - vtkDataSet *input = vtkDataSet::SafeDownCast( - inInfo->Get(vtkDataObject::DATA_OBJECT())); - vtkPolyData *output = vtkPolyData::SafeDownCast( - outInfo->Get(vtkDataObject::DATA_OBJECT())); - - vtkDebugMacro(<< "Executing cutter"); - - if (!this->SlicePlane) - { - vtkErrorMacro("No slice plane specified"); - return 0; - } - - if ( input->GetNumberOfPoints() < 1 ) - { - return 1; - } - - if (input->GetDataObjectType() == VTK_STRUCTURED_POINTS || - input->GetDataObjectType() == VTK_IMAGE_DATA) - { - if ( input->GetCell(0) && input->GetCell(0)->GetCellDimension() >= 3 ) - { - //this->StructuredPointsCutter(input, output, request, inputVector, outputVector); - return 1; - } - } - if (input->GetDataObjectType() == VTK_STRUCTURED_GRID) - { - if (input->GetCell(0)) - { - int dim = input->GetCell(0)->GetCellDimension(); - // only do 3D structured grids (to be extended in the future) - if (dim >= 3) - { - //this->StructuredGridCutter(input, output); - return 1; - } - } - } - if (input->GetDataObjectType() == VTK_RECTILINEAR_GRID) - { - - //this->RectilinearGridCutter(input, output); - return 1; - - } - - if (input->GetDataObjectType() == VTK_UNSTRUCTURED_GRID) - { - vtkDebugMacro(<< "Executing Unstructured Grid Cutter"); - this->UnstructuredGridCutter(input, output); - } - else - { - vtkDebugMacro(<< "Executing DataSet Cutter"); - //this->DataSetCutter(input, output); - } - - return 1; -} -int vtkPointSetSlicer::RequestUpdateExtent( - vtkInformation *, - vtkInformationVector **inputVector, - vtkInformationVector *) -{ - vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); - inInfo->Set(vtkStreamingDemandDrivenPipeline::EXACT_EXTENT(), 1); - return 1; -} -int vtkPointSetSlicer::FillInputPortInformation(int, vtkInformation *info) -{ - info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet"); - return 1; -} - -void vtkPointSetSlicer::UnstructuredGridCutter(vtkDataSet *input, vtkPolyData *output) -{ - vtkIdType cellId, i; - vtkDoubleArray *cellScalars; - vtkCellArray *newVerts, *newLines, *newPolys; - vtkPoints *newPoints; - vtkDoubleArray *cutScalars; - double s; - vtkIdType estimatedSize, numCells=input->GetNumberOfCells(); - vtkIdType numPts=input->GetNumberOfPoints(); - vtkIdType cellArrayIt = 0; - int numCellPts; - vtkPointData *inPD, *outPD; - vtkCellData *inCD=input->GetCellData(), *outCD=output->GetCellData(); - vtkIdList *cellIds; - int abortExecute = 0; - - double range[2]; - - // Create objects to hold output of contour operation - // - estimatedSize = (vtkIdType) pow ((double) numCells, .75); - estimatedSize = estimatedSize / 1024 * 1024; //multiple of 1024 - if (estimatedSize < 1024) - { - estimatedSize = 1024; - } - - newPoints = vtkPoints::New(); - newPoints->Allocate(estimatedSize,estimatedSize/2); - newVerts = vtkCellArray::New(); - newVerts->Allocate(estimatedSize,estimatedSize/2); - newLines = vtkCellArray::New(); - newLines->Allocate(estimatedSize,estimatedSize/2); - newPolys = vtkCellArray::New(); - newPolys->Allocate(estimatedSize,estimatedSize/2); - cutScalars = vtkDoubleArray::New(); - cutScalars->SetNumberOfTuples(numPts); - - // Interpolate data along edge. If generating cut scalars, do necessary setup - if ( this->GenerateCutScalars ) - { - inPD = vtkPointData::New(); - inPD->ShallowCopy(input->GetPointData());//copies original attributes - inPD->SetScalars(cutScalars); - } - else - { - inPD = input->GetPointData(); - } - outPD = output->GetPointData(); - outPD->InterpolateAllocate(inPD,estimatedSize,estimatedSize/2); - outCD->CopyAllocate(inCD,estimatedSize,estimatedSize/2); - - // locator used to merge potentially duplicate points - if ( this->Locator == NULL ) - { - this->CreateDefaultLocator(); - } - this->Locator->InitPointInsertion (newPoints, input->GetBounds()); - - // Loop over all points evaluating scalar function at each point - // - for ( i=0; i < numPts; i++ ) - { - s = this->SlicePlane->FunctionValue(input->GetPoint(i)); - cutScalars->SetComponent(i,0,s); - } - - // Compute some information for progress methods - // - vtkIdType numCuts = numCells; - vtkIdType progressInterval = numCuts/20 + 1; - int cut=0; - - vtkUnstructuredGrid *grid = (vtkUnstructuredGrid *)input; - vtkIdType *cellArrayPtr = grid->GetCells()->GetPointer(); - double *scalarArrayPtr = cutScalars->GetPointer(0); - double tempScalar; - cellScalars = cutScalars->NewInstance(); - cellScalars->SetNumberOfComponents(cutScalars->GetNumberOfComponents()); - cellScalars->Allocate(VTK_CELL_SIZE*cutScalars->GetNumberOfComponents()); - - // Three passes over the cells to process lower dimensional cells first. - // For poly data output cells need to be added in the order: - // verts, lines and then polys, or cell data gets mixed up. - // A better solution is to have an unstructured grid output. - // I create a table that maps cell type to cell dimensionality, - // because I need a fast way to get cell dimensionality. - // This assumes GetCell is slow and GetCellType is fast. - // I do not like hard coding a list of cell types here, - // but I do not want to add GetCellDimension(vtkIdType cellId) - // to the vtkDataSet API. Since I anticipate that the output - // will change to vtkUnstructuredGrid. This temporary solution - // is acceptable. - // - int cellType; - unsigned char cellTypeDimensions[VTK_NUMBER_OF_CELL_TYPES]; - vtkCutter::GetCellTypeDimensions(cellTypeDimensions); - int dimensionality; - // We skip 0d cells (points), because they cannot be cut (generate no data). - for (dimensionality = 1; dimensionality <= 3; ++dimensionality) - { - // Loop over all cells; get scalar values for all cell points - // and process each cell. - // - cellArrayIt = 0; - for (cellId=0; cellId < numCells && !abortExecute; cellId++) - { - numCellPts = cellArrayPtr[cellArrayIt]; - // I assume that "GetCellType" is fast. - cellType = input->GetCellType(cellId); - if (cellType >= VTK_NUMBER_OF_CELL_TYPES) - { // Protect against new cell types added. - vtkErrorMacro("Unknown cell type " << cellType); - cellArrayIt += 1+numCellPts; - continue; - } - if (cellTypeDimensions[cellType] != dimensionality) - { - cellArrayIt += 1+numCellPts; - continue; - } - cellArrayIt++; - - //find min and max values in scalar data - range[0] = scalarArrayPtr[cellArrayPtr[cellArrayIt]]; - range[1] = scalarArrayPtr[cellArrayPtr[cellArrayIt]]; - cellArrayIt++; - - for (i = 1; i < numCellPts; i++) - { - tempScalar = scalarArrayPtr[cellArrayPtr[cellArrayIt]]; - cellArrayIt++; - if (tempScalar <= range[0]) - { - range[0] = tempScalar; - } //if tempScalar <= min range value - if (tempScalar >= range[1]) - { - range[1] = tempScalar; - } //if tempScalar >= max range value - } // for all points in this cell - - int needCell = 0; - if (0.0 >= range[0] && 0.0 <= range[1]) - { - needCell = 1; - } - - if (needCell) - { - vtkCell *cell = input->GetCell(cellId); - cellIds = cell->GetPointIds(); - cutScalars->GetTuples(cellIds,cellScalars); - // Loop over all contour values. - if (dimensionality == 3 && !(++cut % progressInterval) ) - { - vtkDebugMacro(<<"Cutting #" << cut); - this->UpdateProgress (static_cast(cut)/numCuts); - abortExecute = this->GetAbortExecute(); - } - - this->ContourUnstructuredGridCell(cell, cellScalars, this->Locator, - newVerts, newLines, newPolys, inPD, outPD, - inCD, cellId, outCD); - } // if need cell - } // for all cells - } // for all dimensions (1,2,3). - - // Update ourselves. Because we don't know upfront how many verts, lines, - // polys we've created, take care to reclaim memory. - // - cellScalars->Delete(); - cutScalars->Delete(); - - if ( this->GenerateCutScalars ) - { - inPD->Delete(); - } - - output->SetPoints(newPoints); - newPoints->Delete(); - - if (newVerts->GetNumberOfCells()) - { - output->SetVerts(newVerts); - } - newVerts->Delete(); - - if (newLines->GetNumberOfCells()) - { - output->SetLines(newLines); - } - newLines->Delete(); - - if (newPolys->GetNumberOfCells()) - { - output->SetPolys(newPolys); - } - newPolys->Delete(); - - this->Locator->Initialize();//release any extra memory - output->Squeeze(); -} - -void vtkPointSetSlicer::ContourUnstructuredGridCell(vtkCell* cell, - vtkDataArray* cellScalars, vtkPointLocator* locator, - vtkCellArray* verts, vtkCellArray* lines, - vtkCellArray* polys, vtkPointData* inPd, - vtkPointData* outPd, vtkCellData* inCd, - vtkIdType cellId, vtkCellData* outCd) -{ - if (cell->GetCellType() == VTK_HEXAHEDRON) - { - static int CASE_MASK[8] = {1,2,4,8,16,32,64,128}; - POLY_CASES *polyCase; - EDGE_LIST *edge; - int i, j, index, *vert; - volatile int pnum; - int v1, v2, newCellId; - double t, x1[3], x2[3], x[3], deltaScalar; - vtkIdType offset = verts->GetNumberOfCells() + lines->GetNumberOfCells(); - - // Build the case table - for ( i=0, index = 0; i < 8; i++) - { - if (cellScalars->GetComponent(i,0) >= 0) - { - index |= CASE_MASK[i]; - } - } - - polyCase = polyCases + index; - edge = polyCase->edges; - - // get the point number of the polygon - pnum = 0; - for (i = 0; i < 8; i++) - if (edge[i] > -1) pnum++; - else break; - - vtkIdType* pts = new vtkIdType[pnum]; - for (i=0; iGetComponent(vert[1],0) - - cellScalars->GetComponent(vert[0],0)); - if (deltaScalar > 0) - { - v1 = vert[0]; v2 = vert[1]; - } - else - { - v1 = vert[1]; v2 = vert[0]; - deltaScalar = -deltaScalar; - } - - // linear interpolation - t = ( deltaScalar == 0.0 ? 0.0 : (-cellScalars->GetComponent(v1,0)) / deltaScalar ); - - cell->GetPoints()->GetPoint(v1, x1); - cell->GetPoints()->GetPoint(v2, x2); - - for (j=0; j<3; j++) - { - x[j] = x1[j] + t * (x2[j] - x1[j]); - } - if ( locator->InsertUniquePoint(x, pts[i]) ) - { - if ( outPd ) - { - vtkIdType p1 = cell->GetPointIds()->GetId(v1); - vtkIdType p2 = cell->GetPointIds()->GetId(v2); - outPd->InterpolateEdge(inPd,pts[i],p1,p2,t); - } - } - } - - // check for degenerate polygon - std::vector pset; - for (i=0; i 2) - { - i = 0; - for (std::vector::iterator iter = pset.begin(); iter != pset.end(); iter++) - { - pts[i] = *iter; - i++; - } - newCellId = offset + polys->InsertNextCell(pset.size(),pts); - outCd->CopyData(inCd,cellId,newCellId); - } - delete [] pts; - - } - else - { - cell->Contour(0, cellScalars, locator, verts, lines, polys, - inPd, outPd, inCd, cellId, outCd); - } -} - -// Specify a spatial locator for merging points. By default, -// an instance of vtkMergePoints is used. -void vtkPointSetSlicer::SetLocator(vtkPointLocator *locator) -{ - if ( this->Locator == locator ) - { - return; - } - if ( this->Locator ) - { - this->Locator->UnRegister(this); - this->Locator = 0; - } - if ( locator ) - { - locator->Register(this); - } - this->Locator = locator; - this->Modified(); -} - -void vtkPointSetSlicer::CreateDefaultLocator() -{ - if ( this->Locator == 0 ) - { - this->Locator = vtkMergePoints::New(); - this->Locator->Register(this); - this->Locator->Delete(); - } -} - - -void vtkPointSetSlicer::PrintSelf(std::ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); - - os << indent << "Slice Plane: " << this->SlicePlane << "\n"; - - if ( this->Locator ) - { - os << indent << "Locator: " << this->Locator << "\n"; - } - else - { - os << indent << "Locator: (none)\n"; - } - - os << indent << "Generate Cut Scalars: " - << (this->GenerateCutScalars ? "On\n" : "Off\n"); -} - -int vtkPointSetSlicer::edges[12][2] = { {0,1},{1,2},{3,2},{0,3}, - {4,5},{5,6},{7,6},{4,7}, - {0,4},{1,5},{2,6},{3,7} }; - -vtkPointSetSlicer::POLY_CASES -vtkPointSetSlicer::polyCases[256] = { - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{0, 3, 8, -1, -1, -1, -1, -1}}, - {{1, 0, 9, -1, -1, -1, -1, -1}}, - {{1, 3, 8, 9, -1, -1, -1, -1}}, - {{2, 1, 10, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{2, 0, 9, 10, -1, -1, -1, -1}}, - {{2, 10, 9, 8, 3, -1, -1, -1}}, - {{3, 2, 11, -1, -1, -1, -1, -1}}, - {{0, 2, 11, 8, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{1, 9, 8, 11, 2, -1, -1, -1}}, - {{3, 1, 10, 11, -1, -1, -1, -1}}, - {{0, 8, 11, 10, 1, -1, -1, -1}}, - {{3, 11, 10, 9, 0, -1, -1, -1}}, - {{8, 9, 10, 11, -1, -1, -1, -1}}, - {{4, 7, 8, -1, -1, -1, -1, -1}}, - {{3, 7, 4, 0, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{9, 1, 3, 7, 4, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{11, 2, 0, 4, 7, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{1, 2, 11, 7, 4, 9, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{4, 7, 11, 10, 9, -1, -1, -1}}, - {{5, 4, 9, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{0, 4, 5, 1, -1, -1, -1, -1}}, - {{8, 3, 1, 5, 4, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{10, 2, 0, 4, 5, -1, -1, -1}}, - {{2, 3, 8, 4, 5, 10, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{5, 4, 8, 11, 10, -1, -1, -1}}, - {{5, 7, 8, 9, -1, -1, -1, -1}}, - {{9, 5, 7, 3, 0, -1, -1, -1}}, - {{8, 7, 5, 1, 0, -1, -1, -1}}, - {{1, 3, 7, 5, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{2, 10, 5, 7, 3, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{2, 11, 7, 5, 1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{5, 7, 11, 10, -1, -1, -1, -1}}, - {{6, 5, 10, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{1, 5, 6, 2, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{9, 0, 2, 6, 5, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{11, 3, 1, 5, 6, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{3, 0, 9, 5, 6, 11, -1, -1}}, - {{6, 5, 9, 8, 11, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{6, 4, 9, 10, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{10, 6, 4, 0, 1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{9, 4, 6, 2, 1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{2, 0, 4, 6, -1, -1, -1, -1}}, - {{3, 8, 4, 6, 2, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{3, 11, 6, 4, 0, -1, -1, -1}}, - {{6, 4, 8, 11, -1, -1, -1, -1}}, - {{6, 10, 9, 8, 7, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{6, 7, 8, 0, 1, 10, -1, -1}}, - {{6, 10, 1, 3, 7, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{7, 8, 0, 2, 6, -1, -1, -1}}, - {{2, 6, 7, 3, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{6, 7, 11, -1, -1, -1, -1, -1}}, - {{7, 6, 11, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{2, 6, 7, 3, -1, -1, -1, -1}}, - {{8, 0, 2, 6, 7, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{10, 1, 3, 7, 6, -1, -1, -1}}, - {{0, 1, 10, 6, 7, 8, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{7, 6, 10, 9, 8, -1, -1, -1}}, - {{4, 6, 11, 8, -1, -1, -1, -1}}, - {{11, 6, 4, 0, 3, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{8, 4, 6, 2, 3, -1, -1, -1}}, - {{0, 2, 6, 4, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{1, 9, 4, 6, 2, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{1, 10, 6, 4, 0, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{4, 6, 10, 9, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{5, 9, 8, 11, 6, -1, -1, -1}}, - {{5, 6, 11, 3, 0, 9, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{6, 11, 3, 1, 5, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{5, 9, 0, 2, 6, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{1, 5, 6, 2, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{5, 6, 10, -1, -1, -1, -1, -1}}, - {{7, 5, 10, 11, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{11, 7, 5, 1, 2, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{10, 5, 7, 3, 2, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{3, 1, 5, 7, -1, -1, -1, -1}}, - {{0, 8, 7, 5, 1, -1, -1, -1}}, - {{0, 9, 5, 7, 3, -1, -1, -1}}, - {{7, 5, 9, 8, -1, -1, -1, -1}}, - {{4, 8, 11, 10, 5, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{4, 5, 10, 2, 3, 8, -1, -1}}, - {{5, 10, 2, 0, 4, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{4, 8, 3, 1, 5, -1, -1, -1}}, - {{0, 4, 5, 1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{4, 5, 9, -1, -1, -1, -1, -1}}, - {{7, 11, 10, 9, 4, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{7, 4, 9, 1, 2, 11, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{7, 11, 2, 0, 4, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{4, 9, 1, 3, 7, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{3, 7, 4, 0, -1, -1, -1, -1}}, - {{7, 4, 8, -1, -1, -1, -1, -1}}, - {{10, 11, 8, 9, -1, -1, -1, -1}}, - {{0, 3, 11, 10, 9, -1, -1, -1}}, - {{1, 0, 8, 11, 10, -1, -1, -1}}, - {{1, 3, 11, 10, -1, -1, -1, -1}}, - {{2, 1, 9, 8, 11, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{2, 0, 8, 11, -1, -1, -1, -1}}, - {{2, 3, 11, -1, -1, -1, -1, -1}}, - {{3, 2, 10, 9, 8, -1, -1, -1}}, - {{0, 2, 10, 9, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}}, - {{1, 2, 10, -1, -1, -1, -1, -1}}, - {{3, 1, 9, 8, -1, -1, -1, -1}}, - {{0, 1, 9, -1, -1, -1, -1, -1}}, - {{3, 0, 8, -1, -1, -1, -1, -1}}, - {{-1, -1, -1, -1, -1, -1, -1, -1}} -}; diff --git a/Modules/Ext/Algorithms/vtkPointSetSlicer.h b/Modules/Ext/Algorithms/vtkPointSetSlicer.h deleted file mode 100644 index 26e1cb31f7..0000000000 --- a/Modules/Ext/Algorithms/vtkPointSetSlicer.h +++ /dev/null @@ -1,118 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef _VTKPOINTSETSLICER_H_ -#define _VTKPOINTSETSLICER_H_ - -#include -#include "MitkExtExports.h" - -#include "vtkVersion.h" - -class vtkCutter; -class vtkPlane; -class vtkPointLocator; -class vtkCell; -class vtkDataArray; -class vtkCellArray; -class vtkPointData; -class vtkCellData; - -#include "mitkCommon.h" -#include "MitkExtExports.h" - -#include "vtkPolyDataAlgorithm.h" - -class MitkExt_EXPORT vtkPointSetSlicer : public vtkPolyDataAlgorithm -{ -public: - vtkTypeMacro(vtkPointSetSlicer,vtkPolyDataAlgorithm); - - void PrintSelf(std::ostream& os, vtkIndent indent); - - // Description: - // Construct with user-specified implicit function; initial value of 0.0; and - // generating cut scalars turned off. - static vtkPointSetSlicer *New(); - - // Description: - // Override GetMTime because we delegate to vtkContourValues and refer to - // vtkImplicitFunction. - unsigned long GetMTime(); - - // Description - // Specify the implicit function to perform the cutting. - virtual void SetSlicePlane(vtkPlane*); - vtkGetObjectMacro(SlicePlane,vtkPlane); - - // Description: - // If this flag is enabled, then the output scalar values will be - // interpolated from the implicit function values, and not the input scalar - // data. - vtkSetMacro(GenerateCutScalars,int); - vtkGetMacro(GenerateCutScalars,int); - vtkBooleanMacro(GenerateCutScalars,int); - - // Description: - // Specify a spatial locator for merging points. By default, - // an instance of vtkMergePoints is used. - void SetLocator(vtkPointLocator *locator); - vtkGetObjectMacro(Locator,vtkPointLocator); - - // Description: - // Create default locator. Used to create one when none is specified. The - // locator is used to merge coincident points. - void CreateDefaultLocator(); - -protected: - vtkPointSetSlicer(vtkPlane* cf = 0); - ~vtkPointSetSlicer(); - - virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); - virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *); - virtual int FillInputPortInformation(int port, vtkInformation *info); - - void UnstructuredGridCutter(vtkDataSet *input, vtkPolyData *output); - - void ContourUnstructuredGridCell(vtkCell* cell, - vtkDataArray* cellScalars, vtkPointLocator* locator, - vtkCellArray* verts, vtkCellArray* lines, - vtkCellArray* polys, vtkPointData* inPd, - vtkPointData* outPd, vtkCellData* inCd, - vtkIdType cellId, vtkCellData* outCd); - - vtkPlane *SlicePlane; - vtkCutter *Cutter; - - vtkPointLocator *Locator; - int GenerateCutScalars; - -private: - vtkPointSetSlicer(const vtkPointSetSlicer&); // Not implemented. - void operator=(const vtkPointSetSlicer&); // Not implemented. - - static int edges[12][2]; - - typedef int EDGE_LIST; - typedef struct { - EDGE_LIST edges[8]; - } POLY_CASES; - - static POLY_CASES polyCases[256]; -}; - - -#endif /* _VTKPOINTSETSLICER_H_ */ diff --git a/Modules/Ext/CMakeLists.txt b/Modules/Ext/CMakeLists.txt deleted file mode 100644 index a1c32d30c0..0000000000 --- a/Modules/Ext/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -#if(WIN32) -# option(MITK_USE_TD_MOUSE "Enable support for 3D Connexion SpaceNavigator" OFF) -#endif(WIN32) - -configure_file(${PROJECT_SOURCE_DIR}/CMake/ToolExtensionITKFactory.cpp.in ${PROJECT_BINARY_DIR}/ToolExtensionITKFactory.cpp.in COPYONLY) -configure_file(${PROJECT_SOURCE_DIR}/CMake/ToolExtensionITKFactoryLoader.cpp.in ${PROJECT_BINARY_DIR}/ToolExtensionITKFactoryLoader.cpp.in COPYONLY) -configure_file(${PROJECT_SOURCE_DIR}/CMake/ToolGUIExtensionITKFactory.cpp.in ${PROJECT_BINARY_DIR}/ToolGUIExtensionITKFactory.cpp.in COPYONLY) - -MITK_CREATE_MODULE( - INCLUDE_DIRS Algorithms Controllers DataManagement Interactions IO Rendering - DEPENDS MitkDataTypesExt MitkImageExtraction MitkIpPicSupport - PACKAGE_DEPENDS ANN ITK|ITKConnectedComponents+ITKBinaryMathematicalMorphology - DEPRECATED_SINCE 2014.03 -) - -if(BUILD_TESTING) - add_subdirectory(Testing) -endif() - diff --git a/Modules/Ext/Controllers/mitkTDMouseVtkCameraController.cpp b/Modules/Ext/Controllers/mitkTDMouseVtkCameraController.cpp deleted file mode 100644 index 9cdcd2fd2f..0000000000 --- a/Modules/Ext/Controllers/mitkTDMouseVtkCameraController.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkTDMouseVtkCameraController.h" -#include "mitkVtkPropRenderer.h" -#include "vtkCamera.h" -#include "vtkRenderer.h" -#include "vtkTransform.h" -#include "mitkNumericTypes.h" -#include "mitkInteractionConst.h" -#include "mitkStateEvent.h" -#include "mitkTDMouseEventThrower.h" -#include "mitkTDMouseEvent.h" -#include "mitkGlobalInteraction.h" -#include "vtkMath.h" - -const double TRANSLATIONSENSITIVITY = 2.0; -const double ROTATIONSENSIVITY = 3.5; -const double ANGLESENSITIVITY = 3.5; - - -mitk::TDMouseVtkCameraController::TDMouseVtkCameraController() -: CameraController("TDMouseInteraction") -{ - //activate and instanciate EventThrower - mitk::TDMouseEventThrower* thrower = mitk::TDMouseEventThrower::GetInstance(); - //add this to GlobalInteracion to listen to events - mitk::GlobalInteraction::GetInstance()->AddListener(this); - //connect method this->OnTDMouseEvent to StateMachineEventMechanism - CONNECT_ACTION(AcONTDMOUSEINPUT, OnTDMouseEvent); - CONNECT_ACTION(AcONTDMOUSEKEYDOWN, OnTDMouseKeyDown); - m_ClippingRangeIsSet = false; -} - -mitk::TDMouseVtkCameraController::~TDMouseVtkCameraController() -{ -} - -bool mitk::TDMouseVtkCameraController::OnTDMouseEvent(mitk::Action* a, const mitk::StateEvent* e) -{ - //only if 3D rendering - mitk::BaseRenderer const* br = this->GetRenderer(); - mitk::BaseRenderer::MapperSlotId id = ((mitk::BaseRenderer*)(br))->GetMapperID(); - if (id != mitk::BaseRenderer::Standard3D) - return true; - - //only if focused by the FocusManager - if (this->GetRenderer() != mitk::GlobalInteraction::GetInstance()->GetFocus()) - return true; - - //pre-checking for safety - vtkRenderer* vtkRenderer = ((mitk::VtkPropRenderer*)this->GetRenderer())->GetVtkRenderer(); - if (vtkRenderer == NULL) - return false; - - - vtkCamera* vtkCam = (vtkCamera*)vtkRenderer->GetActiveCamera(); - - if(!m_ClippingRangeIsSet) - vtkCam->SetClippingRange(0.1, 1000000); - - const mitk::TDMouseEvent* tdevent = dynamic_cast(e->GetEvent()); - if (tdevent == NULL) - { - std::cout<<"Wrong event for TDMouseCameraController!"<GetTranslation(); - mitk::Vector3D rotation = tdevent->GetRotation(); - mitk::ScalarType angle = tdevent->GetAngle(); - - //output for debug - //std::cout<<"translation: "<GetDataStorage(); - mitk::BoundingBox::Pointer bb = ds->ComputeBoundingBox(); - mitk::BoundingBox::AccumulateType length = bb->GetDiagonalLength2(); - if (length > 0.00001)//if length not zero - sceneSensivity *= 100.0 / (sqrt(length)) ; - - //sensivity to adapt to mitk speed - translation *= sceneSensivity * TRANSLATIONSENSITIVITY; - rotation *= sceneSensivity * ROTATIONSENSIVITY; - angle *= sceneSensivity * ANGLESENSITIVITY; - - //compute the global space coordinates from the relative mouse coordinate - //first we need the position of the camera - mitk::Vector3D camPosition; - double camPositionTemp[3]; - vtkCam->GetPosition(camPositionTemp); - camPosition[0] = camPositionTemp[0]; camPosition[1] = camPositionTemp[1]; camPosition[2] = camPositionTemp[2]; - - //then the upvector of the camera - mitk::Vector3D upCamVector; - double upCamTemp[3]; - vtkCam->GetViewUp(upCamTemp); - upCamVector[0] = upCamTemp[0]; upCamVector[1] = upCamTemp[1]; upCamVector[2] = upCamTemp[2]; - upCamVector.Normalize(); - - //then the vector to which the camera is heading at (focalpoint) - mitk::Vector3D focalPoint; - double focalPointTemp[3]; - vtkCam->GetFocalPoint(focalPointTemp); - focalPoint[0] = focalPointTemp[0]; focalPoint[1] = focalPointTemp[1]; focalPoint[2] = focalPointTemp[2]; - mitk::Vector3D focalVector; - focalVector = focalPoint - camPosition; - focalVector.Normalize(); - - //orthogonal vector to focalVector and upCamVector - mitk::Vector3D crossVector; - crossVector = CrossProduct(upCamVector, focalVector); - crossVector.Normalize(); - - //now we have the current orientation so we can adapt it according to the current information, which we got from the TDMouse - - //new position of the camera: - //left/right = camPosition + crossVector * translation[0]; - mitk::Vector3D vectorX = crossVector * -translation[0]; //changes the magnitude, not the direction - double nextCamPosition[3]; - nextCamPosition[0] = camPosition[0] + vectorX[0]; - nextCamPosition[1] = camPosition[1] + vectorX[1]; - nextCamPosition[2] = camPosition[2] + vectorX[2]; - - //now the up/down movement - mitk::Vector3D vectorY = upCamVector * translation[1]; //changes the magnitude, not the direction - nextCamPosition[0] += vectorY[0]; - nextCamPosition[1] += vectorY[1]; - nextCamPosition[2] += vectorY[2]; - - //forward/backward movement - mitk::Vector3D vectorZ = focalVector * -translation[2]; //changes the magnitude, not the direction - nextCamPosition[0] += vectorZ[0]; - nextCamPosition[1] += vectorZ[1]; - nextCamPosition[2] += vectorZ[2]; - - //set the next position - double nextPosition[3]; - nextPosition[0] = nextCamPosition[0]; nextPosition[1] = nextCamPosition[1]; nextPosition[2] = nextCamPosition[2]; - vtkCam->SetPosition(nextPosition); - - //adapt the focal point the same way - double currentFocalPoint[3], nextFocalPoint[3]; - vtkCam->GetFocalPoint(currentFocalPoint); - nextFocalPoint[0] = currentFocalPoint[0] + vectorX[0] + vectorY[0] + vectorZ[0]; - nextFocalPoint[1] = currentFocalPoint[1] + vectorX[1] + vectorY[1] + vectorZ[1]; ; - nextFocalPoint[2] = currentFocalPoint[2] + vectorX[2] + vectorY[2] + vectorZ[2]; - vtkCam->SetFocalPoint(nextFocalPoint); - - - //now adapt the rotation of the mouse and adapt the camera according to it - - //Pitch: - //Rotate the focal point about the cross product of the view up vector and the direction of - //projection, centered at the camera's position. - vtkCam->Pitch(rotation[0]*angle); - - //Yaw: - //Rotate the focal point about the view up vector centered at the camera's position. - //Note that the view up vector is not necessarily perpendicular to the direction of projection. - vtkCam->Yaw(rotation[1]*angle); - - //Roll: - //Rotate the camera about the direction of projection. - vtkCam->Roll(-rotation[2]*angle * 1.5);//*1.5 to speed up the rotation[2] a little bit - - //Recompute the ViewUp vector to force it to be perpendicular to camera->focalpoint vector. - //Unless you are going to use Yaw or Azimuth on the camera, there is no need to do this. - vtkCam->OrthogonalizeViewUp(); - - //no zooming, only translating to the front or back - // dolly: Move the position of the camera along the direction - // of projection. Moving towards the focal point (e.g., greater - // than 1) is a dolly-in, moving away from the focal point - // (e.g., less than 1) is a dolly-out. - //double distance = ((tdevent->GetTranslation())[1] / 10.0);//make it less sensitive in comparison to translation and rotatipn - //vtkCam->Dolly(1.0 + distance ); - - - //Reset the camera clipping range based on the bounds of the visible actors. - //This ensures that no props are cut off - vtkRenderer->ResetCameraClippingRange(); - - mitk::RenderingManager::GetInstance()->ForceImmediateUpdate(mitk::GlobalInteraction::GetInstance()->GetFocus()->GetRenderWindow()); - - return true; -} - - -bool mitk::TDMouseVtkCameraController::OnTDMouseKeyDown(mitk::Action* a, const mitk::StateEvent* e) -{ - //reset the camera, so that the objects shown in the scene can be seen. - const mitk::VtkPropRenderer* glRenderer = dynamic_cast(m_Renderer); - if (glRenderer) - { - vtkRenderer* vtkRenderer = glRenderer->GetVtkRenderer(); - mitk::DataStorage* ds = m_Renderer->GetDataStorage(); - if (ds == NULL) - return false; - - mitk::BoundingBox::Pointer bb = ds->ComputeBoundingBox(); - - mitk::Point3D middle =bb->GetCenter(); - vtkRenderer->GetActiveCamera()->SetFocalPoint(middle[0],middle[1],middle[2]); - - vtkRenderer->ResetCamera(); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - return true; - } - return false; -} diff --git a/Modules/Ext/Controllers/mitkTDMouseVtkCameraController.h b/Modules/Ext/Controllers/mitkTDMouseVtkCameraController.h deleted file mode 100644 index 6daa75a49e..0000000000 --- a/Modules/Ext/Controllers/mitkTDMouseVtkCameraController.h +++ /dev/null @@ -1,58 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef MITKTDMOUSEVTKCAMERACONTROLLER_H_HEADER_INCLUDED -#define MITKTDMOUSEVTKCAMERACONTROLLER_H_HEADER_INCLUDED - -#include "mitkCameraController.h" - - -class vtkRenderWindow; - -namespace mitk { - -//##Documentation -//## @brief vtk-based camera controller -//## @ingroup NavigationControl -class TDMouseVtkCameraController : public CameraController -{ -public: - mitkClassMacro(TDMouseVtkCameraController, CameraController); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - virtual bool OnTDMouseEvent(mitk::Action* a, const mitk::StateEvent* e); - virtual bool OnTDMouseKeyDown(mitk::Action* a, const mitk::StateEvent* e); - -protected: - /** - * @brief Default Constructor - **/ - TDMouseVtkCameraController(); - - /** - * @brief Default Destructor - **/ - virtual ~TDMouseVtkCameraController(); - - bool m_ClippingRangeIsSet; - - -}; - -} // namespace mitk - -#endif /* MITKTDMOUSEVTKCAMERACONTROLLER_H_HEADER_INCLUDED */ diff --git a/Modules/Ext/DataManagement/doc_mitkDataTreeFilterHierarchyHandling.dia b/Modules/Ext/DataManagement/doc_mitkDataTreeFilterHierarchyHandling.dia deleted file mode 100644 index 0b1b1710bd..0000000000 Binary files a/Modules/Ext/DataManagement/doc_mitkDataTreeFilterHierarchyHandling.dia and /dev/null differ diff --git a/Modules/Ext/DataManagement/doc_mitkDataTreeFilterHierarchyHandling.png b/Modules/Ext/DataManagement/doc_mitkDataTreeFilterHierarchyHandling.png deleted file mode 100644 index d1f9b31add..0000000000 Binary files a/Modules/Ext/DataManagement/doc_mitkDataTreeFilterHierarchyHandling.png and /dev/null differ diff --git a/Modules/Ext/DataManagement/doc_mitkDataTreeFilterRelatedClasses.dia b/Modules/Ext/DataManagement/doc_mitkDataTreeFilterRelatedClasses.dia deleted file mode 100644 index fae3939b86..0000000000 Binary files a/Modules/Ext/DataManagement/doc_mitkDataTreeFilterRelatedClasses.dia and /dev/null differ diff --git a/Modules/Ext/DataManagement/doc_mitkDataTreeFilterRelatedClasses.png b/Modules/Ext/DataManagement/doc_mitkDataTreeFilterRelatedClasses.png deleted file mode 100644 index ecc84b901d..0000000000 Binary files a/Modules/Ext/DataManagement/doc_mitkDataTreeFilterRelatedClasses.png and /dev/null differ diff --git a/Modules/Ext/DataManagement/doc_mitkDataTreeFilterTreeViewsGUI.png b/Modules/Ext/DataManagement/doc_mitkDataTreeFilterTreeViewsGUI.png deleted file mode 100644 index 0c79c1e3e9..0000000000 Binary files a/Modules/Ext/DataManagement/doc_mitkDataTreeFilterTreeViewsGUI.png and /dev/null differ diff --git a/Modules/Ext/DataManagement/itkAffineGeometryFrame.h.dox b/Modules/Ext/DataManagement/itkAffineGeometryFrame.h.dox deleted file mode 100644 index 1b563211c3..0000000000 --- a/Modules/Ext/DataManagement/itkAffineGeometryFrame.h.dox +++ /dev/null @@ -1,127 +0,0 @@ -// copied here for documentation purposes -#ifdef DOXYGEN_SKIP -/*========================================================================= - - Program: Insight Segmentation & Registration Toolkit - Module: $RCSfile: itkAffineGeometryFrame.h,v $ - Language: C++ - Date: $Date$ - Version: $Revision: 1.7 $ - - Copyright (c) Insight Software Consortium. All rights reserved. - See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ -#ifndef __itkAffineGeometryFrame_h -#define __itkAffineGeometryFrame_h - -#include "itkObject.h" -#include "itkMacro.h" -#include "itkScalableAffineTransform.h" -#include "itkBoundingBox.h" - -namespace itk -{ - - /** \class AffineGeometryFrame - * \brief Describes the geometry of a data object - */ -template -class AffineGeometryFrame : public itk::Object -{ -public: - typedef AffineGeometryFrame Self; - typedef itk::Object Superclass; - typedef SmartPointer Pointer; - typedef SmartPointer ConstPointer; - - typedef ScalableAffineTransform TransformType; - typedef BoundingBox BoundingBoxType; - typedef typename BoundingBoxType::BoundsArrayType BoundsArrayType; - typedef typename BoundingBoxType::Pointer BoundingBoxPointer; - - /** Method for creation through the object factory. */ - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - /** \brief Method for creation through the object factory. */ - itkTypeMacro(AffineGeometryFrame, Object); - - /** \brief Get the bounding box */ - itkGetConstObjectMacro(BoundingBox, BoundingBoxType); - - const BoundsArrayType GetBounds() const - { - assert(m_BoundingBox.IsNotNull()); - return m_BoundingBox->GetBounds(); - } - - /** \brief Set the bounding box Only possible via the BoundsArray - * to make clear that a copy of the bounding-box is stored, - * not a reference to it.*/ - virtual void SetBounds(const BoundsArrayType& bounds); - - /** \brief Get the extent of the bounding box */ - TScalarType GetExtent(unsigned int direction) const - { - assert(directionGetBounds(); - return bounds[direction*2+1]-bounds[direction*2]; - } - - /** \brief Set/Get the IndexToObjectTransform */ - itkGetConstObjectMacro(IndexToObjectTransform, TransformType); - itkGetObjectMacro(IndexToObjectTransform, TransformType); - itkSetObjectMacro(IndexToObjectTransform, TransformType); - - /** \brief Set/Get the ObjectToNodeTransform */ - itkGetConstObjectMacro(ObjectToNodeTransform, TransformType); - itkGetObjectMacro(ObjectToNodeTransform, TransformType); - itkSetObjectMacro(ObjectToNodeTransform, TransformType); - - /** \brief Set/Get the IndexToWorldTransform */ - itkGetConstObjectMacro(IndexToWorldTransform, TransformType); - itkGetObjectMacro(IndexToWorldTransform, TransformType); - itkSetObjectMacro(IndexToWorldTransform, TransformType); - - - /** \brief Get the IndexToNodeTransform - * This Transform cannot be set, and is just computed internally */ - itkGetConstObjectMacro(IndexToNodeTransform, TransformType); - - /** \brief Initialize the geometry frame */ - virtual void Initialize(); - -protected: - - AffineGeometryFrame(); - virtual ~AffineGeometryFrame(); - - /** \brief used in clone to initialize the newly created geometry */ - virtual void InitializeGeometry(Self * newGeometry) const; - void SetBoundsArray(const BoundsArrayType& bounds, - BoundingBoxPointer& boundingBox); - mutable BoundingBoxPointer m_BoundingBox; - - /** \brief Transform from unit coordinates to object coordinates */ - typename TransformType::Pointer m_IndexToObjectTransform; - typename TransformType::Pointer m_ObjectToNodeTransform; - typename TransformType::Pointer m_IndexToNodeTransform; - typename TransformType::Pointer m_IndexToWorldTransform; - -private: - AffineGeometryFrame(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - -}; - -} // namespace itk - -#endif /* __itkAffineGeometryFrame_h */ - -#endif diff --git a/Modules/Ext/DataManagement/itkSmartPointerVectorContainer.h b/Modules/Ext/DataManagement/itkSmartPointerVectorContainer.h deleted file mode 100644 index 797a8c3ece..0000000000 --- a/Modules/Ext/DataManagement/itkSmartPointerVectorContainer.h +++ /dev/null @@ -1,223 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef __itkSmartPointerVectorContainer_h -#define __itkSmartPointerVectorContainer_h - -/* - - Defines a vector container just like from itkSmartPointerVectorContainer.h. - The important difference ist, that this vector holds SmartPointers - to object instead of objects themselves. - - Major difference to SmartPointerVectorContainer>: - - When you ask for a ConstIterator you won't get const SmartPointers, - but a list of const Object*. -*/ - -#include "itkObject.h" - -#include -#include - -namespace itk -{ - -/** \class SmartPointerVectorContainer - * Define a front-end to the STL "vector" container that conforms to the - * IndexedContainerInterface. This is a full-fleged Object, so - * there is modification time, debug, and reference count information. - * - * Template parameters for SmartPointerVectorContainer: - * - * TElementIdentifier = - * An INTEGRAL type for use in indexing the vector. - * - * TElement = - * The element type stored in the container. - * - * \ingroup DataRepresentation - */ -template < - typename TElementIdentifier, - typename TElement - > -class SmartPointerVectorContainer: - public Object, - public std::vector > /** difference: we handle smart pointers */ -{ -public: - /** Standard class typedefs. */ - typedef SmartPointerVectorContainer Self; - typedef Object Superclass; - typedef SmartPointer Pointer; - typedef SmartPointer ConstPointer; - - /** Save the template parameters. */ - typedef TElementIdentifier ElementIdentifier; - typedef TElement Element; - typedef const TElement ConstElement; - typedef itk::SmartPointer ElementPointer; - typedef const itk::SmartPointer ConstElementPointer; - -private: - /** Quick access to the STL vector type that was inherited. */ - typedef std::vector VectorType; - typedef typename VectorType::size_type size_type; - typedef typename VectorType::iterator VectorIterator; - typedef typename VectorType::const_iterator VectorConstIterator; - -protected: - /** Provide pass-through constructors corresponding to all the STL - * vector constructors. These are for internal use only since this is also - * an Object which must be constructed through the "New()" routine. */ - SmartPointerVectorContainer(): - Object(), VectorType() {} - SmartPointerVectorContainer(size_type n): - Object(), VectorType(n) {} - SmartPointerVectorContainer(size_type n, const Element& x): - Object(), VectorType(n, x) {} - SmartPointerVectorContainer(const Self& r): - Object(), VectorType(r) {} - template - SmartPointerVectorContainer(InputIterator first, InputIterator last): - Object(), VectorType(first, last) {} - -public: - - /** This type is provided to Adapt this container as an STL container */ - typedef VectorType STLContainerType; - - /** Method for creation through the object factory. */ - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - /** Standard part of every itk Object. */ - itkTypeMacro(SmartPointerVectorContainer, Object); - - /** Convenient typedefs for the iterator and const iterator. */ - class Iterator; - class ConstIterator; - - /** Cast the container to a STL container type */ - STLContainerType & CastToSTLContainer() { - return dynamic_cast(*this); } - - /** Cast the container to a const STL container type */ - const STLContainerType & CastToSTLConstContainer() const { - return dynamic_cast(*this); } - - /** Friends to this class. */ - friend class Iterator; - friend class ConstIterator; - - class Iterator - { - public: - Iterator() {} - Iterator(size_type d, const VectorType* vec, const VectorIterator& i): m_Pos(d), m_Vector(vec), m_Iter(i) {} - - ElementPointer& operator* () { return *m_Iter; } - Element* operator-> () { return m_Iter == m_Vector->end() ? NULL : m_Iter->GetPointer(); } - ElementPointer& operator++ () { ++m_Pos; ++m_Iter; return *m_Iter; } - ElementPointer operator++ (int) { Iterator temp(*this); ++m_Pos; ++m_Iter; return *temp; } - ElementPointer& operator-- () { --m_Pos; --m_Iter; return *this; } - ElementPointer operator-- (int) { Iterator temp(*this); --m_Pos; --m_Iter; return *temp; } - - bool operator == (const Iterator& r) const { return m_Iter == r.m_Iter; } - bool operator != (const Iterator& r) const { return m_Iter != r.m_Iter; } - bool operator == (const ConstIterator& r) const { return m_Iter == r.m_Iter; } - bool operator != (const ConstIterator& r) const { return m_Iter != r.m_Iter; } - - /** Get the index into the SmartPointerVectorContainer associated with this iterator. */ - ElementIdentifier Index(void) const { return static_cast( m_Pos ); } - - /** Get the value at this iterator's location in the SmartPointerVectorContainer. */ - Element* Value(void) const { return m_Iter->GetPointer(); } - - private: - size_type m_Pos; - const VectorType* m_Vector; - VectorIterator m_Iter; - friend class ConstIterator; - }; - - class ConstIterator - { - public: - ConstIterator() {} - ConstIterator(size_type d, const VectorType* vec, const VectorConstIterator& i): m_Pos(d), m_Vector(vec), m_Iter(i) {} - ConstIterator(const Iterator& r): m_Pos(r.m_Pos), m_Vector(r.m_Vector), m_Iter(r.m_Iter) {} - - ConstElementPointer operator* () { return ConstElementPointer(m_Iter == m_Vector->end() ? NULL : m_Iter->GetPointer()); } - ConstElement* operator-> () { return m_Iter == m_Vector->end() ? NULL : m_Iter->GetPointer(); } - ConstElementPointer operator++ () { ++m_Pos; ++m_Iter; return ConstElementPointer(m_Iter == m_Vector->end() ? NULL : m_Iter->GetPointer()); } - ConstElementPointer operator++ (int) { ConstIterator temp(*this); ++m_Pos; ++m_Iter; return *temp; } - ConstElementPointer operator-- () { --m_Pos; --m_Iter; return ConstElementPointer(m_Iter == m_Vector->end() ? NULL : m_Iter->GetPointer()); } - ConstElementPointer operator-- (int) { ConstIterator temp(*this); --m_Pos; --m_Iter; return *temp; } - - ConstIterator& operator = (const Iterator& r) { m_Pos = r.m_Pos; m_Iter = r.m_Iter; return *this; } - - bool operator == (const Iterator& r) const { return m_Iter == r.m_Iter; } - bool operator != (const Iterator& r) const { return m_Iter != r.m_Iter; } - bool operator == (const ConstIterator& r) const { return m_Iter == r.m_Iter; } - bool operator != (const ConstIterator& r) const { return m_Iter != r.m_Iter; } - - /** Get the index into the SmartPointerVectorContainer associated with this iterator. */ - ElementIdentifier Index(void) const { return static_cast( m_Pos ); } - - /** Get the value at this iterator's location in the SmartPointerVectorContainer. */ - const Element* Value(void) const { return m_Iter->GetPointer(); } - - private: - size_type m_Pos; - const VectorType* m_Vector; - VectorConstIterator m_Iter; - friend class Iterator; - }; - - /** Declare the public interface routines. */ - ElementPointer& ElementAt(ElementIdentifier); - ConstElementPointer ElementAt(ElementIdentifier) const; // no need to return reference, because assignment not allowed! - ElementPointer& CreateElementAt(ElementIdentifier); - ConstElementPointer GetElement(ElementIdentifier) const; - void SetElement(ElementIdentifier, Element*); - void InsertElement(ElementIdentifier, Element*); - bool IndexExists(ElementIdentifier) const; - bool GetElementIfIndexExists(ElementIdentifier, Element**) const; - void CreateIndex(ElementIdentifier); - void DeleteIndex(ElementIdentifier); - ConstIterator Begin(void) const; - ConstIterator End(void) const; - Iterator Begin(void); - Iterator End(void); - unsigned long Size(void) const; - void Reserve(ElementIdentifier); - void Squeeze(void); - void Initialize(void); - -}; - -} // end namespace itk - -#ifndef ITK_MANUAL_INSTANTIATION -#include "itkSmartPointerVectorContainer.txx" -#endif - -#endif - - diff --git a/Modules/Ext/DataManagement/itkSmartPointerVectorContainer.txx b/Modules/Ext/DataManagement/itkSmartPointerVectorContainer.txx deleted file mode 100644 index dc8d9feffd..0000000000 --- a/Modules/Ext/DataManagement/itkSmartPointerVectorContainer.txx +++ /dev/null @@ -1,316 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -/*=================================================================== - -This file is based heavily on a corresponding ITK filter. - -===================================================================*/ -#ifndef _itkSmartPointerVectorContainer_txx -#define _itkSmartPointerVectorContainer_txx -#include "itkSmartPointerVectorContainer.h" - -#include "itkNumericTraits.h" - -namespace itk -{ - -/** - * Get a reference to the element at the given index. - * It is assumed that the index exists, and it will not automatically - * be created. - * - * It is assumed that the value of the element is modified through the - * reference. - */ -template -typename SmartPointerVectorContainer< TElementIdentifier , TElement >::ElementPointer& -SmartPointerVectorContainer< TElementIdentifier , TElement > -::ElementAt(ElementIdentifier id) -{ - this->Modified(); - return this->VectorType::operator[](id); -} - -/** - * Get a reference to the element at the given index. - * It is assumed that the index exists, and it will not automatically - * be created. - * - */ -template -const typename SmartPointerVectorContainer< TElementIdentifier , TElement >::ConstElementPointer -SmartPointerVectorContainer< TElementIdentifier , TElement > -::ElementAt(ElementIdentifier id) const -{ - return ConstElementPointer(this->VectorType::operator[](id)); -} - - -/** - * Get a reference to the element at the given index. - * If the element location does not exist, it will be created with a - * default element value. - * - * It is assumed that the value of the element is modified through the - * reference. - */ -template -typename SmartPointerVectorContainer< TElementIdentifier , TElement >::ElementPointer& -SmartPointerVectorContainer< TElementIdentifier , TElement > -::CreateElementAt(ElementIdentifier id) -{ - if(id >= this->VectorType::size()) - { - this->CreateIndex(id); - } - this->Modified(); - return this->VectorType::operator[](id); -} - - -/** - * Read the element from the given index. - * It is assumed that the index exists. - */ -template -const typename SmartPointerVectorContainer< TElementIdentifier , TElement >::ConstElementPointer -SmartPointerVectorContainer< TElementIdentifier , TElement > -::GetElement(ElementIdentifier id) const -{ - return ConstElementPointer(this->VectorType::operator[](id).GetPointer()); -} - - -/** - * Set the element value at the given index. - * It is assumed that the index exists. - */ -template -void -SmartPointerVectorContainer< TElementIdentifier , TElement > -::SetElement(ElementIdentifier id, Element* element) -{ - this->VectorType::operator[](id) = element; - this->Modified(); -} - - -/** - * Set the element value at the given index. - * If the element location does not exist, it will be created with a - * default element value. - */ -template -void -SmartPointerVectorContainer< TElementIdentifier , TElement > -::InsertElement(ElementIdentifier id, Element* element) -{ - if(id >= static_cast(this->VectorType::size())) - { - this->CreateIndex(id); - } - this->VectorType::operator[](id) = element; - this->Modified(); -} - - -/** - * Check if the index range of the STL vector is large enough to allow the - * given index without expansion. - */ -template -bool -SmartPointerVectorContainer< TElementIdentifier , TElement > -::IndexExists(ElementIdentifier id) const -{ - return (NumericTraits::IsNonnegative(id) - && (id < this->VectorType::size())); -} - - - -/** - * Check if the given index is in range of the STL vector. If it is not, - * return false. Otherwise, set the element through the pointer (if it isn't - * NULL), and return true. - */ -template -bool -SmartPointerVectorContainer< TElementIdentifier , TElement > -::GetElementIfIndexExists(ElementIdentifier id, Element** element) const -{ - if (NumericTraits::IsNonnegative(id) - && (id < this->VectorType::size())) - { - if(element) - { - *element = this->VectorType::operator[](id).GetPointer(); - } - return true; - } - return false; -} - - -/** - * Make sure that the index range of the STL vector is large enough to allow - * the given index, expanding it if necessary. The index will contain - * the default element regardless of whether expansion occured. - */ -template -void -SmartPointerVectorContainer< TElementIdentifier , TElement > -::CreateIndex(ElementIdentifier id) -{ - if(id >= static_cast(this->VectorType::size())) - { - /** - * The vector must be expanded to fit the - * new id. - */ - this->VectorType::resize(id+1); - this->Modified(); - } - else if(id > 0) - { - /** - * No expansion was necessary. Just overwrite the index's entry with - * the default element. - */ - this->VectorType::operator[](id) = NULL; - this->Modified(); - } -} - - -/** - * It doesn't make sense to delete a vector index. - * Instead, just overwrite the index with the default element. - */ -template -void -SmartPointerVectorContainer< TElementIdentifier , TElement > -::DeleteIndex(ElementIdentifier id) -{ - this->VectorType::operator[](id) = NULL; - this->Modified(); -} - - -/** - * Get a begin const iterator for the vector. - */ -template -typename SmartPointerVectorContainer< TElementIdentifier , TElement >::ConstIterator -SmartPointerVectorContainer< TElementIdentifier , TElement > -::Begin(void) const -{ - return ConstIterator(0, this, this->VectorType::begin()); -} - - -/** - * Get an end const iterator for the vector. - */ -template -typename SmartPointerVectorContainer< TElementIdentifier , TElement >::ConstIterator -SmartPointerVectorContainer< TElementIdentifier , TElement > -::End(void) const -{ - return ConstIterator(this->VectorType::size()-1, this, this->VectorType::end()); -} - - -/** - * Get a begin iterator for the vector. - */ -template -typename SmartPointerVectorContainer< TElementIdentifier , TElement >::Iterator -SmartPointerVectorContainer< TElementIdentifier , TElement > -::Begin(void) -{ - return Iterator(0, this, this->VectorType::begin()); -} - - -/** - * Get an end iterator for the vector. - */ -template -typename SmartPointerVectorContainer< TElementIdentifier , TElement >::Iterator -SmartPointerVectorContainer< TElementIdentifier , TElement > -::End(void) -{ - return Iterator(this->VectorType::size()-1, this, this->VectorType::end()); -} - - -/** - * Get the number of elements currently stored in the vector. - */ -template -unsigned long -SmartPointerVectorContainer< TElementIdentifier , TElement > -::Size(void) const -{ - return static_cast( this->VectorType::size() ); -} - - -/** - * Clear the elements. The final size will be zero. - */ -template -void -SmartPointerVectorContainer< TElementIdentifier , TElement > -::Initialize(void) -{ - this->VectorType::clear(); -} - - - -/** - * Tell the container to allocate enough memory to allow at least - * as many elements as the size given to be stored. This is NOT - * guaranteed to actually allocate any memory, but is useful if the - * implementation of the container allocates contiguous storage. - */ -template -void -SmartPointerVectorContainer< TElementIdentifier , TElement > -::Reserve(ElementIdentifier size) -{ - this->CreateIndex(size-1); -} - - -/** - * Tell the container to try to minimize its memory usage for storage of - * the current number of elements. This is NOT guaranteed to decrease - * memory usage. - */ -template -void -SmartPointerVectorContainer< TElementIdentifier , TElement > -::Squeeze(void) -{ -} - -} // end namespace itk - -#endif diff --git a/Modules/Ext/DataManagement/mitkAffineTransformationOperation.cpp b/Modules/Ext/DataManagement/mitkAffineTransformationOperation.cpp deleted file mode 100644 index 3e20f7dea5..0000000000 --- a/Modules/Ext/DataManagement/mitkAffineTransformationOperation.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkAffineTransformationOperation.h" - -mitk::AffineTransformationOperation::AffineTransformationOperation(OperationType operationType,Point3D point, ScalarType angle, int index) - : mitk::PointOperation(operationType, point, index), m_Angle(angle) -{ -} - -mitk::AffineTransformationOperation::~AffineTransformationOperation(void) -{ -} - -mitk::ScalarType mitk::AffineTransformationOperation::GetAngle() -{ - return m_Angle; -} - diff --git a/Modules/Ext/DataManagement/mitkAffineTransformationOperation.h b/Modules/Ext/DataManagement/mitkAffineTransformationOperation.h deleted file mode 100644 index 95171dd660..0000000000 --- a/Modules/Ext/DataManagement/mitkAffineTransformationOperation.h +++ /dev/null @@ -1,45 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKAFFINETRANSFORMATIONOPERATION_H_HEADER_INCLUDED -#define MITKAFFINETRANSFORMATIONOPERATION_H_HEADER_INCLUDED - -#include "mitkPointOperation.h" -#include "MitkExtExports.h" -#include "mitkNumericTypes.h" - -namespace mitk { - -//##Documentation -//## @brief Operation, that holds everything necessary for an affine operation. -//## -//## @ingroup Undo -class MitkExt_EXPORT AffineTransformationOperation : public PointOperation -{ -public: - AffineTransformationOperation(OperationType operationType, Point3D point, ScalarType angle, int index); - virtual ~AffineTransformationOperation(void); - ScalarType GetAngle(); -protected: - ScalarType m_Angle; -}; - -} // namespace mitk - -#endif /* MITKAFFINETRANSFORMATIONOPERATION_H_HEADER_INCLUDED */ - - diff --git a/Modules/Ext/DataManagement/mitkColorSequenceHalfTones.cpp b/Modules/Ext/DataManagement/mitkColorSequenceHalfTones.cpp deleted file mode 100644 index e613c942dc..0000000000 --- a/Modules/Ext/DataManagement/mitkColorSequenceHalfTones.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#include "mitkColorSequenceHalfTones.h" -#include -namespace mitk -{ - -ColorSequenceHalfTones::ColorSequenceHalfTones() -{ - m_ColorIndex = 0; - m_Color.SetRed(1.0); - m_Color.SetGreen(0.67); - m_Color.SetBlue(0.0); - InitColorList(); -}//end of constructor - - -ColorSequenceHalfTones::~ColorSequenceHalfTones() -{ - -}//end of destructor - -Color ColorSequenceHalfTones::GetNextColor() -{ - m_Color = m_ColorList[m_ColorIndex]; - - if(m_ColorIndex < m_ColorList.size()) - { - m_ColorIndex++; - } - else - { - m_ColorIndex = 0; - } - return m_Color; -}//end of GetNextMitkColor() - -void ColorSequenceHalfTones::InitColorList() -{ - - Color defaultColor, red, green, blue, yellow, magenta, cyan, orange; - defaultColor.Set(1.0, 0.67, 0.0); - red.Set(1.0, 0.6, 0.6); - green.Set(0.6, 1.0, 0.6); - blue.Set(0.6, 0.6, 1.0); - yellow.Set(1.0, 1.0, 0.6); - magenta.Set(1.0, 0.6, 1.0); - cyan.Set(0.6, 1.0, 1.0); - orange.Set(1.0, 0.8, 0.6); - //m_ColorList.push_back(defaultColor); - m_ColorList.push_back(red); - m_ColorList.push_back(yellow); - m_ColorList.push_back(blue); - m_ColorList.push_back(green); - m_ColorList.push_back(magenta); - m_ColorList.push_back(cyan); - m_ColorList.push_back(orange); - m_ColorList.push_back(defaultColor); - - -}// end of ColorList - -void ColorSequenceHalfTones::GoToBegin() -{ - m_ColorIndex = 0; -} - -}//end of namespace - diff --git a/Modules/Ext/DataManagement/mitkColorSequenceHalfTones.h b/Modules/Ext/DataManagement/mitkColorSequenceHalfTones.h deleted file mode 100644 index 59c44d426b..0000000000 --- a/Modules/Ext/DataManagement/mitkColorSequenceHalfTones.h +++ /dev/null @@ -1,68 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#ifndef MITKCOLORSEQUENCEHALFTONES_H_URTESEINDEUTIGEKENNUNG_03 -#define MITKCOLORSEQUENCEHALFTONES_H_URTESEINDEUTIGEKENNUNG_03 - -#include "mitkColorSequence.h" -#include "MitkExtExports.h" - -namespace mitk -{ - class MitkExt_EXPORT ColorSequenceHalfTones : public ColorSequence - { - public: - ColorSequenceHalfTones(); - virtual ~ColorSequenceHalfTones(); - - /*! - \brief method to return another color - */ - virtual Color GetNextColor(); - - /*! - \brief method to set the color-index to begin again - */ - virtual void GoToBegin(); - - - private: - /*! - \brief method that fills the pre-defnied colors - */ - void InitColorList(); - - /*! - \brief global color-object that holds the actual color and changes to the next one - */ - Color m_Color; - - /*! - \brief color-index to iterate through the colors - */ - unsigned int m_ColorIndex; - - /*! - \brief vector-List with all pre-defined colors - */ - std::vector m_ColorList; - - }; - -} - -#endif - - diff --git a/Modules/Ext/DataManagement/mitkDataTreeFilterEvents.h b/Modules/Ext/DataManagement/mitkDataTreeFilterEvents.h deleted file mode 100644 index 0eb74a6d85..0000000000 --- a/Modules/Ext/DataManagement/mitkDataTreeFilterEvents.h +++ /dev/null @@ -1,290 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef MITK_DATATREEFILTEREVENTS_H_INCLUDED -#define MITK_DATATREEFILTEREVENTS_H_INCLUDED - -#pragma GCC visibility push(default) -#include -#pragma GCC visibility pop -#include "MitkExtExports.h" - -namespace mitk { - -//------ TreeFilterUpdateAllEvent -------------------------------------------------------- - -#pragma GCC visibility push(default) -itkEventMacro( TreeFilterUpdateAllEvent, itk::ModifiedEvent ); -itkEventMacro( TreeFilterRemoveAllEvent, itk::ModifiedEvent ); -#pragma GCC visibility pop - -//------ TreeFilterItemEvent ------------------------------------------------------------- - class MitkExt_EXPORT TreeFilterItemEvent : public itk::ModifiedEvent - { - public: - typedef TreeFilterItemEvent Self; - typedef itk::ModifiedEvent Superclass; - - TreeFilterItemEvent() - : m_ChangedItem( NULL ){} - - TreeFilterItemEvent( const mitk::DataTreeFilter::Item* item ) : - m_ChangedItem(item) {} - - virtual ~TreeFilterItemEvent() {} - - virtual const char * GetEventName() const - { - return "TreeFilterItemEvent"; - } - - virtual bool CheckEvent(const ::itk::EventObject* e) const - { - return dynamic_cast(e); - } - - virtual ::itk::EventObject* MakeObject() const - { - return new Self( m_ChangedItem ); - } - - const mitk::DataTreeFilter::Item* GetChangedItem() const - { - return m_ChangedItem; - } - - TreeFilterItemEvent(const Self& s) : itk::ModifiedEvent(s), m_ChangedItem(s.m_ChangedItem) {}; - - protected: - const mitk::DataTreeFilter::Item* m_ChangedItem; - - private: - void operator=(const Self&); - - }; - -//------ TreeFilterEvent -------------------------------------------------------- - class MitkExt_EXPORT TreeFilterNewItemEvent : public TreeFilterItemEvent - { - public: - typedef TreeFilterNewItemEvent Self; - typedef TreeFilterItemEvent Superclass; - - TreeFilterNewItemEvent() : TreeFilterItemEvent() {} - TreeFilterNewItemEvent(const mitk::DataTreeFilter::Item* item) : TreeFilterItemEvent(item) {} - - virtual ~TreeFilterNewItemEvent() {} - - virtual const char * GetEventName() const - { - return "TreeFilterNewItemEvent"; - } - - virtual bool CheckEvent(const ::itk::EventObject* e) const - { - return dynamic_cast(e); - } - - virtual ::itk::EventObject* MakeObject() const - { - return new Self( m_ChangedItem ); - } - - TreeFilterNewItemEvent(const Self& s) : TreeFilterItemEvent(s) {}; - - private: - void operator=(const Self&); - - }; - - -//------ TreeFilterItemAddedEvent -------------------------------------------------------- - class MitkExt_EXPORT TreeFilterItemAddedEvent : public TreeFilterItemEvent - { - public: - typedef TreeFilterItemAddedEvent Self; - typedef TreeFilterItemEvent Superclass; - - TreeFilterItemAddedEvent() : TreeFilterItemEvent() {} - TreeFilterItemAddedEvent(const mitk::DataTreeFilter::Item* item) : TreeFilterItemEvent(item) {} - - virtual ~TreeFilterItemAddedEvent() {} - - virtual const char * GetEventName() const - { - return "TreeFilterItemAddedEvent"; - } - - virtual bool CheckEvent(const ::itk::EventObject* e) const - { - return dynamic_cast(e); - } - - virtual ::itk::EventObject* MakeObject() const - { - return new Self( m_ChangedItem ); - } - - TreeFilterItemAddedEvent(const Self& s) : TreeFilterItemEvent(s) {}; - - private: - void operator=(const Self&); - - }; - -//------ TreeFilterSelectionChangedEvent ------------------------------------------------- - class MitkExt_EXPORT TreeFilterSelectionChangedEvent : public TreeFilterItemEvent - { - public: - typedef TreeFilterSelectionChangedEvent Self; - typedef TreeFilterItemEvent Superclass; - - TreeFilterSelectionChangedEvent() : TreeFilterItemEvent() {} - TreeFilterSelectionChangedEvent(const mitk::DataTreeFilter::Item* item, bool selected) : TreeFilterItemEvent(item), m_Selected(selected) {} - - virtual ~TreeFilterSelectionChangedEvent() {} - - virtual const char * GetEventName() const - { - return "TreeFilterSelectionChangedEvent"; - } - - virtual bool CheckEvent(const ::itk::EventObject* e) const - { - return dynamic_cast(e); - } - - virtual ::itk::EventObject* MakeObject() const - { - return new Self( m_ChangedItem, m_Selected ); - } - - virtual bool IsSelected() const { return m_Selected; } - - TreeFilterSelectionChangedEvent(const Self&s) : TreeFilterItemEvent(s) {}; - private: - void operator=(const Self&); - - bool m_Selected; - - }; - - //------ TreeFilterItemChangedEvent ------------------------------------------------------ - class MitkExt_EXPORT TreeFilterItemChangedEvent : public TreeFilterItemEvent - { - public: - typedef TreeFilterItemChangedEvent Self; - typedef TreeFilterItemEvent Superclass; - - TreeFilterItemChangedEvent() : TreeFilterItemEvent() {} - TreeFilterItemChangedEvent(const mitk::DataTreeFilter::Item* item) : TreeFilterItemEvent(item) {} - - virtual ~TreeFilterItemChangedEvent() {} - - virtual const char * GetEventName() const - { - return "TreeFilterItemChangedEvent"; - } - - virtual bool CheckEvent(const ::itk::EventObject* e) const - { - return dynamic_cast(e); - } - - virtual ::itk::EventObject* MakeObject() const - { - return new Self( m_ChangedItem ); - } - - TreeFilterItemChangedEvent(const Self&s) : TreeFilterItemEvent(s) {}; - - private: - void operator=(const Self&); - - }; - -//------ TreeFilterRemoveItemEvent ------------------------------------------------------- - class MitkExt_EXPORT TreeFilterRemoveItemEvent : public TreeFilterItemEvent - { - public: - typedef TreeFilterRemoveItemEvent Self; - typedef TreeFilterItemEvent Superclass; - - TreeFilterRemoveItemEvent() : TreeFilterItemEvent() {} - TreeFilterRemoveItemEvent(const mitk::DataTreeFilter::Item* item) : TreeFilterItemEvent(item) {} - - virtual ~TreeFilterRemoveItemEvent() {} - - virtual const char * GetEventName() const - { - return "TreeFilterRemoveItemEvent"; - } - - virtual bool CheckEvent(const ::itk::EventObject* e) const - { - return dynamic_cast(e); - } - - virtual ::itk::EventObject* MakeObject() const - { - return new Self( m_ChangedItem ); - } - - TreeFilterRemoveItemEvent(const Self&s) : TreeFilterItemEvent(s) {}; - - private: - void operator=(const Self&); - - }; - -//------ TreeFilterRemoveChildrenEvent ------------------------------------------------------- - class MitkExt_EXPORT TreeFilterRemoveChildrenEvent : public TreeFilterItemEvent - { - public: - typedef TreeFilterRemoveChildrenEvent Self; - typedef TreeFilterItemEvent Superclass; - - TreeFilterRemoveChildrenEvent() : TreeFilterItemEvent() {} - TreeFilterRemoveChildrenEvent(const mitk::DataTreeFilter::Item* item) : TreeFilterItemEvent(item) {} - - virtual ~TreeFilterRemoveChildrenEvent() {} - - virtual const char * GetEventName() const - { - return "TreeFilterRemoveChildrenEvent"; - } - - virtual bool CheckEvent(const ::itk::EventObject* e) const - { - return dynamic_cast(e); - } - - virtual ::itk::EventObject* MakeObject() const - { - return new Self( m_ChangedItem ); - } - - TreeFilterRemoveChildrenEvent(const Self&s) : TreeFilterItemEvent(s) {}; - - private: - void operator=(const Self&); - - }; -} - -#endif - - diff --git a/Modules/Ext/DataManagement/mitkDataTreeFilterFunctions.cpp b/Modules/Ext/DataManagement/mitkDataTreeFilterFunctions.cpp deleted file mode 100644 index f9cafd5028..0000000000 --- a/Modules/Ext/DataManagement/mitkDataTreeFilterFunctions.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include -#include "mitkDataNode.h" - -namespace mitk -{ - -bool DataTreeFilterFunction::operator()(DataNode* node) const -{ - return NodeMatches(node); -} - -bool IsDataNode::NodeMatches(DataNode* node) const -{ - return ( node != NULL ); -} - -DataTreeFilterFunction* IsDataNode::Clone() const -{ - return new IsDataNode(); -} - -bool IsGoodDataNode::NodeMatches(DataNode* node) const -{ - return ( node != NULL && node->GetData() ); -} - -DataTreeFilterFunction* IsGoodDataNode::Clone() const -{ - return new IsGoodDataNode(); -} - -bool IsInResultSet::NodeMatches(DataNode* node) const -{ - if ((node == NULL) || (m_ResultSet.empty())) - return false; - - return (std::find(m_ResultSet.begin(), m_ResultSet.end(), node) != m_ResultSet.end()); // search for node in resultset -} - -DataTreeFilterFunction* IsInResultSet::Clone() const -{ - return new IsInResultSet(m_ResultSet); -} - -} // namespace - diff --git a/Modules/Ext/DataManagement/mitkDataTreeFilterFunctions.h b/Modules/Ext/DataManagement/mitkDataTreeFilterFunctions.h deleted file mode 100644 index 76bd5d9dae..0000000000 --- a/Modules/Ext/DataManagement/mitkDataTreeFilterFunctions.h +++ /dev/null @@ -1,330 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef MITK_DATATREEFILTERFUNCTOINS_H_INCLUDED -#define MITK_DATATREEFILTERFUNCTOINS_H_INCLUDED - -#include -#include "MitkExtExports.h" - -#include -#include - -namespace mitk -{ - class DataNode; - - /*! \brief Base class for all filter function that are accepted by mitk::DataTreeFilter. - - Subclasses are required to implement the Clone() method, which should return a copy of - the object, and the NodeMatches() method. NodeMatches() will receive a - mitk::DataNode* everytime it is called, and should return true. This pointer can be NULL. - */ - class MitkExt_EXPORT DataTreeFilterFunction - { - public: - virtual ~DataTreeFilterFunction() {} - virtual bool operator()(DataNode*) const; - virtual bool NodeMatches(DataNode*) const = 0; - virtual DataTreeFilterFunction* Clone() const = 0; - }; - - /*! \brief tests the data entry of nodes for a specific type (given here as template parameter). - - To be used with mitk::DataTreeFilter, e.g. - \code - treeFilter->SetFilter( mitk::IsBaseDataType() ); - \endcode - */ - template - class IsBaseDataType : public DataTreeFilterFunction - { - public: - virtual bool NodeMatches(DataNode* node) const - { - return ( node != NULL && node->GetData() && dynamic_cast(node->GetData()) ); - } - - virtual DataTreeFilterFunction* Clone() const - { - return new IsBaseDataType(); - } - - virtual ~IsBaseDataType() {} - }; - - /*! \brief Tests the data entry of nodes for a specific type (given here as template parameter) AND having a given property. - - To be used with mitk::DataTreeFilter, e.g. - \code - treeFilter->SetFilter( mitk::IsBaseDataTypeWithProperty("volume") ); - \endcode - */ - template - class IsBaseDataTypeWithProperty : public DataTreeFilterFunction - { - public: - - IsBaseDataTypeWithProperty(const char* propertyName) - :m_PropertyName(propertyName) - { - } - - virtual bool NodeMatches(DataNode* node) const - { - return ( node != NULL && node->GetData() // node is not NULL, and node->GetData is also not NULL - && dynamic_cast(node->GetData() ) // data is of a certain type - && ( node->GetProperty(m_PropertyName.c_str())!= NULL // there is a certain property - ) - ); - } - - virtual DataTreeFilterFunction* Clone() const - { - return new IsBaseDataTypeWithProperty(m_PropertyName.c_str()); - } - - virtual ~IsBaseDataTypeWithProperty() {} - - private: - - std::string m_PropertyName; - }; - - /*! \brief Tests the data entry of nodes for a specific type (given here as template parameter) AND having a TRUE BoolProperty. - - To be used with mitk::DataTreeFilter, e.g. - \code - treeFilter->SetFilter( mitk::IsBaseDataTypeWithBoolProperty("segmentation") ); - \endcode - */ - template - class IsBaseDataTypeWithBoolProperty : public DataTreeFilterFunction - { - public: - - IsBaseDataTypeWithBoolProperty(const char* propertyName) - :m_PropertyName(propertyName) - { - } - - virtual bool NodeMatches(DataNode* node) const - { - bool propVal(false); - return ( node != NULL && node->GetData() // node is not NULL, and node->GetData is also not NULL - && dynamic_cast( node->GetData() ) // data is of a certain type - && node->GetPropertyValue(m_PropertyName.c_str(), propVal) // there is a certain BoolProperty - && propVal - ); - } - - virtual DataTreeFilterFunction* Clone() const - { - return new IsBaseDataTypeWithBoolProperty(m_PropertyName.c_str()); - } - - virtual ~IsBaseDataTypeWithBoolProperty() {} - - private: - - std::string m_PropertyName; - }; - - - /*! \brief Tests the data entry of nodes for a specific type (given here as template parameter) AND for NOT having a given property (or it being a false bool property). - - To be used with mitk::DataTreeFilter, e.g. - \code - treeFilter->SetFilter( mitk::IsBaseDataTypeWithoutProperty("segmentation") ); - \endcode - */ - template - class IsBaseDataTypeWithoutProperty : public DataTreeFilterFunction - { - public: - - IsBaseDataTypeWithoutProperty(const char* propertyName) - :m_PropertyName(propertyName) - { - } - - virtual bool NodeMatches(DataNode* node) const - { - bool propVal(false); - bool propertyExists(false); - - if (node) - propertyExists = node->GetPropertyValue(m_PropertyName.c_str(), propVal ); - - return ( node != NULL && node->GetData() // node is not NULL, and node->GetData is also not NULL - && dynamic_cast(node->GetData() ) // data is of a certain type - && ( !propertyExists || !propVal )); // the property does not exist, OR its value is false - } - - virtual DataTreeFilterFunction* Clone() const - { - return new IsBaseDataTypeWithoutProperty(m_PropertyName.c_str()); - } - - virtual ~IsBaseDataTypeWithoutProperty() {} - - private: - - std::string m_PropertyName; - }; - - - // some default filters in mitk:: namespace for use by clients of mitk::DataTreeFilter - - /*! \brief Accepts all nodes (accepts nodes that are not NULL). - - To be used with mitk::DataTreeFilter, e.g. - \code - treeFilter->SetFilter( mitk::IsBaseDataTypeWithoutProperty("segmentation") ); - \endcode - */ - class MitkExt_EXPORT IsDataNode : public DataTreeFilterFunction - { - public: - virtual ~IsDataNode() {} - virtual bool NodeMatches(DataNode*) const; - virtual DataTreeFilterFunction* Clone() const; - }; - - /*! \brief Accepts all data objects (accepts nodes that have associated mitk::BaseData (tested via GetData)). - - To be used with mitk::DataTreeFilter, e.g. - \code - treeFilter->SetFilter( mitk::IsBaseDataTypeWithoutProperty("segmentation") ); - \endcode - */ - class MitkExt_EXPORT IsGoodDataNode : public DataTreeFilterFunction - { - public: - virtual ~IsGoodDataNode() {} - virtual bool NodeMatches(DataNode*) const; - virtual DataTreeFilterFunction* Clone() const; - }; - - /*! \brief Accepts all data objects (accepts nodes that have associated mitk::BaseData (tested via GetData)). - - To be used with mitk::DataTreeFilter, e.g. - \code - treeFilter->SetFilter( mitk::IsBaseDataTypeWithoutProperty("segmentation") ); - \endcode - */ - class MitkExt_EXPORT IsInResultSet : public DataTreeFilterFunction - { - public: - IsInResultSet( std::set rs ) - :m_ResultSet(rs) - { - } - - IsInResultSet(const DataStorage::SetOfObjects* rs) - { - if (rs) - { - for (DataStorage::SetOfObjects::const_iterator iter = rs->begin(); - iter != rs->end(); - ++iter) - { - m_ResultSet.insert( iter->GetPointer() ); - } - } - } - - virtual ~IsInResultSet() {} - virtual bool NodeMatches(DataNode*) const; - virtual DataTreeFilterFunction* Clone() const; - protected: - //DataStorage::SetOfObjects::ConstPointer m_ResultSet; - std::set m_ResultSet; - }; - - /*! \brief Tests if the node contains an image with a specified dimensionality (template parameter) - - To be used with mitk::DataTreeFilter, e.g. - \code - treeFilter->SetFilter( mitk::ImageWithDimensionAndProperty<3>("volume") ); - \endcode - */ - template - class IsImageWithDimensionAndWithoutProperty : public DataTreeFilterFunction - { - public: - - IsImageWithDimensionAndWithoutProperty(const char* propertyName) - :m_PropertyName(propertyName) - { - } - - virtual bool NodeMatches(DataNode* node) const - { - return ( node != NULL && node->GetData() // node is not NULL, and node->GetData is also not NULL - && dynamic_cast(node->GetData() ) // data is an image - && (dynamic_cast(node->GetData() )->GetDimension() == DIM) - && ( node->GetProperty(m_PropertyName.c_str()) == NULL // there is a certain property - ) - ); - } - - virtual DataTreeFilterFunction* Clone() const - { - return new IsImageWithDimensionAndWithoutProperty(m_PropertyName.c_str()); - } - - virtual ~IsImageWithDimensionAndWithoutProperty() {} - - private: - - std::string m_PropertyName; - }; - - /*! \brief Tests if the node contains an image with a dimensionality greater or equal to the template parameter - - To be used with mitk::DataTreeFilter, e.g. - \code - treeFilter->SetFilter( mitk::IsImageWithMinimumDimension<3>() ); - \endcode - */ - template - class IsImageWithMinimumDimension : public DataTreeFilterFunction - { - public: - - virtual bool NodeMatches(DataNode* node) const - { - return ( node != NULL && node->GetData() // node is not NULL, and node->GetData is also not NULL - && dynamic_cast(node->GetData() ) // data is an image - && (dynamic_cast(node->GetData() )->GetDimension() >= DIM) - ); - } - - virtual DataTreeFilterFunction* Clone() const - { - return new IsImageWithMinimumDimension(); - } - - virtual ~IsImageWithMinimumDimension() {} - }; - -} // namespace mitk - -#endif -// vi: textwidth=90 - - diff --git a/Modules/Ext/DataManagement/mitkDataTreeHelper.cpp b/Modules/Ext/DataManagement/mitkDataTreeHelper.cpp deleted file mode 100644 index 76249f7b7a..0000000000 --- a/Modules/Ext/DataManagement/mitkDataTreeHelper.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkDataTreeHelper.h" - -mitk::DataTreeIteratorClone mitk::DataTreeHelper::FindIteratorToNode( - mitk::DataTreeBase* tree, - const mitk::DataNode* node) -{ - if(tree == NULL) - return NULL; - - DataTreeIteratorClone pos = DataTreePreOrderIterator(tree); - - while ( !pos->IsAtEnd() ) - { - if ( pos->Get().GetPointer() == node ) - return pos; - ++pos; - } - return pos; -} - -mitk::DataTreeIteratorClone mitk::DataTreeHelper::FindIteratorToNode( - const mitk::DataTreeIteratorBase* startPosition, - const mitk::DataNode* node - ) -{ - DataTreeIteratorClone pos = *startPosition; - - while ( !pos->IsAtEnd() ) - { - if ( pos->Get().GetPointer() == node ) - return pos; - ++pos; - } - return pos; -} - -mitk::DataTreeIteratorClone mitk::DataTreeHelper::GetNamedChild(mitk::DataTreeIteratorBase* iterator, std::string name) -{ - mitk::DataTreeChildIterator childIterator(*iterator); - while (! childIterator.IsAtEnd() ) - { - mitk::DataNode* node = childIterator.Get(); - std::string nodeName; - if (node && node->GetName(nodeName)) - { - if (nodeName == name) - { - return DataTreeIteratorClone(childIterator); - } - } - ++childIterator; - } - return DataTreeIteratorClone(NULL); -} diff --git a/Modules/Ext/DataManagement/mitkDelegateManager.cpp b/Modules/Ext/DataManagement/mitkDelegateManager.cpp deleted file mode 100644 index 0029551f1b..0000000000 --- a/Modules/Ext/DataManagement/mitkDelegateManager.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkDelegateManager.h" - -mitk::DelegateManager::DelegateManager() -{ -} -mitk::DelegateManager* mitk::DelegateManager::GetInstance() -{ - static mitk::DelegateManager _DelegateManager; - return &_DelegateManager; -} - -void mitk::DelegateManager::SetCommand( const std::string& _CommandID, mitk::MessageAbstractDelegate<>* _Command) -{ - MessageAbstractDelegate<>* _ExistingCommand = this->GetCommand(_CommandID); - // delete existing MessageAbstractDelegate for id, but only if the existing MessageAbstractDelegate is not the same as the - // MessageAbstractDelegate parameter - if(_ExistingCommand && _ExistingCommand != _Command) - { - m_CommandMap.erase(_CommandID); - delete _ExistingCommand; - _ExistingCommand = 0; - } - m_CommandMap[_CommandID] = _Command; -} - -bool mitk::DelegateManager::RemoveCommand( const std::string& _CommandID ) -{ - MessageAbstractDelegate<>* _ExistingCommand = this->GetCommand(_CommandID); - if(_ExistingCommand) - { - m_CommandMap.erase(_CommandID); - delete _ExistingCommand; - _ExistingCommand = 0; - return true; - } - return false; -} - -mitk::MessageAbstractDelegate<>* mitk::DelegateManager::GetCommand( const std::string& _CommandID ) const -{ - std::map*>::const_iterator it = m_CommandMap.find(_CommandID); - return (it == m_CommandMap.end()) ? 0: it->second; -} - -mitk::DelegateManager::~DelegateManager() -{ - // delete all commands - for(std::map*>::iterator it=m_CommandMap.begin(); it!=m_CommandMap.end() - ; it++) - { - delete it->second; - it->second = 0; - } - - m_CommandMap.clear(); -} diff --git a/Modules/Ext/DataManagement/mitkDelegateManager.h b/Modules/Ext/DataManagement/mitkDelegateManager.h deleted file mode 100644 index 5dd7b360b3..0000000000 --- a/Modules/Ext/DataManagement/mitkDelegateManager.h +++ /dev/null @@ -1,83 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKDelegateManager_H_HEADER_INCLUDED -#define MITKDelegateManager_H_HEADER_INCLUDED - -#include "mitkMessage.h" -#include "MitkExtExports.h" -#include "mitkCommon.h" - -#include - -namespace mitk -{ - - /// - /// \brief Renames the mitk::MessageAbstractDelegate, which is a Functor to a simple function - /// with no params, to "Command". This should emphasize that it is not used as an event - /// function but rather as a command. - /// - //typedef MessageAbstractDelegate Command; - - /// - /// \class DelegateManager - /// \brief A class that stores commands (= mitk::Message) via a unique identifier. - /// One could also say it is an Event Multiplexer. - /// - /// - class MitkExt_EXPORT DelegateManager - { - public: - /// - /// \brief Singleton pattern. - /// - static DelegateManager* GetInstance(); - /// - /// \brief Adds or overwrites a Command. *Attention*: This is class is the owner of the Command. - /// Thus whenever a command is overwritten, the old Command is deleted! - /// - void SetCommand(const std::string& _CommandID, MessageAbstractDelegate<>*); - /// - /// \brief Removes and *deletes* the Command with the given id. - /// - bool RemoveCommand(const std::string& _CommandID); - /// - /// \brief Returns the Command with the given id or NULL if the _CommandID is unknown. - /// - MessageAbstractDelegate<>* GetCommand(const std::string& _CommandID) const; - /// - /// \brief Dtor: Deletes all commands and clears m_CommandMap. - /// - virtual ~DelegateManager(); - protected: - /// - /// \brief Singleton pattern: protected Ctor. - /// - DelegateManager(); - /// - /// \brief Maps IDs to Commands. - /// - std::map*> m_CommandMap; - - }; -} - - -#endif /* MITKDelegateManager_H_HEADER_INCLUDED */ - - diff --git a/Modules/Ext/DataManagement/mitkDrawOperation.cpp b/Modules/Ext/DataManagement/mitkDrawOperation.cpp deleted file mode 100755 index d40057251f..0000000000 --- a/Modules/Ext/DataManagement/mitkDrawOperation.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include - - -mitk::DrawOperation::DrawOperation(OperationType operationType, Point3D point, Point3D last_point, int draw_state, int radius) -: Operation(operationType), m_Point(point), m_LastPoint(last_point), m_DrawState(draw_state), m_Radius(radius) -{} - - -mitk::DrawOperation::~DrawOperation() -{ -} - - -mitk::Point3D mitk::DrawOperation::GetPoint() -{ - return m_Point; -} - -mitk::Point3D mitk::DrawOperation::GetLastPoint() -{ - return m_LastPoint; -} - -int mitk::DrawOperation::GetDrawState() -{ - return m_DrawState; -} - -int mitk::DrawOperation::GetRadius() -{ - return m_Radius; -} - -mitk::SeedsImage::Pointer mitk::DrawOperation::GetSeedsImage() -{ - return m_SeedsImage; -} - -mitk::SeedsImage::Pointer mitk::DrawOperation::GetLastSeedsImage() -{ - return m_LastSeedsImage; -} diff --git a/Modules/Ext/DataManagement/mitkDrawOperation.h b/Modules/Ext/DataManagement/mitkDrawOperation.h deleted file mode 100755 index eb7b818f9b..0000000000 --- a/Modules/Ext/DataManagement/mitkDrawOperation.h +++ /dev/null @@ -1,76 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKDRAWOPERATION_H -#define MITKDRAWOPERATION_H - -#include -#include "MitkExtExports.h" -#include -#include -#include -#include - -namespace mitk { - -//##Documentation -//## @brief DrawOperation, that handles all actions on seeds. -//## -//## Stores everything for adding and deleting seeds. -//## @ingroup Undo -class MitkExt_EXPORT DrawOperation : public Operation -{ - public: - //##Documentation - //##@brief DrawOperation, that handles all actions on seeds. - //## - //## @param operationType is the type of that operation (see mitkOperation.h; e.g. move or add; Information for StateMachine::ExecuteOperation()); - //## @param point is the information of the seedpoint to add to the seedsimage - //## @param last_point is the information of the point added before - //## @param draw_state represents the seeds type e.g foreground or background seeds - //## @param radius is the radius of seeds - DrawOperation(OperationType operationType, Point3D point, Point3D last_point, int draw_state, int radius); - - virtual ~DrawOperation(); - - Point3D GetPoint(); - - Point3D GetLastPoint(); - - int GetDrawState(); - - int GetRadius(); - - SeedsImage::Pointer GetSeedsImage(); - - SeedsImage::Pointer GetLastSeedsImage(); - - private: - Point3D m_Point; - Point3D m_LastPoint; - - int m_DrawState; - int m_Radius; - - SeedsImage::Pointer m_SeedsImage; - SeedsImage::Pointer m_LastSeedsImage; - -}; -}//namespace mitk -#endif /* MITKDRAWOPERATION_H*/ - - diff --git a/Modules/Ext/DataManagement/mitkExternAbstractTransformGeometry.cpp b/Modules/Ext/DataManagement/mitkExternAbstractTransformGeometry.cpp deleted file mode 100644 index a0dd3e6949..0000000000 --- a/Modules/Ext/DataManagement/mitkExternAbstractTransformGeometry.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkExternAbstractTransformGeometry.h" -#include - -mitk::ExternAbstractTransformGeometry::ExternAbstractTransformGeometry() -{ -} -mitk::ExternAbstractTransformGeometry::ExternAbstractTransformGeometry(const ExternAbstractTransformGeometry& other) : Superclass(other) -{ -} - -mitk::ExternAbstractTransformGeometry::~ExternAbstractTransformGeometry() -{ -} - -void mitk::ExternAbstractTransformGeometry::SetVtkAbstractTransform(vtkAbstractTransform* aVtkAbstractTransform) -{ - Superclass::SetVtkAbstractTransform(aVtkAbstractTransform); -} - -void mitk::ExternAbstractTransformGeometry::SetPlane(const mitk::PlaneGeometry* aPlane) -{ - Superclass::SetPlane(aPlane); -} - -void mitk::ExternAbstractTransformGeometry::SetParametricBounds(const BoundingBox::BoundsArrayType& bounds) -{ - Superclass::SetParametricBounds(bounds); - //@warning affine-transforms and bounding-box should be set by specific sub-classes! - SetBounds(bounds); - - if(m_Plane.IsNotNull()) - { - m_Plane->SetSizeInUnits(bounds[1]-bounds[0], bounds[3]-bounds[2]); - m_Plane->SetBounds(bounds); - } -} - -itk::LightObject::Pointer mitk::ExternAbstractTransformGeometry::InternalClone() const -{ - Self::Pointer newGeometry = new ExternAbstractTransformGeometry(*this); - newGeometry->UnRegister(); - return newGeometry.GetPointer(); -} - diff --git a/Modules/Ext/DataManagement/mitkExternAbstractTransformGeometry.h b/Modules/Ext/DataManagement/mitkExternAbstractTransformGeometry.h deleted file mode 100644 index 672729b2ac..0000000000 --- a/Modules/Ext/DataManagement/mitkExternAbstractTransformGeometry.h +++ /dev/null @@ -1,71 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKEXTERNABSTRACTTRANSFORMPLANEGEOMETRY_H_HEADER_INCLUDED_C1C68A2C -#define MITKEXTERNABSTRACTTRANSFORMPLANEGEOMETRY_H_HEADER_INCLUDED_C1C68A2C - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkAbstractTransformGeometry.h" - -namespace mitk { - -//##Documentation -//## @brief Identical with AbstractTransformGeometry, except that -//## it can be externally configured. -//## -//## In contrast to its superclass (AbstractTransformGeometry), this class -//## provides write access to the vtkAbstractTransform and m_Plane. -//## @note The PlaneGeometry is cloned, @em not linked/referenced. -//## @note The bounds of the PlaneGeometry are used as the parametric bounds. -//## @sa AbstractTransformGeometry -//## @ingroup Geometry -class MitkExt_EXPORT ExternAbstractTransformGeometry : public AbstractTransformGeometry -{ -public: - mitkClassMacro(ExternAbstractTransformGeometry, AbstractTransformGeometry); - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - //##Documentation - //## @brief Set the vtkAbstractTransform (stored in m_VtkAbstractTransform) - virtual void SetVtkAbstractTransform(vtkAbstractTransform* aVtkAbstractTransform); - - //##Documentation - //## @brief Set the rectangular area that is used for transformation by - //## m_VtkAbstractTransform and therewith defines the 2D manifold described by - //## ExternAbstractTransformGeometry - //## - //## @note The bounds of the PlaneGeometry are used as the parametric bounds. - //## @note The PlaneGeometry is cloned, @em not linked/referenced. - virtual void SetPlane(const mitk::PlaneGeometry* aPlane); - - virtual void SetParametricBounds(const BoundingBox::BoundsArrayType& bounds); - - virtual itk::LightObject::Pointer InternalClone() const; - -protected: - - ExternAbstractTransformGeometry(); - ExternAbstractTransformGeometry(const ExternAbstractTransformGeometry& other); - virtual ~ExternAbstractTransformGeometry(); - -}; - -} // namespace mitk -#endif /* MITKEXTERNABSTRACTTRANSFORMPLANEGEOMETRY_H_HEADER_INCLUDED_C1C68A2C */ diff --git a/Modules/Ext/DataManagement/mitkFrameOfReferenceUIDManager.cpp b/Modules/Ext/DataManagement/mitkFrameOfReferenceUIDManager.cpp deleted file mode 100644 index 6e26356055..0000000000 --- a/Modules/Ext/DataManagement/mitkFrameOfReferenceUIDManager.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkFrameOfReferenceUIDManager.h" - -std::vector mitk::FrameOfReferenceUIDManager::m_FrameOfReferenceUIDs; - -mitk::FrameOfReferenceUIDManager::FrameOfReferenceUIDManager() -{ - if(m_FrameOfReferenceUIDs.size()==0) - m_FrameOfReferenceUIDs.push_back(""); -} - -mitk::FrameOfReferenceUIDManager::~FrameOfReferenceUIDManager() -{ - m_FrameOfReferenceUIDs.clear(); -} - -unsigned int mitk::FrameOfReferenceUIDManager::AddFrameOfReferenceUID(const char* forUID) -{ - std::string forUIDstring=forUID; - unsigned int i; - size_t size; - size = m_FrameOfReferenceUIDs.size(); - std::vector::iterator it; - for(i=0, it=m_FrameOfReferenceUIDs.begin(); i= m_FrameOfReferenceUIDs.size()) - return NULL; - return m_FrameOfReferenceUIDs[geometryFrameOfReferenceID].c_str(); -} - -static mitk::FrameOfReferenceUIDManager AddStandardFOR; diff --git a/Modules/Ext/DataManagement/mitkFrameOfReferenceUIDManager.h b/Modules/Ext/DataManagement/mitkFrameOfReferenceUIDManager.h deleted file mode 100644 index 10f0d98c19..0000000000 --- a/Modules/Ext/DataManagement/mitkFrameOfReferenceUIDManager.h +++ /dev/null @@ -1,48 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef FRAMEOFREFERENCEUIDMANAGER_H_HEADER_INCLUDED_C1EBD0AD -#define FRAMEOFREFERENCEUIDMANAGER_H_HEADER_INCLUDED_C1EBD0AD - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include -#include - -namespace mitk { - -//##Documentation -//## @brief Manager to map the internal FrameOfReferenceID of -//## the Geometry3D (Geometry3D::m_FrameOfReferenceID) to a -//## DICOM FrameOfReferenceUID -//## -class MitkExt_EXPORT FrameOfReferenceUIDManager -{ -public: - typedef std::string FrameOfReferenceUIDType; -private: - static std::vector m_FrameOfReferenceUIDs; -public: - static unsigned int AddFrameOfReferenceUID(const char* forUID); - static const char* GetFrameOfReferenceUID(unsigned int geometryFrameOfReferenceID); - FrameOfReferenceUIDManager(); - ~FrameOfReferenceUIDManager(); -}; - -} // namespace mitk - -#endif /* GEOMETRY3D_H_HEADER_INCLUDED_C1EBD0AD */ diff --git a/Modules/Ext/DataManagement/mitkItkBaseDataAdapter.cpp b/Modules/Ext/DataManagement/mitkItkBaseDataAdapter.cpp deleted file mode 100644 index ba78ad15cd..0000000000 --- a/Modules/Ext/DataManagement/mitkItkBaseDataAdapter.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkItkBaseDataAdapter.h" - -namespace mitk { - -void ItkBaseDataAdapter::PrintSelf(std::ostream& os, itk::Indent indent) const -{ - os << indent << "ItkBaseDataAdapter:" << std::endl; - if(m_ItkDataObject.IsNull()) - { - os << indent << "No DataObject!" << std::endl; - } - else - { - m_ItkDataObject->Print(os, indent); - } -} - -} diff --git a/Modules/Ext/DataManagement/mitkItkBaseDataAdapter.h b/Modules/Ext/DataManagement/mitkItkBaseDataAdapter.h deleted file mode 100644 index ebda75e49b..0000000000 --- a/Modules/Ext/DataManagement/mitkItkBaseDataAdapter.h +++ /dev/null @@ -1,57 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkBaseData.h" -#include "MitkExtExports.h" - -#include - -namespace mitk { - -/** - * \brief Small class to store itk::DataObjects in the mitk::DataStorage. - * - * This class can used to store any itk::DataObject in the DataStorage. - * Please be aware that these objects cannot be visualized via mappers. - * The user of this class must care himself for type safety. - **/ -class MitkExt_EXPORT ItkBaseDataAdapter : public BaseData -{ -public: - mitkClassMacro(ItkBaseDataAdapter, BaseData); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - /** Typedef for the data object */ - typedef itk::DataObject DataType; - - /** Returns the data object. **/ - itkGetObjectMacro(ItkDataObject, DataType); - /** Sets the data object. **/ - itkSetObjectMacro(ItkDataObject, DataType); - - virtual void SetRequestedRegionToLargestPossibleRegion() {} - virtual bool RequestedRegionIsOutsideOfTheBufferedRegion() { return false; } - virtual bool VerifyRequestedRegion() { return true; } - virtual void SetRequestedRegion( const itk::DataObject*) {} - -protected: - DataType::Pointer m_ItkDataObject; - - virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; -}; - -} diff --git a/Modules/Ext/DataManagement/mitkLine.txx b/Modules/Ext/DataManagement/mitkLine.txx deleted file mode 100644 index adb4d283ac..0000000000 --- a/Modules/Ext/DataManagement/mitkLine.txx +++ /dev/null @@ -1,85 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkLine.h" -#include -#include - - -//##ModelId=3E639CD30201 -mitk::Line::Line() -{ - m_SlicedGeometry = SlicedGeometry3D::New(); - SetGeometry(m_SlicedGeometry); - m_SlicedGeometry->Initialize(1); -} - -//##ModelId=3E639CD30233 -mitk::Line::~Line() -{ -} - -//##ModelId=3E6423D2030E -void mitk::Line::SetGeometry2D(mitk::Geometry2D *geometry2d) -{ - m_SlicedGeometry->SetGeometry2D(geometry2d, 0); - m_Geometry2D=geometry2d; - Modified(); -} - -//##ModelId=3E66CC5A0295 -void mitk::Line::UpdateOutputInformation() -{ - SetPipelineMTime(m_Geometry2D->GetMTime()); - if (this->GetSource()) - { - this->GetSource()->UpdateOutputInformation(); - } -} - -//##ModelId=3E66CC5A02B4 -void mitk::Line::SetRequestedRegionToLargestPossibleRegion() -{ - -} - -//##ModelId=3E66CC5A02D2 -bool mitk::Line::RequestedRegionIsOutsideOfTheBufferedRegion() -{ - if(m_Geometry2D.IsNull()) return true; - - return false; -} - -//##ModelId=3E66CC5A02F0 -bool mitk::Line::VerifyRequestedRegion() -{ - if(m_Geometry2D.IsNull()) return false; - - return true; -} - -//##ModelId=3E66CC5A030E -void mitk::Line::SetRequestedRegion(itk::DataObject *data) -{ - -} - -//##ModelId=3E67D85E00B7 -void mitk::Line::CopyInformation(const itk::DataObject *data) -{ -} - diff --git a/Modules/Ext/DataManagement/mitkNamedPoint.h b/Modules/Ext/DataManagement/mitkNamedPoint.h deleted file mode 100644 index fa983c10cf..0000000000 --- a/Modules/Ext/DataManagement/mitkNamedPoint.h +++ /dev/null @@ -1,89 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef MITK_NAMED_POINT_H -#define MITK_NAMED_POINT_H - -#include -#include - -namespace mitk { - -class NamedPoint{ - - std::string m_Name; - mitk::Point3D m_Point; - -public: - - /** - * - */ - NamedPoint() { - }; - - /** - * - */ - NamedPoint( const NamedPoint& namedPoint ) - : m_Name( namedPoint.m_Name ), m_Point( namedPoint.m_Point ) { - - }; - - /** - * - */ - NamedPoint( const std::string name, const Point3D& point ) - : m_Name( name ), m_Point( point ) { - - }; - - - /** - * - */ - const std::string& GetName() const { - - return m_Name; - }; - - /** - * - */ - void SetName( const std::string& name ) { - - m_Name = name; - }; - - /** - * - */ - const Point3D& GetPoint() const { - - return m_Point; - }; - - /** - * - */ - void SetPoint( const Point3D& point ) { - - m_Point = point; - }; -}; - -} // mitk -#endif // MITK_NAMED_POINT_H diff --git a/Modules/Ext/DataManagement/mitkObjectObserver.h b/Modules/Ext/DataManagement/mitkObjectObserver.h deleted file mode 100644 index 6abfba797c..0000000000 --- a/Modules/Ext/DataManagement/mitkObjectObserver.h +++ /dev/null @@ -1,35 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#ifndef MITKOBJECTOBSERVER_H -#define MITKOBJECTOBSERVER_H - -#include -#include "mitkSetObserver.h" - -namespace mitk -{ - - /// - /// Abstract interface for classes - /// that want to be informed when an - /// itk object was modified or deleted - /// - struct ObjectObserver: public SetObserver - { - }; -} - -#endif // MITKOBJECTOBSERVER_H diff --git a/Modules/Ext/DataManagement/mitkObjectSet.cpp b/Modules/Ext/DataManagement/mitkObjectSet.cpp deleted file mode 100644 index f123bc1d48..0000000000 --- a/Modules/Ext/DataManagement/mitkObjectSet.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#include "mitkObjectSet.h" diff --git a/Modules/Ext/DataManagement/mitkObjectSet.h b/Modules/Ext/DataManagement/mitkObjectSet.h deleted file mode 100644 index a851faf6af..0000000000 --- a/Modules/Ext/DataManagement/mitkObjectSet.h +++ /dev/null @@ -1,26 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#ifndef MITKObjectSet_H -#define MITKObjectSet_H - -#include - -namespace mitk -{ - typedef mitk::Set ObjectSet; -} - -#endif // MITKObjectSet_H diff --git a/Modules/Ext/DataManagement/mitkPropertyManager.cpp b/Modules/Ext/DataManagement/mitkPropertyManager.cpp deleted file mode 100644 index 8dfb9fd904..0000000000 --- a/Modules/Ext/DataManagement/mitkPropertyManager.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkPropertyManager.h" -#include "mitkProperties.h" -#include - -mitk::PropertyManager::PropertyManager() -{ - m_DefaultPropertyNameSet.insert(std::string("visible")); - m_PropertyLimits.insert(std::make_pair("opacity",std::make_pair(0.0f,1.0f))); -} -mitk::PropertyManager* mitk::PropertyManager::GetInstance() -{ - static mitk::PropertyManager propManager; - return &propManager; -} -const mitk::PropertyManager::PropertyNameSet& mitk::PropertyManager::GetDefaultPropertyNames() -{ - return m_DefaultPropertyNameSet; -}; -mitk::BaseProperty::Pointer mitk::PropertyManager::CreateDefaultProperty(std::string name) -{ - mitk::BaseProperty::Pointer newProperty(NULL); - if ( name == "visible" ) - { - newProperty = mitk::BoolProperty::New(true); - } - else - { - //MITK_INFO << "Warning: non-existing default property requested: " << name << std::endl; - } - return newProperty; -} -bool mitk::PropertyManager::GetDefaultLimits(const std::string &name,std::pair &minMax) -{ - PropertyLimitsMap::iterator it = m_PropertyLimits.find(name.c_str()); - if (it != m_PropertyLimits.end()) - { - minMax = it->second; - return true; - } - else - { - minMax = std::make_pair(std::numeric_limits::min(),std::numeric_limits::max()); - return false; - } -} diff --git a/Modules/Ext/DataManagement/mitkPropertyManager.h b/Modules/Ext/DataManagement/mitkPropertyManager.h deleted file mode 100644 index e2147738e7..0000000000 --- a/Modules/Ext/DataManagement/mitkPropertyManager.h +++ /dev/null @@ -1,48 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKPROPERTYMANAGER_H_HEADER_INCLUDED -#define MITKPROPERTYMANAGER_H_HEADER_INCLUDED -#include "mitkPropertyList.h" -#include "MitkExtExports.h" -#include -#include - -namespace mitk { - class MitkExt_EXPORT PropertyManager { - - public: - typedef std::set PropertyNameSet; - -// typedef PropertyNameSetterator PropertyNameIterator; - const PropertyNameSet& GetDefaultPropertyNames(); - BaseProperty::Pointer CreateDefaultProperty(std::string name); - static PropertyManager* GetInstance(); - bool GetDefaultLimits(const std::string &name,std::pair &minMax); - protected: - PropertyManager(); - PropertyNameSet m_DefaultPropertyNameSet; - static void InitDefaultPropertyNames(); - typedef std::map< std::string, std::pair > PropertyLimitsMap; - PropertyLimitsMap m_PropertyLimits; - } ; -} - - -#endif /* MITKPROPERTYMANAGER_H_HEADER_INCLUDED */ - - diff --git a/Modules/Ext/DataManagement/mitkSTLVectorContainer.h b/Modules/Ext/DataManagement/mitkSTLVectorContainer.h deleted file mode 100644 index 94bc528c56..0000000000 --- a/Modules/Ext/DataManagement/mitkSTLVectorContainer.h +++ /dev/null @@ -1,90 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef _MITK_STL_VECTOR_H_ -#define _MITK_STL_VECTOR_H_ - -#include -#include - -namespace mitk -{ - - -template -class STLVectorContainer : public itk::SimpleDataObjectDecorator< std::vector > -{ -public: - - typedef STLVectorContainer Self; - typedef itk::SimpleDataObjectDecorator< std::vector > Superclass; - typedef itk::SmartPointer Pointer; - typedef itk::SmartPointer ConstPointer; - itkTypeMacro(STLVectorContainer,itk::SimpleDataObjectDecorator) - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - typedef T ValueType; - - typedef std::vector STLVectorContainerType; - - /** - * Returns the number of elements contained in the - * underlying stl-vector - */ - unsigned int GetSize(); - - /** - * Emptys the undelying stl-vector. That means, that - * after a call to this function, GetSize() returns 0. - */ - void Clear(); - - /** - * Resizes the underlying stl vector to the given size. - */ - void Resize( unsigned int size ); - - /** - * sets the n'th element of the underluing stl vector. - * if the index is out of range, an assertion is raised - */ - void SetElement( const unsigned int& index, const ValueType& element ); - - /** - * returns the n'th element of the undelying stl vector - * If the index is out of range, an assertion is raised! - */ - ValueType& GetElement( const unsigned int& index ); - - -}; - -typedef STLVectorContainer IntVectorContainer; -typedef STLVectorContainer UnsignedIntVectorContainer; -typedef STLVectorContainer LongVectorContainer; -typedef STLVectorContainer UnsignedLongVectorContainer; -typedef STLVectorContainer ShortIntVectorContainer; -typedef STLVectorContainer ShortUnsignedIntVectorContainer; -typedef STLVectorContainer FloatVectorContainer; -typedef STLVectorContainer DoubleVectorContainer; - - -} //end of namespace mitk - -#include "mitkSTLVectorContainer.txx" - -#endif diff --git a/Modules/Ext/DataManagement/mitkSTLVectorContainer.txx b/Modules/Ext/DataManagement/mitkSTLVectorContainer.txx deleted file mode 100644 index b281cfe648..0000000000 --- a/Modules/Ext/DataManagement/mitkSTLVectorContainer.txx +++ /dev/null @@ -1,70 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef _MITK_STL_VECTOR_CONTAINER_TXX_ -#define _MITK_STL_VECTOR_CONTAINER_TXX_ - -#include "mitkSTLVectorContainer.h" - -template -unsigned int mitk::STLVectorContainer::GetSize() -{ - return this->Get().size(); -} - -template -void mitk::STLVectorContainer::Clear() -{ - return this->Get().clear(); - this->Modified(); -} - -/* - * Resizes the underlying stl vector to the given size. - */ -template -void mitk::STLVectorContainer::Resize( unsigned int size ) -{ - this->Get().resize( size ); - this->Modified(); -} - -/* - * sets the n'th element of the underluing stl vector. - * if the index is out of range, an assertion is raised - */ -template -void mitk::STLVectorContainer::SetElement( const unsigned int& index, const typename mitk::STLVectorContainer::ValueType& element ) -{ - assert( index < this->Get().size() ); - this->Get()[index] = element; - this->Modified(); -} - -/* - * returns the n'th element of the undelying stl vector - * If the index is out of range, an assertion is raised! - */ -template -typename mitk::STLVectorContainer::ValueType& mitk::STLVectorContainer::GetElement( const unsigned int& index ) -{ - assert( index < this->Get().size() ); - return this->Get()[index]; - -} - - -#endif diff --git a/Modules/Ext/DataManagement/mitkSTLVectorContainerSource.h b/Modules/Ext/DataManagement/mitkSTLVectorContainerSource.h deleted file mode 100644 index f5f44d0a68..0000000000 --- a/Modules/Ext/DataManagement/mitkSTLVectorContainerSource.h +++ /dev/null @@ -1,106 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef _MITK_STL_VECTOR_CONTAINER_SOURCE_H_ -#define _MITK_STL_VECTOR_CONTAINER_SOURCE_H_ - - -#include "mitkSTLVectorContainer.h" -#include "mitkCommon.h" -#include "mitkBaseProcess.h" - -namespace mitk -{ - -template -class STLVectorContainerSource : public BaseProcess -{ -public: - - mitkClassMacro( STLVectorContainerSource, BaseProcess ); - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - typedef mitk::STLVectorContainer OutputType; - - typedef typename OutputType::Pointer OutputTypePointer; - - typedef itk::DataObject::Pointer DataObjectPointer; - - /** - * Allocates a new output object and returns it. Currently the - * index idx is not evaluated. - * @param idx the index of the output for which an object should be created - * @returns the new object - */ - virtual DataObjectPointer MakeOutput ( unsigned int idx ); - - /** - * Generates the input requested region simply by calling the equivalent - * method of the superclass. - */ - void GenerateInputRequestedRegion(); - - /** - * Allows to set the output of the stl vector container source. According to the itk documentation - * this method is outdated and should not be used. Instead GraftOutput(...) - * should be used. - * @param output the intended output of the lookup table source - */ - void SetOutput( OutputType* output ); - - /** - * Replacement of the SetOutput method. I think it is not yet correcly - * implemented, so you should better not use it. - * @todo provide a more usefule implementation - * @param output the intended output of the lookup table source. - */ - virtual void GraftOutput( OutputType* output ); - - /** - * Returns the output with index 0 of the stl vector container source - * @returns the output - */ - OutputType* GetOutput(); - - /** - * Returns the n'th output of the stl vector container source - * @param idx the index of the wanted output - * @returns the output with index idx. - */ - OutputType* GetOutput ( unsigned int idx ); - -protected: - STLVectorContainerSource(); - virtual ~STLVectorContainerSource(); - -}; - -typedef STLVectorContainerSource IntVectorContainerSource; -typedef STLVectorContainerSource UnsignedIntVectorContainerSource; -typedef STLVectorContainerSource LongVectorContainerSource; -typedef STLVectorContainerSource UnsignedLongVectorContainerSource; -typedef STLVectorContainerSource ShortIntVectorContainerSource; -typedef STLVectorContainerSource ShortUnsignedIntVectorContainerSource; -typedef STLVectorContainerSource FloatVectorContainerSource; -typedef STLVectorContainerSource DoubleVectorContainerSource; - -} // end of namespace mitk - -#include "mitkSTLVectorContainerSource.txx" - -#endif diff --git a/Modules/Ext/DataManagement/mitkSTLVectorContainerSource.txx b/Modules/Ext/DataManagement/mitkSTLVectorContainerSource.txx deleted file mode 100644 index 0c5e6a2a92..0000000000 --- a/Modules/Ext/DataManagement/mitkSTLVectorContainerSource.txx +++ /dev/null @@ -1,113 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef _MITK_STL_VECTOR_CONTAINER_SOURCE_TXX_ -#define _MITK_STL_VECTOR_CONTAINER_SOURCE_TXX_ - -#include "mitkSTLVectorContainerSource.h" - -template -mitk::STLVectorContainerSource::STLVectorContainerSource() -{ - OutputTypePointer output = static_cast( this->MakeOutput( 0 ).GetPointer() ); - - assert( output.GetPointer() != NULL ); - - this->ProcessObject::SetNumberOfRequiredOutputs( 1 ); - this->ProcessObject::SetNthOutput( 0, output.GetPointer() ); -} - - -template -mitk::STLVectorContainerSource::~STLVectorContainerSource() -{} - - - - -template -typename mitk::STLVectorContainerSource::DataObjectPointer -mitk::STLVectorContainerSource::MakeOutput ( unsigned int ) -{ - return OutputType::New().GetPointer(); -} - - - - -template -void -mitk::STLVectorContainerSource::SetOutput( OutputType* output ) -{ - itkWarningMacro( << "SetOutput(): This method is slated to be removed from ITK. Please use GraftOutput() in possible combination with DisconnectPipeline() instead." ); - this->SetNthOutput( 0, output ); -} - - - - -template -typename mitk::STLVectorContainerSource::OutputType* -mitk::STLVectorContainerSource::GetOutput() -{ - if ( this->GetNumberOfOutputs() < 1 ) - { - return 0; - } - - if ( static_cast ( this->ProcessObject::GetOutput( 0 ) ) == NULL ) - itkWarningMacro(<< "Output is NULL!" ); - return static_cast ( this->ProcessObject::GetOutput( 0 ) ); -} - - - - -template -typename mitk::STLVectorContainerSource::OutputType* -mitk::STLVectorContainerSource::GetOutput ( unsigned int idx ) -{ - return static_cast ( this->ProcessObject::GetOutput( idx ) ); -} - - - - -template -void -mitk::STLVectorContainerSource::GenerateInputRequestedRegion() -{ - this->ProcessObject::GenerateInputRequestedRegion(); -} - - - - -template -void -mitk::STLVectorContainerSource::GraftOutput( OutputType* graft ) -{ - OutputType * output = this->GetOutput(); - - if ( output && graft ) - { - // copy the meta-information - output->CopyInformation( graft ); - } -} - - -#endif diff --git a/Modules/Ext/DataManagement/mitkSeedsImage.cpp b/Modules/Ext/DataManagement/mitkSeedsImage.cpp deleted file mode 100644 index 4ccc3d39b1..0000000000 --- a/Modules/Ext/DataManagement/mitkSeedsImage.cpp +++ /dev/null @@ -1,269 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkSeedsImage.h" - -#include "mitkOperation.h" -#include "mitkOperationActor.h" -#include "mitkDrawOperation.h" -#include "mitkImageAccessByItk.h" -#include "mitkInteractionConst.h" -#include "mitkRenderingManager.h" - -#include -#include - - -mitk::SeedsImage::SeedsImage() -{ - m_GaussianFunction3D = GaussianFunction3DType::New(); - m_GaussianFunction2D = GaussianFunction2DType::New(); -} - -mitk::SeedsImage::~SeedsImage() -{ -} - -void mitk::SeedsImage::Initialize() -{ - Superclass::Initialize(); - m_Radius = 1; -} - - -void mitk::SeedsImage::ExecuteOperation(mitk::Operation* operation) -{ - //mitkCheckOperationTypeMacro(SeedsOperation, operation, seedsOp); - m_Spacing = this->GetGeometry()->GetSpacing(); - for(unsigned int i=0; iGetDimension(); i++) - orig_size[i] = this->GetDimension(i); - - mitk::DrawOperation * seedsOp = - dynamic_cast< mitk::DrawOperation * >( operation ); - - if ( seedsOp != NULL ) - { - m_DrawState = seedsOp->GetDrawState(); - - if (m_Radius != seedsOp->GetRadius()) - { - m_Radius = seedsOp->GetRadius(); - } - - switch (operation->GetOperationType()) - { - case mitk::OpADD: - { - m_Point = seedsOp->GetPoint(); - m_LastPoint = m_Point; - AccessByItk(this, AddSeedPoint); - break; - } - case mitk::OpMOVE: - { - m_Point = seedsOp->GetPoint(); - AccessByItk(this, AddSeedPoint); - AccessByItk(this, PointInterpolation); - m_LastPoint = m_Point; - break; - } - case mitk::OpUNDOADD: - { - m_Point = seedsOp->GetPoint(); - m_LastPoint = m_Point; - m_DrawState = 0; - - // todo - operation is not equal with its inverse operation - possible - // approximation problems in the function PointInterpolation() - m_Radius = m_Radius+4; - AccessByItk(this, AddSeedPoint); - break; - } - case mitk::OpUNDOMOVE: - { - m_Point = seedsOp->GetPoint(); - m_DrawState = 0; - - // todo - operation is not equal with its inverse operation - possible - // approximation problems in the function PointInterpolation() - m_Radius = m_Radius+4; - AccessByItk(this, AddSeedPoint); - AccessByItk(this, PointInterpolation); - m_LastPoint = m_Point; - break; - } - } - - //*todo has to be done here, cause of update-pipeline not working yet - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - //mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - - this->Modified(); - } -} - - -template < typename SeedsImageType > -void mitk::SeedsImage::AddSeedPoint(SeedsImageType* itkImage) -{ - typedef itk::NeighborhoodIterator< SeedsImageType > - NeighborhoodIteratorType; - typedef typename NeighborhoodIteratorType::IndexType IndexType; - - NeighborhoodIteratorType& nit = this->GetNit< SeedsImageType >( itkImage ); - - const unsigned int dimension = - SeedsImageType::ImageDimension; - - mitk::Point3D index; - this->GetGeometry()->WorldToIndex( m_Point, index ); - - IndexType itkIndex; - unsigned int d; - for ( d = 0; d < dimension; ++d ) - { - itkIndex[d] = (int)(index[d] + 0.5); - } - nit.SetLocation( itkIndex ); - - - unsigned int i; - for ( i = 0; i < nit.Size(); ++i ) - { - if ( nit[i] != 0 ) - { - try - { - nit.SetPixel( i, m_DrawState ); - } - catch( itk::RangeError & ) - { - } - } - } -} - - -template < typename SeedsImageType > -void mitk::SeedsImage::PointInterpolation(SeedsImageType* itkImage) -{ - typedef itk::NeighborhoodIterator< SeedsImageType > - NeighborhoodIteratorType; - typedef typename NeighborhoodIteratorType::IndexType IndexType; - - - NeighborhoodIteratorType& nit = this->GetNit< SeedsImageType >( itkImage ); - - const unsigned int dimension = - SeedsImageType::ImageDimension; - - mitk::Point3D indexBegin, indexEnd; - this->GetGeometry()->WorldToIndex( m_Point, indexBegin ); - this->GetGeometry()->WorldToIndex( m_LastPoint, indexEnd ); - - IndexType itkIndexBegin, itkIndexEnd; - unsigned int d; - for ( d = 0; d < dimension; ++d ) - { - itkIndexBegin[d] = (int)(indexBegin[d] + 0.5); - itkIndexEnd[d] = (int)(indexEnd[d] + 0.5); - } - - - typedef itk::LineConstIterator< SeedsImageType > LineIteratorType; - LineIteratorType lit( itkImage, itkIndexBegin, itkIndexEnd ); - - // Disable warnings (which would otherwise be displayed if line leaves the - // region). - bool warningDisplay = itk::Object::GetGlobalWarningDisplay(); - itk::Object::GlobalWarningDisplayOff(); - for ( lit.GoToBegin(); !lit.IsAtEnd(); ++lit ) - { - nit.SetLocation( lit.GetIndex() ); - - unsigned int i; - for ( i = 0; i < nit.Size(); ++i ) - { - if ( nit[i] != 0 ) - { - try - { - nit.SetPixel( i, m_DrawState ); - } - catch( itk::RangeError & ) - { - } - } - } - } - itk::Object::SetGlobalWarningDisplay( warningDisplay ); -} - -void mitk::SeedsImage::ClearBuffer() -{ - AccessByItk(this, ClearBuffer); -} - -template < typename SeedsImageType > -void mitk::SeedsImage::ClearBuffer(SeedsImageType* itkImage) -{ - itkImage->FillBuffer(0); -} - -template < typename SeedsImageType > -itk::NeighborhoodIterator< SeedsImageType >& -mitk::SeedsImage::GetNit( SeedsImageType* image ) -{ - typedef itk::NeighborhoodIterator< SeedsImageType > - NeighborhoodIteratorType; - typedef typename NeighborhoodIteratorType::OffsetType OffsetType; - typedef typename NeighborhoodIteratorType::SizeType SizeType; - typedef itk::GaussianSpatialFunction< int, SeedsImageType::ImageDimension > - GaussianFunctionType; - - static SeedsImageType* iteratedImage = 0; - static NeighborhoodIteratorType nit; - static typename GaussianFunctionType::Pointer gaussianFunction - = GaussianFunctionType::New(); - - if ( iteratedImage != image ) - { - SizeType radius; - radius.Fill( m_Radius); - nit.Initialize( radius, image, image->GetBufferedRegion() ); - iteratedImage = image; - } - - nit.SetRadius( m_Radius ); - - unsigned int i; - for ( i = 0; i < nit.GetCenterNeighborhoodIndex()*2+1; ++i ) - { - OffsetType offset = nit.GetOffset( i ); - - typename GaussianFunctionType::InputType point; - double dist = 0; - unsigned int d; - for ( d = 0; d < SeedsImageType::ImageDimension; ++d ) - { - point[d] = offset[d]; - dist += offset[d] * offset[d]; - } - } - - return nit; -} - diff --git a/Modules/Ext/DataManagement/mitkSeedsImage.h b/Modules/Ext/DataManagement/mitkSeedsImage.h deleted file mode 100644 index 5cc2ffba2e..0000000000 --- a/Modules/Ext/DataManagement/mitkSeedsImage.h +++ /dev/null @@ -1,103 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKSEEDSIMAGE_H_HEADER_INCLUDED_C1C2FCD2 -#define MITKSEEDSIMAGE_H_HEADER_INCLUDED_C1C2FCD2 - -#include "mitkImage.h" -#include "MitkExtExports.h" - -#include -#include -#include -#include -#include - -namespace mitk -{ - -//##Documentation -//## @brief SeedsImage class for storing seeds-images -//## -//## Handles operations for drawing seeds. -//## @ingroup Data -class MitkExt_EXPORT SeedsImage : public Image -{ - -public: - - mitkClassMacro(SeedsImage, Image); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - itkGetMacro(LastPoint, mitk::Point3D); - - void Initialize(); - - /// handles operations - virtual void ExecuteOperation(Operation* operation); - - void ClearBuffer(); - - -protected: - SeedsImage(); - virtual ~SeedsImage(); - - template< typename SeedsImageType > - itk::NeighborhoodIterator< SeedsImageType >& GetNit( SeedsImageType* image ); - - /// sets a sphere of seeds around the point - template < typename SeedsImageType > - void AddSeedPoint(SeedsImageType * itkImage); - - /// interpolates a tube of seeds between two points - template < typename SeedsImageType > - void PointInterpolation(SeedsImageType * itkImage); - - /// interpolates a tube of seeds between two points - template < typename SeedsImageType > - void ClearBuffer(SeedsImageType * itkImage); - - -protected: - mitk::Point3D m_Point; - mitk::Point3D m_LastPoint; - mitk::Vector3D m_Spacing; - int orig_size[3]; - int m_DrawState; - int m_Radius; - float delta_x, delta_y, delta_z; - float sphere_distance; - - typedef itk::Image MaskImageType; - - typedef itk::GaussianSpatialFunction< int, 3 > GaussianFunction3DType; - GaussianFunction3DType::Pointer m_GaussianFunction3D; - typedef itk::GaussianSpatialFunction< int, 2 > GaussianFunction2DType; - GaussianFunction2DType::Pointer m_GaussianFunction2D; - - typedef itk::BinaryBallStructuringElement< short, 3 > BallStructuringElement3DType; - BallStructuringElement3DType m_StructuringElement3D; - typedef itk::BinaryBallStructuringElement< short, 2 > BallStructuringElement2DType; - BallStructuringElement2DType m_StructuringElement2D; - -}; - -} // namespace mitk - -#endif /* MITKSEEDSIMAGE_H_HEADER_INCLUDED_C1C2FCD2 */ diff --git a/Modules/Ext/DataManagement/mitkSeedsImageLookupTableSource.cpp b/Modules/Ext/DataManagement/mitkSeedsImageLookupTableSource.cpp deleted file mode 100644 index d21a97ca76..0000000000 --- a/Modules/Ext/DataManagement/mitkSeedsImageLookupTableSource.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkSeedsImageLookupTableSource.h" -#include - - -mitk::SeedsImageLookupTableSource::~SeedsImageLookupTableSource() -{} - - -mitk::SeedsImageLookupTableSource::SeedsImageLookupTableSource() : mitk::LookupTableSource() -{ - m_Mode = DefaultLUT; - m_LookupTable = NULL; - - this->Modified(); -} - - -void mitk::SeedsImageLookupTableSource::GenerateData() -{ - OutputType::Pointer output = this->GetOutput(); - - vtkLookupTable* vtkLut = this->BuildVtkLookupTable(); - output->SetVtkLookupTable( vtkLut ); - vtkLut->Delete(); -} - -vtkLookupTable* mitk::SeedsImageLookupTableSource::BuildSeedsLookupTable() -{ - vtkLookupTable *vtkLookupTable = vtkLookupTable::New(); - vtkLookupTable->SetNumberOfTableValues( 256 ); - vtkLookupTable->SetTableRange( 0.0, 255.0 ); - - // black - int i; - for ( i = 0; i < 253; i++ ) - { - vtkLookupTable->SetTableValue ( i, 0.0, 0.0, 0.0, 0.0 ); - } - - // blue - vtkLookupTable->SetTableValue( 254, 0.0, 0.0, 1.0, 0.7 ); - - // red - vtkLookupTable->SetTableValue( 255, 1.0, 0.0, 0.0, 0.7 ); - - return vtkLookupTable; -} - -vtkLookupTable* mitk::SeedsImageLookupTableSource::BuildForceLookupTable() -{ - vtkLookupTable *vtkLookupTable = vtkLookupTable::New(); - vtkLookupTable->SetTableRange( 0.0, 1.0 ); - vtkLookupTable->SetValueRange( 0.0, 1.0 ); - vtkLookupTable->SetNumberOfColors( 256 ); - vtkLookupTable->Build(); - - int i; - for ( i = 0; i < 128; i++ ) - { - vtkLookupTable->SetTableValue ( i, - 0.0, 0.0, 1.0, 0.2 + fabs(128.0 - i) / 256.0 ); - } - - vtkLookupTable->SetTableValue ( 127, 0.0, 0.0, 1.0, 0.0 ); - - for ( i = 128; i < 256; i++ ) - { - vtkLookupTable->SetTableValue ( i, - 1.0, 1.0, 0.0, 0.2 + fabs(i - 128.0) / 256.0 ); - } - - return vtkLookupTable; -} - -vtkLookupTable* mitk::SeedsImageLookupTableSource::BuildDefaultLookupTable() -{ - vtkLookupTable *vtkLookupTable = vtkLookupTable::New(); - int size = 256; - vtkLookupTable->SetTableRange(0,255); - vtkLookupTable->SetNumberOfColors( size ); - vtkLookupTable->Build(); - return( vtkLookupTable ); -} - - -vtkLookupTable* mitk::SeedsImageLookupTableSource::BuildVtkLookupTable() -{ - if ( m_Mode == Seeds ) - { - return BuildSeedsLookupTable(); - } - else if ( m_Mode == Force ) - { - return BuildForceLookupTable(); - } - - else - { - return BuildDefaultLookupTable(); - } -} diff --git a/Modules/Ext/DataManagement/mitkSeedsImageLookupTableSource.h b/Modules/Ext/DataManagement/mitkSeedsImageLookupTableSource.h deleted file mode 100644 index 0989a0903f..0000000000 --- a/Modules/Ext/DataManagement/mitkSeedsImageLookupTableSource.h +++ /dev/null @@ -1,86 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKSEEDSIMAGELOOKUPTABLESOURCE_H_HEADER_INCLUDED -#define MITKSEEDSIMAGELOOKUPTABLESOURCE_H_HEADER_INCLUDED - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkLookupTableSource.h" - - -namespace mitk -{ - -class MitkExt_EXPORT SeedsImageLookupTableSource : public LookupTableSource -{ -public: - typedef enum {Seeds, DefaultLUT, Force} LookupTableMode; - - mitkClassMacro( SeedsImageLookupTableSource, LookupTableSource ); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - /** @brief Some convenient typedefs. */ - typedef mitk::LookupTable OutputType; - - void SetUseSeedsLookupTable() {m_Mode = Seeds; this->Modified();}; - - void SetUseForceLookupTable() {m_Mode = Force; this->Modified();}; - -protected: - SeedsImageLookupTableSource(); - virtual ~SeedsImageLookupTableSource(); - - /** - * Generates a LookupTable depended on the given mode and stores - * it in an output object - */ - virtual void GenerateData(); - - /** - * Generates a lookup table, dependend on the given mode - * @returns a vtkLookupTable - */ - vtkLookupTable* BuildVtkLookupTable( ); - - /** - * Generates a Seeds lookup table - * @returns a vtkLookupTable - */ - vtkLookupTable* BuildSeedsLookupTable(); - - /** - * Generates a force lookup table - * @returns a vtkLookupTable - */ - vtkLookupTable* BuildForceLookupTable(); - - /** - * Generates a default lookup table - * @returns a vtkLookupTable - */ - vtkLookupTable* BuildDefaultLookupTable(); - -private: - LookupTableMode m_Mode; - OutputTypePointer m_LookupTable; -}; - -} // namespace mitk - -#endif /* MITKSEEDSIMAGELOOKUPSOURCE_H_HEADER_INCLUDED */ diff --git a/Modules/Ext/DataManagement/mitkSet.h b/Modules/Ext/DataManagement/mitkSet.h deleted file mode 100644 index 67727136e1..0000000000 --- a/Modules/Ext/DataManagement/mitkSet.h +++ /dev/null @@ -1,257 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#ifndef mitkSet_H -#define mitkSet_H - -#include -#include -#include -#include -#include - -#include "mitkSetObserver.h" - -namespace mitk -{ - -/// -/// A class that acts like a weak pointer -/// but for a list of itk objects -/// -template -class Set: virtual public itk::Object -{ -public: - typedef mitk::SetObserver Observer; - mitkClassMacro(Set, itk::Object); - itkFactorylessNewMacro(Set); - - Set() - { - } - - /// - /// clears this set, copies over all elements from otherSet - /// - void Copy( mitk::Set* otherSet ) - { - this->Clear(); - for(unsigned int i=0; i< otherSet->GetSize(); ++i) - { - this->Add( otherSet->Get(i) ); - } - } - - bool Add ( const T& obj ) - { - if(this->Has(obj)) // this is a set! do not add twice - return false; - - // add it now - m_Objects.push_back(obj); // if index is not valid any more, just add - // the element - // subscribe for modified event - typename itk::MemberCommand >::Pointer _modifiedCommand = - itk::MemberCommand >::New(); - _modifiedCommand->SetCallbackFunction(this - , &Set::OnObjectModified); - m_ObjectModifiedTags[obj] = - obj->AddObserver(itk::ModifiedEvent(), _modifiedCommand); - - // subscribe for delete event - typename itk::MemberCommand >::Pointer _DeleteCommand = - itk::MemberCommand >::New(); - _DeleteCommand->SetCallbackFunction(this - , &Set::OnObjectModified); - m_ObjectDeleteTags[obj] = - obj->AddObserver(itk::DeleteEvent(), _DeleteCommand); - - for(typename std::set*>::iterator it = m_SetObserver.begin(); - it != m_SetObserver.end(); ++it) - (*it)->OnAdded(obj); - - this->Modified(); - return true; - } - - bool Remove ( const T& obj ) - { - return this->Remove(this->IndexOf(obj)); - } - - bool Remove ( int index ) - { - if( !this->IsValid(index) ) // element must exist to be removed - return false; - - typename std::vector::iterator it = m_Objects.begin(); - std::advance(it, index); - - T& obj = *it; - - for(typename std::set*>::iterator it2 - = m_SetObserver.begin(); it2 != m_SetObserver.end(); ++it2) - (*it2)->OnRemove(*it); - // remove it now - obj->RemoveObserver(m_ObjectModifiedTags[obj]); - obj->RemoveObserver(m_ObjectDeleteTags[obj]); - m_ObjectModifiedTags.erase(obj); - m_ObjectDeleteTags.erase(obj); - m_Objects.erase(it); - this->Modified(); - return true; - } - - void Clear () - { - while(m_Objects.size() > 0) - this->Remove(m_Objects.size()-1); - } - - unsigned int GetSize() const - { - return m_Objects.size(); - } - int IndexOf(const T& obj) const - { - int index = -1; - - for(unsigned int i=0; iIndexOf(obj) != -1; - } - bool IsEmpty() const - { - return m_Objects.empty(); - } - bool IsValid( int index ) const - { - if(index >= 0) - { - return m_Objects.size() > 0 - && static_cast< unsigned int > (index) < m_Objects.size(); - } - return false; - } - T& Front() - { - return m_Objects.front(); - } - T& Back() - { - return m_Objects.back(); - } - T& Get( unsigned int index ) - { - return m_Objects.at(index); - } - const T& Front() const - { - return m_Objects.front(); - } - const T& Back() const - { - return m_Objects.back(); - } - const T& Get( unsigned int index ) const - { - return m_Objects.at(index); - } - void AddObserver( SetObserver* observer ) const - { - m_SetObserver.insert( observer ); - } - void RemoveObserver( SetObserver* observer ) const - { - m_SetObserver.erase( observer ); - } - void OnObjectModified(const itk::Object* caller - , const itk::EventObject &event) - { - unsigned int i=0; - for(; i(m_Objects.at(i)) == caller ) - break; - - const itk::DeleteEvent* delEvent - = dynamic_cast(&event); - - // inform listeners - for(typename std::set*>::iterator it = m_SetObserver.begin(); - it != m_SetObserver.end(); ++it) - delEvent ? (*it)->OnDelete( this->Get(i) ) - : (*it)->OnModified( this->Get(i) ); - - // remove from list if object was deleted (no dangling pointers) - if(delEvent) - { - this->Remove(i); - } - } - - Set(const Set& other) - { - *this = other; - } - Set& operator= - (const Set& other) - { - // do not simply copy -> because of observer objects - // instead: use add method for each element of the other List - for(int i=0; iAdd( other.Get(i) ); - - return *this; - } - virtual ~Set() - { - this->Clear(); - } -protected: - /// - /// Holds all objects - /// - std::vector m_Objects; - - /// - /// holds the list of observed itk objects (will be updated in setat()) - /// - mutable std::set*> m_SetObserver; - - /// - /// \brief Holds all tags of Modified Event Listeners. - /// - std::map m_ObjectModifiedTags; - - /// - /// \brief Holds all tags of Modified Event Listeners. - /// - std::map m_ObjectDeleteTags; -}; - -} // namespace mitk - -#endif // mitkSet_H diff --git a/Modules/Ext/DataManagement/mitkSetObserver.h b/Modules/Ext/DataManagement/mitkSetObserver.h deleted file mode 100644 index a27ff5233a..0000000000 --- a/Modules/Ext/DataManagement/mitkSetObserver.h +++ /dev/null @@ -1,45 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#ifndef MITKSETOBSERVER_H -#define MITKSETOBSERVER_H - -namespace mitk -{ - /// - /// abstract base class for all objects observing an mitk::Set - /// - template - struct SetObserver - { - virtual void OnAdded( T object ) {} - virtual void OnModified( T object ) {} - /// - /// Will be called before an object gets removed - /// - virtual void OnRemove( T object ) {} - virtual void OnDelete( T object ) {} - /// - /// Makes this class abstract - /// - virtual ~SetObserver() = 0; - }; - - template - SetObserver::~SetObserver() {} - -} - -#endif // MITKSETOBSERVER_H diff --git a/Modules/Ext/DataManagement/mitkSphereLandmarkProjector.cpp b/Modules/Ext/DataManagement/mitkSphereLandmarkProjector.cpp deleted file mode 100644 index f9851d51f6..0000000000 --- a/Modules/Ext/DataManagement/mitkSphereLandmarkProjector.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkSphereLandmarkProjector.h" -#include - -#include -#include -#include - -mitk::SphereLandmarkProjector::SphereLandmarkProjector() -{ - m_SphericalTransform = vtkSphericalTransform::New(); - m_SphereRotation = vtkTransform::New(); - m_SpatialPlacementTransform = vtkTransform::New(); - m_PlaneToSphericalTransform = vtkGeneralTransform::New(); - - m_SphereRotation->RotateX(90); - - //setup parameter-plane of the sphere: x is phi, y is theta; the radius is always 1 - mitk::ScalarType origin[3] = {1, 0, 2*vnl_math::pi}; // (1, 0, 6.28) (1, 0, 0) - mitk::ScalarType right[3] = {0, 0, -2*vnl_math::pi}; // (0,3.14, 0) (0, 0, 6.28) - mitk::ScalarType bottom[3] = {0, vnl_math::pi, 0}; // (0, 0,-6.28) (0,3.14, 0) - - m_SphereParameterPlane = mitk::PlaneGeometry::New(); - m_SphereParameterPlane->InitializeStandardPlane(right, bottom); - m_SphereParameterPlane->SetOrigin(origin); - m_SphereParameterPlane->SetSizeInUnits(100, 50); - - m_ParameterPlane = m_SphereParameterPlane; -} - -mitk::SphereLandmarkProjector::~SphereLandmarkProjector() -{ - m_SphericalTransform->Delete(); - m_SphereRotation->Delete(); - m_SpatialPlacementTransform->Delete(); - m_PlaneToSphericalTransform->Delete(); -} - -void mitk::SphereLandmarkProjector::ComputeCompleteAbstractTransform() -{ - m_PlaneToSphericalTransform->Identity(); - m_PlaneToSphericalTransform->PostMultiply(); - m_PlaneToSphericalTransform->Concatenate(m_SphericalTransform); - m_PlaneToSphericalTransform->Concatenate(m_SphereRotation); - m_PlaneToSphericalTransform->Concatenate(m_InterpolatingAbstractTransform);//GetInterpolatingAbstractTransform()); - m_PlaneToSphericalTransform->Concatenate(m_SpatialPlacementTransform); - - m_CompleteAbstractTransform = m_PlaneToSphericalTransform; -} - -void mitk::SphereLandmarkProjector::ProjectLandmarks( - const mitk::PointSet::DataType::PointsContainer* targetLandmarks) -{ - unsigned int size=targetLandmarks->Size(); - mitk::PointSet::DataType::PointsContainer::ConstIterator pointiterator, start = targetLandmarks->Begin(); - mitk::PointSet::DataType::PointsContainer::ElementIdentifier id; - - //Part I: Calculate center of sphere - mitk::Point3D center; - center.Fill(0); - mitk::ScalarType radius; - mitk::PointSet::PointType point; - //determine center - for(id=0, pointiterator=start;idValue(); - center[0]+=point[0]; - center[1]+=point[1]; - center[2]+=point[2]; - } - center[0]/=(mitk::ScalarType)size; - center[1]/=(mitk::ScalarType)size; - center[2]/=(mitk::ScalarType)size; - //determine radius - switch(0) - { - case 0/*MIN*/: - radius = itk::NumericTraits::max(); - for(id=0, pointiterator=start;idValue(); - mitk::Vector3D v; - v[0]=point[0]-center[0]; - v[1]=point[1]-center[1]; - v[2]=point[2]-center[2]; - if (v.GetNorm() < radius) radius = v.GetNorm(); - } - break; - case 1/*MAX*/: - radius = 0; - for(id=0, pointiterator=start;idValue(); - mitk::Vector3D v; - v[0]=point[0]-center[0]; - v[1]=point[1]-center[1]; - v[2]=point[2]-center[2]; - if (v.GetNorm() > radius) radius = v.GetNorm(); - } - break; - case 2/*AVERAGE*/: - radius = 0; - for(id=0, pointiterator=start;idValue(); - mitk::Vector3D v; - v[0]=point[0]-center[0]; - v[1]=point[1]-center[1]; - v[2]=point[2]-center[2]; - radius += v.GetNorm(); - } - radius*=1.0/size; - break; - } - mitk::Point3D origin = m_SphereParameterPlane->GetOrigin(); origin[0]=radius; m_SphereParameterPlane->SetOrigin(origin); - m_SpatialPlacementTransform->GetMatrix()->SetElement(0, 3, center[0]); - m_SpatialPlacementTransform->GetMatrix()->SetElement(1, 3, center[1]); - m_SpatialPlacementTransform->GetMatrix()->SetElement(2, 3, center[2]); - - - //Part II: Project points on sphere - mitk::Point3D projectedPoint; - - m_WritableFinalTargetLandmarks->Initialize(); - m_ProjectedLandmarks->Initialize(); - - m_WritableFinalTargetLandmarks->Reserve(size); - m_ProjectedLandmarks->Reserve(size); - for(id=0, pointiterator=start;idValue(); - - mitk::Vector3D v; - v=point-center; - mitk::FillVector3D(point, v[0], v[1], v[2]); - v.Normalize(); v*=radius; - mitk::FillVector3D(projectedPoint, v[0], v[1], v[2]); - - m_WritableFinalTargetLandmarks->InsertElement(id, point); - m_ProjectedLandmarks->InsertElement(id, projectedPoint); - } -} diff --git a/Modules/Ext/DataManagement/mitkSphereLandmarkProjector.h b/Modules/Ext/DataManagement/mitkSphereLandmarkProjector.h deleted file mode 100644 index dac94ca8dd..0000000000 --- a/Modules/Ext/DataManagement/mitkSphereLandmarkProjector.h +++ /dev/null @@ -1,61 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKSPHERELANDMARKPROJECTOR_H_HEADER_INCLUDED_C1C68A2C -#define MITKSPHERELANDMARKPROJECTOR_H_HEADER_INCLUDED_C1C68A2C - -#include "mitkLandmarkProjector.h" -#include "MitkExtExports.h" -#include "mitkPointSet.h" - -class vtkTransform; -class vtkSphericalTransform; -class vtkGeneralTransform; -class vtkTransformPolyDataFilter; - -namespace mitk { - -//##Documentation -//## @brief Thin-plate-spline-based landmark-based curved geometry -//## -//## @ingroup Geometry -class MitkExt_EXPORT SphereLandmarkProjector : public LandmarkProjector -{ -public: - mitkClassMacro(SphereLandmarkProjector, LandmarkProjector); - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - virtual void ProjectLandmarks(const mitk::PointSet::DataType::PointsContainer* targetLandmarks); -protected: - SphereLandmarkProjector(); - virtual ~SphereLandmarkProjector(); - - virtual void ComputeCompleteAbstractTransform(); - - vtkSphericalTransform* m_SphericalTransform; - vtkTransform* m_SphereRotation; - vtkTransform* m_SpatialPlacementTransform; - vtkGeneralTransform* m_PlaneToSphericalTransform; - - mitk::PlaneGeometry::Pointer m_SphereParameterPlane; -}; - -} // namespace mitk - -#endif /* MITKSPHERELANDMARKPROJECTOR_H_HEADER_INCLUDED_C1C68A2C */ diff --git a/Modules/Ext/DataManagement/mitkUSLookupTableSource.cpp b/Modules/Ext/DataManagement/mitkUSLookupTableSource.cpp deleted file mode 100644 index 1e701ac02e..0000000000 --- a/Modules/Ext/DataManagement/mitkUSLookupTableSource.cpp +++ /dev/null @@ -1,408 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkUSLookupTableSource.h" -#include -#include -#include - - -extern "C" -{ -#include "uscfunctions/usc.h" -} - - -mitk::USLookupTableSource::~USLookupTableSource() -{} - - -mitk::USLookupTableSource::USLookupTableSource() : mitk::LookupTableSource() -{ - - std::cout << "creating USLookupTableSource ... " << std::endl; - m_Mode = DefaultLUT; - m_LookupTable = NULL; - - this->Modified(); - std::cout << "creating USLookupTableSource OK! " << std::endl; -} - - -void mitk::USLookupTableSource::GenerateData() -{ - std::cout << "USLookupTableSource::generate data!" << std::endl; - OutputType::Pointer output = this->GetOutput(); - output->SetVtkLookupTable( this->BuildVtkLookupTable( ) ); -} - -vtkLookupTable* mitk::USLookupTableSource::BuildDSRDopplerLookupTable() -{ - - std::cout << " creating HP LookupTable ... " << std::endl; - - mitkIpPicDescriptor *HPMap; - - char MapFilename[ 20 ] = "a.map"; - int failed ; - - ifstream infile ( MapFilename, ios::in ); - failed = infile.fail() ; - infile.close() ; - - if ( !failed ) // do we have a HP LUT ? - { - std::cout << " reading a.map ... " << std::endl; - HPMap = usReadMap( "a.map", ".", -1000, -1000 ); - - vtkLookupTable *vtkLookupTable = vtkLookupTable::New(); - mitkIpUInt1_t *data = ( ( mitkIpUInt1_t * ) HPMap->data ); - - vtkLookupTable->SetTableRange(0,255); - - int LookupTablesize = 256; - double rgba[ 4 ]; - - vtkLookupTable->SetNumberOfColors( LookupTablesize ); - for ( int i = 0; i < LookupTablesize; i++ ) - { - rgba[ 0 ] = ( ( mitkIpUInt1_t * ) data ) [ 0 + i * 3 * LookupTablesize ] / 255.0f; - rgba[ 1 ] = ( ( mitkIpUInt1_t * ) data ) [ 1 + i * 3 * LookupTablesize ] / 255.0f ; - rgba[ 2 ] = ( ( mitkIpUInt1_t * ) data ) [ 2 + i * 3 * LookupTablesize ] / 255.0f ; - rgba[ 3 ] = 1; - vtkLookupTable->SetTableValue ( i, rgba ); - } - - return ( vtkLookupTable ); - - } // do we have a HP LUT ? - - - else // no HP lut -> create custom LUT - { - std::cout << " no a.map available! creating custom Doppler LookUpTable ... " << std::endl; - - vtkLookupTable *vtkLookupTable = vtkLookupTable::New(); - vtkLookupTable->SetTableRange(0,255); - // size is the no of different colors in the lut - int size = 256; - int lutSize = 256; - int repeats = lutSize / size; - - int factor = 1; - int i, n; - - double rgba[ 4 ]; - - //int xDim = lutSize; - //int yDim = 3; - - int quartalSize = size / 4; - - int index; - - for ( i = 1; i <= quartalSize ; i++ ) - { - for ( n = 0; n < repeats ; n++ ) - { - - index = ( i - 1 ) * repeats + n; - rgba[ 0 ] = 0; // rot - rgba[ 1 ] = 1 - i / 2.0 / quartalSize; // gruen - rgba[ 2 ] = 1; // blau - rgba[ 3 ] = factor * 1; - vtkLookupTable->SetTableValue ( index, rgba ); - } - } - - // dunkelblau - for ( i = 1; i <= quartalSize ; i++ ) - { - for ( n = 0; n < repeats ; n++ ) - { - - index = ( i - 1 ) * repeats + repeats * quartalSize + n; - rgba[ 0 ] = 0; - rgba[ 1 ] = 0.5 - i / 2.0 / quartalSize; - rgba[ 2 ] = 1 - i / ( float ) ( 2 * quartalSize ); - rgba[ 3 ] = factor * 1; - vtkLookupTable->SetTableValue ( index, rgba ); - } - } - - - - // dunkelrot - for ( i = 1; i <= quartalSize ; i++ ) - { - for ( n = 0; n < repeats ; n++ ) - { - - index = ( i - 1 ) * repeats + ( 2 * repeats * quartalSize ) + n; - rgba[ 0 ] = 0.5 + i / ( float ) ( 2 * quartalSize ); - rgba[ 1 ] = i / 2.0 / quartalSize; - rgba[ 2 ] = 0; - rgba[ 3 ] = factor * 1; - vtkLookupTable->SetTableValue ( index, rgba ); - } - } - - - // hellrot - for ( i = 1; i <= quartalSize ; i++ ) - { - for ( n = 0; n < repeats ; n++ ) - { - - index = ( i - 1 ) * repeats + ( 3 * repeats * quartalSize ) + n; - rgba[ 0 ] = 1; - rgba[ 1 ] = 0.5 + i / 2.0 / quartalSize; - rgba[ 2 ] = 0; - rgba[ 3 ] = factor * 1; - vtkLookupTable->SetTableValue ( index, rgba ); - } - } - - // the value 0 is mapped to black - // so we see the field-out-of-view as black - index = 0; - rgba[ 0 ] = 0; - rgba[ 1 ] = 0; - rgba[ 2 ] = 0; - rgba[ 3 ] = factor * 1; - vtkLookupTable->SetTableValue( index, rgba ); - - int mapZeroVelocityToBlack = 1; - if ( mapZeroVelocityToBlack == 1 ) - { - // map the middle value to black, so no velocity (v=0) - // is displayed as black, otherwise darkred - rgba[ 0 ] = 0; - rgba[ 1 ] = 0; - rgba[ 2 ] = 0; - rgba[ 3 ] = factor * 1; - index = lutSize / 2 ; - vtkLookupTable->SetTableValue( index, rgba ); -// index = lutSize / 2 - 1; -// vtkLookupTable->SetTableValue( index, rgba ); -// index = lutSize / 2 + 1; - vtkLookupTable->SetTableValue( index, rgba ); - } - - // for (int i=0; iGetTableValue(i,&rgba[0]); - // cout << "i=" << i << " r=" << rgba[0] << " g=" << rgba[1]<< " b=" << rgba[2] << endl; - // } - - return( vtkLookupTable ); - - } // no HP lut -> create custom LUT -} - - -vtkLookupTable* mitk::USLookupTableSource::BuildStrainRateLookupTable() -{ - std::cout << " creating StrainRate LookupTable ... " << std::endl; - vtkLookupTable *vtkLookupTable = vtkLookupTable::New(); - - vtkLookupTable->SetTableRange(0,255); - - int lutSize = 256; - vtkLookupTable->SetNumberOfTableValues(lutSize); - - // xDim = size; - // yDim = 3; - double rgba[ 4 ]; - - float quartal = lutSize / 8.0f; - - float sizeQuartal1 = 3 * quartal; //quartal-1; - - float sizeQuartal2 = 0.9375 * quartal; - float sizeZeroStrain = 0.125 * quartal; - float sizeQuartal3 = 0.9375 * quartal; - - // float sizeQuartal2 = 0.875 * quartal; - // float sizeZeroStrain = 0.25* quartal; - // float sizeQuartal3 = 0.875 * quartal; - - // float sizeQuartal2 = 0.975 * quartal; - // float sizeZeroStrain = 0.05* quartal; - // float sizeQuartal3 = 0.975 * quartal; - - - float sizeQuartal4 = 3 * quartal; - - // std::cout << "quartal = " << quartal << std::endl; - // std::cout << "quartal 1 = " << sizeQuartal1 << std::endl; - // std::cout << "quartal 2 = " << sizeQuartal2 << std::endl; - // std::cout << "quartal 3 = " << sizeQuartal3 << std::endl; - // std::cout << "quartal 4 = " << sizeQuartal4 << std::endl; - // std::cout << "quartal zero = " << sizeZeroStrain << std::endl; - - - int factor = 1; - int i; - - // dunkelrot - for ( i = 1; i <= sizeQuartal1; i++ ) - { - int index = i - 1; - rgba[ 0 ] = factor * ( 0.5 + i / ( 2 * sizeQuartal1 ) ); // rot - rgba[ 1 ] = factor * 0; // gruen - rgba[ 2 ] = factor * 0; // blau - rgba[ 3 ] = factor * 1; - vtkLookupTable->SetTableValue ( index, rgba ); - } - - // hellrot bis gelb - for ( i = 1 ; i <= sizeQuartal2 ; i++ ) - { - int index = ( i - 1 ) + ( int ) sizeQuartal1; - rgba[ 0 ] = factor * 1; - rgba[ 1 ] = factor * ( i / sizeQuartal2 ); - rgba[ 2 ] = factor * 0; - rgba[ 3 ] = factor * 1; - vtkLookupTable->SetTableValue ( index, rgba ); - } - - - //gruen - for ( i = 1 ; i <= sizeZeroStrain ; i++ ) - { - int index = ( i - 1 ) + ( int ) ( sizeQuartal1 + sizeQuartal2 ); - rgba[ 0 ] = factor * 0; //1 - i/sizeZeroStrain; - rgba[ 1 ] = factor * 1; - rgba[ 2 ] = factor * 0; //i/sizeZeroStrain; - rgba[ 3 ] = factor * 1; - vtkLookupTable->SetTableValue ( index, rgba ); - } - - - // hellblau - for ( i = 1 ; i <= sizeQuartal3; i++ ) - { - int index = ( i - 1 ) + ( int ) ( sizeQuartal1 + sizeQuartal2 + sizeZeroStrain ); - rgba[ 0 ] = factor * 0; - rgba[ 1 ] = factor * ( 1 - i / sizeQuartal3 ); - rgba[ 2 ] = factor * 1; - rgba[ 3 ] = factor * 1; - vtkLookupTable->SetTableValue ( index, rgba ); - } - - // blau - for ( i = 1 ; i <= sizeQuartal4 ; i++ ) - { - int index = ( i - 1 ) + ( int ) ( sizeQuartal1 + sizeQuartal2 + sizeQuartal3 + sizeZeroStrain ); - rgba[ 0 ] = factor * 0; - rgba[ 1 ] = factor * 0; - rgba[ 2 ] = factor * ( 1 - i / sizeQuartal4 ); - rgba[ 3 ] = factor * 1; - vtkLookupTable->SetTableValue ( index, rgba ); - - } - - // the value 0 is mapped to black - // so we see the field-out-of-view as black - int index = 0; - rgba[ 0 ] = 0; - rgba[ 1 ] = 0; - rgba[ 2 ] = 0; - rgba[ 3 ] = factor * 1; - vtkLookupTable->SetTableValue ( index, rgba ); - vtkLookupTable->SetTableValue ( index + 1, rgba ); - - bool mapZeroStrainRateToBlack = true; - if ( mapZeroStrainRateToBlack ) - { - // map the middle value to black, so no velocity (v=0) - // is displayed as black - rgba[ 0 ] = 0; - rgba[ 1 ] = 0; - rgba[ 2 ] = 0; - rgba[ 3 ] = factor * 1; - -// index = lutSize / 2 -1; // FIXME: this should be lutSize/2 !!!!???? - index = 128 ; // FIXME: this should be lutSize/2 !!!!???? - std::cout << " setting table value " << index << " to zero " << std::endl; - - vtkLookupTable->SetTableValue( index, rgba ); - } - - -// for (int i=0; iGetTableValue(i,&rgba[0]); -// cout << "i=" << i << " r=" << rgba[0] << " g=" << rgba[1]<< " b=" << rgba[2] << endl; -// } - -// std::cout << " created with " << vtkLookupTable->GetNumberOfColors() << " colors .. " << std::endl; -// std::cout << " created with " << vtkLookupTable->GetNumberOfTableValues() << " colors .. " << std::endl; -// float data[2]; -// vtkLookupTable->GetTableRange (data); -// std::cout << " data0=" << data[0] << " data1=" << data[1] << std::endl; -// vtkLookupTable->GetTableValue (200, rgba); -// std::cout << " r=" << rgba[0] << " g=" << rgba[1] << " b=" << rgba[2]<< " a=" << rgba[3]<< std::endl; -// float rgb[3]; -// vtkLookupTable->GetColor (200, rgb); -// std::cout << " r=" << rgb[0] << " g=" << rgb[1] << " b=" << rgb[2]<< std::endl; -// unsigned char *p = vtkLookupTable->GetPointer(200); -// std::cout << " p0=" << (int)p[0] << " p1=" << (int)p[1] << " p2=" << (int)p[2]<< std::endl; -// p = vtkLookupTable->GetPointer(128); -// std::cout << " p0=" << (unsigned int)p[0] << " p1=" <<(unsigned int) p[1] << " p2=" << (unsigned int)p[2]<< std::endl; - - return( vtkLookupTable ); - -} - -vtkLookupTable* mitk::USLookupTableSource::BuildDefaultLookupTable(){ - - std::cout << " creating default LookupTable... " << std::endl; - vtkLookupTable *vtkLookupTable = vtkLookupTable::New(); - int size = 256; - vtkLookupTable->SetTableRange(0,255); - vtkLookupTable->SetNumberOfColors( size ); - vtkLookupTable->Build(); - return( vtkLookupTable ); - -} - - -vtkLookupTable* mitk::USLookupTableSource::BuildVtkLookupTable() -{ - - std::cout << "mitk::USLookupTableSource::BuildVtkLookupTable() ... " << std::endl; - - if ( m_Mode == DSRDoppler ) - { - return BuildDSRDopplerLookupTable(); - } - else if ( m_Mode == StrainRate ) - { - return BuildStrainRateLookupTable(); - } - else - { - return BuildDefaultLookupTable(); - } - - -} - - - diff --git a/Modules/Ext/DataManagement/mitkUSLookupTableSource.h b/Modules/Ext/DataManagement/mitkUSLookupTableSource.h deleted file mode 100644 index 2d51c837ef..0000000000 --- a/Modules/Ext/DataManagement/mitkUSLookupTableSource.h +++ /dev/null @@ -1,98 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKUSLookupTableSOURCE_H_HEADER_INCLUDED -#define MITKUSLookupTableSOURCE_H_HEADER_INCLUDED - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkLookupTableSource.h" - - -class mitk::LookupTable; - -namespace mitk -{ - - -class MitkExt_EXPORT USLookupTableSource : public LookupTableSource -{ -public: - typedef enum {DSRDoppler, StrainRate, DefaultLUT} LookupTableMode; - - mitkClassMacro( USLookupTableSource, LookupTableSource ); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - /** @brief Some convenient typedefs. */ - typedef mitk::LookupTable OutputType; - - void SetUseDSRDopplerLookupTable() {m_Mode = DSRDoppler; this->Modified();}; - - void SetUseStrainRateLookupTable() {m_Mode = StrainRate; this->Modified();}; - -protected: - USLookupTableSource(); - virtual ~USLookupTableSource(); - - /** - * Generates a LookupTable depended on the given mode and stores - * it in an output object - */ - virtual void GenerateData(); - - /** - * Generates a lookup table, dependend on the given mode - * @returns a vtkLookupTable - */ - vtkLookupTable* BuildVtkLookupTable( ); - - /** - * Generates a Philips Doppler lookup table - * if an a.map file is given, then a original LookupTable is genereated - * else an LookupTable similar to the original one is generated - * @returns a vtkLookupTable - */ - vtkLookupTable* BuildDSRDopplerLookupTable(); - - /** - * Generates a Strain Rate lookup table than those that are - * used e.g. by GE - * - * @returns a vtkLookupTable - */ - vtkLookupTable* BuildStrainRateLookupTable(); - - /** - * Generates a default lookup table - * @returns a vtkLookupTable - */ - vtkLookupTable* BuildDefaultLookupTable(); - - - -private: - LookupTableMode m_Mode; - OutputTypePointer m_LookupTable; - -}; - -} // namespace mitk - - - -#endif /* MITKLookupTableSOURCE_H_HEADER_INCLUDED */ diff --git a/Modules/Ext/DataManagement/vtkObjectObserver.h b/Modules/Ext/DataManagement/vtkObjectObserver.h deleted file mode 100644 index 9c61d4eab5..0000000000 --- a/Modules/Ext/DataManagement/vtkObjectObserver.h +++ /dev/null @@ -1,28 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#ifndef VTKOBJECTOBSERVER_H -#define VTKOBJECTOBSERVER_H - -class vtkObject; - -class vtkObjectObserver -{ -public: - virtual void OnModified( const vtkObject* object ) = 0; - virtual void OnDeleted( const vtkObject* object ) = 0; -}; - -#endif // VTKOBJECTOBSERVER_H diff --git a/Modules/Ext/DataManagement/vtkObjectSet.cpp b/Modules/Ext/DataManagement/vtkObjectSet.cpp deleted file mode 100644 index bb8941ddaa..0000000000 --- a/Modules/Ext/DataManagement/vtkObjectSet.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#include "vtkObjectSet.h" -#include "vtkObjectObserver.h" - -#include -#include -#include - -vtkObjectSet::vtkObjectSet() -{ -} - -vtkObjectSet::~vtkObjectSet() -{ - -} - -void vtkObjectSet::AddObserver( vtkObjectObserver* observer ) -{ - m_vtkObjectObservers.insert(observer); -} - -void vtkObjectSet::RemoveObserver( vtkObjectObserver* observer ) -{ - m_vtkObjectObservers.erase(observer); -} - -void vtkObjectSet::AddObject ( vtkObject * obj ) -{ - // if add object, add observer for modified and delete event - std::pair::iterator, bool> res = m_Objects.insert(obj); - - if(res.second) - { - vtkSmartPointer modifiedCallback = - vtkSmartPointer::New(); - modifiedCallback->SetCallback ( vtkObjectSet::OnObjectModified ); - modifiedCallback->SetClientData(this); - - m_ObjectModifiedTags[obj] = obj->AddObserver - ( vtkCommand::ModifiedEvent, modifiedCallback ); - m_ObjectDeleteTags[obj] = obj->AddObserver - ( vtkCommand::DeleteEvent, modifiedCallback ); - } -} - -void vtkObjectSet::RemoveObject ( vtkObject * obj ) -{ - // if object removed, remove observer and tags for modified and delete event - std::set::size_type deletedObjs = m_Objects.erase(obj); - - if(deletedObjs > 0) - { - obj->RemoveObserver(m_ObjectModifiedTags[obj]); - obj->RemoveObserver(m_ObjectDeleteTags[obj]); - - m_ObjectModifiedTags.erase(obj); - m_ObjectDeleteTags.erase(obj); - } -} - -void vtkObjectSet::OnObjectModified(vtkObject* caller, unsigned long eid - , void* clientdata, void * /*calldata*/) -{ - // if event == modified event, inform objectobservers - // else: call RemoveObject() or remove objectobserver and inform objectobservers - - vtkObjectSet* instance = static_cast( clientdata ); - - for(std::set::iterator it = instance->m_vtkObjectObservers.begin(); - it != instance->m_vtkObjectObservers.end(); ++it) - eid == vtkCommand::ModifiedEvent ? (*it)->OnModified( caller ): - (*it)->OnDeleted( caller ); - - if(eid != vtkCommand::ModifiedEvent) - instance->RemoveObject( caller ); -} diff --git a/Modules/Ext/DataManagement/vtkObjectSet.h b/Modules/Ext/DataManagement/vtkObjectSet.h deleted file mode 100644 index b994cda7a6..0000000000 --- a/Modules/Ext/DataManagement/vtkObjectSet.h +++ /dev/null @@ -1,66 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#ifndef MITKvtkObjectSet_H -#define MITKvtkObjectSet_H - -#include -#include -#include -#include - -class vtkObjectObserver; - -/// -/// a class holding -/// a list of itk objects and/or vtk objects. -/// the main idea of the class -/// is that it listens to the modified -/// and delete events of the objects -/// and informs associated objectobservers. -/// This eases the handling of the sometimes complicated -/// event handling mechanisms. -/// -class MitkExt_EXPORT vtkObjectSet -{ -public: - vtkObjectSet(); - virtual ~vtkObjectSet(); - - void AddObserver( vtkObjectObserver* observer ); - void RemoveObserver( vtkObjectObserver* observer ); - - void AddObject ( vtkObject * obj ); - void RemoveObject ( vtkObject * obj ); - - /// - /// vtk event function - /// - static void OnObjectModified(vtkObject *, unsigned long eid - , void* clientdata, void * /*calldata*/); -protected: - std::set m_vtkObjectObservers; - std::set m_Objects; - /// - /// \brief Holds all tags of Modified Event Listeners. - /// - std::map m_ObjectModifiedTags; - /// - /// \brief Holds all tags of Modified Event Listeners. - /// - std::map m_ObjectDeleteTags; -}; - -#endif // MITKvtkObjectSet_H diff --git a/Modules/Ext/IO/mitkChiliPluginIpPicStub.c b/Modules/Ext/IO/mitkChiliPluginIpPicStub.c deleted file mode 100644 index d05c50b105..0000000000 --- a/Modules/Ext/IO/mitkChiliPluginIpPicStub.c +++ /dev/null @@ -1,18 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#undef CHILIPLUGIN -#include "mitkIpPicGet.c" diff --git a/Modules/Ext/IO/mitkObjFileIOFactory.cpp b/Modules/Ext/IO/mitkObjFileIOFactory.cpp deleted file mode 100644 index 24d6eaf34a..0000000000 --- a/Modules/Ext/IO/mitkObjFileIOFactory.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkObjFileIOFactory.h" -#include "mitkIOAdapter.h" -#include "mitkObjFileReader.h" - -#include "itkVersion.h" - - -namespace mitk -{ -ObjFileIOFactory::ObjFileIOFactory() -{ - this->RegisterOverride("mitkIOAdapter", - "mitkObjFileReader", - "mitk Obj Surface IO", - 1, - itk::CreateObjectFunction >::New()); -} - -ObjFileIOFactory::~ObjFileIOFactory() -{ -} - -const char* ObjFileIOFactory::GetITKSourceVersion() const -{ - return ITK_SOURCE_VERSION; -} - -const char* ObjFileIOFactory::GetDescription() const -{ - return "ObjFile IO Factory, allows the loading of Obj files"; -} - -} // end namespace mitk diff --git a/Modules/Ext/IO/mitkObjFileIOFactory.h b/Modules/Ext/IO/mitkObjFileIOFactory.h deleted file mode 100644 index 1ef13fdcbe..0000000000 --- a/Modules/Ext/IO/mitkObjFileIOFactory.h +++ /dev/null @@ -1,75 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#ifndef __mitkObjFileIOFactory_h -#define __mitkObjFileIOFactory_h - -#ifdef _MSC_VER -#pragma warning ( disable : 4786 ) -#endif - -#include "itkObjectFactoryBase.h" -#include "MitkExtExports.h" -#include "mitkBaseData.h" - -namespace mitk -{ -//##Documentation -//## @brief Create instances of ObjFileReader objects using an object factory. -//## -//## @ingroup IO -class MitkExt_EXPORT ObjFileIOFactory : public itk::ObjectFactoryBase -{ -public: - /** Standard class typedefs. */ - typedef ObjFileIOFactory Self; - typedef itk::ObjectFactoryBase Superclass; - typedef itk::SmartPointer Pointer; - typedef itk::SmartPointer ConstPointer; - - /** Class methods used to interface with the registered factories. */ - virtual const char* GetITKSourceVersion(void) const; - virtual const char* GetDescription(void) const; - - /** Method for class instantiation. */ - itkFactorylessNewMacro(Self); - static ObjFileIOFactory* FactoryNew() { return new ObjFileIOFactory;} - /** Run-time type information (and related methods). */ - itkTypeMacro(ObjFileIOFactory, ObjectFactoryBase); - - /** - * Register one factory of this type - * \deprecatedSince{2013_09} - */ - DEPRECATED(static void RegisterOneFactory(void)) - { - ObjFileIOFactory::Pointer ObjFileIOFactory = ObjFileIOFactory::New(); - ObjectFactoryBase::RegisterFactory(ObjFileIOFactory); - } - -protected: - ObjFileIOFactory(); - ~ObjFileIOFactory(); - -private: - ObjFileIOFactory(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - -}; - - -} // end namespace mitk - -#endif diff --git a/Modules/Ext/IO/mitkObjFileReader.cpp b/Modules/Ext/IO/mitkObjFileReader.cpp deleted file mode 100644 index f101302f66..0000000000 --- a/Modules/Ext/IO/mitkObjFileReader.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#include "mitkObjFileReader.h" -#include -#include - - -mitk::ObjFileReader::ObjFileReader() - : m_FileName("") -{ -} - -mitk::ObjFileReader::~ObjFileReader() -{ -} - -void mitk::ObjFileReader::GenerateData() -{ - mitk::Surface::Pointer output = this->GetOutput(); - - if( m_FileName != "") - { - MITK_INFO << "Loading " << m_FileName << " as obj..." << std::endl; - - vtkOBJReader *reader = vtkOBJReader::New(); - reader->SetFileName( m_FileName.c_str() ); - reader->Update(); - - if ( reader->GetOutput() != NULL ) - output->SetVtkPolyData( reader->GetOutput() ); - - reader->Delete(); - - MITK_INFO << "...finished!" << std::endl; - } -} - -bool mitk::ObjFileReader::CanReadFile(const std::string filename, const std::string /*filePrefix*/, const std::string /*filePattern*/) -{ - // First check the extension - //std::string filename = file; - if( filename == "" ) - { - //MITK_INFO<<"No filename specified."< - -mitk::PACSPlugin* mitk::PACSPlugin::GetInstance(bool destroyInstance) -{ - static mitk::PACSPlugin::Pointer s_Instance = mitk::PACSPlugin::New(); - - if( destroyInstance ) - { - s_Instance = NULL; - } - - return s_Instance; -} - - -mitk::PACSPlugin::PACSPlugin() -: m_ReaderType(0) -{ -} - - -mitk::PACSPlugin::~PACSPlugin() -{ -} - - -mitk::PACSPlugin::PACSPluginCapability mitk::PACSPlugin::GetPluginCapabilities() -{ - PACSPluginCapability result; - result.IsPACSFunctional = false; - result.HasLoadCapability = false; - result.HasSaveCapability = false; - return result; -} - - -mitk::PACSPlugin::PatientInformationList mitk::PACSPlugin::GetPatientInformationList() -{ - PatientInformationList emptyResult; - emptyResult.clear(); - return emptyResult; -} - - -mitk::PACSPlugin::StudyInformationList mitk::PACSPlugin::GetStudyInformationList( const PatientInformation& /* patient */ ) -{ - StudyInformationList emptyResult; - emptyResult.clear(); - return emptyResult; -} - - -mitk::PACSPlugin::SeriesInformationList mitk::PACSPlugin::GetSeriesInformationList( const std::string& /*studyInstanceUID*/ ) -{ - SeriesInformationList emptyResult; - emptyResult.clear(); - return emptyResult; -} - - -mitk::PACSPlugin::DocumentInformationList mitk::PACSPlugin::GetDocumentInformationList( const std::string& /*seriesInstanceUID*/ ) -{ - DocumentInformationList emptyResult; - emptyResult.clear(); - return emptyResult; -} - - -mitk::PACSPlugin::PatientInformation mitk::PACSPlugin::GetPatientInformation( const std::string& ) -{ - PatientInformation emptyResult; - emptyResult.PatientsSex = "O"; - emptyResult.PatientComments = "No PACS connectivity implemented or configured. Cannot query patient"; - return emptyResult; -} - - -mitk::PACSPlugin::StudyInformation mitk::PACSPlugin::GetStudyInformation( const std::string& ) -{ - StudyInformation emptyResult; - emptyResult.StudyDescription = "No PACS connectivity implemented or configured. Cannot query study"; - return emptyResult; -} - - -mitk::PACSPlugin::SeriesInformation mitk::PACSPlugin::GetSeriesInformation( const std::string& ) -{ - SeriesInformation emptyResult; - emptyResult.SeriesDescription = "No PACS connectivity implemented or configured. Cannot query series."; - return emptyResult; -} - - -mitk::PACSPlugin::DocumentInformation mitk::PACSPlugin::GetDocumentInformation( const std::string& itkNotUsed(seriesInstanceUID), - unsigned int itkNotUsed(instanceNumber) ) -{ - DocumentInformation emptyResult; - return emptyResult; -} - - -unsigned int mitk::PACSPlugin::GetLightboxCount() -{ - return 0; -} - - -unsigned int mitk::PACSPlugin::GetActiveLightbox() -{ - return (unsigned int)-1; // user should check GetLightboxCount() first, unsensible values might tell him that his request is not sensible -} - - -void mitk::PACSPlugin::SetReaderType( unsigned int readerType ) -{ - m_ReaderType = readerType; -} - - -void mitk::PACSPlugin::AbortPACSImport() -{ -} - - -std::vector mitk::PACSPlugin::LoadImagesFromLightbox( unsigned int itkNotUsed(lightboxIndex) ) -{ - std::vector emptyVector; - emptyVector.clear(); - return emptyVector; -} - - -std::vector mitk::PACSPlugin::LoadFromSeries( const std::string& seriesInstanceUID ) -{ - std::vector resultVector = this->LoadImagesFromSeries( seriesInstanceUID ); - std::vector secondResultVector = this->LoadTextsFromSeries( seriesInstanceUID ); - resultVector.insert( resultVector.end(), secondResultVector.begin(), secondResultVector.end() ); - return resultVector; -} - - -std::vector mitk::PACSPlugin::LoadImagesFromSeries( const std::string& /* seriesInstanceUID */ ) -{ - std::vector emptyVector; - emptyVector.clear(); - return emptyVector; -} - -std::vector mitk::PACSPlugin::LoadImagesFromSeries( std::vector /* seriesInstanceUIDs */ ) -{ - std::vector emptyVector; - emptyVector.clear(); - return emptyVector; -} - - -std::vector mitk::PACSPlugin::LoadTextsFromSeries( const std::string& /* seriesInstanceUID */ ) -{ - std::vector emptyVector; - emptyVector.clear(); - return emptyVector; -} - - -mitk::DataNode::Pointer mitk::PACSPlugin::LoadSingleText( const std::string& /* seriesInstanceUID */ , unsigned int /* instanceNumber */ ) -{ - return NULL; -} - - -void mitk::PACSPlugin::SaveAsNewSeries( DataStorage::SetOfObjects::ConstPointer /* inputNodes */, - const std::string& /* studyInstanceUID */, - int /* seriesNumber */, - const std::string& /*seriesDescription */) -{ -} - - -void mitk::PACSPlugin::SaveToSeries( DataStorage::SetOfObjects::ConstPointer /* inputNodes */, - const std::string& /* seriesInstanceUID */, - bool /* overwriteExistingSeries */) -{ -} - -void mitk::PACSPlugin::UploadFileAsNewSeries( const std::string& /* filename */, - const std::string& /* mimeType */, - const std::string& /* studyInstanceUID */, - int /* seriesNumber */, - const std::string& /* seriesDescription */ ) -{ -} - -void mitk::PACSPlugin::UploadFileToSeries( const std::string& /* filename */, - const std::string& /* filebasename */, - const std::string& /* mimeType */, - const std::string& /* seriesInstanceUID */, - bool /* overwriteExistingSeries */ ) -{ -} - -std::string mitk::PACSPlugin::GuessMIMEType( const std::string& filename ) -{ - std::ifstream file( filename.c_str() ); - if (!file) - { - // cannot open file - return std::string(""); - } - - const unsigned int maxLength = 8; - unsigned char line[ maxLength]; - file.getline( reinterpret_cast(line), maxLength ); - file.close(); - - std::string firstLine( reinterpret_cast(line) ); - - if ( firstLine.substr( 1, 3 ) == "PDF" ) - { - return std::string("application/pdf"); - } - - if ( firstLine.substr( 0, 5 ) == "{\\rtf" ) - { - return std::string("text/richtext"); - } - - if ( firstLine.substr( 0, 2 ) == "PK" ) - { - return std::string("application/zip"); - } - - if ( (line[0] == 0xFF) && (line[1] == 0xD8) ) - { - return std::string("image/jpeg"); - } - - if ( (line[0] == 0x89) && - (line[1] == 0x50) && - (line[2] == 0x4E) && - (line[3] == 0x47) && - (line[4] == 0x0D) && - (line[5] == 0x0A) && - (line[6] == 0x1A) && - (line[7] == 0x0A) - ) - { - return std::string("image/png"); - } - - if ( (line[0] == 0x4D) && (line[1] == 0x5A) ) - { - //return std::string("application/octet-stream"); - return std::string("Windows EXE"); - } - - if ( ( filename.rfind( ".stl" ) == filename.length() - 4 ) || - ( filename.rfind( ".STL" ) == filename.length() - 4 ) ) - { - // this is a guess. don't know a good way to test for STL. - return std::string("application/sla"); - } - - if ( ( filename.rfind( ".txt" ) == filename.length() - 4 ) || - ( filename.rfind( ".TXT" ) == filename.length() - 4 ) ) - { - // this is a guess. don't know a good way to test for STL. - return std::string("text/plain"); - } - - return std::string(""); -} - - -void mitk::PACSPlugin::DownloadSingleFile( const std::string& /*seriesInstanceUID*/, - unsigned int /*instanceNumber*/, - const std::string& /*filename*/) -{ -} diff --git a/Modules/Ext/IO/mitkPACSPlugin.h b/Modules/Ext/IO/mitkPACSPlugin.h deleted file mode 100644 index b17d09d086..0000000000 --- a/Modules/Ext/IO/mitkPACSPlugin.h +++ /dev/null @@ -1,315 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef MITKCHILIPLUGIN_H_HEADER_INCLUDED_C1EBD0AD -#define MITKCHILIPLUGIN_H_HEADER_INCLUDED_C1EBD0AD - -#include "mitkDataStorage.h" -#include "MitkExtExports.h" - -namespace mitk { - -/** Documentation - \brief Interface for minimal PACS communication - \ingroup IO - \ingroup Chili - - Defines some basic function for communication with a PACS. - Currently only really implemented for the CHILI Workstation (see CHILIPlugin), - but should be basic enough to work with differnt systems, too. - - \todo The PatientInformation, StudyInformation, SeriesInformation structures should be classes able to contain any kind of tags -*/ -class MitkExt_EXPORT PACSPlugin : public itk::Object -{ - public: - - /** This struct contain the plugin capabilities. */ - struct MitkExt_EXPORT PACSPluginCapability - { - bool IsPACSFunctional; // is there actually a real PACS connectivity implemented, configured and working right now? - bool HasLoadCapability; // can the current implementation load data from a PACS? - bool HasSaveCapability; // can the current implementation save data into the PACS? - }; - - /** Information about a patient in the PACS. Fields should correspond to DICOM PS 3.4-2008 Annex C.6.1.1.2 **/ - class MitkExt_EXPORT PatientInformation - { - public: - std::string UID; // application specific - std::string PatientsName; // tag 0010,0010 - std::string PatientID; // tag 0010,0020 - std::string PatientsBirthDate; // tag 0010,0030 - std::string PatientsBirthTime; // tag 0010,0032 - std::string PatientsSex; // tag 0010,0040 - std::string PatientComments; // tag 0010,4000 - }; - - typedef std::list PatientInformationList; - - /** Information about a study in the PACS. Fields should correspond to DICOM PS 3.4-2008 Annex C.6.1.1.3 **/ - class MitkExt_EXPORT StudyInformation - { - public: - std::string StudyInstanceUID; // tag 0020,000D - std::string StudyID; // tag 0020,0010 - std::string StudyDate; // tag 0008,0020 - std::string StudyTime; // tag 0008,0030 - std::string AccessionNumber; // tag 0008,0050 - std::string ModalitiesInStudy; // tag 0008,0061 - std::string ReferringPhysician; // tag 0008,0090 - std::string StudyDescription; // tag 0008,1030 - }; - - typedef std::list StudyInformationList; - - /** Information about a study in the PACS. Fields should correspond to DICOM PS 3.4-2008 Annex C.6.1.1.4 **/ - class MitkExt_EXPORT SeriesInformation - { - public: - std::string SeriesInstanceUID; // tag 0020,000E - int SeriesNumber; // tag 0020,0011 - std::string SeriesDate; // tag 0008,0021 - std::string SeriesTime; // tag 0008,0031 - std::string SeriesDescription; // tag 0008,103E - std::string BodyPartExamined; // tag 0018,0015 - std::string FrameOfReferenceUID;// tag 0020,0052 - int AcquisitionNumber; // tag 0020,0012 image specific - std::string ContrastAgent; // tag 0018,0010 image specific - std::string ScanningSequence; // tag 0018,0020 mr image specific - int EchoNumber; // tag 0018,0086 mr image specific - int TemporalPosition; // tag 0020,0100 mr image specific - - SeriesInformation() - : SeriesNumber(-1), - AcquisitionNumber(-1), - EchoNumber(-1), - TemporalPosition(-1) - { - } - }; - - typedef std::list SeriesInformationList; - - /** Information about a document in a series. Very roughly corresponds to DICOM PS 3.3-2008 Annex C.24 */ - class MitkExt_EXPORT DocumentInformation - { - public: - std::string SeriesInstanceUID; // tag 0020,000E - unsigned int InstanceNumber; // tag 0020,0013 - std::string MimeType; // tag 0042,0012 - std::string ContentDate; // tag 0008,0023 - std::string DocumentTitle; // tag 0042,0010 - - DocumentInformation() - :InstanceNumber( (unsigned int)-1 ) - { - } - }; - - /** There can be lots of texts to one series, so we need a list. */ - typedef std::list DocumentInformationList; - - mitkClassMacro( PACSPlugin,itk::Object ); - - /*! - * \brief Return a singleton mitk::PACSPlugin-Instance - * - * \param destroyInstance Tell the specific implementation it should free/delete itself. - * \warning Application should not use the instance after calling GetInstance(true); - * \todo check deletion mechanism, should be done by the application, which knows about CHILI (because there is a QcMITK... - */ - static PACSPlugin* GetInstance( bool destroyInstance = false ); - - /*! - * \brief Information about capabilities of the current implementation. - */ - virtual PACSPluginCapability GetPluginCapabilities(); - - /*! - * \brief Get a list of all known patients - */ - virtual PatientInformationList GetPatientInformationList(); - - /*! - * \brief Get a list of all studies for a patient - */ - virtual StudyInformationList GetStudyInformationList( const PatientInformation& patient ); - - /*! - * \brief Get a list of all series for a study instance UID - */ - virtual SeriesInformationList GetSeriesInformationList( const std::string& studyInstanceUID = "" ); - - /*! - * \brief Get a list of all non-image documents for a series instance UID - */ - virtual DocumentInformationList GetDocumentInformationList( const std::string& seriesInstanceUID = "" ); - - /*! - * \brief Patient information for a given series instance UID - */ - virtual PatientInformation GetPatientInformation( const std::string& seriesInstanceUID = "" ); - - /*! - * \brief Study information for a given series instance UID - */ - virtual StudyInformation GetStudyInformation( const std::string& seriesInstanceUID = "" ); - - /*! - * \brief Series information for a given series instance UID - */ - virtual SeriesInformation GetSeriesInformation( const std::string& seriesInstanceUID = "" ); - - /*! - * \brief Document information for a given series instance UID and a document instance number - */ - virtual DocumentInformation GetDocumentInformation( const std::string& seriesInstanceUID, - unsigned int instanceNumber ); - - /*! - * \brief Number of image preview boxes (lightboxes) - * - * If the specific PACS implementation supports a kind of lightbox concept - * (a preview of all images from a selected series), then this function should - * return how many of such lightboxes there are. - */ - virtual unsigned int GetLightboxCount(); - - /*! - * \brief Return the index of the active image preview box (lightbox) - * - * If the specific PACS implementation supports a kind of lightbox concept - * (a preview of all images from a selected series), then this function should - * return the index of the currently active lightbox (starting from 0). - * - * If no active lightbox exists (perhaps due to lack of such a concept), it - * is the calling object's duty to check if the returned index is larger than - * the number of existing lightboxes reported by GetLightboxCount(). - */ - virtual unsigned int GetActiveLightbox(); - - /*! - * Set type of "sorter" that stacks 2D images into 3D or 3D+t volumes - * \param readerType 0 used for the ImageNumberFilter, 1 for the SingleSpacingFilter and 2 used for SpacingSetFilter. - * \todo this should take enum values - */ - virtual void SetReaderType( unsigned int readerType = 0 ); - - virtual void AbortPACSImport(); - - /*! - * - * \brief Load all images from the given lightbox. - * \todo rename to LoadLightboxContent and load all images and texts, ignoring the lightbox!! make it use LoadSeriesContent for all series UIDs found in lightbox - */ - virtual std::vector LoadImagesFromLightbox( unsigned int lightboxIndex = 0 ); - - /*! - * \brief Load all objects from a given series instance UID - * \todo rename to LoadSeriesContent, make this take a list of UIDs - */ - virtual std::vector LoadFromSeries( const std::string& seriesInstanceUID ); - - /*! - * \brief Load all image objects from a given series instance UID - * \todo rename to LoadSeriesImageContent, make this take a list of UIDs - */ - virtual std::vector LoadImagesFromSeries( const std::string& seriesInstanceUID ); - - virtual std::vector LoadImagesFromSeries( std::vector seriesInstanceUIDs ); - - /*! - * \brief Load all objects from a given series instance UID - * \todo rename to LoadSeriesDocumentContent, make this take a list of UIDs - */ - virtual std::vector LoadTextsFromSeries( const std::string& seriesInstanceUID ); - - /*! - * \brief Load a given document object for a series instance UID and a document instance number - * \todo rename to LoadDocument make it take a list of parameters - */ - virtual DataNode::Pointer LoadSingleText( const std::string& seriesInstanceUID, unsigned int instanceNumber ); - - /*! - * \brief Load a given document object for a series instance UID and a document instance number - * In contrast to LoadSingleText this method will just create a new file on the local file system. - */ - virtual void DownloadSingleFile( const std::string& seriesInstanceUID, - unsigned int instanceNumber, - const std::string& filename ); - - /*! - * \brief Save given data as a new series - * \param studyInstanceUID save into this study - * \param seriesNumber a number identifying the new series - * \param seriesDescription a string description for the new series - */ - virtual void SaveAsNewSeries( DataStorage::SetOfObjects::ConstPointer inputNodes, - const std::string& studyInstanceUID, - int seriesNumber, - const std::string& seriesDescription ); - - /*! - * \brief Save given data into an existing series - * \param seriesInstanceUID save into this series - * \param seriesDescription a string description for the new series - */ - virtual void SaveToSeries( DataStorage::SetOfObjects::ConstPointer inputNodes, - const std::string& seriesInstanceUID, - bool overwriteExistingSeries ); - - /*! - * \brief Upload a file as a new series - * \param studyInstanceUID save into this study - * \param seriesNumber a number identifying the new series - * \param seriesDescription a string description for the new series - */ - virtual void UploadFileAsNewSeries( const std::string& filename, - const std::string& mimeType, - const std::string& studyInstanceUID, - int seriesNumber, - const std::string& seriesDescription ); - - /*! - * \brief Upload file into an existing series - * \param seriesInstanceUID save into this series - * \param seriesDescription a string description for the new series - */ - virtual void UploadFileToSeries( const std::string& filename, - const std::string& filebasename, - const std::string& mimeType, - const std::string& seriesInstanceUID, - bool overwriteExistingSeries ); - - virtual std::string GuessMIMEType( const std::string& filename ); - - - protected: - - // All this is hidden, should be instantiated through the GetInstance() method. - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - PACSPlugin(); - virtual ~PACSPlugin(); - - int m_ReaderType; -}; - -} // end namespace - -#endif - diff --git a/Modules/Ext/IO/mitkPACSPluginEvents.h b/Modules/Ext/IO/mitkPACSPluginEvents.h deleted file mode 100644 index 54130dfae8..0000000000 --- a/Modules/Ext/IO/mitkPACSPluginEvents.h +++ /dev/null @@ -1,36 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkPACSPluginEventshincluded -#define mitkPACSPluginEventshincluded - -#include -#pragma GCC visibility push(default) -#include -#pragma GCC visibility pop - -namespace mitk -{ - #pragma GCC visibility push(default) - itkEventMacro( PluginEvent, itk::AnyEvent ); - itkEventMacro( PluginStudySelected, PluginEvent ); - itkEventMacro( PluginLightBoxCountChanged, PluginEvent ); - itkEventMacro( PluginAbortPACSImport, PluginEvent ); - #pragma GCC visibility pop -} - -#endif - diff --git a/Modules/Ext/IO/mitkParRecFileIOFactory.cpp b/Modules/Ext/IO/mitkParRecFileIOFactory.cpp deleted file mode 100644 index 8b2d7d6bf5..0000000000 --- a/Modules/Ext/IO/mitkParRecFileIOFactory.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkParRecFileIOFactory.h" -#include "mitkIOAdapter.h" -#include "mitkParRecFileReader.h" - -#include "itkVersion.h" - - -namespace mitk -{ -ParRecFileIOFactory::ParRecFileIOFactory() -{ - this->RegisterOverride("mitkIOAdapter", - "mitkParRecFileReader", - "mitk ParRec Image IO", - 1, - itk::CreateObjectFunction >::New()); -} - -ParRecFileIOFactory::~ParRecFileIOFactory() -{ -} - -const char* ParRecFileIOFactory::GetITKSourceVersion() const -{ - return ITK_SOURCE_VERSION; -} - -const char* ParRecFileIOFactory::GetDescription() const -{ - return "ParRecFile IO Factory, allows the loading of ParRec images"; -} - -} // end namespace mitk diff --git a/Modules/Ext/IO/mitkParRecFileIOFactory.h b/Modules/Ext/IO/mitkParRecFileIOFactory.h deleted file mode 100644 index 334717fcb5..0000000000 --- a/Modules/Ext/IO/mitkParRecFileIOFactory.h +++ /dev/null @@ -1,76 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef __mitkParRecFileIOFactory_h -#define __mitkParRecFileIOFactory_h - -#ifdef _MSC_VER -#pragma warning ( disable : 4786 ) -#endif - -#include "itkObjectFactoryBase.h" -#include "MitkExtExports.h" -#include "mitkBaseData.h" - -namespace mitk -{ -//##Documentation -//## @brief Create instances of ParRecFileReader objects using an object factory. -//## -//## @ingroup IO -class MitkExt_EXPORT ParRecFileIOFactory : public itk::ObjectFactoryBase -{ -public: - /** Standard class typedefs. */ - typedef ParRecFileIOFactory Self; - typedef itk::ObjectFactoryBase Superclass; - typedef itk::SmartPointer Pointer; - typedef itk::SmartPointer ConstPointer; - - /** Class methods used to interface with the registered factories. */ - virtual const char* GetITKSourceVersion(void) const; - virtual const char* GetDescription(void) const; - - /** Method for class instantiation. */ - itkFactorylessNewMacro(Self); - static ParRecFileIOFactory* FactoryNew() { return new ParRecFileIOFactory;} - /** Run-time type information (and related methods). */ - itkTypeMacro(ParRecFileIOFactory, ObjectFactoryBase); - - /** - * Register one factory of this type - * \deprecatedSince{2013_09} - */ - DEPRECATED(static void RegisterOneFactory(void)) - { - ParRecFileIOFactory::Pointer ParRecFileIOFactory = ParRecFileIOFactory::New(); - ObjectFactoryBase::RegisterFactory(ParRecFileIOFactory); - } - -protected: - ParRecFileIOFactory(); - ~ParRecFileIOFactory(); - -private: - ParRecFileIOFactory(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - -}; - - -} // end namespace mitk - -#endif diff --git a/Modules/Ext/IO/mitkParRecFileReader.cpp b/Modules/Ext/IO/mitkParRecFileReader.cpp deleted file mode 100644 index 045064e54d..0000000000 --- a/Modules/Ext/IO/mitkParRecFileReader.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkParRecFileReader.h" -#include - -#ifdef __GNUC__ -#define stricmp strcasecmp -#endif - -void mitk::ParRecFileReader::GenerateOutputInformation() -{ - mitk::Image::Pointer output = this->GetOutput(); - - if ((output->IsInitialized()) && (this->GetMTime() <= m_ReadHeaderTime.GetMTime())) - return; - - itkDebugMacro(<<"Reading PAR file for GenerateOutputInformation()" << m_FileName); - - // Check to see if we can read the file given the name or prefix - // - if ( m_FileName == "" && m_FilePrefix == "" ) - { - throw itk::ImageFileReaderException(__FILE__, __LINE__, "One of FileName or FilePrefix must be non-empty"); - } - - m_RecFileName = ""; - if( m_FileName != "") - { - int extPos=m_FileName.find_last_of("."); - if(extPos>=-1) - { - const char *ext=m_FileName.c_str()+extPos+1; - if(stricmp(ext,"par")==0) - m_RecFileName = m_FileName.substr(0,extPos); - else - m_RecFileName = m_FileName; - } - else - m_RecFileName = m_FileName; - - m_RecFileName.append(".rec"); - - bool headerRead = false; - - bool signedCharType = true; - unsigned int dimension=0; - unsigned int dimensions[4]={0,0,1,1}; - float sliceThickness=0.0; - float sliceGap=0.0; - float sliceSpacing=0.0; - mitk::Vector3D thickness; thickness.Fill(1.0); - mitk::Vector3D gap; gap.Fill(0.0); - mitk::Vector3D spacing; - - FILE *f; - f=fopen(m_FileName.c_str(), "r"); - if(f!=NULL) - { - while(!feof(f)) - { - char s[300], *p; - char* ignored = fgets(s,200,f); - ++ignored; - if(strstr(s,"Max. number of cardiac phases")) - { - p=strchr(s,':')+1; - dimensions[3]=atoi(p); - if(dimensions[3]>1) - dimension=4; - } - else - if(strstr(s,"Max. number of slices/locations")) - { - p=strchr(s,':')+1; - dimensions[2]=atoi(p); - if(dimension==0) - { - if(dimensions[2]>1) - dimension=3; - else - dimension=2; - } - } - else - if(strstr(s,"Image pixel size")) - { - p=strchr(s,':')+1; - int bpe=atoi(p); - if(bpe!=8) - signedCharType = false; - } - else - if(strstr(s,"Recon resolution")) - { - p=s+strcspn(s,"0123456789"); - sscanf(p,"%u %u", dimensions, dimensions+1); - } - else - if(strstr(s,"FOV (ap,fh,rl) [mm]")) - { - p=s+strcspn(s,"0123456789"); - char *oldLocale = setlocale(LC_ALL, 0); - sscanf(p,"%f %f %f", &thickness[0], &thickness[1], &thickness[2]); - setlocale(LC_ALL, oldLocale); - } - else - if(strstr(s,"Slice thickness [mm]")) - { - p=s+strcspn(s,"0123456789"); - char *oldLocale = setlocale(LC_ALL, 0); - sscanf(p,"%f", &sliceThickness); - setlocale(LC_ALL, oldLocale); - } - else - if(strstr(s,"Slice gap [mm]")) - { - p=s+strcspn(s,"-0123456789"); - char *oldLocale = setlocale(LC_ALL, 0); - sscanf(p,"%f", &sliceGap); - setlocale(LC_ALL, oldLocale); - } - } - fclose(f); - -//C:\home\ivo\data\coronaries\ucsf-wholeheart-2.par - sliceSpacing = sliceThickness+sliceGap; - if((dimension>0) && (dimensions[0]>0) && (dimensions[1]>0) && (sliceThickness>0) && (sliceSpacing>0)) - { - headerRead = true; - if(fabs(thickness[0]/dimensions[2]-sliceSpacing)<0.0001) - thickness[0]=thickness[1]; - else - if(fabs(thickness[1]/dimensions[2]-sliceSpacing)<0.0001) - thickness[1]=thickness[0]; - thickness[2]=sliceSpacing; - - thickness[0]/=dimensions[0]; - thickness[1]/=dimensions[1]; - spacing=thickness+gap; - } - } - - if( headerRead == false) - { - itk::ImageFileReaderException e(__FILE__, __LINE__); - std::ostringstream msg; - msg << " Could not read file " - << m_FileName.c_str(); - e.SetDescription(msg.str().c_str()); - throw e; - return; - } - - // define types - mitk::PixelType SCType = mitk::MakeScalarPixelType(); - mitk::PixelType SSType = mitk::MakeScalarPixelType(); - - if( signedCharType ) - output->Initialize(SCType, dimension, dimensions); - else - output->Initialize(SSType, dimension, dimensions); - - output->GetSlicedGeometry()->SetSpacing(spacing); - - //output->GetSlicedGeometry()->SetPlaneGeometry(mitk::Image::BuildStandardPlanePlaneGeometry(output->GetSlicedGeometry(), dimensions).GetPointer(), 0); - output->GetSlicedGeometry()->SetEvenlySpaced(); - } - - m_ReadHeaderTime.Modified(); -} - -void mitk::ParRecFileReader::GenerateData() -{ - mitk::Image::Pointer output = this->GetOutput(); - - // Check to see if we can read the file given the name or prefix - // - if ( m_RecFileName == "" ) - { - throw itk::ImageFileReaderException(__FILE__, __LINE__, "FileName for rec-file empty"); - } - - if( m_RecFileName != "") - { - FILE *f = fopen(m_RecFileName.c_str(), "r"); - if(f==NULL) - { - throw itk::ImageFileReaderException(__FILE__, __LINE__, "Could not open rec-file."); - } - - int zstart, zmax; - int tstart, tmax; - - zstart=output->GetRequestedRegion().GetIndex(2); - tstart=output->GetRequestedRegion().GetIndex(3); - - zmax=zstart+output->GetRequestedRegion().GetSize(2); - tmax=tstart+output->GetRequestedRegion().GetSize(3); - - int sliceSize=output->GetDimension(0)*output->GetDimension(1)*output->GetPixelType().GetBpe()/8; - void *data = malloc(sliceSize); - - bool ignore4Dtopogram=false; - { - int slicePlusTimeSize=output->GetDimension(0)*output->GetDimension(1)*output->GetDimension(3)*output->GetPixelType().GetBpe()/8; - if(output->GetDimension(3)>1) - ignore4Dtopogram=true; - - int z,t; - for(t=tstart;tSetSlice(data,z,t,0); - } - } - //else - //{ - // for(;zSetSlice(data,z,0,0); - // } - //} - free(data); - - fclose(f); - } -} - -bool mitk::ParRecFileReader::CanReadFile(const std::string filename, const std::string /*filePrefix*/, const std::string /*filePattern*/) -{ - // First check the extension - if( filename == "" ) - { - //MITK_INFO<<"No filename specified."< -#include -#include "mitkProperties.h" -#include "mitkStringProperty.h" -#include "mitkEnumerationProperty.h" -#include -#include -#include -#include "usServiceReference.h" -#include -#include - -namespace mitk -{ - struct PropertyListExportToXmlFileData - { - const std::string* m_FileName; - const PropertyList* m_PropertyList; - }; - - PropertyListExportToXmlFile::PropertyListExportToXmlFile(const std::string* _FileName, - const PropertyList* _PropertyList) - : d( new PropertyListExportToXmlFileData ) - { - d->m_FileName = _FileName; - d->m_PropertyList = _PropertyList; - } - - PropertyListExportToXmlFile::~PropertyListExportToXmlFile() - { - delete d; - } - - void PropertyListExportToXmlFile::Update() - { - std::string _FileName = *d->m_FileName; - PropertyList::Pointer propList = PropertyList::New(); - - TiXmlDocument doc( _FileName.c_str() ); - TiXmlElement* root = 0; - TiXmlElement* elem = 0; - - std::string className; - d->m_PropertyList->GetStringProperty("ClassName", className); - // check if element is already available - if(doc.LoadFile()) - { - root = doc.FirstChildElement(); - if(!root) - { - MITK_WARN("PropertyListExportToXml") << "No root element found"; - return; - } - elem = root->FirstChildElement( className ); - std::string id; - d->m_PropertyList->GetStringProperty("Id", id); - if( !id.empty() ) - { - std::string foundId; - while(elem) - { - elem->QueryStringAttribute("Id", &foundId); - if( foundId == id ) - break; - elem = elem->NextSiblingElement( className ); - } - } - } - else - { - // document did not exist, create new one with declration - TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "", "" ); - doc.LinkEndChild( decl ); - // create root - root = new TiXmlElement( "data" ); - doc.LinkEndChild( root ); - } - - // create elem if not existent - TiXmlElement* newElem = 0; - if(!elem) - { - elem = new TiXmlElement( className ); - newElem = elem; - } - - const std::map< std::string, BaseProperty::Pointer>* propMap = d->m_PropertyList->GetMap(); - std::map< std::string, BaseProperty::Pointer>::const_iterator propMapIt = propMap->begin(); - while( propMapIt != propMap->end() ) - { - if( propMapIt->first.find_first_of(".") != std::string::npos ) - { - MITK_DEBUG << "meta property found. will not write."; - ++propMapIt; - continue; - } - mitk::IntProperty* intProp = 0; - mitk::FloatProperty* floatProp = 0; - mitk::DoubleProperty* doubleProp = 0; - mitk::BoolProperty* boolProp = 0; - mitk::StringProperty* stringProp = 0; - mitk::EnumerationProperty* enumProp = 0; - - if( (boolProp = dynamic_cast( propMapIt->second.GetPointer() ) ) ) - { - elem->SetAttribute( propMapIt->first, boolProp->GetValue() ? 1 : 0 ); - } - else if( (stringProp = dynamic_cast( propMapIt->second.GetPointer() ) ) ) - { - elem->SetAttribute( propMapIt->first, stringProp->GetValue() ); - } - else if( (intProp = dynamic_cast( propMapIt->second.GetPointer() ) ) ) - { - elem->SetAttribute( propMapIt->first, intProp->GetValue() ); - } - else if( (enumProp = dynamic_cast( propMapIt->second.GetPointer() ) ) ) - { - elem->SetAttribute( propMapIt->first, enumProp->GetValueAsId() ); - } - else if( (doubleProp = dynamic_cast( propMapIt->second.GetPointer() ) ) ) - { - elem->SetDoubleAttribute( propMapIt->first, doubleProp->GetValue() ); - } - else if( (floatProp = dynamic_cast( propMapIt->second.GetPointer() ) ) ) - { - elem->SetDoubleAttribute( propMapIt->first, static_cast( floatProp->GetValue() ) ); - } - else - { - MITK_DEBUG << "trying to look up serializer for baseproperty in AlgorithmRegistry"; - - { - MITK_WARN("PropertyListExportToXmlFile") << "Base property " << propMapIt->first << " is unknown"; - } - } - ++propMapIt; - } - - // add the element node as child - if( newElem ) - root->LinkEndChild(elem); - - if( !doc.SaveFile( _FileName ) ) - { - MITK_DEBUG << "File " << _FileName << " could not be written. Please check permissions."; - MITK_WARN("PropertyListExportToXmlFile") << "Cannot write file"; - } - } - - void PropertyListExportToXmlFile::SetFileName(const std::string* _FileName) - { - d->m_FileName = _FileName; - } - - void PropertyListExportToXmlFile::SetPropertyList(const PropertyList* _PropertyList) - { - d->m_PropertyList = _PropertyList; - } -} // namespace mitk diff --git a/Modules/Ext/IO/mitkPropertyListExportToXmlFile.h b/Modules/Ext/IO/mitkPropertyListExportToXmlFile.h deleted file mode 100644 index 6bc4ef6d87..0000000000 --- a/Modules/Ext/IO/mitkPropertyListExportToXmlFile.h +++ /dev/null @@ -1,63 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#ifndef mitkPropertyListExportToXmlFile_h -#define mitkPropertyListExportToXmlFile_h - -#include "MitkExtExports.h" -#include - -namespace mitk -{ - /// - /// d pointer forward declaration - /// - struct PropertyListExportToXmlFileData; - /// - /// writes a 2d cv point to an xml file - /// - class MitkExt_EXPORT PropertyListExportToXmlFile - { - public: - /// - /// init default values and save references - /// - PropertyListExportToXmlFile( const std::string* _FileName = 0, - const PropertyList* _PropertyList = 0); - /// - /// executes the algorithm if inputs changed - /// - void Update(); - /// - /// delete d pointer - /// - virtual ~PropertyListExportToXmlFile(); - /// - /// setter for field FileName - /// - void SetFileName(const std::string* _FileName); - /// - /// setter for field PropertyList - /// - void SetPropertyList(const PropertyList* _PropertyList); - private: - /// - /// d pointer - /// - PropertyListExportToXmlFileData* d; - }; -} // namespace mitk - -#endif // mitkPropertyListExportToXmlFile_h diff --git a/Modules/Ext/IO/mitkPropertyListImportFromXmlFile.cpp b/Modules/Ext/IO/mitkPropertyListImportFromXmlFile.cpp deleted file mode 100644 index aa70e625e1..0000000000 --- a/Modules/Ext/IO/mitkPropertyListImportFromXmlFile.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#include "mitkPropertyListImportFromXmlFile.h" -#include -#include -#include -#include "mitkProperties.h" -#include "mitkStringProperty.h" -#include "mitkEnumerationProperty.h" -#include "mitkGenericProperty.h" -//#include "mitkBasePropertyFromString.h" -#include -#include -#include -#include "usServiceReference.h" - -namespace mitk -{ - struct PropertyListImportFromXmlFileData - { - const std::string* m_FileName; - PropertyList* m_PropertyList; - - //private - long int m_FileModifiedTime; - }; - - PropertyListImportFromXmlFile::PropertyListImportFromXmlFile( - const std::string* _FileName, - PropertyList* _PropertyList) - : d( new PropertyListImportFromXmlFileData ) - { - d->m_FileName = _FileName; - d->m_PropertyList = _PropertyList; - d->m_FileModifiedTime = 0; - } - - PropertyListImportFromXmlFile::~PropertyListImportFromXmlFile() - { - delete d; - } - - void GetPropertyListFromXMLFile ( const TiXmlElement* elem, const std::string* _FileName, PropertyList* _PropertyList ) - { - const std::map< std::string, BaseProperty::Pointer>* propMap = _PropertyList->GetMap(); - std::map< std::string, BaseProperty::Pointer>::const_iterator propMapIt = propMap->begin(); - while( propMapIt != propMap->end() ) - { - std::string key = propMapIt->first; - mitk::BaseProperty* prop = propMapIt->second.GetPointer(); - mitk::IntProperty* intProp = 0; - mitk::FloatProperty* floatProp = 0; - mitk::DoubleProperty* doubleProp = 0; - mitk::BoolProperty* boolProp = 0; - mitk::StringProperty* stringProp = 0; - mitk::EnumerationProperty* enumProp = 0; - bool found = false; - - if( (boolProp = dynamic_cast( prop ) ) ) - { - int val = false; - found = elem->QueryIntAttribute(key, &val) == TIXML_SUCCESS; - if( found ) - boolProp->SetValue( val==0 ? false : true ); - } - else if( (stringProp = dynamic_cast( prop ) ) ) - { - std::string val = ""; - found = elem->QueryStringAttribute(key.c_str(), &val) == TIXML_SUCCESS; - if( found ) - stringProp->SetValue( val ); - } - else if( (intProp = dynamic_cast( prop ) ) ) - { - int val = 0; - found = elem->QueryIntAttribute(key, &val) == TIXML_SUCCESS; - if( found ) - intProp->SetValue( val ); - } - else if( (enumProp = dynamic_cast( prop ) ) ) - { - int val = 0; - found = elem->QueryIntAttribute(key, &val) == TIXML_SUCCESS; - if( found && enumProp->IsValidEnumerationValue( val ) ) - enumProp->SetValue( static_cast ( val ) ); - else - { - std::string strval = ""; - found = elem->QueryStringAttribute(key.c_str(), &strval); - if( found && enumProp->IsValidEnumerationValue( strval ) ) - enumProp->SetValue( strval ); - } - } - else if( (doubleProp = dynamic_cast( prop ) ) ) - { - double val = 0; - found = elem->QueryDoubleAttribute(key, &val) == TIXML_SUCCESS; - doubleProp->SetValue( val ); - } - else if( (floatProp = dynamic_cast( prop ) ) ) - { - double val = 0; - found = elem->QueryDoubleAttribute(key, &val) == TIXML_SUCCESS; - floatProp->SetValue( static_cast( val ) ); - } - else - { - MITK_WARN("PropertyListImportFromXmlFile") << "Base property " << key << " is unknown"; - } - - if(!found) - { - MITK_DEBUG << "Attribute " << key << " not found"; - } - - ++propMapIt; - } - } - - void PropertyListImportFromXmlFile::Update() - { - - std::string _FileName = *d->m_FileName; - - MITK_DEBUG << "extracting real path (complete path)"; - _FileName = itksys::SystemTools::GetRealPath( _FileName.c_str() ); - - if( !itksys::SystemTools::FileExists(_FileName.c_str()) ) - { - MITK_WARN("PropertyListFromXml") << " Cannot open file"; - } - - long int _FileModifiedTime = itksys::SystemTools::ModifiedTime( _FileName.c_str() ); - // file has not changed: we know that version... -> do nothing - if( d->m_FileModifiedTime >= _FileModifiedTime ) - return; - - // reread - TiXmlDocument doc( _FileName ); - doc.LoadFile(); - - MITK_DEBUG << "searching for element with classname"; - std::string className; - d->m_PropertyList->GetStringProperty("ClassName", className); - - TiXmlHandle docHandle( &doc ); - TiXmlElement* elem = docHandle.FirstChildElement().FirstChildElement( className ).ToElement(); - - if(!elem) - { - MITK_WARN("PropertyListFromXml") << "Cannot find element"; - return; - } - - std::string id; - d->m_PropertyList->GetStringProperty("Id", id); - if( !id.empty() ) - { - std::string foundId; - while(elem) - { - elem->QueryStringAttribute("Id", &foundId); - if( foundId == id ) - break; - elem = elem->NextSiblingElement( className ); - } - if(!elem) - { - MITK_WARN("PropertyListFromXml") << "Cannot find element by id"; - return; - } - } - - MITK_DEBUG << "element found. now reading attributes into propertylist"; - GetPropertyListFromXMLFile( elem, &_FileName, d->m_PropertyList ); - - MITK_DEBUG << "save that modified time"; - d->m_FileModifiedTime = _FileModifiedTime; - } - - void PropertyListImportFromXmlFile::SetFileName(const std::string* _FileName) - { - d->m_FileName = _FileName; - } - - void PropertyListImportFromXmlFile::SetPropertyList(PropertyList* _PropertyList) - { - d->m_PropertyList = _PropertyList; - } -} // namespace mitk diff --git a/Modules/Ext/IO/mitkPropertyListImportFromXmlFile.h b/Modules/Ext/IO/mitkPropertyListImportFromXmlFile.h deleted file mode 100644 index e4e983876e..0000000000 --- a/Modules/Ext/IO/mitkPropertyListImportFromXmlFile.h +++ /dev/null @@ -1,64 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#ifndef mitkPropertyListImportFromXmlFile_h -#define mitkPropertyListImportFromXmlFile_h - -#include -#include "MitkExtExports.h" - -namespace mitk -{ - /// - /// d pointer forward declaration - /// - struct PropertyListImportFromXmlFileData; - /// - /// DOCUMENTATION - /// - class MitkExt_EXPORT PropertyListImportFromXmlFile - { - public: - /// - /// init default values and save references - /// - PropertyListImportFromXmlFile( const std::string* _FileName = 0, - PropertyList* _PropertyList = 0 ); - - /// - /// executes the algorithm if inputs changed - /// - void Update(); - /// - /// delete d pointer - /// - virtual ~PropertyListImportFromXmlFile(); - /// - /// setter for field FileName - /// - void SetFileName(const std::string* _FileName); - /// - /// setter for field PropertyList - /// - void SetPropertyList(PropertyList* _PropertyList); - private: - /// - /// d pointer - /// - PropertyListImportFromXmlFileData* d; - }; -} // namespace mitk - -#endif // mitkPropertyListImportFromXmlFile_h diff --git a/Modules/Ext/IO/mitkStlVolumeTimeSeriesIOFactory.cpp b/Modules/Ext/IO/mitkStlVolumeTimeSeriesIOFactory.cpp deleted file mode 100644 index 12e1582135..0000000000 --- a/Modules/Ext/IO/mitkStlVolumeTimeSeriesIOFactory.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkStlVolumeTimeSeriesIOFactory.h" -#include "mitkIOAdapter.h" -#include "mitkStlVolumeTimeSeriesReader.h" - -#include "itkVersion.h" - - -namespace mitk -{ -StlVolumeTimeSeriesIOFactory::StlVolumeTimeSeriesIOFactory() -{ - this->RegisterOverride("mitkIOAdapter", - "mitkStlVolumeTimeSeriesReader", - "mitk Stl Surface IO", - 1, - itk::CreateObjectFunction >::New()); -} - -StlVolumeTimeSeriesIOFactory::~StlVolumeTimeSeriesIOFactory() -{ -} - -const char* StlVolumeTimeSeriesIOFactory::GetITKSourceVersion() const -{ - return ITK_SOURCE_VERSION; -} - -const char* StlVolumeTimeSeriesIOFactory::GetDescription() const -{ - return "StlVolumeTimeSeries IO Factory, allows the loading of Stl surfaces"; -} - -} // end namespace mitk diff --git a/Modules/Ext/IO/mitkStlVolumeTimeSeriesIOFactory.h b/Modules/Ext/IO/mitkStlVolumeTimeSeriesIOFactory.h deleted file mode 100644 index fce9500ff4..0000000000 --- a/Modules/Ext/IO/mitkStlVolumeTimeSeriesIOFactory.h +++ /dev/null @@ -1,75 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#ifndef __mitkStlVolumeTimeSeriesIOFactory_h -#define __mitkStlVolumeTimeSeriesIOFactory_h - -#ifdef _MSC_VER -#pragma warning ( disable : 4786 ) -#endif - -#include "itkObjectFactoryBase.h" -#include "MitkExtExports.h" -#include "mitkBaseData.h" - -namespace mitk -{ -//##Documentation -//## @brief Create instances of StlVolumeTimeSeriesReader objects using an object factory. -//## -//## @ingroup IO -class MitkExt_EXPORT StlVolumeTimeSeriesIOFactory : public itk::ObjectFactoryBase -{ -public: - /** Standard class typedefs. */ - typedef StlVolumeTimeSeriesIOFactory Self; - typedef itk::ObjectFactoryBase Superclass; - typedef itk::SmartPointer Pointer; - typedef itk::SmartPointer ConstPointer; - - /** Class methods used to interface with the registered factories. */ - virtual const char* GetITKSourceVersion(void) const; - virtual const char* GetDescription(void) const; - - /** Method for class instantiation. */ - itkFactorylessNewMacro(Self); - static StlVolumeTimeSeriesIOFactory* FactoryNew() { return new StlVolumeTimeSeriesIOFactory;} - /** Run-time type information (and related methods). */ - itkTypeMacro(StlVolumeTimeSeriesIOFactory, ObjectFactoryBase); - - /** - * Register one factory of this type - * \deprecatedSince{2013_09} - */ - DEPRECATED(static void RegisterOneFactory(void)) - { - StlVolumeTimeSeriesIOFactory::Pointer StlVolumeTimeSeriesIOFactory = StlVolumeTimeSeriesIOFactory::New(); - ObjectFactoryBase::RegisterFactory(StlVolumeTimeSeriesIOFactory); - } - -protected: - StlVolumeTimeSeriesIOFactory(); - ~StlVolumeTimeSeriesIOFactory(); - -private: - StlVolumeTimeSeriesIOFactory(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - -}; - - -} // end namespace mitk - -#endif diff --git a/Modules/Ext/IO/mitkStlVolumeTimeSeriesReader.cpp b/Modules/Ext/IO/mitkStlVolumeTimeSeriesReader.cpp deleted file mode 100644 index 0188706f5e..0000000000 --- a/Modules/Ext/IO/mitkStlVolumeTimeSeriesReader.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkStlVolumeTimeSeriesReader.h" -#include "mitkSTLFileReader.h" -#include "mitkSurface.h" -#include "vtkPolyData.h" - -void mitk::StlVolumeTimeSeriesReader::GenerateData() -{ - if ( !this->GenerateFileList() ) - { - itkWarningMacro( << "Sorry, file list could not be determined..." ); - return ; - } - - mitk::Surface::Pointer surface = this->GetOutput(); - MITK_INFO << "prefix: "<< m_FilePrefix << ", pattern: " <Expand(m_MatchedFileNames.size()); - for ( unsigned int i = 0 ; i < m_MatchedFileNames.size(); ++i ) - { - std::string fileName = m_MatchedFileNames[i]; - MITK_INFO << "Loading " << fileName << " as stl..." << std::endl; - - STLFileReader::Pointer stlReader = STLFileReader::New(); - stlReader->SetFileName( fileName.c_str() ); - stlReader->Update(); - - if ( stlReader->GetOutput() != NULL ) - { - surface->SetVtkPolyData( stlReader->GetOutput()->GetVtkPolyData(), i ); - } - else - { - itkWarningMacro(<< "stlReader returned NULL while reading " << fileName << ". Trying to continue with empty vtkPolyData..."); - surface->SetVtkPolyData( vtkPolyData::New(), i ); - } - } -} - -bool mitk::StlVolumeTimeSeriesReader::CanReadFile(const std::string /*filename*/, const std::string filePrefix, const std::string filePattern) -{ - if( filePattern != "" && filePrefix != "" ) - return false; - - bool extensionFound = false; - std::string::size_type STLPos = filePattern.rfind(".stl"); - if ((STLPos != std::string::npos) && (STLPos == filePattern.length() - 4)) - extensionFound = true; - - STLPos = filePattern.rfind(".STL"); - if ((STLPos != std::string::npos) && (STLPos == filePattern.length() - 4)) - extensionFound = true; - - if( !extensionFound ) - return false; - - return true; -} - -mitk::StlVolumeTimeSeriesReader::StlVolumeTimeSeriesReader() -{} - -mitk::StlVolumeTimeSeriesReader::~StlVolumeTimeSeriesReader() -{} diff --git a/Modules/Ext/IO/mitkStlVolumeTimeSeriesReader.h b/Modules/Ext/IO/mitkStlVolumeTimeSeriesReader.h deleted file mode 100644 index 6ea287fe18..0000000000 --- a/Modules/Ext/IO/mitkStlVolumeTimeSeriesReader.h +++ /dev/null @@ -1,68 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef _Stl_VOLUME_TIME_SERIES_READER__H_ -#define _Stl_VOLUME_TIME_SERIES_READER__H_ - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkFileSeriesReader.h" -#include "mitkSurfaceSource.h" - -namespace mitk -{ -//##Documentation -//## @brief Reader to read a series of volume files in stl-format -//## @ingroup IO -class MitkExt_EXPORT StlVolumeTimeSeriesReader : public SurfaceSource, public FileSeriesReader -{ -public: - mitkClassMacro( StlVolumeTimeSeriesReader, FileReader ); - - /** Method for creation through the object factory. */ - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - itkSetStringMacro(FileName); - itkGetStringMacro(FileName); - - itkSetStringMacro(FilePrefix); - itkGetStringMacro(FilePrefix); - - itkSetStringMacro(FilePattern); - itkGetStringMacro(FilePattern); - - static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern); - -protected: - virtual void GenerateData(); - - StlVolumeTimeSeriesReader(); - - ~StlVolumeTimeSeriesReader(); - - //##Description - //## @brief Time when Header was last read - itk::TimeStamp m_ReadHeaderTime; - -}; - -} // namespace mitk - -#endif - - diff --git a/Modules/Ext/IO/mitkUnstructuredGridVtkWriter.cpp b/Modules/Ext/IO/mitkUnstructuredGridVtkWriter.cpp deleted file mode 100644 index c5c68ecccf..0000000000 --- a/Modules/Ext/IO/mitkUnstructuredGridVtkWriter.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkUnstructuredGridVtkWriter.h" -#include "mitkUnstructuredGridVtkWriter.txx" - -namespace mitk { - -template<> -std::vector UnstructuredGridVtkWriter::GetPossibleFileExtensions() -{ - std::vector possibleFileExtensions; - possibleFileExtensions.push_back(".vtk"); - return possibleFileExtensions; -} - -template<> -std::vector UnstructuredGridVtkWriter::GetPossibleFileExtensions() -{ - std::vector possibleFileExtensions; - possibleFileExtensions.push_back(".vtu"); - return possibleFileExtensions; -} - -template<> -std::vector UnstructuredGridVtkWriter::GetPossibleFileExtensions() -{ - std::vector possibleFileExtensions; - possibleFileExtensions.push_back(".pvtu"); - return possibleFileExtensions; -} - -template<> -const char * UnstructuredGridVtkWriter::GetDefaultFilename() -{ - return "vtkUnstructuredGrid.vtk"; -} - -template<> -const char * UnstructuredGridVtkWriter::GetDefaultFilename() -{ - return "vtkUnstructuredGrid.vtu"; -} - -template<> -const char * UnstructuredGridVtkWriter::GetDefaultFilename() -{ - return "vtkUnstructuredGrid.pvtu"; -} - -template<> -const char * UnstructuredGridVtkWriter::GetFileDialogPattern() -{ - return "VTK Legacy Unstructured Grid (*.vtk)"; -} - -template<> -const char * UnstructuredGridVtkWriter::GetFileDialogPattern() -{ - return "VTK XML Unstructured Grid (*.vtu)"; -} - -template<> -const char * UnstructuredGridVtkWriter::GetFileDialogPattern() -{ - return "VTK Parallel XML Unstructured Grid (*.pvtu)"; -} - -template<> -const char * UnstructuredGridVtkWriter::GetDefaultExtension() -{ - return ".vtk"; -} - -template<> -const char * UnstructuredGridVtkWriter::GetDefaultExtension() -{ - return ".vtu"; -} - -template<> -const char * UnstructuredGridVtkWriter::GetDefaultExtension() -{ - return ".pvtu"; -} - - -template class UnstructuredGridVtkWriter; -template class UnstructuredGridVtkWriter; -template class UnstructuredGridVtkWriter; - - -} - diff --git a/Modules/Ext/IO/mitkUnstructuredGridVtkWriter.h b/Modules/Ext/IO/mitkUnstructuredGridVtkWriter.h deleted file mode 100644 index ddfc1710a1..0000000000 --- a/Modules/Ext/IO/mitkUnstructuredGridVtkWriter.h +++ /dev/null @@ -1,157 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef _MITK_UNSTRUCTURED_GRID_VTK_WRITER__H_ -#define _MITK_UNSTRUCTURED_GRID_VTK_WRITER__H_ - - -#include -#include - -#include -#include -#include - -#include "mitkUnstructuredGrid.h" - -#include - -namespace mitk -{ - -/** - * @brief VTK-based writer for mitk::UnstructuredGrid - * - * The mitk::UnstructuredGrid is written using the VTK-writer-type provided as the - * template argument. If the mitk::UnstructuredGrid contains multiple points of - * time, multiple files are written. The life-span (time-bounds) of each - * each point of time is included in the filename according to the - * following scheme: - * <filename>_S<timebounds[0]>E<timebounds[1]>_T<framenumber> - * (S=start, E=end, T=time). - * Writing of multiple files according to a given filename pattern is not - * yet supported. - * @ingroup Process -*/ -template -class MitkExt_EXPORT UnstructuredGridVtkWriter : public mitk::FileWriterWithInformation -{ -public: - - mitkClassMacro( UnstructuredGridVtkWriter, mitk::FileWriterWithInformation ); - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - mitkWriterMacro; - - /** - * Sets the filename of the file to write. - * @param _arg the name of the file to write. - */ - itkSetStringMacro( FileName ); - - /** - * @returns the name of the file to be written to disk. - */ - itkGetStringMacro( FileName ); - - /** - * @warning multiple write not (yet) supported - */ - itkSetStringMacro( FilePrefix ); - - /** - * @warning multiple write not (yet) supported - */ - itkGetStringMacro( FilePrefix ); - - /** - * @warning multiple write not (yet) supported - */ - itkSetStringMacro( FilePattern ); - - /** - * @warning multiple write not (yet) supported - */ - itkGetStringMacro( FilePattern ); - - using FileWriter::SetInput; - - /** - * Sets the 0'th input object for the filter. - * @param input the first input for the filter. - */ - void SetInput( BaseData* input ); - - /** - * @returns the 0'th input object of the filter. - */ - const UnstructuredGrid* GetInput(); - - /** - * Returns false if an error happened during writing - */ - itkGetMacro( Success, bool ); - - /** - * @brief Return the possible file extensions for the data type associated with the writer - */ - virtual std::vector GetPossibleFileExtensions(); - - // FileWriterWithInformation methods - virtual const char * GetDefaultFilename(); - virtual const char * GetFileDialogPattern(); - virtual const char * GetDefaultExtension(); - virtual bool CanWriteBaseDataType(BaseData::Pointer data); - virtual void DoWrite(BaseData::Pointer data); - -protected: - - /** - * Constructor. - */ - UnstructuredGridVtkWriter(); - - /** - * Virtual destructor. - */ - virtual ~UnstructuredGridVtkWriter(); - - void ExecuteWrite(VTKWRITER* vtkWriter); - - virtual void GenerateData(); - - std::string m_FileName; - - std::string m_FilePrefix; - - std::string m_FilePattern; - - bool m_Success; -}; - -#ifndef MitkExt_EXPORTS -extern template class UnstructuredGridVtkWriter; -extern template class UnstructuredGridVtkWriter; -extern template class UnstructuredGridVtkWriter; -#endif - -} - - -#endif // _MITK_UNSTRUCTURED_GRID_VTK_WRITER__H_ diff --git a/Modules/Ext/IO/mitkUnstructuredGridVtkWriter.txx b/Modules/Ext/IO/mitkUnstructuredGridVtkWriter.txx deleted file mode 100644 index 46eb319ee5..0000000000 --- a/Modules/Ext/IO/mitkUnstructuredGridVtkWriter.txx +++ /dev/null @@ -1,203 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef _MITK_UNSTRUCTURED_GRID_VTKWRITER_TXX_ -#define _MITK_UNSTRUCTURED_GRID_VTKWRITER_TXX_ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace mitk { - -template -UnstructuredGridVtkWriter::UnstructuredGridVtkWriter() - : m_Success(false) -{ - this->SetNumberOfRequiredInputs(1); -} - -template -UnstructuredGridVtkWriter::~UnstructuredGridVtkWriter() -{ - -} - -template -void UnstructuredGridVtkWriter::GenerateData() -{ - m_Success = false; - if ( m_FileName == "" ) - { - itkWarningMacro( << "Sorry, filename has not been set!" ); - return ; - } - - mitk::UnstructuredGrid::Pointer input = const_cast(this->GetInput()); - - if (input.IsNull()) - { - itkWarningMacro( << "Sorry, input to mitk::UnstructuredGridVtkWriter is NULL"); - return; - } - - VTKWRITER* unstructuredGridWriter = VTKWRITER::New(); - vtkTransformFilter* transformPointSet = vtkTransformFilter::New(); - vtkUnstructuredGrid * unstructuredGrid; - BaseGeometry* geometry; - - if(input->GetTimeGeometry()->CountTimeSteps()>1) - { - - int t, timesteps; - - timesteps = input->GetTimeGeometry()->CountTimeSteps(); - for(t = 0; t < timesteps; ++t) - { - std::ostringstream filename; - geometry = input->GetGeometry(t); - if(input->GetTimeGeometry()->IsValidTimeStep(t)) - { - const mitk::TimeBounds& timebounds = input->GetTimeGeometry()->GetTimeBounds(t); - filename << m_FileName.c_str() << "_S" << std::setprecision(0) << timebounds[0] << "_E" << std::setprecision(0) << timebounds[1] << "_T" << t << GetDefaultExtension(); - } - else - { - itkWarningMacro(<<"Error on write: TimeGeometry invalid of unstructured grid " << filename.str() << "."); - filename << m_FileName.c_str() << "_T" << t << GetDefaultExtension(); - } - transformPointSet->SetInputData(input->GetVtkUnstructuredGrid(t)); - transformPointSet->SetTransform(geometry->GetVtkTransform()); - transformPointSet->UpdateWholeExtent(); - unstructuredGrid = static_cast(transformPointSet->GetOutput()); - - unstructuredGridWriter->SetFileName(filename.str().c_str()); - unstructuredGridWriter->SetInputData(unstructuredGrid); - - ExecuteWrite( unstructuredGridWriter ); - } - } - else - { - geometry = input->GetGeometry(); - transformPointSet->SetInputData(input->GetVtkUnstructuredGrid()); - transformPointSet->SetTransform(geometry->GetVtkTransform()); - transformPointSet->UpdateWholeExtent(); - unstructuredGrid = static_cast(transformPointSet->GetOutput()); - - unstructuredGridWriter->SetFileName(m_FileName.c_str()); - unstructuredGridWriter->SetInputData(unstructuredGrid); - - ExecuteWrite( unstructuredGridWriter ); - } - transformPointSet->Delete(); - unstructuredGridWriter->Delete(); - - m_Success = true; -} - -template -void UnstructuredGridVtkWriter::ExecuteWrite( VTKWRITER* vtkWriter ) -{ - struct stat fileStatus; - time_t timeBefore=0; - if (!stat(vtkWriter->GetFileName(), &fileStatus)) - { - timeBefore = fileStatus.st_mtime; - } - if (!vtkWriter->Write()) - { - itkExceptionMacro( << "Error during unstructured grid writing."); - } - - // check if file can be written because vtkWriter doesn't check that - if (stat(vtkWriter->GetFileName(), &fileStatus) || (timeBefore == fileStatus.st_mtime)) - { - itkExceptionMacro(<<"Error during unstructured grid writing: file could not be written"); - } -} - -template -void UnstructuredGridVtkWriter::SetInput(BaseData *input) -{ - this->ProcessObject::SetNthInput(0, input); -} - -template -const UnstructuredGrid* UnstructuredGridVtkWriter::GetInput() -{ - if (this->GetNumberOfInputs() < 1) - { - return 0; - } - else - { - return dynamic_cast(this->ProcessObject::GetInput(0)); - } -} - -template -bool UnstructuredGridVtkWriter::CanWriteBaseDataType(BaseData::Pointer data) -{ - return (dynamic_cast(data.GetPointer()) != 0); -} - -template -void UnstructuredGridVtkWriter::DoWrite(BaseData::Pointer data) -{ - if (CanWriteBaseDataType(data)) - { - this->SetInput(dynamic_cast(data.GetPointer())); - this->Update(); - } -} - -template -std::vector UnstructuredGridVtkWriter::GetPossibleFileExtensions() -{ - throw std::exception(); // no specialization available! -} - -template -const char* UnstructuredGridVtkWriter::GetDefaultFilename() -{ - throw std::exception(); // no specialization available! -} - -template -const char* UnstructuredGridVtkWriter::GetFileDialogPattern() -{ - throw std::exception(); // no specialization available! -} - -template -const char* UnstructuredGridVtkWriter::GetDefaultExtension() -{ - throw std::exception(); // no specialization available! -} - -} - -#endif diff --git a/Modules/Ext/IO/mitkUnstructuredGridVtkWriterFactory.cpp b/Modules/Ext/IO/mitkUnstructuredGridVtkWriterFactory.cpp deleted file mode 100644 index 2f24d71402..0000000000 --- a/Modules/Ext/IO/mitkUnstructuredGridVtkWriterFactory.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkUnstructuredGridVtkWriterFactory.h" - -#include "itkCreateObjectFunction.h" -#include "itkVersion.h" - -#include - -#include -#include -#include - -namespace mitk -{ - -template -class CreateUnstructuredGridWriter : public itk::CreateObjectFunctionBase -{ -public: - - /** Standard class typedefs. */ - typedef CreateUnstructuredGridWriter Self; - typedef itk::SmartPointer Pointer; - - /** Methods from itk:LightObject. */ - itkFactorylessNewMacro(Self); - LightObject::Pointer CreateObject() { typename T::Pointer p = T::New(); - p->Register(); - return p.GetPointer(); - } - -protected: - CreateUnstructuredGridWriter() {} - ~CreateUnstructuredGridWriter() {} - -private: - CreateUnstructuredGridWriter(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented -}; - -UnstructuredGridVtkWriterFactory::UnstructuredGridVtkWriterFactory() -{ - this->RegisterOverride("IOWriter", - "UnstructuredGridVtkWriter", - "VTK Legacy Unstructured Grid Writer", - 1, - mitk::CreateUnstructuredGridWriter< mitk::UnstructuredGridVtkWriter >::New()); - - this->RegisterOverride("IOWriter", - "UnstructuredGridVtkWriter", - "VTK XML UnstructuredGrid Writer", - 1, - mitk::CreateUnstructuredGridWriter< mitk::UnstructuredGridVtkWriter >::New()); - - this->RegisterOverride("IOWriter", - "UnstructuredGridVtkWriter", - "VTK Parallel XML UnstructuredGrid Writer", - 1, - mitk::CreateUnstructuredGridWriter< mitk::UnstructuredGridVtkWriter >::New()); -} - -UnstructuredGridVtkWriterFactory::~UnstructuredGridVtkWriterFactory() -{ -} - -const char* UnstructuredGridVtkWriterFactory::GetITKSourceVersion() const -{ - return ITK_SOURCE_VERSION; -} - -const char* UnstructuredGridVtkWriterFactory::GetDescription() const -{ - return "UnstructuredGridVtkWriterFactory"; -} - -} // end namespace mitk diff --git a/Modules/Ext/IO/mitkUnstructuredGridVtkWriterFactory.h b/Modules/Ext/IO/mitkUnstructuredGridVtkWriterFactory.h deleted file mode 100644 index 1319b7f9d9..0000000000 --- a/Modules/Ext/IO/mitkUnstructuredGridVtkWriterFactory.h +++ /dev/null @@ -1,70 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef UNSTRUCTURED_GRID_WRITERFACTORY_H_HEADER_INCLUDED -#define UNSTRUCTURED_GRID_WRITERFACTORY_H_HEADER_INCLUDED - -#include "itkObjectFactoryBase.h" -#include "MitkExtExports.h" -#include "mitkBaseData.h" - -namespace mitk -{ - -class MitkExt_EXPORT UnstructuredGridVtkWriterFactory : public itk::ObjectFactoryBase -{ -public: - - mitkClassMacro( mitk::UnstructuredGridVtkWriterFactory, itk::ObjectFactoryBase ) - - /** Class methods used to interface with the registered factories. */ - virtual const char* GetITKSourceVersion(void) const; - virtual const char* GetDescription(void) const; - - /** Method for class instantiation. */ - itkFactorylessNewMacro(Self); - - /** - * Register one factory of this type - * \deprecatedSince{2013_09} - */ - DEPRECATED(static void RegisterOneFactory(void)) - { - static bool IsRegistered = false; - if ( !IsRegistered ) - { - UnstructuredGridVtkWriterFactory::Pointer ugVtkWriterFactory = UnstructuredGridVtkWriterFactory::New(); - ObjectFactoryBase::RegisterFactory( ugVtkWriterFactory ); - IsRegistered = true; - } - } - -protected: - UnstructuredGridVtkWriterFactory(); - ~UnstructuredGridVtkWriterFactory(); - -private: - UnstructuredGridVtkWriterFactory(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - -}; - -} // end namespace mitk - -#endif // UNSTRUCTURED_GRID_WRITERFACTORY_H_HEADER_INCLUDED - - - diff --git a/Modules/Ext/IO/mitkVtkUnstructuredGridIOFactory.cpp b/Modules/Ext/IO/mitkVtkUnstructuredGridIOFactory.cpp deleted file mode 100644 index 89382e368e..0000000000 --- a/Modules/Ext/IO/mitkVtkUnstructuredGridIOFactory.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkVtkUnstructuredGridIOFactory.h" -#include "mitkIOAdapter.h" -#include "mitkVtkUnstructuredGridReader.h" - -#include "itkVersion.h" - - -namespace mitk -{ -VtkUnstructuredGridIOFactory::VtkUnstructuredGridIOFactory() -{ - this->RegisterOverride("mitkIOAdapter", - "mitkVtkUnstructuredGridReader", - "mitk Vtk UnstructuredGrid IO", - 1, - itk::CreateObjectFunction >::New()); -} - -VtkUnstructuredGridIOFactory::~VtkUnstructuredGridIOFactory() -{ -} - -const char* VtkUnstructuredGridIOFactory::GetITKSourceVersion() const -{ - return ITK_SOURCE_VERSION; -} - -const char* VtkUnstructuredGridIOFactory::GetDescription() const -{ - return "VtkUnstructuredGrid IO Factory, allows the loading of Vtk files containing unstructured grid data"; -} - -} // end namespace mitk diff --git a/Modules/Ext/IO/mitkVtkUnstructuredGridIOFactory.h b/Modules/Ext/IO/mitkVtkUnstructuredGridIOFactory.h deleted file mode 100644 index 92ae0e0cbe..0000000000 --- a/Modules/Ext/IO/mitkVtkUnstructuredGridIOFactory.h +++ /dev/null @@ -1,75 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#ifndef __MITK_VTK_UNSTRUCTURED_GRID_IO_FACTORY_H_HEADER__ -#define __MITK_VTK_UNSTRUCTURED_GRID_IO_FACTORY_H_HEADER__ - -#ifdef _MSC_VER -#pragma warning ( disable : 4786 ) -#endif - -#include "itkObjectFactoryBase.h" -#include "MitkExtExports.h" -#include "mitkBaseData.h" - -namespace mitk -{ -//##Documentation -//## @brief Create instances of VtkUnstructuredGridReader objects using an object factory. -//## -//## @ingroup IO -class MitkExt_EXPORT VtkUnstructuredGridIOFactory : public itk::ObjectFactoryBase -{ -public: - /** Standard class typedefs. */ - typedef VtkUnstructuredGridIOFactory Self; - typedef itk::ObjectFactoryBase Superclass; - typedef itk::SmartPointer Pointer; - typedef itk::SmartPointer ConstPointer; - - /** Class methods used to interface with the registered factories. */ - virtual const char* GetITKSourceVersion(void) const; - virtual const char* GetDescription(void) const; - - /** Method for class instantiation. */ - itkFactorylessNewMacro(Self); - static VtkUnstructuredGridIOFactory* FactoryNew() { return new VtkUnstructuredGridIOFactory;} - /** Run-time type information (and related methods). */ - itkTypeMacro(VtkUnstructuredGridIOFactory, ObjectFactoryBase); - - /** - * Register one factory of this type - * \deprecatedSince{2013_09} - */ - DEPRECATED(static void RegisterOneFactory(void)) - { - VtkUnstructuredGridIOFactory::Pointer VtkUnstructuredGridIOFactory = VtkUnstructuredGridIOFactory::New(); - ObjectFactoryBase::RegisterFactory(VtkUnstructuredGridIOFactory); - } - -protected: - VtkUnstructuredGridIOFactory(); - ~VtkUnstructuredGridIOFactory(); - -private: - VtkUnstructuredGridIOFactory(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - -}; - - -} // end namespace mitk - -#endif // __MITK_VTK_UNSTRUCTURED_GRID_IO_FACTORY_H_HEADER__ diff --git a/Modules/Ext/IO/mitkVtkUnstructuredGridReader.cpp b/Modules/Ext/IO/mitkVtkUnstructuredGridReader.cpp deleted file mode 100644 index ad44d57d63..0000000000 --- a/Modules/Ext/IO/mitkVtkUnstructuredGridReader.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#include "mitkVtkUnstructuredGridReader.h" -#include -#include -#include -#include - -#include - - -mitk::VtkUnstructuredGridReader::VtkUnstructuredGridReader() -: m_FileName("") -{ -} - -mitk::VtkUnstructuredGridReader::~VtkUnstructuredGridReader() -{ -} - -void mitk::VtkUnstructuredGridReader::GenerateData() -{ - if( m_FileName != "") - { - bool success = false; - MITK_INFO << "Loading " << m_FileName << " as vtk unstructured grid" << std::endl; - - std::string ext = itksys::SystemTools::GetFilenameLastExtension(m_FileName); - ext = itksys::SystemTools::LowerCase(ext); - if (ext == ".vtk") - { - ///We create a Generic Reader to test de .vtk/ - vtkDataReader *chooser=vtkDataReader::New(); - chooser->SetFileName(m_FileName.c_str() ); - if( chooser->IsFileUnstructuredGrid()) - { - ///UnstructuredGrid/ - itkDebugMacro( << "UnstructuredGrid" ); - vtkUnstructuredGridReader *reader = vtkUnstructuredGridReader::New(); - reader->SetFileName( m_FileName.c_str() ); - reader->Update(); - - if ( reader->GetOutput() != NULL ) - { - mitk::UnstructuredGrid::Pointer output = this->GetOutput(); - output->SetVtkUnstructuredGrid( reader->GetOutput() ); - success = true; - } - reader->Delete(); - } - } - else if (ext == ".vtu") - { - vtkXMLUnstructuredGridReader *reader=vtkXMLUnstructuredGridReader::New(); - if( reader->CanReadFile(m_FileName.c_str()) ) - { - ///UnstructuredGrid/ - itkDebugMacro( << "XMLUnstructuredGrid" ); - reader->SetFileName( m_FileName.c_str() ); - reader->Update(); - - if ( reader->GetOutput() != NULL ) - { - mitk::UnstructuredGrid::Pointer output = this->GetOutput(); - output->SetVtkUnstructuredGrid( reader->GetOutput() ); - success = true; - } - reader->Delete(); - } - } - if(!success) - { - itkExceptionMacro( << " ... sorry, this .vtk format is not supported yet." ); - } - } -} - -bool mitk::VtkUnstructuredGridReader::CanReadFile(const std::string filename, const std::string /*filePrefix*/, const std::string /*filePattern*/) -{ - // First check the extension - if( filename == "" ) - return false; - - std::string ext = itksys::SystemTools::GetFilenameLastExtension(filename); - ext = itksys::SystemTools::LowerCase(ext); - if (ext == ".vtk") - { - vtkDataReader *chooser=vtkDataReader::New(); - chooser->SetFileName(filename.c_str() ); - if(!chooser->IsFileUnstructuredGrid()) - { - chooser->Delete(); - return false; - } - } - else if (ext == ".vtu") - { - vtkXMLUnstructuredGridReader *chooser=vtkXMLUnstructuredGridReader::New(); - if(!chooser->CanReadFile(filename.c_str())) - { - chooser->Delete(); - return false; - } - } - else - return false; - - return true; -} diff --git a/Modules/Ext/IO/mitkVtkUnstructuredGridReader.h b/Modules/Ext/IO/mitkVtkUnstructuredGridReader.h deleted file mode 100644 index 9db5b40c5a..0000000000 --- a/Modules/Ext/IO/mitkVtkUnstructuredGridReader.h +++ /dev/null @@ -1,60 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#ifndef VtkUnstructuredGridReader_H_HEADER_INCLUDED -#define VtkUnstructuredGridReader_H_HEADER_INCLUDED - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkUnstructuredGridSource.h" - -namespace mitk { -//##Documentation -//## @brief Reader to read unstructured grid files in vtk-format -//## @ingroup IO -class MitkExt_EXPORT VtkUnstructuredGridReader : public UnstructuredGridSource -{ -public: - mitkClassMacro(VtkUnstructuredGridReader, UnstructuredGridSource); - - /** Method for creation through the object factory. */ - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - itkSetStringMacro(FileName); - itkGetStringMacro(FileName); - - itkSetStringMacro(FilePrefix); - itkGetStringMacro(FilePrefix); - - itkSetStringMacro(FilePattern); - itkGetStringMacro(FilePattern); - - static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern); - -protected: - virtual void GenerateData(); - - VtkUnstructuredGridReader(); - - ~VtkUnstructuredGridReader(); - - std::string m_FileName, m_FilePrefix, m_FilePattern; - -}; - -} // namespace mitk - -#endif /* VtkUnstructuredGridReader_H_HEADER_INCLUDED */ diff --git a/Modules/Ext/IO/mitkVtkVolumeTimeSeriesIOFactory.cpp b/Modules/Ext/IO/mitkVtkVolumeTimeSeriesIOFactory.cpp deleted file mode 100644 index ca921fc2b9..0000000000 --- a/Modules/Ext/IO/mitkVtkVolumeTimeSeriesIOFactory.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkVtkVolumeTimeSeriesIOFactory.h" -#include "mitkIOAdapter.h" -#include "mitkVtkVolumeTimeSeriesReader.h" - -#include "itkVersion.h" - - -namespace mitk -{ -VtkVolumeTimeSeriesIOFactory::VtkVolumeTimeSeriesIOFactory() -{ - this->RegisterOverride("mitkIOAdapter", - "mitkVtkVolumeTimeSeriesReader", - "mitk Vtk Surface IO", - 1, - itk::CreateObjectFunction >::New()); -} - -VtkVolumeTimeSeriesIOFactory::~VtkVolumeTimeSeriesIOFactory() -{ -} - -const char* VtkVolumeTimeSeriesIOFactory::GetITKSourceVersion() const -{ - return ITK_SOURCE_VERSION; -} - -const char* VtkVolumeTimeSeriesIOFactory::GetDescription() const -{ - return "VtkVolumeTimeSeries IO Factory, allows the loading of Vtk surfaces"; -} - -} // end namespace mitk diff --git a/Modules/Ext/IO/mitkVtkVolumeTimeSeriesIOFactory.h b/Modules/Ext/IO/mitkVtkVolumeTimeSeriesIOFactory.h deleted file mode 100644 index 49c2b60412..0000000000 --- a/Modules/Ext/IO/mitkVtkVolumeTimeSeriesIOFactory.h +++ /dev/null @@ -1,75 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#ifndef __mitkVtkVolumeTimeSeriesIOFactory_h -#define __mitkVtkVolumeTimeSeriesIOFactory_h - -#ifdef _MSC_VER -#pragma warning ( disable : 4786 ) -#endif - -#include "itkObjectFactoryBase.h" -#include "MitkExtExports.h" -#include "mitkBaseData.h" - -namespace mitk -{ -//##Documentation -//## @brief Create instances of VtkVolumeTimeSeriesReader objects using an object factory. -//## -//## @ingroup IO -class MitkExt_EXPORT VtkVolumeTimeSeriesIOFactory : public itk::ObjectFactoryBase -{ -public: - /** Standard class typedefs. */ - typedef VtkVolumeTimeSeriesIOFactory Self; - typedef itk::ObjectFactoryBase Superclass; - typedef itk::SmartPointer Pointer; - typedef itk::SmartPointer ConstPointer; - - /** Class methods used to interface with the registered factories. */ - virtual const char* GetITKSourceVersion(void) const; - virtual const char* GetDescription(void) const; - - /** Method for class instantiation. */ - itkFactorylessNewMacro(Self); - static VtkVolumeTimeSeriesIOFactory* FactoryNew() { return new VtkVolumeTimeSeriesIOFactory;} - /** Run-time type information (and related methods). */ - itkTypeMacro(VtkVolumeTimeSeriesIOFactory, ObjectFactoryBase); - - /** - * Register one factory of this type - * \deprecatedSince{2013_09} - */ - DEPRECATED(static void RegisterOneFactory(void)) - { - VtkVolumeTimeSeriesIOFactory::Pointer VtkVolumeTimeSeriesIOFactory = VtkVolumeTimeSeriesIOFactory::New(); - ObjectFactoryBase::RegisterFactory(VtkVolumeTimeSeriesIOFactory); - } - -protected: - VtkVolumeTimeSeriesIOFactory(); - ~VtkVolumeTimeSeriesIOFactory(); - -private: - VtkVolumeTimeSeriesIOFactory(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - -}; - - -} // end namespace mitk - -#endif diff --git a/Modules/Ext/IO/mitkVtkVolumeTimeSeriesReader.cpp b/Modules/Ext/IO/mitkVtkVolumeTimeSeriesReader.cpp deleted file mode 100644 index 23c386cb4f..0000000000 --- a/Modules/Ext/IO/mitkVtkVolumeTimeSeriesReader.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkVtkVolumeTimeSeriesReader.h" -#include "mitkVtkSurfaceReader.h" -#include "mitkSurface.h" -#include "vtkPolyData.h" - -void mitk::VtkVolumeTimeSeriesReader::GenerateData() -{ - if ( !this->GenerateFileList() ) - { - itkWarningMacro( << "Sorry, file list could not be determined..." ); - return ; - } - - mitk::Surface::Pointer output = this->GetOutput(); - MITK_INFO << "prefix: "<< m_FilePrefix << ", pattern: " <Expand(m_MatchedFileNames.size()); - for ( unsigned int i = 0 ; i < m_MatchedFileNames.size(); ++i ) - { - std::string fileName = m_MatchedFileNames[i]; - MITK_INFO << "Loading " << fileName << " as vtk..." << std::endl; - - VtkSurfaceReader::Pointer vtkReader = VtkSurfaceReader::New(); - vtkReader->SetFileName( fileName.c_str() ); - vtkReader->Update(); - - if ( vtkReader->GetOutput() != NULL ) - { - output->SetVtkPolyData( vtkReader->GetOutput()->GetVtkPolyData(), i ); - } - else - { - itkWarningMacro(<< "vtkPolyDataReader returned NULL while reading " << fileName << ". Trying to continue with empty vtkPolyData..."); - output->SetVtkPolyData( vtkPolyData::New(), i ); - } - } -} - -bool mitk::VtkVolumeTimeSeriesReader::CanReadFile(const std::string /*filename*/, const std::string filePrefix, const std::string filePattern) -{ - if( filePattern != "" && filePrefix != "" ) - return false; - - bool extensionFound = false; - std::string::size_type VTKPos = filePattern.rfind(".vtk"); - if ((VTKPos != std::string::npos) && (VTKPos == filePattern.length() - 4)) - extensionFound = true; - - VTKPos = filePattern.rfind(".VTK"); - if ((VTKPos != std::string::npos) && (VTKPos == filePattern.length() - 4)) - extensionFound = true; - - if( !extensionFound ) - return false; - - return true; -} - -mitk::VtkVolumeTimeSeriesReader::VtkVolumeTimeSeriesReader() -{} - -mitk::VtkVolumeTimeSeriesReader::~VtkVolumeTimeSeriesReader() -{} diff --git a/Modules/Ext/IO/mitkVtkVolumeTimeSeriesReader.h b/Modules/Ext/IO/mitkVtkVolumeTimeSeriesReader.h deleted file mode 100644 index 3e1e4b906d..0000000000 --- a/Modules/Ext/IO/mitkVtkVolumeTimeSeriesReader.h +++ /dev/null @@ -1,68 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef _Vtk_VOLUME_TIME_SERIES_READER__H_ -#define _Vtk_VOLUME_TIME_SERIES_READER__H_ - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkFileSeriesReader.h" -#include "mitkSurfaceSource.h" - -namespace mitk -{ -//##Documentation -//## @brief Reader to read a series of volume files in Vtk-format -//## @ingroup IO -class MitkExt_EXPORT VtkVolumeTimeSeriesReader : public SurfaceSource, public FileSeriesReader -{ -public: - mitkClassMacro( VtkVolumeTimeSeriesReader, FileReader ); - - /** Method for creation through the object factory. */ - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - itkSetStringMacro(FileName); - itkGetStringMacro(FileName); - - itkSetStringMacro(FilePrefix); - itkGetStringMacro(FilePrefix); - - itkSetStringMacro(FilePattern); - itkGetStringMacro(FilePattern); - - static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern); - -protected: - virtual void GenerateData(); - - VtkVolumeTimeSeriesReader(); - - ~VtkVolumeTimeSeriesReader(); - - //##Description - //## @brief Time when Header was last read - itk::TimeStamp m_ReadHeaderTime; - -}; - -} // namespace mitk - -#endif - - diff --git a/Modules/Ext/Interactions/StateMachines.zip b/Modules/Ext/Interactions/StateMachines.zip deleted file mode 100644 index b72378a5a9..0000000000 Binary files a/Modules/Ext/Interactions/StateMachines.zip and /dev/null differ diff --git a/Modules/Ext/Interactions/debug_protocoll.pdf b/Modules/Ext/Interactions/debug_protocoll.pdf deleted file mode 100644 index 02c5e3aba4..0000000000 Binary files a/Modules/Ext/Interactions/debug_protocoll.pdf and /dev/null differ diff --git a/Modules/Ext/Interactions/mitkAffineInteractor3D.cpp b/Modules/Ext/Interactions/mitkAffineInteractor3D.cpp deleted file mode 100644 index 0c0f25130e..0000000000 --- a/Modules/Ext/Interactions/mitkAffineInteractor3D.cpp +++ /dev/null @@ -1,489 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkAffineInteractor3D.h" -#include "mitkPointOperation.h" -#include "mitkPositionEvent.h" -#include "mitkStatusBar.h" -#include "mitkDataNode.h" -#include "mitkInteractionConst.h" -#include "mitkAction.h" -#include "mitkStateEvent.h" -#include "mitkOperationEvent.h" -#include "mitkUndoController.h" -#include "mitkStateMachineFactory.h" -#include "mitkStateTransitionOperation.h" -#include "mitkBaseRenderer.h" -#include "mitkRenderingManager.h" -#include "mitkRotationOperation.h" - -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace mitk -{ - -//how precise must the user pick the point -//default value -AffineInteractor3D -::AffineInteractor3D(const char * type, DataNode* dataNode, int /* n */ ) -: Interactor( type, dataNode ), - m_Precision( 6.5 ), - m_InteractionMode( INTERACTION_MODE_TRANSLATION ) -{ - Geometry3D::Pointer geo3D = Geometry3D::New(); - m_OriginalGeometry = dynamic_cast(geo3D.GetPointer()); - - // Initialize vector arithmetic - m_ObjectNormal[0] = 0.0; - m_ObjectNormal[1] = 0.0; - m_ObjectNormal[2] = 1.0; -} - - -AffineInteractor3D::~AffineInteractor3D() -{ -} - - -void AffineInteractor3D::SetInteractionMode( unsigned int interactionMode ) -{ - m_InteractionMode = interactionMode; -} - - -void AffineInteractor3D::SetInteractionModeToTranslation() -{ - m_InteractionMode = INTERACTION_MODE_TRANSLATION; -} - - -void AffineInteractor3D::SetInteractionModeToRotation() -{ - m_InteractionMode = INTERACTION_MODE_ROTATION; -} - - -unsigned int AffineInteractor3D::GetInteractionMode() const -{ - return m_InteractionMode; -} - - -void AffineInteractor3D::SetPrecision( ScalarType precision ) -{ - m_Precision = precision; -} - -// Overwritten since this class can handle it better! -float AffineInteractor3D -::CanHandleEvent(StateEvent const* stateEvent) const -{ - float returnValue = 0.5; - - - // If it is a key event that can be handled in the current state, - // then return 0.5 - DisplayPositionEvent const *disPosEvent = - dynamic_cast (stateEvent->GetEvent()); - - // Key event handling: - if (disPosEvent == NULL) - { - // Check if the current state has a transition waiting for that key event. - if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) - { - return 0.5; - } - else - { - return 0.0; - } - } - - //on MouseMove do nothing! - //if (stateEvent->GetEvent()->GetType() == Type_MouseMove) - //{ - // return 0.0; - //} - - //if the event can be understood and if there is a transition waiting for that event - if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) - { - returnValue = 0.5;//it can be understood - } - - //int timeStep = disPosEvent->GetSender()->GetTimeStep(); - - //CurveModel *curveModel = dynamic_cast( - // m_DataNode->GetData() ); - - //if ( curveModel != NULL ) - //{ - // // Get the PlaneGeometry of the window the user interacts with (for 2D point - // // projection) - // BaseRenderer *renderer = stateEvent->GetEvent()->GetSender(); - // const PlaneGeometry *projectionPlane = renderer->GetCurrentWorldPlaneGeometry(); - - // // For reading on the points, Ids etc - // //CurveModel::PointSetType *pointSet = curveModel->GetPointSet( timeStep ); - // //if ( pointSet == NULL ) - // //{ - // // return 0.0; - // //} - - //} - return returnValue; -} - - -bool AffineInteractor3D -::ExecuteAction( Action *action, StateEvent const *stateEvent ) -{ - bool ok = false; - - // Get data object - BaseData *data = m_DataNode->GetData(); - if ( data == NULL ) - { - MITK_ERROR << "No data object present!"; - return ok; - } - - // Get Event and extract renderer - const Event *event = stateEvent->GetEvent(); - BaseRenderer *renderer = NULL; - vtkRenderWindow *renderWindow = NULL; - vtkRenderWindowInteractor *renderWindowInteractor = NULL; - vtkRenderer *currentVtkRenderer = NULL; - vtkCamera *camera = NULL; - - if ( event != NULL ) - { - renderer = event->GetSender(); - if ( renderer != NULL ) - { - renderWindow = renderer->GetRenderWindow(); - if ( renderWindow != NULL ) - { - renderWindowInteractor = renderWindow->GetInteractor(); - if ( renderWindowInteractor != NULL ) - { - currentVtkRenderer = renderWindowInteractor - ->GetInteractorStyle()->GetCurrentRenderer(); - if ( currentVtkRenderer != NULL ) - { - camera = currentVtkRenderer->GetActiveCamera(); - } - } - } - } - } - - // Check if we have a DisplayPositionEvent - const DisplayPositionEvent *dpe = - dynamic_cast< const DisplayPositionEvent * >( stateEvent->GetEvent() ); - if ( dpe != NULL ) - { - m_CurrentPickedPoint = dpe->GetWorldPosition(); - m_CurrentPickedDisplayPoint = dpe->GetDisplayPosition(); - } - - // Get the timestep to also support 3D+t - int timeStep = 0; - ScalarType timeInMS = 0.0; - if ( renderer != NULL ) - { - timeStep = renderer->GetTimeStep( data ); - timeInMS = renderer->GetTime(); - } - - // If data is an mitk::Surface, extract it - Surface *surface = dynamic_cast< Surface * >( data ); - vtkPolyData *polyData = NULL; - if ( surface != NULL ) - { - polyData = surface->GetVtkPolyData( timeStep ); - - // Extract surface normal from surface (if existent, otherwise use default) - vtkPointData *pointData = polyData->GetPointData(); - if ( pointData != NULL ) - { - vtkDataArray *normal = polyData->GetPointData()->GetVectors( "planeNormal" ); - if ( normal != NULL ) - { - m_ObjectNormal[0] = normal->GetComponent( 0, 0 ); - m_ObjectNormal[1] = normal->GetComponent( 0, 1 ); - m_ObjectNormal[2] = normal->GetComponent( 0, 2 ); - } - } - } - - // Get geometry object - m_Geometry = data->GetGeometry( timeStep ); - - - // Make sure that the data (if time-resolved) has enough entries; - // if not, create the required extra ones (empty) - data->Expand( timeStep+1 ); - - - switch (action->GetActionId()) - { - case AcDONOTHING: - ok = true; - break; - - - case AcCHECKOBJECT: - { - // Re-enable VTK interactor (may have been disabled previously) - if ( renderWindowInteractor != NULL ) - { - renderWindowInteractor->Enable(); - } - - // Check if we have a DisplayPositionEvent - const DisplayPositionEvent *dpe = - dynamic_cast< const DisplayPositionEvent * >( stateEvent->GetEvent() ); - if ( dpe == NULL ) - { - ok = true; - break; - } - - // Check if an object is present at the current mouse position - DataNode *pickedNode = dpe->GetPickedObjectNode(); - StateEvent *newStateEvent; - if ( pickedNode == m_DataNode ) - { - // Yes: object will be selected - newStateEvent = new StateEvent( EIDYES ); - } - else - { - // No: back to start state - newStateEvent = new StateEvent( EIDNO ); - } - - this->HandleEvent( newStateEvent ); - - ok = true; - break; - } - - case AcDESELECTOBJECT: - { - // Color object white - m_DataNode->SetColor( 1.0, 1.0, 1.0 ); - RenderingManager::GetInstance()->RequestUpdateAll(); - - // Colorize surface / wireframe as inactive - this->ColorizeSurface( polyData, - m_CurrentPickedPoint, -1.0 ); - - ok = true; - break; - } - - case AcSELECTPICKEDOBJECT: - { - // Color object red - m_DataNode->SetColor( 1.0, 0.0, 0.0 ); - RenderingManager::GetInstance()->RequestUpdateAll(); - - // Colorize surface / wireframe dependend on distance from picked point - this->ColorizeSurface( polyData, - m_CurrentPickedPoint, 0.0 ); - - ok = true; - break; - } - - case AcINITMOVE: - { - // Disable VTK interactor until MITK interaction has been completed - if ( renderWindowInteractor != NULL ) - { - renderWindowInteractor->Disable(); - } - - // Check if we have a DisplayPositionEvent - const DisplayPositionEvent *dpe = - dynamic_cast< const DisplayPositionEvent * >( stateEvent->GetEvent() ); - if ( dpe == NULL ) - { - ok = true; - break; - } - - //DataNode *pickedNode = dpe->GetPickedObjectNode(); - - m_InitialPickedPoint = m_CurrentPickedPoint; - m_InitialPickedDisplayPoint = m_CurrentPickedDisplayPoint; - - if ( currentVtkRenderer != NULL ) - { - vtkInteractorObserver::ComputeDisplayToWorld( - currentVtkRenderer, - m_InitialPickedDisplayPoint[0], - m_InitialPickedDisplayPoint[1], - 0.0, //m_InitialInteractionPickedPoint[2], - m_InitialPickedPointWorld ); - } - - - // Make deep copy of current Geometry3D of the plane - data->UpdateOutputInformation(); // make sure that the Geometry is up-to-date - m_OriginalGeometry = static_cast< BaseGeometry * >( - data->GetGeometry( timeStep )->Clone().GetPointer() ); - - ok = true; - break; - } - - case AcMOVE: - { - // Check if we have a DisplayPositionEvent - const DisplayPositionEvent *dpe = - dynamic_cast< const DisplayPositionEvent * >( stateEvent->GetEvent() ); - if ( dpe == NULL ) - { - ok = true; - break; - } - - if ( currentVtkRenderer != NULL ) - { - vtkInteractorObserver::ComputeDisplayToWorld( - currentVtkRenderer, - m_CurrentPickedDisplayPoint[0], - m_CurrentPickedDisplayPoint[1], - 0.0, //m_InitialInteractionPickedPoint[2], - m_CurrentPickedPointWorld ); - } - - - Vector3D interactionMove; - interactionMove[0] = m_CurrentPickedPointWorld[0] - m_InitialPickedPointWorld[0]; - interactionMove[1] = m_CurrentPickedPointWorld[1] - m_InitialPickedPointWorld[1]; - interactionMove[2] = m_CurrentPickedPointWorld[2] - m_InitialPickedPointWorld[2]; - - if ( m_InteractionMode == INTERACTION_MODE_TRANSLATION ) - { - Point3D origin = m_OriginalGeometry->GetOrigin(); - - Vector3D transformedObjectNormal; - data->GetGeometry( timeStep )->IndexToWorld( - m_ObjectNormal, transformedObjectNormal ); - - data->GetGeometry( timeStep )->SetOrigin( - origin + transformedObjectNormal * (interactionMove * transformedObjectNormal) ); - } - else if ( m_InteractionMode == INTERACTION_MODE_ROTATION ) - { - if ( camera ) - { - double vpn[3]; - camera->GetViewPlaneNormal( vpn ); - - Vector3D viewPlaneNormal; - viewPlaneNormal[0] = vpn[0]; - viewPlaneNormal[1] = vpn[1]; - viewPlaneNormal[2] = vpn[2]; - - Vector3D rotationAxis = - itk::CrossProduct( viewPlaneNormal, interactionMove ); - rotationAxis.Normalize(); - - int *size = currentVtkRenderer->GetSize(); - double l2 = - (m_CurrentPickedDisplayPoint[0] - m_InitialPickedDisplayPoint[0]) * - (m_CurrentPickedDisplayPoint[0] - m_InitialPickedDisplayPoint[0]) + - (m_CurrentPickedDisplayPoint[1] - m_InitialPickedDisplayPoint[1]) * - (m_CurrentPickedDisplayPoint[1] - m_InitialPickedDisplayPoint[1]); - - double rotationAngle = 360.0 * sqrt(l2/(size[0]*size[0]+size[1]*size[1])); - - // Use center of data bounding box as center of rotation - Point3D rotationCenter = m_OriginalGeometry->GetCenter();; - - // Reset current Geometry3D to original state (pre-interaction) and - // apply rotation - RotationOperation op( OpROTATE, rotationCenter, rotationAxis, rotationAngle ); - BaseGeometry::Pointer newGeometry = static_cast< BaseGeometry * >( - m_OriginalGeometry->Clone().GetPointer() ); - newGeometry->ExecuteOperation( &op ); - data->SetClonedGeometry(newGeometry, timeStep); - } - } - - RenderingManager::GetInstance()->RequestUpdateAll(); - ok = true; - break; - } - - - - default: - return Superclass::ExecuteAction( action, stateEvent ); - } - - return ok; -} - -bool AffineInteractor3D::ColorizeSurface( vtkPolyData *polyData, - const Point3D & /*pickedPoint*/, double scalar ) -{ - if ( polyData == NULL ) - { - return false; - } - - //vtkPoints *points = polyData->GetPoints(); - vtkPointData *pointData = polyData->GetPointData(); - if ( pointData == NULL ) - { - return false; - } - - vtkDataArray *scalars = pointData->GetScalars(); - if ( scalars == NULL ) - { - return false; - } - - for ( unsigned int i = 0; i < pointData->GetNumberOfTuples(); ++i ) - { - scalars->SetComponent( i, 0, scalar ); - } - - polyData->Modified(); - pointData->Update(); - - return true; -} - - -} // namespace diff --git a/Modules/Ext/Interactions/mitkAffineInteractor3D.h b/Modules/Ext/Interactions/mitkAffineInteractor3D.h deleted file mode 100644 index 58b5b317a6..0000000000 --- a/Modules/Ext/Interactions/mitkAffineInteractor3D.h +++ /dev/null @@ -1,117 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKAFFINEINTERACTOR3D_H_HEADER_INCLUDED -#define MITKAFFINEINTERACTOR3D_H_HEADER_INCLUDED - -#include "mitkInteractor.h" -#include "MitkExtExports.h" -#include "mitkCommon.h" -#include "mitkSurface.h" - -#include -#include - -namespace mitk -{ - -class DataNode; - -/** - * \brief Affine interaction with objects in 3D windows. - * - * NOTE: The interaction mechanism is similar to that of vtkPlaneWidget - * - * \ingroup Interaction - * \deprecatedSince{2013_12} mitk::AffineInteractor is deprecated. Use mitk::AffineDataInteractor instead. - - */ -class MitkExt_EXPORT AffineInteractor3D : public Interactor -{ -public: - enum { INTERACTION_MODE_TRANSLATION, INTERACTION_MODE_ROTATION }; - - mitkClassMacro(AffineInteractor3D, Interactor); - mitkNewMacro3Param(Self, const char *, DataNode *, int); - mitkNewMacro2Param(Self, const char *, DataNode *); - - - void SetInteractionMode( unsigned int interactionMode ); - void SetInteractionModeToTranslation(); - void SetInteractionModeToRotation(); - unsigned int GetInteractionMode() const; - - /** \brief Sets the amount of precision */ - void SetPrecision( ScalarType precision ); - - /** - * \brief calculates how good the data, this statemachine handles, is hit - * by the event. - * - * overwritten, cause we don't look at the boundingbox, we look at each point - */ - virtual float CanHandleEvent(StateEvent const *stateEvent) const; - - -protected: - /** - * \brief Constructor with Param n for limited Set of Points - * - * if no n is set, then the number of points is unlimited* - */ - DEPRECATED(AffineInteractor3D(const char *type, - DataNode *dataNode, int n = -1)); - - /** - * \brief Default Destructor - **/ - virtual ~AffineInteractor3D(); - - virtual bool ExecuteAction( Action* action, - mitk::StateEvent const* stateEvent ); - - bool ColorizeSurface( vtkPolyData *polyData, const Point3D &pickedPoint, - double scalar = 0.0 ); - - -private: - - /** \brief to store the value of precision to pick a point */ - ScalarType m_Precision; - - bool m_InteractionMode; - - Point3D m_InitialPickedPoint; - Point2D m_InitialPickedDisplayPoint; - double m_InitialPickedPointWorld[4]; - - Point3D m_CurrentPickedPoint; - Point2D m_CurrentPickedDisplayPoint; - double m_CurrentPickedPointWorld[4]; - - BaseGeometry::Pointer m_Geometry; - - BaseGeometry::Pointer m_OriginalGeometry; - - Vector3D m_ObjectNormal; - -}; - - -} - -#endif /* MITKAFFINEINTERACTOR3D_H_HEADER_INCLUDED */ diff --git a/Modules/Ext/Interactions/mitkConferenceEventMapper.cpp b/Modules/Ext/Interactions/mitkConferenceEventMapper.cpp deleted file mode 100644 index 184812dec7..0000000000 --- a/Modules/Ext/Interactions/mitkConferenceEventMapper.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include -#include -#include -#include -#include -#include - - -mitk::ConferenceEventMapper::ConferenceEventMapper(){} - -mitk::ConferenceEventMapper::~ConferenceEventMapper(){} - -//CONFERENCE USE -bool -mitk::ConferenceEventMapper::MapEvent(signed int mitkEventID, const char* sender, int Etype, int Estate, int Ebuttonstate, int Ekey, float w1,float w2,float w3,float p1,float p2) -{ - - //CONFERENCE EVENT - mitk::BaseRenderer *br = const_cast(mitk::BaseRenderer::GetByName( std::string(sender) )); - - mitk::Point3D p3d; - p3d[0] = (mitk::ScalarType) w1; - p3d[1] = (mitk::ScalarType) w2; - p3d[2] = (mitk::ScalarType) w3; - - // fit relative values to absolut.... - mitk::Point2D p2d; - p2d[0] = (mitk::ScalarType) p1 * br->GetSizeX(); - p2d[1] = (mitk::ScalarType) p2 * br->GetSizeX(); - - - mitk::PositionEvent *pe = new mitk::PositionEvent(br,Etype,Estate,Ebuttonstate,Ekey,p2d,p3d); - - // MOUSE Overlay - mitk::Point2D p2d_mm, pos_unit; - //Map world to 2d mm - if (br->GetDisplayGeometry()->Map( p3d, p2d_mm ) ) - { - //calculate position of the real inner widget - br->GetDisplayGeometry()->WorldToDisplay( p2d_mm, pos_unit); - //MITK_INFO<DrawOverlayMouse(pos_unit); //TEST - //mitk::RenderingManager::GetInstance()->RequestOverlayUpdateAll(); - } - - - //MITK_INFO<<"mitkEventMapper::MapEvent(): "<GetSizeX()<<" * "<GetSizeY()<<" * "<< p2 <<" =Y (("<GetMapperID() == 2 ) - { - mitk::CameraController* cc = br->GetCameraController(); - - //Qt Event IDs - if (Etype == 6) - { - // KeyPress - //cc->KeyPressEvent( keyevent); */ - ; - } - else - { - //Umrechnung fuer VTKCameraControler - p2d[1] = (mitk::ScalarType) (br->GetSizeY() - p2) * br->GetSizeY(); - mitk::PositionEvent *peVTK = new mitk::PositionEvent(br,Etype,Estate,Ebuttonstate,Ekey,p2d,p3d); - // END - - //PRESS - if(Etype == 2) - { - cc->MousePressEvent( peVTK ); - } - else if (Etype == 3 ) - { - //RELEASE - cc->MouseReleaseEvent( peVTK ); - } - else if (Etype == 5) - { - //MOVE - cc->MouseMoveEvent( peVTK ); - } - } - } - - bool ok = EventMapper::MapEvent( pe, mitk::GlobalInteraction::GetInstance(), mitkEventID ); - - return ok; -} - -bool -mitk::ConferenceEventMapper::MapEvent(const char* sender, float w1, float w2, float w3) -{ - - //CONFERENCE EVENT - mitk::BaseRenderer *br = const_cast(mitk::BaseRenderer::GetByName( std::string(sender) )); - - mitk::Point3D p3d; - p3d[0] = (mitk::ScalarType) w1; - p3d[1] = (mitk::ScalarType) w2; - p3d[2] = (mitk::ScalarType) w3; - - // MOUSE Overlay - mitk::Point2D p2d_mm, pos_unit; - //Map world to 2d mm - if (br->GetDisplayGeometry()->Map( p3d, p2d_mm ) ) - { - //calculate position of the real inner widget - br->GetDisplayGeometry()->WorldToDisplay( p2d_mm, pos_unit); - //MITK_INFO<DrawOverlayMouse(pos_unit); //TEST - //mitk::RenderingManager::GetInstance()->RequestOverlayUpdateAll(); - } - - return true; -} - - diff --git a/Modules/Ext/Interactions/mitkConferenceEventMapper.h b/Modules/Ext/Interactions/mitkConferenceEventMapper.h deleted file mode 100644 index 55febd7484..0000000000 --- a/Modules/Ext/Interactions/mitkConferenceEventMapper.h +++ /dev/null @@ -1,46 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef CONFERENCEVENTMAPPER_H_HEADER_INCLUDE -#define CONFERENCEVENTMAPPER_H_HEADER_INCLUDE - -#include -#include "MitkExtExports.h" - -namespace mitk { - - class MitkExt_EXPORT ConferenceEventMapper : public EventMapper - { - public: - ConferenceEventMapper(); - - ~ConferenceEventMapper(); - - // First part MITK Event ID and baserendere name - // Second the normaly not needed integer information from the GUI Event (type, state, button, key) - // Third the koordinated 3D and the relativ 2D - static bool MapEvent(signed int id, const char* sender, int Etype, int Estate, int EButtonState, int key, float w1,float w2,float w3,float d0,float d1); - - /* EasyEvent for MousMove Interaction. - * used during conferences - */ - static bool MapEvent(const char* sender, float w1,float w2,float w3); - }; -} // namespace mitk - -#endif - - diff --git a/Modules/Ext/Interactions/mitkConnectPointsInteractor.cpp b/Modules/Ext/Interactions/mitkConnectPointsInteractor.cpp deleted file mode 100644 index 325ac4c099..0000000000 --- a/Modules/Ext/Interactions/mitkConnectPointsInteractor.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkConnectPointsInteractor.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//how precise must the user pick the point -//default value -const int PRECISION = 5; - -mitk::ConnectPointsInteractor::ConnectPointsInteractor(const char * type, DataNode* dataNode, int n) -:Interactor(type, dataNode), m_N(n), m_CurrentCellId(0), m_Precision(PRECISION) -{ - m_LastPoint.Fill(0); - m_SumVec.Fill(0); -} - -mitk::ConnectPointsInteractor::~ConnectPointsInteractor() -{ -} - -void mitk::ConnectPointsInteractor::SetPrecision(unsigned int precision) -{ - m_Precision = precision; -} - -//##Documentation -//## overwritten cause this class can handle it better! -float mitk::ConnectPointsInteractor::CanHandleEvent(StateEvent const* stateEvent) const -{ - float returnValue = 0; - - mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - //checking if a keyevent can be handled: - if (posEvent == NULL) - { - //check, if the current state has a transition waiting for that key event. - if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) - { - return 0.5; - } - else - { - return 0; - } - } - - //Mouse event handling: - //on MouseMove do nothing! reimplement if needed differently - if (stateEvent->GetEvent()->GetType() == mitk::Type_MouseMove) - { - return 0; - } - - //check on the right data-type - mitk::PointSet* pointSet = dynamic_cast(m_DataNode->GetData()); - if (pointSet == NULL) - return 0; - - - //since we now have 3D picking in GlobalInteraction and all events send are DisplayEvents with 3D information, - //we concentrate on 3D coordinates - mitk::Point3D worldPoint = posEvent->GetWorldPosition(); - float p[3]; - itk2vtk(worldPoint, p); - //transforming the Worldposition to local coordinatesystem - m_DataNode->GetData()->GetGeometry()->GetVtkTransform()->GetInverse()->TransformPoint(p, p); - vtk2itk(p, worldPoint); - - float distance = 5; - int index = pointSet->SearchPoint(worldPoint, distance); - if (index>-1) - //how far away is the line from the point? - { - //get the point and calculate the jurisdiction out of it. - mitk::PointSet::PointType point; - pointSet->GetPointSet()->GetPoint(index, &point); - returnValue = point.EuclideanDistanceTo(worldPoint); - - //between 1 and 0. 1 if directly hit - returnValue = 1 - ( returnValue / distance ); - if (returnValue<0 || returnValue>1) - { - itkWarningMacro("Difficulties in calculating Jurisdiction. Check PointInteractor"); - return 0; - } - - //and now between 0,5 and 1 - returnValue = 0.5 + (returnValue / 2); - - return returnValue; - } - else //not found - { - return 0; - } -} - -bool mitk::ConnectPointsInteractor::ExecuteAction( Action* action, mitk::StateEvent const* stateEvent ) -{ - bool ok = false;//for return type bool - - //checking corresponding Data; has to be a Mesh or a subclass - mitk::Mesh* mesh = dynamic_cast(m_DataNode->GetData()); - if (mesh == NULL) - return false; - - //for reading on the points, Id's etc - //mitk::PointSet::DataType *itkpointSet = mesh->GetPointSet(); - //mitk::PointSet::PointsContainer *points = itkpointSet->GetPoints();//Warning Fix: not used! - - /*Each case must watch the type of the event!*/ - switch (action->GetActionId()) - { - case AcDONOTHING: - ok = true; - break; - case AcADDPOINT: - { - mitk::DisplayPositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - if (posEvent == NULL) - return false; - - mitk::Point3D worldPoint; - worldPoint = posEvent->GetWorldPosition(); - - int position = mesh->SearchPoint(worldPoint, m_Precision); - if (position >= 0)//found a point near enough to the given point - { - // if the point is the last in current cell, remove it (this has to be moved in a separate action) - bool deleteLine=false; - if(mesh->GetMesh()->GetCells()->Size() > 0) - { - Mesh::CellAutoPointer cellAutoPointer; - ok = mesh->GetMesh()->GetCell(m_CurrentCellId, cellAutoPointer); - if(ok) - { - Mesh::PointIdIterator last = cellAutoPointer->PointIdsEnd(); - --last; - int foundCell = mesh->SearchFirstCell( (unsigned long) position ); - if (foundCell != -1)//not found - deleteLine = ((unsigned int)foundCell == m_CurrentCellId) && (*last == (unsigned int)position); - } - } - if(deleteLine) - { - LineOperation* doOp = new mitk::LineOperation(OpDELETELINE, m_CurrentCellId, position); - if (m_UndoEnabled) - { - LineOperation* undoOp = new mitk::LineOperation(OpADDLINE, m_CurrentCellId, position); - OperationEvent *operationEvent = new OperationEvent(mesh, doOp, undoOp, "Delete line"); - m_UndoController->SetOperationEvent(operationEvent); - } - //execute the Operation - mesh->ExecuteOperation(doOp ); - } - else - { - // add new cell if necessary - if(mesh->GetNewCellId() == 0) //allow single line only - //allow multiple lines: if((mesh->SearchFirstCell(position) >= 0) || ((m_CurrentCellId == 0) && (mesh->GetNewCellId() == 0))) - { - //get the next cellId and set m_CurrentCellId - m_CurrentCellId = mesh->GetNewCellId(); - - //now reserv a new cell in m_ItkData - LineOperation* doOp = new mitk::LineOperation(OpNEWCELL, m_CurrentCellId); - if (m_UndoEnabled) - { - LineOperation* undoOp = new mitk::LineOperation(OpDELETECELL, m_CurrentCellId); - OperationEvent *operationEvent = new OperationEvent(mesh, doOp, undoOp, "Add cell"); - m_UndoController->SetOperationEvent(operationEvent); - } - mesh->ExecuteOperation(doOp); - } - // add line if point is not yet included in current cell - if(mesh->SearchFirstCell(position) < 0) - { - LineOperation* doOp = new mitk::LineOperation(OpADDLINE, m_CurrentCellId, position); - if (m_UndoEnabled) - { - LineOperation* undoOp = new mitk::LineOperation(OpDELETELINE, m_CurrentCellId, position); - OperationEvent *operationEvent = new OperationEvent(mesh, doOp, undoOp, "Add line"); - m_UndoController->SetOperationEvent(operationEvent); - } - //execute the Operation - mesh->ExecuteOperation(doOp ); - } - } - } - ok = true; - break; - } - case AcREMOVEPOINT: - { - //mitk::DisplayPositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - //if (posEvent == NULL) - // return false; - - //mitk::Point3D worldPoint; - //worldPoint = posEvent->GetWorldPosition(); - - //int position = mesh->SearchPoint(worldPoint, m_Precision); - //if (position>=0)//found a point near enough to the given point - //{ - // // if the point is in the current cell, remove it (this has to be moved in a separate action) - // if(mesh->SearchFirstCell(position) == m_CurrentCellId) - // { - // LineOperation* doOp = new mitk::LineOperation(OpDELETELINE, m_CurrentCellId, position); - // if (m_UndoEnabled) - // { - // LineOperation* undoOp = new mitk::LineOperation(OpADDLINE, m_CurrentCellId, position); - // OperationEvent *operationEvent = new OperationEvent(mesh, doOp, undoOp); - // m_UndoController->SetOperationEvent(operationEvent); - // } - // //execute the Operation - // mesh->ExecuteOperation(doOp ); - // } - //} - ok = true; - break; - } - case AcCHECKELEMENT: - /*checking if the Point transmitted is close enough to one point. Then generate a new event with the point and let this statemaschine handle the event.*/ - { - mitk::DisplayPositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - if (posEvent != NULL) - { - mitk::Point3D worldPoint = posEvent->GetWorldPosition(); - - int position = mesh->SearchPoint(worldPoint, m_Precision); - if (position>=0)//found a point near enough to the given point - { - PointSet::PointType pt = mesh->GetPoint(position);//get that point, the one meant by the user! - mitk::Point2D displPoint; - displPoint[0] = worldPoint[0]; displPoint[1] = worldPoint[1]; - //new Event with information YES and with the correct point - mitk::PositionEvent const* newPosEvent = new mitk::PositionEvent(posEvent->GetSender(), Type_None, BS_NoButton, BS_NoButton, Key_none, displPoint, pt); - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDYES, newPosEvent); - //call HandleEvent to leave the guard-state - this->HandleEvent( newStateEvent ); - ok = true; - } - else - { - //new Event with information NO - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, posEvent); - this->HandleEvent(newStateEvent ); - ok = true; - } - } - else - { - mitk::DisplayPositionEvent const *disPosEvent = dynamic_cast (stateEvent->GetEvent()); - if (disPosEvent != NULL) - {//2d Koordinates for 3D Interaction; return false to redo the last statechange - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, posEvent); - this->HandleEvent(newStateEvent ); - ok = true; - } - } - break; - } - case AcCHECKNMINUS1://generate Events if the set will be full after the addition of the point or not. - { - if (m_N<0)//number of points not limited->pass on "Amount of points in Set is smaller then N-1" - { - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDSTSMALERNMINUS1, stateEvent->GetEvent()); - this->HandleEvent( newStateEvent ); - ok = true; - } - else - { - if (mesh->GetSize()<(m_N-1)) - //pointset after addition won't be full - { - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDSTSMALERNMINUS1, stateEvent->GetEvent()); - this->HandleEvent( newStateEvent ); - ok = true; - } - else //(mesh->GetSize()>=(m_N-1)) - //after the addition of a point, the container will be full - { - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDSTLARGERNMINUS1, stateEvent->GetEvent()); - this->HandleEvent(newStateEvent ); - ok = true; - }//else - }//else - } - break; - case AcCHECKEQUALS1: - { - if (mesh->GetSize()<=1)//the number of points in the list is 1 (or smaler) - { - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDYES, stateEvent->GetEvent()); - this->HandleEvent( newStateEvent ); - ok = true; - } - else //more than 1 points in list, so stay in the state! - { - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, stateEvent->GetEvent()); - this->HandleEvent(newStateEvent ); - ok = true; - } - } - break; - default: - return Superclass::ExecuteAction( action, stateEvent ); - //mitk::StatusBar::GetInstance()->DisplayText("Message from mitkConnectPointsInteractor: I do not understand the Action!", 10000); - //ok = false; - //a false here causes the statemachine to undo its last statechange. - //otherwise it will end up in a different state, but without done Action. - //if a transition really has no Action, than call donothing - } - - return ok; -} diff --git a/Modules/Ext/Interactions/mitkConnectPointsInteractor.h b/Modules/Ext/Interactions/mitkConnectPointsInteractor.h deleted file mode 100644 index c78d58396e..0000000000 --- a/Modules/Ext/Interactions/mitkConnectPointsInteractor.h +++ /dev/null @@ -1,101 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKCONNECTPOINTSINTERACTOR_H_HEADER_INCLUDED_C11202FF -#define MITKCONNECTPOINTSINTERACTOR_H_HEADER_INCLUDED_C11202FF - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkNumericTypes.h" -#include - -namespace mitk -{ - class DataNode; - //##Documentation - //## @brief Interaction for mitk::Mesh: Connect existing points to lines - //## @ingroup Interaction - /** - * \deprecatedSince{2014_03} mitk::ConnectPointsInteractor is deprecated. Needs to be updated to the new interaction-framework. - * Refer to \see DataInteractionPage for general information about the concept of the new implementation. - */ - class DEPRECATED() MitkExt_EXPORT ConnectPointsInteractor : public Interactor - { - public: - mitkClassMacro(ConnectPointsInteractor, Interactor); - mitkNewMacro3Param(Self, const char*, DataNode*, int); - mitkNewMacro2Param(Self, const char*, DataNode*); - - //##Documentation - //## @brief Sets the amount of precision - void SetPrecision( unsigned int precision ); - - //##Documentation - //## @brief calculates how good the data, this statemachine handles, is hit by the event. - //## - //## overwritten, cause we don't look at the boundingbox, we look at each point - virtual float CanHandleEvent(StateEvent const* stateEvent) const; - - - protected: - //##Documentation - //##@brief Constructor with Param n for limited Set of Points - //## - //## if no n is set, then the number of points is unlimited* - ConnectPointsInteractor(const char * type, DataNode* dataNode, int n = -1); - - virtual ~ConnectPointsInteractor(); - - virtual bool ExecuteAction( Action* action, mitk::StateEvent const* stateEvent ); - - //##Documentation - //## @brief deselects the Points in the PointSet. - //## supports Undo if enabled - void UnselectAll(); - - //##Documentation - //## @brief Selects the point. - //## supports Undo if enabled. - //## @param position is the index of the point that has to be selected - void SelectPoint( int position ); - - private: - - //##Documentation - //## @brief the number of possible points in this object - //## - //## if -1, then no limit set - int m_N; - - //##Documentation - //## @brief stores the current CellId this Statemachine works in - unsigned int m_CurrentCellId; - - //##Documentation - //## @brief to calculate a direction vector from last point and actual point - Point3D m_LastPoint; - - //##Documentation - //## @brief summ-vector for Movement - Vector3D m_SumVec; - - //##Documentation - //## @brief to store the value of precision to pick a point - unsigned int m_Precision; - }; -} -#endif /* MITKCONNECTPOINTSINTERACTOR_H_HEADER_INCLUDED_C11202FF */ diff --git a/Modules/Ext/Interactions/mitkDisplayPointSetInteractor.cpp b/Modules/Ext/Interactions/mitkDisplayPointSetInteractor.cpp deleted file mode 100644 index 9945b641c9..0000000000 --- a/Modules/Ext/Interactions/mitkDisplayPointSetInteractor.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkDisplayPointSetInteractor.h" -#include "mitkInteractionConst.h" -#include "mitkStateEvent.h" -#include "mitkBaseRenderer.h" -#include "mitkNumericTypes.h" - - - -mitk::DisplayPointSetInteractor -::DisplayPointSetInteractor(const char * type, DataNode* dataNode, int n) -:PointSetInteractor(type, dataNode, n) -{ - - -} - -mitk::DisplayPointSetInteractor::~DisplayPointSetInteractor() -{ -} - - -bool mitk::DisplayPointSetInteractor -::ExecuteAction( Action* action, mitk::StateEvent const* stateEvent ) -{ - bool ok = false;//for return type bool - - //get the timestep to also support 3D+T - //const mitk::Event *theEvent = stateEvent->GetEvent(); - - /*Each case must watch the type of the event!*/ - /*Each time a Point is added or removed or finished moved, the display-coordinates and the last renderer is stored.*/ - switch (action->GetActionId()) - { - case AcADDPOINT: - { - mitk::DisplayPositionEvent const *posEvent = - dynamic_cast < const mitk::DisplayPositionEvent * > - (stateEvent->GetEvent()); - if ( posEvent == NULL ) - { - return false; - } - - m_LastDisplayCoordinates = posEvent->GetDisplayPosition(); - m_LastRenderer = posEvent->GetSender(); - - - ok = Superclass::ExecuteAction( action, stateEvent ); - break; - } - case AcREMOVEPOINT://remove the given Point from the list - { - mitk::DisplayPositionEvent const *posEvent = - dynamic_cast < const mitk::DisplayPositionEvent * > - (stateEvent->GetEvent()); - if ( posEvent == NULL ) - { - return false; - } - - m_LastDisplayCoordinates = posEvent->GetDisplayPosition(); - m_LastRenderer = posEvent->GetSender(); - - - ok = Superclass::ExecuteAction( action, stateEvent ); - break; - } - case AcREMOVEALL: - { - mitk::DisplayPositionEvent const *posEvent = - dynamic_cast < const mitk::DisplayPositionEvent * > - (stateEvent->GetEvent()); - if ( posEvent == NULL ) - { - return false; - } - - m_LastDisplayCoordinates = posEvent->GetDisplayPosition(); - m_LastRenderer = posEvent->GetSender(); - - - ok = Superclass::ExecuteAction( action, stateEvent ); - break; - } - case AcFINISHMOVEMENT: - { - mitk::DisplayPositionEvent const *posEvent = - dynamic_cast < const mitk::DisplayPositionEvent * > - (stateEvent->GetEvent()); - if ( posEvent == NULL ) - { - return false; - } - - m_LastDisplayCoordinates = posEvent->GetDisplayPosition(); - m_LastRenderer = posEvent->GetSender(); - - - ok = Superclass::ExecuteAction( action, stateEvent ); - break; - } - - default: - return Superclass::ExecuteAction( action, stateEvent ); - } - - return ok; -} - -mitk::Point2D mitk::DisplayPointSetInteractor::GetLastDisplayCoordinates() -{ - return m_LastDisplayCoordinates; -} - -mitk::BaseRenderer* mitk::DisplayPointSetInteractor::GetLastRenderer() -{ - return m_LastRenderer; -} diff --git a/Modules/Ext/Interactions/mitkDisplayPointSetInteractor.h b/Modules/Ext/Interactions/mitkDisplayPointSetInteractor.h deleted file mode 100644 index 21974293ad..0000000000 --- a/Modules/Ext/Interactions/mitkDisplayPointSetInteractor.h +++ /dev/null @@ -1,84 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKDISPLAYPOINTSETINTERACTOR_H_HEADER_INCLUDED_C11202FF -#define MITKDISPLAYPOINTSETINTERACTOR_H_HEADER_INCLUDED_C11202FF - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkNumericTypes.h" -#include -#include "mitkPointSetInteractor.h" -#include - -namespace mitk -{ - class DataNode; - - /** - * \brief Interaction with a set of points. - * - * Points can be added, removed and moved. - * \ingroup Interaction - */ - - /** - * \deprecatedSince{2014_03} mitk::DisplayPointSetInteractor is deprecated. Needs to be updated to the new interaction-framework. - * Refer to \see DataInteractionPage for general information about the concept of the new implementation. - */ - - class DEPRECATED() MitkExt_EXPORT DisplayPointSetInteractor : public PointSetInteractor - { - public: - mitkClassMacro(DisplayPointSetInteractor, PointSetInteractor); - mitkNewMacro3Param(Self, const char*, DataNode*, int); - mitkNewMacro2Param(Self, const char*, DataNode*); - - Point2D GetLastDisplayCoordinates(); - - BaseRenderer* GetLastRenderer(); - - - protected: - /** - * \brief Constructor with Param n for limited Set of Points - * - * if no n is set, then the number of points is unlimited* - */ - DisplayPointSetInteractor(const char * type, - DataNode* dataNode, int n = -1); - - /** - * \brief Default Destructor - **/ - virtual ~DisplayPointSetInteractor(); - - virtual bool ExecuteAction( Action* action, - mitk::StateEvent const* stateEvent ); - - /** \brief last display-coordinates of the point - * - */ - Point2D m_LastDisplayCoordinates; - - - mitk::BaseRenderer* m_LastRenderer; - - - }; -} -#endif /* MITKDisplayPointSetInteractor_H_HEADER_INCLUDED_C11202FF */ diff --git a/Modules/Ext/Interactions/mitkEventAndActionConstants.xml b/Modules/Ext/Interactions/mitkEventAndActionConstants.xml deleted file mode 100644 index 69c850a546..0000000000 --- a/Modules/Ext/Interactions/mitkEventAndActionConstants.xml +++ /dev/null @@ -1,369 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Modules/Ext/Interactions/mitkEventAndActionConstants.xsl b/Modules/Ext/Interactions/mitkEventAndActionConstants.xsl deleted file mode 100644 index 1baabec256..0000000000 --- a/Modules/Ext/Interactions/mitkEventAndActionConstants.xsl +++ /dev/null @@ -1,516 +0,0 @@ - - - -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKINTERACTCONST_H -#define MITKINTERACTCONST_H - -//##Documentation -//## @file mitkInteractionConst.h -//## @brief Constants for most interaction classes, due to the generic StateMachines. -//## -//## Changes in Type, ButtonState or Key has to be don in mitkEventMapper.cpp, too. -//## @ingroup Interaction - -/*Prefixes for Constants: -E = Enumeration -EID = EventId's -Op = Operations -Ac = Action -Type_ = Type of Event -BS_ = ButtonStates and Buttons -Key_ = Keys like in QT -*/ -namespace mitk{ - -/* -//UndoMechanism: -//constants for UndoMechanism; -*/ -//different UndoModels: -typedef enum EUndoModels{LIMITEDLINEARUNDO=10, VERBOSE_LIMITEDLINEARUNDO=11, TREEUNDO=20}; - -//Constants for EventIds; use the according constant to through an event in the code -typedef enum EEventIds -{ - - - - - - = - - -, - - - // - - - - - - - -}; - -//##Constants for Operations -//## xomments are always examples of the usage -typedef enum EOperations -{ - OpNOTHING = 0, - OpTEST = 1, - OpNEWCELL = 10, //add a new cell - OpADD = 100, //add a point or a vessel - OpUNDOADD = 101, - OpADDLINE = 1001, //add a line - OpINSERT = 200, //insert a point at position - OpINSERTLINE = 201, //insert a line at position - OpINSERTPOINT = 202, - OpCLOSECELL = 250, //close a cell (to a polygon) - OpOPENCELL = 251, //close a cell (to a polygon) - OpMOVE = 300, //move a point - OpMOVELINE = 301, //move a line - OpMOVECELL = 302, //move a line - OpUNDOMOVE = 303, - OpREMOVE = 400, //remove a point at position - OpREMOVELINE = 401, //remove a line at position - OpREMOVECELL = 402, //remove a cell - OpREMOVEPOINT = 403, - OpDELETE = 500, //delete - OpDELETELINE = 501, //delete the last line in a cell - OpUNDELETE = 502, - OpDELETECELL = 505, - OpSTATECHANGE = 600, //change a state - OpTERMINATE = 666, //change a state - OpSELECTPOINT = 700, - OpSELECTLINE = 701, - OpSELECTCELL = 702, - OpSELECTSUBOBJECT = 703, //for VesselGraphInteractor - //OpSELECTNEWSUBOBJECT = 704, //for VesselGraphInteractor - OpSELECT = 705, - OpDESELECTPOINT = 800, - OpDESELECTLINE = 801, - OpDESELECTCELL = 802, - OpDESELECTSUBOBJECT = 803, //for VesselGraphInteractor - OpDESELECTALL = 804, //for VesselGraphInteractor - OpDESELECT = 805, - OpNAVIGATE = 900, - OpZOOM = 1000, - OpSCALE = 1100, - OpROTATE = 1200, - OpSETPOINTTYPE = 1210, - OpMODECHANGE = 1500, - OpSENDCOORDINATES = 1600, - OpPERIPHERYSEARCH = 2000, //used in VesselGraphInteractor - OpROOTSEARCH = 2001, //used in VesselGraphInteractor - OpTHICKSTVESSELSEARCH = 2002, //used in VesselGraphInteractor - OpSHORTESTPATHSEARCH = 2003, //used in VesselGraphInteractor - OpATTRIBUTATION = 2004, //used in VesselGraphInteractor - OpDEFAULT = 2006, //used in VesselGraphInteractor -}; - -//##Constants for EventMapping... -//##connects the statemachine.xml-File with the implemented conditions. -//##within one statemachine the choice of the actionconstants is freely -//## -//## ActionId -typedef enum EActions -{ - - - - - - - = - - -, - - - // - - - - - - - -}; - - -/* -//!!!!!!!!!!!!!!!!!!!!!!!! -//!!!!!!!!!!!!!!!!!!!!!!!! -//EventMechanism: -//If you change anything from here on, then change in mitkEventMapper.cpp (Array of constants) as well. -//!!!!!!!!!!!!!!!!!!!!!!!! -//!!!!!!!!!!!!!!!!!!!!!!!! -*/ - -//Type of an Event; -typedef enum EEventType -{ - Type_None = 0, // invalid event - Type_Timer = 1, // timer event - Type_MouseButtonPress = 2, // mouse button pressed - Type_MouseButtonRelease = 3, // mouse button released - Type_MouseButtonDblClick = 4, // mouse button double click - Type_MouseMove = 5, // mouse move - Type_KeyPress = 6, // key pressed - Type_KeyRelease = 7, // key released - Type_FocusIn = 8, // keyboard focus received - Type_FocusOut = 9, // keyboard focus lost - Type_Enter = 10, // mouse enters widget - Type_Leave = 11, // mouse leaves widget - Type_Paint = 12, // paint widget - Type_Move = 13, // move widget - Type_Resize = 14, // resize widget - Type_Create = 15, // after object creation - Type_Destroy = 16, // during object destruction - Type_Show = 17, // widget is shown - Type_Hide = 18, // widget is hidden - Type_Close = 19, // request to close widget - Type_Quit = 20, // request to quit application - Type_Reparent = 21, // widget has been reparented - Type_ShowMinimized = 22, // widget is shown minimized - Type_ShowNormal = 23, // widget is shown normal - Type_WindowActivate = 24, // window was activated - Type_WindowDeactivate = 25, // window was deactivated - Type_ShowToParent = 26, // widget is shown to parent - Type_HideToParent = 27, // widget is hidden to parent - Type_ShowMaximized = 28, // widget is shown maximized - Type_ShowFullScreen = 29, // widget is shown full-screen - Type_Accel = 30, // accelerator event - Type_Wheel = 31, // wheel event - Type_AccelAvailable = 32, // accelerator available event - Type_CaptionChange = 33, // caption changed - Type_IconChange = 34, // icon changed - Type_ParentFontChange = 35, // parent font changed - Type_ApplicationFontChange = 36, // application font changed - Type_ParentPaletteChange = 37, // parent palette changed - Type_ApplicationPaletteChange = 38, // application palette changed - Type_PaletteChange = 39, // widget palette changed - Type_Clipboard = 40, // internal clipboard event - Type_Speech = 42, // reserved for speech input - Type_SockAct = 50, // socket activation - Type_AccelOverride = 51, // accelerator override event - Type_DeferredDelete = 52, // deferred delete event - Type_DragEnter = 60, // drag moves into widget - Type_DragMove = 61, // drag moves in widget - Type_DragLeave = 62, // drag leaves or is cancelled - Type_Drop = 63, // actual drop - Type_DragResponse = 64, // drag accepted/rejected - Type_ChildInserted = 70, // new child widget - Type_ChildRemoved = 71, // deleted child widget - Type_LayoutHint = 72, // child min/max size changed - Type_ShowWindowRequest = 73, // widget's window should be mapped - Type_ActivateControl = 80, // ActiveX activation - Type_DeactivateControl = 81, // ActiveX deactivation - Type_ContextMenu = 82, // context popup menu - Type_IMStart = 83, // input method composition start - Type_IMCompose = 84, // input method composition - Type_IMEnd = 85, // input method composition end - Type_Accessibility = 86, // accessibility information is requested - Type_TabletMove = 87, // Wacom tablet event - Type_LocaleChange = 88, // the system locale changed - Type_LanguageChange = 89, // the application language changed - Type_LayoutDirectionChange = 90, // the layout direction changed - Type_Style = 91, // internal style event - Type_TabletPress = 92, // tablet press - Type_TabletRelease = 93, // tablet release - Type_User = 1000, // first user event id - Type_MaxUser = 65535 -}; - - -//##ButtonState -// mouse/keyboard state values -//QT combinations if MOUSEBUTTONRelease: left MouseButton + ControlButton: 0x201 -typedef enum EButtonStates -{ - BS_NoButton = 0x0000, - BS_LeftButton = 0x0001, - BS_RightButton = 0x0002, - BS_MidButton = 0x0004, - BS_MouseButtonMask = 0x0007, - BS_ShiftButton = 0x0100, - BS_ControlButton = 0x0200, - BS_AltButton = 0x0400, - BS_MetaButton = 0x0800, - BS_KeyButtonMask = 0x0f00, - BS_Keypad = 0x4000 -}; -//##Key -typedef enum EKeys -{ - Key_Escape = 0x1000, // misc keys - Key_Tab = 0x1001, - Key_Backtab = 0x1002, - Key_BackTab = 0x1002, //= Key_Backtab - Key_Backspace = 0x1003, - Key_BackSpace = 0x1003, //= Key_Backspace - Key_Return = 0x1004, - Key_Enter = 0x1005, - Key_Insert = 0x1006, - Key_Delete = 0x1007, - Key_Pause = 0x1008, - Key_Print = 0x1009, - Key_SysReq = 0x100a, - Key_Home = 0x1010, // cursor movement - Key_End = 0x1011, - Key_Left = 0x1012, - Key_Up = 0x1013, - Key_Right = 0x1014, - Key_Down = 0x1015, - Key_Prior = 0x1016, - Key_PageUp = 0x1016, //=Key_Prior - Key_Next = 0x1017, - Key_PageDown = 0x1017, //=Key_Next - Key_Shift = 0x1020, // modifiers - Key_Control = 0x1021, - Key_Meta = 0x1022, - Key_Alt = 0x1023, - Key_CapsLock = 0x1024, - Key_NumLock = 0x1025, - Key_ScrollLock = 0x1026, - Key_F1 = 0x1030, // function keys - Key_F2 = 0x1031, - Key_F3 = 0x1032, - Key_F4 = 0x1033, - Key_F5 = 0x1034, - Key_F6 = 0x1035, - Key_F7 = 0x1036, - Key_F8 = 0x1037, - Key_F9 = 0x1038, - Key_F10 = 0x1039, - Key_F11 = 0x103a, - Key_F12 = 0x103b, - Key_F13 = 0x103c, - Key_F14 = 0x103d, - Key_F15 = 0x103e, - Key_F16 = 0x103f, - Key_F17 = 0x1040, - Key_F18 = 0x1041, - Key_F19 = 0x1042, - Key_F20 = 0x1043, - Key_F21 = 0x1044, - Key_F22 = 0x1045, - Key_F23 = 0x1046, - Key_F24 = 0x1047, - Key_F25 = 0x1048, // F25 .. F35 only on X11 - Key_F26 = 0x1049, - Key_F27 = 0x104a, - Key_F28 = 0x104b, - Key_F29 = 0x104c, - Key_F30 = 0x104d, - Key_F31 = 0x104e, - Key_F32 = 0x104f, - Key_F33 = 0x1050, - Key_F34 = 0x1051, - Key_F35 = 0x1052, - Key_Super_L = 0x1053, // extra keys - Key_Super_R = 0x1054, - Key_Menu = 0x1055, - Key_Hyper_L = 0x1056, - Key_Hyper_R = 0x1057, - Key_Help = 0x1058, - // International input method support (X keycode - = 0xEE00) - // Only interesting if you are writing your own input method - Key_Muhenkan = 0x1122, // Cancel Conversion - Key_Henkan = 0x1123, // Start/Stop Conversion - Key_Hiragana_Katakana = 0x1127, // Hiragana/Katakana toggle - Key_Zenkaku_Hankaku = 0x112A, // Zenkaku/Hankaku toggle - Key_Space = 0x20, // 7 bit printable ASCII - Key_Any = 0x20, //= Key_Space - Key_Exclam = 0x21, - Key_QuoteDbl = 0x22, - Key_NumberSign = 0x23, - Key_Dollar = 0x24, - Key_Percent = 0x25, - Key_Ampersand = 0x26, - Key_Apostrophe = 0x27, - Key_ParenLeft = 0x28, - Key_ParenRight = 0x29, - Key_Asterisk = 0x2a, - Key_Plus = 0x2b, - Key_Comma = 0x2c, - Key_Minus = 0x2d, - Key_Period = 0x2e, - Key_Slash = 0x2f, - Key_0 = 0x30, - Key_1 = 0x31, - Key_2 = 0x32, - Key_3 = 0x33, - Key_4 = 0x34, - Key_5 = 0x35, - Key_6 = 0x36, - Key_7 = 0x37, - Key_8 = 0x38, - Key_9 = 0x39, - Key_Colon = 0x3a, - Key_Semicolon = 0x3b, - Key_Less = 0x3c, - Key_Equal = 0x3d, - Key_Greater = 0x3e, - Key_Question = 0x3f, - Key_At = 0x40, - Key_A = 0x41, - Key_B = 0x42, - Key_C = 0x43, - Key_D = 0x44, - Key_E = 0x45, - Key_F = 0x46, - Key_G = 0x47, - Key_H = 0x48, - Key_I = 0x49, - Key_J = 0x4a, - Key_K = 0x4b, - Key_L = 0x4c, - Key_M = 0x4d, - Key_N = 0x4e, - Key_O = 0x4f, - Key_P = 0x50, - Key_Q = 0x51, - Key_R = 0x52, - Key_S = 0x53, - Key_T = 0x54, - Key_U = 0x55, - Key_V = 0x56, - Key_W = 0x57, - Key_X = 0x58, - Key_Y = 0x59, - Key_Z = 0x5a, - Key_BracketLeft = 0x5b, - Key_Backslash = 0x5c, - Key_BracketRight = 0x5d, - Key_AsciiCircum = 0x5e, - Key_Underscore = 0x5f, - Key_QuoteLeft = 0x60, - Key_BraceLeft = 0x7b, - Key_Bar = 0x7c, - Key_BraceRight = 0x7d, - Key_AsciiTilde = 0x7e, - Key_nobreakspace = 0x0a0, - Key_exclamdown = 0x0a1, - Key_cent = 0x0a2, - Key_sterling = 0x0a3, - Key_currency = 0x0a4, - Key_yen = 0x0a5, - Key_brokenbar = 0x0a6, - Key_section = 0x0a7, - Key_diaeresis = 0x0a8, - Key_copyright = 0x0a9, - Key_ordfeminine = 0x0aa, - Key_guillemotleft = 0x0ab, // left angle quotation mark - Key_notsign = 0x0ac, - Key_hyphen = 0x0ad, - Key_registered = 0x0ae, - Key_macron = 0x0af, - Key_degree = 0x0b0, - Key_plusminus = 0x0b1, - Key_twosuperior = 0x0b2, - Key_threesuperior = 0x0b3, - Key_acute = 0x0b4, - Key_mu = 0x0b5, - Key_paragraph = 0x0b6, - Key_periodcentered = 0x0b7, - Key_cedilla = 0x0b8, - Key_onesuperior = 0x0b9, - Key_masculine = 0x0ba, - Key_guillemotright = 0x0bb, // right angle quotation mark - Key_onequarter = 0x0bc, - Key_onehalf = 0x0bd, - Key_threequarters = 0x0be, - Key_questiondown = 0x0bf, - Key_Agrave = 0x0c0, - Key_Aacute = 0x0c1, - Key_Acircumflex = 0x0c2, - Key_Atilde = 0x0c3, - Key_Adiaeresis = 0x0c4, - Key_Aring = 0x0c5, - Key_AE = 0x0c6, - Key_Ccedilla = 0x0c7, - Key_Egrave = 0x0c8, - Key_Eacute = 0x0c9, - Key_Ecircumflex = 0x0ca, - Key_Ediaeresis = 0x0cb, - Key_Igrave = 0x0cc, - Key_Iacute = 0x0cd, - Key_Icircumflex = 0x0ce, - Key_Idiaeresis = 0x0cf, - Key_ETH = 0x0d0, - Key_Ntilde = 0x0d1, - Key_Ograve = 0x0d2, - Key_Oacute = 0x0d3, - Key_Ocircumflex = 0x0d4, - Key_Otilde = 0x0d5, - Key_Odiaeresis = 0x0d6, - Key_multiply = 0x0d7, - Key_Ooblique = 0x0d8, - Key_Ugrave = 0x0d9, - Key_Uacute = 0x0da, - Key_Ucircumflex = 0x0db, - Key_Udiaeresis = 0x0dc, - Key_Yacute = 0x0dd, - Key_THORN = 0x0de, - Key_ssharp = 0x0df, - Key_agrave = 0x0e0, - Key_aacute = 0x0e1, - Key_acircumflex = 0x0e2, - Key_atilde = 0x0e3, - Key_adiaeresis = 0x0e4, - Key_aring = 0x0e5, - Key_ae = 0x0e6, - Key_ccedilla = 0x0e7, - Key_egrave = 0x0e8, - Key_eacute = 0x0e9, - Key_ecircumflex = 0x0ea, - Key_ediaeresis = 0x0eb, - Key_igrave = 0x0ec, - Key_iacute = 0x0ed, - Key_icircumflex = 0x0ee, - Key_idiaeresis = 0x0ef, - Key_eth = 0x0f0, - Key_ntilde = 0x0f1, - Key_ograve = 0x0f2, - Key_oacute = 0x0f3, - Key_ocircumflex = 0x0f4, - Key_otilde = 0x0f5, - Key_odiaeresis = 0x0f6, - Key_division = 0x0f7, - Key_oslash = 0x0f8, - Key_ugrave = 0x0f9, - Key_uacute = 0x0fa, - Key_ucircumflex = 0x0fb, - Key_udiaeresis = 0x0fc, - Key_yacute = 0x0fd, - Key_thorn = 0x0fe, - Key_ydiaeresis = 0x0ff, - Key_unknown = 0xffff, - Key_none = 0xffff//= Key_unknown -}; - -}//namespace mitk -#endif //ifndef MITKINTERACTCONST_H - - - - \ No newline at end of file diff --git a/Modules/Ext/Interactions/mitkInteractionDebug.cpp b/Modules/Ext/Interactions/mitkInteractionDebug.cpp deleted file mode 100644 index 127df13a77..0000000000 --- a/Modules/Ext/Interactions/mitkInteractionDebug.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkInteractionDebug.h" -#include "mitkSocketClient.h" -#include - -namespace mitk { - - const int InteractionDebug::OPEN_CONNECTION = 1; - const int InteractionDebug::NEW_STATE_MACHINE = 2; - const int InteractionDebug::EVENT = 3; - const int InteractionDebug::TRANSITION = 4; - const int InteractionDebug::ACTION = 5; - const int InteractionDebug::DELETE_STATE_MACHINE = 6; - - InteractionDebug* InteractionDebug::m_Instance = NULL;; - char* InteractionDebug::m_FileName = NULL; - - /** - * - */ - InteractionDebug::InteractionDebug() - { - SocketClient::GetInstance()->open( "127.0.0.1", 34768 ); - } - - - /** - * - */ - unsigned int InteractionDebug::GetHashValue() - { - return 0; - } - - /** - * - */ - void InteractionDebug::OpenConection() - { - char* wb = m_Buffer; - *((unsigned long*) wb) = (unsigned long) GetHashValue(); - wb += sizeof(long); - - size_t size = strlen( m_FileName ); - - *((unsigned long*) wb) = (unsigned long) size; - wb += sizeof(long); - - strcpy( wb, m_FileName ); - size += 2*sizeof(long); - - sendCounter(); - // MITK_INFO << "Open Connection file name: " << m_FileName << std::endl; - SocketClient::GetInstance()->send( OPEN_CONNECTION, (unsigned int) size, m_Buffer ); - } - - /** - * - */ - bool InteractionDebug::NewStateMachine( const char* name, const StateMachine* stateMachine ) - { - if ( name == NULL ) - return false; - - // Instance Address - char* wb = m_Buffer; - *((unsigned long*) wb) = (unsigned long) stateMachine; - wb += sizeof(long); - - // Length of the name - size_t size = strlen(name); - - *((unsigned long*) wb) = (unsigned long) size; - wb += sizeof(long); - - // name - strcpy(wb,name); - - size += 2*sizeof(long); - - sendCounter(); - // MITK_INFO << "NEW_STATE_MACHINE: instance: " << (unsigned int) stateMachine << " Type: " << name << std::endl; - return SocketClient::GetInstance()->send( NEW_STATE_MACHINE, (unsigned int) size, m_Buffer ); - } - - /** - * - */ - bool InteractionDebug::Event( const StateMachine* stateMachine, unsigned int EventId ) - { - if ( EventId != 520) - { - if ( stateMachine == NULL || stateMachine->GetType().empty() ) - return false; - - // Instance Address - char* wb = m_Buffer; - *((unsigned long*) wb) = (unsigned long) stateMachine; - wb += sizeof(long); - - // eventID - *((unsigned long*) wb) = EventId; - - sendCounter(); - // MITK_INFO << "EVENT: instance: " << (unsigned int) stateMachine << " EventId: " << EventId << std::endl; - return SocketClient::GetInstance()->send( EVENT, 2*sizeof(long), m_Buffer ); - } - return true; - } - - /** - * - */ - bool InteractionDebug::Transition( const StateMachine* stateMachine, const char* transitionName ) - { - if ( stateMachine == NULL || stateMachine->GetType().empty() ) - return false; - - // Instance Address - char* wb = m_Buffer; - *((unsigned long*) wb) = (unsigned long) stateMachine; - wb += sizeof(long); - - // transitionName - unsigned long size = static_cast(strlen( transitionName )); - *((unsigned long*) wb) = size; - - wb += sizeof(long); - - for ( unsigned long i=0; isend( TRANSITION, size, m_Buffer ); - } - - /** - * - */ - bool InteractionDebug::Action( const StateMachine* stateMachine, const char* transitionName, unsigned int action ) - { - if ( stateMachine == NULL || stateMachine->GetType().empty() ) - return false; - - // Instance Address - char* wb = m_Buffer; - *((unsigned long*) wb) = (unsigned long) stateMachine; - wb += sizeof(long); - - // transitionName - unsigned long size = static_cast(strlen( transitionName )); - *((unsigned long*) wb) = size; - - wb += sizeof(long); - - for ( unsigned long i=0; isend( ACTION, size, m_Buffer ); - } - - /** - * - */ - bool InteractionDebug::DeleteStateMachine( const StateMachine* stateMachine ) - { - if ( stateMachine == NULL || stateMachine->GetType().empty() ) - return false; - - // Instance Address - char* wb = m_Buffer; - *((unsigned long*) wb) = (unsigned long) stateMachine; - - sendCounter(); - // MITK_INFO << "DELETE_STATE_MACHINE: instance: << (unsigned int) stateMachine" << std::endl; - return SocketClient::GetInstance()->send( DELETE_STATE_MACHINE, sizeof(long), m_Buffer ); - } - - /** - * - */ - InteractionDebug* InteractionDebug::GetInstance() - { - if (m_Instance==NULL) - m_Instance = new InteractionDebug(); - - return m_Instance; - } - - /** - * - */ - void InteractionDebug::SetXMLFileName( const char* fileName ) - { - size_t size = strlen(fileName) + 1; - m_FileName = new char[size]; - strcpy(m_FileName,fileName); - } - - void InteractionDebug::sendCounter() - { - static unsigned long m_Counter = 0; - static char my_Buffer[sizeof(long)]; - m_Counter++; - - char* wb = my_Buffer; - *((unsigned long*) wb) = (unsigned long) m_Counter; - - bool success = SocketClient::GetInstance()->send( 7, sizeof(long), wb ); - if (success) - { - MITK_INFO << "Counter: " << m_Counter << std::endl; - } - } - - void InteractionDebug::setMaxConnectionAdvance(int maxConnectionAdvance) - { - SocketClient::GetInstance()->setMaxConnectionAdvance(maxConnectionAdvance); - } - -} // mitk diff --git a/Modules/Ext/Interactions/mitkInteractionDebug.h b/Modules/Ext/Interactions/mitkInteractionDebug.h deleted file mode 100644 index fc044c0532..0000000000 --- a/Modules/Ext/Interactions/mitkInteractionDebug.h +++ /dev/null @@ -1,58 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef INTERACTION_DEBUG_H -#define INTERACTION_DEBUG_H -#include "mitkStateMachine.h" -#include "MitkExtExports.h" -#include "mitkSocketClient.h" - -namespace mitk{ - -class MitkExt_EXPORT InteractionDebug -{ - static InteractionDebug* m_Instance; - static char* m_FileName; - - char m_Buffer[255]; - - static const int OPEN_CONNECTION; - static const int NEW_STATE_MACHINE; - static const int EVENT; - static const int TRANSITION; - static const int ACTION; - static const int DELETE_STATE_MACHINE; - - unsigned int GetHashValue(); - InteractionDebug(); - -public: - void OpenConection(); - bool NewStateMachine( const char* name, const StateMachine* stateMachine ); - bool Event( const StateMachine* stateMachine, unsigned int EventId ); - bool Transition( const StateMachine* stateMachine, const char* transitionName ); - bool Action( const StateMachine* stateMachine, const char* transitionName, unsigned int action ); - bool DeleteStateMachine( const StateMachine* stateMachine ); - void setMaxConnectionAdvance(int maxConectionAdvance); - static InteractionDebug* GetInstance(); - static void SetXMLFileName( const char* fileName ); - - void sendCounter(); -}; - -} // mitk - -#endif // INTERACTION_DEBUG_H diff --git a/Modules/Ext/Interactions/mitkInteractionDebugger.cpp b/Modules/Ext/Interactions/mitkInteractionDebugger.cpp deleted file mode 100644 index 8378d71266..0000000000 --- a/Modules/Ext/Interactions/mitkInteractionDebugger.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkInteractionDebugger.h" -#include - -const char* mitk::InteractionDebugger::m_CurrentSender = ""; -bool mitk::InteractionDebugger::m_Active = false; - -mitk::InteractionDebugger::InteractionDebugger() -{} - -void mitk::InteractionDebugger::Activate() -{ - m_Active = true; -} - -void mitk::InteractionDebugger::Deactivate() -{ - m_Active = false; -} -mitk::InteractionDebugger::~InteractionDebugger() -{} - -void mitk::InteractionDebugger::Set(const char* sender, const char* text) -{ - if (m_Active) - { - std::ostringstream itkmsg; - if (! itk::Object::GetGlobalWarningDisplay()) - return; - - if (sender != m_CurrentSender) - { - itkmsg << sender <<" :\n"< -#include "MitkExtExports.h" -#include "mitkCommon.h" - - -namespace mitk{ - - /** - * @brief prints out information for debugging purpose - * - * prints out recieved text in a sorted way - * @ingroup Interaction - */ - class MitkExt_EXPORT InteractionDebugger : public itk::Object - { - public: - /** - * set a text for output - * @param sender: who has sent this text - */ - static void Set(const char* sender, const char* text); - static void Activate(); - static void Deactivate(); - - protected: - InteractionDebugger(); - ~InteractionDebugger(); - - private: - static const char* m_CurrentSender; - static bool m_Active; - }; - -}//namespace mitk - -#endif /* MITKINTERACTIONDEBUGGER_H */ - - diff --git a/Modules/Ext/Interactions/mitkPointInteractor.cpp b/Modules/Ext/Interactions/mitkPointInteractor.cpp deleted file mode 100644 index 69befde6b8..0000000000 --- a/Modules/Ext/Interactions/mitkPointInteractor.cpp +++ /dev/null @@ -1,544 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkPointInteractor.h" -#include -#include -#include -//#include "mitkStatusBar.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -mitk::PointInteractor::PointInteractor(const char * type, DataNode* dataNode) -: Interactor(type, dataNode), m_LastPosition(0) -{ - m_LastPoint.Fill(0); -} - -mitk::PointInteractor::~PointInteractor() -{} - -void mitk::PointInteractor::SelectPoint(int position) -{ - mitk::PointSet* pointSet = dynamic_cast(m_DataNode->GetData()); - if (pointSet == NULL) - return; - if (pointSet->GetSize()<=0)//if List is empty, then no select of a point can be done! - return; - - mitk::Point3D noPoint;//dummyPoint... not needed anyway - noPoint.Fill(0); - mitk::PointOperation* doOp = new mitk::PointOperation(OpSELECTPOINT, noPoint, position); - if (m_UndoEnabled) - { - mitk::PointOperation* undoOp = new mitk::PointOperation(OpDESELECTPOINT, noPoint, position); - OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); - m_UndoController->SetOperationEvent(operationEvent); - } - pointSet->ExecuteOperation(doOp); -} - -void mitk::PointInteractor::DeselectAllPoints() -{ - mitk::PointSet* pointSet = dynamic_cast(m_DataNode->GetData()); - if (pointSet == NULL) - return; - - mitk::PointSet::DataType *itkPointSet = pointSet->GetPointSet(); - mitk::PointSet::PointsContainer::Iterator it, end; - end = itkPointSet->GetPoints()->End(); - - for (it = itkPointSet->GetPoints()->Begin(); it != end; it++) - { - int position = it->Index(); - PointSet::PointDataType pointData = {0, false, PTUNDEFINED}; - itkPointSet->GetPointData(position, &pointData); - if ( pointData.selected )//then declare an operation which unselects this point; UndoOperation as well! - { - mitk::Point3D noPoint; - noPoint.Fill(0); - - mitk::PointOperation* doOp = new mitk::PointOperation(OpDESELECTPOINT, noPoint, position); - if (m_UndoEnabled) - { - mitk::PointOperation* undoOp = new mitk::PointOperation(OpSELECTPOINT, noPoint, position); - OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); - m_UndoController->SetOperationEvent(operationEvent); - } - pointSet->ExecuteOperation(doOp); - } - } -} - -float mitk::PointInteractor::CanHandleEvent(StateEvent const* stateEvent) const -//go through all points and check, if the given Point lies near a line -{ - float returnValue = 0; - - mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - //checking if a keyevent can be handled: - if (posEvent == NULL) - { - //check, if the current state has a transition waiting for that key event. - if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) - { - return 0.5; - } - else - { - return 0; - } - } - - //Mouse event handling: - //on MouseMove do nothing! reimplement if needed differently - if (stateEvent->GetEvent()->GetType() == mitk::Type_MouseMove) - { - return 0; - } - - //if the event can be understood and if there is a transition waiting for that event - if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) - { - returnValue = 0.5;//it can be understood - } - - //check on the right data-type - mitk::PointSet* pointSet = dynamic_cast(m_DataNode->GetData()); - if (pointSet == NULL) - return 0; - - - //since we now have 3D picking in GlobalInteraction and all events send are DisplayEvents with 3D information, - //we concentrate on 3D coordinates - mitk::Point3D worldPoint = posEvent->GetWorldPosition(); - float p[3]; - itk2vtk(worldPoint, p); - //transforming the Worldposition to local coordinatesystem - m_DataNode->GetData()->GetGeometry()->GetVtkTransform()->GetInverse()->TransformPoint(p, p); - vtk2itk(p, worldPoint); - - float distance = 5; - int index = pointSet->SearchPoint(worldPoint, distance); - if (index>-1) - //how far away is the line from the point? - { - //get the point and calculate the jurisdiction out of it. - mitk::PointSet::PointType point; - pointSet->GetPointSet()->GetPoint(index, &point); - returnValue = point.EuclideanDistanceTo(worldPoint); - - //between 1 and 0. 1 if directly hit - returnValue = 1 - ( returnValue / distance ); - if (returnValue<0 || returnValue>1) - { - itkWarningMacro("Difficulties in calculating Jurisdiction. Check PointInteractor"); - return 0; - } - - //and now between 0,5 and 1 - returnValue = 0.5 + (returnValue / 2); - - return returnValue; - } - else //not found - { - return returnValue; - } - -} - - -bool mitk::PointInteractor::ExecuteAction( Action* action, mitk::StateEvent const* stateEvent ) -{ - bool ok = false;//for return type bool - - //checking corresponding Data; has to be a PointSet or a subclass - mitk::PointSet* pointSet = dynamic_cast(m_DataNode->GetData()); - if (pointSet == NULL) - return false; - - //for reading on the points, Id's etc - mitk::PointSet::DataType *itkPointSet = pointSet->GetPointSet(); - mitk::PointSet::PointsContainer *itkPoints = itkPointSet->GetPoints(); - - /*Each case must watch the type of the event!*/ - switch (action->GetActionId()) - { - case AcADDPOINT: - { - mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - if (posEvent == NULL) - return false; - - mitk::Point3D itkPoint; - itkPoint = posEvent->GetWorldPosition(); - - //find the position, the point is to be added to: first entry with empty index. - //if the Set is empty, then start with 0. if not empty, then take the first index not occupied - int lastPosition = 0; - if (!itkPoints->empty()) - { - mitk::PointSet::PointsIterator it, end; - it = itkPoints->Begin(); - end = itkPoints->End(); - while( it != end ) - { - if (!itkPoints->IndexExists(lastPosition)) - break; - ++it; - ++lastPosition; - } - } - - PointOperation* doOp = new mitk::PointOperation(OpINSERT, itkPoint, lastPosition); - if (m_UndoEnabled) - { - PointOperation* undoOp = new mitk::PointOperation(OpREMOVE, itkPoint, lastPosition); - OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp, "Add point"); - m_UndoController->SetOperationEvent(operationEvent); - } - pointSet->ExecuteOperation(doOp); - ok = true; - break; - } - case AcDESELECTALL: - this->DeselectAllPoints(); - ok = true; - break; - case AcCHECKELEMENT : - /*checking if the Point transmitted is close enough to one point. Then generate a new event with the point and let this statemaschine handle the event.*/ - { - mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - if (posEvent != NULL) - { - mitk::Point3D worldPoint = posEvent->GetWorldPosition(); - - int PRECISION = 4; - mitk::IntProperty *precision = dynamic_cast(action->GetProperty("PRECISION")); - if (precision != NULL) - { - PRECISION = precision->GetValue(); - } - - int position = pointSet->SearchPoint(worldPoint, PRECISION); - if (position>=0)//found a point near enough to the given point - { - m_LastPosition = position;//store it to be able to move the point - worldPoint = pointSet->GetPoint(position);//get that point, the one meant by the user! - mitk::Point2D displPoint; - displPoint[0] = worldPoint[0]; - displPoint[1] = worldPoint[1]; - - //new Event with information YES and with the correct point - mitk::PositionEvent const* newPosEvent = new mitk::PositionEvent(posEvent->GetSender(), posEvent->GetType(), - posEvent->GetButton(), posEvent->GetButtonState(), posEvent->GetKey(), - displPoint, worldPoint); - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDYES, newPosEvent); - //call HandleEvent to leave the guard-state - this->HandleEvent( newStateEvent ); - ok = true; - } - else - { - //new Event with information NO - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, posEvent); - this->HandleEvent( newStateEvent ); - ok = true; - } - } - else //hardly used, due to 3dPicking of globalInteraction - { - mitk::DisplayPositionEvent const *disPosEvent = dynamic_cast (stateEvent->GetEvent()); - if (disPosEvent != NULL) - {//2d Koordinates for 3D Interaction; return false to redo the last statechange - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, posEvent); - this->HandleEvent( newStateEvent ); - ok = true; - } - } - } - break; - case AcCHECKSELECTED: - //check if the point that was hit before is still hit - { - mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - if (posEvent != NULL) - { - mitk::Point3D worldPoint = posEvent->GetWorldPosition(); - - int PRECISION = 4; - mitk::IntProperty *precision = dynamic_cast(action->GetProperty("precision")); - if (precision != NULL) - { - PRECISION = precision->GetValue(); - } - - int position = pointSet->SearchPoint(worldPoint, PRECISION); - if (position <0)//no point found at the current mouseposition - { - //new Event with information NO - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, posEvent); - this->HandleEvent( newStateEvent ); - ok = true; - break; - } - - //point found at the current mouseposition, so check if this point is the same like before - unsigned int upos = (unsigned int) position;//comparison signed unsigned int - if (upos == m_LastPosition)//found the same point again - { - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDYES, posEvent); - //call HandleEvent to leave the guard-state - this->HandleEvent( newStateEvent ); - ok = true; - } - else - { - //new Event with information NO - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, posEvent); - this->HandleEvent( newStateEvent ); - ok = true; - } - } - else //hardly used, due to 3dPicking of globalInteraction - { - mitk::DisplayPositionEvent const *disPosEvent = dynamic_cast (stateEvent->GetEvent()); - if (disPosEvent != NULL) - {//2d Koordinates for 3D Interaction; return false to redo the last statechange - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, posEvent); - this->HandleEvent( newStateEvent ); - ok = true; - } - } - } - break; - case AcINITMOVEMENT: - { - mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - if (posEvent == NULL) - return false; - - //start of the Movement is stored to calculate the undoCoordinate in FinishMovement - m_LastPoint = posEvent->GetWorldPosition(); - - ok = true; - break; - } - - case AcMOVESELECTED://moves the point - { - mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - if (posEvent == NULL) - return false; - - mitk::Point3D newPoint; - newPoint = posEvent->GetWorldPosition(); - - PointOperation* doOp = new mitk::PointOperation(OpMOVE, newPoint, m_LastPosition); - //execute the Operation - //here no undo is stored. only the start and the end is stored for undo. - m_DataNode->GetData()->ExecuteOperation(doOp); - ok = true; - break; - } - - case AcFINISHMOVEMENT: - { - mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - if (posEvent == NULL) - return false; - - //finish the movement: - // set undo-information and move it to the last position. - mitk::Point3D newPoint; - newPoint = posEvent->GetWorldPosition(); - - PointOperation* doOp = new mitk::PointOperation(OpMOVE, newPoint, m_LastPosition); - if ( m_UndoEnabled ) - { - PointOperation* undoOp = new mitk::PointOperation(OpMOVE, m_LastPoint, m_LastPosition); - OperationEvent *operationEvent = new OperationEvent( m_DataNode->GetData(), doOp, undoOp, "Move point"); - m_UndoController->SetOperationEvent(operationEvent); - } - //execute the Operation - m_DataNode->GetData()->ExecuteOperation(doOp); - - // //increase the GroupEventId, so that the raw-Undo goes to here - //this->IncCurrGroupEventId(); - ok = true; - } - break; -case AcCHECKGREATERONE: - //check if after deleteion the set will be empty - { - if (pointSet->GetSize()>1) - { - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDYES, stateEvent->GetEvent()); - this->HandleEvent( newStateEvent ); - ok = true; - } - else - { - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, stateEvent->GetEvent()); - this->HandleEvent( newStateEvent ); - ok = true; - } - } - break; -case AcSELECTANOTHEROBJECT: - //selects an other Point after one point has been removed - { - /*select the point "position-1", - and if it is the first in list, - then contine at the last in list*/ - if (pointSet->GetSize()>0)//only then a select of a point is possible! - { - if (m_LastPosition > 0)//not the first in list - { - this->SelectPoint( m_LastPosition-1 ); - } - else//it was the first point in list, that was removed, so select the last in list - { - m_LastPosition = pointSet->GetSize()-1;//last in list - SelectPoint( m_LastPosition ); - }//else - }//if - ok = true; - } - break; -case AcREMOVEPOINT: - { - //store the position of the removed point to be able to use it for selection of a next point - //even if more than one point is selected, as long as we select the point befor the first selected point we are ok. - //need to check if empty before select though! - m_LastPosition = pointSet->SearchSelectedPoint(); - - Operation* doOp = new mitk::Operation(OpREMOVEPOINT); - if (m_UndoEnabled) - { - Operation* undoOp = new mitk::Operation(OpINSERTPOINT); - OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp, "Remove point"); - m_UndoController->SetOperationEvent(operationEvent); - } - pointSet->ExecuteOperation(doOp); - ok = true; - } - break; - case AcSELECT: - //select the point found at the given mouseposition - { - mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - if (posEvent == NULL) - return false; - - mitk::Point3D worldPoint = posEvent->GetWorldPosition(); - - //search the point in the list - //distance set to 0, cause we already got the exact point from last State checkpoint - //but we also need the position in the list to move it - int position = pointSet->SearchPoint(worldPoint, 0); - - if (position>=0)//found a point - { - PointOperation* doOp = new mitk::PointOperation(OpSELECTPOINT, worldPoint, position); - - //Undo - if (m_UndoEnabled) //write to UndoMechanism - { - PointOperation* undoOp = new mitk::PointOperation(OpDESELECTPOINT, worldPoint, position); - OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); - m_UndoController->SetOperationEvent(operationEvent); - } - - //execute the Operation - pointSet->ExecuteOperation(doOp); - ok = true; - } - } - break; - case AcDESELECT: - { - mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - if (posEvent == NULL) - return false; - - mitk::Point3D worldPoint = posEvent->GetWorldPosition(); - - //search the point in the list - //distance set to 0, cause we already got the exact point from last State checkpoint - //but we also need the position in the list to move it - int position = pointSet->SearchPoint(worldPoint, 0); - - if (position>=0)//found a point - { - PointOperation* doOp = new mitk::PointOperation(OpDESELECTPOINT, worldPoint, position); - - //Undo - if (m_UndoEnabled) //write to UndoMechanism - { - PointOperation* undoOp = new mitk::PointOperation(OpSELECTPOINT, worldPoint, position); - OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); - m_UndoController->SetOperationEvent(operationEvent); - } - - //execute the Operation - pointSet->ExecuteOperation(doOp); - ok = true; - } - } - break; - case AcSETSTARTPOINT: - { - //get the selected point and assign it as startpoint - Point3D point;//dummy - point.Fill(0); - int position = pointSet->SearchSelectedPoint(); - if (position >-1) - { - PointOperation* doOp = new mitk::PointOperation(OpSETPOINTTYPE, point, position, true, PTSTART); - - //Undo - if (m_UndoEnabled) //write to UndoMechanism - { - PointOperation* undoOp = new mitk::PointOperation(OpSETPOINTTYPE, point, position, true, PTUNDEFINED); - OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); - m_UndoController->SetOperationEvent(operationEvent); - } - - //execute the Operation - pointSet->ExecuteOperation(doOp); - ok = true; - } - } - break; - default: - return Superclass::ExecuteAction( action, stateEvent ); - } - - return ok; - -} - diff --git a/Modules/Ext/Interactions/mitkPointInteractor.h b/Modules/Ext/Interactions/mitkPointInteractor.h deleted file mode 100644 index 2b4ae96e34..0000000000 --- a/Modules/Ext/Interactions/mitkPointInteractor.h +++ /dev/null @@ -1,88 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKPOINTINTERACTOR_H_HEADER_INCLUDED -#define MITKPOINTINTERACTOR_H_HEADER_INCLUDED - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include -#include - -namespace mitk -{ - class DataNode; - - //##Documentation - //## @brief Interaction with a point - //## - //## Interact with a point: set point, select point, move point and remove point - //## All Set-operations are done through the method "ExecuteAction". - //## the identificationnumber of this point is set by this points and evalued from an empty place in the DataStructure - //## @ingroup Interaction - class MitkExt_EXPORT PointInteractor : public Interactor - { - public: - mitkClassMacro(PointInteractor, Interactor); - mitkNewMacro2Param(Self, const char*, DataNode*); - - //##Documentation - //## @brief Sets the amount of precision - void SetPrecision(unsigned int precision); - - //##Documentation - //## @brief derived from mitk::Interactor; calculates Jurisdiction according to points - //## - //## standard method can not be used, since it doesn't calculate in points, only in BoundingBox of Points - virtual float CanHandleEvent(StateEvent const* stateEvent) const; - - - protected: - //##Documentation - //##@brief Constructor - PointInteractor(const char * type, DataNode* dataNode); - - //##Documentation - //##@brief Destructor - virtual ~PointInteractor(); - - //##Documentation - //## @brief select the point on the given position - virtual void SelectPoint(int position); - - //##Documentation - //## @brief unselect all points that exist in mesh - virtual void DeselectAllPoints(); - - //##Documentation - //## @brief Executes Actions - virtual bool ExecuteAction(Action* action, mitk::StateEvent const* stateEvent); - - - private: - - //##Documentation - //## @brief to calculate a direction vector from last point and actual point - Point3D m_LastPoint; - - //##Documentation - //## @brief to store a position - unsigned int m_LastPosition; - - }; -} -#endif /* MITKPOINTINTERACTOR_H_HEADER_INCLUDED */ diff --git a/Modules/Ext/Interactions/mitkPointSelectorInteractor.cpp b/Modules/Ext/Interactions/mitkPointSelectorInteractor.cpp deleted file mode 100644 index 6fa966a4c8..0000000000 --- a/Modules/Ext/Interactions/mitkPointSelectorInteractor.cpp +++ /dev/null @@ -1,407 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkPointSelectorInteractor.h" -#include -#include -#include -//#include "mitkStatusBar.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -mitk::PointSelectorInteractor::PointSelectorInteractor(const char * type, DataNode* dataNode) -: Interactor(type, dataNode), m_LastPosition(0) -{ - m_LastPoint.Fill(0); -} - -mitk::PointSelectorInteractor::~PointSelectorInteractor() -{} - -void mitk::PointSelectorInteractor::SelectPoint(int position) -{ - mitk::PointSet* pointSet = dynamic_cast(m_DataNode->GetData()); - if (pointSet == NULL) - return; - if (pointSet->GetSize()<=0)//if List is empty, then no select of a point can be done! - return; - - mitk::Point3D noPoint;//dummyPoint... not needed anyway - noPoint.Fill(0); - mitk::PointOperation* doOp = new mitk::PointOperation(OpSELECTPOINT, noPoint, position); - if (m_UndoEnabled) - { - mitk::PointOperation* undoOp = new mitk::PointOperation(OpDESELECTPOINT, noPoint, position); - OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); - m_UndoController->SetOperationEvent(operationEvent); - } - pointSet->ExecuteOperation(doOp); -} - -void mitk::PointSelectorInteractor::DeselectAllPoints() -{ - mitk::PointSet* pointSet = dynamic_cast(m_DataNode->GetData()); - if (pointSet == NULL) - return; - - mitk::PointSet::DataType *itkPointSet = pointSet->GetPointSet(); - mitk::PointSet::PointsContainer::Iterator it, end; - end = itkPointSet->GetPoints()->End(); - - for (it = itkPointSet->GetPoints()->Begin(); it != end; it++) - { - int position = it->Index(); - PointSet::PointDataType pointData = {0, false, PTUNDEFINED}; - itkPointSet->GetPointData(position, &pointData); - if ( pointData.selected )//then declare an operation which unselects this point; UndoOperation as well! - { - mitk::Point3D noPoint; - noPoint.Fill(0); - - mitk::PointOperation* doOp = new mitk::PointOperation(OpDESELECTPOINT, noPoint, position); - if (m_UndoEnabled) - { - mitk::PointOperation* undoOp = new mitk::PointOperation(OpSELECTPOINT, noPoint, position); - OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); - m_UndoController->SetOperationEvent(operationEvent); - } - pointSet->ExecuteOperation(doOp); - } - } -} - -float mitk::PointSelectorInteractor::CanHandleEvent(StateEvent const* stateEvent) const -//go through all points and check, if the given Point lies near a line -{ - float returnValue = 0; - - mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - //checking if a keyevent can be handled: - if (posEvent == NULL) - { - //check, if the current state has a transition waiting for that key event. - if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) - { - return 0.5; - } - else - { - return 0; - } - } - - //Mouse event handling: - //on MouseMove do nothing! reimplement if needed differently - if (stateEvent->GetEvent()->GetType() == mitk::Type_MouseMove) - { - return 0; - } - - //if the event can be understood and if there is a transition waiting for that event - if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) - { - returnValue = 0.5;//it can be understood - } - - //check on the right data-type - mitk::PointSet* pointSet = dynamic_cast(m_DataNode->GetData()); - if (pointSet == NULL) - return 0; - - - //since we now have 3D picking in GlobalInteraction and all events send are DisplayEvents with 3D information, - //we concentrate on 3D coordinates - mitk::Point3D worldPoint = posEvent->GetWorldPosition(); - float p[3]; - itk2vtk(worldPoint, p); - //transforming the Worldposition to local coordinatesystem - m_DataNode->GetData()->GetGeometry()->GetVtkTransform()->GetInverse()->TransformPoint(p, p); - vtk2itk(p, worldPoint); - - float distance = 5; - int index = pointSet->SearchPoint(worldPoint, distance); - if (index>-1) - //how far away is the line from the point? - { - //get the point and calculate the jurisdiction out of it. - mitk::PointSet::PointType point; - pointSet->GetPointSet()->GetPoint(index, &point); - returnValue = point.EuclideanDistanceTo(worldPoint); - - //between 1 and 0. 1 if directly hit - returnValue = 1 - ( returnValue / distance ); - if (returnValue<0 || returnValue>1) - { - itkWarningMacro("Difficulties in calculating Jurisdiction. Check PointSelectorInteractor"); - return 0; - } - - //and now between 0,5 and 1 - returnValue = 0.5 + (returnValue / 2); - - return returnValue; - } - else //not found - { - return returnValue; - } - -} - - -bool mitk::PointSelectorInteractor::ExecuteAction( Action* action, mitk::StateEvent const* stateEvent ) -{ - bool ok = false;//for return type bool - - //checking corresponding Data; has to be a PointSet or a subclass - mitk::PointSet* pointSet = dynamic_cast(m_DataNode->GetData()); - if (pointSet == NULL) - return false; - - //for reading on the points, Id's etc - //mitk::PointSet::DataType *itkPointSet = pointSet->GetPointSet(); - //mitk::PointSet::PointsContainer *itkPoints = itkPointSet->GetPoints(); - - /*Each case must watch the type of the event!*/ - switch (action->GetActionId()) - { - case AcADDPOINT: - break; - case AcDESELECTALL: - this->DeselectAllPoints(); - ok = true; - break; - case AcCHECKELEMENT : - /*checking if the Point transmitted is close enough to one point. Then generate a new event with the point and let this statemaschine handle the event.*/ - { - mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - if (posEvent != NULL) - { - mitk::Point3D worldPoint = posEvent->GetWorldPosition(); - - int PRECISION = 4; - mitk::IntProperty *precision = dynamic_cast(action->GetProperty("PRECISION")); - if (precision != NULL) - { - PRECISION = precision->GetValue(); - } - - int position = pointSet->SearchPoint(worldPoint, PRECISION); - if (position>=0)//found a point near enough to the given point - { - m_LastPosition = position;//store it to be able to move the point - worldPoint = pointSet->GetPoint(position);//get that point, the one meant by the user! - mitk::Point2D displPoint; - displPoint[0] = worldPoint[0]; - displPoint[1] = worldPoint[1]; - - //new Event with information YES and with the correct point - mitk::PositionEvent const* newPosEvent = new mitk::PositionEvent(posEvent->GetSender(), posEvent->GetType(), - posEvent->GetButton(), posEvent->GetButtonState(), posEvent->GetKey(), - displPoint, worldPoint); - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDYES, newPosEvent); - //call HandleEvent to leave the guard-state - this->HandleEvent( newStateEvent ); - ok = true; - } - else - { - //new Event with information NO - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, posEvent); - this->HandleEvent( newStateEvent ); - ok = true; - } - } - else //hardly used, due to 3dPicking of globalInteraction - { - mitk::DisplayPositionEvent const *disPosEvent = dynamic_cast (stateEvent->GetEvent()); - if (disPosEvent != NULL) - {//2d Koordinates for 3D Interaction; return false to redo the last statechange - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, posEvent); - this->HandleEvent( newStateEvent ); - ok = true; - } - } - } - break; - case AcCHECKSELECTED: - //check if the point that was hit before is still hit - { - mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - if (posEvent != NULL) - { - mitk::Point3D worldPoint = posEvent->GetWorldPosition(); - - int PRECISION = 4; - mitk::IntProperty *precision = dynamic_cast(action->GetProperty("precision")); - if (precision != NULL) - { - PRECISION = precision->GetValue(); - } - - int position = pointSet->SearchPoint(worldPoint, PRECISION); - if (position <0)//no point found at the current mouseposition - { - //new Event with information NO - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, posEvent); - this->HandleEvent( newStateEvent ); - ok = true; - break; - } - - //point found at the current mouseposition, so check if this point is the same like before - unsigned int upos = (unsigned int) position;//comparison signed unsigned int - if (upos == m_LastPosition)//found the same point again - { - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDYES, posEvent); - //call HandleEvent to leave the guard-state - this->HandleEvent( newStateEvent ); - ok = true; - } - else - { - //new Event with information NO - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, posEvent); - this->HandleEvent( newStateEvent ); - ok = true; - } - } - else //hardly used, due to 3dPicking of globalInteraction - { - mitk::DisplayPositionEvent const *disPosEvent = dynamic_cast (stateEvent->GetEvent()); - if (disPosEvent != NULL) - {//2d Koordinates for 3D Interaction; return false to redo the last statechange - mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, posEvent); - this->HandleEvent( newStateEvent ); - ok = true; - } - } - } - break; - case AcINITMOVEMENT: - break; - case AcMOVESELECTED://moves the point - break; - case AcFINISHMOVEMENT: - break; - case AcCHECKGREATERONE: - break; - case AcSELECTANOTHEROBJECT: - //selects an other Point after one point has been removed - { - /*select the point "position-1", - and if it is the first in list, - then contine at the last in list*/ - if (pointSet->GetSize()>0)//only then a select of a point is possible! - { - if (m_LastPosition > 0)//not the first in list - { - this->SelectPoint( m_LastPosition-1 ); - } - else//it was the first point in list, that was removed, so select the last in list - { - m_LastPosition = pointSet->GetSize()-1;//last in list - SelectPoint( m_LastPosition ); - }//else - }//if - ok = true; - } - break; - case AcREMOVEPOINT: - break; - case AcSELECT: - //select the point found at the given mouseposition - { - mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - if (posEvent == NULL) - return false; - - mitk::Point3D worldPoint = posEvent->GetWorldPosition(); - - //search the point in the list - //distance set to 0, cause we already got the exact point from last State checkpoint - //but we also need the position in the list to move it - int position = pointSet->SearchPoint(worldPoint, 0); - - if (position>=0)//found a point - { - PointOperation* doOp = new mitk::PointOperation(OpSELECTPOINT, worldPoint, position); - - //Undo - if (m_UndoEnabled) //write to UndoMechanism - { - PointOperation* undoOp = new mitk::PointOperation(OpDESELECTPOINT, worldPoint, position); - OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); - m_UndoController->SetOperationEvent(operationEvent); - } - - //execute the Operation - pointSet->ExecuteOperation(doOp); - ok = true; - } - } - break; - case AcDESELECT: - { - mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); - if (posEvent == NULL) - return false; - - mitk::Point3D worldPoint = posEvent->GetWorldPosition(); - - //search the point in the list - //distance set to 0, cause we already got the exact point from last State checkpoint - //but we also need the position in the list to move it - int position = pointSet->SearchPoint(worldPoint, 0); - - if (position>=0)//found a point - { - PointOperation* doOp = new mitk::PointOperation(OpDESELECTPOINT, worldPoint, position); - - //Undo - if (m_UndoEnabled) //write to UndoMechanism - { - PointOperation* undoOp = new mitk::PointOperation(OpSELECTPOINT, worldPoint, position); - OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); - m_UndoController->SetOperationEvent(operationEvent); - } - - //execute the Operation - pointSet->ExecuteOperation(doOp); - ok = true; - } - } - break; - case AcSETSTARTPOINT: - break; - default: - return Superclass::ExecuteAction( action, stateEvent ); - } - - return ok; - -} - - diff --git a/Modules/Ext/Interactions/mitkPointSelectorInteractor.h b/Modules/Ext/Interactions/mitkPointSelectorInteractor.h deleted file mode 100644 index 05adfa433e..0000000000 --- a/Modules/Ext/Interactions/mitkPointSelectorInteractor.h +++ /dev/null @@ -1,88 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKPOINTSELECTORINTERACTOR_H_HEADER_INCLUDED -#define MITKPOINTSELECTORINTERACTOR_H_HEADER_INCLUDED - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include -#include - -namespace mitk -{ - class DataNode; - - //##Documentation - //## @brief Just select a point, that's the only way to interact with the point - //## - //## Interact with a point: Select the point without moving to get parameters that does not change - //## All Set-operations would be done through the method "ExecuteAction", if there would be anyone. - //## the identificationnumber of this point is set by this points and evalued from an empty place in the DataStructure - //## @ingroup Interaction - class MitkExt_EXPORT PointSelectorInteractor : public Interactor - { - public: - mitkClassMacro(PointSelectorInteractor, Interactor); - mitkNewMacro2Param(Self, const char*, DataNode*); - - //##Documentation - //## @brief Sets the amount of precision - void SetPrecision(unsigned int precision); - - //##Documentation - //## @brief derived from mitk::Interactor; calculates Jurisdiction according to points - //## - //## standard method can not be used, since it doesn't calculate in points, only in BoundingBox of Points - virtual float CanHandleEvent(StateEvent const* stateEvent) const; - - - protected: - //##Documentation - //##@brief Constructor - PointSelectorInteractor(const char * type, DataNode* dataNode); - - //##Documentation - //##@brief Destructor - virtual ~PointSelectorInteractor(); - - //##Documentation - //## @brief select the point on the given position - virtual void SelectPoint(int position); - - //##Documentation - //## @brief unselect all points that exist in mesh - virtual void DeselectAllPoints(); - - //##Documentation - //## @brief Executes Actions - virtual bool ExecuteAction(Action* action, mitk::StateEvent const* stateEvent); - - - private: - - //##Documentation - //## @brief to calculate a direction vector from last point and actual point - Point3D m_LastPoint; - - //##Documentation - //## @brief to store a position - unsigned int m_LastPosition; - - }; -} -#endif /* MITKPointSelectorInteractor_H_HEADER_INCLUDED */ diff --git a/Modules/Ext/Interactions/mitkSeedsInteractor.cpp b/Modules/Ext/Interactions/mitkSeedsInteractor.cpp deleted file mode 100644 index 09636e81ac..0000000000 --- a/Modules/Ext/Interactions/mitkSeedsInteractor.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkSeedsInteractor.h" - -#include "mitkProperties.h" -#include "mitkStringProperty.h" -#include "mitkAction.h" -#include "mitkDisplayPositionEvent.h" -#include "mitkOperationEvent.h" -#include "mitkInteractionConst.h" -#include "mitkUndoController.h" -#include "mitkDataNode.h" -#include "mitkStateEvent.h" -#include "mitkState.h" -#include "mitkDrawOperation.h" - - -mitk::SeedsInteractor::SeedsInteractor(const char * type, mitk::DataNode* dataNode) - : mitk::Interactor(type, dataNode) -{ - m_Radius = 1; - m_Config = 0; // default config 254, 255 are added for fore- and backgrund seeds - m_CurrentDrawState = 255; -} - -mitk::SeedsInteractor::~SeedsInteractor() -{ -} - - -bool mitk::SeedsInteractor::ExecuteAction(mitk::Action* action, mitk::StateEvent const* stateEvent) -{ - const mitk::DisplayPositionEvent* posEvent = dynamic_cast(stateEvent->GetEvent()); - if (posEvent == NULL) - return false; - - event_point = posEvent->GetWorldPosition(); - - m_DataNode->SetVisibility(true); - m_SeedsImage = dynamic_cast(m_DataNode->GetData()); - - - bool ok = false; - switch (action->GetActionId()) - { - case mitk::AcINITFOREGROUND: - { - if (m_Config == 0) m_DrawState = m_CurrentDrawState; - else m_DrawState = 1; - ok = true; - break; - } - case mitk::AcINITBACKGROUND: - { - if (m_Config == 0) m_DrawState = 254; - else m_DrawState = -1; - ok = true; - break; - } - case mitk::AcINITNEUTRAL: - { - m_DrawState = 0; - ok = true; - break; - } - case mitk::AcADD: - { - last_point = event_point; - mitk::DrawOperation* doOp = new mitk::DrawOperation(OpADD, event_point, last_point, m_DrawState, m_Radius); - if (m_UndoEnabled){ //write to UndoMechanism/ Can probably be removed! - mitk::DrawOperation* undoOp = new mitk::DrawOperation(OpUNDOADD, event_point, last_point, m_DrawState, m_Radius); - mitk::OperationEvent *operationEvent = new mitk::OperationEvent(m_SeedsImage, doOp, undoOp, "Add seed point"); - m_UndoController->SetOperationEvent(operationEvent); - } - //execute the Operation - m_SeedsImage->ExecuteOperation(doOp); - ok = true; - break; - } - case mitk::AcMOVE: - { - last_point = event_point; - mitk::DrawOperation* doOp = new mitk::DrawOperation(OpMOVE, event_point, last_point, m_DrawState, m_Radius); - if (m_UndoEnabled){ //write to UndoMechanism/ Can probably be removed! - mitk::DrawOperation* undoOp = new mitk::DrawOperation(OpUNDOMOVE, event_point, last_point, m_DrawState, m_Radius); - mitk::OperationEvent *operationEvent = new mitk::OperationEvent(m_SeedsImage, doOp, undoOp, "Move seed point"); - m_UndoController->SetOperationEvent(operationEvent); - } - //execute the Operation - m_SeedsImage->ExecuteOperation(doOp); - ok = true; - //this->Modified(); - break; - } - case mitk::AcFINISH: - { - last_point = event_point; - ok = true; - this->Modified(); - - this->InvokeEvent( itk::EndEvent() ); - - break; - } - default: - return Superclass::ExecuteAction( action, stateEvent ); - } - return ok; -} diff --git a/Modules/Ext/Interactions/mitkSeedsInteractor.h b/Modules/Ext/Interactions/mitkSeedsInteractor.h deleted file mode 100644 index cb9011f359..0000000000 --- a/Modules/Ext/Interactions/mitkSeedsInteractor.h +++ /dev/null @@ -1,78 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef __SeedsInteractor_H -#define __SeedsInteractor_H - -#include -#include "MitkExtExports.h" -#include -#include -#include //needed by QmitkSimplexMeshes (SMDeformation.cpp and LungSegmentation.cpp) -#include -#include - - -namespace mitk { - - //##Documentation - //## @brief SeedsInteractor handles all actions on the seedsimage - //## @ingroup Interaction - - /** - * \deprecatedSince{2014_03} mitk::ConnectPointsInteractor is deprecated. Needs to be updated to the new interaction-framework. - * Refer to \see DataInteractionPage for general information about the concept of the new implementation. - */ - - class DEPRECATED() MitkExt_EXPORT SeedsInteractor : public Interactor - { - public: - mitkClassMacro(SeedsInteractor, Interactor); - mitkNewMacro2Param(Self, const char*, DataNode*); - - /// sets the radius of the seeds. - void SetRadius(int val){m_Radius=val;}; - void SetCurrentDrawState(int val){m_CurrentDrawState = val;}; - - itkSetMacro(Config, unsigned int); - itkGetMacro(Config, unsigned int); - - protected: - /** - * @brief Default Constructor - **/ - SeedsInteractor(const char * type, DataNode* dataNode); - /** - * @brief Default Destructor - **/ - virtual ~SeedsInteractor(); - - virtual bool ExecuteAction(Action* action, StateEvent const* stateEvent); - - protected: - SeedsImage::Pointer m_SeedsImage; - SeedsImage::Pointer m_LastSeedsImage; - Point3D event_point; - Point3D last_point; - - int m_Radius; - int m_DrawState; - int m_CurrentDrawState; - unsigned int m_Config; // determine whether 254,255 or smoothed float values are used. - }; - -} -#endif //__SeedsInteractor_H diff --git a/Modules/Ext/Interactions/mitkSocketClient.cpp b/Modules/Ext/Interactions/mitkSocketClient.cpp deleted file mode 100644 index 5ddbb43322..0000000000 --- a/Modules/Ext/Interactions/mitkSocketClient.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkSocketClient.h" -#include -#include -#include - -namespace mitk -{ - - SocketClientImplementation* SocketClient::m_Implementation = NULL; - SocketClient* SocketClient::m_Instance = NULL; - - void SocketClient::open( const char* ipAdress, unsigned short port ) - { - if (m_Implementation) - { - m_Implementation->open( ipAdress, port ); - } - } - - void SocketClient::setMaxConnectionAdvance( int maxConnectionAdvance ) - { - if (m_Implementation) - { - m_Implementation->setMaxConnectionAdvance( maxConnectionAdvance ); - } - } - - bool SocketClient::send( unsigned int messagetype, unsigned int bodySize, char* body ) - { - if (m_Implementation) - { - return m_Implementation->send( messagetype, bodySize, body); - } - else - { - return false; - } - } - - void SocketClient::SetImplementationInstance(SocketClientImplementation* implementation) - { - if ( m_Implementation == implementation ) - { - return; - } - m_Implementation = implementation; - } - - SocketClient* SocketClient::GetInstance() - { - if (m_Instance == NULL) - { - m_Instance = new SocketClient(); - } - - return m_Instance; - } - - SocketClient::SocketClient() - { - } - - SocketClient::~SocketClient() - { - } -}//end namespace mitk diff --git a/Modules/Ext/Interactions/mitkSocketClient.h b/Modules/Ext/Interactions/mitkSocketClient.h deleted file mode 100644 index 8b6fdf1e04..0000000000 --- a/Modules/Ext/Interactions/mitkSocketClient.h +++ /dev/null @@ -1,63 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKSOCKETCLIENT_H -#define MITKSOCKETCLIENT_H -#include -#include "MitkExtExports.h" -#include "mitkCommon.h" - -#include "mitkSocketClientImplementation.h" - - -namespace mitk -{ - - //##Documentation - //## @brief Sending a message to the applications ProgressBar - //## - //## Holds a GUI dependent ProgressBarImplementation and sends the progress further. - //## All mitk-classes use this class to display progress on GUI-ProgressBar. - //## The mainapplication has to set the internal held ProgressBarImplementation with SetImplementationInstance(..). - //## @ingroup Interaction - class MitkExt_EXPORT SocketClient : public itk::Object - { - - public: - - itkTypeMacro(ProgressBar, itk::Object); - - static SocketClient* GetInstance(); - - static void SetImplementationInstance(SocketClientImplementation* implementation); - - void open( const char* ipAdress, unsigned short port ); - - void setMaxConnectionAdvance( int maxConnectionAdvance ); - - bool send( unsigned int messagetype, unsigned int bodySize = 0, char* body = NULL ); - - protected: - SocketClient(); - virtual ~SocketClient(); - static SocketClientImplementation* m_Implementation; - static SocketClient* m_Instance; - }; - -}// end namespace mitk - -#endif /* define MITKSOCKETCLIENT_H */ diff --git a/Modules/Ext/Interactions/mitkSocketClientImplementation.h b/Modules/Ext/Interactions/mitkSocketClientImplementation.h deleted file mode 100644 index f52ab15bce..0000000000 --- a/Modules/Ext/Interactions/mitkSocketClientImplementation.h +++ /dev/null @@ -1,51 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKSOCKETCLIENTIMPLEMENTATION_H -#define MITKSOCKETCLIENTIMPLEMENTATION_H - -#include "mitkCommon.h" -#include "MitkExtExports.h" - -namespace mitk -{ - - //##Documentation - //## @brief GUI indepentent Interface for all Gui depentent implementations of a ProgressBar. - class MitkExt_EXPORT SocketClientImplementation - { - - public: - - //##Documentation - //## @brief Constructor - SocketClientImplementation(){}; - - //##Documentation - //## @brief Destructor - virtual ~SocketClientImplementation(){}; - - virtual void open( const char* ipAdress, unsigned short port )=0; - - virtual void setMaxConnectionAdvance( int maxConnectionAdvance )=0; - - virtual bool send( unsigned int messagetype, unsigned int bodySize = 0, char* body = NULL )=0; - }; - -}// end namespace mitk - -#endif /* define MITKSOCKETCLIENTIMPLEMENTATION_H */ diff --git a/Modules/Ext/Interactions/mitkSpaceNavigatorDriver.cpp b/Modules/Ext/Interactions/mitkSpaceNavigatorDriver.cpp deleted file mode 100644 index ab8dfc11dd..0000000000 --- a/Modules/Ext/Interactions/mitkSpaceNavigatorDriver.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#define SPACE_NAVIGATOR_MAIN_SOURCE - -#include "mitkSpaceNavigatorDriver.h" -#include "mitkTDMouseEventThrower.h" - -SpaceNavigatorDriver* SpaceNavigatorDriver::GetInstance() -{ - //create the singleton instance of the driver, so it can listen for events - static SpaceNavigatorDriver instance; - return &instance; -} - -SpaceNavigatorDriver::SpaceNavigatorDriver() -{ - LRESULT result=0; - - HRESULT hr=::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED ); - if (!SUCCEEDED(hr)) - { - cout << "Fehler" << endl; - - // stop creation of window - result = -1; - } - else - { - HRESULT hr = InitializeCOM(); - if (!SUCCEEDED(hr)) - { - // stop creation of window - result = -1; - } - } -} - -SpaceNavigatorDriver::~SpaceNavigatorDriver() -{ - UninitializeCOM(); -} - -inline HRESULT SpaceNavigatorDriver::HookEvent1(CComPtr device) -{ - // Get the interfaces to the sensor and the keyboard; - return device->get_Sensor(&m_pISensor); -} - -inline HRESULT SpaceNavigatorDriver::HookEvent2() -{ - return __hook(&_ISensorEvents::SensorInput, m_pISensor, - &SpaceNavigatorDriver::OnSensorInput); -} - -inline HRESULT SpaceNavigatorDriver::HookEvent3(CComPtr device) -{ - return device->get_Keyboard(&m_pIKeyboard); -} - -inline HRESULT SpaceNavigatorDriver::HookEvent4() -{ - return __hook(&_IKeyboardEvents::KeyDown, m_pIKeyboard, - &SpaceNavigatorDriver::OnKeyDown); -} - -inline HRESULT SpaceNavigatorDriver::HookEvent5() -{ - return __hook(&_IKeyboardEvents::KeyUp, m_pIKeyboard, - &SpaceNavigatorDriver::OnKeyUp); -} - - - -HRESULT SpaceNavigatorDriver::InitializeCOM() -{ - HRESULT hr; - CComPtr _3DxDevice; - - // Create the device object - hr = _3DxDevice.CoCreateInstance(__uuidof(Device)); - if (SUCCEEDED(hr)) - { - - CComPtr _3DxSimpleDevice; - - hr = _3DxDevice.QueryInterface(&_3DxSimpleDevice); - if (SUCCEEDED(hr)) - { - hr = __hook(&_ISimpleDeviceEvents::DeviceChange, _3DxSimpleDevice, - &SpaceNavigatorDriver::OnDeviceChange); - - //workaround for .net 2003 Bug Nr. 829749 - hr = this->HookEvent1(_3DxSimpleDevice); - hr = this->HookEvent2(); - hr = this->HookEvent3(_3DxSimpleDevice); - hr = this->HookEvent4(); - hr = this->HookEvent5(); - - // Connect to the driver - _3DxSimpleDevice->Connect(); - - cout << "Connected to COM-object for space navigation..." << endl; - } - } - else - cout << "CoCreateInstance failed"; - - return hr; -} - -HRESULT SpaceNavigatorDriver::OnDeviceChange(long reserved ) -{ - HRESULT result = S_OK; - //cout << "SpaceNavigatorDriver::OnDeviceChange(reserved =0" << reserved << endl; - - HRESULT hr; - ISimpleDevicePtr _p3DxDevice; - hr = m_pIKeyboard->get_Device((IDispatch**)&_p3DxDevice); - if (SUCCEEDED(hr)) - { - long device; - _p3DxDevice->get_Type(&device); - //cout << "Attached device=" << device; - _p3DxDevice.Release(); - - long keys, programmableKeys; - m_pIKeyboard->get_Keys(&keys); - m_pIKeyboard->get_ProgrammableKeys(&programmableKeys); - //cout << "Number of Keys=%d\tProgrammable keys=%d\n" << keys << " / " << programmableKeys; - - for (long i=1; i<=keys; i++) - { - BSTR bstrLabel; - BSTR bstrName; - m_pIKeyboard->GetKeyLabel(i, &bstrLabel); - m_pIKeyboard->GetKeyName(i, &bstrName); - CString strLabel(bstrLabel); - CString strName(bstrName); - - //cout << "Key Label=%s\tKey Name=%s\n" << - //(const TCHAR *)strLabel << " / " << (const TCHAR *)strName; - - } - mitk::TDMouseEventThrower::GetInstance()->DeviceChange (device, keys, programmableKeys); - } - return result; -} - -HRESULT SpaceNavigatorDriver::OnKeyDown(int keyCode ) -{ - HRESULT result = S_OK; - mitk::TDMouseEventThrower::GetInstance()->KeyDown (keyCode); - return result; -} - -HRESULT SpaceNavigatorDriver::OnKeyUp(int keyCode ) -{ - HRESULT result = S_OK; - mitk::TDMouseEventThrower::GetInstance()->KeyUp (keyCode); - return result; -} - -#define ScaleRotation 1024.0 -#define ScaleTranslation 512.0 -#define Sensitivity 1.0 - -HRESULT SpaceNavigatorDriver::OnSensorInput(void) -{ - HRESULT result = S_OK; - static DWORD s_dwLastDraw = 0; - - //cout << "CCubeWindow::OnSensorInput()"; - try { - CComPtr pRotation; - HRESULT hr = m_pISensor->get_Rotation(&pRotation); - - double angle; - pRotation->get_Angle(&angle); - - CComPtr pTranslation; - hr = m_pISensor->get_Translation(&pTranslation); - - double length; - pTranslation->get_Length(&length); - - if (angle > 0. || length > 0.) - { - mitk::Vector3D translation; - mitk::Vector3D rotation; - double val; - - double timeFactor = 1.; - - DWORD dwNow = ::GetTickCount(); - if (s_dwLastDraw) - { - double period; - m_pISensor->get_Period(&period); - timeFactor = (double)(dwNow-s_dwLastDraw)/period; - } - s_dwLastDraw = dwNow; - - length *= timeFactor; - length /= ScaleTranslation*Sensitivity; - - pTranslation->put_Length(length); - - pTranslation->get_X(&val); - translation[0] = (float)val; - pTranslation->get_Y(&val); - translation[1] = (float)val; - pTranslation->get_Z(&val); - translation[2] = (float)val; - - pRotation->get_X(&val); - rotation[0] = (float)val; - pRotation->get_Y(&val); - rotation[1] = (float)val; - pRotation->get_Z(&val); - rotation[2] = (float)val; - - angle *= timeFactor; - angle /= ScaleRotation*Sensitivity; - - mitk::TDMouseEventThrower::GetInstance()->SensorInput( translation, rotation, angle); - //cout << translation[0] << "\t" << translation[1] << "\t" << translation[2] << endl; - } - else - s_dwLastDraw = 0; - - pRotation.Release(); - pTranslation.Release(); - } - catch (...) - { - cout << "Some sort of exception handling" << endl; - } - - return result; -} - -HRESULT SpaceNavigatorDriver::UninitializeCOM() -{ - HRESULT hr; - CComPtr _3DxDevice; - - // Create the device object - hr = _3DxDevice.CoCreateInstance(__uuidof(Device)); - if (SUCCEEDED(hr)) - { - CComPtr _3DxSimpleDevice; - _3DxDevice.QueryInterface(&_3DxSimpleDevice); - _3DxSimpleDevice->Disconnect(); - } - - - if (m_pISensor) - { - // unhook (unadvise) the sensor event sink - __unhook(&_ISensorEvents::SensorInput, m_pISensor, - &SpaceNavigatorDriver::OnSensorInput); - - m_pISensor.Release(); - } - - if (m_pIKeyboard) - { - __unhook(&_IKeyboardEvents::KeyDown, m_pIKeyboard, - &SpaceNavigatorDriver::OnKeyDown); - - m_pIKeyboard.Release(); - } - - return hr; -} diff --git a/Modules/Ext/Interactions/mitkSurfaceDeformationInteractor3D.cpp b/Modules/Ext/Interactions/mitkSurfaceDeformationInteractor3D.cpp deleted file mode 100644 index f385279407..0000000000 --- a/Modules/Ext/Interactions/mitkSurfaceDeformationInteractor3D.cpp +++ /dev/null @@ -1,498 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkSurfaceDeformationInteractor3D.h" -#include "mitkPointOperation.h" -#include "mitkDisplayPositionEvent.h" -#include "mitkWheelEvent.h" -#include "mitkStatusBar.h" -#include "mitkDataNode.h" -#include "mitkInteractionConst.h" -#include "mitkAction.h" -#include "mitkStateEvent.h" -#include "mitkOperationEvent.h" -#include "mitkUndoController.h" -#include "mitkStateMachineFactory.h" -#include "mitkStateTransitionOperation.h" -#include "mitkBaseRenderer.h" -#include "mitkRenderingManager.h" -#include "mitkSurface.h" - - -#include -#include -#include -#include -#include -#include -#include -#include - - -//how precise must the user pick the point -//default value -mitk::SurfaceDeformationInteractor3D -::SurfaceDeformationInteractor3D(const char * type, DataNode* dataNode, int /* n */ ) -: Interactor( type, dataNode ), - m_Precision( 6.5 ), - m_PickedSurfaceNode( NULL ), - m_PickedSurface( NULL ), - m_GaussSigma( 30.0 ) -{ - m_OriginalPolyData = vtkPolyData::New(); - - // Initialize vector arithmetic - m_ObjectNormal[0] = 0.0; - m_ObjectNormal[1] = 0.0; - m_ObjectNormal[2] = 1.0; -} - -mitk::SurfaceDeformationInteractor3D::~SurfaceDeformationInteractor3D() -{ - m_OriginalPolyData->Delete(); -} - -void mitk::SurfaceDeformationInteractor3D::SetPrecision( mitk::ScalarType precision ) -{ - m_Precision = precision; -} - -// Overwritten since this class can handle it better! -float mitk::SurfaceDeformationInteractor3D -::CanHandleEvent(StateEvent const* stateEvent) const -{ - float returnValue = 0.5; - - - // If it is a key event that can be handled in the current state, - // then return 0.5 - mitk::DisplayPositionEvent const *disPosEvent = - dynamic_cast (stateEvent->GetEvent()); - - // Key event handling: - if (disPosEvent == NULL) - { - // Check if the current state has a transition waiting for that key event. - if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) - { - return 0.5; - } - else - { - return 0.0; - } - } - - //on MouseMove do nothing! - //if (stateEvent->GetEvent()->GetType() == mitk::Type_MouseMove) - //{ - // return 0.0; - //} - - //if the event can be understood and if there is a transition waiting for that event - if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) - { - returnValue = 0.5;//it can be understood - } - - //int timeStep = disPosEvent->GetSender()->GetTimeStep(); - - //mitk::CurveModel *curveModel = dynamic_cast( - // m_DataNode->GetData() ); - - //if ( curveModel != NULL ) - //{ - // // Get the PlaneGeometry of the window the user interacts with (for 2D point - // // projection) - // mitk::BaseRenderer *renderer = stateEvent->GetEvent()->GetSender(); - // const PlaneGeometry *projectionPlane = renderer->GetCurrentWorldPlaneGeometry(); - - // // For reading on the points, Ids etc - // //mitk::CurveModel::PointSetType *pointSet = curveModel->GetPointSet( timeStep ); - // //if ( pointSet == NULL ) - // //{ - // // return 0.0; - // //} - - //} - return returnValue; -} - - -bool mitk::SurfaceDeformationInteractor3D -::ExecuteAction( Action *action, mitk::StateEvent const *stateEvent ) -{ - bool ok = false; - - // Get data object - mitk::BaseData *data = m_DataNode->GetData(); - if ( data == NULL ) - { - MITK_ERROR << "No data object present!"; - return ok; - } - - // Get mitk::Event and extract renderer - const mitk::Event *event = stateEvent->GetEvent(); - mitk::BaseRenderer *renderer = NULL; - vtkRenderWindow *renderWindow = NULL; - vtkRenderWindowInteractor *renderWindowInteractor = NULL; - - if ( event != NULL ) - { - renderer = event->GetSender(); - if ( renderer != NULL ) - { - renderWindow = renderer->GetRenderWindow(); - if ( renderWindow != NULL ) - { - renderWindowInteractor = renderWindow->GetInteractor(); - } - } - } - - // Check if we have a DisplayPositionEvent - const mitk::DisplayPositionEvent *dpe = - dynamic_cast< const mitk::DisplayPositionEvent * >( stateEvent->GetEvent() ); - if ( dpe != NULL ) - { - m_PickedSurfaceNode = dpe->GetPickedObjectNode(); - m_CurrentPickedPoint = dpe->GetWorldPosition(); - m_CurrentPickedDisplayPoint = dpe->GetDisplayPosition(); - } - - - // Get the timestep to also support 3D+t - int timeStep = 0; - mitk::ScalarType timeInMS = 0.0; - if ( renderer != NULL ) - { - timeStep = renderer->GetTimeStep( data ); - timeInMS = renderer->GetTime(); - } - - // Extract surface - m_Surface = dynamic_cast< Surface * >( data ); - if ( m_Surface != NULL ) - { - m_PolyData = m_Surface->GetVtkPolyData( timeStep ); - } - else - { - m_PolyData = NULL; - } - - // Extract surface normal from surface (if existent, otherwise use default) - vtkPointData *pointData = m_PolyData->GetPointData(); - if ( pointData != NULL ) - { - vtkDataArray *normal = m_PolyData->GetPointData()->GetVectors( "planeNormal" ); - if ( normal != NULL ) - { - m_ObjectNormal[0] = normal->GetComponent( 0, 0 ); - m_ObjectNormal[1] = normal->GetComponent( 0, 1 ); - m_ObjectNormal[2] = normal->GetComponent( 0, 2 ); - } - } - - // Get geometry object - m_Geometry = data->GetGeometry( timeStep ); - - - // Make sure that the data (if time-resolved) has enough entries; - // if not, create the required extra ones (empty) - data->Expand( timeStep+1 ); - - - switch (action->GetActionId()) - { - case AcDONOTHING: - ok = true; - break; - - - case AcCHECKOBJECT: - { - // Check if an object is present at the current mouse position - m_PickedSurface = NULL; - m_PickedPolyData = NULL; - - if ( m_PickedSurfaceNode != NULL ) - { - m_PickedSurface = dynamic_cast< mitk::Surface * >( m_PickedSurfaceNode->GetData() ); - if ( m_PickedSurface != NULL ) - { - m_PickedPolyData = m_PickedSurface->GetVtkPolyData( timeStep ); - } - } - - mitk::StateEvent *newStateEvent; - if ( (m_PickedSurfaceNode == m_DataNode) && (m_PickedSurface != NULL) ) - { - // Yes: object will be selected - newStateEvent = new mitk::StateEvent( EIDYES ); - - // Disable VTK interactor until MITK interaction has been completed - if ( renderWindowInteractor != NULL ) - { - renderWindowInteractor->Disable(); - } - } - else - { - // No: back to start state - newStateEvent = new mitk::StateEvent( EIDNO ); - - // Re-enable VTK interactor (may have been disabled previously) - if ( renderWindowInteractor != NULL ) - { - renderWindowInteractor->Enable(); - } - } - - this->HandleEvent( newStateEvent ); - - // Colorized surface at current picked position - m_SurfaceColorizationCenter = m_CurrentPickedPoint; - - ok = true; - break; - } - - case AcDESELECTOBJECT: - { - // Color object white - m_DataNode->SetColor( 1.0, 1.0, 1.0 ); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - - // Colorize surface / wireframe as inactive - this->ColorizeSurface( m_PolyData, - m_SurfaceColorizationCenter, COLORIZATION_CONSTANT, -1.0 ); - - ok = true; - break; - } - - case AcSELECTPICKEDOBJECT: - { - // Color object red - m_DataNode->SetColor( 1.0, 0.0, 0.0 ); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - - // Colorize surface / wireframe dependend on distance from picked point - this->ColorizeSurface( m_PolyData, - m_SurfaceColorizationCenter, COLORIZATION_GAUSS ); - - ok = true; - break; - } - - case AcINITMOVE: - { - // Store current picked point - m_InitialPickedPoint = m_CurrentPickedPoint; - m_InitialPickedDisplayPoint = m_CurrentPickedDisplayPoint; - - if ( renderWindowInteractor != NULL ) - { - vtkInteractorObserver::ComputeDisplayToWorld( - renderWindowInteractor->GetInteractorStyle()->GetCurrentRenderer(), - m_InitialPickedDisplayPoint[0], - m_InitialPickedDisplayPoint[1], - 0.0, //m_InitialInteractionPickedPoint[2], - m_InitialPickedPointWorld ); - } - - - // Make deep copy of vtkPolyData interacted on - m_OriginalPolyData->DeepCopy( m_PolyData ); - - ok = true; - break; - } - - case AcMOVE: - { - if ( renderWindowInteractor != NULL ) - { - vtkInteractorObserver::ComputeDisplayToWorld( - renderWindowInteractor->GetInteractorStyle()->GetCurrentRenderer(), - m_CurrentPickedDisplayPoint[0], - m_CurrentPickedDisplayPoint[1], - 0.0, //m_InitialInteractionPickedPoint[2], - m_CurrentPickedPointWorld ); - } - - - // Calculate mouse move in 3D space - mitk::Vector3D interactionMove; - interactionMove[0] = m_CurrentPickedPointWorld[0] - m_InitialPickedPointWorld[0]; - interactionMove[1] = m_CurrentPickedPointWorld[1] - m_InitialPickedPointWorld[1]; - interactionMove[2] = m_CurrentPickedPointWorld[2] - m_InitialPickedPointWorld[2]; - - // Transform mouse move into geometry space - data->UpdateOutputInformation(); // make sure that the Geometry is up-to-date - mitk::Point3D origin; origin.Fill( 0.0 ); - mitk::Vector3D interactionMoveIndex; - m_Geometry->WorldToIndex( interactionMove, interactionMoveIndex ); - - - // Get picked point and transform into local coordinates - mitk::Point3D pickedPoint; - m_Geometry->WorldToIndex( m_InitialPickedPoint, pickedPoint ); - mitk::Vector3D v1 = pickedPoint.GetVectorFromOrigin(); - - mitk::Vector3D v2 = m_ObjectNormal * (interactionMoveIndex * m_ObjectNormal); - - - vtkPoints *originalPoints = m_OriginalPolyData->GetPoints(); - vtkPoints *deformedPoints = m_PolyData->GetPoints(); - - double denom = m_GaussSigma * m_GaussSigma * 2; - double point[3]; - for ( unsigned int i = 0; i < deformedPoints->GetNumberOfPoints(); ++i ) - { - // Get original point - double *originalPoint = originalPoints->GetPoint( i ); - mitk::Vector3D v0; - v0[0] = originalPoint[0]; - v0[1] = originalPoint[1]; - v0[2] = originalPoint[2]; - - - // Calculate distance of this point from line through picked point - double d = itk::CrossProduct( m_ObjectNormal, (v1 - v0) ).GetNorm(); - - mitk::Vector3D t = v2 * exp( - d * d / denom ); - - point[0] = originalPoint[0] + t[0]; - point[1] = originalPoint[1] + t[1]; - point[2] = originalPoint[2] + t[2]; - deformedPoints->SetPoint( i, point ); - } - - // Make sure that surface is colorized at initial picked position - // as long as we are in deformation state - m_SurfaceColorizationCenter = m_InitialPickedPoint; - - m_PolyData->Modified(); - m_Surface->Modified(); - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - ok = false; - break; - } - - case AcMODIFY: - { - // Check if we have an mitk::WheelEvent - const mitk::WheelEvent *we = - dynamic_cast< const mitk::WheelEvent * >( stateEvent->GetEvent() ); - if ( we == NULL ) - { - ok = true; - break; - } - - m_GaussSigma += (double) (we->GetDelta()) / 20;; - if ( m_GaussSigma < 10.0 ) - { - m_GaussSigma = 10.0; - } - else if ( m_GaussSigma > 128.0 ) - { - m_GaussSigma = 128.0; - } - - // Colorize surface / wireframe dependend on sigma and distance from picked point - this->ColorizeSurface( m_PolyData, - m_SurfaceColorizationCenter, COLORIZATION_GAUSS ); - - - mitk::RenderingManager::GetInstance()->RequestUpdateAll( - mitk::RenderingManager::REQUEST_UPDATE_3DWINDOWS ); - ok = true; - break; - } - - - default: - return Superclass::ExecuteAction( action, stateEvent ); - } - - return ok; -} - - -bool mitk::SurfaceDeformationInteractor3D::ColorizeSurface( vtkPolyData *polyData, - const Point3D &pickedPoint, int mode, double scalar ) -{ - if ( polyData == NULL ) - { - return false; - } - - vtkPoints *points = polyData->GetPoints(); - vtkPointData *pointData = polyData->GetPointData(); - if ( pointData == NULL ) - { - return false; - } - - vtkDataArray *scalars = pointData->GetScalars(); - if ( scalars == NULL ) - { - return false; - } - - if ( mode == COLORIZATION_GAUSS ) - { - // Get picked point and transform into local coordinates - mitk::Point3D localPickedPoint; - m_Geometry->WorldToIndex( pickedPoint, localPickedPoint ); - mitk::Vector3D v1 = localPickedPoint.GetVectorFromOrigin(); - - double denom = m_GaussSigma * m_GaussSigma * 2; - for ( unsigned int i = 0; i < points->GetNumberOfPoints(); ++i ) - { - // Get original point - double *point = points->GetPoint( i ); - mitk::Vector3D v0; - v0[0] = point[0]; - v0[1] = point[1]; - v0[2] = point[2]; - - // Calculate distance of this point from line through picked point - double d = itk::CrossProduct( m_ObjectNormal, (v1 - v0) ).GetNorm(); - double t = exp( - d * d / denom ); - - scalars->SetComponent( i, 0, t ); - } - } - else if ( mode == COLORIZATION_CONSTANT ) - { - for ( unsigned int i = 0; i < pointData->GetNumberOfTuples(); ++i ) - { - scalars->SetComponent( i, 0, scalar ); - } - } - - polyData->Modified(); - pointData->Update(); - - return true; -} diff --git a/Modules/Ext/Interactions/mitkSurfaceDeformationInteractor3D.h b/Modules/Ext/Interactions/mitkSurfaceDeformationInteractor3D.h deleted file mode 100644 index b61be85aeb..0000000000 --- a/Modules/Ext/Interactions/mitkSurfaceDeformationInteractor3D.h +++ /dev/null @@ -1,122 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKSURFACEDEFORMATIONINTERACTOR3D_H_HEADER_INCLUDED -#define MITKSURFACEDEFORMATIONINTERACTOR3D_H_HEADER_INCLUDED - -#include "mitkInteractor.h" -#include "MitkExtExports.h" -#include "mitkCommon.h" - -#include - -class vtkPolyData; - -namespace mitk -{ - -class DataNode; -class Surface; - -/** - * \brief Affine interaction with objects in 3D windows. - * - * NOTE: The interaction mechanism is similar to that of vtkPlaneWidget - * - * \ingroup Interaction - */ -class MitkExt_EXPORT SurfaceDeformationInteractor3D : public Interactor -{ -public: - mitkClassMacro(SurfaceDeformationInteractor3D, Interactor); - mitkNewMacro3Param(Self, const char *, DataNode *, int); - mitkNewMacro2Param(Self, const char *, DataNode *); - - /** \brief Sets the amount of precision */ - void SetPrecision( ScalarType precision ); - - /** - * \brief calculates how good the data, this statemachine handles, is hit - * by the event. - * - * overwritten, cause we don't look at the boundingbox, we look at each point - */ - virtual float CanHandleEvent(StateEvent const *stateEvent) const; - - -protected: - /** - * \brief Constructor with Param n for limited Set of Points - * - * if no n is set, then the number of points is unlimited* - */ - SurfaceDeformationInteractor3D(const char *type, - DataNode *dataNode, int n = -1); - - /** - * \brief Default Destructor - **/ - virtual ~SurfaceDeformationInteractor3D(); - - virtual bool ExecuteAction( Action* action, - mitk::StateEvent const* stateEvent ); - - enum - { - COLORIZATION_GAUSS, - COLORIZATION_CONSTANT - }; - - bool ColorizeSurface( vtkPolyData *polyData, const Point3D &pickedPoint, - int mode, double scalar = 0.0 ); - - -private: - - /** \brief to store the value of precision to pick a point */ - ScalarType m_Precision; - - Point3D m_InitialPickedPoint; - Point2D m_InitialPickedDisplayPoint; - double m_InitialPickedPointWorld[4]; - - Point3D m_CurrentPickedPoint; - Point2D m_CurrentPickedDisplayPoint; - double m_CurrentPickedPointWorld[4]; - - Point3D m_SurfaceColorizationCenter; - - Vector3D m_ObjectNormal; - - BaseGeometry::Pointer m_Geometry; - - Surface *m_Surface; - vtkPolyData *m_PolyData; - - DataNode *m_PickedSurfaceNode; - Surface *m_PickedSurface; - vtkPolyData *m_PickedPolyData; - - vtkPolyData *m_OriginalPolyData; - - double m_GaussSigma; - -}; - -} - -#endif /* MITKSURFACEDEFORMATIONINTERACTOR3D_H_HEADER_INCLUDED */ diff --git a/Modules/Ext/Interactions/mitkSurfaceInteractor.cpp b/Modules/Ext/Interactions/mitkSurfaceInteractor.cpp deleted file mode 100644 index dcf25b7f09..0000000000 --- a/Modules/Ext/Interactions/mitkSurfaceInteractor.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkSurfaceInteractor.h" -#include "mitkPointLocator.h" -#include "mitkSurface.h" - -#include "mitkStateEvent.h" -#include "mitkInteractionConst.h" -#include "mitkBaseRenderer.h" - -#include - -mitk::SurfaceInteractor::SurfaceInteractor(const char * type, DataNode* dataNode) -: AffineInteractor(type, dataNode) -{ - m_PtLoc = PLocType::New(); -} - - -float mitk::SurfaceInteractor::CanHandleEvent( StateEvent const* stateEvent ) const -{ - float jd = 0.0f; - - if( ! ( stateEvent->GetEvent()->GetButtonState() == mitk::BS_ControlButton && stateEvent->GetEvent()->GetType() == mitk::Type_MouseButtonPress )) - return jd; - - if ( stateEvent->GetEvent()->GetSender()->GetMapperID() == mitk::BaseRenderer::Standard3D ) - return jd; - - mitk::Surface* surf = dynamic_cast(this->GetData()); - if (surf) - { - mitk::DisplayPositionEvent const *event = dynamic_cast (stateEvent->GetEvent()); - mitk::PointSet::PointType pt = event->GetWorldPosition(); - - // Use ANN to get the point of the polydata closest to the world event - if( surf->GetVtkPolyData(m_TimeStep) == NULL ) itkExceptionMacro(<< "No polydata at this time step!"); - m_PtLoc->SetPoints(dynamic_cast(surf->GetVtkPolyData(m_TimeStep))); - mitk::PointLocator::DistanceType dst = m_PtLoc->GetMinimalDistance(pt); - - mitk::BaseRenderer* ren = stateEvent->GetEvent()->GetSender(); - - // Get the diameter of the render window bounding box - mitk::DataStorage* storage = ren->GetDataStorage(); - mitk::BoundingBox::Pointer bb = storage->ComputeBoundingBox(); - mitk::BoundingBox::AccumulateType dia = std::sqrt(bb->GetDiagonalLength2()); - - if (dia > 0.00001) //if diameter not zero - { - float verh = dst/dia; - if (verh>1) verh = 1; //if dst is bigger than dia, then set to 1 - //now inverse (0 = bad and 1 = good) and set between 0.5 and 1 - jd = ((1-verh)/2)+0.5f; - } - } - return jd; -} diff --git a/Modules/Ext/Interactions/mitkSurfaceInteractor.h b/Modules/Ext/Interactions/mitkSurfaceInteractor.h deleted file mode 100644 index 5d4f59bb00..0000000000 --- a/Modules/Ext/Interactions/mitkSurfaceInteractor.h +++ /dev/null @@ -1,75 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKSURFACEINTERACTOR_H_HEADER_INCLUDED -#define MITKSURFACEINTERACTOR_H_HEADER_INCLUDED - -#include "mitkAffineInteractor.h" -#include "MitkExtExports.h" -#include "mitkPointLocator.h" - -namespace mitk { - - //##Documentation - //## @brief Interactor for Affine transformations on one or multiple surfaces - //## - //## A surface interacted by this class can translate, rotate and scale - //## by modifying its geometry. The surface closest to the picking point is - //## chosen for interaction automatically by CanHandleEvent - //## @ingroup Interaction - class MitkExt_EXPORT SurfaceInteractor : public AffineInteractor - { - public: - mitkClassMacro(SurfaceInteractor,AffineInteractor); - // itkFactorylessNewMacro(Self) - // itkCloneMacro(Self) - mitkNewMacro2Param(Self, const char*, DataNode*); - - protected: - - //##Documentation - //## @brief Constructor - //## - //## @param dataNode is the node, this Interactor is connected to - //## @param type is the type of StateMachine like declared in the XML-Configure-File - SurfaceInteractor(const char * type, DataNode* dataNode); - - //##Documentation - //## @brief Destructor - ~SurfaceInteractor(){}; - - //##Documentation - //## @brief calculates how good the data this state machine handles is hit by the event. - //## - //## Returns a value between 0 and 1. - //## (Used by GlobalInteraction to decide which DESELECTED state machine to send the event to.) - //## - //## \WARNING This is interactor currently does not work for interaction in 3D. Try using mitkAffineInteractor3D instead. - virtual float CanHandleEvent(StateEvent const* stateEvent) const; - - private: - - typedef PointLocator PLocType; - typedef PLocType::Pointer PLPointer; - - PLPointer m_PtLoc; - - }; - -} // namespace mitk - -#endif /* MITKSURFACEINTERACTOR_H_HEADER_INCLUDED */ diff --git a/Modules/Ext/Interactions/mitkTDMouseEvent.cpp b/Modules/Ext/Interactions/mitkTDMouseEvent.cpp deleted file mode 100644 index 13e62055d0..0000000000 --- a/Modules/Ext/Interactions/mitkTDMouseEvent.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkTDMouseEvent.h" -#include "mitkInteractionConst.h" -#include "mitkNumericTypes.h" - -mitk::TDMouseEvent::TDMouseEvent(int buttonState, const Vector3D& translation, const Vector3D& rotation, const ScalarType& angle) -: Event(NULL, Type_TDMouseInput, BS_NoButton, buttonState, Key_none), m_Translation(translation), m_Rotation(rotation), m_Angle(angle) -{ -} diff --git a/Modules/Ext/Interactions/mitkTDMouseEvent.h b/Modules/Ext/Interactions/mitkTDMouseEvent.h deleted file mode 100644 index 9e69d43eb3..0000000000 --- a/Modules/Ext/Interactions/mitkTDMouseEvent.h +++ /dev/null @@ -1,76 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef TDMOUSEEVENT_H_HEADER_INCLUDED -#define TDMOUSEEVENT_H_HEADER_INCLUDED - -#include "mitkCommon.h" -#include "mitkEvent.h" -#include "mitkNumericTypes.h" - - -namespace mitk { - -//##Documentation -//## @brief Event on 3D Mouse input -//## -//## Seven coordinates exposed by the 3D Mouse: -//## 3-dimensional translation vector -//## 3-dimensional rotation achsis (length allways 1.0) -//## scalar rotation angle -//## @ingroup Interaction -class TDMouseEvent : public Event -{ - public: - //##Documentation - //## @brief Constructor with all necessary arguments. - //## - //## buttonState: information from the Event - TDMouseEvent(int buttonState, const Vector3D& translation, const Vector3D& rotation, const ScalarType& angle); - - const Vector3D& GetTranslation() const - { - return m_Translation; - } - - void SetTranslation(const Vector3D& translation) { m_Translation = translation; } - - const Vector3D& GetRotation() const - { - return m_Rotation; - } - - void SetRotation(const Vector3D& rotation) { m_Rotation = rotation; } - - const ScalarType& GetAngle() const - { - return m_Angle; - } - - void SetAngle(const ScalarType& angle) { m_Angle = angle; } - - - protected: - Vector3D m_Translation; - Vector3D m_Rotation; - ScalarType m_Angle; - -}; - -} // namespace mitk - -#endif /* TDMOUSEEVENT_H_HEADER_INCLUDED */ diff --git a/Modules/Ext/Interactions/mitkTDMouseEventThrower.cpp b/Modules/Ext/Interactions/mitkTDMouseEventThrower.cpp deleted file mode 100644 index b419761930..0000000000 --- a/Modules/Ext/Interactions/mitkTDMouseEventThrower.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkTDMouseEventThrower.h" -#include "mitkTDMouseEvent.h" -#include "mitkInteractionConst.h" -#include "mitkNumericTypes.h" -#include "mitkGlobalInteraction.h" -#include "mitkStateEvent.h" -#include "mitkSpaceNavigatorDriver.h" - - -mitk::TDMouseEventThrower * mitk::TDMouseEventThrower::GetInstance() -{ - //instance will not be initialize and return 0 - static TDMouseEventThrower instance; - return &instance; -} - -mitk::TDMouseEventThrower::TDMouseEventThrower() -{ - //init the driver - SpaceNavigatorDriver* spaceNavigatorDriver = SpaceNavigatorDriver::GetInstance(); -} - -mitk::TDMouseEventThrower::~TDMouseEventThrower() -{ -} - -void mitk::TDMouseEventThrower::DeviceChange (long device, long keys, long programmableKeys) -{ -} - -void mitk::TDMouseEventThrower::KeyDown (int keyCode) -{ - //send the informations to GlobalInteraction - mitk::Event* e = new mitk::Event(NULL, mitk::Type_TDMouseKeyDown, mitk::BS_LeftButton, keyCode, mitk::Key_none); - mitk::StateEvent* se = new mitk::StateEvent(mitk::EIDTDMOUSEKEYDOWN, e); - mitk::GlobalInteraction::GetInstance()->HandleEvent(se); -} - -void mitk::TDMouseEventThrower::KeyUp (int keyCode) -{ -} - -void mitk::TDMouseEventThrower::SensorInput( mitk::Vector3D translation, mitk::Vector3D rotation, mitk::ScalarType angle) -{ - mitk::TDMouseEvent* e = new mitk::TDMouseEvent(mitk::BS_NoButton, translation, rotation, angle); - mitk::StateEvent* se = new mitk::StateEvent(mitk::EIDTDMOUSEINPUT, e); - mitk::GlobalInteraction::GetInstance()->HandleEvent(se); -} diff --git a/Modules/Ext/Interactions/mitkTDMouseEventThrower.h b/Modules/Ext/Interactions/mitkTDMouseEventThrower.h deleted file mode 100644 index 9f86a61f32..0000000000 --- a/Modules/Ext/Interactions/mitkTDMouseEventThrower.h +++ /dev/null @@ -1,44 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef TDMouseEventThrower__h__ -#define TDMouseEventThrower__h__ - -#include -#include - -namespace mitk { - - class TDMouseEventThrower - { - public: - - static TDMouseEventThrower* GetInstance(); - - void DeviceChange (long device, long keys, long programmableKeys); - void KeyDown (int keyCode); - void KeyUp (int keyCode); - void SensorInput( mitk::Vector3D translation, mitk::Vector3D rotation, mitk::ScalarType angle); - - protected: - TDMouseEventThrower(); - ~TDMouseEventThrower(); - }; - -}//namespace - -#endif // TDMouseEventThrower__h__ diff --git a/Modules/Ext/Rendering/mitkGLUT.h b/Modules/Ext/Rendering/mitkGLUT.h deleted file mode 100644 index c273feff62..0000000000 --- a/Modules/Ext/Rendering/mitkGLUT.h +++ /dev/null @@ -1,30 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKGLUT_H_HEADER_INCLUDED -#define MITKGLUT_H_HEADER_INCLUDED - -// Since 7.8.07 MITK is not using/requiring GLUT anymore. - -#ifdef __APPLE__ -//#include -#else -//#include -#endif - -#endif /* MITKGLUT_H_HEADER_INCLUDED */ - diff --git a/Modules/Ext/Rendering/mitkImageBackground2D.cpp b/Modules/Ext/Rendering/mitkImageBackground2D.cpp deleted file mode 100644 index 77df492c68..0000000000 --- a/Modules/Ext/Rendering/mitkImageBackground2D.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkImageBackground2D.h" -// MITK includes -#include "mitkVtkLayerController.h" - -// VTK includes -#include "vtkSystemIncludes.h" -#include "vtkRenderer.h" -#include "vtkMapper.h" -#include "vtkObjectFactory.h" -#include "vtkImageActor.h" -#include "vtkRenderWindow.h" -#include "vtkImageImport.h" -#include "vtkCommand.h" -#include "vtkCamera.h" - -#include - -// VTK CALLBACK for automatic resize of the video -class vtkVideoSizeCallback : public vtkCommand -{ -public: - static vtkVideoSizeCallback *New(){ return new vtkVideoSizeCallback; } - - vtkRenderer * m_ImageRenderer; - int m_ImageWidth, m_ImageHeight; - - void SetVtkVideoRenderer(vtkRenderer* r) - { - m_ImageRenderer = r; - } - void SetVideoDimensions(int x, int y) - { - m_ImageWidth = x; m_ImageHeight = y; - } - - virtual void Execute(vtkObject* /*caller*/, unsigned long, void*) - { - //vtkRenderWindow * RenderWindow = reinterpret_cast(caller); - //m_ImageRenderer->ResetCameraClippingRange(); - } -}; - -mitk::ImageBackground2D::ImageBackground2D() -{ - m_ImageWidth = 0; - m_ImageHeight = 0; - m_ImageScalarComponents = 3; - m_ParallelScale = 0; - m_RenderWindow = NULL; - - m_Actor = vtkImageActor::New(); - m_ImageRenderer = vtkRenderer::New(); - m_VtkImageImport = vtkImageImport::New(); - - m_ImageData = NULL; -} - -void mitk::ImageBackground2D::InitVtkImageImport() -{ - /*m_VtkImageImport->Delete(); - m_VtkImageImport = vtkImageImport::New();*/ - m_VtkImageImport->SetDataScalarTypeToUnsignedChar(); - m_VtkImageImport->SetNumberOfScalarComponents(m_ImageScalarComponents); - m_VtkImageImport->SetWholeExtent(0,m_ImageWidth-1,0,m_ImageHeight-1,0,1-1); - m_VtkImageImport->SetDataExtentToWholeExtent(); -} - -mitk::ImageBackground2D::~ImageBackground2D() -{ - if ( m_RenderWindow != NULL ) - if ( this->IsEnabled() ) - this->Disable(); - if ( m_Actor!=NULL ) - m_Actor->Delete(); - if ( m_ImageRenderer != NULL ) - m_ImageRenderer->Delete(); - if ( m_VtkImageImport != NULL) - m_VtkImageImport->Delete(); -} -/** - * Sets the renderwindow, in which the Video background - * will be shown. Make sure, you have called this function - * before calling Enable() - */ -void mitk::ImageBackground2D::SetRenderWindow(vtkRenderWindow* renderWindow ) -{ - m_RenderWindow = renderWindow; - - /*m_SizeCallback = vtkVideoSizeCallback::New(); - m_RenderWindow->GetVtkRenderWindow()->AddObserver(vtkCommand::ModifiedEvent,m_SizeCallback);*/ - -} - -void mitk::ImageBackground2D::SetParallelScale(int scale) -{ - m_ParallelScale = scale; - m_ImageRenderer->GetActiveCamera()->SetParallelScale(m_ParallelScale); -} -int mitk::ImageBackground2D::GetParallelScale() -{ - // TODO someone who knows this, check if double->int could cause problems - return static_cast(m_ImageRenderer->GetActiveCamera()->GetParallelScale()); -} -/** - * Enables drawing of the color Video background. - * If you want to disable it, call the Disable() function. - */ -void mitk::ImageBackground2D::Enable() -{ - m_ImageRenderer = vtkRenderer::New(); - - mitk::VtkLayerController::GetInstance(m_RenderWindow)->InsertBackgroundRenderer(m_ImageRenderer,true); - - char * c = 0; - Update(c); - m_Actor->SetInputData(m_VtkImageImport->GetOutput()); - - m_ImageRenderer->AddActor2D(m_Actor); - m_ImageRenderer->ResetCamera(); - m_ImageRenderer->InteractiveOff(); - m_ImageRenderer->GetActiveCamera()->ParallelProjectionOn(); - if(m_ParallelScale == 0) - m_ImageRenderer->GetActiveCamera()->SetParallelScale(m_ImageHeight/2); - - //m_SizeCallback->SetVtkVideoRenderer(m_ImageRenderer); - //m_SizeCallback->SetVideoDimensions(m_ImageWidth, m_ImageHeight); - -} - -/** - * Disables drawing of the color Video background. - * If you want to enable it, call the Enable() function. - */ -void mitk::ImageBackground2D::Disable() -{ - if ( this->IsEnabled() ) - mitk::VtkLayerController::GetInstance(m_RenderWindow)->RemoveRenderer(m_ImageRenderer); -} -/** - * Checks, if the Video background is currently - * enabled (visible) - */ -bool mitk::ImageBackground2D::IsEnabled() -{ - if ( mitk::VtkLayerController::GetInstance(m_RenderWindow)->IsRendererInserted(m_ImageRenderer)) - return true; - else - return false; -} - -void mitk::ImageBackground2D::Update(char * dataPointer) -{ - if(!IsEnabled()) - return; - - // VTK import image data must be allocated before import (with correct parameters) - if(m_ImageData == NULL) - m_ImageData = new unsigned char[m_ImageHeight*m_ImageWidth*m_ImageScalarComponents]; - - if(!dataPointer) - {// no valid image pointer provided -> initialize black image - unsigned char* b = m_ImageData; - for ( int textCounter = 0; textCounter < (m_ImageHeight*m_ImageWidth*m_ImageScalarComponents); textCounter++ ) - *b++ = 0; - } - - m_VtkImageImport->SetImportVoidPointer(m_ImageData); - m_VtkImageImport->Modified(); - m_VtkImageImport->Update(); - m_RenderWindow->Render(); - -} - -void mitk::ImageBackground2D::Update(char * dataPointer, int width, int height, int imageScalarComponents) -{ - // no image-backround layer is rendered - if(!IsEnabled()) - return; - - // image contains no data, OR image scalar components missmatch (no RGB, no greyscale) - if(!dataPointer || (imageScalarComponents != 1 && imageScalarComponents != 3)) - { - // no valid image pointer provided -> we initialize black image - if(m_ImageData == NULL) - m_ImageData = new unsigned char[m_ImageHeight*m_ImageWidth*m_ImageScalarComponents]; - - unsigned char* b = m_ImageData; - for ( int textCounter = 0; textCounter < (m_ImageHeight*m_ImageWidth*m_ImageScalarComponents); textCounter++ ) - *b++ = 0; - } - else - { - if(m_ImageWidth == 0) - { // VTK Image Import has to be initialized properly - m_ImageHeight = height; - m_ImageWidth = width; - m_ImageScalarComponents = imageScalarComponents; - InitVtkImageImport(); - } - - - // VTK import image data must be allocated before import (with correct parameters) - if(m_ImageData == NULL) - m_ImageData = new unsigned char[m_ImageHeight*m_ImageWidth*m_ImageScalarComponents]; - - int column, row; - unsigned char* tex = m_ImageData; - char* data = dataPointer; - - // PREPARE image Data for VTKImageImport Filter // - - - if(imageScalarComponents == 1) - { - m_VtkImageImport->SetNumberOfScalarComponents(m_ImageScalarComponents); - - unsigned char g; - for (column = 0; column < m_ImageHeight; column++) - for (row = 0; row < m_ImageWidth; row++) - { - g = *data++; - *tex++ = g; - } - } - else if(imageScalarComponents == 3) - { - // flip image, change color channels - unsigned char r, g, b; - for (column = 0; column < m_ImageHeight; column++) - for (row = 0; row < m_ImageWidth; row++) - { //change r with b - b = *data++; - g = *data++; - r = *data++; - *tex++ = r; - *tex++ = g; - *tex++ = b; - } - } // else if(imageScalarComponents == 3) - - } // end else image data present - - - // Initialize VTK-ImageImport Filter // - m_VtkImageImport->SetImportVoidPointer(m_ImageData); - m_VtkImageImport->Modified(); - m_VtkImageImport->Update(); - m_RenderWindow->Render(); - -} - - diff --git a/Modules/Ext/Rendering/mitkImageBackground2D.h b/Modules/Ext/Rendering/mitkImageBackground2D.h deleted file mode 100644 index 5d5ec8c856..0000000000 --- a/Modules/Ext/Rendering/mitkImageBackground2D.h +++ /dev/null @@ -1,106 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef _mitk_Image_Background2D_h_ -#define _mitk_Image_Background2D_h_ - -#include "mitkVideoSource.h" -#include "MitkExtExports.h" - -#include "mitkConfig.h" - -class vtkRenderer; -class vtkRenderWindow; -class vtkImageActor; -class vtkImageImport; -class vtkVideoSizeCallback; - -namespace mitk -{ - - class RenderWindow; - - /** - * Displays a 2D image (currently unsigned char) in the background - * of a vtkRenderWindow. - * Caution: As the data is not being copied, a user is responsible for a valid - * pointer to the image. Also the image dimensions needs to be set correctly before enabling the - * background. - */ - class MitkExt_EXPORT ImageBackground2D : public itk::Object - { - public: - mitkClassMacro( ImageBackground2D, itk::Object ); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - ////##Documentation - ////## @brief returns the mitkRenderWindow in which the video is displayed. - vtkRenderWindow* GetRenderWindow(); - ////##Documentation - ////## @brief sets the mitkRenderWindow in which the video is displayed. - ////## must be initialized before enabling the background. - void SetRenderWindow(vtkRenderWindow* renderWindow); - ////##Documentation - ////## @brief sets the width,height and number of scalar components of the image. - ////## must be correctly initialized before enabling the background. - void SetImageDimensions(int x, int y, int nrOfScalarComponents) - { - m_ImageWidth = x; - m_ImageHeight = y; - m_ImageScalarComponents = nrOfScalarComponents; - InitVtkImageImport(); - } - - void SetParallelScale(int scale); - int GetParallelScale(); - - void Update(char * dataPointer); - void Update(char * dataPointer, int width, int height, int imageScalarComponents); - - ////##Documentation - ////## @brief visualizes the video. Requires image dimensions and an active mitkvideosource to be set. - void Enable(); - ////##Documentation - ////## @brief disables visualization of the video. - void Disable(); - ////##Documentation - ////## @brief Checks, if the Video background is currently enabled (visible). - bool IsEnabled(); - - protected: - ImageBackground2D(); - ~ImageBackground2D(); - - void InitVtkImageImport(); - - vtkRenderWindow* m_RenderWindow; - vtkRenderer* m_ImageRenderer; - vtkImageActor* m_Actor; - vtkImageImport* m_VtkImageImport; - - // Adjust Image Size - vtkVideoSizeCallback * m_SizeCallback; - - unsigned char * m_ImageData; - - int m_ImageWidth, m_ImageHeight, m_ImageScalarComponents, m_ParallelScale; - }; -} // namespace mitk - -#endif - - diff --git a/Modules/Ext/Rendering/mitkLineMapper2D.cpp b/Modules/Ext/Rendering/mitkLineMapper2D.cpp deleted file mode 100644 index 19560e23ca..0000000000 --- a/Modules/Ext/Rendering/mitkLineMapper2D.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkLineMapper2D.h" -#include "mitkPointSet.h" -#include "mitkBaseRenderer.h" -#include "mitkPlaneGeometry.h" -#include "mitkColorProperty.h" -#include "mitkProperties.h" -#include -#include "mitkPointSet.h" -#include "mitkGL.h" - -mitk::LineMapper2D::LineMapper2D() -: mitk::PointSetGLMapper2D() -{ - -} - -mitk::LineMapper2D::~LineMapper2D() -{ -} - -const mitk::PointSet *mitk::LineMapper2D::GetInput(void) -{ - return static_cast ( GetDataNode()->GetData() ); -} - -void mitk::LineMapper2D::Paint(mitk::BaseRenderer * renderer) -{ - - bool visible = true; - GetDataNode()->GetVisibility(visible, renderer, "visible"); - if(!visible) return; - - bool updateNeccesary = true;//!!!! @TODO !??!! - - if (updateNeccesary) - { - mitk::PointSet::Pointer input = const_cast(this->GetInput()); - mitk::DisplayGeometry::Pointer displayGeometry = renderer->GetDisplayGeometry(); - assert(displayGeometry.IsNotNull()); - - //apply color and opacity read from the PropertyList - ApplyColorAndOpacityProperties(renderer); - - vtkLinearTransform* transform = GetDataNode()->GetVtkTransform(); - - //List of the Points - PointSet::DataType::PointsContainerConstIterator it, end; - it = input->GetPointSet()->GetPoints()->Begin(); - end = input->GetPointSet()->GetPoints()->End();//the last before end, because lines from n to n+1 - if (end!=it) // otherwise PointSet is empty - end--; - - //bool list for the selection of the points - PointSet::DataType::PointDataContainerIterator selIt, selItNext; - selIt=input->GetPointSet()->GetPointData()->Begin(); - - int j=0; - while(it!=end) - { - mitk::Point3D p, q, projected_p, projected_q; - float vtkp[3]; - itk2vtk(it->Value(), vtkp); - transform->TransformPoint(vtkp, vtkp); - vtk2itk(vtkp,p); - - //next point n+1 - it++; - itk2vtk(it->Value(), vtkp); - transform->TransformPoint(vtkp, vtkp); - vtk2itk(vtkp,q); - it--; - - displayGeometry->Project(p, projected_p); - displayGeometry->Project(q, projected_q); - - Vector3D diffp=p-projected_p, diffq=q-projected_q; - if((diffp.GetSquaredNorm()<4.0) && - (diffq.GetSquaredNorm()<4.0)) - { - Point2D p2d, q2d, tmp; - - displayGeometry->Map(projected_p, p2d); - displayGeometry->WorldToDisplay(p2d, p2d); - displayGeometry->Map(projected_q, q2d); - displayGeometry->WorldToDisplay(q2d, q2d); - - //outlined, cause iterators behave strange and multiple points can't be selected anyway by now! - //selItNext = selIt++;//Iterator to the next Element, cause only when the two points ar selected, then the Line is Selected - //if (selIt->Value() && selItNext->Value())//selected - //{ - // float colorSel[]={1.0,0.0,0.6}; //for selected! - - // //current color for changing to a diferent color if selected - // float currCol[4]; - // glGetFloatv(GL_CURRENT_COLOR,currCol); - - // glColor3f(colorSel[0],colorSel[1],colorSel[2]);//red - - - // glBegin (GL_LINES); - // glVertex2f(p2d[0], p2d[1]); - // glVertex2f(q2d[0], q2d[1]); - // glEnd (); - - // glColor3f(currCol[0],currCol[1],currCol[2]);//the color before changing to select! - - //} - //else - //{ - glBegin (GL_LINES); - glVertex2f(p2d[0], p2d[1]); - glVertex2f(q2d[0], q2d[1]); - glEnd (); - //} - } - ++it; - ++selIt; - j++; - } - //drawing the points - PointSetGLMapper2D::Paint(renderer); - } -} diff --git a/Modules/Ext/Rendering/mitkLineMapper2D.h b/Modules/Ext/Rendering/mitkLineMapper2D.h deleted file mode 100644 index 9ad9444abd..0000000000 --- a/Modules/Ext/Rendering/mitkLineMapper2D.h +++ /dev/null @@ -1,59 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKLINEMAPPER2D_H_HEADER_INCLUDED -#define MITKLINEMAPPER2D_H_HEADER_INCLUDED - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkPointSetGLMapper2D.h" - -namespace mitk { - -class BaseRenderer; -class PointSet; - -//##Documentation -//## @brief OpenGL-based mapper to display Lines -//## -//## uses the information from the PointSet to build up the lines. -//## Only lines in 2D in one Slice are drawn, not between slices! -//## @ingroup Mapper - -/** \deprecatedSince{2013_06} This mapper is deprecated. */ -class DEPRECATED() MitkExt_EXPORT LineMapper2D : public PointSetGLMapper2D -{ -public: - mitkClassMacro(LineMapper2D, PointSetGLMapper2D); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - //##Documentation - //## @brief Get the PointDataList to map - const PointSet * GetInput(void); - - virtual void Paint(mitk::BaseRenderer * renderer); - -protected: - LineMapper2D(); - - virtual ~LineMapper2D(); -}; - -} // namespace mitk - -#endif /* MITKLINEMAPPER2D_H_HEADER_INCLUDED */ diff --git a/Modules/Ext/Rendering/mitkLineVtkMapper3D.cpp b/Modules/Ext/Rendering/mitkLineVtkMapper3D.cpp deleted file mode 100644 index e5feb688b2..0000000000 --- a/Modules/Ext/Rendering/mitkLineVtkMapper3D.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkLineVtkMapper3D.h" - -#include -#include -#include -#include -#include "mitkStringProperty.h" -#include - -mitk::LineVtkMapper3D::LineVtkMapper3D() -: PointSetVtkMapper3D()//constructor of superclass -{ -} - -mitk::LineVtkMapper3D::~LineVtkMapper3D() -{ -} - -void mitk::LineVtkMapper3D::GenerateDataForRenderer(mitk::BaseRenderer* renderer) -{//from PointListVTKMapper3D and a little re-layouted! - if(IsVisible(renderer)==false) - { - m_Actor->VisibilityOff(); - return; - } - - m_Actor->VisibilityOn(); - - m_vtkPointList->Delete(); - m_vtkTextList->Delete(); - m_contour->Delete(); - m_tubefilter->Delete(); - - m_vtkPointList = vtkAppendPolyData::New(); - m_vtkTextList = vtkAppendPolyData::New(); - m_contour = vtkPolyData::New(); - m_tubefilter = vtkTubeFilter::New(); - - - mitk::PointSet::Pointer input = const_cast(this->GetInput()); - mitk::PointSet::PointSetType::Pointer pointList; - - pointList = input->GetPointList(); - - mitk::PointSet::PointsContainer::Iterator i; - - int j; - bool makeContour; - if (dynamic_cast(this->GetDataNode()->GetProperty("show contour").GetPointer()) == NULL) - makeContour = false; - else - makeContour = dynamic_cast(this->GetDataNode()->GetProperty("show contour").GetPointer())->GetValue(); - - vtkPoints *points = vtkPoints::New(); - vtkCellArray *polys = vtkCellArray::New(); - - for (j=0, i=pointList->GetPoints()->Begin(); i!=pointList->GetPoints()->End() ; i++,j++) - { - int cell[2] = {j-1,j}; - points->InsertPoint(j,i.Value()[0],i.Value()[1],i.Value()[2]); - if (j>0) - polys->InsertNextCell(2,cell); - } - - bool close; - if (dynamic_cast(this->GetDataNode()->GetProperty("close contour").GetPointer()) == NULL) - close = false; - else - close = dynamic_cast(this->GetDataNode()->GetProperty("close contour").GetPointer())->GetValue(); - - if (close) - { - int cell[2] = {j-1,0}; - polys->InsertNextCell(2,cell); - } - - m_contour->SetPoints(points); - points->Delete(); - m_contour->SetLines(polys); - polys->Delete(); - m_contour->Update(); - - m_tubefilter->SetInput(m_contour); - m_tubefilter->SetRadius(1); - m_tubefilter->Update();; - - m_vtkPointList->AddInput(m_tubefilter->GetOutput()); - - - // check for color prop and use it for rendering if it exists - float rgba[4]={1.0f,1.0f,1.0f,1.0f}; - GetColor(rgba, renderer); - - for (j=0, i=pointList->GetPoints()->Begin(); i!=pointList->GetPoints()->End() ; i++,j++) - { - vtkSphereSource *sphere = vtkSphereSource::New(); - - sphere->SetRadius(2); - sphere->SetCenter(i.Value()[0],i.Value()[1],i.Value()[2]); - - m_vtkPointList->AddInput(sphere->GetOutput()); - - if (dynamic_cast(this->GetDataNode()->GetProperty("label").GetPointer()) == NULL) - { - } - else - { - const char * pointLabel =dynamic_cast(this->GetDataNode()->GetProperty("label").GetPointer())->GetValue(); - char buffer[20]; - std::string l = pointLabel; - if (input->GetSize()>1) - { - sprintf(buffer,"%d",j+1); - l.append(buffer); - } - - // Define the text for the label - vtkVectorText *label = vtkVectorText::New(); - label->SetText(l.c_str()); - - // Set up a transform to move the label to a new position. - vtkTransform *aLabelTransform =vtkTransform::New(); - aLabelTransform->Identity(); - aLabelTransform->Translate(i.Value()[0]+2,i.Value()[1]+2,i.Value()[2]); - aLabelTransform->Scale(5.7,5.7,5.7); - - // Move the label to a new position. - vtkTransformPolyDataFilter *labelTransform = vtkTransformPolyDataFilter::New(); - labelTransform->SetTransform(aLabelTransform); - labelTransform->SetInput(label->GetOutput()); - - m_vtkPointList->AddInput(labelTransform->GetOutput()); - } - - - } - - - m_VtkPolyDataMapper->SetInput(m_vtkPointList->GetOutput()); - m_Actor->GetProperty()->SetColor(rgba); -} - diff --git a/Modules/Ext/Rendering/mitkLineVtkMapper3D.h b/Modules/Ext/Rendering/mitkLineVtkMapper3D.h deleted file mode 100644 index ccca95cfe2..0000000000 --- a/Modules/Ext/Rendering/mitkLineVtkMapper3D.h +++ /dev/null @@ -1,71 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKLINEVTKMAPPER3D_H_HEADER_INCLUDED -#define MITKLINEVTKMAPPER3D_H_HEADER_INCLUDED - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "mitkPointSetVtkMapper3D.h" -#include "mitkPointSet.h" -#include "mitkBaseRenderer.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -class vtkActor; -class vtkAssembly; -class vtkFollower; -class vtkPolyDataMapper; - -namespace mitk { - -//##Documentation -//## @brief Vtk-based mapper to draw Lines from PointSet -//## -//## @ingroup Mapper -class MitkExt_EXPORT LineVtkMapper3D : public PointSetVtkMapper3D -{ - public: - - mitkClassMacro(LineVtkMapper3D, PointSetVtkMapper3D); - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - - protected: - LineVtkMapper3D(); - virtual ~LineVtkMapper3D(); - - virtual void GenerateDataForRenderer(mitk::BaseRenderer* renderer); -}; - -} // namespace mitk - -#endif /* MITKLINEVTKMAPPER3D_H_HEADER_INCLUDED */ diff --git a/Modules/Ext/Rendering/mitkNativeRenderWindowInteractor.cpp b/Modules/Ext/Rendering/mitkNativeRenderWindowInteractor.cpp deleted file mode 100644 index 309ce8fd46..0000000000 --- a/Modules/Ext/Rendering/mitkNativeRenderWindowInteractor.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkNativeRenderWindowInteractor.h" - -#include -#include - -mitk::NativeRenderWindowInteractor::NativeRenderWindowInteractor() : m_MitkRenderWindow(NULL), m_NativeVtkRenderWindowInteractor(NULL) -{ - m_NativeVtkRenderWindowInteractor = vtkRenderWindowInteractor::New(); -} - -mitk::NativeRenderWindowInteractor::~NativeRenderWindowInteractor() -{ - m_NativeVtkRenderWindowInteractor->Delete(); -} - -void mitk::NativeRenderWindowInteractor::SetMitkRenderWindow(vtkRenderWindow* renderwindow) -{ - m_MitkRenderWindow = renderwindow; - if(m_MitkRenderWindow != NULL) - m_NativeVtkRenderWindowInteractor->SetRenderWindow(m_MitkRenderWindow); -} - -void mitk::NativeRenderWindowInteractor::Start() -{ - if(m_MitkRenderWindow != NULL) - m_NativeVtkRenderWindowInteractor->Start(); -} diff --git a/Modules/Ext/Rendering/mitkNativeRenderWindowInteractor.h b/Modules/Ext/Rendering/mitkNativeRenderWindowInteractor.h deleted file mode 100644 index 446ba16e60..0000000000 --- a/Modules/Ext/Rendering/mitkNativeRenderWindowInteractor.h +++ /dev/null @@ -1,57 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef MITKNATIVERENDERWINDOWINTERACTOR_H_HEADER_INCLUDED_C1C53722 -#define MITKNATIVERENDERWINDOWINTERACTOR_H_HEADER_INCLUDED_C1C53722 - -#include "mitkCommon.h" -#include "MitkExtExports.h" -#include "itkObject.h" -#include "itkObjectFactory.h" - -class vtkRenderWindow; -class vtkRenderWindowInteractor; - -namespace mitk -{ - -class MitkExt_EXPORT NativeRenderWindowInteractor : public itk::Object -{ -public: - mitkClassMacro(NativeRenderWindowInteractor, itk::Object); - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - virtual void Start(); - - void SetMitkRenderWindow(vtkRenderWindow * renderwindow); - itkGetMacro(MitkRenderWindow, vtkRenderWindow*); - -protected: - NativeRenderWindowInteractor(); - virtual ~NativeRenderWindowInteractor(); - - vtkRenderWindow* m_MitkRenderWindow; - - vtkRenderWindowInteractor* m_NativeVtkRenderWindowInteractor; -}; - -} -#endif /* MITKNATIVERENDERWINDOWINTERACTOR_H_HEADER_INCLUDED_C1C53722 */ - - diff --git a/Modules/Ext/Rendering/vtkMitkOpenGLGPUVolumeRayCastMapper.cpp b/Modules/Ext/Rendering/vtkMitkOpenGLGPUVolumeRayCastMapper.cpp deleted file mode 100644 index 1b731f69f8..0000000000 --- a/Modules/Ext/Rendering/vtkMitkOpenGLGPUVolumeRayCastMapper.cpp +++ /dev/null @@ -1,7493 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -/*========================================================================= - - Program: Visualization Toolkit - Module: $RCSfile: vtkMitkOpenGLGPUVolumeRayCastMapper.cxx,v $ - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -#include "vtkMitkOpenGLGPUVolumeRayCastMapper.h" - -// Only with VTK 5.6 or above -#if ((VTK_MAJOR_VERSION > 5) || ((VTK_MAJOR_VERSION==5) && (VTK_MINOR_VERSION>=6) )) - -#include "vtkObjectFactory.h" -#include "vtkVolume.h" -#include "vtkRenderer.h" -#include "vtkRenderWindow.h" -#include "vtkCamera.h" -#include "vtkMatrix4x4.h" -#include "vtkImageData.h" - -#include "vtkTimerLog.h" - -#include "vtkVolumeProperty.h" -#include "vtkColorTransferFunction.h" -#include "vtkPiecewiseFunction.h" - -#include "vtkOpenGLExtensionManager.h" -#include "vtkgl.h" - -#ifndef VTK_IMPLEMENT_MESA_CXX -# include "vtkOpenGL.h" -#endif - -#include - -#include -#include -#include -#include - -#include "vtkClipDataSet.h" -#include "vtkCellArray.h" -#include "vtkDoubleArray.h" -#include "vtkFloatArray.h" -#include "vtkGeometryFilter.h" -#include "vtkMath.h" -#include "vtkPlane.h" -#include "vtkPlaneCollection.h" -#include "vtkPlanes.h" -#include "vtkPolyData.h" -#include "vtkPointData.h" -#include "vtkCellData.h" -#include "vtkPoints.h" -#include "vtkUnsignedCharArray.h" -#include "vtkUnsignedShortArray.h" -#include "vtkUnsignedIntArray.h" -#include "vtkUnstructuredGrid.h" -#include "vtkVoxel.h" - -#include "vtkClipConvexPolyData.h" -#include "vtkClipPolyData.h" -#include "vtkDensifyPolyData.h" - -#include "vtkImageResample.h" - -#include -#include // qsort() - -#include "vtkDataSetTriangleFilter.h" - -#include "vtkAbstractArray.h" // required if compiled against VTK 5.0 - -#include "vtkTessellatedBoxSource.h" -#include "vtkCleanPolyData.h" - -#include "vtkCommand.h" // for VolumeMapperRender{Start|End|Progress}Event -#include "vtkPerlinNoise.h" - -#include -#include "vtkStdString.h" - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -class vtkUnsupportedRequiredExtensionsStringStream -{ -public: - vtkstd::ostringstream Stream; - vtkUnsupportedRequiredExtensionsStringStream() - { - } -private: - // undefined copy constructor. - vtkUnsupportedRequiredExtensionsStringStream(const vtkUnsupportedRequiredExtensionsStringStream &other); - // undefined assignment operator. - vtkUnsupportedRequiredExtensionsStringStream &operator=(const vtkUnsupportedRequiredExtensionsStringStream &other); -}; - -class vtkMapDataArrayTextureId -{ -public: - vtkstd::map Map; - vtkMapDataArrayTextureId() - { - } -private: - // undefined copy constructor. - vtkMapDataArrayTextureId(const vtkMapDataArrayTextureId &other); - // undefined assignment operator. - vtkMapDataArrayTextureId &operator=(const vtkMapDataArrayTextureId &other); -}; - -class vtkMapMaskTextureId -{ -public: - vtkstd::map Map; - vtkMapMaskTextureId() - { - } -private: - // undefined copy constructor. - vtkMapMaskTextureId(const vtkMapMaskTextureId &other); - // undefined assignment operator. - vtkMapMaskTextureId &operator=(const vtkMapMaskTextureId &other); -}; - -//----------------------------------------------------------------------------- -extern const char *vtkMitkGPUVolumeRayCastMapper_CompositeFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_CompositeCroppingFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_CompositeNoCroppingFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_HeaderFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_MIPFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_MIPFourDependentFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_MIPFourDependentCroppingFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_MIPFourDependentNoCroppingFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_MIPCroppingFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_MIPNoCroppingFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_ParallelProjectionFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_PerspectiveProjectionFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_ScaleBiasFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_MinIPFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_MinIPFourDependentFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_MinIPFourDependentCroppingFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_MinIPFourDependentNoCroppingFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_MinIPCroppingFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_MinIPNoCroppingFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_CompositeMaskFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_NoShadeFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_ShadeFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_OneComponentFS; -extern const char *vtkMitkGPUVolumeRayCastMapper_FourComponentsFS; - -enum -{ - vtkMitkOpenGLGPUVolumeRayCastMapperProjectionNotInitialized=-1, // not init - vtkMitkOpenGLGPUVolumeRayCastMapperProjectionPerspective=0, // false - vtkMitkOpenGLGPUVolumeRayCastMapperProjectionParallel=1 // true -}; - -enum -{ - vtkMitkOpenGLGPUVolumeRayCastMapperMethodNotInitialized, - vtkMitkOpenGLGPUVolumeRayCastMapperMethodMIP, - vtkMitkOpenGLGPUVolumeRayCastMapperMethodMIPFourDependent, - vtkMitkOpenGLGPUVolumeRayCastMapperMethodComposite, - vtkMitkOpenGLGPUVolumeRayCastMapperMethodMinIP, - vtkMitkOpenGLGPUVolumeRayCastMapperMethodMinIPFourDependent, - vtkMitkOpenGLGPUVolumeRayCastMapperMethodCompositeMask -}; - -// component implementation -enum -{ - vtkMitkOpenGLGPUVolumeRayCastMapperComponentNotInitialized=-1, // not init - vtkMitkOpenGLGPUVolumeRayCastMapperComponentOne=0, // false - vtkMitkOpenGLGPUVolumeRayCastMapperComponentFour=1, // true - vtkMitkOpenGLGPUVolumeRayCastMapperComponentNotUsed=2 // when not composite -}; - -// Shade implementation -enum -{ - vtkMitkOpenGLGPUVolumeRayCastMapperShadeNotInitialized=-1, // not init - vtkMitkOpenGLGPUVolumeRayCastMapperShadeNo=0, // false - vtkMitkOpenGLGPUVolumeRayCastMapperShadeYes=1, // true - vtkMitkOpenGLGPUVolumeRayCastMapperShadeNotUsed=2 // when not composite -}; - - -// Cropping implementation -enum -{ - vtkMitkOpenGLGPUVolumeRayCastMapperCroppingNotInitialized, - vtkMitkOpenGLGPUVolumeRayCastMapperCompositeCropping, - vtkMitkOpenGLGPUVolumeRayCastMapperCompositeNoCropping, - vtkMitkOpenGLGPUVolumeRayCastMapperMIPCropping, - vtkMitkOpenGLGPUVolumeRayCastMapperMIPNoCropping, - vtkMitkOpenGLGPUVolumeRayCastMapperMIPFourDependentCropping, - vtkMitkOpenGLGPUVolumeRayCastMapperMIPFourDependentNoCropping, - vtkMitkOpenGLGPUVolumeRayCastMapperMinIPCropping, - vtkMitkOpenGLGPUVolumeRayCastMapperMinIPNoCropping, - vtkMitkOpenGLGPUVolumeRayCastMapperMinIPFourDependentCropping, - vtkMitkOpenGLGPUVolumeRayCastMapperMinIPFourDependentNoCropping -}; - -enum -{ - vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectDepthMap=0, // 2d texture - vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront // 2d texture -}; - -const int vtkMitkOpenGLGPUVolumeRayCastMapperNumberOfTextureObjects=vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+2; - -const int vtkMitkOpenGLGPUVolumeRayCastMapperOpacityTableSize=1024; //power of two - -#ifndef VTK_IMPLEMENT_MESA_CXX -vtkStandardNewMacro(vtkMitkOpenGLGPUVolumeRayCastMapper); -#endif - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -class vtkOpacityTable -{ -public: - vtkOpacityTable() - { - this->TextureId=0; - this->LastBlendMode=vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND; - this->LastSampleDistance=1.0; - this->Table=0; - this->Loaded=false; - this->LastLinearInterpolation=false; - } - - ~vtkOpacityTable() - { - if(this->TextureId!=0) - { - glDeleteTextures(1,&this->TextureId); - this->TextureId=0; - } - if(this->Table!=0) - { - delete[] this->Table; - this->Table=0; - } - } - - bool IsLoaded() - { - return this->Loaded; - } - - void Bind() - { - assert("pre: uptodate" && this->Loaded); - glBindTexture(GL_TEXTURE_1D,this->TextureId); - } - - // \pre the active texture is set to TEXTURE2 - void Update(vtkPiecewiseFunction *scalarOpacity, - int blendMode, - double sampleDistance, - double range[2], - double unitDistance, - bool linearInterpolation) - { - assert("pre: scalarOpacity_exists" && scalarOpacity!=0); - bool needUpdate=false; - if(this->TextureId==0) - { - glGenTextures(1,&this->TextureId); - needUpdate=true; - } - glBindTexture(GL_TEXTURE_1D,this->TextureId); - if(needUpdate) - { - glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, - vtkgl::CLAMP_TO_EDGE); - } - if(scalarOpacity->GetMTime() > this->BuildTime || - (this->LastBlendMode!=blendMode) - || (blendMode==vtkVolumeMapper::COMPOSITE_BLEND && - this->LastSampleDistance!=sampleDistance) - || needUpdate || !this->Loaded) - { - this->Loaded=false; - if(this->Table==0) - { - this->Table= - new float[vtkMitkOpenGLGPUVolumeRayCastMapperOpacityTableSize]; - } - - scalarOpacity->GetTable(range[0],range[1], - vtkMitkOpenGLGPUVolumeRayCastMapperOpacityTableSize, - this->Table); - - this->LastBlendMode=blendMode; - - // Correct the opacity array for the spacing between the planes if we - // are using a composite blending operation - if(blendMode==vtkVolumeMapper::COMPOSITE_BLEND) - { - float *ptr=this->Table; - double factor=sampleDistance/unitDistance; - int i=0; - while(i0.0001f) - { - *ptr=static_cast(1.0-pow(1.0-static_cast(*ptr), - factor)); - } - ++ptr; - ++i; - } - this->LastSampleDistance=sampleDistance; - } - glTexImage1D(GL_TEXTURE_1D,0,GL_ALPHA16, - vtkMitkOpenGLGPUVolumeRayCastMapperOpacityTableSize,0, - GL_ALPHA,GL_FLOAT,this->Table); - vtkMitkOpenGLGPUVolumeRayCastMapper::PrintError("1d opacity texture is too large"); - this->Loaded=true; - this->BuildTime.Modified(); - } - - needUpdate=needUpdate || - this->LastLinearInterpolation!=linearInterpolation; - if(needUpdate) - { - this->LastLinearInterpolation=linearInterpolation; - GLint value; - if(linearInterpolation) - { - value=GL_LINEAR; - } - else - { - value=GL_NEAREST; - } - glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MIN_FILTER,value); - glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MAG_FILTER,value); - } - } -protected: - GLuint TextureId; - int LastBlendMode; - double LastSampleDistance; - vtkTimeStamp BuildTime; - float *Table; - bool Loaded; - bool LastLinearInterpolation; -}; - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -class vtkOpacityTables -{ -public: - vtkstd::vector Vector; - vtkOpacityTables(size_t numberOfLevels) - : Vector(numberOfLevels) - { - } -private: - // undefined copy constructor. - vtkOpacityTables(const vtkOpacityTables &other); - // undefined assignment operator. - vtkOpacityTables &operator=(const vtkOpacityTables &other); -}; - -//----------------------------------------------------------------------------- -class vtkRGBTable -{ -public: - vtkRGBTable() - { - this->TextureId=0; - this->Table=0; - this->Loaded=false; - this->LastLinearInterpolation=false; - } - - ~vtkRGBTable() - { - if(this->TextureId!=0) - { - glDeleteTextures(1,&this->TextureId); - this->TextureId=0; - } - if(this->Table!=0) - { - delete[] this->Table; - this->Table=0; - } - } - - bool IsLoaded() - { - return this->Loaded; - } - - void Bind() - { - assert("pre: uptodate" && this->Loaded); - glBindTexture(GL_TEXTURE_1D,this->TextureId); - } - - // \pre the active texture is set properly. (default color, - // mask1, mask2,..) - void Update(vtkColorTransferFunction *scalarRGB, - double range[2], - bool linearInterpolation) - { - assert("pre: scalarRGB_exists" && scalarRGB!=0); - bool needUpdate=false; - if(this->TextureId==0) - { - glGenTextures(1,&this->TextureId); - needUpdate=true; - } - glBindTexture(GL_TEXTURE_1D,this->TextureId); - if(needUpdate) - { - glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, - vtkgl::CLAMP_TO_EDGE); - } - if(scalarRGB->GetMTime() > this->BuildTime - || needUpdate || !this->Loaded) - { - this->Loaded=false; - if(this->Table==0) - { - this->Table= - new float[vtkMitkOpenGLGPUVolumeRayCastMapperOpacityTableSize*3]; - } - - scalarRGB->GetTable(range[0],range[1], - vtkMitkOpenGLGPUVolumeRayCastMapperOpacityTableSize, - this->Table); - - glTexImage1D(GL_TEXTURE_1D,0,GL_RGB16, - vtkMitkOpenGLGPUVolumeRayCastMapperOpacityTableSize,0, - GL_RGB,GL_FLOAT,this->Table); - vtkMitkOpenGLGPUVolumeRayCastMapper::PrintError("1d RGB texture is too large"); - this->Loaded=true; - this->BuildTime.Modified(); - } - - needUpdate=needUpdate || - this->LastLinearInterpolation!=linearInterpolation; - if(needUpdate) - { - this->LastLinearInterpolation=linearInterpolation; - GLint value; - if(linearInterpolation) - { - value=GL_LINEAR; - } - else - { - value=GL_NEAREST; - } - glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MIN_FILTER,value); - glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MAG_FILTER,value); - } - } -protected: - GLuint TextureId; - vtkTimeStamp BuildTime; - float *Table; - bool Loaded; - bool LastLinearInterpolation; -}; - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -class vtkKWScalarField -{ -public: - vtkKWScalarField() - { - this->TextureId=0; - this->Loaded=false; - this->Supports_GL_ARB_texture_float=false; - this->LoadedTableRange[0]=0.0; - this->LoadedTableRange[1]=1.0; - this->LoadedExtent[0]=VTK_INT_MAX; - this->LoadedExtent[1]=VTK_INT_MIN; - this->LoadedExtent[2]=VTK_INT_MAX; - this->LoadedExtent[3]=VTK_INT_MIN; - this->LoadedExtent[4]=VTK_INT_MAX; - this->LoadedExtent[5]=VTK_INT_MIN; - } - ~vtkKWScalarField() - { - if(this->TextureId!=0) - { - glDeleteTextures(1,&this->TextureId); - this->TextureId=0; - } - } - - vtkTimeStamp GetBuildTime() - { - return this->BuildTime; - } - - void Bind() - { - assert("pre: uptodate" && this->Loaded); - glBindTexture(vtkgl::TEXTURE_3D,this->TextureId); - } - - void Update(vtkImageData *input, - int cellFlag, - int textureExtent[6], - int scalarMode, - int arrayAccessMode, - int arrayId, - const char *arrayName, - bool linearInterpolation, - double tableRange[2], - int maxMemoryInBytes) - { - bool needUpdate=false; - bool modified=false; - if(this->TextureId==0) - { - glGenTextures(1,&this->TextureId); - needUpdate=true; - } - glBindTexture(vtkgl::TEXTURE_3D,this->TextureId); - - int obsolete=needUpdate || !this->Loaded || input->GetMTime()>this->BuildTime; - if(!obsolete) - { - obsolete=cellFlag!=this->LoadedCellFlag; - int i=0; - while(!obsolete && i<6) - { - obsolete=obsolete || this->LoadedExtent[i]>textureExtent[i]; - ++i; - obsolete=obsolete || this->LoadedExtent[i]LoadedTableRange[0]!=tableRange[0] || - this->LoadedTableRange[1]!=tableRange[1]; - } - - if(obsolete) - { - this->Loaded=false; - int dim[3]; - input->GetDimensions(dim); - - GLint internalFormat=0; - GLenum format=0; - GLenum type=0; - // shift then scale: y:=(x+shift)*scale - double shift=0.0; - double scale=1.0; - int needTypeConversion=0; - vtkDataArray *sliceArray=0; - - vtkDataArray *scalars= - vtkAbstractMapper::GetScalars(input,scalarMode,arrayAccessMode, - arrayId,arrayName, - this->LoadedCellFlag); - - // DONT USE GetScalarType() or GetNumberOfScalarComponents() on - // ImageData as it deals only with point data... - - int scalarType=scalars->GetDataType(); - if(scalars->GetNumberOfComponents()==4) - { - // this is RGBA, unsigned char only - internalFormat=GL_RGBA16; - format=GL_RGBA; - type=GL_UNSIGNED_BYTE; - } - else - { - // input->GetNumberOfScalarComponents()==1 - switch(scalarType) - { - case VTK_FLOAT: - if(this->Supports_GL_ARB_texture_float) - { - internalFormat=vtkgl::INTENSITY16F_ARB; - } - else - { - internalFormat=GL_INTENSITY16; - } - format=GL_RED; - type=GL_FLOAT; - shift=-tableRange[0]; - scale=1/(tableRange[1]-tableRange[0]); - break; - case VTK_UNSIGNED_CHAR: - internalFormat=GL_INTENSITY8; - format=GL_RED; - type=GL_UNSIGNED_BYTE; - shift=-tableRange[0]/VTK_UNSIGNED_CHAR_MAX; - scale= - VTK_UNSIGNED_CHAR_MAX/(tableRange[1]-tableRange[0]); - break; - case VTK_SIGNED_CHAR: - internalFormat=GL_INTENSITY8; - format=GL_RED; - type=GL_BYTE; - shift=-(2*tableRange[0]+1)/VTK_UNSIGNED_CHAR_MAX; - scale=VTK_SIGNED_CHAR_MAX/(tableRange[1]-tableRange[0]); - break; - case VTK_CHAR: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_BIT: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_ID_TYPE: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_INT: - internalFormat=GL_INTENSITY16; - format=GL_RED; - type=GL_INT; - - shift=-(2*tableRange[0]+1)/VTK_UNSIGNED_INT_MAX; - scale=VTK_INT_MAX/(tableRange[1]-tableRange[0]); - break; - case VTK_DOUBLE: - case VTK___INT64: - case VTK_LONG: - case VTK_LONG_LONG: - case VTK_UNSIGNED___INT64: - case VTK_UNSIGNED_LONG: - case VTK_UNSIGNED_LONG_LONG: - needTypeConversion=1; // to float - if(this->Supports_GL_ARB_texture_float) - { - internalFormat=vtkgl::INTENSITY16F_ARB; - } - else - { - internalFormat=GL_INTENSITY16; - } - format=GL_RED; - type=GL_FLOAT; - shift=-tableRange[0]; - scale=1/(tableRange[1]-tableRange[0]); - sliceArray=vtkFloatArray::New(); - break; - case VTK_SHORT: - internalFormat=GL_INTENSITY16; - format=GL_RED; - type=GL_SHORT; - - shift=-(2*tableRange[0]+1)/VTK_UNSIGNED_SHORT_MAX; - scale=VTK_SHORT_MAX/(tableRange[1]-tableRange[0]); - break; - case VTK_STRING: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_UNSIGNED_SHORT: - internalFormat=GL_INTENSITY16; - format=GL_RED; - type=GL_UNSIGNED_SHORT; - - shift=-tableRange[0]/VTK_UNSIGNED_SHORT_MAX; - scale= - VTK_UNSIGNED_SHORT_MAX/(tableRange[1]-tableRange[0]); - break; - case VTK_UNSIGNED_INT: - internalFormat=GL_INTENSITY16; - format=GL_RED; - type=GL_UNSIGNED_INT; - - shift=-tableRange[0]/VTK_UNSIGNED_INT_MAX; - scale=VTK_UNSIGNED_INT_MAX/(tableRange[1]-tableRange[0]); - break; - default: - assert("check: impossible case" && 0); - break; - } - } - - // Enough memory? - int textureSize[3]; - int i=0; - while(i<3) - { - textureSize[i]=textureExtent[2*i+1]-textureExtent[2*i]+1; - ++i; - } - - GLint width; - glGetIntegerv(vtkgl::MAX_3D_TEXTURE_SIZE,&width); - this->Loaded=textureSize[0]<=width && textureSize[1]<=width - && textureSize[2]<=width; - if(this->Loaded) - { - // so far, so good. the texture size is theorically small enough - // for OpenGL - - vtkgl::TexImage3D(vtkgl::PROXY_TEXTURE_3D,0,internalFormat, - textureSize[0],textureSize[1],textureSize[2],0, - format,type,0); - glGetTexLevelParameteriv(vtkgl::PROXY_TEXTURE_3D,0,GL_TEXTURE_WIDTH, - &width); - - this->Loaded=width!=0; - if(this->Loaded) - { - // so far, so good but some cards always succeed with a proxy texture - // let's try to actually allocate.. - - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,internalFormat,textureSize[0], - textureSize[1],textureSize[2],0,format,type,0); - GLenum errorCode=glGetError(); - this->Loaded=errorCode!=GL_OUT_OF_MEMORY; - if(this->Loaded) - { - // so far, so good, actual allocation succeeded. - if(errorCode!=GL_NO_ERROR) - { - cout<<"after try to load the texture"; - cout<<" ERROR (x"<(errorCode)); - cout<Loaded=textureSize[0]*textureSize[1]* - textureSize[2]*vtkAbstractArray::GetDataTypeSize(scalarType)* - scalars->GetNumberOfComponents()<=maxMemoryInBytes; - if(this->Loaded) - { - // OK, we consider the allocation above succeeded... - // If it actually didn't the only to fix it for the user - // is to decrease the value of this->MaxMemoryInBytes. - - // enough memory! We can load the scalars! - - double bias=shift*scale; - - // we don't clamp to edge because for the computation of the - // gradient on the border we need some external value. - glTexParameterf(vtkgl::TEXTURE_3D,vtkgl::TEXTURE_WRAP_R,vtkgl::CLAMP_TO_EDGE); - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_WRAP_S,vtkgl::CLAMP_TO_EDGE); - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_WRAP_T,vtkgl::CLAMP_TO_EDGE); - - GLfloat borderColor[4]={0.0,0.0,0.0,0.0}; - - glTexParameterfv(vtkgl::TEXTURE_3D,GL_TEXTURE_BORDER_COLOR, borderColor); - - if(needTypeConversion) - { - // Convert and send to the GPU, z-slice by z-slice. - // Allocate memory on the GPU (NULL data pointer with the right - // dimensions) - // Here we are assuming that GL_ARB_texture_non_power_of_two is - // available - glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); - - // memory allocation is already done. - - // Send the slices: - // allocate CPU memory for a slice. - sliceArray->SetNumberOfComponents(1); // FB TODO CHECK THAT - sliceArray->SetNumberOfTuples(textureSize[0]*textureSize[1]); - - void *slicePtr=sliceArray->GetVoidPointer(0); - int k=0; - int kInc=(dim[0]-cellFlag)*(dim[1]-cellFlag); - int kOffset=(textureExtent[4]*(dim[1]-cellFlag) - +textureExtent[2])*(dim[0]-cellFlag) - +textureExtent[0]; - while(kSetTuple1(jDestOffset+i, - (scalars->GetTuple1(kOffset+jOffset - +i) - +shift)*scale); - ++i; - } - ++j; - jOffset+=dim[0]-cellFlag; - jDestOffset+=textureSize[0]; - } - - // Here we are assuming that GL_ARB_texture_non_power_of_two is - // available - vtkgl::TexSubImage3D(vtkgl::TEXTURE_3D, 0, - 0,0,k, - textureSize[0],textureSize[1], - 1, // depth is 1, not 0! - format,type, slicePtr); - ++k; - kOffset+=kInc; - } - sliceArray->Delete(); - } - else - { - // One chunk of data to the GPU. - // It works for the whole volume or for a subvolume. - // Here we are assuming that GL_ARB_texture_non_power_of_two is - // available - - // make sure any previous OpenGL call is executed and will not - // be disturbed by our PixelTransfer value - glFinish(); - glPixelTransferf(GL_RED_SCALE,static_cast(scale)); - glPixelTransferf(GL_RED_BIAS,static_cast(bias)); - glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); - - if(!(textureExtent[1]-textureExtent[0]+cellFlag==dim[0])) - { - glPixelStorei(GL_UNPACK_ROW_LENGTH,dim[0]-cellFlag); - } - if(!(textureExtent[3]-textureExtent[2]+cellFlag==dim[1])) - { - glPixelStorei(vtkgl::UNPACK_IMAGE_HEIGHT_EXT, - dim[1]-cellFlag); - } - void *dataPtr=scalars->GetVoidPointer( - ((textureExtent[4]*(dim[1]-cellFlag)+textureExtent[2]) - *(dim[0]-cellFlag)+textureExtent[0]) - *scalars->GetNumberOfComponents()); - - if(1) // !this->SupportsPixelBufferObjects) - { - vtkgl::TexImage3D(vtkgl::TEXTURE_3D, 0, internalFormat, - textureSize[0],textureSize[1],textureSize[2], - 0,format,type,dataPtr); - } - else - { - GLuint pbo=0; - vtkgl::GenBuffers(1,&pbo); - vtkMitkOpenGLGPUVolumeRayCastMapper::PrintError("genbuffer"); - vtkgl::BindBuffer(vtkgl::PIXEL_UNPACK_BUFFER,pbo); - vtkMitkOpenGLGPUVolumeRayCastMapper::PrintError("binbuffer"); - vtkgl::GLsizeiptr texSize= - textureSize[0]*textureSize[1]*textureSize[2]* - vtkAbstractArray::GetDataTypeSize(scalarType)* - scalars->GetNumberOfComponents(); - vtkgl::BufferData(vtkgl::PIXEL_UNPACK_BUFFER,texSize,dataPtr, - vtkgl::STREAM_DRAW); - vtkMitkOpenGLGPUVolumeRayCastMapper::PrintError("bufferdata"); - vtkgl::TexImage3D(vtkgl::TEXTURE_3D, 0, internalFormat, - textureSize[0],textureSize[1],textureSize[2], - 0,format,type,0); - vtkMitkOpenGLGPUVolumeRayCastMapper::PrintError("teximage3d"); - vtkgl::BindBuffer(vtkgl::PIXEL_UNPACK_BUFFER,0); - vtkMitkOpenGLGPUVolumeRayCastMapper::PrintError("bindbuffer to 0"); - vtkgl::DeleteBuffers(1,&pbo); - } - vtkMitkOpenGLGPUVolumeRayCastMapper::PrintError("3d texture is too large2"); - // make sure TexImage3D is executed with our PixelTransfer mode - glFinish(); - // Restore the default values. - glPixelStorei(GL_UNPACK_ROW_LENGTH,0); - glPixelStorei(vtkgl::UNPACK_IMAGE_HEIGHT_EXT,0); - glPixelTransferf(GL_RED_SCALE,1.0); - glPixelTransferf(GL_RED_BIAS,0.0); - } - this->LoadedCellFlag=cellFlag; - i=0; - while(i<6) - { - this->LoadedExtent[i]=textureExtent[i]; - ++i; - } - - double spacing[3]; - double origin[3]; - input->GetSpacing(spacing); - input->GetOrigin(origin); - int swapBounds[3]; - swapBounds[0]=(spacing[0]<0); - swapBounds[1]=(spacing[1]<0); - swapBounds[2]=(spacing[2]<0); - - if(!this->LoadedCellFlag) // loaded extents represent points - { - // slabsPoints[i]=(slabsDataSet[i] - origin[i/2]) / spacing[i/2]; - // in general, x=o+i*spacing. - // if spacing is positive min extent match the min of the - // bounding box - // and the max extent match the max of the bounding box - // if spacing is negative min extent match the max of the - // bounding box - // and the max extent match the min of the bounding box - - // if spacing is negative, we may have to rethink the equation - // between real point and texture coordinate... - this->LoadedBounds[0]=origin[0]+ - static_cast(this->LoadedExtent[0+swapBounds[0]])*spacing[0]; - this->LoadedBounds[2]=origin[1]+ - static_cast(this->LoadedExtent[2+swapBounds[1]])*spacing[1]; - this->LoadedBounds[4]=origin[2]+ - static_cast(this->LoadedExtent[4+swapBounds[2]])*spacing[2]; - this->LoadedBounds[1]=origin[0]+ - static_cast(this->LoadedExtent[1-swapBounds[0]])*spacing[0]; - this->LoadedBounds[3]=origin[1]+ - static_cast(this->LoadedExtent[3-swapBounds[1]])*spacing[1]; - this->LoadedBounds[5]=origin[2]+ - static_cast(this->LoadedExtent[5-swapBounds[2]])*spacing[2]; - - } - else // loaded extents represent cells - { - int wholeTextureExtent[6]; - input->GetExtent(wholeTextureExtent); - i=1; - while(i<6) - { - wholeTextureExtent[i]--; - i+=2; - } - - i=0; - while(i<3) - { - if(this->LoadedExtent[2*i]==wholeTextureExtent[2*i]) - { - this->LoadedBounds[2*i+swapBounds[i]]=origin[i]; - } - else - { - this->LoadedBounds[2*i+swapBounds[i]]=origin[i]+ - (static_cast(this->LoadedExtent[2*i])+0.5)*spacing[i]; - } - - if(this->LoadedExtent[2*i+1]==wholeTextureExtent[2*i+1]) - { - this->LoadedBounds[2*i+1-swapBounds[i]]=origin[i]+ - (static_cast(this->LoadedExtent[2*i+1])+1.0)*spacing[i]; - } - else - { - this->LoadedBounds[2*i+1-swapBounds[i]]=origin[i]+ - (static_cast(this->LoadedExtent[2*i+1])+0.5)*spacing[i]; - } - ++i; - } - } - this->LoadedTableRange[0]=tableRange[0]; - this->LoadedTableRange[1]=tableRange[1]; - modified=true; - } // if enough memory - else - { - } - } //load fail with out of memory - else - { - } - } // proxy ok - else - { // proxy failed - } - } - else - { - // out of therical limitationa - } - } // if obsolete - - if(this->Loaded && - (needUpdate || modified || - linearInterpolation!=this->LinearInterpolation)) - { - this->LinearInterpolation=linearInterpolation; - if(this->LinearInterpolation) - { - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_MIN_FILTER, - GL_LINEAR); - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_MAG_FILTER, - GL_LINEAR); - } - else - { - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_MIN_FILTER, - GL_NEAREST ); - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_MAG_FILTER, - GL_NEAREST ); - } - modified=true; - } - if(modified) - { - this->BuildTime.Modified(); - } - } - - double *GetLoadedBounds() - { - assert("pre: loaded" && this->Loaded); - return this->LoadedBounds; - } - - vtkIdType *GetLoadedExtent() - { - assert("pre: loaded" && this->Loaded); - return this->LoadedExtent; - } - - int GetLoadedCellFlag() - { - assert("pre: loaded" && this->Loaded); - return this->LoadedCellFlag; - } - - bool IsLoaded() - { - return this->Loaded; - } - - bool GetSupports_GL_ARB_texture_float() - { - return this->Supports_GL_ARB_texture_float; - } - - void SetSupports_GL_ARB_texture_float(bool value) - { - this->Supports_GL_ARB_texture_float=value; - } - -protected: - GLuint TextureId; - vtkTimeStamp BuildTime; - double LoadedBounds[6]; - vtkIdType LoadedExtent[6]; - int LoadedCellFlag; - bool Loaded; - bool LinearInterpolation; - bool Supports_GL_ARB_texture_float; - double LoadedTableRange[2]; -}; - - -//----------------------------------------------------------------------------- -class vtkKWMask -{ -public: - vtkKWMask() - { - this->TextureId=0; - this->Loaded=false; - this->LoadedExtent[0]=VTK_INT_MAX; - this->LoadedExtent[1]=VTK_INT_MIN; - this->LoadedExtent[2]=VTK_INT_MAX; - this->LoadedExtent[3]=VTK_INT_MIN; - this->LoadedExtent[4]=VTK_INT_MAX; - this->LoadedExtent[5]=VTK_INT_MIN; - } - ~vtkKWMask() - { - if(this->TextureId!=0) - { - glDeleteTextures(1,&this->TextureId); - this->TextureId=0; - } - } - - vtkTimeStamp GetBuildTime() - { - return this->BuildTime; - } - - // \pre vtkgl::ActiveTexture(vtkgl::TEXTURE7) has to be called first. - void Bind() - { - assert("pre: uptodate" && this->Loaded); - glBindTexture(vtkgl::TEXTURE_3D,this->TextureId); - } - - // \pre vtkgl::ActiveTexture(vtkgl::TEXTURE7) has to be called first. - void Update(vtkImageData *input, - int cellFlag, - int textureExtent[6], - int scalarMode, - int arrayAccessMode, - int arrayId, - const char *arrayName, - int maxMemoryInBytes) - { - bool needUpdate=false; - bool modified=false; - if(this->TextureId==0) - { - glGenTextures(1,&this->TextureId); - needUpdate=true; - } - glBindTexture(vtkgl::TEXTURE_3D,this->TextureId); - - int obsolete=needUpdate || !this->Loaded - || input->GetMTime()>this->BuildTime; - if(!obsolete) - { - obsolete=cellFlag!=this->LoadedCellFlag; - int i=0; - while(!obsolete && i<6) - { - obsolete=obsolete || this->LoadedExtent[i]>textureExtent[i]; - ++i; - obsolete=obsolete || this->LoadedExtent[i]Loaded=false; - int dim[3]; - input->GetDimensions(dim); - - vtkDataArray *scalars= - vtkAbstractMapper::GetScalars(input,scalarMode,arrayAccessMode, - arrayId,arrayName, - this->LoadedCellFlag); - - // DONT USE GetScalarType() or GetNumberOfScalarComponents() on - // ImageData as it deals only with point data... - - int scalarType=scalars->GetDataType(); - if(scalarType!=VTK_UNSIGNED_CHAR) - { - cout <<"mask should be VTK_UNSIGNED_CHAR." << endl; - } - if(scalars->GetNumberOfComponents()!=1) - { - cout <<"mask should be a one-component scalar field." << endl; - } - - GLint internalFormat=GL_ALPHA8; - GLenum format=GL_ALPHA; - GLenum type=GL_UNSIGNED_BYTE; - - // Enough memory? - int textureSize[3]; - int i=0; - while(i<3) - { - textureSize[i]=textureExtent[2*i+1]-textureExtent[2*i]+1; - ++i; - } - - GLint width; - glGetIntegerv(vtkgl::MAX_3D_TEXTURE_SIZE,&width); - this->Loaded=textureSize[0]<=width && textureSize[1]<=width - && textureSize[2]<=width; - if(this->Loaded) - { - // so far, so good. the texture size is theorically small enough - // for OpenGL - - vtkgl::TexImage3D(vtkgl::PROXY_TEXTURE_3D,0,internalFormat, - textureSize[0],textureSize[1],textureSize[2],0, - format,type,0); - glGetTexLevelParameteriv(vtkgl::PROXY_TEXTURE_3D,0,GL_TEXTURE_WIDTH, - &width); - - this->Loaded=width!=0; - if(this->Loaded) - { - // so far, so good but some cards always succeed with a proxy texture - // let's try to actually allocate.. - - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,internalFormat,textureSize[0], - textureSize[1],textureSize[2],0,format,type,0); - GLenum errorCode=glGetError(); - this->Loaded=errorCode!=GL_OUT_OF_MEMORY; - if(this->Loaded) - { - // so far, so good, actual allocation succeeded. - if(errorCode!=GL_NO_ERROR) - { - cout<<"after try to load the texture"; - cout<<" ERROR (x"<(errorCode)); - cout<Loaded=textureSize[0]*textureSize[1]* - textureSize[2]*vtkAbstractArray::GetDataTypeSize(scalarType)* - scalars->GetNumberOfComponents()<=maxMemoryInBytes; - if(this->Loaded) - { - // OK, we consider the allocation above succeeded... - // If it actually didn't the only to fix it for the user - // is to decrease the value of this->MaxMemoryInBytes. - - // enough memory! We can load the scalars! - - // we don't clamp to edge because for the computation of the - // gradient on the border we need some external value. - glTexParameterf(vtkgl::TEXTURE_3D,vtkgl::TEXTURE_WRAP_R,vtkgl::CLAMP_TO_EDGE); - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_WRAP_S,vtkgl::CLAMP_TO_EDGE); - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_WRAP_T,vtkgl::CLAMP_TO_EDGE); - - GLfloat borderColor[4]={0.0,0.0,0.0,0.0}; - - glTexParameterfv(vtkgl::TEXTURE_3D,GL_TEXTURE_BORDER_COLOR, borderColor); - - glPixelTransferf(GL_ALPHA_SCALE,1.0); - glPixelTransferf(GL_ALPHA_BIAS,0.0); - glPixelStorei(GL_UNPACK_ALIGNMENT,1); - - if(!(textureExtent[1]-textureExtent[0]+cellFlag==dim[0])) - { - glPixelStorei(GL_UNPACK_ROW_LENGTH,dim[0]-cellFlag); - } - if(!(textureExtent[3]-textureExtent[2]+cellFlag==dim[1])) - { - glPixelStorei(vtkgl::UNPACK_IMAGE_HEIGHT_EXT, - dim[1]-cellFlag); - } - void *dataPtr=scalars->GetVoidPointer( - ((textureExtent[4]*(dim[1]-cellFlag)+textureExtent[2]) - *(dim[0]-cellFlag)+textureExtent[0]) - *scalars->GetNumberOfComponents()); - - vtkgl::TexImage3D(vtkgl::TEXTURE_3D, 0, internalFormat, - textureSize[0],textureSize[1],textureSize[2], - 0,format,type,dataPtr); - - // Restore the default values. - glPixelStorei(GL_UNPACK_ROW_LENGTH,0); - glPixelStorei(vtkgl::UNPACK_IMAGE_HEIGHT_EXT,0); - glPixelTransferf(GL_ALPHA_SCALE,1.0); - glPixelTransferf(GL_ALPHA_BIAS,0.0); - - this->LoadedCellFlag=cellFlag; - i=0; - while(i<6) - { - this->LoadedExtent[i]=textureExtent[i]; - ++i; - } - - double spacing[3]; - double origin[3]; - input->GetSpacing(spacing); - input->GetOrigin(origin); - int swapBounds[3]; - swapBounds[0]=(spacing[0]<0); - swapBounds[1]=(spacing[1]<0); - swapBounds[2]=(spacing[2]<0); - - if(!this->LoadedCellFlag) // loaded extents represent points - { - // slabsPoints[i]=(slabsDataSet[i] - origin[i/2]) / spacing[i/2]; - // in general, x=o+i*spacing. - // if spacing is positive min extent match the min of the - // bounding box - // and the max extent match the max of the bounding box - // if spacing is negative min extent match the max of the - // bounding box - // and the max extent match the min of the bounding box - - // if spacing is negative, we may have to rethink the equation - // between real point and texture coordinate... - this->LoadedBounds[0]=origin[0]+ - static_cast(this->LoadedExtent[0+swapBounds[0]])*spacing[0]; - this->LoadedBounds[2]=origin[1]+ - static_cast(this->LoadedExtent[2+swapBounds[1]])*spacing[1]; - this->LoadedBounds[4]=origin[2]+ - static_cast(this->LoadedExtent[4+swapBounds[2]])*spacing[2]; - this->LoadedBounds[1]=origin[0]+ - static_cast(this->LoadedExtent[1-swapBounds[0]])*spacing[0]; - this->LoadedBounds[3]=origin[1]+ - static_cast(this->LoadedExtent[3-swapBounds[1]])*spacing[1]; - this->LoadedBounds[5]=origin[2]+ - static_cast(this->LoadedExtent[5-swapBounds[2]])*spacing[2]; - - } - else // loaded extents represent cells - { - int wholeTextureExtent[6]; - input->GetExtent(wholeTextureExtent); - i=1; - while(i<6) - { - wholeTextureExtent[i]--; - i+=2; - } - - i=0; - while(i<3) - { - if(this->LoadedExtent[2*i]==wholeTextureExtent[2*i]) - { - this->LoadedBounds[2*i+swapBounds[i]]=origin[i]; - } - else - { - this->LoadedBounds[2*i+swapBounds[i]]=origin[i]+ - (static_cast(this->LoadedExtent[2*i])+0.5)*spacing[i]; - } - - if(this->LoadedExtent[2*i+1]==wholeTextureExtent[2*i+1]) - { - this->LoadedBounds[2*i+1-swapBounds[i]]=origin[i]+ - (static_cast(this->LoadedExtent[2*i+1])+1.0)*spacing[i]; - } - else - { - this->LoadedBounds[2*i+1-swapBounds[i]]=origin[i]+ - (static_cast(this->LoadedExtent[2*i+1])+0.5)*spacing[i]; - } - ++i; - } - } - modified=true; - } // if enough memory - else - { - } - } //load fail with out of memory - else - { - } - } // proxy ok - else - { // proxy failed - } - } - else - { - // out of therical limitationa - } - } // if obsolete - - if(this->Loaded && (needUpdate || modified)) - { - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_MIN_FILTER, - GL_NEAREST ); - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_MAG_FILTER, - GL_NEAREST ); - modified=true; - } - if(modified) - { - this->BuildTime.Modified(); - } - } - - double *GetLoadedBounds() - { - assert("pre: loaded" && this->Loaded); - return this->LoadedBounds; - } - - vtkIdType *GetLoadedExtent() - { - assert("pre: loaded" && this->Loaded); - return this->LoadedExtent; - } - - int GetLoadedCellFlag() - { - assert("pre: loaded" && this->Loaded); - return this->LoadedCellFlag; - } - - bool IsLoaded() - { - return this->Loaded; - } - -protected: - GLuint TextureId; - vtkTimeStamp BuildTime; - double LoadedBounds[6]; - vtkIdType LoadedExtent[6]; - int LoadedCellFlag; - bool Loaded; -}; - - -//----------------------------------------------------------------------------- -// Display the status of the current framebuffer on the standard output. -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::CheckFrameBufferStatus() -{ - GLenum status; - status = vtkgl::CheckFramebufferStatusEXT(vtkgl::FRAMEBUFFER_EXT); - switch(status) - { - case 0: - cout << "call to vtkgl::CheckFramebufferStatusEXT generates an error." - << endl; - break; - case vtkgl::FRAMEBUFFER_COMPLETE_EXT: - break; - case vtkgl::FRAMEBUFFER_UNSUPPORTED_EXT: - cout << "framebuffer is unsupported" << endl; - break; - case vtkgl::FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: - cout << "framebuffer has an attachment error"<DisplayFrameBufferAttachments(); -// this->DisplayReadAndDrawBuffers(); -} - -//----------------------------------------------------------------------------- -vtkStdString vtkMitkOpenGLGPUVolumeRayCastMapper::BufferToString(int buffer) -{ - vtkStdString result; - vtksys_ios::ostringstream ost; - - GLint size; - - GLint b=static_cast(buffer); - switch(b) - { - case GL_NONE: - ost << "GL_NONE"; - break; - case GL_FRONT_LEFT: - ost << "GL_FRONT_LEFT"; - break; - case GL_FRONT_RIGHT: - ost << "GL_FRONT_RIGHT"; - break; - case GL_BACK_LEFT: - ost << "GL_BACK_LEFT"; - break; - case GL_BACK_RIGHT: - ost << "GL_BACK_RIGHT"; - break; - case GL_FRONT: - ost << "GL_FRONT"; - break; - case GL_BACK: - ost << "GL_BACK"; - break; - case GL_LEFT: - ost << "GL_LEFT"; - break; - case GL_RIGHT: - ost << "GL_RIGHT"; - break; - case GL_FRONT_AND_BACK: - ost << "GL_FRONT_AND_BACK"; - break; - default: - glGetIntegerv(GL_AUX_BUFFERS,&size); - if(buffer>=GL_AUX0 && buffer<(GL_AUX0+size)) - { - ost << "GL_AUX" << (buffer-GL_AUX0); - } - else - { - glGetIntegerv(vtkgl::MAX_COLOR_ATTACHMENTS_EXT,&size); - if(static_cast(buffer)>=vtkgl::COLOR_ATTACHMENT0_EXT && - static_cast(buffer)< - (vtkgl::COLOR_ATTACHMENT0_EXT+static_cast(size))) - { - ost << "GL_COLOR_ATTACHMENT" - << (static_cast(buffer)-vtkgl::COLOR_ATTACHMENT0_EXT) - << "_EXT"; - } - else - { - ost << "unknown color buffer type=0x"<(value); - - vtkStdString s; - GLenum i=0; - while(iBufferToString(static_cast(value)); - cout << "draw buffer " << i << "=" << s << endl; - ++i; - } - - glGetIntegerv(GL_READ_BUFFER,&value); - s=this->BufferToString(static_cast(value)); - cout << "read buffer=" << s << endl; -} - -// ---------------------------------------------------------------------------- -// Description: -// Display all the attachments of the current framebuffer object. -// ---------------------------------------------------------------------------- -// -// ---------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::DisplayFrameBufferAttachments() -{ - GLint framebufferBinding; - glGetIntegerv(vtkgl::FRAMEBUFFER_BINDING_EXT,&framebufferBinding); - this->PrintError("after getting FRAMEBUFFER_BINDING_EXT"); - if(framebufferBinding==0) - { - cout<<"Current framebuffer is bind to the system one"<(value); - this->PrintError("after getting MAX_COLOR_ATTACHMENTS_EXT"); - GLenum i=0; - while(iDisplayFrameBufferAttachment(vtkgl::COLOR_ATTACHMENT0_EXT+i); - ++i; - } - cout<<"depth attachement :"<DisplayFrameBufferAttachment(vtkgl::DEPTH_ATTACHMENT_EXT); - cout<<"stencil attachement :"<DisplayFrameBufferAttachment(vtkgl::STENCIL_ATTACHMENT_EXT); - } -} - -// ---------------------------------------------------------------------------- -// Description: -// Display a given attachment for the current framebuffer object. -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::DisplayFrameBufferAttachment( - unsigned int uattachment) -{ - GLenum attachment=static_cast(uattachment); - - GLint params; - vtkgl::GetFramebufferAttachmentParameterivEXT( - vtkgl::FRAMEBUFFER_EXT,attachment, - vtkgl::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT,¶ms); - - this->PrintError("after getting FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT"); - switch(params) - { - case GL_NONE: - cout<<" this attachment is empty"<PrintError("after getting FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT"); - cout<<" this attachment is a texture with name: "<PrintError( - "after getting FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT"); - cout<<" its mipmap level is: "<PrintError( - "after getting FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT"); - if(params==0) - { - cout<<" this is not a cube map texture."<PrintError( - "after getting FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT"); - if(params==0) - { - cout<<" this is not 3D texture."<PrintError("after getting FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT"); - cout<<" this attachment is a renderbuffer with name: "<(params)); - this->PrintError( - "after getting binding the current RENDERBUFFER_EXT to params"); - - vtkgl::GetRenderbufferParameterivEXT(vtkgl::RENDERBUFFER_EXT, - vtkgl::RENDERBUFFER_WIDTH_EXT, - ¶ms); - this->PrintError("after getting RENDERBUFFER_WIDTH_EXT"); - cout<<" renderbuffer width="<PrintError("after getting RENDERBUFFER_HEIGHT_EXT"); - cout<<" renderbuffer height="<PrintError("after getting RENDERBUFFER_INTERNAL_FORMAT_EXT"); - - cout<<" renderbuffer internal format=0x"<< hex<PrintError("after getting RENDERBUFFER_RED_SIZE_EXT"); - cout<<" renderbuffer actual resolution for the red component="<PrintError("after getting RENDERBUFFER_GREEN_SIZE_EXT"); - cout<<" renderbuffer actual resolution for the green component="<PrintError("after getting RENDERBUFFER_BLUE_SIZE_EXT"); - cout<<" renderbuffer actual resolution for the blue component="<PrintError("after getting RENDERBUFFER_ALPHA_SIZE_EXT"); - cout<<" renderbuffer actual resolution for the alpha component="<PrintError("after getting RENDERBUFFER_DEPTH_SIZE_EXT"); - cout<<" renderbuffer actual resolution for the depth component="<PrintError("after getting RENDERBUFFER_STENCIL_SIZE_EXT"); - cout<<" renderbuffer actual resolution for the stencil component=" - <(errorCode)) - { - case GL_NO_ERROR: - result="No error"; - break; - case GL_INVALID_ENUM: - result="Invalid enum"; - break; - case GL_INVALID_VALUE: - result="Invalid value"; - break; - case GL_INVALID_OPERATION: - result="Invalid operation"; - break; - case GL_STACK_OVERFLOW: - result="stack overflow"; - break; - case GL_STACK_UNDERFLOW: - result="stack underflow"; - break; - case GL_OUT_OF_MEMORY: - result="out of memory"; - break; - case vtkgl::TABLE_TOO_LARGE: - // GL_ARB_imaging - result="Table too large"; - break; - case vtkgl::INVALID_FRAMEBUFFER_OPERATION_EXT: - // GL_EXT_framebuffer_object, 310 - result="invalid framebuffer operation ext"; - break; - case vtkgl::TEXTURE_TOO_LARGE_EXT: - // GL_EXT_texture - result="Texture too large"; - break; - default: - result="unknown error"; - } - assert("post: result_exists" && result!=0); - return result; -} - -//----------------------------------------------------------------------------- -// Display headerMessage on the standard output and the last OpenGL error -// message if any. -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::PrintError(const char *headerMessage) -{ - GLenum errorCode=glGetError(); - if(errorCode!=GL_NO_ERROR) - { - if ( headerMessage ) - { - cout<(errorCode)); - cout<UnsupportedRequiredExtensions=0; - this->OpenGLObjectsCreated=0; - this->LoadExtensionsSucceeded=0; - this->NumberOfFrameBuffers=0; - - this->m_BindMax = false; - - // up to 2 frame buffer 2D textures (left/right) - // 1 dataset 3D texture - // 1 colormap 1D texture - // 1 opacitymap 1d texture - // 1 grabbed depth buffer 2d texture - int i=0; - while(iTextureObjects[i]=0; - ++i; - } - - this->DepthRenderBufferObject=0; - this->FrameBufferObject=0; - - for ( int j = 0; j < 8; j++ ) - { - for (i = 0; i < 3; i++ ) - { - this->BoundingBox[j][i] = 0.0; - } - } - - this->LastSize[0]=0; - this->LastSize[1]=0; - - this->ReductionFactor = 1.0; - - this->Supports_GL_ARB_texture_float=0; - this->SupportsPixelBufferObjects=0; - - i=0; - while(i<3) - { - this->TempMatrix[i]=vtkMatrix4x4::New(); - ++i; - } - - this->ErrorLine=0; - this->ErrorColumn=0; - this->ErrorString=0; - - this->LastParallelProjection= - vtkMitkOpenGLGPUVolumeRayCastMapperProjectionNotInitialized; - this->LastRayCastMethod= - vtkMitkOpenGLGPUVolumeRayCastMapperMethodNotInitialized; - this->LastCroppingMode= - vtkMitkOpenGLGPUVolumeRayCastMapperCroppingNotInitialized; - this->LastComponent= - vtkMitkOpenGLGPUVolumeRayCastMapperComponentNotInitialized; - this->LastShade=vtkMitkOpenGLGPUVolumeRayCastMapperShadeNotInitialized; - - this->ClippedBoundingBox = NULL; - - this->SmallInput = NULL; - - this->MaxValueFrameBuffer=0; - this->MaxValueFrameBuffer2=0; - this->ReducedSize[0]=0; - this->ReducedSize[1]=0; - - this->NumberOfCroppingRegions=0; - - this->PolyDataBoundingBox=0; - this->Planes=0; - this->NearPlane=0; - this->Clip=0; - this->Densify=0; - this->InvVolumeMatrix=vtkMatrix4x4::New(); - - this->ScaleBiasProgramShader=0; - this->UFrameBufferTexture=-1; - this->UScale=-1; - this->UBias=-1; - - this->SavedFrameBuffer=0; - - this->BoxSource=0; - - this->NoiseTexture=0; - this->NoiseTextureSize=0; - this->NoiseTextureId=0; - - this->IgnoreSampleDistancePerPixel=true; - - this->ScalarsTextures=new vtkMapDataArrayTextureId; - this->MaskTextures=new vtkMapMaskTextureId; - - this->RGBTable=0; - this->Mask1RGBTable=0; - this->Mask2RGBTable=0; - this->OpacityTables=0; - - this->CurrentScalar=0; - this->CurrentMask=0; - - this->ActualSampleDistance=1.0; - this->LastProgressEventTime=0.0; // date in seconds - - this->PreserveOrientation=true; -} - -//----------------------------------------------------------------------------- -// Destruct a vtkMitkOpenGLGPUVolumeRayCastMapper - clean up any memory used -//----------------------------------------------------------------------------- -vtkMitkOpenGLGPUVolumeRayCastMapper::~vtkMitkOpenGLGPUVolumeRayCastMapper() -{ - if(this->UnsupportedRequiredExtensions!=0) - { - delete this->UnsupportedRequiredExtensions; - this->UnsupportedRequiredExtensions=0; - } - int i=0; - while(i<3) - { - this->TempMatrix[i]->Delete(); - this->TempMatrix[i]=0; - ++i; - } - - if(this->ErrorString!=0) - { - delete[] this->ErrorString; - this->ErrorString=0; - } - - if ( this->SmallInput ) - { - this->SmallInput->UnRegister(this); - } - - if(this->PolyDataBoundingBox!=0) - { - this->PolyDataBoundingBox->UnRegister(this); - this->PolyDataBoundingBox=0; - } - if(this->Planes!=0) - { - this->Planes->UnRegister(this); - this->Planes=0; - } - if(this->NearPlane!=0) - { - this->NearPlane->UnRegister(this); - this->NearPlane=0; - } - if(this->Clip!=0) - { - this->Clip->UnRegister(this); - this->Clip=0; - } - if(this->Densify!=0) - { - this->Densify->UnRegister(this); - this->Densify=0; - } - - if(this->BoxSource!=0) - { - this->BoxSource->UnRegister(this); - this->BoxSource=0; - } - this->InvVolumeMatrix->UnRegister(this); - this->InvVolumeMatrix=0; - - if(this->NoiseTexture!=0) - { - delete[] this->NoiseTexture; - this->NoiseTexture=0; - this->NoiseTextureSize=0; - } - - if(this->ScalarsTextures!=0) - { - delete this->ScalarsTextures; - this->ScalarsTextures=0; - } - - if(this->MaskTextures!=0) - { - delete this->MaskTextures; - this->MaskTextures=0; - } -} - -//----------------------------------------------------------------------------- -// Based on hardware and properties, we may or may not be able to -// render using 3D texture mapping. This indicates if 3D texture -// mapping is supported by the hardware, and if the other extensions -// necessary to support the specific properties are available. -// -//----------------------------------------------------------------------------- -int vtkMitkOpenGLGPUVolumeRayCastMapper::IsRenderSupported( - vtkRenderWindow *window, - vtkVolumeProperty *vtkNotUsed(property)) -{ - window->MakeCurrent(); - if(!this->LoadExtensionsSucceeded) - { - this->LoadExtensions(window); - } - if(!this->LoadExtensionsSucceeded) - { - vtkDebugMacro( - "The following OpenGL extensions are required but not supported: " - << (this->UnsupportedRequiredExtensions->Stream.str()).c_str()); - return 0; - } - return 1; -} - -//----------------------------------------------------------------------------- -// Return if the required OpenGL extension `extensionName' is supported. -// If not, its name is added to the string of unsupported but required -// extensions. -// \pre extensions_exist: extensions!=0 -// \pre extensionName_exists: extensionName!=0 -//----------------------------------------------------------------------------- -int vtkMitkOpenGLGPUVolumeRayCastMapper::TestRequiredExtension( - vtkOpenGLExtensionManager *extensions, - const char *extensionName) -{ - assert("pre: extensions_exist" && extensions!=0); - assert("pre: extensionName_exists" && extensionName!=0); - int result=extensions->ExtensionSupported(extensionName); - - if(!result) - { - if(this->LoadExtensionsSucceeded) - { - this->UnsupportedRequiredExtensions->Stream<LoadExtensionsSucceeded=0; - } - else - { - this->UnsupportedRequiredExtensions->Stream<<", "<LoadExtensionsSucceeded will be set to 0 or 1 -// - this->UnsupportedRequiredExtensions will have a message indicating -// any failure codes -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::LoadExtensions( - vtkRenderWindow *window) -{ - // We may already have a string stream for the unsupported extensions - // from the last time this method was called. If so, delete it. - if(this->UnsupportedRequiredExtensions!=0) - { - delete this->UnsupportedRequiredExtensions; - } - - // Create a string stream to hold the unsupported extensions so we can - // report something meaningful back - this->UnsupportedRequiredExtensions = - new vtkUnsupportedRequiredExtensionsStringStream; - - // It does not work on Apple OS X Snow Leopard with nVidia. - // There is a bug in the OpenGL driver with an error in the - // Cg compiler about an infinite loop. -#ifdef __APPLE__ - this->LoadExtensionsSucceeded=0; - return; -#endif - - // Assume success - this->LoadExtensionsSucceeded=1; - - const char *gl_vendor=reinterpret_cast(glGetString(GL_VENDOR)); - /* if(strstr(gl_vendor,"ATI")!=0) - { - this->LoadExtensionsSucceeded=0; - return; - }*/ - const char *gl_version=reinterpret_cast(glGetString(GL_VERSION)); - if(strstr(gl_version,"Mesa")!=0) - { - // - GL_VENDOR cannot be used because it can be "Brian Paul" or - // "Mesa project" - // - GL_RENDERER cannot be used because it can be "Software Rasterizer" or - // "Mesa X11" - // - GL_VERSION is more robust. It has things like "2.0 Mesa 7.0.4" or - // "2.1 Mesa 7.2" or "2.1 Mesa 7.3-devel" - // Mesa does not work with multiple draw buffers: - // "framebuffer has bad draw buffer" - // "render clipped 1 ERROR (x506) invalid framebuffer operation ext" - this->LoadExtensionsSucceeded=0; - return; - } - - // Create an extension manager - vtkOpenGLExtensionManager *extensions=vtkOpenGLExtensionManager::New(); - extensions->SetRenderWindow(window); - - // GL_ARB_draw_buffers requires OpenGL 1.3, so we must have OpenGL 1.3 - // We don't need to check for some extensions that become part of OpenGL - // core after 1.3. Among them: - // - texture_3d is in core OpenGL since 1.2 - // - texture_edge_clamp is in core OpenGL since 1.2 - // (GL_SGIS_texture_edge_clamp or GL_EXT_texture_edge_clamp (nVidia) ) - // - multitexture is in core OpenGL since 1.3 - - int supports_GL_1_3=extensions->ExtensionSupported("GL_VERSION_1_3"); - int supports_GL_2_0=0; - - // No 1.3 support - give up - if(!supports_GL_1_3) - { - this->LoadExtensionsSucceeded=0; - this->UnsupportedRequiredExtensions->Stream<< - " OpenGL 1.3 is required but not supported"; - extensions->Delete(); - return; - } - - // Check for 2.0 support - supports_GL_2_0=extensions->ExtensionSupported("GL_VERSION_2_0"); - - // Some extensions that are supported in 2.0, but if we don't - // have 2.0 we'll need to check further - int supports_shading_language_100 = 1; - int supports_shader_objects = 1; - int supports_fragment_shader = 1; - int supports_texture_non_power_of_two = 1; - int supports_draw_buffers = 1; - if(!supports_GL_2_0) - { - supports_shading_language_100= - extensions->ExtensionSupported("GL_ARB_shading_language_100"); - supports_shader_objects= - extensions->ExtensionSupported("GL_ARB_shader_objects"); - supports_fragment_shader= - extensions->ExtensionSupported("GL_ARB_fragment_shader"); - supports_texture_non_power_of_two= - extensions->ExtensionSupported("GL_ARB_texture_non_power_of_two"); - supports_draw_buffers= - extensions->ExtensionSupported("GL_ARB_draw_buffers"); - } - - // We have to check for framebuffer objects - int supports_GL_EXT_framebuffer_object= - extensions->ExtensionSupported("GL_EXT_framebuffer_object" ); - - // Find out if we have OpenGL 1.4 support - int supports_GL_1_4=extensions->ExtensionSupported("GL_VERSION_1_4"); - - // Find out if we have the depth texture ARB extension - int supports_GL_ARB_depth_texture= - extensions->ExtensionSupported("GL_ARB_depth_texture"); - - // Depth textures are support if we either have OpenGL 1.4 - // or if the depth texture ARB extension is supported - int supports_depth_texture = - supports_GL_1_4 || supports_GL_ARB_depth_texture; - - // Now start adding messages to the UnsupportedRequiredExtensions string - // Log message if shading language 100 is not supported - if(!supports_shading_language_100) - { - this->UnsupportedRequiredExtensions->Stream<< - " shading_language_100 (or OpenGL 2.0) is required but not supported"; - this->LoadExtensionsSucceeded=0; - } - else - { - // We can query the GLSL version, we need >=1.20 - const char *glsl_version= - reinterpret_cast(glGetString(vtkgl::SHADING_LANGUAGE_VERSION)); - int glslMajor, glslMinor; - vtksys_ios::istringstream ist(glsl_version); - ist >> glslMajor; - char c; - ist.get(c); // '.' - ist >> glslMinor; -//sscanf(version, "%d.%d", &glslMajor, &glslMinor); - if(glslMajor<1 || (glslMajor==1 && glslMinor<20)) - { - this->LoadExtensionsSucceeded=0; - } - } - - // Log message if shader objects are not supported - if(!supports_shader_objects) - { - this->UnsupportedRequiredExtensions->Stream<< - " shader_objects (or OpenGL 2.0) is required but not supported"; - this->LoadExtensionsSucceeded=0; - } - - // Log message if fragment shaders are not supported - if(!supports_fragment_shader) - { - this->UnsupportedRequiredExtensions->Stream<< - " fragment_shader (or OpenGL 2.0) is required but not supported"; - this->LoadExtensionsSucceeded=0; - } - - // Log message if non power of two textures are not supported - if(!supports_texture_non_power_of_two) - { - this->UnsupportedRequiredExtensions->Stream<< - " texture_non_power_of_two (or OpenGL 2.0) is required but not " - << "supported"; - this->LoadExtensionsSucceeded=0; - } - - // Log message if draw buffers are not supported - if(!supports_draw_buffers) - { - this->UnsupportedRequiredExtensions->Stream<< - " draw_buffers (or OpenGL 2.0) is required but not supported"; - this->LoadExtensionsSucceeded=0; - } - - // Log message if depth textures are not supported - if(!supports_depth_texture) - { - this->UnsupportedRequiredExtensions->Stream<< - " depth_texture (or OpenGL 1.4) is required but not supported"; - this->LoadExtensionsSucceeded=0; - } - - // Log message if framebuffer objects are not supported - if(!supports_GL_EXT_framebuffer_object) - { - this->UnsupportedRequiredExtensions->Stream<< - " framebuffer_object is required but not supported"; - this->LoadExtensionsSucceeded=0; - } - - // Have we succeeded so far? If not, just return. - if(!this->LoadExtensionsSucceeded) - { - extensions->Delete(); - return; - } - - // Now start loading the extensions - // First load all 1.2 and 1.3 extensions (we know we - // support at least up to 1.3) - extensions->LoadExtension("GL_VERSION_1_2"); - extensions->LoadExtension("GL_VERSION_1_3"); - - // Load the 2.0 extensions if supported - if(supports_GL_2_0) - { - extensions->LoadExtension("GL_VERSION_2_0"); - } - // Otherwise, we'll need to specifically load the - // shader objects, fragment shader, and draw buffers - // extensions - else - { - extensions->LoadCorePromotedExtension("GL_ARB_shader_objects"); - extensions->LoadCorePromotedExtension("GL_ARB_fragment_shader"); - extensions->LoadCorePromotedExtension("GL_ARB_draw_buffers"); - } - - // Load the framebuffer object extension - extensions->LoadExtension("GL_EXT_framebuffer_object"); - - // Optional extension (does not fail if not present) - // Load it if supported which will allow us to store - // textures as floats - this->Supports_GL_ARB_texture_float= - extensions->ExtensionSupported("GL_ARB_texture_float" ); - if(this->Supports_GL_ARB_texture_float) - { - extensions->LoadExtension( "GL_ARB_texture_float" ); - } - - // Optional extension (does not fail if not present) - // Used to minimize memory footprint when loading large 3D textures - // of scalars. - // VBO or 1.5 is required by PBO or 2.1 - int supports_GL_1_5=extensions->ExtensionSupported("GL_VERSION_1_5"); - int supports_vertex_buffer_object=supports_GL_1_5 || - extensions->ExtensionSupported("GL_ARB_vertex_buffer_object"); - int supports_GL_2_1=extensions->ExtensionSupported("GL_VERSION_2_1"); - this->SupportsPixelBufferObjects=supports_vertex_buffer_object && - (supports_GL_2_1 || - extensions->ExtensionSupported("GL_ARB_pixel_buffer_object")); - - if(this->SupportsPixelBufferObjects) - { - if(supports_GL_1_5) - { - extensions->LoadExtension("GL_VERSION_1_5"); - } - else - { - extensions->LoadCorePromotedExtension("GL_ARB_vertex_buffer_object"); - } - if(supports_GL_2_1) - { - extensions->LoadExtension("GL_VERSION_2_1"); - } - else - { - extensions->LoadCorePromotedExtension("GL_ARB_pixel_buffer_object"); - } - } - - // Ultimate test. Some old cards support OpenGL 2.0 but not while - // statements in a fragment shader (example: nVidia GeForce FX 5200) - // It does not fail when compiling each shader source but at linking - // stage because the parser underneath only check for syntax during - // compilation and the actual native code generation happens during - // the linking stage. - this->CreateGLSLObjects(); - this->NumberOfCroppingRegions=1; - this->BuildProgram(1,vtkMitkOpenGLGPUVolumeRayCastMapperMethodComposite, - vtkMitkOpenGLGPUVolumeRayCastMapperShadeNo, - vtkMitkOpenGLGPUVolumeRayCastMapperComponentOne); - - GLint params; - vtkgl::GetProgramiv(static_cast(this->ProgramShader), - vtkgl::LINK_STATUS,¶ms); - if(params==GL_FALSE) - { - this->LoadExtensionsSucceeded=0; - this->UnsupportedRequiredExtensions->Stream<< - " this card does not support while statements in fragment shaders."; - } - - // FB debug - this->CheckLinkage(this->ProgramShader); - - // Release GLSL Objects. - GLuint programShader=static_cast(this->ProgramShader); - vtkgl::DeleteProgram(programShader); - - this->LastParallelProjection= - vtkMitkOpenGLGPUVolumeRayCastMapperProjectionNotInitialized; - this->LastRayCastMethod= - vtkMitkOpenGLGPUVolumeRayCastMapperMethodNotInitialized; - this->LastCroppingMode= - vtkMitkOpenGLGPUVolumeRayCastMapperCroppingNotInitialized; - this->LastComponent= - vtkMitkOpenGLGPUVolumeRayCastMapperComponentNotInitialized; - this->LastShade=vtkMitkOpenGLGPUVolumeRayCastMapperShadeNotInitialized; - - extensions->Delete(); -} - -//----------------------------------------------------------------------------- -// Create GLSL OpenGL objects such fragment program Ids. -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::CreateGLSLObjects() -{ - GLuint programShader; - GLuint fragmentMainShader; - - programShader=vtkgl::CreateProgram(); - fragmentMainShader=vtkgl::CreateShader(vtkgl::FRAGMENT_SHADER); - vtkgl::AttachShader(programShader,fragmentMainShader); - vtkgl::DeleteShader(fragmentMainShader); // reference counting - - vtkgl::ShaderSource( - fragmentMainShader,1, - const_cast(&vtkMitkGPUVolumeRayCastMapper_HeaderFS),0); - vtkgl::CompileShader(fragmentMainShader); - - this->CheckCompilation(static_cast(fragmentMainShader)); - - GLuint fragmentProjectionShader; - GLuint fragmentTraceShader; - GLuint fragmentCroppingShader; - GLuint fragmentComponentShader; - GLuint fragmentShadeShader; - - fragmentProjectionShader=vtkgl::CreateShader(vtkgl::FRAGMENT_SHADER); - vtkgl::AttachShader(programShader,fragmentProjectionShader); - vtkgl::DeleteShader(fragmentProjectionShader); // reference counting - - fragmentTraceShader=vtkgl::CreateShader(vtkgl::FRAGMENT_SHADER); - vtkgl::AttachShader(programShader,fragmentTraceShader); - vtkgl::DeleteShader(fragmentTraceShader); // reference counting - fragmentCroppingShader=vtkgl::CreateShader(vtkgl::FRAGMENT_SHADER); - vtkgl::AttachShader(programShader,fragmentCroppingShader); - vtkgl::DeleteShader(fragmentCroppingShader); // reference counting - - fragmentComponentShader=vtkgl::CreateShader(vtkgl::FRAGMENT_SHADER); - - // don't delete it, it is optionally attached. - fragmentShadeShader=vtkgl::CreateShader(vtkgl::FRAGMENT_SHADER); - - // Save GL objects by static casting to standard C types. GL* types - // are not allowed in VTK header files. - this->ProgramShader=static_cast(programShader); - - this->FragmentMainShader=static_cast(fragmentMainShader); - this->FragmentProjectionShader= - static_cast(fragmentProjectionShader); - this->FragmentTraceShader=static_cast(fragmentTraceShader); - this->FragmentCroppingShader= - static_cast(fragmentCroppingShader); - this->FragmentComponentShader= - static_cast(fragmentComponentShader); - this->FragmentShadeShader= - static_cast(fragmentShadeShader); - -} - -void vtkMitkOpenGLGPUVolumeRayCastMapper::BindFramebuffer() -{ - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D, - this->TextureObjects[vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront], - 0); - GLenum err = glGetError(); - - if(m_BindMax) - { - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT+1, - GL_TEXTURE_2D,this->MaxValueFrameBuffer,0); - } -} - -//----------------------------------------------------------------------------- -// Create OpenGL objects such as textures, buffers and fragment program Ids. -// It only registers Ids, there is no actual initialization of textures or -// fragment program. -// -// Pre-conditions: -// This method assumes that this->LoadedExtensionsSucceeded is 1. -// -// Post-conditions: -// When this method completes successfully, this->OpenGLObjectsCreated -// will be 1. -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::CreateOpenGLObjects() -{ - // Do nothing if the OpenGL objects have already been created - if ( this->OpenGLObjectsCreated ) - { - return; - } - - // We need only two color buffers (ping-pong) - this->NumberOfFrameBuffers=2; - - // TODO: clean this up! - // 2*Frame buffers(2d textures)+colorMap (1d texture) +dataset (3d texture) - // + opacitymap (1d texture) + grabbed depthMap (2d texture) - - // Frame buffers(2d textures)+colorMap (1d texture) +dataset (3d texture) - // + opacity (1d texture)+grabbed depth buffer (2d texture) - - GLuint frameBufferObject; - GLuint depthRenderBufferObject; - GLuint textureObjects[vtkMitkOpenGLGPUVolumeRayCastMapperNumberOfTextureObjects]; - - // Create the various objects we will need - one frame buffer - // which will contain a render buffer for depth and a texture - // for color. - vtkgl::GenFramebuffersEXT(1, &frameBufferObject); // color - vtkgl::GenRenderbuffersEXT(1, &depthRenderBufferObject); // depth - glGenTextures(vtkMitkOpenGLGPUVolumeRayCastMapperNumberOfTextureObjects,textureObjects); - - // Color buffers - GLint value; - glGetIntegerv(vtkgl::FRAMEBUFFER_BINDING_EXT,&value); - GLuint savedFrameBuffer=static_cast(value); - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT,frameBufferObject); - - - // Depth buffer - vtkgl::BindRenderbufferEXT(vtkgl::RENDERBUFFER_EXT, - depthRenderBufferObject); - - vtkgl::FramebufferRenderbufferEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::DEPTH_ATTACHMENT_EXT, - vtkgl::RENDERBUFFER_EXT, - depthRenderBufferObject); - - // Restore default frame buffer. - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT,savedFrameBuffer); - - - this->CreateGLSLObjects(); - - // Save GL objects by static casting to standard C types. GL* types - // are not allowed in VTK header files. - this->FrameBufferObject=static_cast(frameBufferObject); - this->DepthRenderBufferObject=static_cast(depthRenderBufferObject); - int i=0; - while(iTextureObjects[i]=static_cast(textureObjects[i]); - ++i; - } - - - this->OpenGLObjectsCreated=1; -} - - -//----------------------------------------------------------------------------- -// Check the compilation status of some fragment shader source. -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::CheckCompilation( - unsigned int fragmentShader) -{ - GLuint fs=static_cast(fragmentShader); - GLint params; - vtkgl::GetShaderiv(fs,vtkgl::COMPILE_STATUS,¶ms); - - if(params==GL_TRUE) - { - vtkDebugMacro(<<"shader source compiled successfully"); - } - else - { - vtkErrorMacro(<<"shader source compile error"); - // include null terminator - vtkgl::GetShaderiv(fs,vtkgl::INFO_LOG_LENGTH,¶ms); - if(params>0) - { - char *buffer=new char[params]; - vtkgl::GetShaderInfoLog(fs,params,0,buffer); - vtkErrorMacro(<<"log: "<(programShader); - - // info about the list of active uniform variables - vtkgl::GetProgramiv(prog,vtkgl::ACTIVE_UNIFORMS,¶ms); - cout<<"There are "<(params); - vtkgl::GetProgramiv(prog,vtkgl::OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB, - ¶ms); - - GLint buffSize=params; - char *name=new char[buffSize+1]; - GLint size; - GLenum type; - while(i(programShader); - vtkgl::GetProgramiv(prog,vtkgl::LINK_STATUS,¶ms); - int status = 0; - if(params==GL_TRUE) - { - status = 1; - vtkDebugMacro(<<"program linked successfully"); - } - else - { - vtkErrorMacro(<<"program link error"); - vtkgl::GetProgramiv(prog,vtkgl::INFO_LOG_LENGTH,¶ms); - if(params>0) - { - char *buffer=new char[params]; - vtkgl::GetProgramInfoLog(prog,params,0,buffer); - vtkErrorMacro(<<"log: "<OpenGLObjectsCreated==0 -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::ReleaseGraphicsResources( - vtkWindow *window) -{ - if(this->OpenGLObjectsCreated) - { - window->MakeCurrent(); - this->LastSize[0]=0; - this->LastSize[1]=0; - GLuint frameBufferObject=static_cast(this->FrameBufferObject); - vtkgl::DeleteFramebuffersEXT(1,&frameBufferObject); - GLuint depthRenderBufferObject= - static_cast(this->DepthRenderBufferObject); - vtkgl::DeleteRenderbuffersEXT(1,&depthRenderBufferObject); - GLuint textureObjects[vtkMitkOpenGLGPUVolumeRayCastMapperNumberOfTextureObjects]; - int i=0; - while(i<(vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+this->NumberOfFrameBuffers)) - { - textureObjects[i]=static_cast(this->TextureObjects[i]); - ++i; - } - glDeleteTextures(vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+this->NumberOfFrameBuffers,textureObjects); - - if(this->MaxValueFrameBuffer!=0) - { - GLuint maxValueFrameBuffer= - static_cast(this->MaxValueFrameBuffer); - glDeleteTextures(1,&maxValueFrameBuffer); - this->MaxValueFrameBuffer=0; - } - if(this->MaxValueFrameBuffer2!=0) - { - GLuint maxValueFrameBuffer2= - static_cast(this->MaxValueFrameBuffer2); - glDeleteTextures(1,&maxValueFrameBuffer2); - this->MaxValueFrameBuffer2=0; - } - - GLuint programShader=static_cast(this->ProgramShader); - vtkgl::DeleteProgram(programShader); - this->ProgramShader=0; - GLuint fragmentComponentShader= - static_cast(this->FragmentComponentShader); - vtkgl::DeleteShader(fragmentComponentShader); - GLuint fragmentShadeShader= - static_cast(this->FragmentShadeShader); - vtkgl::DeleteShader(fragmentShadeShader); - - GLuint scaleBiasProgramShader= - static_cast(this->ScaleBiasProgramShader); - if(scaleBiasProgramShader!=0) - { - vtkgl::DeleteProgram(scaleBiasProgramShader); - this->ScaleBiasProgramShader=0; - } - this->LastParallelProjection= - vtkMitkOpenGLGPUVolumeRayCastMapperProjectionNotInitialized; - this->LastRayCastMethod= - vtkMitkOpenGLGPUVolumeRayCastMapperMethodNotInitialized; - this->LastCroppingMode= - vtkMitkOpenGLGPUVolumeRayCastMapperCroppingNotInitialized; - this->LastComponent= - vtkMitkOpenGLGPUVolumeRayCastMapperComponentNotInitialized; - this->LastShade=vtkMitkOpenGLGPUVolumeRayCastMapperShadeNotInitialized; - this->OpenGLObjectsCreated=0; - } - - if(this->NoiseTextureId!=0) - { - window->MakeCurrent(); - GLuint noiseTextureObjects=static_cast(this->NoiseTextureId); - glDeleteTextures(1,&noiseTextureObjects); - this->NoiseTextureId=0; - } - - if(this->ScalarsTextures!=0) - { - if(!this->ScalarsTextures->Map.empty()) - { - vtkstd::map::iterator it=this->ScalarsTextures->Map.begin(); - while(it!=this->ScalarsTextures->Map.end()) - { - vtkKWScalarField *texture=(*it).second; - delete texture; - ++it; - } - this->ScalarsTextures->Map.clear(); - } - } - - if(this->MaskTextures!=0) - { - if(!this->MaskTextures->Map.empty()) - { - vtkstd::map::iterator it=this->MaskTextures->Map.begin(); - while(it!=this->MaskTextures->Map.end()) - { - vtkKWMask *texture=(*it).second; - delete texture; - ++it; - } - this->MaskTextures->Map.clear(); - } - } - - if(this->RGBTable!=0) - { - delete this->RGBTable; - this->RGBTable=0; - } - - if(this->Mask1RGBTable!=0) - { - delete this->Mask1RGBTable; - this->Mask1RGBTable=0; - } - - if(this->Mask2RGBTable!=0) - { - delete this->Mask2RGBTable; - this->Mask2RGBTable=0; - } - - if(this->OpacityTables!=0) - { - delete this->OpacityTables; - this->OpacityTables=0; - } -} - - - -//----------------------------------------------------------------------------- -// Delete OpenGL objects. -// \post done: this->OpenGLObjectsCreated==0 -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::ReleaseGraphicsResources( - mitk::BaseRenderer * renderer) -{ - if(this->OpenGLObjectsCreated) - { - vtkWindow * window = renderer->GetVtkRenderer()->GetRenderWindow(); - window->MakeCurrent(); - this->LastSize[0]=0; - this->LastSize[1]=0; - GLuint frameBufferObject=static_cast(this->FrameBufferObject); - vtkgl::DeleteFramebuffersEXT(1,&frameBufferObject); - GLuint depthRenderBufferObject= - static_cast(this->DepthRenderBufferObject); - vtkgl::DeleteRenderbuffersEXT(1,&depthRenderBufferObject); - GLuint textureObjects[vtkMitkOpenGLGPUVolumeRayCastMapperNumberOfTextureObjects]; - int i=0; - while(i<(vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+this->NumberOfFrameBuffers)) - { - textureObjects[i]=static_cast(this->TextureObjects[i]); - ++i; - } - glDeleteTextures(vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+this->NumberOfFrameBuffers,textureObjects); - - if(this->MaxValueFrameBuffer!=0) - { - GLuint maxValueFrameBuffer= - static_cast(this->MaxValueFrameBuffer); - glDeleteTextures(1,&maxValueFrameBuffer); - this->MaxValueFrameBuffer=0; - } - if(this->MaxValueFrameBuffer2!=0) - { - GLuint maxValueFrameBuffer2= - static_cast(this->MaxValueFrameBuffer2); - glDeleteTextures(1,&maxValueFrameBuffer2); - this->MaxValueFrameBuffer2=0; - } - - GLuint programShader=static_cast(this->ProgramShader); - vtkgl::DeleteProgram(programShader); - this->ProgramShader=0; - GLuint fragmentComponentShader= - static_cast(this->FragmentComponentShader); - vtkgl::DeleteShader(fragmentComponentShader); - GLuint fragmentShadeShader= - static_cast(this->FragmentShadeShader); - vtkgl::DeleteShader(fragmentShadeShader); - - GLuint scaleBiasProgramShader= - static_cast(this->ScaleBiasProgramShader); - if(scaleBiasProgramShader!=0) - { - vtkgl::DeleteProgram(scaleBiasProgramShader); - this->ScaleBiasProgramShader=0; - } - this->LastParallelProjection= - vtkMitkOpenGLGPUVolumeRayCastMapperProjectionNotInitialized; - this->LastRayCastMethod= - vtkMitkOpenGLGPUVolumeRayCastMapperMethodNotInitialized; - this->LastCroppingMode= - vtkMitkOpenGLGPUVolumeRayCastMapperCroppingNotInitialized; - this->LastComponent= - vtkMitkOpenGLGPUVolumeRayCastMapperComponentNotInitialized; - this->LastShade=vtkMitkOpenGLGPUVolumeRayCastMapperShadeNotInitialized; - this->OpenGLObjectsCreated=0; - } - - if(this->NoiseTextureId!=0) - { - window->MakeCurrent(); - GLuint noiseTextureObjects=static_cast(this->NoiseTextureId); - glDeleteTextures(1,&noiseTextureObjects); - this->NoiseTextureId=0; - } - - if(this->ScalarsTextures!=0) - { - if(!this->ScalarsTextures->Map.empty()) - { - vtkstd::map::iterator it=this->ScalarsTextures->Map.begin(); - while(it!=this->ScalarsTextures->Map.end()) - { - vtkKWScalarField *texture=(*it).second; - delete texture; - ++it; - } - this->ScalarsTextures->Map.clear(); - } - } - - if(this->MaskTextures!=0) - { - if(!this->MaskTextures->Map.empty()) - { - vtkstd::map::iterator it=this->MaskTextures->Map.begin(); - while(it!=this->MaskTextures->Map.end()) - { - vtkKWMask *texture=(*it).second; - delete texture; - ++it; - } - this->MaskTextures->Map.clear(); - } - } - - if(this->RGBTable!=0) - { - delete this->RGBTable; - this->RGBTable=0; - } - - if(this->Mask1RGBTable!=0) - { - delete this->Mask1RGBTable; - this->Mask1RGBTable=0; - } - - if(this->Mask2RGBTable!=0) - { - delete this->Mask2RGBTable; - this->Mask2RGBTable=0; - } - - if(this->OpacityTables!=0) - { - delete this->OpacityTables; - this->OpacityTables=0; - } -} - - -//----------------------------------------------------------------------------- -// Allocate memory on the GPU for the framebuffers according to the size of -// the window or reallocate if the size has changed. Return true if -// allocation succeeded. -// \pre ren_exists: ren!=0 -// \pre opengl_objects_created: this->OpenGLObjectsCreated -// \post right_size: LastSize[]=window size. -//----------------------------------------------------------------------------- -int vtkMitkOpenGLGPUVolumeRayCastMapper::AllocateFrameBuffers(vtkRenderer *ren) -{ - assert("pre: ren_exists" && ren!=0); - assert("pre: opengl_objects_created" && this->OpenGLObjectsCreated); - - int result=1; - int size[2]; - ren->GetTiledSize(&size[0],&size[1]); - - int sizeChanged=this->LastSize[0]!=size[0] || this->LastSize[1]!=size[1]; - - GLenum errorCode=glGetError(); - - // Need allocation? - if(sizeChanged) - { - int i=0; - GLenum errorCode=glGetError(); - - while(i NumberOfFrameBuffers && errorCode==GL_NO_ERROR) - { - glBindTexture(GL_TEXTURE_2D,static_cast(this->TextureObjects[vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+i])); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - // Here we are assuming that GL_ARB_texture_non_power_of_two is available - if(this->Supports_GL_ARB_texture_float) - { - glTexImage2D(GL_TEXTURE_2D,0,vtkgl::RGBA16F_ARB,size[0],size[1], - 0, GL_RGBA, GL_FLOAT, NULL ); - } - else - { - glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA16,size[0],size[1], - 0, GL_RGBA, GL_FLOAT, NULL ); - } - errorCode=glGetError(); - - ++i; - } - if(errorCode==GL_NO_ERROR) - { - // grabbed depth buffer - glBindTexture(GL_TEXTURE_2D,static_cast(this->TextureObjects[vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectDepthMap])); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameteri(GL_TEXTURE_2D, vtkgl::DEPTH_TEXTURE_MODE, GL_LUMINANCE); - glTexImage2D(GL_TEXTURE_2D, 0, vtkgl::DEPTH_COMPONENT32, size[0],size[1], - 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL ); - - // Set up the depth render buffer - - GLint savedFrameBuffer; - glGetIntegerv(vtkgl::FRAMEBUFFER_BINDING_EXT,&savedFrameBuffer); - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, - static_cast(this->FrameBufferObject)); - - this->BindFramebuffer(); - - vtkgl::BindRenderbufferEXT( - vtkgl::RENDERBUFFER_EXT, - static_cast(this->DepthRenderBufferObject)); - vtkgl::RenderbufferStorageEXT(vtkgl::RENDERBUFFER_EXT, - vtkgl::DEPTH_COMPONENT24,size[0],size[1]); - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, - static_cast(savedFrameBuffer)); - errorCode=glGetError(); - - if(errorCode==GL_NO_ERROR) - { - this->LastSize[0]=size[0]; - this->LastSize[1]=size[1]; - } - } - result=errorCode==GL_NO_ERROR; - } - - int needNewMaxValueBuffer=this->MaxValueFrameBuffer==0 && - (this->BlendMode==vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND || - this->BlendMode==vtkMitkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND); - - if(needNewMaxValueBuffer) - { - - // blend mode changed and need max value buffer. - - // create and bind second color buffer (we use only the red component - // to store the max scalar). We cant use a one component color buffer - // because all color buffer have to have the same format. - - // max scalar frame buffer - GLuint maxValueFrameBuffer; - glGenTextures(1,&maxValueFrameBuffer); - this->MaxValueFrameBuffer= - static_cast(maxValueFrameBuffer); - - // Color buffers - - this->m_BindMax = true; - - // max scalar frame buffer2 - GLuint maxValueFrameBuffer2; - - glGenTextures(1,&maxValueFrameBuffer2); - - glBindTexture(GL_TEXTURE_2D,maxValueFrameBuffer2); - this->MaxValueFrameBuffer2= - static_cast(maxValueFrameBuffer2); - - } - else - { - if(this->MaxValueFrameBuffer!=0 && - (this->BlendMode!=vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND - && - this->BlendMode!=vtkMitkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND)) - { - // blend mode changed and does not need max value buffer anymore. - - GLint savedFrameBuffer; - glGetIntegerv(vtkgl::FRAMEBUFFER_BINDING_EXT,&savedFrameBuffer); - - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, - static_cast(this->FrameBufferObject)); - - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT+1, - GL_TEXTURE_2D,0,0); // not scalar buffer - - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, - static_cast(savedFrameBuffer)); - - GLuint maxValueFrameBuffer= - static_cast(this->MaxValueFrameBuffer); - glDeleteTextures(1,&maxValueFrameBuffer); - this->MaxValueFrameBuffer=0; - - m_BindMax = false; - - GLuint maxValueFrameBuffer2= - static_cast(this->MaxValueFrameBuffer2); - glDeleteTextures(1,&maxValueFrameBuffer2); - this->MaxValueFrameBuffer2=0; - } - } - - if((this->BlendMode==vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND - || this->BlendMode==vtkMitkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND) && (sizeChanged || needNewMaxValueBuffer)) - { - - // max scalar frame buffer - GLuint maxValueFrameBuffer=static_cast(this->MaxValueFrameBuffer); - glBindTexture(GL_TEXTURE_2D,maxValueFrameBuffer); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - // Here we are assuming that GL_ARB_texture_non_power_of_two is available - - if(this->Supports_GL_ARB_texture_float) - { - glTexImage2D(GL_TEXTURE_2D,0,vtkgl::RGBA16F_ARB,size[0],size[1], - 0, GL_RGBA, GL_FLOAT, NULL ); - } - else - { - glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA16,size[0],size[1], - 0, GL_RGBA, GL_FLOAT, NULL ); - } - - // max scalar frame buffer 2 - GLuint maxValueFrameBuffer2=static_cast(this->MaxValueFrameBuffer2); - glBindTexture(GL_TEXTURE_2D,maxValueFrameBuffer2); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - // Here we are assuming that GL_ARB_texture_non_power_of_two is available - if(this->Supports_GL_ARB_texture_float) - { - glTexImage2D(GL_TEXTURE_2D,0,vtkgl::RGBA16F_ARB,size[0],size[1], - 0, GL_RGBA, GL_FLOAT, NULL ); - } - else - { - glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA16,size[0],size[1], - 0, GL_RGBA, GL_FLOAT, NULL ); - } - - } - - PrintError("AllocateFrameBuffers"); - return result; -} - - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::GetTextureFormat( - vtkImageData *input, - unsigned int *internalFormat, - unsigned int *format, - unsigned int *type, - int *componentSize) -{ - *internalFormat=0; - *format=0; - *type=0; - *componentSize=0; - - vtkDataArray *scalars=this->GetScalars(input,this->ScalarMode, - this->ArrayAccessMode, - this->ArrayId, - this->ArrayName, - this->CellFlag); - - int scalarType=scalars->GetDataType(); - int components=scalars->GetNumberOfComponents(); - *componentSize=vtkAbstractArray::GetDataTypeSize(scalarType)*components; - - if(components==4) - { - // this is RGBA, unsigned char only - *internalFormat=GL_RGBA16; - *format=GL_RGBA; - *type=GL_UNSIGNED_BYTE; - } - else - { - // components==1 - switch(scalarType) - { - case VTK_FLOAT: - if(this->Supports_GL_ARB_texture_float) - { - *internalFormat=vtkgl::INTENSITY16F_ARB; - } - else - { - *internalFormat=GL_INTENSITY16; - } - *format=GL_RED; - *type=GL_FLOAT; - break; - case VTK_UNSIGNED_CHAR: - *internalFormat=GL_INTENSITY8; - *format=GL_RED; - *type=GL_UNSIGNED_BYTE; - break; - case VTK_SIGNED_CHAR: - *internalFormat=GL_INTENSITY8; - *format=GL_RED; - *type=GL_BYTE; - break; - case VTK_CHAR: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_BIT: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_ID_TYPE: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_INT: - *internalFormat=GL_INTENSITY16; - *format=GL_RED; - *type=GL_INT; - break; - case VTK_DOUBLE: - case VTK___INT64: - case VTK_LONG: - case VTK_LONG_LONG: - case VTK_UNSIGNED___INT64: - case VTK_UNSIGNED_LONG: - case VTK_UNSIGNED_LONG_LONG: - if(this->Supports_GL_ARB_texture_float) - { - *internalFormat=vtkgl::INTENSITY16F_ARB; - } - else - { - *internalFormat=GL_INTENSITY16; - } - *format=GL_RED; - *type=GL_FLOAT; - break; - case VTK_SHORT: - *internalFormat=GL_INTENSITY16; - *format=GL_RED; - *type=GL_SHORT; - break; - case VTK_STRING: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_UNSIGNED_SHORT: - *internalFormat=GL_INTENSITY16; - *format=GL_RED; - *type=GL_UNSIGNED_SHORT; - break; - case VTK_UNSIGNED_INT: - *internalFormat=GL_INTENSITY16; - *format=GL_RED; - *type=GL_UNSIGNED_INT; - break; - default: - assert("check: impossible case" && 0); - break; - } - } -} - -//----------------------------------------------------------------------------- -// Assuming the textureSize[3] is less of equal to the maximum size of an -// OpenGL 3D texture, try to see if the texture can fit on the card. -//----------------------------------------------------------------------------- -bool vtkMitkOpenGLGPUVolumeRayCastMapper::TestLoadingScalar( - unsigned int internalFormat, - unsigned int format, - unsigned int type, - int textureSize[3], - int componentSize) -{ - // componentSize=vtkAbstractArray::GetDataTypeSize(scalarType)*input->GetNumberOfScalarComponents() - - bool result; - - vtkgl::TexImage3D(vtkgl::PROXY_TEXTURE_3D,0, - static_cast(internalFormat), - textureSize[0],textureSize[1],textureSize[2],0, - format, - type,0); - GLint width; - glGetTexLevelParameteriv(vtkgl::PROXY_TEXTURE_3D,0,GL_TEXTURE_WIDTH, - &width); - - result=width!=0; - if(result) - { - // so far, so good but some cards always succeed with a proxy texture - // let's try to actually allocate.. - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,static_cast(internalFormat), - textureSize[0], - textureSize[1],textureSize[2],0, - format, - type,0); - GLenum errorCode=glGetError(); - - result=errorCode!=GL_OUT_OF_MEMORY; - if(result) - { - if(errorCode!=GL_NO_ERROR) - { - cout<<"after try to load the texture"; - cout<<" ERROR (x"<(errorCode)); - cout<(this->MaxMemoryInBytes)*this->MaxMemoryFraction; - } - } - return result; -} - -//----------------------------------------------------------------------------- -// Load the scalar field (one or four component scalar field), cell or point -// based for a given subextent of the whole extent (can be the whole extent) -// as a 3D texture on the GPU. -// Extents are expressed in point if the cell flag is false or in cells of -// the cell flag is true. -// It returns true if it succeeded, false if there is not enough memory on -// the GPU. -// If succeeded, it updates the LoadedExtent, LoadedBounds, LoadedCellFlag -// and LoadedTime. It also succeed if the scalar field is already loaded -// (ie since last load, input has not changed and cell flag has not changed -// and requested texture extents are enclosed in the loaded extent). -// \pre input_exists: input!=0 -// \pre valid_point_extent: (this->CellFlag || -// (textureExtent[0]CellFlag || -// (textureExtent[0]<=textureExtent[1] && -// textureExtent[2]<=textureExtent[3] && -// textureExtent[4]<=textureExtent[5]))) -//----------------------------------------------------------------------------- -int vtkMitkOpenGLGPUVolumeRayCastMapper::LoadScalarField(vtkImageData *input, - vtkImageData *maskInput, - int textureExtent[6], - vtkVolume *volume) -{ - assert("pre: input_exists" && input!=0); - assert("pre: valid_point_extent" && (this->CellFlag || - (textureExtent[0]CellFlag || - (textureExtent[0]<=textureExtent[1] && - textureExtent[2]<=textureExtent[3] && - textureExtent[4]<=textureExtent[5]))); - - int result=1; // succeeded - - // make sure we rebind our texture object to texture0 even if we don't have - // to load the data themselves because the binding might be changed by - // another mapper between two rendering calls. - - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - - // Find the texture. - vtkstd::map::iterator it= - this->ScalarsTextures->Map.find(input); - - - vtkKWScalarField *texture; - if(it==this->ScalarsTextures->Map.end()) - { - texture=new vtkKWScalarField; - this->ScalarsTextures->Map[input]=texture; - texture->SetSupports_GL_ARB_texture_float(this->Supports_GL_ARB_texture_float==1); - } - else - { - texture=(*it).second; - } - - texture->Update(input,this->CellFlag,textureExtent,this->ScalarMode, - this->ArrayAccessMode, - this->ArrayId, - this->ArrayName, - volume->GetProperty()->GetInterpolationType() - ==VTK_LINEAR_INTERPOLATION, - this->TableRange, - static_cast(static_cast(this->MaxMemoryInBytes)*this->MaxMemoryFraction)); - - result=texture->IsLoaded(); - this->CurrentScalar=texture; - - - // Mask - if(maskInput!=0) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE7); - - // Find the texture. - vtkstd::map::iterator it2= - this->MaskTextures->Map.find(maskInput); - - - vtkKWMask *mask; - if(it2==this->MaskTextures->Map.end()) - { - mask=new vtkKWMask; - this->MaskTextures->Map[maskInput]=mask; - } - else - { - mask=(*it2).second; - } - - mask->Update(maskInput,this->CellFlag,textureExtent,this->ScalarMode, - this->ArrayAccessMode, - this->ArrayId, - this->ArrayName, - static_cast(static_cast(this->MaxMemoryInBytes)*this->MaxMemoryFraction)); - - result=result && mask->IsLoaded(); - this->CurrentMask=mask; - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - } - - return result; -} - -//----------------------------------------------------------------------------- -// Allocate memory and load color table on the GPU or -// reload it if the transfer function changed. -// \pre vol_exists: vol!=0 -// \pre valid_numberOfScalarComponents: numberOfScalarComponents==1 || numberOfScalarComponents==4 -//----------------------------------------------------------------------------- -int vtkMitkOpenGLGPUVolumeRayCastMapper::UpdateColorTransferFunction( - vtkVolume *vol, - int numberOfScalarComponents) -{ - assert("pre: vol_exists" && vol!=0); - assert("pre: valid_numberOfScalarComponents" && - (numberOfScalarComponents==1 || numberOfScalarComponents==4)); - - // Build the colormap in a 1D texture. - - // 1D RGB-texture=mapping from scalar values to color values - // build the table - - if(numberOfScalarComponents==1) - { - vtkVolumeProperty *volumeProperty=vol->GetProperty(); - vtkColorTransferFunction *colorTransferFunction=volumeProperty->GetRGBTransferFunction(0); - - vtkgl::ActiveTexture(vtkgl::TEXTURE1); - - this->RGBTable->Update( - colorTransferFunction,this->TableRange, - volumeProperty->GetInterpolationType()==VTK_LINEAR_INTERPOLATION); - // Restore default - vtkgl::ActiveTexture( vtkgl::TEXTURE0); - } - - if(this->MaskInput!=0) - { - vtkVolumeProperty *volumeProperty=vol->GetProperty(); - vtkColorTransferFunction *c=volumeProperty->GetRGBTransferFunction(1); - - vtkgl::ActiveTexture(vtkgl::TEXTURE8); - this->Mask1RGBTable->Update(c,this->TableRange,false); - - c=volumeProperty->GetRGBTransferFunction(2); - vtkgl::ActiveTexture(vtkgl::TEXTURE9); - this->Mask2RGBTable->Update(c,this->TableRange,false); - - // Restore default - vtkgl::ActiveTexture( vtkgl::TEXTURE0); - } - return 1; -} - -//----------------------------------------------------------------------------- -// Allocate memory and load opacity table on the GPU or -// reload it if the transfert function changed. -// \pre vol_exists: vol!=0 -// \pre valid_numberOfScalarComponents: numberOfScalarComponents==1 || numberOfScalarComponents==4 -//----------------------------------------------------------------------------- -int vtkMitkOpenGLGPUVolumeRayCastMapper::UpdateOpacityTransferFunction( - vtkVolume *vol, - int numberOfScalarComponents, - unsigned int level) -{ - assert("pre: vol_exists" && vol!=0); - assert("pre: valid_numberOfScalarComponents" && - (numberOfScalarComponents==1 || numberOfScalarComponents==4)); - - (void)numberOfScalarComponents; // remove warning in release mode. - - vtkVolumeProperty *volumeProperty=vol->GetProperty(); - vtkPiecewiseFunction *scalarOpacity=volumeProperty->GetScalarOpacity(); - - vtkgl::ActiveTexture( vtkgl::TEXTURE2); //stay here - this->OpacityTables->Vector[level].Update( - scalarOpacity,this->BlendMode, - this->ActualSampleDistance, - this->TableRange, - volumeProperty->GetScalarOpacityUnitDistance(0), - volumeProperty->GetInterpolationType()==VTK_LINEAR_INTERPOLATION); - // Restore default active texture - vtkgl::ActiveTexture( vtkgl::TEXTURE0); - - return 1; -} - -//----------------------------------------------------------------------------- -// Prepare rendering in the offscreen framebuffer. -// \pre ren_exists: ren!=0 -// \pre vol_exists: vol!=0 -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::SetupRender(vtkRenderer *ren, - vtkVolume *vol) -{ - assert("pre: ren_exists" && ren!=0); - assert("pre: vol_exists" && vol!=0); - - double aspect[2]; - int lowerLeft[2]; - int usize, vsize; - - ren->GetTiledSizeAndOrigin(&usize,&vsize,lowerLeft,lowerLeft+1); - - usize = static_cast(usize*this->ReductionFactor); - vsize = static_cast(vsize*this->ReductionFactor); - - this->ReducedSize[0]=usize; - this->ReducedSize[1]=vsize; - - // the FBO has the size of the renderer (not the renderwindow), - // we always starts at 0,0. - glViewport(0,0, usize, vsize); - glEnable( GL_SCISSOR_TEST ); // scissor on the FBO, on the reduced part. - glScissor(0,0, usize, vsize); - glClearColor(0.0, 0.0, 0.0, 0.0); // maxvalue is 1 - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - ren->ComputeAspect(); - ren->GetAspect(aspect); - double aspect2[2]; - ren->vtkViewport::ComputeAspect(); - ren->vtkViewport::GetAspect(aspect2); - double aspectModification = aspect[0]*aspect2[1]/(aspect[1]*aspect2[0]); - - vtkCamera *cam = ren->GetActiveCamera(); - - glMatrixMode( GL_PROJECTION); - if(usize && vsize) - { - this->TempMatrix[0]->DeepCopy(cam->GetProjectionTransformMatrix( - aspectModification*usize/vsize, -1,1)); - this->TempMatrix[0]->Transpose(); - glLoadMatrixd(this->TempMatrix[0]->Element[0]); - } - else - { - glLoadIdentity(); - - } - - // push the model view matrix onto the stack, make sure we - // adjust the mode first - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - this->TempMatrix[0]->DeepCopy(vol->GetMatrix()); - this->TempMatrix[0]->Transpose(); - - // insert camera view transformation - glMultMatrixd(this->TempMatrix[0]->Element[0]); - glShadeModel(GL_SMOOTH); - glDisable( GL_LIGHTING); - glEnable (GL_CULL_FACE); - glDisable(GL_DEPTH_TEST); - glDisable(GL_BLEND); // very important, otherwise the first image looks dark. - this->PrintError("SetupRender"); -} - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::DebugDisplayBox(vtkPolyData *box) -{ - vtkPoints *points=box->GetPoints(); - vtkCellArray *polys=box->GetPolys(); - cout<<"npts="<GetNumberOfPoints()<GetNumberOfPoints()) - { - double coords[3]; - points->GetPoint(pointId,coords); - cout<<"pointId="<GetMatrix( this->InvVolumeMatrix ); - this->InvVolumeMatrix->Invert(); - - if(this->BoxSource==0) - { - this->BoxSource=vtkTessellatedBoxSource::New(); - } - this->BoxSource->SetBounds(worldBounds); - this->BoxSource->SetLevel(0); - this->BoxSource->QuadsOn(); - - if(this->Planes==0) - { - this->Planes=vtkPlaneCollection::New(); - } - this->Planes->RemoveAllItems(); - - vtkCamera *cam = ren->GetActiveCamera(); - double camWorldRange[2]; - double camWorldPos[4]; - double camFocalWorldPoint[4]; - double camWorldDirection[3]; - double range[2]; - double camPos[4]; - double focalPoint[4]; - double direction[3]; - - cam->GetPosition(camWorldPos); - camWorldPos[3] = 1.0; - this->InvVolumeMatrix->MultiplyPoint( camWorldPos, camPos ); - if ( camPos[3] ) - { - camPos[0] /= camPos[3]; - camPos[1] /= camPos[3]; - camPos[2] /= camPos[3]; - } - - cam->GetFocalPoint(camFocalWorldPoint); - camFocalWorldPoint[3]=1.0; - this->InvVolumeMatrix->MultiplyPoint( camFocalWorldPoint,focalPoint ); - if ( focalPoint[3] ) - { - focalPoint[0] /= focalPoint[3]; - focalPoint[1] /= focalPoint[3]; - focalPoint[2] /= focalPoint[3]; - } - - // Compute the normalized view direction - direction[0] = focalPoint[0] - camPos[0]; - direction[1] = focalPoint[1] - camPos[1]; - direction[2] = focalPoint[2] - camPos[2]; - - vtkMath::Normalize(direction); - - // The range (near/far) must also be transformed - // into the local coordinate system. - camWorldDirection[0] = camFocalWorldPoint[0] - camWorldPos[0]; - camWorldDirection[1] = camFocalWorldPoint[1] - camWorldPos[1]; - camWorldDirection[2] = camFocalWorldPoint[2] - camWorldPos[2]; - vtkMath::Normalize(camWorldDirection); - - double camNearWorldPoint[4]; - double camFarWorldPoint[4]; - double camNearPoint[4]; - double camFarPoint[4]; - cam->GetClippingRange(camWorldRange); - camNearWorldPoint[0] = camWorldPos[0] + camWorldRange[0]*camWorldDirection[0]; - camNearWorldPoint[1] = camWorldPos[1] + camWorldRange[0]*camWorldDirection[1]; - camNearWorldPoint[2] = camWorldPos[2] + camWorldRange[0]*camWorldDirection[2]; - camNearWorldPoint[3] = 1.; - - camFarWorldPoint[0] = camWorldPos[0] + camWorldRange[1]*camWorldDirection[0]; - camFarWorldPoint[1] = camWorldPos[1] + camWorldRange[1]*camWorldDirection[1]; - camFarWorldPoint[2] = camWorldPos[2] + camWorldRange[1]*camWorldDirection[2]; - camFarWorldPoint[3] = 1.; - - this->InvVolumeMatrix->MultiplyPoint( camNearWorldPoint, camNearPoint ); - if (camNearPoint[3]) - { - camNearPoint[0] /= camNearPoint[3]; - camNearPoint[1] /= camNearPoint[3]; - camNearPoint[2] /= camNearPoint[3]; - } - this->InvVolumeMatrix->MultiplyPoint( camFarWorldPoint, camFarPoint ); - if (camFarPoint[3]) - { - camFarPoint[0] /= camFarPoint[3]; - camFarPoint[1] /= camFarPoint[3]; - camFarPoint[2] /= camFarPoint[3]; - } - range[0] = sqrt(vtkMath::Distance2BetweenPoints(camNearPoint, camPos)); - range[1] = sqrt(vtkMath::Distance2BetweenPoints(camFarPoint, camPos)); - - //double nearPoint[3], farPoint[3]; - - double dist = range[1] - range[0]; - range[0] += dist / (2<<16); - range[1] -= dist / (2<<16); - - if(this->NearPlane==0) - { - this->NearPlane= vtkPlane::New(); - } - //this->NearPlane->SetOrigin( nearPoint ); - this->NearPlane->SetOrigin( camNearPoint ); - this->NearPlane->SetNormal( direction ); - this->Planes->AddItem(this->NearPlane); - - if ( this->ClippingPlanes ) - { - this->ClippingPlanes->InitTraversal(); - vtkPlane *plane; - while ( (plane = this->ClippingPlanes->GetNextItem()) ) - { - // Planes are in world coordinates, we need to - // convert them in local coordinates - double planeOrigin[4], planeNormal[4], planeP1[4]; - plane->GetOrigin(planeOrigin); - planeOrigin[3] = 1.; - plane->GetNormal(planeNormal); - planeP1[0] = planeOrigin[0] + planeNormal[0]; - planeP1[1] = planeOrigin[1] + planeNormal[1]; - planeP1[2] = planeOrigin[2] + planeNormal[2]; - planeP1[3] = 1.; - this->InvVolumeMatrix->MultiplyPoint(planeOrigin, planeOrigin); - this->InvVolumeMatrix->MultiplyPoint(planeP1, planeP1); - if( planeOrigin[3]) - { - planeOrigin[0] /= planeOrigin[3]; - planeOrigin[1] /= planeOrigin[3]; - planeOrigin[2] /= planeOrigin[3]; - } - if( planeP1[3]) - { - planeP1[0] /= planeP1[3]; - planeP1[1] /= planeP1[3]; - planeP1[2] /= planeP1[3]; - } - planeNormal[0] = planeP1[0] - planeOrigin[0]; - planeNormal[1] = planeP1[1] - planeOrigin[1]; - planeNormal[2] = planeP1[2] - planeOrigin[2]; - vtkMath::Normalize(planeNormal); - vtkPlane* localPlane = vtkPlane::New(); - localPlane->SetOrigin(planeOrigin); - localPlane->SetNormal(planeNormal); - this->Planes->AddItem(localPlane); - localPlane->Delete(); - } - } - - if(this->Clip==0) - { - this->Clip=vtkClipConvexPolyData::New(); - this->Clip->SetInputConnection(this->BoxSource->GetOutputPort()); - this->Clip->SetPlanes( this->Planes ); - } - - this->Clip->Update(); - - if(this->Densify==0) - { - this->Densify=vtkDensifyPolyData::New(); - this->Densify->SetInputConnection(this->Clip->GetOutputPort()); - this->Densify->SetNumberOfSubdivisions(2); - } - this->Densify->Update(); - this->ClippedBoundingBox = this->Densify->GetOutput(); -} - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -int vtkMitkOpenGLGPUVolumeRayCastMapper::RenderClippedBoundingBox( - int tcoordFlag, - size_t currentBlock, - size_t numberOfBlocks, - vtkRenderWindow *renWin ) -{ - assert("pre: valid_currentBlock" && currentBlockClippedBoundingBox->GetPoints(); - vtkCellArray *polys = this->ClippedBoundingBox->GetPolys(); - - vtkIdType npts; - vtkIdType *pts; - - vtkIdType i, j; - - double center[3] = {0,0,0}; - double min[3] = {VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX}; - double max[3] = {VTK_DOUBLE_MIN, VTK_DOUBLE_MIN, VTK_DOUBLE_MIN}; - - // First compute center point - npts = points->GetNumberOfPoints(); - for ( i = 0; i < npts; i++ ) - { - double pt[3]; - points->GetPoint( i, pt ); - for ( j = 0; j < 3; j++ ) - { - min[j] = (pt[j]max[j])?(pt[j]):(max[j]); - } - } - - center[0] = 0.5*(min[0]+max[0]); - center[1] = 0.5*(min[1]+max[1]); - center[2] = 0.5*(min[2]+max[2]); - - double *loadedBounds=0; - vtkIdType *loadedExtent=0; - - if ( tcoordFlag ) - { - loadedBounds=this->CurrentScalar->GetLoadedBounds(); - loadedExtent=this->CurrentScalar->GetLoadedExtent(); - } - - double *spacing=this->GetInput()->GetSpacing(); - double spacingSign[3]; - i=0; - while(i<3) - { - if(spacing[i]<0) - { - spacingSign[i]=-1.0; - } - else - { - spacingSign[i]=1.0; - } - ++i; - } - - // make it double for the ratio of the progress. - int polyId=0; - double polyCount=static_cast(polys->GetNumberOfCells()); - polys->InitTraversal(); - int abort=0; - while ( !abort && polys->GetNextCell(npts, pts) ) - { - vtkIdType start, end, inc; - - // Need to have at least a triangle - if ( npts > 2 ) - { - // Check the cross product of the first two - // vectors dotted with the vector from the - // center to the second point. Is it positive or - // negative? - - double p1[3], p2[3], p3[3]; - double v1[3], v2[3], v3[3], v4[3]; - - points->GetPoint(pts[0], p1 ); - points->GetPoint(pts[1], p2 ); - points->GetPoint(pts[2], p3 ); - - v1[0] = p2[0] - p1[0]; - v1[1] = p2[1] - p1[1]; - v1[2] = p2[2] - p1[2]; - - v2[0] = p2[0] - p3[0]; - v2[1] = p2[1] - p3[1]; - v2[2] = p2[2] - p3[2]; - - vtkMath::Cross( v1, v2, v3 ); - vtkMath::Normalize(v3); - - v4[0] = p2[0] - center[0]; - v4[1] = p2[1] - center[1]; - v4[2] = p2[2] - center[2]; - vtkMath::Normalize(v4); - - double dot = vtkMath::Dot( v3, v4 ); - - if (( dot < 0) && this->PreserveOrientation) - { - start = 0; - end = npts; - inc = 1; - } - else - { - start = npts-1; - end = -1; - inc = -1; - } - - glBegin( GL_TRIANGLE_FAN ); // GL_POLYGON -> GL_TRIANGLE_FAN - - double vert[3]; - double tcoord[3]; - for ( i = start; i != end; i += inc ) - { - points->GetPoint(pts[i], vert); - if ( tcoordFlag ) - { - for ( j = 0; j < 3; j++ ) - { - // loaded bounds take both cell data and point date cases into - // account - if(this->CellFlag) // texcoords between 0 and 1. More complex - // depends on the loaded texture - { - tcoord[j] = spacingSign[j]*(vert[j] - loadedBounds[j*2]) / - (loadedBounds[j*2+1] - loadedBounds[j*2]); - } - else // texcoords between 1/2N and 1-1/2N. - { - double tmp; // between 0 and 1 - tmp = spacingSign[j]*(vert[j] - loadedBounds[j*2]) / - (loadedBounds[j*2+1] - loadedBounds[j*2]); - double delta=static_cast( - loadedExtent[j*2+1]-loadedExtent[j*2]+1); - tcoord[j]=(tmp*(delta-1)+0.5)/delta; - } - } - vtkgl::MultiTexCoord3dv(vtkgl::TEXTURE0, tcoord); - } - glVertex3dv(vert); - } - glEnd(); - - } - if(tcoordFlag) - { - // otherwise, we are rendering back face to initialize the zbuffer. - if (!this->GeneratingCanonicalView && this->ReportProgress) - { - glFinish(); - // Only invoke an event at most one every second. - double currentTime=vtkTimerLog::GetUniversalTime(); - if(currentTime - this->LastProgressEventTime > 1.0) - { - double progress=(static_cast(currentBlock)+polyId/polyCount)/ - static_cast(numberOfBlocks); - this->InvokeEvent(vtkCommand::VolumeMapperRenderProgressEvent, - &progress); - renWin->MakeCurrent(); - this->LastProgressEventTime = currentTime; - } - } - abort=renWin->CheckAbortStatus(); - } - ++polyId; - } - return abort; -} - -void vtkMitkOpenGLGPUVolumeRayCastMapper::CopyFBOToTexture() -{ - // in OpenGL copy texture to texture does not exist but - // framebuffer to texture exists (and our FB is an FBO). - // we have to copy and not just to switch color textures because the - // colorbuffer has to accumulate color or values step after step. - // Switching would not work because two different steps can draw different - // polygons that don't overlap - vtkgl::ActiveTexture(vtkgl::TEXTURE4); - glBindTexture( - GL_TEXTURE_2D, - this->TextureObjects[ - vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+1]); - - glReadBuffer(vtkgl::COLOR_ATTACHMENT0_EXT); - glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,this->ReducedSize[0], - this->ReducedSize[1]); - if(this->BlendMode==vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND - || this->BlendMode==vtkMitkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE5); - glBindTexture(GL_TEXTURE_2D,this->MaxValueFrameBuffer2); - glReadBuffer(vtkgl::COLOR_ATTACHMENT0_EXT+1); - glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,this->ReducedSize[0], - this->ReducedSize[1]); - } - vtkgl::ActiveTexture(vtkgl::TEXTURE0); -} - -//----------------------------------------------------------------------------- -// Restore OpenGL state after rendering of the dataset. -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::CleanupRender() -{ - glPopMatrix(); - glDisable(GL_CULL_FACE); -} - -//----------------------------------------------------------------------------- -// Build the fragment shader program that scale and bias a texture -// for window/level purpose. -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::BuildScaleBiasProgram() -{ - if(this->ScaleBiasProgramShader==0) - { - GLuint programShader; - GLuint fragmentShader; - - programShader=vtkgl::CreateProgram(); - fragmentShader=vtkgl::CreateShader(vtkgl::FRAGMENT_SHADER); - vtkgl::AttachShader(programShader,fragmentShader); - vtkgl::DeleteShader(fragmentShader); // reference counting - - vtkgl::ShaderSource( - fragmentShader,1, - const_cast(&vtkMitkGPUVolumeRayCastMapper_ScaleBiasFS),0); - vtkgl::CompileShader(fragmentShader); - - this->CheckCompilation(static_cast(fragmentShader)); - vtkgl::LinkProgram(programShader); - this->CheckLinkage(static_cast(programShader)); - - this->ScaleBiasProgramShader=static_cast(programShader); - this->UFrameBufferTexture= - static_cast(vtkgl::GetUniformLocation(programShader, - "frameBufferTexture")); - this->UScale=static_cast(vtkgl::GetUniformLocation(programShader, - "scale")); - this->UBias=static_cast(vtkgl::GetUniformLocation(programShader, - "bias")); - } - -} - -//----------------------------------------------------------------------------- -// Render the offscreen buffer to the screen. -// \pre ren_exists: ren!=0 -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::RenderTextureToScreen(vtkRenderer *ren) -{ - assert("pre: ren_exists" && ren!=0); - - if ( this->GeneratingCanonicalView ) - { - // We just need to copy of the data, not render it - glBindTexture(GL_TEXTURE_2D, - this->TextureObjects[ - vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront]); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); - glPixelStorei( GL_PACK_ALIGNMENT, 1 ); - - unsigned char *outPtr = static_cast(this->CanonicalViewImageData->GetScalarPointer()); - glGetTexImage( GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, outPtr ); - return; - } - - int lowerLeft[2]; - int usize, vsize; - ren->GetTiledSizeAndOrigin(&usize,&vsize,lowerLeft,lowerLeft+1); - glViewport(lowerLeft[0],lowerLeft[1], usize, vsize); - glEnable( GL_SCISSOR_TEST ); - glScissor(lowerLeft[0],lowerLeft[1], usize, vsize); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(0.0, usize, 0.0, vsize, -1.0, 1.0 ); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - glBindTexture(GL_TEXTURE_2D, - this->TextureObjects[vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront]); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - glEnable(GL_BLEND); - glBlendFunc( GL_ONE,GL_ONE_MINUS_SRC_ALPHA); - - // As we use replace mode, we don't need to set the color value. - - glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE); - - glDisable(GL_DEPTH_TEST); - - double xOffset = 1.0 / usize; - double yOffset = 1.0 / vsize; - - glDepthMask(GL_FALSE); - - double scale=1.0/this->FinalColorWindow; - double bias=0.5-this->FinalColorLevel/this->FinalColorWindow; - - if(scale!=1.0 || bias!=0.0) - { - this->BuildScaleBiasProgram(); - vtkgl::UseProgram(this->ScaleBiasProgramShader); - if(this->UFrameBufferTexture!=-1) - { - vtkgl::Uniform1i(this->UFrameBufferTexture,0); - } - else - { - vtkErrorMacro(<<"uFrameBufferTexture is not a uniform variable."); - } - if(this->UScale!=-1) - { - vtkgl::Uniform1f(this->UScale,static_cast(scale)); - } - else - { - vtkErrorMacro(<<"uScale is not a uniform variable."); - } - if(this->UBias!=-1) - { - vtkgl::Uniform1f(this->UBias,static_cast(bias)); - } - else - { - vtkErrorMacro(<<"uBias is not a uniform variable."); - } - } - else - { - glEnable(GL_TEXTURE_2D); // fixed pipeline - } - - glBegin(GL_QUADS); - glTexCoord2f(static_cast(xOffset),static_cast(yOffset)); - glVertex2f(0.0,0.0); - glTexCoord2f(static_cast(this->ReductionFactor-xOffset), - static_cast(yOffset)); - glVertex2f(static_cast(usize),0.0); - glTexCoord2f(static_cast(this->ReductionFactor-xOffset), - static_cast(this->ReductionFactor-yOffset)); - glVertex2f(static_cast(usize),static_cast(vsize)); - glTexCoord2f(static_cast(xOffset), - static_cast(this->ReductionFactor-yOffset)); - glVertex2f(0.0,static_cast(vsize)); - glEnd(); - - // Restore the default mode. Used in overlay. - glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); - - if(scale!=1.0 || bias!=0.0) - { - vtkgl::UseProgram(0); - } - else - { - glDisable(GL_TEXTURE_2D); - } - - glDepthMask(GL_TRUE); - - glDisable(GL_BLEND); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); -} - -//----------------------------------------------------------------------------- -// Update the reduction factor of the render viewport (this->ReductionFactor) -// according to the time spent in seconds to render the previous frame -// (this->TimeToDraw) and a time in seconds allocated to render the next -// frame (allocatedTime). -// \pre valid_current_reduction_range: this->ReductionFactor>0.0 && this->ReductionFactor<=1.0 -// \pre positive_TimeToDraw: this->TimeToDraw>=0.0 -// \pre positive_time: allocatedTime>0.0 -// \post valid_new_reduction_range: this->ReductionFactor>0.0 && this->ReductionFactor<=1.0 -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::ComputeReductionFactor( - double allocatedTime) -{ - assert("pre: valid_current_reduction_range" && this->ReductionFactor>0.0 - && this->ReductionFactor<=1.0); - assert("pre: positive_TimeToDraw" && this->TimeToDraw>=0.0); - assert("pre: positive_time" && allocatedTime>0.0); - - if ( this->GeneratingCanonicalView ) - { - this->ReductionFactor = 1.0; - return; - } - - if ( !this->AutoAdjustSampleDistances ) - { - this->ReductionFactor = 1.0 / this->ImageSampleDistance; - return; - } - - if ( this->TimeToDraw ) - { - double oldFactor = this->ReductionFactor; - - double timeToDraw; - if (allocatedTime < 1.0) - { - timeToDraw = this->SmallTimeToDraw; - if ( timeToDraw == 0.0 ) - { - timeToDraw = this->BigTimeToDraw/3.0; - } - } - else - { - timeToDraw = this->BigTimeToDraw; - } - - if ( timeToDraw == 0.0 ) - { - timeToDraw = 10.0; - } - - double fullTime = timeToDraw / this->ReductionFactor; - double newFactor = allocatedTime / fullTime; - - if ( oldFactor == 1.0 || - newFactor / oldFactor > 1.3 || - newFactor / oldFactor < .95 ) - { - - this->ReductionFactor = (newFactor+oldFactor)/2.0; - - this->ReductionFactor = (this->ReductionFactor > 5.0)?(1.00):(this->ReductionFactor); - this->ReductionFactor = (this->ReductionFactor > 1.0)?(0.99):(this->ReductionFactor); - this->ReductionFactor = (this->ReductionFactor < 0.1)?(0.10):(this->ReductionFactor); - - if ( 1.0/this->ReductionFactor > this->MaximumImageSampleDistance ) - { - this->ReductionFactor = 1.0 / this->MaximumImageSampleDistance; - } - if ( 1.0/this->ReductionFactor < this->MinimumImageSampleDistance ) - { - this->ReductionFactor = 1.0 / this->MinimumImageSampleDistance; - } - } - } - else - { - this->ReductionFactor = 1.0; - } - - assert("post: valid_new_reduction_range" && this->ReductionFactor>0.0 - && this->ReductionFactor<=1.0); -} - -//----------------------------------------------------------------------------- -// Rendering initialization including making the context current, loading -// necessary extensions, allocating frame buffers, updating transfer function, -// computing clipping regions, and building the fragment shader. -// -// Pre-conditions: -// - ren != NULL -// - vol != NULL -// - ren->GetRenderWindow() != NULL -// - 1 <= numberOfScalarComponents <= 4 -// - numberOfLevels >= 1 -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::PreRender(vtkRenderer *ren, - vtkVolume *vol, - double datasetBounds[6], - double scalarRange[2], - int numberOfScalarComponents, - unsigned int numberOfLevels) -{ - // make sure our window is the current OpenGL context. - ren->GetRenderWindow()->MakeCurrent(); - - // If we haven't already succeeded in loading the extensions, - // try to load them - if(!this->LoadExtensionsSucceeded) - { - this->LoadExtensions(ren->GetRenderWindow()); - } - - // If we can't load the necessary extensions, provide - // feedback on why it failed. - if(!this->LoadExtensionsSucceeded) - { - vtkErrorMacro( - "Rendering failed because the following OpenGL extensions " - "are required but not supported: " << - (this->UnsupportedRequiredExtensions->Stream.str()).c_str()); - return; - } - - // Create the OpenGL object that we need - this->CreateOpenGLObjects(); - - // Compute the reduction factor that may be necessary to get - // the interactive rendering rate that we want - this->ComputeReductionFactor(vol->GetAllocatedRenderTime()); - - // Allocate the frame buffers - if(!this->AllocateFrameBuffers(ren)) - { - vtkErrorMacro("Not enough GPU memory to create a framebuffer."); - return; - } - - // Save the scalar range - this is what we will use for the range - // of the transfer functions - this->TableRange[0]=scalarRange[0]; - this->TableRange[1]=scalarRange[1]; - - - if(this->RGBTable==0) - { - this->RGBTable=new vtkRGBTable; - } - - if(this->MaskInput!=0) - { - if(this->Mask1RGBTable==0) - { - this->Mask1RGBTable=new vtkRGBTable; - } - if(this->Mask2RGBTable==0) - { - this->Mask2RGBTable=new vtkRGBTable; - } - } - - // Update the color transfer function - this->UpdateColorTransferFunction(vol,numberOfScalarComponents); - - // Update the noise texture that will be used to jitter rays to - // reduce alliasing artifacts - this->UpdateNoiseTexture(); - - // We are going to change the blending mode and blending function - - // so lets push here so we can pop later - glPushAttrib(GL_COLOR_BUFFER_BIT); - - // If this is the canonical view - we don't want to intermix so we'll just - // start by clearing the z buffer. - if ( this->GeneratingCanonicalView ) - { - glClearColor(0.0, 0.0, 0.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - } - - // See if the volume transform is orientation-preserving - vtkMatrix4x4 *m=vol->GetMatrix(); - double det=vtkMath::Determinant3x3( - m->GetElement(0,0),m->GetElement(0,1),m->GetElement(0,2), - m->GetElement(1,0),m->GetElement(1,1),m->GetElement(1,2), - m->GetElement(2,0),m->GetElement(2,1),m->GetElement(2,2)); - - this->PreserveOrientation=det>0; - - // If we have clipping planes, render the back faces of the clipped - // bounding box of the whole dataset to set the zbuffer. - if(this->ClippingPlanes && this->ClippingPlanes->GetNumberOfItems()!=0) - { - // push the model view matrix onto the stack, make sure we - // adjust the mode first - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - this->TempMatrix[0]->DeepCopy(vol->GetMatrix()); - this->TempMatrix[0]->Transpose(); - glMultMatrixd(this->TempMatrix[0]->Element[0]); - this->ClipBoundingBox(ren,datasetBounds,vol); - glEnable (GL_CULL_FACE); - glCullFace (GL_FRONT); - glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); - this->RenderClippedBoundingBox(0,0,1,ren->GetRenderWindow()); - glDisable (GL_CULL_FACE); - glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); - //glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - } - // Check if everything is OK - this->CheckFrameBufferStatus(); - - // Intermixed geometry: Grab the depth buffer into a texture - - int size[2]; - int lowerLeft[2]; - ren->GetTiledSizeAndOrigin(size,size+1,lowerLeft,lowerLeft+1); - - vtkgl::ActiveTexture( vtkgl::TEXTURE3 ); - glBindTexture(GL_TEXTURE_2D, - static_cast( - this->TextureObjects[ - vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectDepthMap])); - glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,lowerLeft[0],lowerLeft[1],size[0], - size[1]); - - - vtkgl::ActiveTexture( vtkgl::TEXTURE0 ); - - int parallelProjection=ren->GetActiveCamera()->GetParallelProjection(); - - // initialize variables to prevent compiler warnings. - int rayCastMethod=vtkMitkOpenGLGPUVolumeRayCastMapperMethodMIP; - int shadeMethod=vtkMitkOpenGLGPUVolumeRayCastMapperShadeNotUsed; - int componentMethod=vtkMitkOpenGLGPUVolumeRayCastMapperComponentNotUsed; - - switch(this->BlendMode) - { - case vtkVolumeMapper::COMPOSITE_BLEND: - switch(numberOfScalarComponents) - { - case 1: - componentMethod=vtkMitkOpenGLGPUVolumeRayCastMapperComponentOne; - break; - case 4: - componentMethod=vtkMitkOpenGLGPUVolumeRayCastMapperComponentFour; - break; - default: - assert("check: impossible case" && false); - break; - } - if(this->MaskInput!=0) - { - rayCastMethod= - vtkMitkOpenGLGPUVolumeRayCastMapperMethodCompositeMask; - } - else - { - //cout<<"program is composite+shade"<GetProperty()->GetShade() ) - { - shadeMethod=vtkMitkOpenGLGPUVolumeRayCastMapperShadeYes; - assert("check: only_1_component_todo" && numberOfScalarComponents==1); - } - else - { - shadeMethod=vtkMitkOpenGLGPUVolumeRayCastMapperShadeNo; - //cout<<"program is composite"<ComputeNumberOfCroppingRegions(); // TODO AMR vs single block - if(this->AMRMode) - { - NumberOfCroppingRegions=2; // >1, means use do compositing between blocks - } - this->BuildProgram(parallelProjection,rayCastMethod,shadeMethod, - componentMethod); - this->CheckLinkage(this->ProgramShader); - - vtkgl::UseProgram(this->ProgramShader); - - // for active texture 0, dataset - - if(numberOfScalarComponents==1) - { - // colortable - vtkgl::ActiveTexture(vtkgl::TEXTURE1); - this->RGBTable->Bind(); - - if(this->MaskInput!=0) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE8); - this->Mask1RGBTable->Bind(); - vtkgl::ActiveTexture(vtkgl::TEXTURE9); - this->Mask2RGBTable->Bind(); - } - } - - GLint uDataSetTexture; - - uDataSetTexture=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"dataSetTexture"); - - if(uDataSetTexture!=-1) - { - vtkgl::Uniform1i(uDataSetTexture,0); - } - else - { - vtkErrorMacro(<<"dataSetTexture is not a uniform variable."); - } - - if ( this->MaskInput) - { - // Make the mask texture available on texture unit 7 - GLint uMaskTexture; - - uMaskTexture=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"maskTexture"); - - if(uMaskTexture!=-1) - { - vtkgl::Uniform1i(uMaskTexture,7); - } - else - { - vtkErrorMacro(<<"maskTexture is not a uniform variable."); - } - } - - if(numberOfScalarComponents==1) - { - GLint uColorTexture; - uColorTexture=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"colorTexture"); - - if(uColorTexture!=-1) - { - vtkgl::Uniform1i(uColorTexture,1); - } - else - { - vtkErrorMacro(<<"colorTexture is not a uniform variable."); - } - - if(this->MaskInput!=0) - { - GLint uMask1ColorTexture; - uMask1ColorTexture=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"mask1ColorTexture"); - - if(uMask1ColorTexture!=-1) - { - vtkgl::Uniform1i(uMask1ColorTexture,8); - } - else - { - vtkErrorMacro(<<"mask1ColorTexture is not a uniform variable."); - } - - GLint uMask2ColorTexture; - uMask2ColorTexture=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"mask2ColorTexture"); - - if(uMask2ColorTexture!=-1) - { - vtkgl::Uniform1i(uMask2ColorTexture,9); - } - else - { - vtkErrorMacro(<<"mask2ColorTexture is not a uniform variable."); - } - - GLint uMaskBlendFactor; - uMaskBlendFactor=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"maskBlendFactor"); - if(uMaskBlendFactor!=-1) - { - vtkgl::Uniform1f(uMaskBlendFactor,this->MaskBlendFactor); - } - else - { - vtkErrorMacro(<<"maskBlendFactor is not a uniform variable."); - } - } - - } - - GLint uOpacityTexture; - - uOpacityTexture=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"opacityTexture"); - - if(uOpacityTexture!=-1) - { - vtkgl::Uniform1i(uOpacityTexture,2); - } - else - { - vtkErrorMacro(<<"opacityTexture is not a uniform variable."); - } - - // depthtexture - vtkgl::ActiveTexture( vtkgl::TEXTURE3 ); - glBindTexture(GL_TEXTURE_2D,static_cast(this->TextureObjects[vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectDepthMap])); - - GLint uDepthTexture; - - uDepthTexture=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"depthTexture"); - - if(uDepthTexture!=-1) - { - vtkgl::Uniform1i(uDepthTexture,3); - } - else - { - vtkErrorMacro(<<"depthTexture is not a uniform variable."); - } - - // noise texture - vtkgl::ActiveTexture( vtkgl::TEXTURE6 ); - glBindTexture(GL_TEXTURE_2D,static_cast(this->NoiseTextureId)); - - - GLint uNoiseTexture; - - uNoiseTexture=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"noiseTexture"); - - if(uNoiseTexture!=-1) - { - vtkgl::Uniform1i(uNoiseTexture,6); - } - else - { - vtkErrorMacro(<<"noiseTexture is not a uniform variable."); - } - - this->CheckFrameBufferStatus(); - - if(this->NumberOfCroppingRegions>1) - { - // framebuffer texture - if(rayCastMethod!=vtkMitkOpenGLGPUVolumeRayCastMapperMethodMIP && rayCastMethod!=vtkMitkOpenGLGPUVolumeRayCastMapperMethodMinIP) - { - vtkgl::ActiveTexture( vtkgl::TEXTURE4 ); - glBindTexture(GL_TEXTURE_2D,static_cast(this->TextureObjects[vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront])); - - GLint uFrameBufferTexture; - - uFrameBufferTexture=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"frameBufferTexture"); - - this->PrintError("framebuffertexture 1"); - if(uFrameBufferTexture!=-1) - { - vtkgl::Uniform1i(uFrameBufferTexture,4); - } - else - { - vtkErrorMacro(<<"frameBufferTexture is not a uniform variable."); - } - this->PrintError("framebuffertexture 2"); - } - - this->CheckFrameBufferStatus(); - // max scalar value framebuffer texture - if(this->BlendMode==vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND - || this->BlendMode==vtkMitkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND) - { - vtkgl::ActiveTexture( vtkgl::TEXTURE5 ); - glBindTexture(GL_TEXTURE_2D,static_cast(this->MaxValueFrameBuffer2)); - - GLint uScalarBufferTexture; - - uScalarBufferTexture=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"scalarBufferTexture"); - - this->PrintError("scalarbuffertexture 1"); - if(uScalarBufferTexture!=-1) - { - vtkgl::Uniform1i(uScalarBufferTexture,5); - } - else - { - vtkErrorMacro(<<"scalarBufferTexture is not a uniform variable."); - } - this->PrintError("scalarbuffertexture 2"); - } - } - this->CheckFrameBufferStatus(); - - GLint uWindowLowerLeftCorner; - - uWindowLowerLeftCorner=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"windowLowerLeftCorner"); - - if(uWindowLowerLeftCorner!=-1) - { - vtkgl::Uniform2f(uWindowLowerLeftCorner,static_cast(lowerLeft[0]), - static_cast(lowerLeft[1])); - } - else - { - vtkErrorMacro(<<"windowLowerLeftCorner is not a uniform variable."); - } - GLint uInvOriginalWindowSize; - - uInvOriginalWindowSize=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"invOriginalWindowSize"); - - if(uInvOriginalWindowSize!=-1) - { - vtkgl::Uniform2f(uInvOriginalWindowSize, - static_cast(1.0/size[0]), - static_cast(1.0/size[1])); - } - else - { - // yes it is not error. It is only actually used when there is some - // complex cropping (this->NumberOfCroppingRegions>1). Some GLSL compilers - // may remove the uniform variable for optimization when it is not used. - vtkDebugMacro( - <<"invOriginalWindowSize is not an active uniform variable."); - } - - size[0] = static_cast(size[0]*this->ReductionFactor); - size[1] = static_cast(size[1]*this->ReductionFactor); - - GLint uInvWindowSize; - - uInvWindowSize=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"invWindowSize"); - - if(uInvWindowSize!=-1) - { - vtkgl::Uniform2f(uInvWindowSize,static_cast(1.0/size[0]), - static_cast(1.0/size[1])); - } - else - { - vtkErrorMacro(<<"invWindowSize is not a uniform variable."); - } - - - this->PrintError("after uniforms for textures"); - - - this->CheckFrameBufferStatus(); - - GLint savedFrameBuffer; - glGetIntegerv(vtkgl::FRAMEBUFFER_BINDING_EXT,&savedFrameBuffer); - this->SavedFrameBuffer=static_cast(savedFrameBuffer); - - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, - static_cast(this->FrameBufferObject)); - - this->BindFramebuffer(); - - GLenum buffer[4]; - buffer[0] = vtkgl::COLOR_ATTACHMENT0_EXT; - if(this->NumberOfCroppingRegions>1 && - this->BlendMode==vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND) - { - // max scalar frame buffer - buffer[1] = vtkgl::COLOR_ATTACHMENT1_EXT; - } - else - { - buffer[1] = GL_NONE; - } - - vtkgl::DrawBuffers(2,buffer); - - this->CheckFrameBufferStatus(); - - // Use by the composite+shade program - double shininess=vol->GetProperty()->GetSpecularPower(); - if(shininess>128.0) - { - shininess=128.0; // upper limit for the OpenGL shininess. - } - glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,static_cast(shininess)); - - glDisable(GL_COLOR_MATERIAL); // other mapper may have enable that. - - GLfloat values[4]; - values[3]=1.0; - - values[0]=0.0; - values[1]=values[0]; - values[2]=values[0]; - glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,values); - - values[0]=static_cast(vol->GetProperty()->GetAmbient()); - values[1]=values[0]; - values[2]=values[0]; - glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,values); - - values[0]=static_cast(vol->GetProperty()->GetDiffuse()); - values[1]=values[0]; - values[2]=values[0]; - glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,values); - values[0]=static_cast(vol->GetProperty()->GetSpecular()); - values[1]=values[0]; - values[2]=values[0]; - glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,values); - -// cout << "pingpong=" << this->PingPongFlag << endl; - - // To initialize the second color buffer - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, - this->TextureObjects[vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront], - 0); - - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT+1, - GL_TEXTURE_2D, - this->TextureObjects[vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+1], - 0); - buffer[0] = vtkgl::COLOR_ATTACHMENT0_EXT; - buffer[1] = vtkgl::COLOR_ATTACHMENT1_EXT; - vtkgl::DrawBuffers(2,buffer); - -// cout << "check before setup" << endl; - this->CheckFrameBufferStatus(); - this->SetupRender(ren,vol); - - // restore in case of composite with no cropping or streaming. - buffer[0] = vtkgl::COLOR_ATTACHMENT0_EXT; - buffer[1] = GL_NONE; - vtkgl::DrawBuffers(2,buffer); - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT+1, - GL_TEXTURE_2D,0,0); -// cout << "check after color init" << endl; - this->CheckFrameBufferStatus(); - - if(this->NumberOfCroppingRegions>1 && - (this->BlendMode==vtkMitkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND - || this->BlendMode==vtkMitkGPUVolumeRayCastMapper::MAXIMUM_INTENSITY_BLEND)) - { -// cout << "this->MaxValueFrameBuffer="<< this->MaxValueFrameBuffer <MaxValueFrameBuffer2="<< this->MaxValueFrameBuffer2 <MaxValueFrameBuffer,0); - - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT+1, - GL_TEXTURE_2D, - this->MaxValueFrameBuffer2,0); - - buffer[0] = vtkgl::COLOR_ATTACHMENT0_EXT; - buffer[1] = vtkgl::COLOR_ATTACHMENT1_EXT; - vtkgl::DrawBuffers(2,buffer); - - if(this->BlendMode==vtkMitkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND) - { - glClearColor(1.0, 0.0, 0.0, 0.0); - } - else - { - glClearColor(0.0, 0.0, 0.0, 0.0); // for MAXIMUM_INTENSITY_BLEND - } -// cout << "check before clear on max" << endl; - this->CheckFrameBufferStatus(); - glClear(GL_COLOR_BUFFER_BIT); - } - - if(this->NumberOfCroppingRegions>1) - { - // color buffer target in the color attachement 0 - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, - this->TextureObjects[vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront], - 0); - - // color buffer input is on texture unit 4. - vtkgl::ActiveTexture(vtkgl::TEXTURE4); - glBindTexture(GL_TEXTURE_2D,this->TextureObjects[vtkMitkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+1]); - - if(this->BlendMode==vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND - || this->BlendMode==vtkMitkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND) - { - // max buffer target in the color attachment 1 - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT+1, - GL_TEXTURE_2D, - this->MaxValueFrameBuffer,0); - - // max buffer input is on texture unit 5. - vtkgl::ActiveTexture(vtkgl::TEXTURE5); - glBindTexture(GL_TEXTURE_2D,this->MaxValueFrameBuffer2); - } - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - } - - this->CheckFrameBufferStatus(); - - if(this->OpacityTables!=0 && - this->OpacityTables->Vector.size()!=numberOfLevels) - { - delete this->OpacityTables; - this->OpacityTables=0; - } - if(this->OpacityTables==0) - { - this->OpacityTables=new vtkOpacityTables(numberOfLevels); - } - - // debug code - // DO NOT REMOVE the following commented line -// this->ValidateProgram(); - - glCullFace (GL_BACK); - // otherwise, we are rendering back face to initialize the zbuffer. - - - if(!this->GeneratingCanonicalView && this->ReportProgress) - { - // initialize the time to avoid a progress event at the beginning. - this->LastProgressEventTime=vtkTimerLog::GetUniversalTime(); - } - - this->PrintError("PreRender end"); -} - -//----------------------------------------------------------------------------- -// Compute how each axis of a cell is projected on the viewport in pixel. -// This requires to have information about the camera and about the volume. -// It set the value of IgnoreSampleDistancePerPixel to true in case of -// degenerated case (axes aligned with the view). -//----------------------------------------------------------------------------- -double vtkMitkOpenGLGPUVolumeRayCastMapper::ComputeMinimalSampleDistancePerPixel( - vtkRenderer *renderer, - vtkVolume *volume) -{ - // For each of the 3 directions of a cell, compute the step in z - // (world coordinate, not eye/camera coordinate) - // to go to the next pixel in x. - // Same for the next pixel in y. - // Keep the minimum of both zstep - // Then keep the minimum for the 3 directions. - - // in case of either the numerator or the denominator of each ratio is 0. - this->IgnoreSampleDistancePerPixel=true; - double result=0.0; - - vtkMatrix4x4 *worldToDataset=volume->GetMatrix(); - vtkCamera *camera=renderer->GetActiveCamera(); - vtkMatrix4x4 *eyeToWorld=camera->GetViewTransformMatrix(); - vtkMatrix4x4 *eyeToDataset=vtkMatrix4x4::New(); - vtkMatrix4x4::Multiply4x4(eyeToWorld,worldToDataset,eyeToDataset); - - int usize; - int vsize; - renderer->GetTiledSize(&usize,&vsize); - vtkMatrix4x4 *viewportToEye=camera->GetProjectionTransformMatrix( - usize/static_cast(vsize),0.0,1.0); - - double volBounds[6]; - this->GetInput()->GetBounds(volBounds); - int dims[3]; - this->GetInput()->GetDimensions(dims); - - double v0[4]; - v0[0]=volBounds[0]; - v0[1]=volBounds[2]; - v0[2]=volBounds[4]; - v0[3]=1.0; - - double w0[4]; - eyeToDataset->MultiplyPoint(v0,w0); - - double z0; - - if(w0[3]!=0.0) - { - z0=w0[2]/w0[3]; - } - else - { - z0=0.0; - vtkGenericWarningMacro( "eyeToWorld transformation has some projective component." ); - } - - double p0[4]; - viewportToEye->MultiplyPoint(w0,p0); - p0[0]/=p0[3]; - p0[1]/=p0[3]; - p0[2]/=p0[3]; - - bool inFrustum=p0[0]>=-1.0 && p0[0]<=1.0 && p0[1]>=-1.0 && p0[1]<=1.0 && p0[2]>=-1.0 && p0[2]<=1.0; - - if(inFrustum) - { - int dim=0; - while(dim<3) - { - double v1[4]; - int coord=0; - while(coord<3) - { - if(coord==dim) - { - v1[coord]=volBounds[2*coord+1]; - } - else - { - v1[coord]=volBounds[2*coord]; // same as v0[coord]; - } - ++coord; - } - v1[3]=1.0; - - double w1[4]; - eyeToDataset->MultiplyPoint(v1,w1); - double z1; - - if(w1[3]!=0.0) - { - z1=w1[2]/w1[3]; - } - else - { - z1=0.0; - vtkGenericWarningMacro( "eyeToWorld transformation has some projective component." ); - } - - - double p1[4]; - viewportToEye->MultiplyPoint(w1,p1); - p1[0]/=p1[3]; - p1[1]/=p1[3]; - p1[2]/=p1[3]; - - inFrustum=p1[0]>=-1.0 && p1[0]<=1.0 && p1[1]>=-1.0 && p1[1]<=1.0 && p1[2]>=-1.0 && p1[2]<=1.0; - - if(inFrustum) - { - double dx=fabs(p1[0]-p0[0]); - double dy=fabs(p1[1]-p0[1]); - double dz=fabs(z1-z0); - dz=dz/(dims[dim]-1); - dx=dx/(dims[dim]-1)*usize; - dy=dy/(dims[dim]-1)*vsize; - - if(dz!=0.0) - { - if(dx!=0.0) - { - double d=dz/dx; - if(!this->IgnoreSampleDistancePerPixel) - { - if(result>d) - { - result=d; - } - } - else - { - this->IgnoreSampleDistancePerPixel=false; - result=d; - } - } - - if(dy!=0.0) - { - double d=dz/dy; - if(!this->IgnoreSampleDistancePerPixel) - { - if(result>d) - { - result=d; - } - } - else - { - this->IgnoreSampleDistancePerPixel=false; - result=d; - } - } - - } - } - ++dim; - } - } - - eyeToDataset->Delete(); - - if(this->IgnoreSampleDistancePerPixel) - { - // cout<<"ignore SampleDistancePerPixel"<ValidateProgram(); - - this->PrintError("before render"); - if(!this->Cropping) - { - this->RenderWholeVolume(ren,vol); - } - else - { - this->ClipCroppingRegionPlanes(); - this->RenderRegions(ren,vol); - } - this->PrintError("after render"); -} - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::PostRender( - vtkRenderer *ren, - int numberOfScalarComponents) -{ - this->PrintError("PostRender1"); - if(this->NumberOfCroppingRegions>1) - { - if(this->BlendMode==vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND - || this->BlendMode==vtkMitkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND) - { - vtkgl::ActiveTexture( vtkgl::TEXTURE5 ); - glBindTexture(GL_TEXTURE_2D,0); - } - - if(this->LastRayCastMethod!=vtkMitkOpenGLGPUVolumeRayCastMapperMethodMIP - && this->LastRayCastMethod!=vtkMitkOpenGLGPUVolumeRayCastMapperMethodMinIP) - { - vtkgl::ActiveTexture( vtkgl::TEXTURE4 ); - glBindTexture(GL_TEXTURE_2D,0); - } - } - - // noisetexture - vtkgl::ActiveTexture(vtkgl::TEXTURE6); - glBindTexture(GL_TEXTURE_2D,0); - - // depthtexture - vtkgl::ActiveTexture(vtkgl::TEXTURE3); - glBindTexture(GL_TEXTURE_2D,0); - - // opacity - vtkgl::ActiveTexture(vtkgl::TEXTURE2); - glBindTexture(GL_TEXTURE_1D,0); - - if(numberOfScalarComponents==1) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE1); - glBindTexture(GL_TEXTURE_1D,0); - } - - - // mask, if any - if(this->MaskInput!=0) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE7); - glBindTexture(vtkgl::TEXTURE_3D_EXT,0); - } - - // back to active texture 0. - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - glBindTexture(vtkgl::TEXTURE_3D_EXT,0); - - vtkgl::UseProgram(0); - - this->PrintError("after UseProgram(0)"); - - this->CleanupRender(); - this->PrintError("after CleanupRender"); - - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, - static_cast(this->SavedFrameBuffer)); - this->SavedFrameBuffer=0; - - // Undo the viewport change we made to reduce resolution - int size[2]; - int lowerLeft[2]; - ren->GetTiledSizeAndOrigin(size,size+1,lowerLeft,lowerLeft+1); - glViewport(lowerLeft[0],lowerLeft[1], size[0], size[1]); - glEnable( GL_SCISSOR_TEST ); - glScissor(lowerLeft[0],lowerLeft[1], size[0], size[1]); - - // Render the texture to the screen - this copies the offscreen buffer - // onto the screen as a texture mapped polygon - this->RenderTextureToScreen(ren); - this->PrintError("after RenderTextureToScreen"); - - glEnable(GL_DEPTH_TEST); - - glPopAttrib(); // restore the blending mode and function - - glFinish(); - - this->PrintError("PostRender2"); -} - -//----------------------------------------------------------------------------- -// The main render method called from the superclass -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::GPURender(vtkRenderer *ren, - vtkVolume *vol) -{ - // We've already checked that we have input - vtkImageData *input = this->GetTransformedInput(); - - // Get the bounds of this data - double bounds[6]; - this->GetBounds(bounds); - - // Get the scalar range. First we have to get the scalars. - double range[2]; - vtkDataArray *scalars=this->GetScalars(input,this->ScalarMode, - this->ArrayAccessMode, - this->ArrayId,this->ArrayName, - this->CellFlag); - - // How many components are there? - int numberOfScalarComponents=scalars->GetNumberOfComponents(); - - // If it is just one, then get the range from the scalars - if(numberOfScalarComponents==1) - { - // Warning: here, we ignore the blank cells. - scalars->GetRange(range); - } - // If it is 3, then use the 4th component's range since that is - // the component that will be passed through the scalar opacity - // transfer function to look up opacity - else - { - // Note that we've already checked data type and we know this is - // unsigned char - scalars->GetRange(range,3); - } - - // The rendering work has been broken into 3 stages to support AMR - // volume rendering in blocks. Here we are simply rendering the - // whole volume as one block. Note that if the volume is too big - // to fix into texture memory, it will be streamed through in the - // RenderBlock method. - - this->PreRender(ren,vol,bounds,range,numberOfScalarComponents,1); - - if(!this->OpacityTables) - this->PreRender(ren,vol,bounds,range,numberOfScalarComponents,1); - - if(this->LoadExtensionsSucceeded) - { - this->RenderBlock(ren,vol,0); - this->PostRender(ren,numberOfScalarComponents); - } - - // Let's just make sure no OpenGL errors occurred during this render - this->PrintError("End GPU Render"); - - // If this isn't a canonical view render, then update the progress to - // 1 because we are done. - if (!this->GeneratingCanonicalView ) - { - double progress=1.0; - this->InvokeEvent(vtkCommand::VolumeMapperRenderProgressEvent,&progress); - ren->GetRenderWindow()->MakeCurrent(); - } -} - - -//----------------------------------------------------------------------------- -// Render a the whole volume. -// \pre this->ProgramShader!=0 and is linked. -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::RenderWholeVolume(vtkRenderer *ren, - vtkVolume *vol) -{ - double volBounds[6]; - this->GetTransformedInput()->GetBounds(volBounds); - this->RenderSubVolume(ren,volBounds,vol); -} - - -//----------------------------------------------------------------------------- -// Sort regions from front to back. -//----------------------------------------------------------------------------- -class vtkRegionDistance2 -{ -public: - size_t Id; // 0<=Id<27 - // square distance between camera center to region center: >=0 - double Distance2; -}; - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -extern "C" int vtkRegionComparisonFunction(const void *x, - const void *y) -{ - double dx=static_cast(x)->Distance2; - double dy=static_cast(y)->Distance2; - - int result; - if(dxdy) - { - result=1; - } - else - { - result=0; - } - } - return result; -} - -//----------------------------------------------------------------------------- -// Render a subvolume. -// \pre this->ProgramShader!=0 and is linked. -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::RenderRegions(vtkRenderer *ren, - vtkVolume *vol) -{ - double bounds[27][6]; - double distance2[27]; - - double camPos[4]; - ren->GetActiveCamera()->GetPosition(camPos); - - double volBounds[6]; - this->GetInput()->GetBounds(volBounds); - - - // Pass camera through inverse volume matrix - // so that we are in the same coordinate system - vol->GetMatrix( this->InvVolumeMatrix ); - camPos[3] = 1.0; - this->InvVolumeMatrix->Invert(); - this->InvVolumeMatrix->MultiplyPoint( camPos, camPos ); - if ( camPos[3] ) - { - camPos[0] /= camPos[3]; - camPos[1] /= camPos[3]; - camPos[2] /= camPos[3]; - } - - // These are the region limits for x (first four), y (next four) and - // z (last four). The first region limit is the lower bound for - // that axis, the next two are the region planes along that axis, and - // the final one in the upper bound for that axis. - double limit[12]; - size_t i; - for ( i = 0; i < 3; i++ ) - { - limit[i*4 ] = volBounds[i*2]; - limit[i*4+1] = this->ClippedCroppingRegionPlanes[i*2]; - limit[i*4+2] = this->ClippedCroppingRegionPlanes[i*2+1]; - limit[i*4+3] = volBounds[i*2+1]; - } - - // For each of the 27 possible regions, find out if it is enabled, - // and if so, compute the bounds and the distance from the camera - // to the center of the region. - size_t numRegions = 0; - size_t region; - for ( region = 0; region < 27; region++ ) - { - int regionFlag = 1<CroppingRegionFlags & regionFlag ) - { - // what is the coordinate in the 3x3x3 grid - size_t loc[3]; - loc[0] = region%3; - loc[1] = (region/3)%3; - loc[2] = (region/9)%3; - - // make sure the cropping region is not empty NEW - // otherwise, we skip the region. - if((limit[loc[0]]!=limit[loc[0]+1]) - && (limit[loc[1]+4]!=limit[loc[1]+5]) - && (limit[loc[2]+8]!=limit[loc[2]+9])) - { - // compute the bounds and center - double center[3]; - for ( i = 0; i < 3; i++ ) - { - bounds[numRegions][i*2 ] = limit[4*i+loc[i]]; - bounds[numRegions][i*2+1] = limit[4*i+loc[i]+1]; - center[i]=(bounds[numRegions][i*2]+bounds[numRegions][i*2+1])*0.5; - } - - // compute the distance squared to the center - distance2[numRegions] = - (camPos[0]-center[0])*(camPos[0]-center[0]) + - (camPos[1]-center[1])*(camPos[1]-center[1]) + - (camPos[2]-center[2])*(camPos[2]-center[2]); - - // we've added one region - numRegions++; - } - } - } - vtkRegionDistance2 regions[27]; - - i=0; - while(iNumberOfCroppingRegions>=0); -} - -//----------------------------------------------------------------------------- -// slabsDataSet are position of the slabs in dataset coordinates. -// slabsPoints are position of the slabs in points coordinates. -// For instance, slabsDataSet[0] is the position of the plane bounding the slab -// on the left of x axis of the dataset. slabsPoints[0]=0.3 means that -// this plane lies between point 0 and point 1 along the x-axis. -// There is no clamping/clipping according to the dataset bounds so, -// slabsPoints can be negative or excess the number of points along the -// corresponding axis. -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::SlabsFromDatasetToIndex( - double slabsDataSet[6], - double slabsPoints[6]) -{ - double *spacing=this->GetInput()->GetSpacing(); - double origin[3]; - - // take spacing sign into account - double *bds = this->GetInput()->GetBounds(); - origin[0] = bds[0]; - origin[1] = bds[2]; - origin[2] = bds[4]; - - int i=0; - while(i<6) - { - slabsPoints[i]=(slabsDataSet[i] - origin[i/2]) / spacing[i/2]; - ++i; - } -} - -//----------------------------------------------------------------------------- -// slabsDataSet are position of the slabs in dataset coordinates. -// slabsPoints are position of the slabs in points coordinates. -// For instance, slabsDataSet[0] is the position of the plane bounding the slab -// on the left of x axis of the dataset. slabsPoints[0]=0.3 means that -// this plane lies between point 0 and point 1 along the x-axis. -// There is no clamping/clipping according to the dataset bounds so, -// slabsPoints can be negative or excess the number of points along the -// corresponding axis. -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::SlabsFromIndexToDataset( - double slabsPoints[6], - double slabsDataSet[6]) -{ - double *spacing=this->GetInput()->GetSpacing(); - double origin[3]; - - // take spacing sign into account - double *bds = this->GetInput()->GetBounds(); - origin[0] = bds[0]; - origin[1] = bds[2]; - origin[2] = bds[4]; - - int i=0; - while(i<6) - { - slabsDataSet[i]=slabsPoints[i]*spacing[i/2]+origin[i/2]; - ++i; - } -} - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -class vtkStreamBlock -{ -public: - double Bounds[6]; - double Extent[6]; -}; - -//----------------------------------------------------------------------------- -// Render a subvolume. bounds are in world coordinates. -// \pre this->ProgramShader!=0 and is linked. -//----------------------------------------------------------------------------- -int vtkMitkOpenGLGPUVolumeRayCastMapper::RenderSubVolume(vtkRenderer *ren, - double bounds[6], - vtkVolume *volume) -{ - // Time to load scalar field - size_t i; - int wholeTextureExtent[6]; - this->GetTransformedInput()->GetExtent(wholeTextureExtent); - if(this->CellFlag) - { - i=1; - while(i<6) - { - wholeTextureExtent[i]--; - i+=2; - } - } - - // 1. Found out the extent of the subvolume - double realExtent[6]; - int subvolumeTextureExtent[6]; - - this->SlabsFromDatasetToIndex(bounds,realExtent); - - if(this->CellFlag) // 3D texture are celldata - { - // texture extents are expressed in cells in this case - i=0; - while(i<6) - { - subvolumeTextureExtent[i]=vtkMath::Floor(realExtent[i]-0.5); - ++i; - subvolumeTextureExtent[i]=vtkMath::Floor(realExtent[i]-0.5)+1; - ++i; - } - } - else - { - // texture extents are expressed in points in this case - i=0; - while(i<6) - { - subvolumeTextureExtent[i]=vtkMath::Floor(realExtent[i]); - ++i; - subvolumeTextureExtent[i]=vtkMath::Floor(realExtent[i])+1; // used to not have +1 - ++i; - } - } - - i=0; - while(i<6) - { - assert("check: wholeTextureExtent" && wholeTextureExtent[i]==0); - if(subvolumeTextureExtent[i]wholeTextureExtent[i]) - { - subvolumeTextureExtent[i]=wholeTextureExtent[i]; - } - ++i; - } - - assert("check: subvolume_inside_wholevolume" && - subvolumeTextureExtent[0]>=wholeTextureExtent[0] - && subvolumeTextureExtent[1]<=wholeTextureExtent[1] - && subvolumeTextureExtent[2]>=wholeTextureExtent[2] - && subvolumeTextureExtent[3]<=wholeTextureExtent[3] - && subvolumeTextureExtent[4]>=wholeTextureExtent[4] - && subvolumeTextureExtent[5]<=wholeTextureExtent[5]); - - // 2. Is this subvolume already on the GPU? - // ie are the extent of the subvolume inside the loaded extent? - - - // Find the texture (and mask). - vtkstd::map::iterator it= - this->ScalarsTextures->Map.find(this->GetTransformedInput()); - vtkKWScalarField *texture; - if(it==this->ScalarsTextures->Map.end()) - { - texture=0; - } - else - { - texture=(*it).second; - } - - vtkKWMask *mask=0; - if(this->MaskInput!=0) - { - vtkstd::map::iterator it2= - this->MaskTextures->Map.find(this->MaskInput); - if(it2==this->MaskTextures->Map.end()) - { - mask=0; - } - else - { - mask=(*it2).second; - } - } - - int loaded = - texture!=0 && - texture->IsLoaded() && - this->GetTransformedInput()->GetMTime()<=texture->GetBuildTime() && - (this->GetMaskInput() ? this->GetMaskInput()->GetMTime() <= texture->GetBuildTime() : true) && - texture->GetLoadedCellFlag()==this->CellFlag; - - - vtkIdType *loadedExtent; - - if(loaded) - { - loadedExtent=texture->GetLoadedExtent(); - i=0; - while(loaded && i<6) - { - loaded=loaded && loadedExtent[i]<=subvolumeTextureExtent[i]; - ++i; - loaded=loaded && loadedExtent[i]>=subvolumeTextureExtent[i]; - ++i; - } - } - - if(loaded) - { - this->CurrentScalar=texture; - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - this->CurrentScalar->Bind(); - - vtkgl::ActiveTexture(vtkgl::TEXTURE7); - this->CurrentMask=mask; - if(this->CurrentMask!=0) - { - this->CurrentMask->Bind(); - } - } - - if(!loaded) - { - // 3. Not loaded: try to load the whole dataset - if(!this->LoadScalarField(this->GetTransformedInput(),this->MaskInput,wholeTextureExtent,volume)) - { - // 4. loading the whole dataset failed: try to load the subvolume - if(!this->LoadScalarField(this->GetTransformedInput(),this->MaskInput, subvolumeTextureExtent, - volume)) - { - // 5. loading the subvolume failed: stream the subvolume - // 5.1 do zslabs first, if too large then cut with x or y with the - // largest dimension. order of zlabs depends on sign of spacing[2] - int streamTextureExtent[6]; - i=0; - while(i<6) - { - streamTextureExtent[i]=subvolumeTextureExtent[i]; - ++i; - } - - unsigned int internalFormat; - unsigned int format; - unsigned int type; - int componentSize; - this->GetTextureFormat(this->GetInput(),&internalFormat,&format,&type, - &componentSize); - - // Enough memory? - int originalTextureSize[3]; - int textureSize[3]; - i=0; - while(i<3) - { - textureSize[i]=subvolumeTextureExtent[2*i+1]-subvolumeTextureExtent[2*i]+1; - originalTextureSize[i]=textureSize[i]; - ++i; - } - - // Make sure loading did not fail because of theorical limits - - GLint width; - glGetIntegerv(vtkgl::MAX_3D_TEXTURE_SIZE,&width); - - int clippedXY=0; - int clippedZ=0; - - if(textureSize[0]>width) - { - textureSize[0]=width; - clippedXY=1; - } - if(textureSize[1]>width) - { - textureSize[1]=width; - clippedXY=1; - } - if(textureSize[2]>width) - { - textureSize[2]=width; - clippedZ=1; - } - - int minSize; - if(this->CellFlag) - { - minSize=1; - } - else - { - minSize=2; - } - - if(clippedXY) - { - // We cannot expect to first divide as z-slabs because it is already - // clipped in another dimension. From now, just divide in the largest - // dimension. - bool foundSize=false; - while(!foundSize && textureSize[0]>=minSize - && textureSize[1]>=minSize) - { - foundSize=this->TestLoadingScalar(internalFormat,format,type, - textureSize,componentSize); - if(!foundSize) - { - int maxDim=0; - if(textureSize[1]>textureSize[0]) - { - maxDim=1; - } - if(textureSize[2]>textureSize[maxDim]) - { - maxDim=2; - } - textureSize[maxDim]>>=1; // /=2 - } - } - } - else - { - // we are in cropping mode, it will be slow anyway. the case we want - // to optimize is stream the all scalar field. With that in mine, - // it is better to first try to send z-slabs. If even a minimal - // z-slab is too big, we have to divide by x or y dimensions. In - // this case, it will be slow and we can choose to keep blocks as - // square as possible by dividing by the largest dimension at each - // iteration. - - if(!clippedZ) - { - // we start by subdividing only if we did not already clipped - // the z dimension according to the theorical limits. - textureSize[2]>>=1; // /=2 - } - - bool foundSize=false; - while(!foundSize && textureSize[2]>=minSize) - { - foundSize=this->TestLoadingScalar(internalFormat,format,type, - textureSize,componentSize); - if(!foundSize) - { - textureSize[2]>>=1; // /=2 - } - } - if(!foundSize) - { - textureSize[2]=minSize; - if(textureSize[0]>textureSize[1]) - { - textureSize[0]>>=1; // /=2 - } - else - { - textureSize[1]>>=1; // /=2 - } - while(!foundSize && textureSize[0]>=minSize - && textureSize[1]>=minSize) - { - foundSize=this->TestLoadingScalar(internalFormat,format,type, - textureSize,componentSize); - if(!foundSize) - { - if(textureSize[0]>textureSize[1]) - { - textureSize[0]>>=1; // /=2 - } - else - { - textureSize[1]>>=1; // /=2 - } - } - } - } - if(!foundSize) - { - vtkErrorMacro( - <<"No memory left on the GPU even for a minimal block."); - return 1; // abort - } - } - - // except for the last bound. - // front to back ordering - - // Pass camera through inverse volume matrix - // so that we are in the same coordinate system - double camPos[4]; - vtkCamera *cam = ren->GetActiveCamera(); - cam->GetPosition(camPos); - volume->GetMatrix( this->InvVolumeMatrix ); - camPos[3] = 1.0; - this->InvVolumeMatrix->Invert(); - this->InvVolumeMatrix->MultiplyPoint( camPos, camPos ); - if ( camPos[3] ) - { - camPos[0] /= camPos[3]; - camPos[1] /= camPos[3]; - camPos[2] /= camPos[3]; - } - - - // 5.2 iterate of each stream of the subvolume and render it: - - // point scalar: on the first block, the first point is not shared - - // blockExtent is always expressed in point, not in texture - // extent. - size_t remainder[3]; - i=0; - while(i<3) - { - remainder[i]=static_cast( - (originalTextureSize[i]-textureSize[i])%(textureSize[i]-1)); - if(remainder[i]>0) - { - remainder[i]=1; - } - ++i; - } - - size_t counts[3]; - - counts[0]=static_cast((originalTextureSize[0]-textureSize[0]) - /(textureSize[0]-1)); - counts[0]+=remainder[0]+1; - counts[1]=static_cast((originalTextureSize[1]-textureSize[1]) - /(textureSize[1]-1)); - counts[1]+=remainder[1]+1; - counts[2]=static_cast((originalTextureSize[2]-textureSize[2]) - /(textureSize[2]-1)); - counts[2]+=remainder[2]+1; - - size_t count=counts[0]*counts[1]*counts[2]; - - double blockExtent[6]; - vtkStreamBlock *blocks=new vtkStreamBlock[count]; - vtkRegionDistance2 *sortedBlocks=new vtkRegionDistance2[count]; - - // iterate over z,y,x - size_t blockId=0; - - size_t zIndex=0; - blockExtent[4]=realExtent[4]; - blockExtent[5]=vtkMath::Floor(blockExtent[4])+textureSize[2]; - if(!this->CellFlag) - { - blockExtent[5]--; - } - if(blockExtent[5]>realExtent[5]) - { - blockExtent[5]=realExtent[5]; - } - while(zIndexCellFlag) - { - blockExtent[3]--; - } - if(blockExtent[3]>realExtent[3]) - { - blockExtent[3]=realExtent[3]; - } - size_t yIndex=0; - while(yIndexCellFlag) - { - blockExtent[1]--; - } - if(blockExtent[1]>realExtent[1]) - { - blockExtent[1]=realExtent[1]; - } - size_t xIndex=0; - while(xIndexSlabsFromIndexToDataset(blockExtent,blockBounds); - - // compute the bounds and center - double center[3]; - i=0; - while(i<3) - { - center[i]=(blockBounds[i*2]+blockBounds[i*2+1])*0.5; - ++i; - } - - // compute the distance squared to the center - double distance2=(camPos[0]-center[0])*(camPos[0]-center[0])+ - (camPos[1]-center[1])*(camPos[1]-center[1]) + - (camPos[2]-center[2])*(camPos[2]-center[2]); - - i=0; - while(i<6) - { - blocks[blockId].Bounds[i]=blockBounds[i]; - blocks[blockId].Extent[i]=blockExtent[i]; - ++i; - } - - sortedBlocks[blockId].Id=blockId; - sortedBlocks[blockId].Distance2=distance2; - - ++blockId; - - blockExtent[0]=blockExtent[1]; - blockExtent[1]=blockExtent[0]+textureSize[0]; - if(!this->CellFlag) - { - blockExtent[1]--; - } - if(blockExtent[1]>realExtent[1]) - { - blockExtent[1]=realExtent[1]; - } - ++xIndex; - } // while x - - blockExtent[2]=blockExtent[3]; - blockExtent[3]=blockExtent[2]+textureSize[1]; - if(!this->CellFlag) - { - blockExtent[3]--; - } - if(blockExtent[3]>realExtent[3]) - { - blockExtent[3]=realExtent[3]; - } - ++yIndex; - } // while y - - - blockExtent[4]=blockExtent[5]; - blockExtent[5]=blockExtent[4]+textureSize[2]; - if(!this->CellFlag) - { - blockExtent[5]--; - } - if(blockExtent[5]>realExtent[5]) - { - blockExtent[5]=realExtent[5]; - } - ++zIndex; - } // while z - - assert("check: valid_number_of_blocks" && blockId==count); - - qsort(sortedBlocks,static_cast(count), - sizeof(vtkRegionDistance2), - vtkRegionComparisonFunction); - - // loop over all blocks we need to render - i=0; - int abort=0; - while(!abort && i < count) // 1) //count) - { - size_t k=sortedBlocks[i].Id; - - int blockTextureExtent[6]; - int j; - if(this->CellFlag) // 3D texture are celldata - { - // texture extents are expressed in cells in this case - j=0; - while(j<6) - { - blockTextureExtent[j]=vtkMath::Floor(blocks[k].Extent[j]); - ++j; - } - } - else - { - // texture extents are expressed in points in this case - j=0; - while(j<6) - { - blockTextureExtent[j]=vtkMath::Floor(blocks[k].Extent[j]); - ++j; - blockTextureExtent[j]=vtkMath::Floor(blocks[k].Extent[j]); - if(blockTextureExtent[j]LoadScalarField(this->GetInput(),this->MaskInput, blockTextureExtent, - volume)) - { - cout<<"Loading the streamed block FAILED!!!!!"<CurrentScalar->GetLoadedExtent(); - - float lowBounds[3]; - float highBounds[3]; - if(!this->CurrentScalar->GetLoadedCellFlag()) // points - { - j=0; - while(j<3) - { - double delta= - static_cast(loadedExtent[j*2+1]-loadedExtent[j*2]); - lowBounds[j]=static_cast((blocks[k].Extent[j*2]-static_cast(loadedExtent[j*2]))/delta); - highBounds[j]=static_cast((blocks[k].Extent[j*2+1]-static_cast(loadedExtent[j*2]))/delta); - ++j; - } - } - else // cells - { - j=0; - while(j<3) - { - double delta= - static_cast(loadedExtent[j*2+1]-loadedExtent[j*2]); - lowBounds[j]=static_cast((blocks[k].Extent[j*2]-0.5-static_cast(loadedExtent[j*2]))/delta); - highBounds[j]=static_cast((blocks[k].Extent[j*2+1]-0.5-static_cast(loadedExtent[j*2]))/delta); - ++j; - } - } - - - - - // bounds have to be normalized. There are used in the shader - // as bounds to a value used to sample a texture. - - assert("check: positive_low_bounds0" && lowBounds[0]>=0.0); - assert("check: positive_low_bounds1" && lowBounds[1]>=0.0); - assert("check: positive_low_bounds2" && lowBounds[2]>=0.0); - - assert("check: increasing_bounds0" && lowBounds[0]<=highBounds[0]); - assert("check: increasing_bounds1" && lowBounds[1]<=highBounds[1]); - assert("check: increasing_bounds2" && lowBounds[2]<=highBounds[2]); - assert("check: high_bounds0_less_than1" && highBounds[0]<=1.0); - assert("check: high_bounds1_less_than1" && highBounds[1]<=1.0); - assert("check: high_bounds2_less_than1" && highBounds[2]<=1.0); - - GLint lb; - lb=vtkgl::GetUniformLocation(static_cast(this->ProgramShader), - "lowBounds"); - - this->PrintError("get uniform low bounds"); - if(lb!=-1) - { - vtkgl::Uniform3f(lb, lowBounds[0],lowBounds[1],lowBounds[2]); - this->PrintError("set uniform low bounds"); - } - else - { - vtkErrorMacro(<<" lowBounds is not a uniform variable."); - } - GLint hb; - hb=vtkgl::GetUniformLocation(static_cast(this->ProgramShader), - "highBounds"); - this->PrintError("get uniform high bounds"); - if(hb!=-1) - { - vtkgl::Uniform3f(hb, highBounds[0],highBounds[1],highBounds[2]); - this->PrintError("set uniform high bounds"); - } - else - { - vtkErrorMacro(<<" highBounds is not a uniform variable."); - } - - this->PrintError("uniform low/high bounds block"); - // other sub-volume rendering code - this->LoadProjectionParameters(ren,volume); - this->ClipBoundingBox(ren,blocks[k].Bounds,volume); - abort=this->RenderClippedBoundingBox(1,i,count,ren->GetRenderWindow()); - if (!abort) - { - this->CopyFBOToTexture(); - } - this->PrintError("render clipped block 1"); - - - - ++i; - } - - delete[] blocks; - delete[] sortedBlocks; - return abort; - } - } - } - - loadedExtent=this->CurrentScalar->GetLoadedExtent(); - - // low bounds and high bounds are in texture coordinates. - float lowBounds[3]; - float highBounds[3]; - if(!this->CurrentScalar->GetLoadedCellFlag()) // points - { - i=0; - while(i<3) - { - double delta= - static_cast(loadedExtent[i*2+1]-loadedExtent[i*2]+1); - lowBounds[i]=static_cast((realExtent[i*2]+0.5-static_cast(loadedExtent[i*2]))/delta); - highBounds[i]=static_cast((realExtent[i*2+1]+0.5-static_cast(loadedExtent[i*2]))/delta); - ++i; - } - } - else // cells - { - i=0; - while(i<3) - { - double delta= - static_cast(loadedExtent[i*2+1]-loadedExtent[i*2]+1); - - // this->LoadedExtent[i*2]==0, texcoord starts at 0, if realExtent==0 - // otherwise, texcoord start at 1/2N - // this->LoadedExtent[i*2]==wholeTextureExtent[i*2+1], texcoord stops at 1, if realExtent==wholeTextureExtent[i*2+1]+1 - // otherwise it stop at 1-1/2N - // N is the number of texels in the loadedtexture not the number of - // texels in the whole texture. - - lowBounds[i]=static_cast((realExtent[i*2]-static_cast(loadedExtent[i*2]))/delta); - highBounds[i]=static_cast((realExtent[i*2+1]-static_cast(loadedExtent[i*2]))/delta); - ++i; - } - } - - assert("check: positive_low_bounds0" && lowBounds[0]>=0.0); - assert("check: positive_low_bounds1" && lowBounds[1]>=0.0); - assert("check: positive_low_bounds2" && lowBounds[2]>=0.0); - - assert("check: increasing_bounds0" && lowBounds[0]<=highBounds[0]); - assert("check: increasing_bounds1" && lowBounds[1]<=highBounds[1]); - assert("check: increasing_bounds2" && lowBounds[2]<=highBounds[2]); - assert("check: high_bounds0_less_than1" && highBounds[0]<=1.0); - assert("check: high_bounds1_less_than1" && highBounds[1]<=1.0); - assert("check: high_bounds2_less_than1" && highBounds[2]<=1.0); - - GLint lb; - lb=vtkgl::GetUniformLocation(static_cast(this->ProgramShader), - "lowBounds"); - - this->PrintError("get uniform low bounds"); - if(lb!=-1) - { - vtkgl::Uniform3f(lb, lowBounds[0],lowBounds[1],lowBounds[2]); - this->PrintError("set uniform low bounds"); - } - else - { - vtkErrorMacro(<<" lowBounds is not a uniform variable."); - } - GLint hb; - hb=vtkgl::GetUniformLocation(static_cast(this->ProgramShader), - "highBounds"); - this->PrintError("get uniform high bounds"); - if(hb!=-1) - { - vtkgl::Uniform3f(hb, highBounds[0],highBounds[1],highBounds[2]); - this->PrintError("set uniform high bounds"); - } - else - { - vtkErrorMacro(<<" highBounds is not a uniform variable."); - } - - this->PrintError("uniform low/high bounds"); - // other sub-volume rendering code - this->LoadProjectionParameters(ren,volume); - this->ClipBoundingBox(ren,bounds,volume); - int abort=this->RenderClippedBoundingBox(1,0,1,ren->GetRenderWindow()); - if (!abort) - { - this->CopyFBOToTexture(); - } - this->PrintError("render clipped 1"); - return abort; -} - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::LoadProjectionParameters( - vtkRenderer *ren, - vtkVolume *vol) -{ - vtkMatrix4x4 *worldToDataset=vol->GetMatrix(); - vtkMatrix4x4 *datasetToWorld=this->TempMatrix[0]; - vtkMatrix4x4::Invert(worldToDataset,datasetToWorld); - - double *bounds=this->CurrentScalar->GetLoadedBounds(); - - double dx=bounds[1]-bounds[0]; - double dy=bounds[3]-bounds[2]; - double dz=bounds[5]-bounds[4]; - - // worldToTexture matrix is needed - - // Compute change-of-coordinate matrix from world space to texture space. - vtkMatrix4x4 *worldToTexture=this->TempMatrix[2]; - vtkMatrix4x4 *datasetToTexture=this->TempMatrix[1]; - - // Set the matrix - datasetToTexture->Zero(); - datasetToTexture->SetElement(0,0,dx); - datasetToTexture->SetElement(1,1,dy); - datasetToTexture->SetElement(2,2,dz); - datasetToTexture->SetElement(3,3,1.0); - datasetToTexture->SetElement(0,3,bounds[0]); - datasetToTexture->SetElement(1,3,bounds[2]); - datasetToTexture->SetElement(2,3,bounds[4]); - - // worldToTexture=worldToDataSet*dataSetToTexture - vtkMatrix4x4::Multiply4x4(worldToDataset,datasetToTexture,worldToTexture); - - // NEW - int parallelProjection=ren->GetActiveCamera()->GetParallelProjection(); - -// cout << "actualSampleDistance=" << this->ActualSampleDistance << endl; - - if(parallelProjection) - { - // Unit vector of the direction of projection in world space. - double dirWorld[4]; - double dir[4]; - ren->GetActiveCamera()->GetDirectionOfProjection(dirWorld); - dirWorld[3]=0.0; - - // direction in dataset space. - datasetToWorld->MultiplyPoint(dirWorld,dir); - - // incremental vector: - // direction in texture space times sample distance in world space. - dir[0]=dir[0]*this->ActualSampleDistance/dx; - dir[1]=dir[1]*this->ActualSampleDistance/dy; - dir[2]=dir[2]*this->ActualSampleDistance/dz; - - GLint rayDir; - rayDir=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"parallelRayDirection"); - if(rayDir!=-1) - { - vtkgl::Uniform3f(rayDir,static_cast(dir[0]), - static_cast(dir[1]), - static_cast(dir[2])); - } - else - { - vtkErrorMacro(<<"parallelRayDirection is not a uniform variable."); - } - //cout<<"rayDir="<GetActiveCamera()->GetPosition(cameraPosWorld); - cameraPosWorld[3]=1.0; // we use homogeneous coordinates. - - datasetToWorld->MultiplyPoint(cameraPosWorld,cameraPosDataset); - - // From homogeneous to cartesian coordinates. - if(cameraPosDataset[3]!=1.0) - { - double ratio=1/cameraPosDataset[3]; - cameraPosDataset[0]*=ratio; - cameraPosDataset[1]*=ratio; - cameraPosDataset[2]*=ratio; - } - - cameraPosTexture[0] = (cameraPosDataset[0]-bounds[0])/dx; - cameraPosTexture[1] = (cameraPosDataset[1]-bounds[2])/dy; - cameraPosTexture[2] = (cameraPosDataset[2]-bounds[4])/dz; - - // Only make sense for the vectorial part of the homogeneous matrix. - // coefMatrix=transposeWorldToTexture*worldToTexture - // we re-cycle the datasetToWorld pointer with a different name - vtkMatrix4x4 *transposeWorldToTexture=this->TempMatrix[1]; - // transposeWorldToTexture={^t}worldToTexture - vtkMatrix4x4::Transpose(worldToTexture,transposeWorldToTexture); - - vtkMatrix4x4 *coefMatrix=this->TempMatrix[1]; - vtkMatrix4x4::Multiply4x4(transposeWorldToTexture,worldToTexture, - coefMatrix); - GLint uCameraPosition; - - uCameraPosition=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"cameraPosition"); - - if(uCameraPosition!=-1) - { - vtkgl::Uniform3f(uCameraPosition, - static_cast(cameraPosTexture[0]), - static_cast(cameraPosTexture[1]), - static_cast(cameraPosTexture[2])); - } - else - { - vtkErrorMacro(<<"cameraPosition is not a uniform variable."); - } - GLint uSampleDistance; - uSampleDistance=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"sampleDistance"); - - if(uSampleDistance!=-1) - { - vtkgl::Uniform1f(uSampleDistance,this->ActualSampleDistance); - } - else - { - vtkErrorMacro(<<"sampleDistance is not a uniform variable."); - } - - GLint uMatrix1; - - uMatrix1=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"matrix1"); - - if(uMatrix1!=-1) - { - vtkgl::Uniform3f(uMatrix1, - static_cast(coefMatrix->GetElement(0,0)), - static_cast(coefMatrix->GetElement(1,1)), - static_cast(coefMatrix->GetElement(2,2))); - } - else - { - vtkErrorMacro(<<"matrix1 is not a uniform variable."); - } - GLint uMatrix2; - uMatrix2=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"matrix2"); - - if(uMatrix2!=-1) - { - vtkgl::Uniform3f(uMatrix2, - static_cast(2*coefMatrix->GetElement(0,1)), - static_cast(2*coefMatrix->GetElement(1,2)), - static_cast(2*coefMatrix->GetElement(0,2))); - } - else - { - vtkErrorMacro(<<"matrix2 is not a uniform variable."); - } - } - this->PrintError("after uniforms for projection"); - - // Change-of-coordinate matrix from Eye space to texture space. - vtkMatrix4x4 *eyeToTexture=this->TempMatrix[1]; - vtkMatrix4x4 *eyeToWorld=ren->GetActiveCamera()->GetViewTransformMatrix(); - - vtkMatrix4x4::Multiply4x4(eyeToWorld,worldToTexture,eyeToTexture); - - GLfloat matrix[16];// used sometimes as 3x3, sometimes as 4x4. - double *raw=eyeToTexture->Element[0]; - int index; - int column; - int row; - - int shadeMethod=this->LastShade; - - if(shadeMethod==vtkMitkOpenGLGPUVolumeRayCastMapperShadeYes) - { - index=0; - column=0; - while(column<3) - { - row=0; - while(row<3) - { -// cout << "index=" << index << " row*4+column=" << row*4+column << endl; - matrix[index]=static_cast(raw[row*4+column]); - ++index; - ++row; - } - ++column; - } - GLint uEyeToTexture3; - - uEyeToTexture3=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"eyeToTexture3"); - - this->PrintError("after getUniform eyeToTexture3"); - - if(uEyeToTexture3!=-1) - { - vtkgl::UniformMatrix3fv(uEyeToTexture3,1,GL_FALSE,matrix); - } - else - { - vtkErrorMacro(<<"eyeToTexture3 is not a uniform variable."); - } - this->PrintError("after Uniform eyeToTexture3"); - - index=0; - column=0; - while(column<4) - { - row=0; - while(row<4) - { -// cout << "index=" << index << " row*4+column=" << row*4+column << endl; - matrix[index]=static_cast(raw[row*4+column]); - ++index; - ++row; - } - ++column; - } - GLint uEyeToTexture4; - - uEyeToTexture4=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"eyeToTexture4"); - - if(uEyeToTexture4!=-1) - { - vtkgl::UniformMatrix4fv(uEyeToTexture4,1,GL_FALSE,matrix); - } - else - { - vtkErrorMacro(<<"eyeToTexture4 is not a uniform variable."); - } - } - - eyeToTexture->Invert(); - - index=0; - column=0; - while(column<4) - { - row=0; - while(row<4) - { -// cout << "index=" << index << " row*4+column=" << row*4+column << endl; - matrix[index]=static_cast(raw[row*4+column]); - ++index; - ++row; - } - ++column; - } - - this->PrintError("before GetUniformLocation TextureToEye"); - GLint uTextureToEye; - - uTextureToEye=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"textureToEye"); - - this->PrintError("after GetUniformLocation TextureToEye"); - if(uTextureToEye!=-1) - { - vtkgl::UniformMatrix4fv(uTextureToEye,1,GL_FALSE,matrix); - } - else - { - vtkErrorMacro(<<"textureToEye is not a uniform variable."); - } - this->PrintError("after UniformMatrxix TextureToEye"); - - if(shadeMethod==vtkMitkOpenGLGPUVolumeRayCastMapperShadeYes) - { - eyeToTexture->Transpose(); - - index=0; - column=0; - while(column<3) - { - row=0; - while(row<3) - { -// cout << "index=" << index << " row*4+column=" << row*4+column << endl; - matrix[index]=static_cast(raw[row*4+column]); - ++index; - ++row; - } - ++column; - } - GLint uTranposeTextureToEye; - uTranposeTextureToEye=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"transposeTextureToEye"); - - if(uTranposeTextureToEye!=-1) - { - vtkgl::UniformMatrix3fv(uTranposeTextureToEye,1,GL_FALSE,matrix); - } - else - { - vtkErrorMacro(<<"transposeTextureToEye is not a uniform variable."); - } - - float cellScale[3]; // 1/(2*Step) - float cellStep[3]; // Step - - vtkIdType *loadedExtent=this->CurrentScalar->GetLoadedExtent(); - cellScale[0]=static_cast(static_cast( - loadedExtent[1]-loadedExtent[0])*0.5); - cellScale[1]=static_cast(static_cast( - loadedExtent[3]-loadedExtent[2])*0.5); - cellScale[2]=static_cast(static_cast( - loadedExtent[5]-loadedExtent[4])*0.5); - cellStep[0]=static_cast(1.0/static_cast( - loadedExtent[1]-loadedExtent[0])); - cellStep[1]=static_cast(1.0/static_cast( - loadedExtent[3]-loadedExtent[2])); - cellStep[2]=static_cast(1.0/static_cast( - loadedExtent[5]-loadedExtent[4])); - - GLint uCellScale; - uCellScale=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"cellScale"); - if(uCellScale!=-1) - { - vtkgl::Uniform3f(uCellScale,cellScale[0],cellScale[1],cellScale[2]); - } - else - { - vtkErrorMacro(<<"error: cellScale is not a uniform variable."); - } - GLint uCellStep; - - uCellStep=vtkgl::GetUniformLocation( - static_cast(this->ProgramShader),"cellStep"); - - if(uCellStep!=-1) - { - vtkgl::Uniform3f(uCellStep,cellStep[0],cellStep[1],cellStep[2]); - } - else - { - vtkErrorMacro(<<"error: cellStep is not a uniform variable."); - } - } - -} - - - -//----------------------------------------------------------------------------- -// Concatenate the header string, projection type code and method to the -// final fragment code in this->FragmentCode. -// \pre valid_raycastMethod: raycastMethod>= -// vtkMitkOpenGLGPUVolumeRayCastMapperMethodMIP && -// raycastMethod<=vtkMitkOpenGLGPUVolumeRayCastMapperMethodMinIPFourDependent -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::BuildProgram(int parallelProjection, - int raycastMethod, - int shadeMethod, - int componentMethod) -{ - - assert("pre: valid_raycastMethod" && - raycastMethod>= vtkMitkOpenGLGPUVolumeRayCastMapperMethodMIP - && raycastMethod<=vtkMitkOpenGLGPUVolumeRayCastMapperMethodCompositeMask); - GLuint fs; - -// cout<<"projection="<ProgramShader, - vtkgl::INFO_LOG_LENGTH,¶ms); - - if(params>0) - { - char *buffer=new char[params]; - vtkgl::GetProgramInfoLog(this->ProgramShader,params,0,buffer); - cout<<"validation log: "<GetEnabledString(glIsEnabled(GL_LIGHTING))<GetEnabledString(glIsEnabled(GL_LIGHTING))<(value); - cout<<"active texture is "<<(activeTexture-vtkgl::TEXTURE0)<(value); - - cout<<"light\t| status\t| ambient\t| diffuse\t| specular\t| position\t| spot direction\t| spot exponent\t| spot cutoff\t| k0\t| k1\t| k2"<=0 -// \post valid_result: result>=x -//----------------------------------------------------------------------------- -int vtkMitkOpenGLGPUVolumeRayCastMapper::PowerOfTwoGreaterOrEqual(int x) -{ - assert("pre: positive_x" && x>=0); - - int result=1; - while(result=x); - return result; -} - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::UpdateNoiseTexture() -{ - if(this->NoiseTextureId==0) - { - GLuint noiseTextureObject; - glGenTextures(1,&noiseTextureObject); - this->NoiseTextureId=static_cast(noiseTextureObject); - vtkgl::ActiveTexture(vtkgl::TEXTURE6); - glBindTexture(GL_TEXTURE_2D,noiseTextureObject); - - GLsizei size=128; // 1024; // Power of two value - GLint maxSize; - const float factor=0.1f; -// const float factor=1.0f; - const float amplitude=0.5f*factor; // something positive. - // amplitude=0.5. noise between -0.5 +0.5. add some +0.5 shift. - - glGetIntegerv(GL_MAX_TEXTURE_SIZE,&maxSize); - if(size>maxSize) - { - size=maxSize; - } - if(this->NoiseTexture!=0 && this->NoiseTextureSize!=size) - { - delete[] this->NoiseTexture; - this->NoiseTexture=0; - } - if(this->NoiseTexture==0) - { - this->NoiseTexture=new float[size*size]; - this->NoiseTextureSize=size; - vtkPerlinNoise *noiseGenerator=vtkPerlinNoise::New(); - noiseGenerator->SetFrequency(size,1.0,1.0); - noiseGenerator->SetPhase(0.0,0.0,0.0); - noiseGenerator->SetAmplitude(amplitude); - int j=0; - while(jNoiseTexture[j*size+i]=0.0; //amplitude+static_cast(noiseGenerator->EvaluateFunction(i,j,0.0)); - ++i; - } - ++j; - } - noiseGenerator->Delete(); - } - glTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE,size,size,0,GL_RED,GL_FLOAT, - this->NoiseTexture); - - glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); - GLfloat borderColor[4]={0.0,0.0,0.0,0.0}; - glTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_BORDER_COLOR,borderColor); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - } -} - -// ---------------------------------------------------------------------------- -// Description: -// Return how much the dataset has to be reduced in each dimension to -// fit on the GPU. If the value is 1.0, there is no need to reduce the -// dataset. -// \pre the calling thread has a current OpenGL context. -// \pre mapper_supported: IsRenderSupported(renderer->GetRenderWindow(),0) -// The computation is based on hardware limits (3D texture indexable size) -// and MaxMemoryInBytes. -// \post valid_i_ratio: ratio[0]>0 && ratio[0]<=1.0 -// \post valid_j_ratio: ratio[1]>0 && ratio[1]<=1.0 -// \post valid_k_ratio: ratio[2]>0 && ratio[2]<=1.0 -void vtkMitkOpenGLGPUVolumeRayCastMapper::GetReductionRatio(double ratio[3]) -{ - // Compute texture size - int i; - int wholeTextureExtent[6]; - this->GetInput()->GetExtent(wholeTextureExtent); - if(this->CellFlag) // if we deal with cell data - { - i=1; - while(i<6) - { - wholeTextureExtent[i]--; - i+=2; - } - } - - // Indexable hardware limits - GLint maxSize; - glGetIntegerv(vtkgl::MAX_3D_TEXTURE_SIZE,&maxSize); - - vtkIdType rTextureSize[3]; - double dMaxSize=static_cast(maxSize); - i=0; - while(i<3) - { - double textureSize=wholeTextureExtent[2*i+1]-wholeTextureExtent[2*i]+1; - if(textureSize>maxSize) - { - ratio[i]=dMaxSize/textureSize; - } - else - { - ratio[i]=1.0; // no reduction - } - rTextureSize[i]=static_cast(floor(textureSize*ratio[i])); - ++i; - } - - // Data memory limits. - - vtkDataArray *scalars=this->GetScalars(this->GetInput(),this->ScalarMode, - this->ArrayAccessMode, - this->ArrayId, - this->ArrayName, - this->CellFlag); - int scalarType=scalars->GetDataType(); - - vtkIdType size=rTextureSize[0]*rTextureSize[1]*rTextureSize[2] - *vtkAbstractArray::GetDataTypeSize(scalarType) - *scalars->GetNumberOfComponents(); - - if(size>static_cast(this->MaxMemoryInBytes) - *static_cast(this->MaxMemoryFraction)) - { - double r=static_cast(this->MaxMemoryInBytes) - *static_cast(this->MaxMemoryFraction)/static_cast(size); - double r3=pow(r,1.0/3.0); - // try the keep reduction ratio uniform to avoid artifacts. - bool reduced[3]; - i=0; - int count=0; - while(i<3) - { - vtkIdType newSize=static_cast( - floor(static_cast(rTextureSize[i])*r3)); - reduced[i]=newSize>=1; - if(reduced[i]) - { - ++count; - } - ++i; - } - - if(count<3) // some axis cannot be reduced - { - double r2=sqrt(r); - count=0; - i=0; - while(i<3) - { - if(reduced[i]) - { - vtkIdType newSize=static_cast( - floor(static_cast(rTextureSize[i])*r2)); - reduced[i]=newSize>=1; - if(reduced[i]) - { - ++count; - } - } - ++i; - } - if(count<2) // we can only reduce one axis - { - i=0; - while(i<3) - { - if(reduced[i]) - { - ratio[i]*=r; - } - ++i; - } - } - else // we can reduce two axes - { - i=0; - while(i<3) - { - if(reduced[i]) - { - ratio[i]*=r2; - } - ++i; - } - } - } - else // we can reduce all three axes - { - i=0; - while(i<3) - { - ratio[i]*=r3; - ++i; - } - } - } - - assert("post: valid_i_ratio" && ratio[0]>0 && ratio[0]<=1.0); - assert("post: valid_j_ratio" && ratio[1]>0 && ratio[1]<=1.0); - assert("post: valid_k_ratio" && ratio[2]>0 && ratio[2]<=1.0); -} - -//----------------------------------------------------------------------------- -// Standard print method -//----------------------------------------------------------------------------- -void vtkMitkOpenGLGPUVolumeRayCastMapper::PrintSelf(ostream& os, - vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); -} - -#endif diff --git a/Modules/Ext/Rendering/vtkMitkOpenGLGPUVolumeRayCastMapper.h b/Modules/Ext/Rendering/vtkMitkOpenGLGPUVolumeRayCastMapper.h deleted file mode 100644 index 3853505924..0000000000 --- a/Modules/Ext/Rendering/vtkMitkOpenGLGPUVolumeRayCastMapper.h +++ /dev/null @@ -1,526 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -/*========================================================================= - - Program: Visualization Toolkit - Module: $RCSfile: vtkMitkOpenGLGPUVolumeRayCastMapper.h,v $ - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -// .NAME vtkMitkOpenGLGPUVolumeRayCastMapper - OpenGL subclass that draws the -// image to the screen -// .SECTION Description -// This is the concrete implementation of a ray cast image display helper - -// a helper class responsible for drawing the image to the screen. - -// .SECTION see also -// vtkGPUVolumeRayCastMapper - -#ifndef __vtkMitkOpenGLGPUVolumeRayCastMapper_h -#define __vtkMitkOpenGLGPUVolumeRayCastMapper_h - -#include "vtkMitkGPUVolumeRayCastMapper.h" -#include "mitkCommon.h" -#include "MitkExtExports.h" - -// Only with VTK 5.6 or above -#if ((VTK_MAJOR_VERSION > 5) || ((VTK_MAJOR_VERSION==5) && (VTK_MINOR_VERSION>=6) )) - -class vtkVolume; -class vtkRenderer; -class vtkOpenGLExtensionManager; -class vtkMatrix4x4; -class vtkUnsupportedRequiredExtensionsStringStream; // Pimpl -class vtkMapDataArrayTextureId; // Pimpl -class vtkMapMaskTextureId; // Pimpl -class vtkPolyData; -class vtkClipConvexPolyData; -class vtkClipPolyData; -class vtkTessellatedBoxSource; - -class vtkOpacityTable; // internal class. -class vtkRGBTable; // internal class. -class vtkKWScalarField; // internal class. -class vtkKWMask; // internal class. - -class vtkOpacityTables; // Pimpl -class vtkDensifyPolyData; -class vtkStdString; - -class MitkExt_EXPORT vtkMitkOpenGLGPUVolumeRayCastMapper : public vtkMitkGPUVolumeRayCastMapper -{ -public: - static vtkMitkOpenGLGPUVolumeRayCastMapper *New(); - vtkTypeMacro(vtkMitkOpenGLGPUVolumeRayCastMapper,vtkMitkGPUVolumeRayCastMapper); - virtual void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // Based on hardware and properties, we may or may not be able to - // render using 3D texture mapping. This indicates if 3D texture - // mapping is supported by the hardware, and if the other extensions - // necessary to support the specific properties are available. - virtual int IsRenderSupported(vtkRenderWindow *window, - vtkVolumeProperty *property); - - // Description: - // Return a string matching the OpenGL errorCode. - // \post result_exists: result!=0 - static const char *OpenGLErrorMessage(unsigned int errorCode); - - // Description: - // Display headerMessage on the standard output and the last OpenGL error - // message if any. - // \pre headerMessage_exists: headerMessage!=0 - static void PrintError(const char *headerMessage); - - - -protected: - vtkMitkOpenGLGPUVolumeRayCastMapper(); - ~vtkMitkOpenGLGPUVolumeRayCastMapper(); - - // The render method called by the superclass - virtual void GPURender(vtkRenderer *ren, - vtkVolume *vol); - - // Methods called by the AMR Volume Mapper. - virtual void PreRender(vtkRenderer *ren, - vtkVolume *vol, - double datasetBounds[6], - double scalarRange[2], - int numberOfScalarComponents, - unsigned int numberOfLevels); - - // \pre input is up-to-date - virtual void RenderBlock(vtkRenderer *ren, - vtkVolume *vol, - unsigned int level); - - virtual void PostRender(vtkRenderer *ren, - int numberOfScalarComponents); - - // Description: - // Return if the required OpenGL extension `extensionName' is supported. - // If not, its name is added to the string of unsupported but required - // extensions. - // \pre extensions_exist: extensions!=0 - // \pre extensionName_exists: extensionName!=0 - int TestRequiredExtension(vtkOpenGLExtensionManager *extensions, - const char *extensionName); - - // Description: - // Attempt to load required and optional OpenGL extensions for the current - // context window. Variable LoadExtensionsSucceeded is set if all required - // extensions has been loaded. In addition, variable - // Supports_GL_ARB_texture_float is set if this extension has been loaded. - // \pre: window_exists: window!=0 - void LoadExtensions(vtkRenderWindow *window); - - // Description: - // Create GLSL OpenGL objects such fragment program Ids. - void CreateGLSLObjects(); - - // Description: - // Allows late binding textures to framebuffers, because ATI openGL requires - // the texture to initialized before - void BindFramebuffer(); - - // Description: - // Create OpenGL objects such as textures, buffers and fragment program Ids. - // It only registers Ids, there is no actual initialization of textures or - // fragment program. - // \pre extensions_loaded: this->LoadExtensionsSucceeded - // \post done: this->OpenGLObjectsCreated==1 - - void CreateOpenGLObjects(); - - // Description: - // Delete OpenGL objects. - // \post done: this->OpenGLObjectsCreated==0 - // \deprecatedSince{2013_12} Use ReleaseGraphicsResources(mitk::BaseRenderer* renderer) instead - // - DEPRECATED(void ReleaseGraphicsResources(vtkWindow *window)); - - // Description: - // Delete OpenGL objects. - // \post done: this->OpenGLObjectsCreated==0 - // - void ReleaseGraphicsResources(mitk::BaseRenderer* renderer); - - // Description: - // Allocate memory on the GPU for the framebuffers according to the size of - // the window or reallocate if the size has changed. Return true if - // allocation succeeded. - // \pre ren_exists: ren!=0 - // \pre opengl_objects_created: this->OpenGLObjectsCreated - // \post right_size: LastSize[]=window size. - int AllocateFrameBuffers(vtkRenderer *ren); - - // Description - // Load the scalar field (one or four component scalar field), cell or point - // based for a given subextent of the whole extent (can be the whole extent) - // as a 3D texture on the GPU. - // Extents are expressed in point if the cell flag is false or in cells of - // the cell flag is true. - // It returns true if it succeeded, false if there is not enough memory on - // the GPU. - // If succeeded, it updates the LoadedExtent, LoadedBounds, LoadedCellFlag - // and LoadedTime. It also succeed if the scalar field is already loaded - // (ie since last load, input has not changed and cell flag has not changed - // and requested texture extents are enclosed in the loaded extent). - // \pre input_exists: input!=0 - // \pre valid_point_extent: (this->CellFlag || - // (textureExtent[0]CellFlag || - // (textureExtent[0]<=textureExtent[1] && - // textureExtent[2]<=textureExtent[3] && - // textureExtent[4]<=textureExtent[5]))) - int LoadScalarField(vtkImageData *input, - vtkImageData *maskInput, - int textureExtent[6], - vtkVolume *volume); - - // Description: - // Allocate memory and load color table on the GPU or - // reload it if the transfer function changed. - // \pre vol_exists: vol!=0 - // \pre valid_numberOfScalarComponents: numberOfScalarComponents==1 || numberOfScalarComponents==4 - int UpdateColorTransferFunction(vtkVolume *vol, - int numberOfScalarComponents); - // Description: - // Allocate memory and load opacity table on the GPU or - // reload it if the transfer functions changed. - // \pre vol_exists: vol!=0 - // \pre valid_numberOfScalarComponents: numberOfScalarComponents==1 || numberOfScalarComponents==4 - int UpdateOpacityTransferFunction(vtkVolume *vol, - int numberOfScalarComponents, - unsigned int level); - - // Description: - // Prepare rendering in the offscreen framebuffer. - // \pre ren_exists: ren!=0 - // \pre vol_exists: vol!=0 - void SetupRender(vtkRenderer *ren, vtkVolume *vol); - - // Description: - // Clip the bounding box with all clipping planes - // and the near and far plane - void ClipBoundingBox(vtkRenderer *ren, - double worldBounds[6], - vtkVolume *vol); - - // Description: - // Render the bounding box. The flag indicates whether - // or not tcoords are rendered too. Return abort status (true==abort). - // \pre valid_currentBlock: currentBlock>=0 && currentBlock=0 - // \post valid_result: result>=x - int PowerOfTwoGreaterOrEqual(int x); - - // Description: - // Display the status of the current framebuffer on the standard output. - void CheckFrameBufferStatus(); - - // Description: - // Create a string from a buffer id. The result has to be free by the caller. - vtkStdString BufferToString(int buffer); - - // Description: - // Display the buffers assigned for drawing and reading operations. - void DisplayReadAndDrawBuffers(); - - // Description: - // Display all the attachments of the current framebuffer object. - void DisplayFrameBufferAttachments(); - - // Description: - // Display a given attachment for the current framebuffer object. - void DisplayFrameBufferAttachment(unsigned int uattachment); - - // Description: - // Concatenate the header string, projection type code and method to the - // final fragment code in this->FragmentCode. - // \pre valid_raycastMethod: raycastMethod>= vtkMitkOpenGLGPUVolumeRayCastMapperMethodMaximumIntensityProjection && raycastMethod<=vtkMitkOpenGLGPUVolumeRayCastMapperMethodMinIPFourDependent - void BuildProgram(int parallelProjection, - int raycastMethod, - int shadeMethod, - int componentMethod); - - // Description: - // Return the current OpenGL state about lighting. - void GetLightingStatus(); - - // Description: - // Check the compilation status of some fragment shader source. - void CheckCompilation(unsigned int fragmentShader); - - // Description: - // Check the linkage status of the fragment program. - int CheckLinkage(unsigned int programShader); - - // Description: - // Print all active uniform variables - void PrintUniformVariables(unsigned int programShader); - - // Description: - // Is the program shader valid in the current OpenGL state? - // Debugging purpose only. - void ValidateProgram(); - - // Description: - // Update the reduction factor of the render viewport (this->ReductionFactor) - // according to the time spent in seconds to render the previous frame - // (this->TimeToDraw) and a time in seconds allocated to render the next - // frame (allocatedTime). - // \pre valid_current_reduction_range: this->ReductionFactor>0.0 && this->ReductionFactor<=1.0 - // \pre positive_TimeToDraw: this->TimeToDraw>=0.0 - // \pre positive_time: allocatedTime>0 - // \post valid_new_reduction_range: this->ReductionFactor>0.0 && this->ReductionFactor<=1.0 - void ComputeReductionFactor(double allocatedTime); - - // Description: - // Render a subvolume. - // \pre this->ProgramShader!=0 and is linked. - void RenderWholeVolume(vtkRenderer *ren, - vtkVolume *vol); - - // Description: - // Render a subvolume. - // \pre this->ProgramShader!=0 and is linked. - void RenderRegions(vtkRenderer *ren, - vtkVolume *vol); - - // Return abort status (true==abort) - int RenderSubVolume(vtkRenderer *ren, - double bounds[6], - vtkVolume *vol); - - void LoadProjectionParameters(vtkRenderer *ren, - vtkVolume *vol); - - // Description: - // Compute and return the number of cropping regions - void ComputeNumberOfCroppingRegions(); - - void GetTextureFormat(vtkImageData *input, - unsigned int *internalFormat, - unsigned int *format, - unsigned int *type, - int *componentSize); - - bool TestLoadingScalar(unsigned int internalFormat, - unsigned int format, - unsigned int type, - int textureSize[3], - int componentSize); - - void SlabsFromDatasetToIndex(double slabsDataSet[6], - double slabsPoints[6]); - - void SlabsFromIndexToDataset(double slabsPoints[6], - double slabsDataSet[6]); - - const char *GetEnabledString(unsigned char value); - void GetOpenGLState(); - - void DebugDisplayBox(vtkPolyData *box); - - void UpdateNoiseTexture(); - - // Description: - // Compute how each axis of a cell is projected on the viewport in pixel. - // This requires to have information about the camera and about the volume. - // It set the value of IgnoreSampleDistancePerPixel to true in case of - // degenerated case (axes aligned with the view). - double ComputeMinimalSampleDistancePerPixel(vtkRenderer *renderer, - vtkVolume *volume); - - // Description: - // Return how much the dataset has to be reduced in each dimension to - // fit on the GPU. If the value is 1.0, there is no need to reduce the - // dataset. - // \pre the calling thread has a current OpenGL context. - // \pre mapper_supported: IsRenderSupported(renderer->GetRenderWindow(),0) - // The computation is based on hardware limits (3D texture indexable size) - // and MaxMemoryInBytes. - // \post valid_i_ratio: ratio[0]>0 && ratio[0]<=1.0 - // \post valid_j_ratio: ratio[1]>0 && ratio[1]<=1.0 - // \post valid_k_ratio: ratio[2]>0 && ratio[2]<=1.0 - virtual void GetReductionRatio(double ratio[3]); - - bool m_BindMax; - - int NumberOfCroppingRegions; - - // World coordinates of each corner of the dataset. - double BoundingBox[8][3]; - - // Used during the clipping process. - vtkPolyData *PolyDataBoundingBox; - vtkPlaneCollection *Planes; - vtkPlane *NearPlane; - - vtkClipConvexPolyData *Clip; - vtkMatrix4x4 *InvVolumeMatrix; - - vtkDensifyPolyData *Densify; - - int OpenGLObjectsCreated; - int NumberOfFrameBuffers; - - unsigned int FrameBufferObject; - unsigned int DepthRenderBufferObject; - - // 3D scalar texture +1D color+1D opacity+2D grabbed depth buffer - // +1 2D colorbuffer. - unsigned int TextureObjects[5]; - unsigned int FragmentMainShader; - unsigned int FragmentProjectionShader; - unsigned int FragmentTraceShader; - unsigned int FragmentCroppingShader; - unsigned int FragmentComponentShader; - unsigned int FragmentShadeShader; - unsigned int ProgramShader; - // used in MIP Mode (2 needed for ping-pong technique) - unsigned int MaxValueFrameBuffer; - unsigned int MaxValueFrameBuffer2; - int ReducedSize[2]; - - vtkPolyData *ClippedBoundingBox; - - int LastSize[2]; - - double ReductionFactor; - - // Supported extensions - // List of unsupported required extensions. Pimpl. - vtkUnsupportedRequiredExtensionsStringStream *UnsupportedRequiredExtensions; - int LoadExtensionsSucceeded; - - int Supports_GL_ARB_texture_float; - int SupportsPixelBufferObjects; - - vtkTimeStamp DataBufferTime; - - // Matrices used in internal computation. As a member variable, - // only one memory allocation is performed. - vtkMatrix4x4 *TempMatrix[3]; - - double TableRange[2]; - - // Final string to send to the GPU as the fragment program source code. -// char *FragmentCode; -// int FragmentCodeCapacity; - - - int ErrorLine; - int ErrorColumn; - char *ErrorString; - - // Store the last projection an raycast method in order to not rebuild - // the fragment code at every call. - int LastParallelProjection; - int LastRayCastMethod; - int LastCroppingMode; - int LastComponent; - int LastShade; - - vtkImageData *SmallInput; - vtkTimeStamp SmallInputBuildTime; - - // Description: - // Build the fragment shader program that scale and bias a texture - // for window/level purpose. - void BuildScaleBiasProgram(); - - unsigned int ScaleBiasProgramShader; // GLuint - int UFrameBufferTexture; // GLint - int UScale; // GLint - int UBias; // GLint - -#if 0 - vtkIdType LoadedExtent[6]; - double LoadedBounds[6]; - vtkTimeStamp LoadedScalarTime; - int LoadedCellFlag; // point data or cell data (or field data, not handled) ? -#endif - - unsigned int SavedFrameBuffer; // some offscreen mode use a framebuffer too. - - vtkTessellatedBoxSource *BoxSource; - - float *NoiseTexture; - int NoiseTextureSize; // size of one dimension. - unsigned int NoiseTextureId; // GLuint - - bool IgnoreSampleDistancePerPixel; - - vtkMapDataArrayTextureId *ScalarsTextures; // need a list for AMR mode. - vtkMapMaskTextureId *MaskTextures; // need a list for AMR mode. - - vtkRGBTable *RGBTable; - vtkRGBTable *Mask1RGBTable; - vtkRGBTable *Mask2RGBTable; - - vtkOpacityTables *OpacityTables; - - vtkKWScalarField *CurrentScalar; - vtkKWMask *CurrentMask; - - float ActualSampleDistance; - - double LastProgressEventTime; // initial value is 0.0. Expressed in seconds. - - bool PreserveOrientation; - -private: - vtkMitkOpenGLGPUVolumeRayCastMapper(const vtkMitkOpenGLGPUVolumeRayCastMapper&); // Not implemented. - void operator=(const vtkMitkOpenGLGPUVolumeRayCastMapper&); // Not implemented. -}; - -#endif - -#endif diff --git a/Modules/Ext/Rendering/vtkMitkOpenGLGPUVolumeRayCastMapperShaders.cpp b/Modules/Ext/Rendering/vtkMitkOpenGLGPUVolumeRayCastMapperShaders.cpp deleted file mode 100644 index 74887c425d..0000000000 --- a/Modules/Ext/Rendering/vtkMitkOpenGLGPUVolumeRayCastMapperShaders.cpp +++ /dev/null @@ -1,1814 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#include - -// Only with VTK 5.6 or above -#if ((VTK_MAJOR_VERSION > 5) || ((VTK_MAJOR_VERSION==5) && (VTK_MINOR_VERSION>=6) )) - /* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_CompositeCroppingFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_CompositeCroppingFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_CompositeCroppingFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_CompositeCroppingFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Implementation of some function used by the composite method when cropping\n" -"// is on.\n" -"\n" -"#version 110\n" -"\n" -"// color buffer as an input\n" -"uniform sampler2D frameBufferTexture;\n" -"// 2D Texture fragment coordinates [0,1] from fragment coordinates\n" -"// the frame buffer texture has the size of the plain buffer but\n" -"// we use a fraction of it. The texture coordinates is less than 1 if\n" -"// the reduction factor is less than 1.\n" -"vec2 fragTexCoord;\n" -"\n" -"vec4 initialColor()\n" -"{\n" -" return texture2D(frameBufferTexture,fragTexCoord);\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_CompositeFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_CompositeFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_CompositeFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_CompositeFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Fragment program part with ray cast and composite method.\n" -"\n" -"#version 110\n" -"\n" -"uniform sampler3D dataSetTexture;\n" -"uniform sampler1D opacityTexture;\n" -"\n" -"uniform vec3 lowBounds;\n" -"uniform vec3 highBounds;\n" -"\n" -"// Entry position (global scope)\n" -"vec3 pos;\n" -"// Incremental vector in texture space (global scope)\n" -"vec3 rayDir;\n" -"\n" -"float tMax;\n" -"\n" -"// from cropping vs no cropping\n" -"vec4 initialColor();\n" -"\n" -"// from 1 vs 4 component shader.\n" -"float scalarFromValue(vec4 value);\n" -"vec4 colorFromValue(vec4 value);\n" -"\n" -"// from noshade vs shade.\n" -"void initShade();\n" -"vec4 shade(vec4 value);\n" -"\n" -"void trace(void)\n" -"{\n" -" vec4 destColor=initialColor();\n" -" float remainOpacity=1.0-destColor.a;\n" -"\n" -" bool inside=true;\n" -" \n" -" vec4 color;\n" -" vec4 opacity;\n" -"\n" -" initShade();\n" -" \n" -" float t=0.0;\n" -" \n" -" // We NEED two nested while loops. It is trick to work around hardware\n" -" // limitation about the maximum number of loops.\n" -"\n" -" while(inside)\n" -" { \n" -" while(inside)\n" -" {\n" -" vec4 value=texture3D(dataSetTexture,pos);\n" -" float scalar=scalarFromValue(value);\n" -" // opacity is the sampled texture value in the 1D opacity texture at\n" -" // scalarValue\n" -" opacity=texture1D(opacityTexture,scalar);\n" -" if(opacity.a>0.0)\n" -" {\n" -" color=shade(value);\n" -" color=color*opacity.a;\n" -" destColor=destColor+color*remainOpacity;\n" -" remainOpacity=remainOpacity*(1.0-opacity.a);\n" -" }\n" -" pos=pos+rayDir;\n" -" t+=1.0;\n" -" inside=t=0.0039); // 1/255=0.0039\n" -" }\n" -" }\n" -" gl_FragColor = destColor;\n" -" gl_FragColor.a = 1.0-remainOpacity;\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_CompositeMaskFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_CompositeMaskFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_CompositeMaskFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_CompositeMaskFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Fragment program part with ray cast and composite method with masks.\n" -"\n" -"#version 110\n" -"\n" -"uniform sampler3D dataSetTexture;\n" -"uniform sampler3D maskTexture;\n" -"uniform sampler1D mask1ColorTexture;\n" -"uniform sampler1D mask2ColorTexture;\n" -"uniform sampler1D opacityTexture;\n" -"\n" -"uniform vec3 lowBounds;\n" -"uniform vec3 highBounds;\n" -"\n" -"uniform float maskBlendFactor;\n" -"\n" -"// Entry position (global scope)\n" -"vec3 pos;\n" -"// Incremental vector in texture space (global scope)\n" -"vec3 rayDir;\n" -"\n" -"float tMax;\n" -"\n" -"// from cropping vs no cropping\n" -"vec4 initialColor();\n" -"\n" -"// from 1 vs 4 component shader.\n" -"float scalarFromValue(vec4 value);\n" -"vec4 colorFromValue(vec4 value);\n" -"\n" -"// from noshade vs shade.\n" -"void initShade();\n" -"vec4 shade(vec4 value);\n" -"\n" -"void trace(void)\n" -"{\n" -" vec4 destColor=initialColor();\n" -" float remainOpacity=1.0-destColor.a;\n" -"\n" -" bool inside=true;\n" -" \n" -" vec4 maskValue;\n" -" vec4 color;\n" -" vec4 opacity;\n" -"\n" -" initShade();\n" -" \n" -" float t=0.0;\n" -" \n" -" // We NEED two nested while loops. It is trick to work around hardware\n" -" // limitation about the maximum number of loops.\n" -"\n" -" while(inside)\n" -" { \n" -" while(inside)\n" -" {\n" -" vec4 value=texture3D(dataSetTexture,pos);\n" -" float scalar=scalarFromValue(value);\n" -" opacity=texture1D(opacityTexture,scalar);\n" -" \n" -" if(maskBlendFactor==0.0)\n" -" {\n" -" color=shade(value);\n" -" }\n" -" else\n" -" {\n" -" // get the mask value at this same location\n" -" maskValue=texture3D(maskTexture,pos);\n" -" if(maskValue.a==0.0)\n" -" {\n" -" color=shade(value);\n" -" }\n" -" else\n" -" {\n" -" if(maskValue.a==1.0/255.0)\n" -" {\n" -" color=texture1D(mask1ColorTexture,scalar);\n" -" }\n" -" else\n" -" {\n" -" // maskValue.a == 2.0/255.0\n" -" color=texture1D(mask2ColorTexture,scalar);\n" -" }\n" -" color.a=1.0;\n" -" if(maskBlendFactor<1.0)\n" -" {\n" -" color=(1.0-maskBlendFactor)*shade(value)+maskBlendFactor*color;\n" -" }\n" -"// color.r = 1;\n" -"// color.g = 0;\n" -"// color.b = 0;\n" -"// color.a = 1;\n" -" }\n" -" }\n" -" \n" -" color=color*opacity.a;\n" -" destColor=destColor+color*remainOpacity;\n" -" remainOpacity=remainOpacity*(1.0-opacity.a);\n" -" \n" -" pos=pos+rayDir;\n" -" t+=1.0;\n" -" inside=t=0.0039); // 1/255=0.0039\n" -" }\n" -" }\n" -" gl_FragColor = destColor;\n" -" gl_FragColor.a = 1.0-remainOpacity;\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_CompositeNoCroppingFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_CompositeNoCroppingFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_CompositeNoCroppingFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_CompositeNoCroppingFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Implementation of some function used by the composite method when cropping\n" -"// is off.\n" -"\n" -"#version 110\n" -"\n" -"// Max intensity is the lowest value.\n" -"vec4 initialColor()\n" -"{\n" -" return vec4(0.0,0.0,0.0,0.0);\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_MinIPCroppingFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_MinIPCroppingFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_MinIPCroppingFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_MinIPCroppingFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Implementation of some functions used by the Minimum Intensity Projection\n" -"// (MinIP) method when cropping is on.\n" -"\n" -"#version 110\n" -"\n" -"// GLSL Spec 1.10 rev 59 30-April-2004 defines gl_FragData[] but implementation\n" -"// older than the spec only has it as an extension\n" -"// (nVidia Linux driver 100.14.13, OpenGL version 2.1.1,\n" -"// on Quadro FX 3500/PCI/SSE2)\n" -"#extension GL_ARB_draw_buffers : enable\n" -"\n" -"// max scalar buffer as an input\n" -"uniform sampler2D scalarBufferTexture;\n" -"// 2D Texture fragment coordinates [0,1] from fragment coordinates\n" -"// the scalar frame buffer texture has the size of the plain buffer but\n" -"// we use a fraction of it. The texture coordinates is less than 1 if\n" -"// the reduction factor is less than 1.\n" -"vec2 fragTexCoord;\n" -"\n" -"float initialMinValue()\n" -"{\n" -" return texture2D(scalarBufferTexture,fragTexCoord).r;\n" -"}\n" -"\n" -"void writeColorAndMinScalar(vec4 sample,\n" -" vec4 opacity,\n" -" float minValue)\n" -"{\n" -" // color framebuffer\n" -" gl_FragData[0].r =sample.r * opacity.a;\n" -" gl_FragData[0].g =sample.g * opacity.a;\n" -" gl_FragData[0].b =sample.b * opacity.a;\n" -" gl_FragData[0].a=opacity.a;\n" -" \n" -" // min scalar framebuffer\n" -" gl_FragData[1].r=minValue;\n" -" gl_FragData[1].g=0.0;\n" -" gl_FragData[1].b=0.0;\n" -" gl_FragData[1].a=0.0;\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_MinIPFourDependentCroppingFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_MinIPFourDependentCroppingFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_MinIPFourDependentCroppingFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_MinIPFourDependentCroppingFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Implementation of some functions used by the 4-component Minimum Intensity\n" -"// Projection (MinIP) method when cropping is on.\n" -"\n" -"#version 110\n" -"\n" -"// GLSL Spec 1.10 rev 59 30-April-2004 defines gl_FragData[] but implementation\n" -"// older than the spec only has it as an extension\n" -"// (nVidia Linux driver 100.14.13, OpenGL version 2.1.1,\n" -"// on Quadro FX 3500/PCI/SSE2)\n" -"#extension GL_ARB_draw_buffers : enable\n" -"\n" -"// max scalar buffer as an input\n" -"uniform sampler2D scalarBufferTexture;\n" -"\n" -"// color buffer as an input\n" -"uniform sampler2D frameBufferTexture;\n" -"\n" -"// 2D Texture fragment coordinates [0,1] from fragment coordinates\n" -"// the scalar frame buffer texture has the size of the plain buffer but\n" -"// we use a fraction of it. The texture coordinates is less than 1 if\n" -"// the reduction factor is less than 1.\n" -"vec2 fragTexCoord;\n" -"\n" -"float initialMinValue()\n" -"{\n" -" return texture2D(scalarBufferTexture,fragTexCoord).r;\n" -"}\n" -"\n" -"vec4 initialColor()\n" -"{\n" -" return texture2D(frameBufferTexture,fragTexCoord);\n" -"}\n" -"\n" -"void writeColorAndMinScalar(vec4 color,\n" -" vec4 opacity,\n" -" float minValue)\n" -"{\n" -" // color framebuffer\n" -" gl_FragData[0].r = color.r*opacity.a;\n" -" gl_FragData[0].g = color.g*opacity.a;\n" -" gl_FragData[0].b = color.b*opacity.a;\n" -" gl_FragData[0].a=opacity.a;\n" -" \n" -" // min scalar framebuffer\n" -" gl_FragData[1].r=minValue;\n" -" gl_FragData[1].g=0.0;\n" -" gl_FragData[1].b=0.0;\n" -" gl_FragData[1].a=0.0;\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_MinIPFourDependentFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_MinIPFourDependentFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_MinIPFourDependentFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_MinIPFourDependentFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Fragment program with ray cast and 4-dependent-component Minimum Intensity\n" -"// Projection (MinIP) method.\n" -"// Compilation: header part and the projection part are inserted first.\n" -"// pos is defined and initialized in header\n" -"// rayDir is defined in header and initialized in the projection part\n" -"\n" -"#version 110\n" -"\n" -"uniform sampler3D dataSetTexture;\n" -"uniform sampler1D opacityTexture;\n" -"\n" -"uniform vec3 lowBounds;\n" -"uniform vec3 highBounds;\n" -"\n" -"// Entry position (global scope)\n" -"vec3 pos;\n" -"// Incremental vector in texture space (global scope)\n" -"vec3 rayDir;\n" -"\n" -"float tMax;\n" -"\n" -"// Sub-functions, depending on cropping mode\n" -"float initialMinValue();\n" -"vec4 initialColor();\n" -"void writeColorAndMinScalar(vec4 color,\n" -" vec4 opacity,\n" -" float minValue);\n" -"\n" -"void trace(void)\n" -"{\n" -" // Max intensity is the lowest value.\n" -" float minValue=initialMinValue();\n" -" vec4 color=initialColor();\n" -" bool inside=true;\n" -" float t=0.0;\n" -" vec4 sample;\n" -" bool changed=false;\n" -" \n" -" // We NEED two nested while loops. It is a trick to work around hardware\n" -" // limitation about the maximum number of loops.\n" -" while(inside)\n" -" {\n" -" while(inside)\n" -" {\n" -" sample=texture3D(dataSetTexture,pos);\n" -" if(sample.w=lowBounds.x && pos.y>=lowBounds.y\n" -" && pos.z>=lowBounds.z && pos.x<=highBounds.x && pos.y<=highBounds.y\n" -" && pos.z<=highBounds.z;\n" -" }\n" -" }\n" -" \n" -" if(changed)\n" -" {\n" -" vec4 opacity=texture1D(opacityTexture,minValue);\n" -" writeColorAndMinScalar(color,opacity,minValue);\n" -" }\n" -" else\n" -" {\n" -" discard;\n" -" }\n" -"}\n" -"\n"; - - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_MinIPFourDependentNoCroppingFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_MinIPFourDependentNoCroppingFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_MinIPFourDependentNoCroppingFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_MinIPFourDependentNoCroppingFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Implementation of some functions used by the 4-component Minimum Intensity\n" -"// Projection (MinIP) method when cropping is off.\n" -"\n" -"#version 110\n" -"\n" -"float initialMinValue()\n" -"{\n" -" return 1.0;\n" -"}\n" -"\n" -"vec4 initialColor()\n" -"{\n" -" return vec4(0.0,0.0,0.0,0.0);\n" -"}\n" -"\n" -"void writeColorAndMinScalar(vec4 color,\n" -" vec4 opacity,\n" -" float minValue)\n" -"{\n" -" // minValue is not used\n" -" \n" -" // color framebuffer\n" -" gl_FragColor.r = color.r*opacity.a;\n" -" gl_FragColor.g = color.g*opacity.a;\n" -" gl_FragColor.b = color.b*opacity.a;\n" -" gl_FragColor.a=opacity.a;\n" -"}\n" -"\n"; - - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_MinIPFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_MinIPFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_MinIPFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_MinIPFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Fragment program with ray cast and Minimum Intensity Projection (MinIP)\n" -"// method.\n" -"// Compilation: header part and the projection part are inserted first.\n" -"// pos is defined and initialized in header\n" -"// rayDir is defined in header and initialized in the projection part\n" -"// initMinValue() and writeColorAndMinScalar are defined in some specific\n" -"// file depending on cropping flag being on or off.\n" -"\n" -"#version 110\n" -"\n" -"uniform sampler3D dataSetTexture;\n" -"uniform sampler1D colorTexture;\n" -"uniform sampler1D opacityTexture;\n" -"\n" -"uniform vec3 lowBounds;\n" -"uniform vec3 highBounds;\n" -"\n" -"// Entry position (global scope)\n" -"vec3 pos;\n" -"// Incremental vector in texture space (global scope)\n" -"vec3 rayDir;\n" -"\n" -"float tMax;\n" -"\n" -"// Sub-functions, depending on cropping mode\n" -"float initialMinValue();\n" -"void writeColorAndMinScalar(vec4 sample,\n" -" vec4 opacity,\n" -" float minValue);\n" -"\n" -"void trace(void)\n" -"{\n" -" // Max intensity is the lowest value.\n" -" float minValue=initialMinValue();\n" -" bool inside=true;\n" -" vec4 sample;\n" -" \n" -" float t=0.0;\n" -" // We NEED two nested while loops. It is trick to work around hardware\n" -" // limitation about the maximum number of loops.\n" -" while(inside)\n" -" {\n" -" while(inside)\n" -" {\n" -" sample=texture3D(dataSetTexture,pos);\n" -" minValue=min(minValue,sample.r);\n" -" pos=pos+rayDir;\n" -" t+=1.0;\n" -" inside=t=lowBounds.x && pos.y>=lowBounds.y\n" -" && pos.z>=lowBounds.z && pos.x<=highBounds.x && pos.y<=highBounds.y\n" -" && pos.z<=highBounds.z;\n" -" \n" -" \n" -" }\n" -" }\n" -"\n" -" sample=texture1D(colorTexture,minValue);\n" -" vec4 opacity=texture1D(opacityTexture,minValue);\n" -" \n" -" writeColorAndMinScalar(sample,opacity,minValue);\n" -"}\n" -"\n"; - - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_MinIPNoCroppingFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_MinIPNoCroppingFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_MinIPNoCroppingFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_MinIPNoCroppingFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Implementation of some functions used by the Minimum Intensity projection\n" -"// (MinIP) method when cropping is off.\n" -"\n" -"#version 110\n" -"\n" -"float initialMinValue()\n" -"{\n" -" return 1.0;\n" -"}\n" -"\n" -"void writeColorAndMinScalar(vec4 sample,\n" -" vec4 opacity,\n" -" float minValue)\n" -"{\n" -" // we don't need to write minValue to a buffer when there is no cropping.\n" -" // color framebuffer\n" -" gl_FragColor.r =sample.r * opacity.a;\n" -" gl_FragColor.g =sample.g * opacity.a;\n" -" gl_FragColor.b =sample.b * opacity.a;\n" -" gl_FragColor.a=opacity.a;\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_MIPCroppingFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_MIPCroppingFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_MIPCroppingFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_MIPCroppingFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Implementation of some functions used by the Maximum Intensity Projection\n" -"// (MIP) method when cropping is on.\n" -"\n" -"#version 110\n" -"\n" -"// GLSL Spec 1.10 rev 59 30-April-2004 defines gl_FragData[] but implementation\n" -"// older than the spec only has it as an extension\n" -"// (nVidia Linux driver 100.14.13, OpenGL version 2.1.1,\n" -"// on Quadro FX 3500/PCI/SSE2)\n" -"#extension GL_ARB_draw_buffers : enable\n" -"\n" -"// max scalar buffer as an input\n" -"uniform sampler2D scalarBufferTexture;\n" -"// 2D Texture fragment coordinates [0,1] from fragment coordinates\n" -"// the scalar frame buffer texture has the size of the plain buffer but\n" -"// we use a fraction of it. The texture coordinates is less than 1 if\n" -"// the reduction factor is less than 1.\n" -"vec2 fragTexCoord;\n" -"\n" -"float initialMaxValue()\n" -"{\n" -" return texture2D(scalarBufferTexture,fragTexCoord).r;\n" -"}\n" -"\n" -"void writeColorAndMaxScalar(vec4 sample,\n" -" vec4 opacity,\n" -" float maxValue)\n" -"{\n" -" // color framebuffer\n" -" gl_FragData[0].r =sample.r * opacity.a;\n" -" gl_FragData[0].g =sample.g * opacity.a;\n" -" gl_FragData[0].b =sample.b * opacity.a;\n" -" gl_FragData[0].a=opacity.a;\n" -" \n" -" // max scalar framebuffer\n" -" gl_FragData[1].r=maxValue;\n" -" gl_FragData[1].g=0.0;\n" -" gl_FragData[1].b=0.0;\n" -" gl_FragData[1].a=0.0;\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_MIPFourDependentCroppingFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_MIPFourDependentCroppingFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_MIPFourDependentCroppingFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_MIPFourDependentCroppingFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Implementation of some functions used by the 4-component Maximum Intensity\n" -"// Projection (MIP) method when cropping is on.\n" -"\n" -"#version 110\n" -"\n" -"// GLSL Spec 1.10 rev 59 30-April-2004 defines gl_FragData[] but implementation\n" -"// older than the spec only has it as an extension\n" -"// (nVidia Linux driver 100.14.13, OpenGL version 2.1.1,\n" -"// on Quadro FX 3500/PCI/SSE2)\n" -"#extension GL_ARB_draw_buffers : enable\n" -"\n" -"// max scalar buffer as an input\n" -"uniform sampler2D scalarBufferTexture;\n" -"\n" -"// color buffer as an input\n" -"uniform sampler2D frameBufferTexture;\n" -"\n" -"// 2D Texture fragment coordinates [0,1] from fragment coordinates\n" -"// the scalar frame buffer texture has the size of the plain buffer but\n" -"// we use a fraction of it. The texture coordinates is less than 1 if\n" -"// the reduction factor is less than 1.\n" -"vec2 fragTexCoord;\n" -"\n" -"float initialMaxValue()\n" -"{\n" -" return texture2D(scalarBufferTexture,fragTexCoord).r;\n" -"}\n" -"\n" -"vec4 initialColor()\n" -"{\n" -" return texture2D(frameBufferTexture,fragTexCoord);\n" -"}\n" -"\n" -"void writeColorAndMaxScalar(vec4 color,\n" -" vec4 opacity,\n" -" float maxValue)\n" -"{\n" -" // color framebuffer\n" -" gl_FragData[0].r = color.r*opacity.a;\n" -" gl_FragData[0].g = color.g*opacity.a;\n" -" gl_FragData[0].b = color.b*opacity.a;\n" -" gl_FragData[0].a=opacity.a;\n" -" \n" -" // max scalar framebuffer\n" -" gl_FragData[1].r=maxValue;\n" -" gl_FragData[1].g=0.0;\n" -" gl_FragData[1].b=0.0;\n" -" gl_FragData[1].a=0.0;\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_MIPFourDependentFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_MIPFourDependentFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_MIPFourDependentFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_MIPFourDependentFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Fragment program with ray cast and 4-dependent-component Maximum Intensity\n" -"// Projection (MIP) method.\n" -"// Compilation: header part and the projection part are inserted first.\n" -"// pos is defined and initialized in header\n" -"// rayDir is defined in header and initialized in the projection part\n" -"\n" -"#version 110\n" -"\n" -"uniform sampler3D dataSetTexture;\n" -"uniform sampler1D opacityTexture;\n" -"\n" -"uniform vec3 lowBounds;\n" -"uniform vec3 highBounds;\n" -"\n" -"// Entry position (global scope)\n" -"vec3 pos;\n" -"// Incremental vector in texture space (global scope)\n" -"vec3 rayDir;\n" -"\n" -"float tMax;\n" -"\n" -"// Sub-functions, depending on cropping mode\n" -"float initialMaxValue();\n" -"vec4 initialColor();\n" -"void writeColorAndMaxScalar(vec4 color,\n" -" vec4 opacity,\n" -" float maxValue);\n" -"\n" -"void trace(void)\n" -"{\n" -" // Max intensity is the lowest value.\n" -" float maxValue=initialMaxValue();\n" -" vec4 color=initialColor();\n" -" bool inside=true;\n" -" float t=0.0;\n" -" vec4 sample;\n" -" bool changed=false;\n" -" \n" -" // We NEED two nested while loops. It is a trick to work around hardware\n" -" // limitation about the maximum number of loops.\n" -" while(inside)\n" -" {\n" -" while(inside)\n" -" {\n" -" sample=texture3D(dataSetTexture,pos);\n" -" if(sample.w>maxValue)\n" -" {\n" -" changed=true;\n" -" maxValue=sample.w;\n" -" color=sample;\n" -" }\n" -" pos=pos+rayDir;\n" -" t+=1.0;\n" -" \n" -" // yes, t=lowBounds.x && pos.y>=lowBounds.y\n" -" && pos.z>=lowBounds.z && pos.x<=highBounds.x && pos.y<=highBounds.y\n" -" && pos.z<=highBounds.z;\n" -" }\n" -" }\n" -" \n" -" if(changed)\n" -" {\n" -" vec4 opacity=texture1D(opacityTexture,maxValue);\n" -" writeColorAndMaxScalar(color,opacity,maxValue);\n" -" }\n" -" else\n" -" {\n" -" discard;\n" -" }\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_MIPFourDependentNoCroppingFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_MIPFourDependentNoCroppingFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_MIPFourDependentNoCroppingFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_MIPFourDependentNoCroppingFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Implementation of some functions used by the 4-component Maximum Intensity\n" -"// Projection (MIP) method when cropping is off.\n" -"\n" -"#version 110\n" -"\n" -"float initialMaxValue()\n" -"{\n" -" return 0.0;\n" -"}\n" -"\n" -"vec4 initialColor()\n" -"{\n" -" return vec4(0.0,0.0,0.0,0.0);\n" -"}\n" -"\n" -"void writeColorAndMaxScalar(vec4 color,\n" -" vec4 opacity,\n" -" float maxValue)\n" -"{\n" -" // maxValue is not used\n" -" \n" -" // color framebuffer\n" -" gl_FragColor.r = color.r*opacity.a;\n" -" gl_FragColor.g = color.g*opacity.a;\n" -" gl_FragColor.b = color.b*opacity.a;\n" -" gl_FragColor.a=opacity.a;\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_MIPFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_MIPFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_MIPFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_MIPFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Fragment program with ray cast and Maximum Intensity Projection (MIP)\n" -"// method.\n" -"// Compilation: header part and the projection part are inserted first.\n" -"// pos is defined and initialized in header\n" -"// rayDir is defined in header and initialized in the projection part\n" -"// initMaxValue() and writeColorAndMaxScalar are defined in some specific\n" -"// file depending on cropping flag being on or off.\n" -"\n" -"#version 110\n" -"\n" -"uniform sampler3D dataSetTexture;\n" -"uniform sampler1D colorTexture;\n" -"uniform sampler1D opacityTexture;\n" -"\n" -"uniform vec3 lowBounds;\n" -"uniform vec3 highBounds;\n" -"\n" -"// Entry position (global scope)\n" -"vec3 pos;\n" -"// Incremental vector in texture space (global scope)\n" -"vec3 rayDir;\n" -"\n" -"float tMax;\n" -"\n" -"// Sub-functions, depending on cropping mode\n" -"float initialMaxValue();\n" -"void writeColorAndMaxScalar(vec4 sample,\n" -" vec4 opacity,\n" -" float maxValue);\n" -"\n" -"void trace(void)\n" -"{\n" -" // Max intensity is the lowest value.\n" -" float maxValue=initialMaxValue();\n" -" bool inside=true;\n" -" vec4 sample;\n" -" \n" -" float t=0.0;\n" -" // We NEED two nested while loops. It is trick to work around hardware\n" -" // limitation about the maximum number of loops.\n" -" while(inside)\n" -" {\n" -" while(inside)\n" -" {\n" -" sample=texture3D(dataSetTexture,pos);\n" -" maxValue=max(maxValue,sample.r);\n" -" pos=pos+rayDir;\n" -" t+=1.0;\n" -" \n" -" // yes, t=lowBounds.x && pos.y>=lowBounds.y\n" -" && pos.z>=lowBounds.z && pos.x<=highBounds.x && pos.y<=highBounds.y\n" -" && pos.z<=highBounds.z;\n" -" }\n" -" }\n" -"\n" -" sample=texture1D(colorTexture,maxValue);\n" -" vec4 opacity=texture1D(opacityTexture,maxValue);\n" -" \n" -" writeColorAndMaxScalar(sample,opacity,maxValue);\n" -"}\n" -"\n"; - - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_MIPNoCroppingFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_MIPNoCroppingFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_MIPNoCroppingFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_MIPNoCroppingFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Implementation of some functions used by the Maximum Intensity projection\n" -"// (MIP) method when cropping is off.\n" -"\n" -"#version 110\n" -"\n" -"float initialMaxValue()\n" -"{\n" -" return 0.0;\n" -"}\n" -"\n" -"void writeColorAndMaxScalar(vec4 sample,\n" -" vec4 opacity,\n" -" float maxValue)\n" -"{\n" -" // we don't need to write maxValue to a buffer when there is no cropping.\n" -" // color framebuffer\n" -" gl_FragColor.r =sample.r * opacity.a;\n" -" gl_FragColor.g =sample.g * opacity.a;\n" -" gl_FragColor.b =sample.b * opacity.a;\n" -" gl_FragColor.a=opacity.a;\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_OneComponentFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_OneComponentFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_OneComponentFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_OneComponentFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Fragment shader that implements scalarFromValue() and colorFromValue() in\n" -"// the case of a one-component dataset.\n" -"// The functions are used in composite mode.\n" -"\n" -"#version 110\n" -"\n" -"// \"value\" is a sample of the dataset.\n" -"// Think of \"value\" as an object.\n" -"\n" -"uniform sampler1D colorTexture;\n" -"\n" -"float scalarFromValue(vec4 value)\n" -"{\n" -" return value.x;\n" -"}\n" -"\n" -"vec4 colorFromValue(vec4 value)\n" -"{\n" -" return texture1D(colorTexture,value.x);\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_ParallelProjectionFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_ParallelProjectionFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_ParallelProjectionFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_ParallelProjectionFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Parallel projection.\n" -"\n" -"#version 110\n" -"\n" -"uniform vec3 parallelRayDirection;\n" -"\n" -"// Incremental vector in texture space (global scope)\n" -"vec3 rayDir;\n" -"\n" -"// Defined in the right projection method.\n" -"void incrementalRayDirection()\n" -"{\n" -" rayDir=parallelRayDirection;\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_PerspectiveProjectionFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_PerspectiveProjectionFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_PerspectiveProjectionFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_PerspectiveProjectionFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Perspective projection.\n" -"\n" -"#version 110\n" -"\n" -"// Entry position (global scope)\n" -"vec3 pos;\n" -"// Incremental vector in texture space (global scope)\n" -"vec3 rayDir;\n" -"\n" -"// Camera position in texture space\n" -"uniform vec3 cameraPosition;\n" -"// Sample distance in world space\n" -"uniform float sampleDistance;\n" -"// Matrix coefficients: diagonal (a11,a22,a33)\n" -"uniform vec3 matrix1;\n" -"// Matrix coefficients: others (2a12,2a23,2a13)\n" -"uniform vec3 matrix2;\n" -"\n" -"// Defined in the right projection method.\n" -"void incrementalRayDirection()\n" -"{\n" -" // Direction of the ray in texture space, not normalized.\n" -" rayDir=pos-cameraPosition;\n" -" \n" -" // x^2, y^2, z^2\n" -" vec3 normDir=rayDir*rayDir;\n" -" normDir.x=dot(normDir,matrix1);\n" -" \n" -" // xy,yz,zx\n" -" vec3 coefs=rayDir*rayDir.yxz;\n" -" coefs.x=dot(coefs,matrix2);\n" -"\n" -" // n^2\n" -" normDir.x=normDir.x+coefs.x;\n" -" \n" -" // 1/n\n" -" // normDir=1/sqrt(normDir)\n" -" normDir.x=inversesqrt(normDir.x);\n" -" \n" -" // Final scale factor for the ray direction in texture space\n" -" // normDir=normDir*sampleDistance\n" -" normDir.x=normDir.x*sampleDistance;\n" -" // Now, rayDir is the incremental direction in texture space\n" -" rayDir=rayDir*normDir.x;\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_ScaleBiasFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_ScaleBiasFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_ScaleBiasFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_ScaleBiasFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// This fragment shader scales and biases a framebuffer passed as a texture.\n" -"// Incoming color from the texture is pre-multiplied by alpha.\n" -"// It does not affect the alpha component.\n" -"// Passing the framebuffer as a texture allows the use of a reduction factor\n" -"// compared to the size of the final image.\n" -"\n" -"#version 110\n" -"\n" -"// Framebuffer to scale.\n" -"uniform sampler2D frameBufferTexture;\n" -"uniform float scale;\n" -"uniform float bias;\n" -"\n" -"void main()\n" -"{\n" -" vec4 color=texture2D(frameBufferTexture,gl_TexCoord[0].xy);\n" -" if(color.a==0.0)\n" -" {\n" -" discard;\n" -" }\n" -" // As incoming color is pre-multiplied by alpha, the bias has to be\n" -" // multiplied by alpha before adding it.\n" -" gl_FragColor.r=color.r*scale+bias*color.a;\n" -" gl_FragColor.g=color.g*scale+bias*color.a;\n" -" gl_FragColor.b=color.b*scale+bias*color.a;\n" -" gl_FragColor.a=color.a;\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_ShadeFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_ShadeFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_ShadeFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_ShadeFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"// Fragment shader that implements initShade() and shade() in the case of\n" -"// shading.\n" -"// The functions are used in composite mode.\n" -"\n" -"#version 110\n" -"\n" -"// \"value\" is a sample of the dataset.\n" -"// Think of \"value\" as an object.\n" -"\n" -"// from 1- vs 4-component shader.\n" -"vec4 colorFromValue(vec4 value);\n" -"\n" -"uniform sampler3D dataSetTexture; // need neighbors for gradient\n" -"\n" -"// Change-of-coordinate matrix from eye space to texture space\n" -"uniform mat3 eyeToTexture3;\n" -"uniform mat4 eyeToTexture4;\n" -"\n" -"// Tranpose of Change-of-coordinate matrix from texture space to eye space\n" -"uniform mat3 transposeTextureToEye;\n" -"\n" -"// Used to compute the gradient.\n" -"uniform vec3 cellStep;\n" -"uniform vec3 cellScale;\n" -"\n" -"\n" -"// Entry position (global scope), updated in the loop\n" -"vec3 pos;\n" -"// Incremental vector in texture space (global scope)\n" -"vec3 rayDir;\n" -"\n" -"\n" -"// local to the implementation, shared between initShade() and shade()\n" -"const vec3 minusOne=vec3(-1.0,-1.0,-1.0);\n" -"const vec4 clampMin=vec4(0.0,0.0,0.0,0.0);\n" -"const vec4 clampMax=vec4(1.0,1.0,1.0,1.0);\n" -"\n" -"vec3 xvec;\n" -"vec3 yvec;\n" -"vec3 zvec;\n" -"vec3 wReverseRayDir;\n" -"vec3 lightPos;\n" -"vec3 ldir;\n" -"vec3 h;\n" -"vec4 hPos; // homogeneous position\n" -"\n" -"// ----------------------------------------------------------------------------\n" -"void initShade()\n" -"{\n" -" xvec=vec3(cellStep.x,0.0,0.0); // 0.01\n" -" yvec=vec3(0.0,cellStep.y,0.0);\n" -" zvec=vec3(0.0,0.0,cellStep.z);\n" -" \n" -" // Reverse ray direction in eye space\n" -" wReverseRayDir=eyeToTexture3*rayDir;\n" -" wReverseRayDir=wReverseRayDir*minusOne;\n" -" wReverseRayDir=normalize(wReverseRayDir);\n" -" \n" -" // Directonal light: w==0\n" -" if(gl_LightSource[0].position.w==0.0)\n" -" {\n" -" ldir=gl_LightSource[0].position.xyz;\n" -" ldir=normalize(ldir);\n" -" h=normalize(ldir+wReverseRayDir);\n" -" }\n" -" else\n" -" {\n" -" lightPos=gl_LightSource[0].position.xyz/gl_LightSource[0].position.w;\n" -" hPos.w=1.0; // used later\n" -" }\n" -"}\n" -"\n" -"// ----------------------------------------------------------------------------\n" -"vec4 shade(vec4 value)\n" -"{\n" -" vec3 g1;\n" -" vec3 g2;\n" -" vec4 tmp;\n" -" float att;\n" -" float spot;\n" -" \n" -" g1.x=texture3D(dataSetTexture,pos+xvec).x;\n" -" g1.y=texture3D(dataSetTexture,pos+yvec).x;\n" -" g1.z=texture3D(dataSetTexture,pos+zvec).x;\n" -" g2.x=texture3D(dataSetTexture,pos-xvec).x;\n" -" g2.y=texture3D(dataSetTexture,pos-yvec).x;\n" -" g2.z=texture3D(dataSetTexture,pos-zvec).x;\n" -" // g1-g2 is the gradient in texture coordinates\n" -" // the result is the normalized gradient in eye coordinates.\n" -" \n" -" g2=g1-g2;\n" -" g2=g2*cellScale;\n" -" \n" -" float normalLength=length(g2);\n" -" if(normalLength>0.0)\n" -" {\n" -" g2=normalize(transposeTextureToEye*g2);\n" -" }\n" -" else\n" -" {\n" -" g2=vec3(0.0,0.0,0.0);\n" -" }\n" -" \n" -" vec4 color=colorFromValue(value);\n" -" \n" -" // initialize color to 0.0\n" -" vec4 finalColor=vec4(0.0,0.0,0.0,0.0); \n" -" \n" -" if(gl_LightSource[0].position.w!=0.0)\n" -" {\n" -" // We need to know the eye position only if light is positional\n" -" // ldir= vertex position in eye coordinates\n" -" hPos.xyz=pos;\n" -" tmp=eyeToTexture4*hPos;\n" -" ldir=tmp.xyz/tmp.w;\n" -" // ldir=light direction\n" -" ldir=lightPos-ldir;\n" -" float sqrDistance=dot(ldir,ldir);\n" -" ldir=normalize(ldir);\n" -" h=normalize(ldir+wReverseRayDir);\n" -" att=1.0/(gl_LightSource[0].constantAttenuation+gl_LightSource[0].linearAttenuation*sqrt(sqrDistance)+gl_LightSource[0].quadraticAttenuation*sqrDistance);\n" -" }\n" -" else\n" -" {\n" -" att=1.0;\n" -" }\n" -" \n" -" if(att>0.0)\n" -" {\n" -" if(gl_LightSource[0].spotCutoff==180.0)\n" -" {\n" -" spot=1.0;\n" -" }\n" -" else\n" -" {\n" -" float coef=-dot(ldir,gl_LightSource[0].spotDirection);\n" -" if(coef>=gl_LightSource[0].spotCosCutoff)\n" -" {\n" -" spot=pow(coef,gl_LightSource[0].spotExponent);\n" -" }\n" -" else\n" -" {\n" -" spot=0.0;\n" -" }\n" -" }\n" -" if(spot>0.0)\n" -" {\n" -" // LIT operation...\n" -" float nDotL=dot(g2,ldir);\n" -" float nDotH=dot(g2,h);\n" -" \n" -" // separate nDotL and nDotH for two-sided shading, otherwise we\n" -" // get black spots.\n" -" \n" -" if(nDotL<0.0) // two-sided shading\n" -" {\n" -" nDotL=-nDotL;\n" -" }\n" -" \n" -" if(nDotH<0.0) // two-sided shading\n" -" {\n" -" nDotH=-nDotH;\n" -" }\n" -" // ambient term for this light\n" -" finalColor+=gl_FrontLightProduct[0].ambient;\n" -" \n" -" // diffuse term for this light\n" -" if(nDotL>0.0)\n" -" {\n" -// WORKAROUND FIX: gl_FrontLightProduct[0].diffuse seems to be not transferred to ATI cards -//" finalColor+=(gl_FrontLightProduct[0].diffuse*nDotL)*color;\n" -// just using a white light now -" finalColor+=(0.8*nDotL)*color;\n" -" }\n" -" \n" -" // specular term for this light\n" -" float shininessFactor=pow(nDotH,gl_FrontMaterial.shininess);\n" -" finalColor+=gl_FrontLightProduct[0].specular*shininessFactor;\n" -" finalColor*=att*spot;\n" -" }\n" -" }\n" -" \n" -" // scene ambient term\n" -// WORKAROUND FIX: gl_FrontLightModelProduct.sceneColor seems to be not transferred to ATI cards -//" finalColor+=gl_FrontLightModelProduct.sceneColor*color;\n" -// just using a dim ambient light -" finalColor+=0.3*color;\n" -" \n" -" // clamp. otherwise we get black spots\n" -" finalColor=clamp(finalColor,clampMin,clampMax);\n" -" \n" -" return finalColor;\n" -"}\n" -"\n"; - - - - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_NoShadeFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_NoShadeFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_NoShadeFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_NoShadeFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Fragment shader that implements initShade() and shade() in the case of no\n" -"// shading.\n" -"// The functions are used in composite mode.\n" -"\n" -"#version 110\n" -"\n" -"// \"value\" is a sample of the dataset.\n" -"// Think of \"value\" as an object.\n" -"\n" -"// from 1- vs 4-component shader.\n" -"vec4 colorFromValue(vec4 value);\n" -"\n" -"// ----------------------------------------------------------------------------\n" -"void initShade()\n" -"{\n" -" // empty, nothing to do.\n" -"}\n" -"\n" -"// ----------------------------------------------------------------------------\n" -"vec4 shade(vec4 value)\n" -"{\n" -" return colorFromValue(value);\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_HeaderFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_HeaderFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_HeaderFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_HeaderFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"#version 110\n" -"\n" -"// Depth map of the polygonal geometry\n" -"uniform sampler2D depthTexture;\n" -"\n" -"// 2D noise texture to jitter the starting point of the ray in order to\n" -"// remove patterns when the opacity transfer function make the data on the\n" -"// border of the dataset to be visible.\n" -"uniform sampler2D noiseTexture;\n" -"\n" -"uniform vec2 windowLowerLeftCorner;\n" -"uniform vec2 invOriginalWindowSize;\n" -"uniform vec2 invWindowSize;\n" -"\n" -"// Change-of-coordinate matrix from eye space to texture space\n" -"uniform mat4 textureToEye;\n" -"\n" -"// Entry position (global scope)\n" -"vec3 pos;\n" -"// Incremental vector in texture space (global scope)\n" -"vec3 rayDir;\n" -"\n" -"// Abscissa along the ray of the point on the depth map\n" -"// tracing stops when t>=tMax\n" -"float tMax;\n" -"\n" -"// 2D Texture fragment coordinates [0,1] from fragment coordinates\n" -"// the frame buffer texture has the size of the plain buffer but\n" -"// we use a fraction of it. The texture coordinates is less than 1 if\n" -"// the reduction factor is less than 1.\n" -"vec2 fragTexCoord;\n" -"\n" -"// Defined in the right projection method.\n" -"// May use pos in global scope as input.\n" -"// Use rayDir in global scope as output.\n" -"void incrementalRayDirection();\n" -"void trace();\n" -"\n" -"void main()\n" -"{\n" -"\n" -" // device coordinates are between -1 and 1\n" -" // we need texture coordinates between 0 and 1\n" -" // the depth buffer has the original size buffer.\n" -" fragTexCoord=(gl_FragCoord.xy-windowLowerLeftCorner)*invWindowSize;\n" -" vec4 depth=texture2D(depthTexture,fragTexCoord);\n" -" if(gl_FragCoord.z>=depth.x) // depth test\n" -" {\n" -" discard;\n" -" }\n" -" \n" -" // color buffer or max scalar buffer have a reduced size.\n" -" fragTexCoord=(gl_FragCoord.xy-windowLowerLeftCorner)*invOriginalWindowSize;\n" -" // Abscissa of the point on the depth buffer along the ray.\n" -" // point in texture coordinates\n" -" vec4 maxPoint;\n" -" \n" -" // from window coordinates to normalized device coordinates\n" -" maxPoint.x=(gl_FragCoord.x-windowLowerLeftCorner.x)*2.0*invWindowSize.x-1.0;\n" -" maxPoint.y=(gl_FragCoord.y-windowLowerLeftCorner.y)*2.0*invWindowSize.y-1.0;\n" -" maxPoint.z=(2.0*depth.x-(gl_DepthRange.near+gl_DepthRange.far))/gl_DepthRange.diff;\n" -" maxPoint.w=1.0;\n" -" \n" -" // from normalized device coordinates to eye coordinates\n" -" maxPoint=gl_ProjectionMatrixInverse*maxPoint;\n" -" \n" -" // from eye coordinates to texture coordinates\n" -" maxPoint=textureToEye*maxPoint;\n" -" // homogeneous to cartesian coordinates\n" -" maxPoint/=maxPoint.w;\n" -" \n" -" // Entry position. divide by q.\n" -" // pos=gl_TexCoord[0].xyz/gl_TexCoord[0].w;\n" -" \n" -" pos.x=gl_TexCoord[0].x/gl_TexCoord[0].w;\n" -" pos.y=gl_TexCoord[0].y/gl_TexCoord[0].w;\n" -" pos.z=gl_TexCoord[0].z/gl_TexCoord[0].w;\n" -" \n" -" // Incremental vector in texture space. Computation depends on the\n" -" // type of projection (parallel or perspective)\n" -" incrementalRayDirection();\n" -" \n" -" vec4 noiseValue=texture2D(noiseTexture,pos.xy*100.0); // with repeat/tiling mode on the noise texture.\n" -" \n" -" pos+=(noiseValue.x)*rayDir;\n" -"\n" -" tMax=length(maxPoint.xyz-pos.xyz) /length(rayDir);\n" -"\n" -"\n" -" // Tracing method. Set the final fragment color.\n" -" trace();\n" -"}\n" -"\n"; - -/* DO NOT EDIT. - * Generated by ..\bin\Release\vtkEncodeString.exe - * - * Define the vtkMitkGPUVolumeRayCastMapper_FourComponentsFS string. - * - * Generated from file: V:/windows/source/VTK560/VolumeRendering/vtkMitkGPUVolumeRayCastMapper_FourComponentsFS.glsl - */ -const char *vtkMitkGPUVolumeRayCastMapper_FourComponentsFS = -"/*=========================================================================\n" -"\n" -" Program: Visualization Toolkit\n" -" Module: $RCSfile: vtkMitkGPUVolumeRayCastMapper_FourComponentsFS.glsl,v $\n" -"\n" -" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n" -" All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n" -"\n" -" This software is distributed WITHOUT ANY WARRANTY; without even\n" -" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" -" PURPOSE. See the above copyright notice for more information.\n" -"\n" -"=========================================================================*/\n" -"\n" -"// Fragment shader that implements scalarFromValue() and colorFromValue() in\n" -"// the case of a one-component dataset.\n" -"// The functions are used in composite mode.\n" -"\n" -"#version 110\n" -"\n" -"// \"value\" is a sample of the dataset.\n" -"// Think of \"value\" as an object.\n" -"\n" -"float scalarFromValue(vec4 value)\n" -"{\n" -" return value.w;\n" -"}\n" -"\n" -"vec4 colorFromValue(vec4 value)\n" -"{\n" -" return vec4(value.xyz,1.0);\n" -"}\n" -"\n"; - -#endif diff --git a/Modules/Ext/Resources/Interactions/AffineDeformationConfig.xml b/Modules/Ext/Resources/Interactions/AffineDeformationConfig.xml deleted file mode 100644 index 207435e14d..0000000000 --- a/Modules/Ext/Resources/Interactions/AffineDeformationConfig.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Modules/Ext/Resources/Interactions/AffineInteraction3D.xml b/Modules/Ext/Resources/Interactions/AffineInteraction3D.xml deleted file mode 100644 index 36d4e14d15..0000000000 --- a/Modules/Ext/Resources/Interactions/AffineInteraction3D.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Modules/Ext/Resources/Interactions/AffineRotationConfig.xml b/Modules/Ext/Resources/Interactions/AffineRotationConfig.xml deleted file mode 100644 index fb9c6fe6d1..0000000000 --- a/Modules/Ext/Resources/Interactions/AffineRotationConfig.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Modules/Ext/Resources/Interactions/AffineTranslationConfig.xml b/Modules/Ext/Resources/Interactions/AffineTranslationConfig.xml deleted file mode 100644 index 4bbbe5c8be..0000000000 --- a/Modules/Ext/Resources/Interactions/AffineTranslationConfig.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Modules/Ext/Testing/CMakeLists.txt b/Modules/Ext/Testing/CMakeLists.txt deleted file mode 100644 index 153cd81e2e..0000000000 --- a/Modules/Ext/Testing/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -MITK_CREATE_MODULE_TESTS() diff --git a/Modules/Ext/Testing/files.cmake b/Modules/Ext/Testing/files.cmake deleted file mode 100644 index fab0398af5..0000000000 --- a/Modules/Ext/Testing/files.cmake +++ /dev/null @@ -1,22 +0,0 @@ -set(MODULE_TESTS - mitkDataNodeExtTest.cpp - mitkExternalToolsTest.cpp - # mitkPipelineSmartPointerCorrectnessTest.cpp - mitkPlaneFitTest.cpp - mitkPointLocatorTest.cpp -) -set(MODULE_IMAGE_TESTS - mitkCylindricToCartesianFilterTest.cpp #only runs on images -) - -set(MODULE_TESTIMAGES - US4DCyl.nrrd - Pic3D.nrrd - Pic2DplusT.nrrd - BallBinary30x30x30.nrrd - Png2D-bw.png -) -set(MODULE_TESTSURFACES - binary.stl - ball.stl -) diff --git a/Modules/Ext/Testing/mitkCylindricToCartesianFilterTest.cpp b/Modules/Ext/Testing/mitkCylindricToCartesianFilterTest.cpp deleted file mode 100644 index 989e7c7fca..0000000000 --- a/Modules/Ext/Testing/mitkCylindricToCartesianFilterTest.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "mitkImage.h" -#include "mitkDataNodeFactory.h" -#include "mitkCylindricToCartesianFilter.h" -#include "mitkImageSliceSelector.h" - -#include -int mitkCylindricToCartesianFilterTest(int argc, char* argv[]) -{ - std::cout << "Loading file: "; - if(argc==0) - { - std::cout<<"no file specified [FAILED]"<SetFileName( argv[1] ); - factory->Update(); - - if(factory->GetNumberOfOutputs()<1) - { - std::cout<<"file could not be loaded [FAILED]"<GetOutput( 0 ); - image = dynamic_cast(node->GetData()); - if(image.IsNull()) - { - std::cout<<"file not an image - test will not be applied [PASSED]"<SetInput(image); - cyl2cart->SetTargetXSize( 64 ); - - //Take a slice - mitk::ImageSliceSelector::Pointer slice = mitk::ImageSliceSelector::New(); - slice->SetInput(cyl2cart->GetOutput()); - slice->SetSliceNr(1); - slice->Update(); - - std::cout << "Testing IsInitialized(): "; - if(slice->GetOutput()->IsInitialized()==false) - { - std::cout<<"[FAILED]"<GetOutput()->IsSliceSet(0)==false) - { - std::cout<<"[FAILED]"<GetDimension(3) > 1) - { - int time=image->GetDimension(3)-1; - - std::cout << "Testing 3D+t: Setting time to " << time << ": "; - slice->SetTimeNr(time); - if(slice->GetTimeNr()!=time) - { - std::cout<<"[FAILED]"<Update(); - if(slice->GetOutput()->IsInitialized()==false) - { - std::cout<<"[FAILED]"<GetOutput()->IsSliceSet(0)==false) - { - std::cout<<"[FAILED]"<IsSliceSet(0, time)==false) - { - std::cout<<"[FAILED]"< -#include "mitkVtkPropRenderer.h" - -#include "mitkTestingMacros.h" -#include "mitkGlobalInteraction.h" - -#include - -//Basedata Test -#include -#include -#include -#include -#include - -//Mapper Test -#include -#include -#include -#include - -#include - -//Interactors -#include -#include -#include -#include -#include - -//Propertylist Test -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -/** - * Extended test for mitk::DataNode. A number of tests from the core test - * mitkDataNodeTest are assumed to pass! - */ -class mitkDataNodeExtTestClass { public: - -static void TestDataSetting(mitk::DataNode::Pointer dataNode) -{ - - mitk::BaseData::Pointer baseData; - - //NULL pointer Test - dataNode->SetData(baseData); - MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a NULL pointer was set correctly" ) - - baseData = mitk::ItkBaseDataAdapter::New(); - dataNode->SetData(baseData); - MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a ItkBaseDataAdapter object was set correctly" ) - - baseData = mitk::Mesh::New(); - dataNode->SetData(baseData); - MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a Mesh object was set correctly" ) - - baseData = mitk::SeedsImage::New(); - dataNode->SetData(baseData); - MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a SeedsImage object was set correctly" ) - - baseData = mitk::BoundingObject::New(); - dataNode->SetData(baseData); - MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a BoundingObject object was set correctly" ) - - baseData = mitk::UnstructuredGrid::New(); - dataNode->SetData(baseData); - MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a UnstructuredGrid object was set correctly" ) -} - -static void TestMapperSetting(mitk::DataNode::Pointer dataNode) -{ - //tests the SetMapper() method - //in dataNode is a mapper vector which can be accessed by index - //in this test method we use only slot 0 (filled with null) and slot 1 - //so we also test the destructor of the mapper classes - mitk::Mapper::Pointer mapper; - - dataNode->SetMapper(0,mapper); - MITK_TEST_CONDITION( mapper == dataNode->GetMapper(0), "Testing if a NULL pointer was set correctly" ) - - mapper = mitk::LineMapper2D::New(); - dataNode->SetMapper(1,mapper); - MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a LineMapper2D was set correctly" ) - MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" ) - - //linker error - //mapper = mitk::LineVtkMapper3D::New(); - //dataNode->SetMapper(1,mapper); - //MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a LineVtkMapper3D was set correctly" ) - //MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" ) -} - -static void TestInteractorSetting(mitk::DataNode::Pointer dataNode) -{ - - //this method tests the SetInteractor() and GetInteractor methods - //the Interactor base class calls the DataNode->SetInteractor method - - mitk::Interactor::Pointer interactor; - - MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a NULL pointer was set correctly (Interactor)" ) - - interactor = mitk::ConnectPointsInteractor::New("AffineInteractions click to select", dataNode); - MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a ConnectPointsInteractor was set correctly" ) - - interactor = mitk::PointInteractor::New("AffineInteractions click to select", dataNode); - MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a PointInteractor was set correctly" ) - - interactor = mitk::PointSelectorInteractor::New("AffineInteractions click to select", dataNode); - MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a PointSelectorInteractor was set correctly" ) - - interactor = mitk::SeedsInteractor::New("AffineInteractions click to select", dataNode); - MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a SeedsInteractor was set correctly" ) - - interactor = mitk::DisplayPointSetInteractor::New("AffineInteractions click to select", dataNode); - MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a DisplayPointSetInteractor was set correctly" ) -} - -}; - -int mitkDataNodeExtTest(int /* argc */, char* /*argv*/[]) -{ - // always start with this! - MITK_TEST_BEGIN("DataNodeExt") - - // Global interaction must(!) be initialized - mitk::GlobalInteraction::GetInstance()->Initialize("global"); - - // let's create an object of our class - mitk::DataNode::Pointer myDataNode = mitk::DataNode::New(); - - // first test: did this work? - // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since - // it makes no sense to continue without an object. - MITK_TEST_CONDITION_REQUIRED(myDataNode.IsNotNull(),"Testing instantiation") - - //test setData() Method - mitkDataNodeExtTestClass::TestDataSetting(myDataNode); - mitkDataNodeExtTestClass::TestMapperSetting(myDataNode); - - //note, that no data is set to the dataNode - mitkDataNodeExtTestClass::TestInteractorSetting(myDataNode); - - // write your own tests here and use the macros from mitkTestingMacros.h !!! - // do not write to std::cout and do not return from this function yourself! - - // always end with this! - MITK_TEST_END() -} diff --git a/Modules/Ext/Testing/mitkExternalToolsTest.cpp b/Modules/Ext/Testing/mitkExternalToolsTest.cpp deleted file mode 100644 index 995c65e0d8..0000000000 --- a/Modules/Ext/Testing/mitkExternalToolsTest.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include -#include - -#include // for system() call - -#include // for chdir et al. - -int mitkExternalToolsTest(int argc, char* argv[]) -{ - return EXIT_SUCCESS; // we'll go back to a CMake solution... - - - std::cout << "Got " << argc << " parameters" << std::endl; - if ( argc == 5 ) - { - // "parse" commandline - // quote spaces in commandline parameters (all paths/files) - //std::string cmakeBinary = itksys::SystemTools::EscapeChars( argv[1], " " ); - std::string cmakeBinary = argv[1]; - std::string cmakeGenerator = argv[2]; - std::string mitkBinaryDirectory = argv[3]; - std::string sourceDirectory = argv[4]; - - // try to configure MITK external project - std::cout << "Calling CMake as '" << cmakeBinary << "'" << std::endl; - std::cout << "Calling CMake for generator '" << cmakeGenerator << "'" << std::endl; - std::cout << "MITK was compiled in '" << mitkBinaryDirectory << "'" << std::endl; - std::cout << "Configuring project in '" << sourceDirectory << "'" << std::endl; - - if( itksys::SystemTools::ChangeDirectory(mitkBinaryDirectory.c_str()) != 0 ) - { - std::cerr << "Couldn't change to MITK build dir. See output above." << std::endl; - return EXIT_FAILURE; - } - - std::string oneCommandlineQuote("\""); - - std::string commandline( oneCommandlineQuote ); - commandline += cmakeBinary; - commandline += oneCommandlineQuote; - - commandline += " -G "; - commandline += oneCommandlineQuote; - commandline += cmakeGenerator; - commandline += oneCommandlineQuote; - - commandline += " -DMITK_DIR:PATH="; - - commandline += oneCommandlineQuote; - commandline += mitkBinaryDirectory; - commandline += oneCommandlineQuote; - commandline += " "; - commandline += oneCommandlineQuote; - commandline += sourceDirectory; - commandline += oneCommandlineQuote; - - std::cout << "Calling system() with '" - << commandline - << "'" - << std::endl; - - int returnCode = system(commandline.c_str()); - - std::cout << "system() returned " << returnCode << std::endl; - - if (returnCode != 0) - { - std::cerr << "Configure FAILED. See output above." << std::endl; - return EXIT_FAILURE; - } - - // try to build MITK external project - -#ifdef WIN32 -#else - commandline = "make"; - // commented out because mbits configures with Qt4. Have to check this monday. - //returnCode = system(commandline.c_str()); - - if (returnCode != 0) // make should return 0 - { - std::cout << "make returned " << returnCode << std::endl; - std::cerr << "Building the project FAILED. See output above." << std::endl; - return EXIT_FAILURE; - } - -#endif - // - // TODO extend test here to support windows... - // - return returnCode; - } - else - { - std::cout << "Invoke this test with three parameters:" << std::endl; - std::cout << " 1. CMake binary including necessary path" << std::endl; - std::cout << " 2. CMake generator name" << std::endl; - std::cout << " 3. MITK binary path (top-level directory)" << std::endl; - std::cout << " 4. Source directory containing CMakeLists.txt" << std::endl; - return EXIT_FAILURE; - } -} - diff --git a/Modules/Ext/Testing/mitkImageStatisticsCalculatorTest.cpp b/Modules/Ext/Testing/mitkImageStatisticsCalculatorTest.cpp deleted file mode 100644 index c9e4202fa9..0000000000 --- a/Modules/Ext/Testing/mitkImageStatisticsCalculatorTest.cpp +++ /dev/null @@ -1,470 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkStandardFileLocations.h" -#include "mitkDicomSeriesReader.h" -#include "mitkTestingMacros.h" -#include "mitkImageStatisticsCalculator.h" -#include "mitkPlanarPolygon.h" - -#include "mitkDicomSeriesReader.h" -#include - -#include "vtkStreamingDemandDrivenPipeline.h" - - -//#include - -/** - * \brief Test class for mitkImageStatisticsCalculator - * - * This test covers: - * - instantiation of an ImageStatisticsCalculator class - * - correctness of statistics when using PlanarFigures for masking - */ -class mitkImageStatisticsCalculatorTestClass -{ - -public: - - struct testCase - { - int id; - mitk::PlanarFigure::Pointer figure; - double mean; - double sd; - }; - - -// calculate statistics for the given image and planarpolygon -static const mitk::ImageStatisticsCalculator::Statistics TestStatistics( mitk::Image::Pointer image, mitk::PlanarFigure::Pointer polygon ) -{ - mitk::ImageStatisticsCalculator::Pointer statisticsCalculator = mitk::ImageStatisticsCalculator::New(); - statisticsCalculator->SetImage( image ); - statisticsCalculator->SetMaskingModeToPlanarFigure(); - statisticsCalculator->SetPlanarFigure( polygon ); - - statisticsCalculator->ComputeStatistics(); - - return statisticsCalculator->GetStatistics(); -} - - -// returns a vector of defined test-cases -static std::vector InitializeTestCases( mitk::Geometry2D::Pointer geom ) -{ - std::vector testCases; - - { - /***************************** - * one whole white pixel - * -> mean of 255 expected - ******************************/ - mitk::PlanarPolygon::Pointer figure1 = mitk::PlanarPolygon::New(); - figure1->SetGeometry2D( geom ); - mitk::Point2D pnt1; pnt1[0] = 10.5 ; pnt1[1] = 3.5; - figure1->PlaceFigure( pnt1 ); - - mitk::Point2D pnt2; pnt2[0] = 9.5; pnt2[1] = 3.5; - figure1->SetControlPoint( 1, pnt2, true ); - mitk::Point2D pnt3; pnt3[0] = 9.5; pnt3[1] = 4.5; - figure1->SetControlPoint( 2, pnt3, true ); - mitk::Point2D pnt4; pnt4[0] = 10.5; pnt4[1] = 4.5; - figure1->SetControlPoint( 3, pnt4, true ); - figure1->GetPolyLine(0); - - testCase test; - test.id = testCases.size(); - test.figure = figure1; - test.mean = 255.0; - test.sd = 0.0; - - testCases.push_back( test ); - } - - { - /***************************** - * half pixel in x-direction (white) - * -> mean of 255 expected - ******************************/ - mitk::PlanarPolygon::Pointer figure1 = mitk::PlanarPolygon::New(); - figure1->SetGeometry2D( geom ); - mitk::Point2D pnt1; pnt1[0] = 10.0 ; pnt1[1] = 3.5; - figure1->PlaceFigure( pnt1 ); - - mitk::Point2D pnt2; pnt2[0] = 9.5; pnt2[1] = 3.5; - figure1->SetControlPoint( 1, pnt2, true ); - mitk::Point2D pnt3; pnt3[0] = 9.5; pnt3[1] = 4.5; - figure1->SetControlPoint( 2, pnt3, true ); - mitk::Point2D pnt4; pnt4[0] = 10.0; pnt4[1] = 4.5; - figure1->SetControlPoint( 3, pnt4, true ); - figure1->GetPolyLine(0); - - testCase test; - test.id = testCases.size(); - test.figure = figure1; - test.mean = 255.0; - test.sd = 0.0; - - testCases.push_back( test ); - } - - { - /***************************** - * half pixel in diagonal-direction (white) - * -> mean of 255 expected - ******************************/ - mitk::PlanarPolygon::Pointer figure1 = mitk::PlanarPolygon::New(); - figure1->SetGeometry2D( geom ); - mitk::Point2D pnt1; pnt1[0] = 10.5 ; pnt1[1] = 3.5; - figure1->PlaceFigure( pnt1 ); - - mitk::Point2D pnt2; pnt2[0] = 9.5; pnt2[1] = 3.5; - figure1->SetControlPoint( 1, pnt2, true ); - mitk::Point2D pnt3; pnt3[0] = 9.5; pnt3[1] = 4.5; - figure1->SetControlPoint( 2, pnt3, true ); - figure1->GetPolyLine(0); - - testCase test; - test.id = testCases.size(); - test.figure = figure1; - test.mean = 255.0; - test.sd = 0.0; - - testCases.push_back( test ); - } - - - { - /***************************** - * one pixel (white) + 2 half pixels (white) + 1 half pixel (black) - * -> mean of 191.25 expected - ******************************/ - mitk::PlanarPolygon::Pointer figure1 = mitk::PlanarPolygon::New(); - figure1->SetGeometry2D( geom ); - mitk::Point2D pnt1; pnt1[0] = 1.1; pnt1[1] = 1.1; - figure1->PlaceFigure( pnt1 ); - - mitk::Point2D pnt2; pnt2[0] = 2.0; pnt2[1] = 2.0; - figure1->SetControlPoint( 1, pnt2, true ); - mitk::Point2D pnt3; pnt3[0] = 3.0; pnt3[1] = 1.0; - figure1->SetControlPoint( 2, pnt3, true ); - mitk::Point2D pnt4; pnt4[0] = 2.0; pnt4[1] = 0.0; - figure1->SetControlPoint( 3, pnt4, true ); - figure1->GetPolyLine(0); - - testCase test; - test.id = testCases.size(); - test.figure = figure1; - test.mean = 191.25; - test.sd = 127.5; - - testCases.push_back( test ); - } - - - { - /***************************** - * whole pixel (white) + half pixel (gray) in x-direction - * -> mean of 191.5 expected - ******************************/ - mitk::PlanarPolygon::Pointer figure1 = mitk::PlanarPolygon::New(); - figure1->SetGeometry2D( geom ); - mitk::Point2D pnt1; pnt1[0] = 11.0; pnt1[1] = 3.5; - figure1->PlaceFigure( pnt1 ); - - mitk::Point2D pnt2; pnt2[0] = 9.5; pnt2[1] = 3.5; - figure1->SetControlPoint( 1, pnt2, true ); - mitk::Point2D pnt3; pnt3[0] = 9.5; pnt3[1] = 4.5; - figure1->SetControlPoint( 2, pnt3, true ); - mitk::Point2D pnt4; pnt4[0] = 11.0; pnt4[1] = 4.5; - figure1->SetControlPoint( 3, pnt4, true ); - figure1->GetPolyLine(0); - - testCase test; - test.id = testCases.size(); - test.figure = figure1; - test.mean = 191.50; - test.sd = 89.80; - - testCases.push_back( test ); - } - - { - /***************************** - * quarter pixel (black) + whole pixel (white) + half pixel (gray) in x-direction - * -> mean of 191.5 expected - ******************************/ - mitk::PlanarPolygon::Pointer figure1 = mitk::PlanarPolygon::New(); - figure1->SetGeometry2D( geom ); - mitk::Point2D pnt1; pnt1[0] = 11.0; pnt1[1] = 3.5; - figure1->PlaceFigure( pnt1 ); - - mitk::Point2D pnt2; pnt2[0] = 9.25; pnt2[1] = 3.5; - figure1->SetControlPoint( 1, pnt2, true ); - mitk::Point2D pnt3; pnt3[0] = 9.25; pnt3[1] = 4.5; - figure1->SetControlPoint( 2, pnt3, true ); - mitk::Point2D pnt4; pnt4[0] = 11.0; pnt4[1] = 4.5; - figure1->SetControlPoint( 3, pnt4, true ); - figure1->GetPolyLine(0); - - testCase test; - test.id = testCases.size(); - test.figure = figure1; - test.mean = 191.5; - test.sd = 89.80; - - testCases.push_back( test ); - } - - { - /***************************** - * half pixel (black) + whole pixel (white) + half pixel (gray) in x-direction - * -> mean of 127.66 expected - ******************************/ - mitk::PlanarPolygon::Pointer figure1 = mitk::PlanarPolygon::New(); - figure1->SetGeometry2D( geom ); - mitk::Point2D pnt1; pnt1[0] = 11.0; pnt1[1] = 3.5; - figure1->PlaceFigure( pnt1 ); - - mitk::Point2D pnt2; pnt2[0] = 9.0; pnt2[1] = 3.5; - figure1->SetControlPoint( 1, pnt2, true ); - mitk::Point2D pnt3; pnt3[0] = 9.0; pnt3[1] = 4.0; - figure1->SetControlPoint( 2, pnt3, true ); - mitk::Point2D pnt4; pnt4[0] = 11.0; pnt4[1] = 4.0; - figure1->SetControlPoint( 3, pnt4, true ); - figure1->GetPolyLine(0); - - testCase test; - test.id = testCases.size(); - test.figure = figure1; - test.mean = 127.66; - test.sd = 127.5; - - testCases.push_back( test ); - } - - - { - /***************************** - * whole pixel (gray) - * -> mean of 128 expected - ******************************/ - mitk::PlanarPolygon::Pointer figure2 = mitk::PlanarPolygon::New(); - figure2->SetGeometry2D( geom ); - mitk::Point2D pnt1; pnt1[0] = 11.5; pnt1[1] = 10.5; - figure2->PlaceFigure( pnt1 ); - - mitk::Point2D pnt2; pnt2[0] = 11.5; pnt2[1] = 11.5; - figure2->SetControlPoint( 1, pnt2, true ); - mitk::Point2D pnt3; pnt3[0] = 12.5; pnt3[1] = 11.5; - figure2->SetControlPoint( 2, pnt3, true ); - mitk::Point2D pnt4; pnt4[0] = 12.5; pnt4[1] = 10.5; - figure2->SetControlPoint( 3, pnt4, true ); - figure2->GetPolyLine(0); - - testCase test; - test.id = testCases.size(); - test.figure = figure2; - test.mean = 128.0; - test.sd = 0.0; - - testCases.push_back( test ); - } - - { - /***************************** - * whole pixel (gray) + half pixel (white) in y-direction - * -> mean of 191.5 expected - ******************************/ - mitk::PlanarPolygon::Pointer figure2 = mitk::PlanarPolygon::New(); - figure2->SetGeometry2D( geom ); - mitk::Point2D pnt1; pnt1[0] = 11.5; pnt1[1] = 10.5; - figure2->PlaceFigure( pnt1 ); - - mitk::Point2D pnt2; pnt2[0] = 11.5; pnt2[1] = 12.0; - figure2->SetControlPoint( 1, pnt2, true ); - mitk::Point2D pnt3; pnt3[0] = 12.5; pnt3[1] = 12.0; - figure2->SetControlPoint( 2, pnt3, true ); - mitk::Point2D pnt4; pnt4[0] = 12.5; pnt4[1] = 10.5; - figure2->SetControlPoint( 3, pnt4, true ); - figure2->GetPolyLine(0); - - testCase test; - test.id = testCases.size(); - test.figure = figure2; - test.mean = 191.5; - test.sd = 89.80; - - testCases.push_back( test ); - } - - { - /***************************** - * 2 whole pixel (white) + 2 whole pixel (black) in y-direction - * -> mean of 127.66 expected - ******************************/ - mitk::PlanarPolygon::Pointer figure2 = mitk::PlanarPolygon::New(); - figure2->SetGeometry2D( geom ); - mitk::Point2D pnt1; pnt1[0] = 11.5; pnt1[1] = 10.5; - figure2->PlaceFigure( pnt1 ); - - mitk::Point2D pnt2; pnt2[0] = 11.5; pnt2[1] = 13.5; - figure2->SetControlPoint( 1, pnt2, true ); - mitk::Point2D pnt3; pnt3[0] = 12.5; pnt3[1] = 13.5; - figure2->SetControlPoint( 2, pnt3, true ); - mitk::Point2D pnt4; pnt4[0] = 12.5; pnt4[1] = 10.5; - figure2->SetControlPoint( 3, pnt4, true ); - figure2->GetPolyLine(0); - - testCase test; - test.id = testCases.size(); - test.figure = figure2; - test.mean = 127.66; - test.sd = 127.5; - - testCases.push_back( test ); - } - - - { - /***************************** - * 9 whole pixels (white) + 3 half pixels (white) - * + 3 whole pixel (black) [ + 3 slightly less than half pixels (black)] - * -> mean of 204.0 expected - ******************************/ - mitk::PlanarPolygon::Pointer figure2 = mitk::PlanarPolygon::New(); - figure2->SetGeometry2D( geom ); - mitk::Point2D pnt1; pnt1[0] = 0.5; pnt1[1] = 0.5; - figure2->PlaceFigure( pnt1 ); - - mitk::Point2D pnt2; pnt2[0] = 3.5; pnt2[1] = 3.5; - figure2->SetControlPoint( 1, pnt2, true ); - mitk::Point2D pnt3; pnt3[0] = 8.4999; pnt3[1] = 3.5; - figure2->SetControlPoint( 2, pnt3, true ); - mitk::Point2D pnt4; pnt4[0] = 5.4999; pnt4[1] = 0.5; - figure2->SetControlPoint( 3, pnt4, true ); - figure2->GetPolyLine(0); - - testCase test; - test.id = testCases.size(); - test.figure = figure2; - test.mean = 204.0; - test.sd = 105.58; - - testCases.push_back( test ); - } - - { - /***************************** - * half pixel (white) + whole pixel (white) + half pixel (black) - * -> mean of 212.66 expected - ******************************/ - mitk::PlanarPolygon::Pointer figure2 = mitk::PlanarPolygon::New(); - figure2->SetGeometry2D( geom ); - mitk::Point2D pnt1; pnt1[0] = 9.5; pnt1[1] = 0.5; - figure2->PlaceFigure( pnt1 ); - - mitk::Point2D pnt2; pnt2[0] = 9.5; pnt2[1] = 2.5; - figure2->SetControlPoint( 1, pnt2, true ); - mitk::Point2D pnt3; pnt3[0] = 11.5; pnt3[1] = 2.5; - figure2->SetControlPoint( 2, pnt3, true ); - figure2->GetPolyLine(0); - - testCase test; - test.id = testCases.size(); - test.figure = figure2; - test.mean = 212.66; - test.sd = 73.32; - - testCases.push_back( test ); - } - - - - return testCases; -} - -// loads the test image -static mitk::Image::Pointer GetTestImage() -{ - mitk::StandardFileLocations::Pointer locator = mitk::StandardFileLocations::GetInstance(); - - const std::string filename = locator->FindFile("testimage.dcm", "Modules/MitkExt/Testing/Data"); - if (filename.empty()) - { - MITK_ERROR << "Could not find test file"; - return NULL; - } - else - { - MITK_INFO << "Found testimage.dcm"; - } - - - itk::FilenamesContainer file; - file.push_back( filename ); - - mitk::DicomSeriesReader* reader = new mitk::DicomSeriesReader; - - mitk::DataNode::Pointer node = reader->LoadDicomSeries( file, false, false ); - mitk::Image::Pointer image = dynamic_cast( node->GetData() ); - - return image; -} - -}; - -int mitkImageStatisticsCalculatorTest(int argc, char* argv[]) -{ - // always start with this! - MITK_TEST_BEGIN("mitkImageStatisticsCalculatorTest") - - //QCoreApplication app(argc, argv); - - mitk::Image::Pointer image = mitkImageStatisticsCalculatorTestClass::GetTestImage(); - MITK_TEST_CONDITION_REQUIRED( image.IsNotNull(), "Loading test image" ); - - mitk::Geometry2D::Pointer geom = image->GetSlicedGeometry()->GetGeometry2D(0); - - std::vector allTestCases = - mitkImageStatisticsCalculatorTestClass::InitializeTestCases( geom ); - - - for ( int i=0; i - -#include "mitkReferenceCountWatcher.h" - -class TwoOutputsFilter : public mitk::SurfaceToImageFilter -{ -public: - mitkClassMacro(TwoOutputsFilter, SurfaceToImageFilter); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) -protected: - TwoOutputsFilter() - { - mitk::Image::Pointer output - = static_cast(this->MakeOutput(0).GetPointer()); - Superclass::SetNumberOfRequiredOutputs(2); - Superclass::SetNthOutput(1, output.GetPointer()); - } - - virtual ~TwoOutputsFilter() - { - } -}; - -template -int runPipelineSmartPointerCorrectnessTestForFilterType(typename InputType::Pointer input) -{ - typename FilterType::Pointer filter; - std::cout << "Testing " << typeid(FilterType).name() << "::New(): "; - filter = FilterType::New(); - if (filter.IsNull()) - { - std::cout<<"[FAILED]"<SetInput(input); - std::cout<<"[PASSED]"<GetOutput(), "filter1Output"); - std::cout<<"[PASSED]"<GetOutput(); - std::cout << "Testing to set filter to NULL, keeping reference to output:"; - filter = NULL; - std::cout<<"[PASSED]"<GetReferenceCount()!=2) - { - std::cout<<"[FAILED]"<GetExternalReferenceCount()!=1) - { - std::cout<<"[FAILED]"<GetSource()->DebugOn(); - //output->DebugOn(); - output = NULL; - std::cout<<"[PASSED]"<GetReferenceCount()!=0) - { - std::cout<<"[FAILED]"<GetReferenceCount()!=0) - { - std::cout<<"[FAILED]"<GetOutput(), "filter2Output"); - try - { - std::cout << "Testing to set filter to NULL, keeping NO reference to output:"; - filter = NULL; - std::cout<<"[PASSED]"<GetReferenceCount()!=0) - { - std::cout<<"[FAILED]"<GetReferenceCount()!=0) - { - std::cout<<"[FAILED]"<GetOutput(), "filter3Output"); - output = localFilter->GetOutput(); - std::cout << "Testing running out of scope of filter, keeping reference to output:"; - } - std::cout<<"[PASSED]"<GetReferenceCount()!=2) - { - std::cout<<"[FAILED]"<GetExternalReferenceCount()!=1) - { - std::cout<<"[FAILED]"<GetReferenceCount()!=0) - { - std::cout<<"[FAILED]"<GetReferenceCount()!=0) - { - std::cout<<"[FAILED]"<GetOutput(), "filter4Output"); - output = localFilter->GetOutput(); - std::cout << "Testing running out of scope of filter, keeping reference to output (as in part 3):"; - } - std::cout<<"[PASSED]"<DisconnectPipeline(): "; - output->DisconnectPipeline(); - std::cout<<"[PASSED]"<GetReferenceCount()!=1) - { - std::cout<<"[FAILED]"<GetExternalReferenceCount()!=1) - { - std::cout<<"[FAILED]"<GetReferenceCount()!=0) - { - std::cout<<"[FAILED]"<GetReferenceCount()!=0) - { - std::cout<<"[FAILED]"<GetOutput(), "filter5Output"); - std::cout << "Testing running out of scope of filter, keeping NO reference to output:"; - } - std::cout<<"[PASSED]"<GetReferenceCount()!=0) - { - std::cout<<"[FAILED]"<GetReferenceCount()!=0) - { - std::cout<<"[FAILED]"<(mitk::Surface::New()); - if( result != EXIT_SUCCESS ) - return result; - std::cout << std::endl; - - result = runPipelineSmartPointerCorrectnessTestForFilterType(mitk::Image::New()); - if( result != EXIT_SUCCESS ) - return result; - std::cout << std::endl; - - result = runPipelineSmartPointerCorrectnessTestForFilterType(mitk::Surface::New()); - if( result != EXIT_SUCCESS ) - return result; - - result = runPipelineSmartPointerCorrectnessTestForFilterType(mitk::Image::New()); - if( result != EXIT_SUCCESS ) - return result; - - std::cout<<"[TEST DONE]"< -#include -#include -#include -#include -#include - -int mitkPlaneFitTest(int, char*[] ) -{ - //float bounds[]={0.0f,10.0f,0.0f,10.0f,0.0f,5.0f}; - - mitk::PlaneFit::Pointer PlaneFit = mitk::PlaneFit::New(); - mitk::PointSet::Pointer PointSet = mitk::PointSet::New(); - mitk::PlaneGeometry::Pointer planeGeo= mitk::PlaneGeometry::New(); - mitk::BaseGeometry::Pointer BaseGeometry = dynamic_cast(planeGeo.GetPointer()); - - mitk::Point3D Point; - - //first without any point, then incrementally add points within thre points there will be a plane geometry - std::cout <<"Start PlaneFitTest "<GetPointSet()->GetPoints()->InsertElement(position, Point); - } - - //Set Input - PlaneFit->SetInput(PointSet); - - const mitk::PointSet* testPointSet = PlaneFit->GetInput(); - std::cout<<" Size test of Input Method: "; - if( testPointSet->GetSize() == PointSet->GetSize() ) - { - std::cout<<"[PASSED]"<Update(); - const mitk::Point3D ¢roid = PlaneFit->GetCentroid(); - mitk::Point3D expectedCentroid; - expectedCentroid[0]=2.5; - expectedCentroid[1]=3.75; - expectedCentroid[2]=2.5; - - if ( centroid == expectedCentroid ) - { - std::cout<<"[PASSED]"<( PlaneFit->GetOutput()->GetGeometry()); - if( PlaneGeometry ) - { - std::cout<<"[PASSED]"< -#include -#include -#include -#include -#include -#include - -double GenerateRandomNumber( const double& min = 0.0, const double& max = 100.0 ) -{ - return ( ( ( double ) ( std::rand( ) ) ) / ( ( double ) ( RAND_MAX ) ) ) * ( max - min) + min; -} - -void GenerateRandomPoint( double& x, double& y, double& z, const double& min = 0.0, const double& max = 100.0 ) -{ - x = GenerateRandomNumber(min, max); - y = GenerateRandomNumber(min, max); - z = GenerateRandomNumber(min, max); -} - -int mitkPointLocatorTest(int /*argc*/, char* /*argv*/[]) -{ - MITK_TEST_BEGIN("mitkPointLocator"); - std::srand( 1 ); - unsigned int num_points = 10000; - - // Create PointSet with randomly defined point - MITK_TEST_OUTPUT(<< "Creating random point set of 10000 points "); - vtkPoints* points = vtkPoints::New(); - for (unsigned int i = 0; i < num_points ; ++i ) - { - points->InsertPoint(i, GenerateRandomNumber(), GenerateRandomNumber(), GenerateRandomNumber()); - } - vtkPolyData* pointSet = vtkPolyData::New(); - pointSet->SetPoints( points ); - points->Delete(); - - MITK_TEST_CONDITION_REQUIRED((unsigned) pointSet->GetNumberOfPoints()== num_points,"Test number of points in vtkPointSet"); - - // feed the point set into a vtk point locator - MITK_TEST_OUTPUT(<< "Building vtkPointLocator "); - vtkPointLocator* vtkPointLoc = vtkPointLocator::New(); - vtkPointLoc->SetDataSet( pointSet ); - vtkPointLoc->BuildLocator(); - MITK_TEST_OUTPUT(<< "[PASSED]"); - - // feed the point set into the mitk point locator - MITK_TEST_OUTPUT(<< "Building mitkPointLocator "); - mitk::PointLocator::Pointer mitkPointLocatorInitializedByVtkPointSet = mitk::PointLocator::New(); - mitk::PointLocator::Pointer mitkPointLocatorInitializedByMITKPointSet = mitk::PointLocator::New(); - mitk::PointLocator::Pointer mitkPointLocatorInitializedByITKPointSet = mitk::PointLocator::New(); - MITK_TEST_CONDITION_REQUIRED(mitkPointLocatorInitializedByVtkPointSet.IsNotNull(), "Test whether mitkPointLocator is not null"); - - mitk::PointSet::Pointer mitkPointSet = mitk::PointSet::New(); - mitk::PointLocator::ITKPointSet::Pointer itkPointSet = mitk::PointLocator::ITKPointSet::New(); - for ( int i=0; iGetNumberOfPoints();i++ ) - { - mitk::Point3D pnt; - pnt[0] = pointSet->GetPoint( i )[0]; - pnt[1] = pointSet->GetPoint( i )[1]; - pnt[2] = pointSet->GetPoint( i )[2]; - mitkPointSet->InsertPoint(i, pnt ); - mitk::PointLocator::ITKPointSet::PointType itkPoint; - itkPoint[0] = pointSet->GetPoint( i )[0]; - itkPoint[1] = pointSet->GetPoint( i )[1]; - itkPoint[2] = pointSet->GetPoint( i )[2]; - itkPointSet->SetPoint(i,itkPoint); - } - - MITK_TEST_OUTPUT(<< "Setting random point set "); - mitkPointLocatorInitializedByVtkPointSet->SetPoints( pointSet ); - mitkPointLocatorInitializedByMITKPointSet->SetPoints( mitkPointSet ); - mitkPointLocatorInitializedByITKPointSet->SetPoints( itkPointSet ); - MITK_TEST_OUTPUT(<< "[PASSED]"); - - MITK_TEST_OUTPUT(<< "Testing 1000 random points "); - // generate N random points and calculate the closest - // points with both the vtk and mitk pointlocator. - // verify, that the point ids are the same. - double p[3], x, y, z; - mitk::PointSet::PointType pointType; - for ( unsigned int i = 0 ; i < 100 ; ++i ) - { - GenerateRandomPoint( x, y, z ); - p[0] = x; - p[1] = y; - p[2] = z; - pointType[0] = p[0]; - pointType[1] = p[1]; - pointType[2] = p[2]; - int closestPointReference = vtkPointLoc->FindClosestPoint(p); // ground truth vtkPointLocator - int closestPointVTK1 = mitkPointLocatorInitializedByVtkPointSet->FindClosestPoint(p); - int closestPointVTK2 = mitkPointLocatorInitializedByVtkPointSet->FindClosestPoint(x, y, z); - int closestPointVTK3 = mitkPointLocatorInitializedByVtkPointSet->FindClosestPoint(pointType); - int closestPointMITK1 = mitkPointLocatorInitializedByMITKPointSet->FindClosestPoint(p); - int closestPointMITK2 = mitkPointLocatorInitializedByMITKPointSet->FindClosestPoint(x, y, z); - int closestPointMITK3 = mitkPointLocatorInitializedByMITKPointSet->FindClosestPoint(pointType); - int closestPointITK1 = mitkPointLocatorInitializedByITKPointSet->FindClosestPoint(p); - int closestPointITK2 = mitkPointLocatorInitializedByITKPointSet->FindClosestPoint(x, y, z); - int closestPointITK3 = mitkPointLocatorInitializedByITKPointSet->FindClosestPoint(pointType); - MITK_TEST_CONDITION_REQUIRED(closestPointReference==closestPointVTK1,"Test FindClosestPoint() using a point array with a PointLocator initialized with a vtkPointSet"); - MITK_TEST_CONDITION_REQUIRED(closestPointReference==closestPointVTK2,"Test FindClosestPoint() using single coordinates with a PointLocator initialized with a vtkPointSet"); - MITK_TEST_CONDITION_REQUIRED(closestPointReference==closestPointVTK3,"Test FindClosestPoint() using an mitk::PointSet with a PointLocator initialized with a vtkPointSet"); - MITK_TEST_CONDITION_REQUIRED(closestPointReference==closestPointMITK1,"Test FindClosestPoint() using a point array with a PointLocator initialized with a mitk::PointSet"); - MITK_TEST_CONDITION_REQUIRED(closestPointReference==closestPointMITK2,"Test FindClosestPoint() using single coordinates with a PointLocator initialized with a mitk::PointSet"); - MITK_TEST_CONDITION_REQUIRED(closestPointReference==closestPointMITK3,"Test FindClosestPoint() using an mitk::PointSet with a PointLocator initialized with a mitk::PointSet"); - MITK_TEST_CONDITION_REQUIRED(closestPointReference==closestPointITK1,"Test FindClosestPoint() using a point array with a PointLocator initialized with a itk::PointSet"); - MITK_TEST_CONDITION_REQUIRED(closestPointReference==closestPointITK2,"Test FindClosestPoint() using single coordinates with a PointLocator initialized with a itk::PointSet"); - MITK_TEST_CONDITION_REQUIRED(closestPointReference==closestPointITK3,"Test FindClosestPoint() using an mitk::PointSet with a PointLocator initialized with a itk::PointSet"); - //Test GetMinimalDistance - // Get closest point - //double* closestPoint = vtkPointLoc->GetPoints()->GetPoint(closestPointReference); - double* closestPoint = pointSet->GetPoint(closestPointReference); - mitk::PointSet::PointType cP; - cP[0] = closestPoint[0]; - cP[1] = closestPoint[1]; - cP[2] = closestPoint[2]; - mitk::PointLocator::DistanceType minimalDistanceReference = cP.SquaredEuclideanDistanceTo(pointType); - - //mitk::PointLocator::DistanceType minimalDistanceReference = - // (x-closestPoint[0])*(x-closestPoint[0])+(y-closestPoint[1])*(y-closestPoint[1])+(z-closestPoint[2])*(z-closestPoint[2]); - mitk::PointLocator::DistanceType minimalDistanceVtk = mitkPointLocatorInitializedByVtkPointSet->GetMinimalDistance(pointType); - mitk::PointLocator::DistanceType minimalDistanceItk = mitkPointLocatorInitializedByITKPointSet->GetMinimalDistance(pointType); - mitk::PointLocator::DistanceType minimalDistanceMITK = mitkPointLocatorInitializedByMITKPointSet->GetMinimalDistance(pointType); - MITK_TEST_CONDITION_REQUIRED(mitk::Equal(minimalDistanceReference,minimalDistanceVtk), "Test GetMinimalDistance() using a PointLocator initialized with a vtkPointSet" ); - MITK_TEST_CONDITION_REQUIRED(mitk::Equal(minimalDistanceReference,minimalDistanceItk), "Test GetMinimalDistance() using a PointLocator initialized with a itkPointSet" ); - MITK_TEST_CONDITION_REQUIRED(mitk::Equal(minimalDistanceReference,minimalDistanceMITK), "Test GetMinimalDistance() using a PointLocator initialized with a MITKPointSet" ); - - int closestPointCombinedVtk; - mitk::PointLocator::DistanceType minimalDistanceCombinedVtk; - mitkPointLocatorInitializedByVtkPointSet->FindClosestPointAndDistance(pointType,&closestPointCombinedVtk,&minimalDistanceCombinedVtk); - int closestPointCombinedITK; - mitk::PointLocator::DistanceType minimalDistanceCombinedITK; - mitkPointLocatorInitializedByITKPointSet->FindClosestPointAndDistance(pointType,&closestPointCombinedITK,&minimalDistanceCombinedITK); - int closestPointCombinedMITK; - mitk::PointLocator::DistanceType minimalDistanceCombinedMITK; - mitkPointLocatorInitializedByMITKPointSet->FindClosestPointAndDistance(pointType,&closestPointCombinedMITK,&minimalDistanceCombinedMITK); - MITK_TEST_CONDITION_REQUIRED(mitk::Equal(minimalDistanceReference,minimalDistanceCombinedVtk), "Test distance returned by FindClosestPointAndDistance() using a PointLocator initialized with a vtkPointSet" ); - MITK_TEST_CONDITION_REQUIRED(mitk::Equal(minimalDistanceReference,minimalDistanceCombinedITK), "Test distance returned by FindClosestPointAndDistance() using a PointLocator initialized with a itkPointSet" ); - MITK_TEST_CONDITION_REQUIRED(mitk::Equal(minimalDistanceReference,minimalDistanceCombinedMITK), "Test distance returned by FindClosestPointAndDistance() using a PointLocator initialized with a MITKPointSet" ); - MITK_TEST_CONDITION_REQUIRED(closestPointReference==closestPointCombinedVtk,"Test closest point returned by FindClosestPointAndDistance() using a point array with a PointLocator initialized with a vtkPointSet"); - MITK_TEST_CONDITION_REQUIRED(closestPointReference==closestPointCombinedITK,"Test closest point returned by FindClosestPointAndDistance() using a point array with a PointLocator initialized with a itkPointSet"); - MITK_TEST_CONDITION_REQUIRED(closestPointReference==closestPointCombinedMITK,"Test closest point returned by FindClosestPointAndDistance() using a point array with a PointLocator initialized with a MITKPointSet"); - } - - vtkPointLoc->Delete(); - pointSet->Delete(); - - MITK_TEST_END(); -} diff --git a/Modules/Ext/files.cmake b/Modules/Ext/files.cmake deleted file mode 100644 index a65eb78547..0000000000 --- a/Modules/Ext/files.cmake +++ /dev/null @@ -1,81 +0,0 @@ -set(CPP_FILES - Algorithms/vtkPointSetSlicer.cxx - Algorithms/mitkAngleCorrectByPointFilter.cpp - Algorithms/mitkCylindricToCartesianFilter.cpp - Algorithms/mitkGeometryDataSource.cpp - Algorithms/mitkImageToLookupTableFilter.cpp - Algorithms/mitkInterpolateLinesFilter.cpp - Algorithms/mitkMeshSource.cpp - Algorithms/mitkPlaneCutFilter.cpp - Algorithms/mitkPlaneFit.cpp - Algorithms/mitkPlanesPerpendicularToLinesFilter.cpp - Algorithms/mitkPointSetToCurvedGeometryFilter.cpp - Algorithms/mitkPointSetToGeometryDataFilter.cpp - Algorithms/mitkPointSetIndexToWorldTransformFilter.cpp - Algorithms/mitkSurfaceIndexToWorldTransformFilter.cpp - Algorithms/mitkPolygonToRingFilter.cpp - Algorithms/mitkProbeFilter.cpp - Algorithms/mitkUnstructuredGridHistogram.cpp - Algorithms/mitkVolumeVisualizationImagePreprocessor.cpp - - DataManagement/mitkAffineTransformationOperation.cpp - DataManagement/mitkColorSequenceHalfTones.cpp - DataManagement/mitkDelegateManager.cpp - DataManagement/mitkDrawOperation.cpp - DataManagement/mitkExternAbstractTransformGeometry.cpp - DataManagement/mitkFrameOfReferenceUIDManager.cpp - DataManagement/mitkItkBaseDataAdapter.cpp - DataManagement/mitkObjectSet.cpp - DataManagement/mitkPropertyManager.cpp - DataManagement/mitkSeedsImage.cpp - DataManagement/mitkSeedsImageLookupTableSource.cpp - DataManagement/mitkSphereLandmarkProjector.cpp -# DataManagement/mitkUSLookupTableSource.cpp - DataManagement/vtkObjectSet.cpp - IO/mitkObjFileIOFactory.cpp - IO/mitkObjFileReader.cpp - IO/mitkPACSPlugin.cpp - IO/mitkParRecFileIOFactory.cpp - IO/mitkParRecFileReader.cpp - IO/mitkPropertyListExportToXmlFile.cpp - IO/mitkPropertyListImportFromXmlFile.cpp - IO/mitkStlVolumeTimeSeriesIOFactory.cpp - IO/mitkStlVolumeTimeSeriesReader.cpp - IO/mitkUnstructuredGridVtkWriter.cpp - IO/mitkUnstructuredGridVtkWriterFactory.cpp - IO/mitkVtkUnstructuredGridIOFactory.cpp - IO/mitkVtkUnstructuredGridReader.cpp - IO/mitkVtkVolumeTimeSeriesIOFactory.cpp - IO/mitkVtkVolumeTimeSeriesReader.cpp - Interactions/mitkConferenceEventMapper.cpp - Interactions/mitkConnectPointsInteractor.cpp - #Interactions/mitkCoordinateSupplier.cpp - #Interactions/mitkDisplayCoordinateOperation.cpp - #Interactions/mitkDisplayInteractor.cpp - Interactions/mitkAffineInteractor3D.cpp - Interactions/mitkDisplayPointSetInteractor.cpp - #Interactions/mitkDisplayVectorInteractor.cpp - Interactions/mitkInteractionDebug.cpp - Interactions/mitkInteractionDebugger.cpp - Interactions/mitkPointInteractor.cpp - Interactions/mitkPointSelectorInteractor.cpp - #Interactions/mitkPositionTracker.cpp - Interactions/mitkSeedsInteractor.cpp - Interactions/mitkSocketClient.cpp - Interactions/mitkSurfaceDeformationInteractor3D.cpp - Interactions/mitkSurfaceInteractor.cpp -# Interactions/mitkCreateSurfaceTool.cpp - Rendering/mitkImageBackground2D.cpp - Rendering/mitkLineMapper2D.cpp -# Rendering/mitkLineVtkMapper3D.cpp - Rendering/mitkNativeRenderWindowInteractor.cpp -) - - -set(RESOURCE_FILES -Interactions/AffineInteraction3D.xml -Interactions/AffineTranslationConfig.xml -Interactions/AffineRotationConfig.xml -Interactions/AffineDeformationConfig.xml -) -