Commit a01fc64a authored by Sean McBride's avatar Sean McBride Committed by Kitware Robot

Merge topic 'vtkMathReview'

b889b631 Introduce VTK's first use of C++11's std::lround() (in a test)
27579ded Deprecated non-thread-safe colour conversion functions
f98c02bb Code review of vtkMath clamping
b4f84fe1 Added const to various vtkMath API
a7ceef61 Replace some int with vtkTypeBool (if public) or bool (if private)
a440133b General code review of vtkMath: trivial & conservative
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: David Gobbi's avatarDavid Gobbi <david.gobbi@gmail.com>
Merge-request: !3299
parents 6144e9eb b889b631
......@@ -607,7 +607,6 @@ static int TestColorConvert(const Triple &rgb, const Triple &hsv,
cout << " CIE-L*ab: " << lab << endl;
Triple result1;
double *result2;
#define COMPARE(testname, target, dest) \
if ((target) != (dest)) \
......@@ -623,11 +622,6 @@ static int TestColorConvert(const Triple &rgb, const Triple &hsv,
vtkMath::HSVToRGB(hsv(), result1());
COMPARE(HSVToRGB, rgb, result1);
result2 = vtkMath::RGBToHSV(rgb());
COMPARE(RGBToHSV, hsv, result2);
result2 = vtkMath::HSVToRGB(hsv());
COMPARE(HSVToRGB, rgb, result2);
vtkMath::RGBToHSV(rgb[0], rgb[1], rgb[2],
&result1[0], &result1[1], &result1[2]);
COMPARE(RGBToHSV, hsv, result1);
......@@ -641,11 +635,6 @@ static int TestColorConvert(const Triple &rgb, const Triple &hsv,
vtkMath::XYZToRGB(xyz(), result1());
COMPARE(XYZToRGB, rgb, result1);
result2 = vtkMath::RGBToXYZ(rgb());
COMPARE(RGBToXYZ, xyz, result2);
result2 = vtkMath::XYZToRGB(xyz());
COMPARE(XYZToRGB, rgb, result2);
vtkMath::RGBToXYZ(rgb[0], rgb[1], rgb[2],
&result1[0], &result1[1], &result1[2]);
COMPARE(RGBToXYZ, xyz, result1);
......@@ -659,11 +648,6 @@ static int TestColorConvert(const Triple &rgb, const Triple &hsv,
vtkMath::XYZToLab(xyz(), result1());
COMPARE(XYZToLab, lab, result1);
result2 = vtkMath::LabToXYZ(lab());
COMPARE(LabToXYZ, xyz, result2);
result2 = vtkMath::XYZToLab(xyz());
COMPARE(XYZToLab, lab, result2);
vtkMath::LabToXYZ(lab[0], lab[1], lab[2],
&result1[0], &result1[1], &result1[2]);
COMPARE(LabToXYZ, xyz, result1);
......@@ -677,11 +661,6 @@ static int TestColorConvert(const Triple &rgb, const Triple &hsv,
vtkMath::RGBToLab(rgb(), result1());
COMPARE(RGBToLab, lab, result1);
result2 = vtkMath::LabToRGB(lab());
COMPARE(LabToRGB, rgb, result2);
result2 = vtkMath::RGBToLab(rgb());
COMPARE(RGBToLab, lab, result2);
vtkMath::LabToRGB(lab[0], lab[1], lab[2],
&result1[0], &result1[1], &result1[2]);
COMPARE(LabToRGB, rgb, result1);
......
......@@ -23,10 +23,6 @@
#include <vector>
static int TestPi();
#if 0
static int TestDoublePi();
static int TestDoubleTwoPi();
#endif
static int TestDegreesFromRadians();
static int TestRound();
static int TestFloor();
......@@ -98,11 +94,6 @@ int UnitTestMath(int,char *[])
status += TestPi();
#if 0
status += TestDoublePi(); // legacy
status += TestDoubleTwoPi(); // legacy
#endif
status += TestDegreesFromRadians();
status += TestRound();
status += TestFloor();
......@@ -202,56 +193,6 @@ int TestPi()
return status;
}
#if 0
// Validate by comparing to atan/4
int TestDoublePi()
{
int status = 0;
std::cout << "DoublePi..";
if (vtkMath::DoublePi() != std::atan(1.0) * 4.0)
{
std::cout << "Expected " << vtkMath::Pi()
<< " but got " << std::atan(1.0) * 4.0;
++status;
}
if (status)
{
std::cout << "..FAILED" << std::endl;
}
else
{
std::cout << ".PASSED" << std::endl;
}
return status;
}
// Validate by comparing to atan/4 * 2
int TestDoubleTwoPi()
{
int status = 0;
std::cout << "DoubleTwoPi..";
if (vtkMath::DoubleTwoPi() != std::atan(1.0) * 4.0 * 2.0)
{
std::cout << "Expected " << vtkMath::Pi() * 2.0
<< " but got " << std::atan(1.0) * 4.0 * 2.0;
++status;
}
if (status)
{
std::cout << "..FAILED" << std::endl;
}
else
{
std::cout << ".PASSED" << std::endl;
}
return status;
}
#endif
// Validate against RadiansFromDegress
int TestDegreesFromRadians()
{
......
This diff is collapsed.
This diff is collapsed.
......@@ -50,8 +50,8 @@ static vtkSmartPointer<vtkRectilinearGrid> MakeRectilinearGrid()
int extent[6];
for (int i = 0; i < 6; i += 2)
{
extent[i] = vtkMath::Round(vtkMath::Random(-10, 10));
extent[i+1] = extent[i] + vtkMath::Round(vtkMath::Random(0, 10));
extent[i] = std::lround(vtkMath::Random(-10, 10));
extent[i+1] = extent[i] + std::lround(vtkMath::Random(0, 10));
}
grid->SetExtent(extent);
......
......@@ -53,9 +53,10 @@ public:
for (int i = 0; i < nDensityValues; i++)
{
this->DensityMapValues.push_back(densityValues[i]);
double* rgb = vtkMath::HSVToRGB(densityValues[i], 1, 0.75);
double r, g, b;
vtkMath::HSVToRGB(densityValues[i], 1, 0.75, &r, &g, &b);
this->DensityMapColorMap.insert(
std::make_pair(densityValues[i], vtkColor4ub(rgb[0] * 255, rgb[1] * 255, rgb[2] * 255)));
std::make_pair(densityValues[i], vtkColor4ub(r * 255, g * 255, b * 255)));
}
}
~DensityMapSettings() {}
......
......@@ -109,8 +109,12 @@ int TestCompositePolyDataMapper2(int argc, char* argv[])
// test not setting it on some
if (block % 11)
{
mapper->SetBlockColor(parent+numLeaves+1,
vtkMath::HSVToRGB(0.8*block/nblocks, 0.2 + 0.8*((parent - levelStart) % 8)/7.0, 1.0));
double rgb[3];
vtkMath::HSVToRGB(0.8*block/nblocks,
0.2 + 0.8*((parent - levelStart) % 8)/7.0,
1.0,
rgb+0, rgb+1, rgb+2);
mapper->SetBlockColor(parent+numLeaves+1, rgb);
// mapper->SetBlockOpacity(parent+numLeaves, (block + 3) % 7 == 0 ? 0.3 : 1.0);
mapper->SetBlockVisibility(parent+numLeaves, (block % 7) != 0);
}
......@@ -140,10 +144,11 @@ int TestCompositePolyDataMapper2(int argc, char* argv[])
// comment the following in/out for worst/best case
// for (int i = 0; i < 20000; ++i)
// {
// mapper->SetBlockColor(i,
// vtkMath::HSVToRGB(0.8*(i%100)/100.0, 1.0, 1.0));
// }
// {
// double r, g, b;
// vtkMath::HSVToRGB(0.8*(i%100)/100.0, 1.0, 1.0, &r, &g, &b);
// mapper->SetBlockColor(i, r, g, b);
// }
#endif
......
......@@ -104,8 +104,10 @@ int TestOSPRayCompositePolyDataMapper2(int argc, char* argv[])
// test not setting it on some
if (block % 11)
{
mapper->SetBlockColor(parent+numLeaves+1,
vtkMath::HSVToRGB(0.8*block/nblocks, 0.2 + 0.8*((parent - levelStart) % 8)/7.0, 1.0));
double hsv[3] = {0.8*block/nblocks, 0.2 + 0.8*((parent - levelStart) % 8)/7.0, 1.0};
double rgb[3];
vtkMath::HSVToRGB(hsv, rgb);
mapper->SetBlockColor(parent+numLeaves+1, rgb);
mapper->SetBlockOpacity(parent+numLeaves, (block + 3) % 7 == 0 ? 0.3 : 1.0);
mapper->SetBlockVisibility(parent+numLeaves, (block % 7) != 0);
}
......
......@@ -107,11 +107,16 @@ int TestCompositePolyDataMapper2Spheres(int argc, char* argv[])
// test not setting it on some
if (block % 11)
{
mapper->SetBlockColor(parent+numLeaves+1,
vtkMath::HSVToRGB(0.8*block/nblocks, 0.2 + 0.8*((parent - levelStart) % 8)/7.0, 1.0));
double r, g, b;
vtkMath::HSVToRGB(
0.8*block/nblocks, 0.2 + 0.8*((parent - levelStart) % 8)/7.0, 1.0,
&r, &g, &b);
mapper->SetBlockColor(parent+numLeaves+1, r, g, b);
mapper->SetBlockVisibility(parent+numLeaves, (block % 7) != 0);
mapper2->SetBlockColor(parent+numLeaves+1,
vtkMath::HSVToRGB(0.2 + 0.8*block/nblocks, 0.7 + 0.3*((parent - levelStart) % 8)/7.0, 1.0));
vtkMath::HSVToRGB(
0.2 + 0.8*block/nblocks, 0.7 + 0.3*((parent - levelStart) % 8)/7.0, 1.0,
&r, &g, &b);
mapper2->SetBlockColor(parent+numLeaves+1, r, g, b);
mapper2->SetBlockVisibility(parent+numLeaves, (block % 7) != 0);
}
++numLeaves;
......
......@@ -101,8 +101,12 @@ int TestCompositePolyDataMapper2Vertices(int argc, char* argv[])
// test not setting it on some
if (block % 11)
{
mapper->SetBlockColor(parent+numLeaves+1,
vtkMath::HSVToRGB(0.8*block/nblocks, 0.2 + 0.8*((parent - levelStart) % 8)/7.0, 1.0));
double r, g, b;
vtkMath::HSVToRGB(0.8*block/nblocks,
0.2 + 0.8*((parent - levelStart) % 8)/7.0,
1.0,
&r, &g, &b);
mapper->SetBlockColor(parent+numLeaves+1, r, g, b);
mapper->SetBlockVisibility(parent+numLeaves, (block % 7) != 0);
}
++numLeaves;
......
......@@ -141,10 +141,11 @@ int TestOptiXCompositePolyDataMapper2(int argc, char* argv[])
// comment the following in/out for worst/best case
// for (int i = 0; i < 20000; ++i)
// {
// mapper->SetBlockColor(i,
// vtkMath::HSVToRGB(0.8*(i%100)/100.0, 1.0, 1.0));
// }
// {
// double r, g, b;
// vtkMath::HSVToRGB(0.8*(i%100)/100.0, 1.0, 1.0, &r, &g, &b);
// mapper->SetBlockColor(i, r, g, b);
// }
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment