Skip to content

Commit

Permalink
STYLE: Make data ImageMomentsCalculator, ComputeDisplacementDist private
Browse files Browse the repository at this point in the history
Made data members of `AdvancedImageMomentsCalculator` and `ComputeDisplacementDistribution` private, including their `m_ComputePerThreadVariables` member.

Based on the first commit of pull request #132 "Improved style of m_ComputePerThreadVariable data members".

Follows C++ Core Guidelines (April 10, 2022): "C.133: Avoid protected data" http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rh-protected
  • Loading branch information
N-Dekker committed May 5, 2022
1 parent 665a197 commit ab0c8df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
25 changes: 14 additions & 11 deletions Common/Transforms/itkAdvancedImageMomentsCalculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ class ITK_TEMPLATE_EXPORT AdvancedImageMomentsCalculator : public Object
/** Typedefs for multi-threading. */
using ThreaderType = itk::PlatformMultiThreader;
using ThreadInfoType = ThreaderType::WorkUnitInfo;
ThreaderType::Pointer m_Threader;

/** Launch MultiThread Compute. */
void
Expand All @@ -280,7 +279,6 @@ class ITK_TEMPLATE_EXPORT AdvancedImageMomentsCalculator : public Object
{
Self * st_Self;
};
mutable MultiThreaderParameterType m_ThreaderParameters;

struct ComputePerThreadStruct
{
Expand All @@ -294,19 +292,10 @@ class ITK_TEMPLATE_EXPORT AdvancedImageMomentsCalculator : public Object
};
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, ComputePerThreadStruct, PaddedComputePerThreadStruct);
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedComputePerThreadStruct, AlignedComputePerThreadStruct);
mutable AlignedComputePerThreadStruct * m_ComputePerThreadVariables;
mutable ThreadIdType m_ComputePerThreadVariablesSize;
bool m_UseMultiThread;
SizeValueType m_NumberOfPixelsCounted;

/** The type of region used for multithreading */
using ThreadRegionType = typename ImageType::RegionType;

SizeValueType m_NumberOfSamplesForCenteredTransformInitialization;
InputPixelType m_LowerThresholdForCenterGravity;
bool m_CenterOfGravityUsesLowerThreshold;
ImageSampleContainerPointer m_SampleContainer;

private:
/** Internal helper function. Does post processing at the end of
* ComputeSingleThreaded() and AfterThreadedCompute() */
Expand All @@ -317,6 +306,20 @@ class ITK_TEMPLATE_EXPORT AdvancedImageMomentsCalculator : public Object
void
operator=(const Self &);

ThreaderType::Pointer m_Threader;

mutable MultiThreaderParameterType m_ThreaderParameters;

mutable AlignedComputePerThreadStruct * m_ComputePerThreadVariables;
mutable ThreadIdType m_ComputePerThreadVariablesSize;
bool m_UseMultiThread;
SizeValueType m_NumberOfPixelsCounted;

SizeValueType m_NumberOfSamplesForCenteredTransformInitialization;
InputPixelType m_LowerThresholdForCenterGravity;
bool m_CenterOfGravityUsesLowerThreshold;
ImageSampleContainerPointer m_SampleContainer;

bool m_Valid; // Have moments been computed yet?
ScalarType m_M0; // Zeroth moment
VectorType m_M1; // First moments about origin
Expand Down
7 changes: 4 additions & 3 deletions Common/itkComputeDisplacementDistribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ class ITK_TEMPLATE_EXPORT ComputeDisplacementDistribution : public ScaledSingleV
{
Self * st_Self;
};
mutable MultiThreaderParameterType m_ThreaderParameters;

struct ComputePerThreadStruct
{
/** Used for accumulating variables. */
Expand All @@ -212,14 +210,17 @@ class ITK_TEMPLATE_EXPORT ComputeDisplacementDistribution : public ScaledSingleV
};
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, ComputePerThreadStruct, PaddedComputePerThreadStruct);
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedComputePerThreadStruct, AlignedComputePerThreadStruct);

private:
mutable MultiThreaderParameterType m_ThreaderParameters;

mutable AlignedComputePerThreadStruct * m_ComputePerThreadVariables;
mutable ThreadIdType m_ComputePerThreadVariablesSize;

SizeValueType m_NumberOfPixelsCounted;
bool m_UseMultiThread;
ImageSampleContainerPointer m_SampleContainer;

private:
ComputeDisplacementDistribution(const Self &) = delete;
void
operator=(const Self &) = delete;
Expand Down

0 comments on commit ab0c8df

Please sign in to comment.