X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkForwardWarpImageFilter.txx;h=4c38b5a5e3d5a627668de493c6cefccb6e2d5021;hb=1c6241402b25efea0052f0464be9a494e761b19e;hp=88804f5248175517f578612382685981deb88277;hpb=7bcf6cdd7f0962768ce55ae0ed62d4830d2a2c0b;p=clitk.git diff --git a/itk/clitkForwardWarpImageFilter.txx b/itk/clitkForwardWarpImageFilter.txx index 88804f5..4c38b5a 100644 --- a/itk/clitkForwardWarpImageFilter.txx +++ b/itk/clitkForwardWarpImageFilter.txx @@ -53,7 +53,9 @@ public: //Typedefs typedef typename OutputImageType::PixelType OutputPixelType; typedef itk::Image WeightsImageType; - typedef itk::Image MutexImageType; +#if ITK_VERSION_MAJOR <= 4 + typedef itk::Image MutexImageType; +#endif //=================================================================================== //Set methods void SetWeights(const typename WeightsImageType::Pointer input) { @@ -64,11 +66,18 @@ public: m_DeformationField=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() { @@ -89,7 +98,11 @@ protected: //member data typename itk::Image< double, ImageDimension>::Pointer m_Weights; typename DeformationFieldType::Pointer m_DeformationField; +#if ITK_VERSION_MAJOR <= 4 typename MutexImageType::Pointer m_MutexImage; +#else + std::mutex m_Mutex; +#endif bool m_ThreadSafe; }; @@ -224,14 +237,22 @@ void HelperClass1::Thread } 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) + overlap * static_cast(inputIt.Get())); 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 @@ -459,11 +480,15 @@ void ForwardWarpImageFilterSetRegions(region); mutex->Allocate(); mutex->SetSpacing(inputPtr->GetSpacing()); helper1->SetMutexImage(mutex); +#else + helper1->SetMutexImage(); +#endif if (m_Verbose) std::cout <<"Forwarp warping using a thread-safe algorithm" <