X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkInvertVFFilter.txx;h=6c91dbb9ebf4fa14d72a411b5bf0fad28ef42986;hb=1c6241402b25efea0052f0464be9a494e761b19e;hp=ec3c90fe31b8e4532ec81f02632daf9621ad3214;hpb=7bcf6cdd7f0962768ce55ae0ed62d4830d2a2c0b;p=clitk.git diff --git a/itk/clitkInvertVFFilter.txx b/itk/clitkInvertVFFilter.txx index ec3c90f..6c91dbb 100644 --- a/itk/clitkInvertVFFilter.txx +++ b/itk/clitkInvertVFFilter.txx @@ -47,7 +47,9 @@ public: //Typedefs typedef typename OutputImageType::PixelType PixelType; typedef itk::Image WeightsImageType; - typedef itk::Image MutexImageType; +#if ITK_VERSION_MAJOR <= 4 + typedef itk::Image MutexImageType; +#endif //=================================================================================== //Set methods @@ -55,11 +57,18 @@ public: m_Weights = input; this->Modified(); } +#if ITK_VERSION_MAJOR <= 4 void SetMutexImage(const typename MutexImageType::Pointer input) { m_MutexImage=input; this->Modified(); m_ThreadSafe=true; } +#else + void SetMutexImage() { + this->Modified(); + m_ThreadSafe=true; + } +#endif //Get methods typename WeightsImageType::Pointer GetWeights() { @@ -79,7 +88,11 @@ protected: //member data typename WeightsImageType::Pointer m_Weights; +#if ITK_VERSION_MAJOR <= 4 typename MutexImageType::Pointer m_MutexImage; +#else + std::mutex m_Mutex; +#endif bool m_ThreadSafe; }; @@ -215,14 +228,22 @@ void HelperClass1::ThreadedGenerateData(const O else { //Entering critilal section: shared memory +#if ITK_VERSION_MAJOR <= 4 m_MutexImage->GetPixel(neighIndex).Lock(); +#else + m_Mutex.lock(); +#endif //Set the pixel and weight at neighIndex outputPtr->SetPixel(neighIndex, outputPtr->GetPixel(neighIndex) - (displacement*overlap)); m_Weights->SetPixel(neighIndex, m_Weights->GetPixel(neighIndex) + overlap); //Unlock +#if ITK_VERSION_MAJOR <= 4 m_MutexImage->GetPixel(neighIndex).Unlock(); +#else + m_Mutex.unlock(); +#endif } //Add to total overlap @@ -451,11 +472,15 @@ template void InvertVFFilterSetRegions(region); mutex->Allocate(); mutex->SetSpacing(inputPtr->GetSpacing()); helper1->SetMutexImage(mutex); +#else + helper1->SetMutexImage(); +#endif if (m_Verbose) std::cout <<"Inverting using a thread-safe algorithm" <