From: Vivien Delmon Date: Wed, 31 Oct 2012 10:11:10 +0000 (+0100) Subject: Merge branch 'master' of tux.creatis.insa-lyon.fr:clitk X-Git-Tag: v1.4.0~239^2~14 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=58cd684433d4a961aa1ac37c39f92830a9a07146;hp=387c2e7bda28033ab077fbd0767e1c4192dd8832;p=clitk.git Merge branch 'master' of tux.creatis.insa-lyon.fr:clitk --- diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 91f53e5..76c19e6 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -39,6 +39,8 @@ IF(CLITK_PRIVATE_FEATURES) ${PROJECT_SOURCE_DIR}/private_features/clitkUsfImageIOFactory.cxx ${PROJECT_SOURCE_DIR}/private_features/clitkUSVoxImageIO.cxx ${PROJECT_SOURCE_DIR}/private_features/clitkUSVoxImageIOFactory.cxx + ${PROJECT_SOURCE_DIR}/private_features/clitkSvlImageIO.cxx + ${PROJECT_SOURCE_DIR}/private_features/clitkSvlImageIOFactory.cxx ) ENDIF(CLITK_PRIVATE_FEATURES) diff --git a/common/clitkIO.cxx b/common/clitkIO.cxx index cfa8e86..79aa958 100644 --- a/common/clitkIO.cxx +++ b/common/clitkIO.cxx @@ -37,6 +37,7 @@ #if CLITK_PRIVATE_FEATURES #include "clitkUsfImageIOFactory.h" #include "clitkUSVoxImageIOFactory.h" + #include "clitkSvlImageIOFactory.h" #endif //-------------------------------------------------------------------- @@ -46,6 +47,7 @@ void clitk::RegisterClitkFactories() #if CLITK_PRIVATE_FEATURES clitk::UsfImageIOFactory::RegisterOneFactory(); clitk::USVoxImageIOFactory::RegisterOneFactory(); + clitk::SvlImageIOFactory::RegisterOneFactory(); #endif clitk::GateAsciiImageIOFactory::RegisterOneFactory(); clitk::DicomRTDoseIOFactory::RegisterOneFactory(); diff --git a/itk/clitkInvertVFFilter.txx b/itk/clitkInvertVFFilter.txx index b74958f..34500a3 100644 --- a/itk/clitkInvertVFFilter.txx +++ b/itk/clitkInvertVFFilter.txx @@ -123,7 +123,7 @@ void HelperClass1::ThreadedGenerateData(const O void HelperClass1::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId ) #endif { - //std::cout << "HelperClass1::ThreadedGenerateData - IN" << std::endl; +// std::cout << "HelperClass1::ThreadedGenerateData - IN " << threadId << std::endl; //Get pointer to the input typename InputImageType::ConstPointer inputPtr = this->GetInput(); @@ -145,6 +145,8 @@ void HelperClass1::ThreadedGenerateData(const O typedef typename OutputImageType::PixelType DisplacementType; DisplacementType displacement; inputIt.GoToBegin(); + + typename OutputImageType::SizeType size = outputPtr->GetLargestPossibleRegion().GetSize(); //define some temp variables signed long baseIndex[ImageDimension]; @@ -197,10 +199,12 @@ void HelperClass1::ThreadedGenerateData(const O overlap *= 1.0 - distance[dim]; } upper >>= 1; + + if (neighIndex[dim] >= size[dim]) + neighIndex[dim] = size[dim] - 1; } - //Set neighbor value only if overlap is not zero if( (overlap>0.0)) // && // (static_cast(neighIndex[0])::ThreadedGenerateData(const O ++inputIt; } - //std::cout << "HelperClass1::ThreadedGenerateData - OUT" << std::endl; +// std::cout << "HelperClass1::ThreadedGenerateData - OUT " << threadId << std::endl; } @@ -328,7 +332,7 @@ template void HelperClass2 void HelperClass2::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId ) #endif { - //std::cout << "HelperClass2::ThreadedGenerateData - IN" << std::endl; +// std::cout << "HelperClass2::ThreadedGenerateData - IN " << threadId << std::endl; //Get pointer to the input typename InputImageType::ConstPointer inputPtr = this->GetInput(); @@ -380,7 +384,7 @@ template void HelperClass2::InvertVFFilter() //Update template void InvertVFFilter::GenerateData() { - //std::cout << "InvertVFFilter::GenerateData - IN" << std::endl; + // std::cout << "InvertVFFilter::GenerateData - IN" << std::endl; //Get the properties of the input typename InputImageType::ConstPointer inputPtr=this->GetInput(); @@ -472,6 +476,7 @@ template void InvertVFFilterSetNumberOfThreads(m_NumberOfThreads); helper2->SetInput(temp); helper2->SetWeights(weights); helper2->SetEdgePaddingValue(m_EdgePaddingValue); @@ -482,6 +487,8 @@ template void InvertVFFilterSetNthOutput(0, helper2->GetOutput()); + + //std::cout << "InvertVFFilter::GenerateData - OUT" << std::endl; } diff --git a/itk/itkFlexibleBinaryFunctorImageFilter.txx b/itk/itkFlexibleBinaryFunctorImageFilter.txx index f8c7a75..d8258cc 100644 --- a/itk/itkFlexibleBinaryFunctorImageFilter.txx +++ b/itk/itkFlexibleBinaryFunctorImageFilter.txx @@ -123,7 +123,7 @@ FlexibleBinaryFunctorImageFilter inputIt1(inputPtr1, outputRegionForThread); - ImageRegionConstIterator inputIt2(inputPtr2, outputRegionForThread); + ImageRegionConstIterator inputIt2(inputPtr2, region2); ImageRegionIterator outputIt(outputPtr, outputRegionForThread); @@ -139,11 +139,12 @@ FlexibleBinaryFunctorImageFilterSetNumberOfInputPorts(1); + this->SetNumberOfOutputPorts(1); +} + +vvClipPolyData::~vvClipPolyData() +{ + +} + +int vvClipPolyData::RequestData(vtkInformation *vtkNotUsed(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 + vtkPolyData *input = vtkPolyData::SafeDownCast( + inInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkStringArray* inputLabels = vtkStringArray::SafeDownCast(input->GetPointData()->GetAbstractArray("labels")); + vtkPolyData *output = vtkPolyData::SafeDownCast( + outInfo->Get(vtkDataObject::DATA_OBJECT())); + // + vtkImplicitFunction* currentImpliciteFunction = this->GetClipFunction(); + int insideOutValue = this->GetInsideOut(); + //if insideOutValue=0; we want to retrieve ouside points + //if insideOutValue=1; we want to retrieve inside points + vtkSmartPointer outputPoints = vtkSmartPointer::New(); + vtkSmartPointer outputStrings = vtkSmartPointer::New(); + outputStrings->SetName("labels"); + for(vtkIdType i=0;iGetNumberOfPoints();i++) { + // + double* currentPoint = input->GetPoint(i); + double currentIFvalue = currentImpliciteFunction->FunctionValue(currentPoint); + //if currentIFvalue>0, current point is outside the clip + if (currentIFvalue>0 && insideOutValue==0) { + outputPoints->InsertNextPoint(currentPoint); + vtkStdString label = inputLabels->GetValue(i); + outputStrings->InsertNextValue(label); + } + //currentIFvalue<=0, current point is inside the clip + else if (currentIFvalue<=0 && insideOutValue==1) { + outputPoints->InsertNextPoint(currentPoint); + vtkStdString label = inputLabels->GetValue(i); + outputStrings->InsertNextValue(label); + } + else { + //vtkErrorMacro("vvClipPolyData - NOT IMPLEMENTED"); + } + } + // + output->ShallowCopy(input); + output->SetPoints(outputPoints); + output->GetPointData()->AddArray(outputStrings); + return 1; +} + +//---------------------------------------------------------------------------- + +void vvClipPolyData::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os,indent); +} diff --git a/vv/vvClipPolyData.h b/vv/vvClipPolyData.h new file mode 100644 index 0000000..5bd3f86 --- /dev/null +++ b/vv/vvClipPolyData.h @@ -0,0 +1,25 @@ +#ifndef VVCLIPPOLYDATA_H +#define VVCLIPPOLYDATA_H + +#include "vtkClipPolyData.h" + +class vvClipPolyData : public vtkClipPolyData +{ +public: + vtkTypeMacro(vvClipPolyData,vtkClipPolyData); + void PrintSelf(ostream& os, vtkIndent indent); + + static vvClipPolyData *New(); + +protected: + vvClipPolyData(); + ~vvClipPolyData(); + + int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); + +private: + vvClipPolyData(const vvClipPolyData&); // Not implemented. + void operator=(const vvClipPolyData&); // Not implemented. +}; + +#endif // VVCLIPPOLYDATA_H diff --git a/vv/vvImageMapToWLColors.cxx b/vv/vvImageMapToWLColors.cxx deleted file mode 100644 index a553583..0000000 --- a/vv/vvImageMapToWLColors.cxx +++ /dev/null @@ -1,270 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -===========================================================================**/ -#include "vvImageMapToWLColors.h" -#include "clitkCommon.h" -#include "vtkDataArray.h" -#include "vtkImageData.h" -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkObjectFactory.h" -#include "vtkScalarsToColors.h" -#include "vtkPointData.h" -#include - -vtkStandardNewMacro(vvImageMapToWLColors); - -vvImageMapToWLColors::vvImageMapToWLColors() : - wl_mode(false) -{} - -template -void vtkImageMapToWindowLevelClamps ( vtkImageData *data, double w, - double l, T& lower, T& upper, - unsigned char &lower_val, - unsigned char &upper_val) -{ - double f_lower, f_upper, f_lower_val, f_upper_val; - double adjustedLower, adjustedUpper; - double range[2]; - - data->GetPointData()->GetScalars()->GetDataTypeRange( range ); - - f_lower = l - fabs(w) / 2.0; - f_upper = f_lower + fabs(w); - - // Set the correct lower value - if ( f_lower <= range[1]) { - if (f_lower >= range[0]) { - lower = static_cast(f_lower); - adjustedLower = f_lower; - } else { - lower = static_cast(range[0]); - adjustedLower = range[0]; - } - } else { - lower = static_cast(range[1]); - adjustedLower = range[1]; - } - - // Set the correct upper value - if ( f_upper >= range[0]) { - if (f_upper <= range[1]) { - upper = static_cast(f_upper); - adjustedUpper = f_upper; - } else { - upper = static_cast(range[1]); - adjustedUpper = range[1]; - } - } else { - upper = static_cast(range[0]); - adjustedUpper = range [0]; - } - - // now compute the lower and upper values - if (w >= 0) { - f_lower_val = 255.0*(adjustedLower - f_lower)/w; - f_upper_val = 255.0*(adjustedUpper - f_lower)/w; - } else { - f_lower_val = 255.0 + 255.0*(adjustedLower - f_lower)/w; - f_upper_val = 255.0 + 255.0*(adjustedUpper - f_lower)/w; - } - - if (f_upper_val > 255) { - upper_val = 255; - } else if (f_upper_val < 0) { - upper_val = 0; - } else { - upper_val = static_cast(f_upper_val); - } - - if (f_lower_val > 255) { - lower_val = 255; - } else if (f_lower_val < 0) { - lower_val = 0; - } else { - lower_val = static_cast(f_lower_val); - } -} - -template -void vvImageMapToWindowLevelColorsExecute( - vtkImageMapToWindowLevelColors *self, - vtkImageData *inData, T *inPtr, - vtkImageData *outData, - unsigned char *outPtr, - int outExt[6], int id, bool wl_mode) -{ - int idxX, idxY, idxZ; - int extX, extY, extZ; - vtkIdType inIncX, inIncY, inIncZ; - vtkIdType outIncX, outIncY, outIncZ; - unsigned long count = 0; - unsigned long target; - int dataType = inData->GetScalarType(); - int numberOfComponents,numberOfOutputComponents,outputFormat; - int rowLength; - vtkScalarsToColors *lookupTable = self->GetLookupTable(); - unsigned char *outPtr1; - T *inPtr1; - unsigned char *optr; - T *iptr; - double shift = self->GetWindow() / 2.0 - self->GetLevel(); - double scale = 255.0 / self->GetWindow(); - - T lower, upper; - unsigned char lower_val, upper_val, result_val; - vtkImageMapToWindowLevelClamps( inData, self->GetWindow(), - self->GetLevel(), - lower, upper, lower_val, upper_val ); - - // find the region to loop over - extX = outExt[1] - outExt[0] + 1; - extY = outExt[3] - outExt[2] + 1; - extZ = outExt[5] - outExt[4] + 1; - - target = static_cast(extZ*extY/50.0); - target++; - - // Get increments to march through data - inData->GetContinuousIncrements(outExt, inIncX, inIncY, inIncZ); - - outData->GetContinuousIncrements(outExt, outIncX, outIncY, outIncZ); - numberOfComponents = inData->GetNumberOfScalarComponents(); - numberOfOutputComponents = outData->GetNumberOfScalarComponents(); - outputFormat = self->GetOutputFormat(); - - rowLength = extX*numberOfComponents; - - // Loop through output pixels - outPtr1 = outPtr; - inPtr1 = inPtr; - for (idxZ = 0; idxZ < extZ; idxZ++) { - for (idxY = 0; !self->AbortExecute && idxY < extY; idxY++) { - if (!id) { - if (!(count%target)) { - self->UpdateProgress(count/(50.0*target)); - } - count++; - } - - iptr = inPtr1; - optr = outPtr1; - - if ( lookupTable ) { - lookupTable->MapScalarsThroughTable2( - inPtr1, - static_cast(outPtr1), - dataType,extX,numberOfComponents, - outputFormat); - if (wl_mode) { - unsigned short ushort_val; - for (idxX = 0; idxX < extX; idxX++) { - if (*iptr <= lower) { - ushort_val = lower_val; - } else if (*iptr >= upper) { - ushort_val = upper_val; - } else { - ushort_val = static_cast((*iptr + shift)*scale); - } - *optr = static_cast((*optr * ushort_val) >> 8); - switch (outputFormat) { - case VTK_RGBA: - *(optr+1) = static_cast( - (*(optr+1) * ushort_val) >> 8); - *(optr+2) = static_cast( - (*(optr+2) * ushort_val) >> 8); - *(optr+3) = 255; - break; - case VTK_RGB: - *(optr+1) = static_cast( - (*(optr+1) * ushort_val) >> 8); - *(optr+2) = static_cast( - (*(optr+2) * ushort_val) >> 8); - break; - case VTK_LUMINANCE_ALPHA: - *(optr+1) = 255; - break; - } - iptr += numberOfComponents; - optr += numberOfOutputComponents; - } - } - } else { - for (idxX = 0; idxX < extX; idxX++) { - if (*iptr <= lower) { - result_val = lower_val; - } else if (*iptr >= upper) { - result_val = upper_val; - } else { - result_val = static_cast((*iptr + shift)*scale); - } - *optr = result_val; - switch (outputFormat) { - case VTK_RGBA: - *(optr+1) = result_val; - *(optr+2) = result_val; - *(optr+3) = 255; - break; - case VTK_RGB: - *(optr+1) = result_val; - *(optr+2) = result_val; - break; - case VTK_LUMINANCE_ALPHA: - *(optr+1) = 255; - break; - } - iptr += numberOfComponents; - optr += numberOfOutputComponents; - } - } - outPtr1 += outIncY + extX*numberOfOutputComponents; - inPtr1 += inIncY + rowLength; - } - outPtr1 += outIncZ; - inPtr1 += inIncZ; - } -} - - -void vvImageMapToWLColors::ThreadedRequestData( - vtkInformation *vtkNotUsed(request), - vtkInformationVector **vtkNotUsed(inputVector), - vtkInformationVector *vtkNotUsed(outputVector), - vtkImageData ***inData, - vtkImageData **outData, - int outExt[6], int id) -{ - void *inPtr = inData[0][0]->GetScalarPointerForExtent(outExt); - void *outPtr = outData[0]->GetScalarPointerForExtent(outExt); - - switch (inData[0][0]->GetScalarType()) { - vtkTemplateMacro( - vvImageMapToWindowLevelColorsExecute(this, - inData[0][0], - static_cast(inPtr), - outData[0], - static_cast(outPtr), - outExt, - id,wl_mode)); - default: - vtkErrorMacro(<< "Execute: Unknown ScalarType"); - return; - } -} - - diff --git a/vv/vvImageMapToWLColors.h b/vv/vvImageMapToWLColors.h deleted file mode 100644 index 7b63e2b..0000000 --- a/vv/vvImageMapToWLColors.h +++ /dev/null @@ -1,42 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -===========================================================================**/ -#ifndef vvImageMapToWLColors_h -#define vvImageMapToWLColors_h -#include - -//This is mostly a copy of the vtk parent class, but with the option -//not to use the W/L when a LUT is set - -class vvImageMapToWLColors : public vtkImageMapToWindowLevelColors -{ -public: - static vvImageMapToWLColors * New(); - vvImageMapToWLColors(); - void SetWindowLevelMode(bool wl) {wl_mode=wl;} - void ThreadedRequestData(vtkInformation *request, - vtkInformationVector **inputVector, - vtkInformationVector *outputVector, - vtkImageData ***inData, vtkImageData **outData, - int extent[6], int id); - -protected: - bool wl_mode; - -}; - -#endif diff --git a/vv/vvLandmarks.cxx b/vv/vvLandmarks.cxx index 682398f..0bab2f4 100644 --- a/vv/vvLandmarks.cxx +++ b/vv/vvLandmarks.cxx @@ -41,6 +41,8 @@ vvLandmarks::vvLandmarks(int size) } mPolyData = vtkPolyData::New(); mIds = vtkFloatArray::New(); + mLabels = vtkStringArray::New(); + mLabels->SetName("labels"); } //-------------------------------------------------------------------- @@ -58,6 +60,8 @@ vvLandmarks::~vvLandmarks() mIds->Delete(); if (mPolyData) mPolyData->Delete(); + if (mLabels) + mLabels->Delete(); } //-------------------------------------------------------------------- @@ -66,14 +70,21 @@ vvLandmarks::~vvLandmarks() void vvLandmarks::AddLandmark(float x,float y,float z,float t,double value) { vvLandmark point; + vtkIdType idPoint; point.coordinates[0] = x; point.coordinates[1] = y; point.coordinates[2] = z; point.coordinates[3] = t; point.pixel_value=value; mLandmarks.push_back(point); - mPoints[int(t)]->InsertNextPoint(x,y,z); - + + idPoint = mPoints[int(t)]->InsertNextPoint(x,y,z); + std::string str_vtkIdType; // string which will contain the result + std::ostringstream convert; // stream used for the conversion + convert << idPoint; // insert the textual representation of 'idPoint' in the characters in the stream + str_vtkIdType = convert.str(); // set 'str_vtkIdType' to the contents of the stream + mLabels->InsertNextValue(str_vtkIdType.c_str()); + std::stringstream numberVal; numberVal << (mLandmarks.size()-1); /* @@ -96,10 +107,12 @@ void vvLandmarks::RemoveLastLandmark() { mPoints[mLandmarks.back().coordinates[3]]->SetNumberOfPoints( mPoints[mLandmarks.back().coordinates[3]]->GetNumberOfPoints()-1); - mPolyData->Modified(); // mText.pop_back(); mLandmarks.pop_back(); mIds->RemoveLastTuple(); + mLabels->SetNumberOfValues(mLabels->GetNumberOfValues()-1); + mLabels->Modified(); + mPolyData->Modified(); } //-------------------------------------------------------------------- @@ -112,9 +125,17 @@ void vvLandmarks::RemoveLandmark(int index) // pologyons linking the points int npoints = mPoints[mLandmarks[index].coordinates[3]]->GetNumberOfPoints(); int t = mLandmarks[index].coordinates[3]; - for (int i = index; i < npoints - 1; i++) + for (int i = index; i < npoints - 1; i++) { mPoints[t]->InsertPoint(i, mPoints[t]->GetPoint(i+1)); + std::string str_i; // string which will contain the result + std::ostringstream convert; // stream used for the conversion + convert << i; // insert the textual representation of 'i' in the characters in the stream + str_i = convert.str(); // set 'str_i' to the contents of the stream + mLabels->SetValue(i,str_i.c_str()); + } mPoints[t]->SetNumberOfPoints(npoints-1); + mLabels->SetNumberOfValues(npoints-1); + mLabels->Modified(); mPolyData->Modified(); mLandmarks.erase(mLandmarks.begin() + index); @@ -165,6 +186,7 @@ void vvLandmarks::LoadFile(std::string filename) } mFilename = filename; mLandmarks.clear(); + vtkIdType idPoint; char line[255]; for (unsigned int i = 0; i < mPoints.size(); i++) mPoints[i]->SetNumberOfPoints(0); @@ -246,8 +268,13 @@ void vvLandmarks::LoadFile(std::string filename) // DD(point.comments); mLandmarks.push_back(point); mIds->InsertNextTuple1(0.55); - mPoints[int(point.coordinates[3])]->InsertNextPoint( + idPoint = mPoints[int(point.coordinates[3])]->InsertNextPoint( point.coordinates[0],point.coordinates[1],point.coordinates[2]); + std::string str_vtkIdType; // string which will contain the result + std::ostringstream convert; // stream used for the conversion + convert << idPoint; // insert the textual representation of 'idPoint' in the characters in the stream + str_vtkIdType = convert.str(); // set 'str_vtkIdType' to the contents of the stream + mLabels->InsertNextValue(str_vtkIdType.c_str()); } } SetTime(0); @@ -301,6 +328,7 @@ void vvLandmarks::SetTime(int time) if (time >= 0 && time <= ((int)mPoints.size() -1)) { mPolyData->SetPoints(mPoints[time]); mPolyData->GetPointData()->SetScalars(mIds); + mPolyData->GetPointData()->AddArray(mLabels); mPolyData->Modified(); mPolyData->Update(); } diff --git a/vv/vvLandmarks.h b/vv/vvLandmarks.h index 6bfe82e..8f94717 100644 --- a/vv/vvLandmarks.h +++ b/vv/vvLandmarks.h @@ -24,6 +24,7 @@ #include "vtkPolyData.h" #include "vtkPoints.h" #include "vvLandmarksGlyph.h" +#include "vtkStringArray.h" //typedef struct vvLandmark { @@ -67,6 +68,7 @@ private: std::vector mPoints; vtkFloatArray* mIds; //std::vector mText; + vtkStringArray* mLabels; std::string mFilename; int mFormatVersion; }; diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index ef623d9..5cf7c98 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -101,9 +101,9 @@ #define COLUMN_IMAGE_NAME 7 #if CLITK_PRIVATE_FEATURES - #define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.usf)" + #define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.usf *.svl)" #else - #define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr)" + #define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan)" #endif /*Data Tree values @@ -3070,6 +3070,12 @@ void vvMainWindow::ShowLastImage() //------------------------------------------------------------------------------ void vvMainWindow::UpdateRenderWindows() { + for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { + mSlicerManagers[i]->GetSlicer(0)->UpdateLandmarks(); + mSlicerManagers[i]->GetSlicer(1)->UpdateLandmarks(); + mSlicerManagers[i]->GetSlicer(2)->UpdateLandmarks(); + mSlicerManagers[i]->GetSlicer(3)->UpdateLandmarks(); + } if (NOViewWidget->GetRenderWindow()) NOViewWidget->GetRenderWindow()->Render(); if (NEViewWidget->GetRenderWindow()) NEViewWidget->GetRenderWindow()->Render(); if (SOViewWidget->GetRenderWindow()) SOViewWidget->GetRenderWindow()->Render(); diff --git a/vv/vvSaveState.cxx b/vv/vvSaveState.cxx index ecf29da..894e8e4 100644 --- a/vv/vvSaveState.cxx +++ b/vv/vvSaveState.cxx @@ -172,7 +172,7 @@ void vvSaveState::SaveLink(const vvSlicerManager* vvManager) std::string my_id = vvManager->GetId(); m_XmlWriter->writeStartElement("LinkedFrom"); m_XmlWriter->writeAttribute("Id", my_id.c_str()); - typename LinkListType::iterator i; + LinkListType::iterator i; for (i = links.begin(); i != links.end(); i++) { std::string link_id = *i; m_XmlWriter->writeTextElement("LinkedTo", link_id.c_str()); diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 9246322..1e1245f 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -21,7 +21,6 @@ #include "vvSlicerManagerCommand.h" #include "vvGlyphSource.h" #include "vvGlyph2D.h" -#include "vvImageMapToWLColors.h" #include #include @@ -41,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -137,9 +137,6 @@ vvSlicer::vvSlicer() this->GetRenderer()->AddActor(legend); showFusionLegend = false; - this->WindowLevel->Delete(); - this->WindowLevel = vvImageMapToWLColors::New(); - this->InstallPipeline(); mLinkOverlayWindowLevel = true; @@ -580,36 +577,40 @@ void vvSlicer::SetLandmarks(vvLandmarks* landmarks) if (!mCross) mCross = vtkSmartPointer::New(); + if (!mClipBox) + mClipBox = vtkSmartPointer::New(); + if (!mLandClipper) + mLandClipper = vtkSmartPointer::New(); + if (!mLandGlyph) + mLandGlyph = vtkSmartPointer::New(); + if (!mLandMapper) + mLandMapper = vtkSmartPointer::New(); + if (!mLandActor) + mLandActor = vtkSmartPointer::New(); + mCross->SetFocalPoint(0.0,0.0,0.0); mCross->SetModelBounds(-10,10,-10,10,-10,10); mCross->AllOff(); mCross->AxesOn(); - if (!mLandGlyph) - mLandGlyph = vtkSmartPointer::New(); + mLandClipper->SetClipFunction(mClipBox); + mLandClipper->InsideOutOn(); + mLandClipper->SetInput(mLandmarks->GetOutput()); + mLandGlyph->SetSource(mCross->GetOutput()); - mLandGlyph->SetInput(landmarks->GetOutput()); + mLandGlyph->SetInput(mLandClipper->GetOutput()); //mLandGlyph->SetIndexModeToScalar(); - mLandGlyph->SetRange(0,1); - mLandGlyph->ScalingOff(); + //mLandGlyph->SetRange(0,1); + //mLandGlyph->ScalingOff(); - mLandGlyph->SetColorModeToColorByScalar(); - - if (!mClipBox) - mClipBox = vtkSmartPointer::New(); - if (!mLandClipper) - mLandClipper = vtkSmartPointer::New(); - mLandClipper->InsideOutOn(); - mLandClipper->SetInput(mLandGlyph->GetOutput()); - mLandClipper->SetClipFunction(mClipBox); + //mLandGlyph->SetColorModeToColorByScalar(); + + mLandGlyph->SetScaleModeToDataScalingOff(); + mLandGlyph->SetIndexModeToOff(); - if (!mLandMapper) - mLandMapper = vtkSmartPointer::New(); - mLandMapper->SetInputConnection(mLandClipper->GetOutputPort()); + mLandMapper->SetInputConnection(mLandGlyph->GetOutputPort()); //mLandMapper->ScalarVisibilityOff(); - if (!mLandActor) - mLandActor = vtkSmartPointer::New(); mLandActor->SetMapper(mLandMapper); mLandActor->GetProperty()->SetColor(255,10,212); mLandActor->SetPickable(0); @@ -908,15 +909,15 @@ void vvSlicer::UpdateDisplayExtent() return; } input->UpdateInformation(); + this->SetSlice( this->GetSlice() ); //SR: make sure the update let the slice in extents // Local copy of extent int w_ext[6]; int* ext = GetExtent(); copyExtent(ext, w_ext); // Set slice value - int s = this->Slice > ext[this->SliceOrientation*2+1] ? ext[this->SliceOrientation*2 + 1] : this->Slice; - w_ext[ this->SliceOrientation*2 ] = s; - w_ext[ this->SliceOrientation*2+1 ] = s; + w_ext[ this->SliceOrientation*2 ] = this->Slice; + w_ext[ this->SliceOrientation*2+1 ] = this->Slice; // Image actor this->ImageActor->SetDisplayExtent(w_ext); @@ -1448,13 +1449,38 @@ void vvSlicer::UpdateLandmarks() { vtkPolyData *pd = static_cast(mLandClipper->GetInput()); if (pd->GetPoints()) { - mLandGlyph->SetRange(0,1); - mLandGlyph->Modified(); - mLandGlyph->Update(); + //mLandGlyph->SetRange(0,1); + //mLandGlyph->Modified(); + //mLandGlyph->Update(); mClipBox->Modified(); mLandClipper->Update(); mLandMapper->Update(); + //Let's add the captions + //First remove all captions: + for(unsigned int i=0;iRenderer->RemoveActor2D(mLandLabelActors[i]); + //allActors2D->Remove (mLandLabelActors[i]); + } + mLandLabelActors.clear(); + //Next add the captions to the displayed points + for (vtkIdType id=0; idGetOutput()->GetNumberOfPoints(); id++) { + double *position = mLandClipper->GetOutput()->GetPoint(id); + vtkStdString label = static_cast(mLandClipper->GetOutput()->GetPointData()->GetAbstractArray("labels"))->GetValue(id); + vtkSmartPointer label_actor = vtkSmartPointer::New(); + label_actor->SetCaption(label); + label_actor->SetAttachmentPoint(position); + label_actor->GetCaptionTextProperty()->SetColor(1,0,0); + label_actor->GetCaptionTextProperty()->SetOrientation(33.333333); + label_actor->GetCaptionTextProperty()->SetFontFamilyToTimes(); + label_actor->GetCaptionTextProperty()->SetBold(0); + label_actor->GetCaptionTextProperty()->SetFontSize(6); + label_actor->BorderOff(); + label_actor->LeaderOff(); + label_actor->ThreeDimensionalLeaderOff(); + mLandLabelActors.push_back(label_actor); + this->Renderer->AddActor2D(mLandLabelActors[id]); + } } } diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index 9a750e1..a738a78 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -24,11 +24,13 @@ #include "vvImage.h" #include "vvMesh.h" #include "vvMeshActor.h" +#include "vvClipPolyData.h" #include #include #include #include +#include class vtkActor; class vtkActor2D; @@ -244,9 +246,10 @@ protected: vtkSmartPointer mVFActor; vtkSmartPointer mLandGlyph; vtkSmartPointer mCross; - vtkSmartPointer mLandClipper; + vtkSmartPointer mLandClipper; vtkSmartPointer mLandMapper; vtkSmartPointer mLandActor; + std::vector > mLandLabelActors; vtkSmartPointer mClipBox; vtkSmartPointer legend; std::vector mSurfaceCutActors; diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index 9331bf1..015409b 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -23,7 +23,6 @@ #include "vvInteractorStyleNavigator.h" #include "vvLandmarks.h" #include "vvMesh.h" -#include "vvImageMapToWLColors.h" #include "vvBlendImageActor.h" #include @@ -1305,15 +1304,11 @@ void vvSlicerManager::SetColorMap(int colormap) invLUT->SetSaturationRange(1,1); invLUT->SetHueRange(double((mOverlayColor+180)%360)/360,double((mOverlayColor+180)%360)/360); invLUT->Build(); - dynamic_cast(mSlicers[i]->GetWindowLevel()) - ->SetWindowLevelMode(true); mSlicers[i]->GetWindowLevel()->SetLookupTable(supLUT); mSlicers[i]->GetOverlayMapper()->SetLookupTable(invLUT); invLUT->Delete(); supLUT->Delete(); } else if (mSlicers[i]->GetOverlay()) { - //dynamic_cast(mSlicers[i]->GetWindowLevel()) - //->SetWindowLevelMode(false); mSlicers[i]->GetWindowLevel()->SetLookupTable(LUT); } else { mSlicers[i]->GetWindowLevel()->SetLookupTable(LUT); diff --git a/vv/vvThreadedFilter.cxx b/vv/vvThreadedFilter.cxx deleted file mode 100644 index 3504b92..0000000 --- a/vv/vvThreadedFilter.cxx +++ /dev/null @@ -1,111 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - ===========================================================================**/ - -// vv -#include "vvThreadedFilter.h" -#include "vvProgressDialog.h" - -// Qt -#include - -//------------------------------------------------------------------------------ -vvThreadedFilter::vvThreadedFilter(): - QThread() -{ - m_Filter = NULL; -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -vvThreadedFilter::~vvThreadedFilter() -{ -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvThreadedFilter::SetFilter(clitk::ImageToImageGenericFilterBase * f) -{ - m_Filter = f; -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvThreadedFilter::Update() -{ - assert(m_Filter != NULL); - - // Show a progress bar while computing - vvProgressDialog progress("Computing ...",100); - progress.SetCancelButtonEnabled(true); - connect(&progress, SIGNAL(rejected()), this, SLOT(reject())); - this->start(); - this->setTerminationEnabled(true); - std::string temp; - while (this->isRunning()) { - // try { - m_FilterBase = m_Filter->GetFilterBase(); // get filterbase is only set after Update - if (m_FilterBase != NULL) { - progress.SetProgress(m_FilterBase->GetCurrentStepNumber(), - m_FilterBase->GetNumberOfSteps()); - if (temp != m_FilterBase->GetCurrentStepName()) { - progress.AddToText(m_FilterBase->GetCurrentStepName()); - } - temp = m_FilterBase->GetCurrentStepName(); - } - this->wait(200); // in miliseconds - qApp->processEvents(); - } -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvThreadedFilter::run() -{ - assert(m_Filter != NULL); - try { - m_Filter->Update(); - } - catch(clitk::ExceptionObject e) { - DD("vvThreadedFilter : exceptionobject handeled"); - DD(e.what()); - QApplication::restoreOverrideCursor(); - QMessageBox::information(new QWidget, tr("Error"), e.what()); - } - DD("end RUN"); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvThreadedFilter::reject() -{ - // First, say the filter it must stop as soon as possible. We then - // wait that an exception occur in the main thread. - if (m_FilterBase != NULL) { - m_FilterBase->Cancel(); - } -} -//------------------------------------------------------------------------------ - - - - diff --git a/vv/vvThreadedFilter.h b/vv/vvThreadedFilter.h deleted file mode 100644 index b367d50..0000000 --- a/vv/vvThreadedFilter.h +++ /dev/null @@ -1,55 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -===========================================================================**/ - -#ifndef VVTHREADEDFILTER_H -#define VVTHREADEDFILTER_H - -// clitk -#include "clitkImageToImageGenericFilterBase.h" - -// qt -#include - -//------------------------------------------------------------------------------ -class vvThreadedFilter: public QThread -{ - Q_OBJECT - public: - vvThreadedFilter(); - ~vvThreadedFilter(); - - // Called from the main thread, runs the reader and displays the progress bar - void SetFilter(clitk::ImageToImageGenericFilterBase * f); - void Update(); - -public slots: - void reject(); - - signals: - void ThreadInterrupted(); - -protected: - void run(); - clitk::ImageToImageGenericFilterBase * m_Filter; - clitk::FilterBase * m_FilterBase; - -}; // end class vvThreadedFilter -//------------------------------------------------------------------------------ - -#endif - diff --git a/vv/vvToolExtractLung.cxx b/vv/vvToolExtractLung.cxx deleted file mode 100644 index 59b4133..0000000 --- a/vv/vvToolExtractLung.cxx +++ /dev/null @@ -1,259 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - ===========================================================================**/ - -// vv -#include "vvToolExtractLung.h" -#include "vvToolStructureSetManager.h" -#include "vvSlicer.h" -#include "vvImageReader.h" -#include "vvImageWriter.h" -#include "vvLabelImageLoaderWidget.h" -#include "vvThreadedFilter.h" - -// Qt -#include - -//------------------------------------------------------------------------------ -// Create the tool and automagically (I like this word) insert it in -// the main window menu. -ADD_TOOL(vvToolExtractLung); -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -vvToolExtractLung::vvToolExtractLung(vvMainWindowBase * parent, Qt::WindowFlags f): - vvToolWidgetBase(parent,f), - vvToolBase(parent), - Ui::vvToolExtractLung() -{ - // GUI - Ui_vvToolExtractLung::setupUi(mToolWidget); - mMaskLoaderBox->setEnabled(false); - mOptionsBox->setEnabled(false); - mPatientMaskInputWidget->SetText("Patient mask"); - connect(mPatientMaskInputWidget, SIGNAL(accepted()), this, SLOT(PatientMaskInputIsSelected())); - - // Default values - mArgsInfo = new ArgsInfoType; - cmdline_parser_clitkExtractLung_init(mArgsInfo); - SetGUIFromArgsInfo(); - m_IsThreadInterrupted = false; - - // Create a new ExtractLung filter - mFilter = new FilterType; // used in AddInputSelector - - // Add input selector - AddInputSelector("Select CT thorax image", mFilter); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -vvToolExtractLung::~vvToolExtractLung() -{ -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractLung::Initialize() { - SetToolName("ExtractLung"); - SetToolMenuName("Extract lungs"); - SetToolIconFilename(":/common/icons/lung-overlay.png"); - SetToolTip("Extract lung mask from thorax CT."); - SetToolExperimental(true); - // SetToolInMenu("Segmentation"); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractLung::InputIsSelected(vvSlicerManager *m) -{ - // Hide selector - HideInputSelector(); // splitter - mToolInputSelectionWidget->hide(); - mCurrentSlicerManager = m; - mCurrentImage = m->GetImage(); - mMaskLoaderBox->setEnabled(true); - mLabelInput->setText(m->GetFileName().c_str()); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractLung::PatientMaskInputIsSelected() -{ - // Get Patient mask and BG value - mPatient = mPatientMaskInputWidget->GetImage(); - mPatientBackgroundValue = mPatientMaskInputWidget->GetBackgroundValue(); - - // Check patient dimension - if (mPatient->GetNumberOfDimensions() != 3) { - QMessageBox::information(this,tr("*Error*"), "Mask image must be 3D"); - return; - } - - mMaskLoaderBox->setEnabled(false); - mOptionsBox->setEnabled(true); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractLung::SetGUIFromArgsInfo() -{ - mAirUpperThresholdSlider->SetText("Upper threshold for air"); - mAirUpperThresholdSlider->SetMinimum(-1200); - mAirUpperThresholdSlider->SetMaximum(2000); - DD(mArgsInfo->upper_arg); - mAirUpperThresholdSlider->SetValue(mArgsInfo->upper_arg); - - mAirLowerThresholdSlider->SetText("Lower threshold for air"); - mAirLowerThresholdSlider->SetMinimum(-1200); - mAirLowerThresholdSlider->SetMaximum(2000); - mAirLowerThresholdSlider->SetValue(mArgsInfo->lower_arg); - -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractLung::GetArgsInfoFromGUI() -{ - // mArgsInfo->patientBG_arg = mPatientMaskInputWidget->GetBackgroundValue(); - mArgsInfo->verboseOption_flag = true; // DEBUG. TO CHANGE - mArgsInfo->verboseStep_flag = true; // DEBUG. TO CHANGE - mArgsInfo->writeStep_flag = false; - mArgsInfo->input_given = 0; - // mArgsInfo->patient_given = 0; - mArgsInfo->output_given = 0; - mArgsInfo->outputTrachea_given = 0; - // mArgsInfo->remove1_given = 0; - - mArgsInfo->upper_arg = mAirUpperThresholdSlider->GetValue(); - mArgsInfo->lower_arg = mAirLowerThresholdSlider->GetValue(); - if (mRadioButtonLowerThan->isChecked()) mArgsInfo->lower_given = 1; -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractLung::apply() -{ - // Change cursor to wait - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - - // Read options from GUI and put it in the ArgsInfo struct - GetArgsInfoFromGUI(); - - // Check options - if (mArgsInfo->lower_given) { - if (mArgsInfo->lower_arg > mArgsInfo->upper_arg) { - QApplication::restoreOverrideCursor(); - QMessageBox::information(this,tr("Error"), "Lower threshold cannot be greater than upper threshold."); - return; - } - } - - // Create new filter - if (mFilter) delete mFilter; - mFilter = new FilterType; // needed when thread cancel the filter - // mFilter->StopOnErrorOff(); - // mFilter->SetIOVerbose(true); - mFilter->AddInputVVImage(mCurrentImage); // CT - mFilter->AddInputVVImage(mPatient); // patient mask - mFilter->SetArgsInfo(*mArgsInfo); - - // Created threaded execution - vvThreadedFilter thread; - connect(&thread, SIGNAL(ThreadInterrupted()), this, SLOT(ThreadInterrupted())); - thread.SetFilter(mFilter); - - try { - thread.Update(); - } - catch(std::runtime_error e) { - DD("Error exception handling"); - DD(m_IsThreadInterrupted); - // Check if the thread has been canceled. In this case, return - if (m_IsThreadInterrupted) { - m_IsThreadInterrupted = false; - QApplication::restoreOverrideCursor(); - return; - } - disconnect(&thread, SIGNAL(ThreadInterrupted()), this, SLOT(ThreadInterrupted())); - - // Check error during filter - // if (mFilter->HasError()) { - QApplication::restoreOverrideCursor(); - QMessageBox::information(this,tr("Error"), e.what());//mFilter->GetLastError().c_str()); - return; - // } - } // end exception - - // Get output - std::vector output = mFilter->GetOutputVVImages(); - if (output.size() == 0) { - std::cerr << "Error : no output ?" << std::endl; - QApplication::restoreOverrideCursor(); - close(); - return; - } - - // Set Lung into VV - vvImage::Pointer lung = output[0]; - std::ostringstream osstream; - osstream << "Lung_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; - vvSlicerManager * v = AddImage(lung,osstream.str()); - v->SetPreset(5); - vvToolStructureSetManager::AddImage(mCurrentSlicerManager, "Right lung", lung, 1, false); // Right is greater than Left - vvToolStructureSetManager::AddImage(mCurrentSlicerManager, "Left lung", lung, 2, false); - - // Set trachea into VV - if (output.size() == 2) { - vvImage::Pointer trachea = output[1]; - std::ostringstream osstream; - osstream << "Trachea_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; - vvSlicerManager * v = AddImage(trachea,osstream.str()); - v->SetPreset(5); - vvToolStructureSetManager::AddImage(mCurrentSlicerManager, "Trachea", trachea, 0); - } - - // End - QApplication::restoreOverrideCursor(); - close(); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -bool vvToolExtractLung::close() -{ - return vvToolWidgetBase::close(); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractLung::ThreadInterrupted() -{ - m_IsThreadInterrupted = true; -} -//------------------------------------------------------------------------------ - diff --git a/vv/vvToolExtractLung.h b/vv/vvToolExtractLung.h deleted file mode 100644 index 5693ad4..0000000 --- a/vv/vvToolExtractLung.h +++ /dev/null @@ -1,73 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -===========================================================================**/ - -#ifndef VVTOOLEXTRACTLUNG_H -#define VVTOOLEXTRACTLUNG_H - -// clitk -#include "clitkExtractLungGenericFilter.h" -#include "../segmentation/clitkExtractLung_ggo.h" - -// vv -#include "ui_vvToolExtractLung.h" -#include "vvToolBase.h" -#include "vvToolWidgetBase.h" -#include "vvROIActor.h" - -// qt -#include - -//------------------------------------------------------------------------------ -class vvToolExtractLung: - public vvToolWidgetBase, - public vvToolBase, - private Ui::vvToolExtractLung -{ - Q_OBJECT - public: - vvToolExtractLung(vvMainWindowBase* parent=0, Qt::WindowFlags f=0); - ~vvToolExtractLung(); - - //----------------------------------------------------- - static void Initialize(); - virtual void InputIsSelected(vvSlicerManager *m); - void GetArgsInfoFromGUI(); - void SetGUIFromArgsInfo(); - - //----------------------------------------------------- -public slots: - virtual void apply(); - virtual bool close(); - void PatientMaskInputIsSelected(); - void ThreadInterrupted(); - - //----------------------------------------------------- -protected: - typedef args_info_clitkExtractLung ArgsInfoType; - ArgsInfoType * mArgsInfo; - typedef clitk::ExtractLungGenericFilter FilterType; - FilterType * mFilter; - vvImage::Pointer mPatient; - double mPatientBackgroundValue; - bool m_IsThreadInterrupted; - -}; // end class vvToolExtractLung -//------------------------------------------------------------------------------ - -#endif - diff --git a/vv/vvToolExtractPatient.cxx b/vv/vvToolExtractPatient.cxx deleted file mode 100644 index d81b123..0000000 --- a/vv/vvToolExtractPatient.cxx +++ /dev/null @@ -1,260 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - ===========================================================================**/ - -// vv -#include "vvToolExtractPatient.h" -#include "vvToolStructureSetManager.h" -#include "vvSlicer.h" -#include "vvImageReader.h" -#include "vvImageWriter.h" -#include "vvLabelImageLoaderWidget.h" -#include "vvThreadedFilter.h" - -// Qt -#include - -//------------------------------------------------------------------------------ -// Create the tool and automagically (I like this word) insert it in -// the main window menu. -ADD_TOOL(vvToolExtractPatient); -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -vvToolExtractPatient::vvToolExtractPatient(vvMainWindowBase * parent, Qt::WindowFlags f): - vvToolWidgetBase(parent,f), - vvToolBase(parent), - Ui::vvToolExtractPatient() -{ - // GUI - Ui_vvToolExtractPatient::setupUi(mToolWidget); - mOptionsBox->setEnabled(true); - //connect(mPatientMaskInputWidget, SIGNAL(accepted()), this, SLOT(PatientMaskInputIsSelected())); - - // Default values - mArgsInfo = new ArgsInfoType; - cmdline_parser_clitkExtractPatient_init(mArgsInfo); - SetGUIFromArgsInfo(); - m_IsThreadInterrupted = false; - - // Create a new ExtractPatient filter - mFilter = new FilterType; // used in AddInputSelector - - // Add input selector - AddInputSelector("Select CT thorax image", mFilter); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -vvToolExtractPatient::~vvToolExtractPatient() -{ -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractPatient::Initialize() { - SetToolName("ExtractPatient"); - SetToolMenuName("Extract Patient"); - SetToolIconFilename(":/common/icons/Patient-overlay.png"); - SetToolTip("Extract Patient mask from thorax CT."); - SetToolExperimental(true); - // SetToolInMenu("Segmentation"); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractPatient::InputIsSelected(vvSlicerManager *m) -{ - // Hide selector - HideInputSelector(); // splitter - mToolInputSelectionWidget->hide(); - mCurrentSlicerManager = m; - mCurrentImage = m->GetImage(); - mLabelInput->setText(m->GetFileName().c_str()); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// void vvToolExtractPatient::PatientMaskInputIsSelected() -// { -// // Get Patient mask and BG value -// mPatient = mPatientMaskInputWidget->GetImage(); -// mPatientBackgroundValue = mPatientMaskInputWidget->GetBackgroundValue(); - -// // Check patient dimension -// if (mPatient->GetNumberOfDimensions() != 3) { -// QMessageBox::information(this,tr("*Error*"), "Mask image must be 3D"); -// return; -// } - -// mMaskLoaderBox->setEnabled(false); -// mOptionsBox->setEnabled(true); -// } -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractPatient::SetGUIFromArgsInfo() -{ - /* - mAirUpperThresholdSlider->SetText("Upper threshold for air"); - mAirUpperThresholdSlider->SetMinimum(-1200); - mAirUpperThresholdSlider->SetMaximum(2000); - DD(mArgsInfo->upper_arg); - mAirUpperThresholdSlider->SetValue(mArgsInfo->upper_arg); - - mAirLowerThresholdSlider->SetText("Lower threshold for air"); - mAirLowerThresholdSlider->SetMinimum(-1200); - mAirLowerThresholdSlider->SetMaximum(2000); - mAirLowerThresholdSlider->SetValue(mArgsInfo->lower_arg); - */ - -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractPatient::GetArgsInfoFromGUI() -{ - //mArgsInfo->patientBG_arg = mPatientMaskInputWidget->GetBackgroundValue(); - mArgsInfo->verboseOption_flag = true; // DEBUG. TO CHANGE - mArgsInfo->verboseStep_flag = true; // DEBUG. TO CHANGE - mArgsInfo->writeStep_flag = false; - mArgsInfo->input_given = 0; - //mArgsInfo->patient_given = 0; - mArgsInfo->output_given = 0; - //mArgsInfo->outputTrachea_given = 0; - //mArgsInfo->remove1_given = 0; - - // mArgsInfo->upper_arg = mAirUpperThresholdSlider->GetValue(); -// mArgsInfo->lower_arg = mAirLowerThresholdSlider->GetValue(); -// if (mRadioButtonLowerThan->isChecked()) mArgsInfo->lower_given = 1; -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractPatient::apply() -{ - // Change cursor to wait - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - - // Read options from GUI and put it in the ArgsInfo struct - GetArgsInfoFromGUI(); - - // Check options - // if (mArgsInfo->lower_given) { -// if (mArgsInfo->lower_arg > mArgsInfo->upper_arg) { -// QApplication::restoreOverrideCursor(); -// QMessageBox::information(this,tr("Error"), "Lower threshold cannot be greater than upper threshold."); -// return; -// } -// } - - // Create new filter - //if (mFilter) delete mFilter; - DD("new filter"); - mFilter = new FilterType; // needed when thread cancel the filter - // mFilter->StopOnErrorOff(); - // mFilter->SetIOVerbose(true); - mFilter->AddInputVVImage(mCurrentImage); // CT -// mFilter->AddInputVVImage(mPatient); // patient mask - mFilter->SetArgsInfo(*mArgsInfo); - - // Created threaded execution - DD("thread"); - vvThreadedFilter thread; - connect(&thread, SIGNAL(ThreadInterrupted()), this, SLOT(ThreadInterrupted())); - thread.SetFilter(mFilter); - - try { - thread.Update(); - } - catch(std::runtime_error e) { - - // Check if the thread has been canceled. In this case, return - if (m_IsThreadInterrupted) { - m_IsThreadInterrupted = false; - QApplication::restoreOverrideCursor(); - return; - } - disconnect(&thread, SIGNAL(ThreadInterrupted()), this, SLOT(ThreadInterrupted())); - - // Check error during filter - // if (mFilter->HasError()) { - QApplication::restoreOverrideCursor(); - QMessageBox::information(this,tr("Error"), e.what());//mFilter->GetLastError().c_str()); - return; - // } - - } - - // Get output - std::vector output = mFilter->GetOutputVVImages(); - if (output.size() == 0) { - std::cerr << "Error : no output ?" << std::endl; - QApplication::restoreOverrideCursor(); - close(); - return; - } - - // Set Patient into VV - vvImage::Pointer Patient = output[0]; - std::ostringstream osstream; - osstream << "Patient_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; - vvSlicerManager * v = AddImage(Patient,osstream.str()); - v->SetPreset(5); - vvToolStructureSetManager::AddImage(mCurrentSlicerManager, "Right Patient", Patient, 1, false); // Right is greater than Left -// vvToolStructureSetManager::AddImage(mCurrentSlicerManager, "Left Patient", Patient, 2, false); - - // // Set trachea into VV -// if (output.size() == 2) { -// vvImage::Pointer trachea = output[1]; -// std::ostringstream osstream; -// osstream << "Trachea_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; -// vvSlicerManager * v = AddImage(trachea,osstream.str()); -// v->SetPreset(5); -// vvToolStructureSetManager::AddImage(mCurrentSlicerManager, "Trachea", trachea, 0); -// } - - // End - QApplication::restoreOverrideCursor(); - close(); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -bool vvToolExtractPatient::close() -{ - return vvToolWidgetBase::close(); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractPatient::ThreadInterrupted() -{ - m_IsThreadInterrupted = true; -} -//------------------------------------------------------------------------------ - diff --git a/vv/vvToolExtractPatient.h b/vv/vvToolExtractPatient.h deleted file mode 100644 index b355d97..0000000 --- a/vv/vvToolExtractPatient.h +++ /dev/null @@ -1,73 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -===========================================================================**/ - -#ifndef VVTOOLEXTRACTPATIENT_H -#define VVTOOLEXTRACTPATIENT_H - -// clitk -#include "clitkExtractPatientGenericFilter.h" -#include "../segmentation/clitkExtractPatient_ggo.h" - -// vv -#include "ui_vvToolExtractPatient.h" -#include "vvToolBase.h" -#include "vvToolWidgetBase.h" -#include "vvROIActor.h" - -// qt -#include - -//------------------------------------------------------------------------------ -class vvToolExtractPatient: - public vvToolWidgetBase, - public vvToolBase, - private Ui::vvToolExtractPatient -{ - Q_OBJECT - public: - vvToolExtractPatient(vvMainWindowBase* parent=0, Qt::WindowFlags f=0); - ~vvToolExtractPatient(); - - //----------------------------------------------------- - static void Initialize(); - virtual void InputIsSelected(vvSlicerManager *m); - void GetArgsInfoFromGUI(); - void SetGUIFromArgsInfo(); - - //----------------------------------------------------- -public slots: - virtual void apply(); - virtual bool close(); - // void PatientMaskInputIsSelected(); - void ThreadInterrupted(); - - //----------------------------------------------------- -protected: - typedef args_info_clitkExtractPatient ArgsInfoType; - ArgsInfoType * mArgsInfo; - typedef clitk::ExtractPatientGenericFilter FilterType; - FilterType * mFilter; - vvImage::Pointer mPatient; - double mPatientBackgroundValue; - bool m_IsThreadInterrupted; - -}; // end class vvToolExtractPatient -//------------------------------------------------------------------------------ - -#endif -