Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Modules/Core/Common/test/itkIteratorTests.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ itkIteratorTests(int, char *[])
unsigned short * ptr = o3->GetBufferPointer();
memset(ptr, 0, num * sizeof(unsigned short));
clock_t end = clock();
double elapsedTime = (end - start) / static_cast<double>(CLOCKS_PER_SEC);
double elapsedTime = (end - start) / double{ CLOCKS_PER_SEC };

std::cout << "Raw pointer using memset" << std::endl;
std::cout << "\tTime = " << elapsedTime << std::endl;
Expand All @@ -83,7 +83,7 @@ itkIteratorTests(int, char *[])
}
end = clock();
*ptr = 0;
elapsedTime = (end - start) / static_cast<double>(CLOCKS_PER_SEC);
elapsedTime = (end - start) / double{ CLOCKS_PER_SEC };

std::cout << "Raw pointer as a 1D array" << std::endl;
std::cout << "\tTime = " << elapsedTime << std::endl;
Expand All @@ -109,7 +109,7 @@ itkIteratorTests(int, char *[])
++i;
}
end = clock();
elapsedTime = (end - start) / static_cast<double>(CLOCKS_PER_SEC);
elapsedTime = (end - start) / double{ CLOCKS_PER_SEC };

std::cout << "Raw pointer in 3 nested loops" << std::endl;
std::cout << "\tTime = " << elapsedTime << std::endl;
Expand All @@ -134,7 +134,7 @@ itkIteratorTests(int, char *[])
++i;
}
end = clock();
elapsedTime = (end - start) / static_cast<double>(CLOCKS_PER_SEC);
elapsedTime = (end - start) / double{ CLOCKS_PER_SEC };

std::cout << "ImageRegionIterator" << std::endl;
std::cout << "\tTime = " << elapsedTime << std::endl;
Expand All @@ -156,7 +156,7 @@ itkIteratorTests(int, char *[])
++i;
}
end = clock();
elapsedTime = (end - start) / static_cast<double>(CLOCKS_PER_SEC);
elapsedTime = (end - start) / double{ CLOCKS_PER_SEC };

std::cout << "ImageRegionIteratorWithIndex" << std::endl;
std::cout << "\tTime = " << elapsedTime << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ constexpr int V_DEPTH = 64;
float
sphere(float x, float y, float z)
{
const float dis = (x - static_cast<float>(V_WIDTH) / 2.0) * (x - static_cast<float>(V_WIDTH) / 2.0) /
((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) +
(y - static_cast<float>(V_HEIGHT) / 2.0) * (y - static_cast<float>(V_HEIGHT) / 2.0) /
((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) +
(z - static_cast<float>(V_DEPTH) / 2.0) * (z - static_cast<float>(V_DEPTH) / 2.0) /
((0.2f * V_DEPTH) * (0.2f * V_DEPTH));
const float dis =
(x - float{ V_WIDTH } / 2.0) * (x - float{ V_WIDTH } / 2.0) / ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) +
(y - float{ V_HEIGHT } / 2.0) * (y - float{ V_HEIGHT } / 2.0) / ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) +
(z - float{ V_DEPTH } / 2.0) * (z - float{ V_DEPTH } / 2.0) / ((0.2f * V_DEPTH) * (0.2f * V_DEPTH));
return (1.0f - dis);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ CustomColormapFunction<TScalar, TRGBPixel>::operator()(const TScalar & v) const
RGBPixelType pixel;
NumericTraits<TRGBPixel>::SetLength(pixel, 3);

for (auto color = static_cast<size_t>(RED); color <= static_cast<size_t>(BLUE); ++color)
for (auto color = size_t{ RED }; color <= size_t{ BLUE }; ++color)
{
pixel[color] = this->RescaleRGBComponentValue(RGBValue[color]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ itkObjectMorphologyImageFilterTest(int, char *[])

end = clock();

elapsedTime = (end - start) / static_cast<double>(CLOCKS_PER_SEC);
elapsedTime = (end - start) / double{ CLOCKS_PER_SEC };

// Print the content of the result image
std::cout << " Success: " << std::endl;
Expand All @@ -174,7 +174,7 @@ itkObjectMorphologyImageFilterTest(int, char *[])

end = clock();

elapsedTime = (end - start) / static_cast<double>(CLOCKS_PER_SEC);
elapsedTime = (end - start) / double{ CLOCKS_PER_SEC };

// Print the content of the result image
std::cout << " Success: " << std::endl;
Expand Down Expand Up @@ -214,7 +214,7 @@ itkObjectMorphologyImageFilterTest(int, char *[])
++count;
}
end = clock();
elapsedTime = (end - start) / static_cast<double>(CLOCKS_PER_SEC);
elapsedTime = (end - start) / double{ CLOCKS_PER_SEC };
std::cout << " Success: " << std::endl;
std::cout << " Time = " << elapsedTime << std::endl;

Expand All @@ -241,7 +241,7 @@ itkObjectMorphologyImageFilterTest(int, char *[])

end = clock();

elapsedTime = (end - start) / static_cast<double>(CLOCKS_PER_SEC);
elapsedTime = (end - start) / double{ CLOCKS_PER_SEC };

// Print the content of the result image
std::cout << " Success: " << std::endl;
Expand All @@ -262,7 +262,7 @@ itkObjectMorphologyImageFilterTest(int, char *[])

end = clock();

elapsedTime = (end - start) / static_cast<double>(CLOCKS_PER_SEC);
elapsedTime = (end - start) / double{ CLOCKS_PER_SEC };

// Print the content of the result image
std::cout << " Success: " << std::endl;
Expand Down Expand Up @@ -302,7 +302,7 @@ itkObjectMorphologyImageFilterTest(int, char *[])
++count;
}
end = clock();
elapsedTime = (end - start) / static_cast<double>(CLOCKS_PER_SEC);
elapsedTime = (end - start) / double{ CLOCKS_PER_SEC };
std::cout << " Success: " << std::endl;
std::cout << " Time = " << elapsedTime << std::endl;

Expand Down
4 changes: 2 additions & 2 deletions Modules/IO/NIFTI/src/itkNiftiImageIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1515,8 +1515,8 @@ NiftiImageIO::WriteImageInformation()
// external tools believe that the time units must be set, even if there
// is only one dataset. Having the time specified for a purely spatial
// image has no consequence, so go ahead and set it to seconds.
this->m_NiftiImage->xyz_units = static_cast<int>(NIFTI_UNITS_MM);
this->m_NiftiImage->time_units = static_cast<int>(NIFTI_UNITS_SEC);
this->m_NiftiImage->xyz_units = int{ NIFTI_UNITS_MM };
this->m_NiftiImage->time_units = int{ NIFTI_UNITS_SEC };
this->m_NiftiImage->dim[7] = this->m_NiftiImage->nw = 1;
this->m_NiftiImage->dim[6] = this->m_NiftiImage->nv = 1;
this->m_NiftiImage->dim[5] = this->m_NiftiImage->nu = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ ImageKmeansModelEstimator<TInputImage, TMembershipFunction>::Perturb(double * ol
for (unsigned int i = 0; i < m_VectorDimension; ++i)
{
srand(static_cast<unsigned int>(time(nullptr)));
const double rand_num = (rand()) / (static_cast<double>(RAND_MAX));
const double rand_num = (rand()) / (double{ RAND_MAX });

if (oldCodeword[i] == 0.0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,20 @@ constexpr int V_DEPTH = 64;
float
sphere(float x, float y, float z)
{
const float dis = (x - static_cast<float>(V_WIDTH) / 2.0) * (x - static_cast<float>(V_WIDTH) / 2.0) /
((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) +
(y - static_cast<float>(V_HEIGHT) / 2.0) * (y - static_cast<float>(V_HEIGHT) / 2.0) /
((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) +
(z - static_cast<float>(V_DEPTH) / 2.0) * (z - static_cast<float>(V_DEPTH) / 2.0) /
((0.2f * V_DEPTH) * (0.2f * V_DEPTH));
const float dis =
(x - float{ V_WIDTH } / 2.0) * (x - float{ V_WIDTH } / 2.0) / ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) +
(y - float{ V_HEIGHT } / 2.0) * (y - float{ V_HEIGHT } / 2.0) / ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) +
(z - float{ V_DEPTH } / 2.0) * (z - float{ V_DEPTH } / 2.0) / ((0.2f * V_DEPTH) * (0.2f * V_DEPTH));
return (1.0f - dis);
}

float
sphere2(float x, float y, float z)
{
const float dis = (x - static_cast<float>(V_WIDTH) / 2.1) * (x - static_cast<float>(V_WIDTH) / 2.1) /
((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) +
(y - static_cast<float>(V_HEIGHT) / 2.0) * (y - static_cast<float>(V_HEIGHT) / 2.0) /
((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) +
(z - static_cast<float>(V_DEPTH) / 2.0) * (z - static_cast<float>(V_DEPTH) / 2.0) /
((0.2f * V_DEPTH) * (0.2f * V_DEPTH));
const float dis =
(x - float{ V_WIDTH } / 2.1) * (x - float{ V_WIDTH } / 2.1) / ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) +
(y - float{ V_HEIGHT } / 2.0) * (y - float{ V_HEIGHT } / 2.0) / ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) +
(z - float{ V_DEPTH } / 2.0) * (z - float{ V_DEPTH } / 2.0) / ((0.2f * V_DEPTH) * (0.2f * V_DEPTH));
return (1.0f - dis);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,20 @@ constexpr int V_DEPTH = 64;
float
sphere(float x, float y, float z)
{
const float dis = (x - static_cast<float>(V_WIDTH) / 2.0) * (x - static_cast<float>(V_WIDTH) / 2.0) /
((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) +
(y - static_cast<float>(V_HEIGHT) / 2.0) * (y - static_cast<float>(V_HEIGHT) / 2.0) /
((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) +
(z - static_cast<float>(V_DEPTH) / 2.0) * (z - static_cast<float>(V_DEPTH) / 2.0) /
((0.2f * V_DEPTH) * (0.2f * V_DEPTH));
const float dis =
(x - float{ V_WIDTH } / 2.0) * (x - float{ V_WIDTH } / 2.0) / ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) +
(y - float{ V_HEIGHT } / 2.0) * (y - float{ V_HEIGHT } / 2.0) / ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) +
(z - float{ V_DEPTH } / 2.0) * (z - float{ V_DEPTH } / 2.0) / ((0.2f * V_DEPTH) * (0.2f * V_DEPTH));
return (1.0f - dis);
}

float
sphere2(float x, float y, float z)
{
const float dis = (x - static_cast<float>(V_WIDTH) / 2.1) * (x - static_cast<float>(V_WIDTH) / 2.1) /
((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) +
(y - static_cast<float>(V_HEIGHT) / 2.0) * (y - static_cast<float>(V_HEIGHT) / 2.0) /
((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) +
(z - static_cast<float>(V_DEPTH) / 2.0) * (z - static_cast<float>(V_DEPTH) / 2.0) /
((0.2f * V_DEPTH) * (0.2f * V_DEPTH));
const float dis =
(x - float{ V_WIDTH } / 2.1) * (x - float{ V_WIDTH } / 2.1) / ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) +
(y - float{ V_HEIGHT } / 2.0) * (y - float{ V_HEIGHT } / 2.0) / ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) +
(z - float{ V_DEPTH } / 2.0) * (z - float{ V_DEPTH } / 2.0) / ((0.2f * V_DEPTH) * (0.2f * V_DEPTH));
return (1.0f - dis);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ constexpr unsigned int WIDTH = (256);
float
circle(unsigned int x, unsigned int y)
{
float dis = (x - static_cast<float>(WIDTH) / 2.0) * (x - static_cast<float>(WIDTH) / 2.0) +
(y - static_cast<float>(HEIGHT) / 2.0) * (y - static_cast<float>(HEIGHT) / 2.0);
float dis =
(x - float{ WIDTH } / 2.0) * (x - float{ WIDTH } / 2.0) + (y - float{ HEIGHT } / 2.0) * (y - float{ HEIGHT } / 2.0);
dis = RADIUS - std::sqrt(dis);
return dis;
}
Expand All @@ -55,8 +55,8 @@ circle(unsigned int x, unsigned int y)
float
square(unsigned int x, unsigned int y)
{
const float X = itk::Math::abs(x - static_cast<float>(WIDTH) / 2.0);
const float Y = itk::Math::abs(y - static_cast<float>(HEIGHT) / 2.0);
const float X = itk::Math::abs(x - float{ WIDTH } / 2.0);
const float Y = itk::Math::abs(y - float{ HEIGHT } / 2.0);
float dis;
if (!((X > RADIUS) && (Y > RADIUS)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ constexpr int V_DEPTH = 64;
float
sphere(float x, float y, float z)
{
const float dis = (x - static_cast<float>(V_WIDTH) / 2.0) * (x - static_cast<float>(V_WIDTH) / 2.0) /
((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) +
(y - static_cast<float>(V_HEIGHT) / 2.0) * (y - static_cast<float>(V_HEIGHT) / 2.0) /
((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) +
(z - static_cast<float>(V_DEPTH) / 2.0) * (z - static_cast<float>(V_DEPTH) / 2.0) /
((0.2f * V_DEPTH) * (0.2f * V_DEPTH));
const float dis =
(x - float{ V_WIDTH } / 2.0) * (x - float{ V_WIDTH } / 2.0) / ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) +
(y - float{ V_HEIGHT } / 2.0) * (y - float{ V_HEIGHT } / 2.0) / ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) +
(z - float{ V_DEPTH } / 2.0) * (z - float{ V_DEPTH } / 2.0) / ((0.2f * V_DEPTH) * (0.2f * V_DEPTH));
return (1.0f - dis);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ constexpr int RADIUS = (std::min(std::min(HEIGHT, WIDTH), DEPTH) / 4);
float
sphere(unsigned int x, unsigned int y, unsigned int z)
{
float dis = (x - static_cast<float>(WIDTH) / 2.0) * (x - static_cast<float>(WIDTH) / 2.0) +
(y - static_cast<float>(HEIGHT) / 2.0) * (y - static_cast<float>(HEIGHT) / 2.0) +
(z - static_cast<float>(DEPTH) / 2.0) * (z - static_cast<float>(DEPTH) / 2.0);
float dis = (x - float{ WIDTH } / 2.0) * (x - float{ WIDTH } / 2.0) +
(y - float{ HEIGHT } / 2.0) * (y - float{ HEIGHT } / 2.0) +
(z - float{ DEPTH } / 2.0) * (z - float{ DEPTH } / 2.0);
dis = RADIUS - std::sqrt(dis);
return (-dis);
}
Expand All @@ -59,9 +59,9 @@ sphere(unsigned int x, unsigned int y, unsigned int z)
float
cube(unsigned int x, unsigned int y, unsigned int z)
{
const float X = itk::Math::abs(x - static_cast<float>(WIDTH) / 2.0);
const float Y = itk::Math::abs(y - static_cast<float>(HEIGHT) / 2.0);
const float Z = itk::Math::abs(z - static_cast<float>(DEPTH) / 2.0);
const float X = itk::Math::abs(x - float{ WIDTH } / 2.0);
const float Y = itk::Math::abs(y - float{ HEIGHT } / 2.0);
const float Z = itk::Math::abs(z - float{ DEPTH } / 2.0);
float dis;
if (!((X > RADIUS) && (Y > RADIUS) && (Z > RADIUS)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ constexpr unsigned int WIDTH = (128);
float
square(unsigned int x, unsigned int y)
{
const float X = itk::Math::abs(x - static_cast<float>(WIDTH) / 2.0);
const float Y = itk::Math::abs(y - static_cast<float>(HEIGHT) / 2.0);
const float X = itk::Math::abs(x - float{ WIDTH } / 2.0);
const float Y = itk::Math::abs(y - float{ HEIGHT } / 2.0);
float dis;
if (!((X > RADIUS) && (Y > RADIUS)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ constexpr int V_DEPTH = 64;
float
sphere(float x, float y, float z)
{
const float dis = (x - static_cast<float>(V_WIDTH) / 2.0) * (x - static_cast<float>(V_WIDTH) / 2.0) /
((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) +
(y - static_cast<float>(V_HEIGHT) / 2.0) * (y - static_cast<float>(V_HEIGHT) / 2.0) /
((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) +
(z - static_cast<float>(V_DEPTH) / 2.0) * (z - static_cast<float>(V_DEPTH) / 2.0) /
((0.2f * V_DEPTH) * (0.2f * V_DEPTH));
const float dis =
(x - float{ V_WIDTH } / 2.0) * (x - float{ V_WIDTH } / 2.0) / ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) +
(y - float{ V_HEIGHT } / 2.0) * (y - float{ V_HEIGHT } / 2.0) / ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) +
(z - float{ V_DEPTH } / 2.0) * (z - float{ V_DEPTH } / 2.0) / ((0.2f * V_DEPTH) * (0.2f * V_DEPTH));
return (1.0f - dis);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ constexpr unsigned int WIDTH = (128);
float
square(unsigned int x, unsigned int y)
{
const float X = itk::Math::abs(x - static_cast<float>(WIDTH) / 2.0);
const float Y = itk::Math::abs(y - static_cast<float>(HEIGHT) / 2.0);
const float X = itk::Math::abs(x - float{ WIDTH } / 2.0);
const float Y = itk::Math::abs(y - float{ HEIGHT } / 2.0);
float dis;
if (!((X > RADIUS) && (Y > RADIUS)))
{
Expand Down
Loading