Skip to content

Commit

Permalink
STYLE: Declare "PerThreadVariables" data member as std::vector
Browse files Browse the repository at this point in the history
Follow-up to pull request #644 commit 398cea9 "STYLE: Declared `m_ComputePerThreadVariables` as an `std::vector` (2 x)"
  • Loading branch information
N-Dekker committed May 12, 2022
1 parent fe4fe15 commit 1cd9bae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class ITK_TEMPLATE_EXPORT ParzenWindowHistogramImageToImageMetric
ParzenWindowHistogramImageToImageMetric();

/** The destructor. */
~ParzenWindowHistogramImageToImageMetric() override;
~ParzenWindowHistogramImageToImageMetric() override = default;

/** Print Self. */
void
Expand Down Expand Up @@ -501,9 +501,8 @@ class ITK_TEMPLATE_EXPORT ParzenWindowHistogramImageToImageMetric
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT,
PaddedParzenWindowHistogramGetValueAndDerivativePerThreadStruct,
AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct);
mutable AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct *
m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables;
mutable ThreadIdType m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariablesSize;
mutable std::vector<AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct>
m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables;

/** Variables that can/should be accessed by their Set/Get functions. */
unsigned long m_NumberOfFixedHistogramBins;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,9 @@ ParzenWindowHistogramImageToImageMetric<TFixedImage, TMovingImage>::ParzenWindow
/** Initialize the m_ParzenWindowHistogramThreaderParameters */
this->m_ParzenWindowHistogramThreaderParameters.m_Metric = this;

// Multi-threading structs
this->m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables = nullptr;
this->m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariablesSize = 0;

} // end Constructor


/**
* ******************* Destructor *******************
*/

template <class TFixedImage, class TMovingImage>
ParzenWindowHistogramImageToImageMetric<TFixedImage, TMovingImage>::~ParzenWindowHistogramImageToImageMetric()
{
delete[] this->m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables;
} // end Destructor


/**
* ********************* PrintSelf ******************************
*/
Expand Down Expand Up @@ -458,22 +443,15 @@ ParzenWindowHistogramImageToImageMetric<TFixedImage, TMovingImage>::InitializeTh
const ThreadIdType numberOfThreads = Self::GetNumberOfWorkUnits();

/** Only resize the array of structs when needed. */
if (this->m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariablesSize != numberOfThreads)
{
delete[] this->m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables;
this->m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables =
new AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct[numberOfThreads];
this->m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariablesSize = numberOfThreads;
}
m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables.resize(numberOfThreads);

/** Some initialization. */
for (ThreadIdType i = 0; i < numberOfThreads; ++i)
for (auto & perThreadVariable : m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables)
{
this->m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables[i].st_NumberOfPixelsCounted =
NumericTraits<SizeValueType>::Zero;
perThreadVariable.st_NumberOfPixelsCounted = 0;

// Initialize the joint pdf
JointPDFPointer & jointPDF = this->m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables[i].st_JointPDF;
JointPDFPointer & jointPDF = perThreadVariable.st_JointPDF;
if (jointPDF.IsNull())
{
jointPDF = JointPDFType::New();
Expand Down

0 comments on commit 1cd9bae

Please sign in to comment.