Commit 27579ded authored by Sean McBride's avatar Sean McBride

Deprecated non-thread-safe colour conversion functions

The use of a shared static buffer (of a mere 3 doubles!) is not thread friendly.

Deprecated all functions that do that. Reimplemented others to not use the deprecated ones.
parent f98c02bb
......@@ -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);
......
......@@ -2531,18 +2531,22 @@ void vtkMath::RGBToHSV(float r, float g, float b,
}
//----------------------------------------------------------------------------
#ifndef VTK_LEGACY_REMOVE
double* vtkMath::RGBToHSV(const double rgb[3])
{
VTK_LEGACY_BODY(vtkMath::RGBToHSV, "VTK 9.0");
return vtkMath::RGBToHSV(rgb[0], rgb[1], rgb[2]);
}
//----------------------------------------------------------------------------
double* vtkMath::RGBToHSV(double r, double g, double b)
{
VTK_LEGACY_BODY(vtkMath::RGBToHSV, "VTK 9.0");
static double hsv[3];
vtkMath::RGBToHSV(r, g, b, hsv, hsv + 1, hsv + 2);
return hsv;
}
#endif
//----------------------------------------------------------------------------
void vtkMath::RGBToHSV(double r, double g, double b,
......@@ -2617,18 +2621,22 @@ void vtkMath::HSVToRGB(float h, float s, float v,
}
//----------------------------------------------------------------------------
#ifndef VTK_LEGACY_REMOVE
double* vtkMath::HSVToRGB(const double hsv[3])
{
VTK_LEGACY_BODY(vtkMath::HSVToRGB, "VTK 9.0");
return vtkMath::HSVToRGB(hsv[0], hsv[1], hsv[2]);
}
//----------------------------------------------------------------------------
double* vtkMath::HSVToRGB(double h, double s, double v)
{
VTK_LEGACY_BODY(vtkMath::HSVToRGB, "VTK 9.0");
static double rgb[3];
vtkMath::HSVToRGB(h, s, v, rgb, rgb + 1, rgb + 2);
return rgb;
}
#endif
//----------------------------------------------------------------------------
void vtkMath::HSVToRGB(double h, double s, double v,
......@@ -2713,12 +2721,15 @@ void vtkMath::LabToXYZ(double L, double a, double b,
}
//-----------------------------------------------------------------------------
#ifndef VTK_LEGACY_REMOVE
double *vtkMath::LabToXYZ(const double lab[3])
{
VTK_LEGACY_BODY(vtkMath::LabToXYZ, "VTK 9.0");
static double xyz[3];
vtkMath::LabToXYZ(lab[0], lab[1], lab[2], xyz+0, xyz+1, xyz+2);
return xyz;
}
#endif
//-----------------------------------------------------------------------------
void vtkMath::XYZToLab(double x, double y, double z,
......@@ -2744,12 +2755,15 @@ void vtkMath::XYZToLab(double x, double y, double z,
}
//-----------------------------------------------------------------------------
#ifndef VTK_LEGACY_REMOVE
double *vtkMath::XYZToLab(const double xyz[3])
{
VTK_LEGACY_BODY(vtkMath::XYZToLab, "VTK 9.0");
static double lab[3];
vtkMath::XYZToLab(xyz[0], xyz[1], xyz[2], lab+0, lab+1, lab+2);
return lab;
}
#endif
//----------------------------------------------------------------------------
void vtkMath::XYZToRGB(double x, double y, double z,
......@@ -2797,12 +2811,15 @@ void vtkMath::XYZToRGB(double x, double y, double z,
}
//-----------------------------------------------------------------------------
#ifndef VTK_LEGACY_REMOVE
double *vtkMath::XYZToRGB(const double xyz[3])
{
VTK_LEGACY_BODY(vtkMath::XYZToRGB, "VTK 9.0");
static double rgb[3];
vtkMath::XYZToRGB(xyz[0], xyz[1], xyz[2], rgb+0, rgb+1, rgb+2);
return rgb;
}
#endif
//-----------------------------------------------------------------------------
void vtkMath::RGBToXYZ(double r, double g, double b,
......@@ -2830,12 +2847,15 @@ void vtkMath::RGBToXYZ(double r, double g, double b,
}
//-----------------------------------------------------------------------------
#ifndef VTK_LEGACY_REMOVE
double *vtkMath::RGBToXYZ(const double rgb[3])
{
VTK_LEGACY_BODY(vtkMath::RGBToXYZ, "VTK 9.0");
static double xyz[3];
vtkMath::RGBToXYZ(rgb[0], rgb[1], rgb[2], xyz+0, xyz+1, xyz+2);
return xyz;
}
#endif
//-----------------------------------------------------------------------------
void vtkMath::RGBToLab(double red, double green, double blue,
......@@ -2847,10 +2867,20 @@ void vtkMath::RGBToLab(double red, double green, double blue,
}
//-----------------------------------------------------------------------------
#ifndef VTK_LEGACY_REMOVE
double *vtkMath::RGBToLab(const double rgb[3])
{
return vtkMath::XYZToLab(vtkMath::RGBToXYZ(rgb));
VTK_LEGACY_BODY(vtkMath::RGBToLab, "VTK 9.0");
double x, y, z;
vtkMath::RGBToXYZ(rgb[0], rgb[1], rgb[2], &x, &y, &z);
static double lab[3];
vtkMath::XYZToLab(x, y, z, lab+0, lab+1, lab+2);
return lab;
}
#endif
//-----------------------------------------------------------------------------
void vtkMath::LabToRGB(double L, double a, double b,
......@@ -2862,10 +2892,20 @@ void vtkMath::LabToRGB(double L, double a, double b,
}
//-----------------------------------------------------------------------------
#ifndef VTK_LEGACY_REMOVE
double *vtkMath::LabToRGB(const double lab[3])
{
return vtkMath::XYZToRGB(vtkMath::LabToXYZ(lab));
VTK_LEGACY_BODY(vtkMath::LabToRGB, "VTK 9.0");
double x, y, z;
vtkMath::LabToXYZ(lab[0], lab[1], lab[2], &x, &y, &z);
static double rgb[3];
vtkMath::XYZToRGB(x, y, z, rgb+0, rgb+1, rgb+2);
return rgb;
}
#endif
//----------------------------------------------------------------------------
void vtkMath::ClampValues(double *values,
......
......@@ -1002,8 +1002,8 @@ public:
RGBToHSV(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
}
static void RGBToHSV(float r, float g, float b, float *h, float *s, float *v);
static double* RGBToHSV(const double rgb[3]) VTK_SIZEHINT(3);
static double* RGBToHSV(double r, double g, double b) VTK_SIZEHINT(3);
VTK_LEGACY(static double* RGBToHSV(const double rgb[3]) VTK_SIZEHINT(3));
VTK_LEGACY(static double* RGBToHSV(double r, double g, double b) VTK_SIZEHINT(3));
static void RGBToHSV(const double rgb[3], double hsv[3]) {
RGBToHSV(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
}
......@@ -1022,8 +1022,8 @@ public:
HSVToRGB(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
}
static void HSVToRGB(float h, float s, float v, float *r, float *g, float *b);
static double* HSVToRGB(const double hsv[3]) VTK_SIZEHINT(3);
static double* HSVToRGB(double h, double s, double v) VTK_SIZEHINT(3);
VTK_LEGACY(static double* HSVToRGB(const double hsv[3]) VTK_SIZEHINT(3));
VTK_LEGACY(static double* HSVToRGB(double h, double s, double v) VTK_SIZEHINT(3));
static void HSVToRGB(const double hsv[3], double rgb[3])
{ HSVToRGB(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); }
static void HSVToRGB(double h, double s, double v, double *r, double *g, double *b);
......@@ -1038,7 +1038,7 @@ public:
}
static void LabToXYZ(double L, double a, double b,
double *x, double *y, double *z);
static double *LabToXYZ(const double lab[3]) VTK_SIZEHINT(3);
VTK_LEGACY(static double *LabToXYZ(const double lab[3]) VTK_SIZEHINT(3));
//@}
//@{
......@@ -1050,7 +1050,7 @@ public:
}
static void XYZToLab(double x, double y, double z,
double *L, double *a, double *b);
static double *XYZToLab(const double xyz[3]) VTK_SIZEHINT(3);
VTK_LEGACY(static double *XYZToLab(const double xyz[3]) VTK_SIZEHINT(3));
//@}
//@{
......@@ -1062,7 +1062,7 @@ public:
}
static void XYZToRGB(double x, double y, double z,
double *r, double *g, double *b);
static double *XYZToRGB(const double xyz[3]) VTK_SIZEHINT(3);
VTK_LEGACY(static double *XYZToRGB(const double xyz[3]) VTK_SIZEHINT(3));
//@}
//@{
......@@ -1074,7 +1074,7 @@ public:
}
static void RGBToXYZ(double r, double g, double b,
double *x, double *y, double *z);
static double *RGBToXYZ(const double rgb[3]) VTK_SIZEHINT(3);
VTK_LEGACY(static double *RGBToXYZ(const double rgb[3]) VTK_SIZEHINT(3));
//@}
//@{
......@@ -1089,7 +1089,7 @@ public:
}
static void RGBToLab(double red, double green, double blue,
double *L, double *a, double *b);
static double *RGBToLab(const double rgb[3]) VTK_SIZEHINT(3);
VTK_LEGACY(static double *RGBToLab(const double rgb[3]) VTK_SIZEHINT(3));
//@}
//@{
......@@ -1101,7 +1101,7 @@ public:
}
static void LabToRGB(double L, double a, double b,
double *red, double *green, double *blue);
static double *LabToRGB(const double lab[3]) VTK_SIZEHINT(3);
VTK_LEGACY(static double *LabToRGB(const double lab[3]) VTK_SIZEHINT(3));
//@}
//@{
......
......@@ -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