Commit b6617c31 authored by Ken Martin's avatar Ken Martin
Browse files

some double fixes

parent eb025f36
......@@ -19,7 +19,7 @@
#include "vtkPropCollection.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkActor2D, "1.36");
vtkCxxRevisionMacro(vtkActor2D, "1.37");
vtkStandardNewMacro(vtkActor2D);
vtkCxxSetObjectMacro(vtkActor2D,Property, vtkProperty2D);
......@@ -195,30 +195,30 @@ void vtkActor2D::SetDisplayPosition(int XPos, int YPos)
this->PositionCoordinate->SetValue((float)XPos,(float)YPos,0.0);
}
void vtkActor2D::SetWidth(float w)
void vtkActor2D::SetWidth(double w)
{
float *pos;
double *pos;
pos = this->Position2Coordinate->GetValue();
this->Position2Coordinate->SetCoordinateSystemToNormalizedViewport();
this->Position2Coordinate->SetValue(w,pos[1]);
}
void vtkActor2D::SetHeight(float w)
void vtkActor2D::SetHeight(double w)
{
float *pos;
double *pos;
pos = this->Position2Coordinate->GetValue();
this->Position2Coordinate->SetCoordinateSystemToNormalizedViewport();
this->Position2Coordinate->SetValue(pos[0],w);
}
float vtkActor2D::GetWidth()
double vtkActor2D::GetWidth()
{
return this->Position2Coordinate->GetValue()[0];
}
float vtkActor2D::GetHeight()
double vtkActor2D::GetHeight()
{
return this->Position2Coordinate->GetValue()[1];
}
......
......@@ -90,10 +90,10 @@ public:
// Set/Get the height and width of the Actor2D. The value is expressed
// as a fraction of the viewport. This really is just another way of
// setting the Position2 instance variable.
void SetWidth(float w);
float GetWidth();
void SetHeight(float h);
float GetHeight();
void SetWidth(double w);
double GetWidth();
void SetHeight(double h);
double GetHeight();
// Description:
// Return this objects MTime.
......
......@@ -16,7 +16,7 @@
#include "vtkViewport.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkCoordinate, "1.29");
vtkCxxRevisionMacro(vtkCoordinate, "1.30");
vtkStandardNewMacro(vtkCoordinate);
vtkCxxSetObjectMacro(vtkCoordinate,ReferenceCoordinate,vtkCoordinate);
......@@ -72,12 +72,14 @@ void vtkCoordinate::PrintSelf(ostream& os, vtkIndent indent)
this->Superclass::PrintSelf(os,indent);
os << indent << "Coordinate System: " << this->GetCoordinateSystemAsString() << "\n";
os << indent << "Coordinate System: " <<
this->GetCoordinateSystemAsString() << "\n";
os << indent << "Value: (" << this->Value[0] << ","
<< this->Value[1] << "," << this->Value[2] << ")\n";
if (this->ReferenceCoordinate)
{
os << indent << "ReferenceCoordinate: " << this->ReferenceCoordinate << "\n";
os << indent << "ReferenceCoordinate: " <<
this->ReferenceCoordinate << "\n";
}
else
{
......@@ -112,9 +114,9 @@ void vtkCoordinate::SetViewport(vtkViewport *viewport)
}
float *vtkCoordinate::GetComputedWorldValue(vtkViewport* viewport)
double *vtkCoordinate::GetComputedWorldValue(vtkViewport* viewport)
{
float *val = this->ComputedWorldValue;
double *val = this->ComputedWorldValue;
// prevent infinite loops
if (this->Computing)
......@@ -140,8 +142,9 @@ float *vtkCoordinate::GetComputedWorldValue(vtkViewport* viewport)
{
if (this->ReferenceCoordinate)
{
float *RefValue;
RefValue = this->ReferenceCoordinate->GetComputedWorldValue(viewport);
double *RefValue;
RefValue =
this->ReferenceCoordinate->GetComputedWorldValue(viewport);
val[0] += RefValue[0];
val[1] += RefValue[1];
val[2] += RefValue[2];
......@@ -157,10 +160,10 @@ float *vtkCoordinate::GetComputedWorldValue(vtkViewport* viewport)
if (this->ReferenceCoordinate && this->CoordinateSystem != VTK_WORLD)
{
float RefValue[3];
float *fval;
double RefValue[3];
double *fval;
fval = this->ReferenceCoordinate->GetComputedFloatDisplayValue(viewport);
fval = this->ReferenceCoordinate->GetComputedDoubleDisplayValue(viewport);
RefValue[0] = fval[0];
RefValue[1] = fval[1];
RefValue[2] = 0.0;
......@@ -184,7 +187,9 @@ float *vtkCoordinate::GetComputedWorldValue(vtkViewport* viewport)
viewport->DisplayToNormalizedDisplay(RefValue[0],RefValue[1]);
viewport->NormalizedDisplayToViewport(RefValue[0],RefValue[1]);
viewport->ViewportToNormalizedViewport(RefValue[0],RefValue[1]);
viewport->NormalizedViewportToView(RefValue[0],RefValue[1],RefValue[2]);
viewport->NormalizedViewportToView(RefValue[0],
RefValue[1],
RefValue[2]);
break;
}
......@@ -211,7 +216,7 @@ float *vtkCoordinate::GetComputedWorldValue(vtkViewport* viewport)
if (this->ReferenceCoordinate && this->CoordinateSystem == VTK_WORLD)
{
float *RefValue;
double *RefValue;
RefValue = this->ReferenceCoordinate->GetComputedWorldValue(viewport);
val[0] += RefValue[0];
val[1] += RefValue[1];
......@@ -227,7 +232,7 @@ float *vtkCoordinate::GetComputedWorldValue(vtkViewport* viewport)
}
float *vtkCoordinate::GetComputedFloatViewportValue(vtkViewport* viewport)
double *vtkCoordinate::GetComputedDoubleViewportValue(vtkViewport* viewport)
{
// use our viewport if set
if (this->Viewport)
......@@ -235,7 +240,7 @@ float *vtkCoordinate::GetComputedFloatViewportValue(vtkViewport* viewport)
viewport = this->Viewport;
}
float *d = this->GetComputedFloatDisplayValue(viewport);
double *d = this->GetComputedDoubleDisplayValue(viewport);
if (!viewport)
{
......@@ -243,22 +248,22 @@ float *vtkCoordinate::GetComputedFloatViewportValue(vtkViewport* viewport)
return d;
}
float f[2];
double f[2];
f[0] = d[0];
f[1] = d[1];
viewport->DisplayToNormalizedDisplay(f[0],f[1]);
viewport->NormalizedDisplayToViewport(f[0],f[1]);
this->ComputedFloatViewportValue[0] = f[0];
this->ComputedFloatViewportValue[1] = f[1];
this->ComputedDoubleViewportValue[0] = f[0];
this->ComputedDoubleViewportValue[1] = f[1];
return this->ComputedFloatViewportValue;
return this->ComputedDoubleViewportValue;
}
int *vtkCoordinate::GetComputedViewportValue(vtkViewport* viewport)
{
float *f = this->GetComputedFloatViewportValue(viewport);
double *f = this->GetComputedDoubleViewportValue(viewport);
this->ComputedViewportValue[0] = (int)VTK_RINT(f[0]);
this->ComputedViewportValue[1] = (int)VTK_RINT(f[1]);
......@@ -268,7 +273,7 @@ int *vtkCoordinate::GetComputedViewportValue(vtkViewport* viewport)
int *vtkCoordinate::GetComputedLocalDisplayValue(vtkViewport* viewport)
{
float a[2];
double a[2];
// use our viewport if set
if (this->Viewport)
......@@ -283,8 +288,8 @@ int *vtkCoordinate::GetComputedLocalDisplayValue(vtkViewport* viewport)
return this->ComputedDisplayValue;
}
a[0] = (float)this->ComputedDisplayValue[0];
a[1] = (float)this->ComputedDisplayValue[1];
a[0] = (double)this->ComputedDisplayValue[0];
a[1] = (double)this->ComputedDisplayValue[1];
viewport->DisplayToLocalDisplay(a[0],a[1]);
......@@ -298,14 +303,14 @@ int *vtkCoordinate::GetComputedLocalDisplayValue(vtkViewport* viewport)
return this->ComputedDisplayValue;
}
float *vtkCoordinate::GetComputedFloatDisplayValue(vtkViewport* viewport)
double *vtkCoordinate::GetComputedDoubleDisplayValue(vtkViewport* viewport)
{
float val[3];
double val[3];
// prevent infinite loops
if (this->Computing)
{
return this->ComputedFloatDisplayValue;
return this->ComputedDoubleDisplayValue;
}
this->Computing = 1;
......@@ -325,21 +330,22 @@ float *vtkCoordinate::GetComputedFloatDisplayValue(vtkViewport* viewport)
// for DISPLAY and VIEWPORT just use the value
if (this->CoordinateSystem == VTK_DISPLAY)
{
this->ComputedFloatDisplayValue[0] = val[0];
this->ComputedFloatDisplayValue[1] = val[1];
this->ComputedDoubleDisplayValue[0] = val[0];
this->ComputedDoubleDisplayValue[1] = val[1];
if (this->ReferenceCoordinate)
{
float *RefValue;
RefValue = this->ReferenceCoordinate->GetComputedFloatDisplayValue(viewport);
this->ComputedFloatDisplayValue[0] += RefValue[0];
this->ComputedFloatDisplayValue[1] += RefValue[1];
double *RefValue;
RefValue = this->ReferenceCoordinate->
GetComputedDoubleDisplayValue(viewport);
this->ComputedDoubleDisplayValue[0] += RefValue[0];
this->ComputedDoubleDisplayValue[1] += RefValue[1];
}
}
else
{
vtkErrorMacro("Request for coordinate transformation without required viewport");
}
return this->ComputedFloatDisplayValue;
return this->ComputedDoubleDisplayValue;
}
// compute our DC
......@@ -348,7 +354,7 @@ float *vtkCoordinate::GetComputedFloatDisplayValue(vtkViewport* viewport)
case VTK_WORLD:
if (this->ReferenceCoordinate)
{
float *RefValue;
double *RefValue;
RefValue = this->ReferenceCoordinate->GetComputedWorldValue(viewport);
val[0] += RefValue[0];
val[1] += RefValue[1];
......@@ -364,9 +370,9 @@ float *vtkCoordinate::GetComputedFloatDisplayValue(vtkViewport* viewport)
this->CoordinateSystem == VTK_VIEWPORT) &&
this->ReferenceCoordinate)
{
float *RefValue;
RefValue =
this->ReferenceCoordinate->GetComputedFloatViewportValue(viewport);
double *RefValue;
RefValue = this->ReferenceCoordinate->
GetComputedDoubleViewportValue(viewport);
val[0] += RefValue[0];
val[1] += RefValue[1];
}
......@@ -387,23 +393,23 @@ float *vtkCoordinate::GetComputedFloatDisplayValue(vtkViewport* viewport)
(this->CoordinateSystem == VTK_DISPLAY ||
this->CoordinateSystem == VTK_NORMALIZED_DISPLAY))
{
float *RefValue;
double *RefValue;
RefValue =
this->ReferenceCoordinate->GetComputedFloatDisplayValue(viewport);
this->ReferenceCoordinate->GetComputedDoubleDisplayValue(viewport);
val[0] += RefValue[0];
val[1] += RefValue[1];
}
this->ComputedFloatDisplayValue[0] = val[0];
this->ComputedFloatDisplayValue[1] = val[1];
this->ComputedDoubleDisplayValue[0] = val[0];
this->ComputedDoubleDisplayValue[1] = val[1];
this->Computing = 0;
return this->ComputedFloatDisplayValue;
return this->ComputedDoubleDisplayValue;
}
int *vtkCoordinate::GetComputedDisplayValue(vtkViewport* viewport)
{
float *val = this->GetComputedFloatDisplayValue(viewport);
double *val = this->GetComputedDoubleDisplayValue(viewport);
this->ComputedDisplayValue[0] = (int)(val[0]);
this->ComputedDisplayValue[1] = (int)(val[1]);
......@@ -416,7 +422,7 @@ int *vtkCoordinate::GetComputedDisplayValue(vtkViewport* viewport)
float *vtkCoordinate::GetComputedValue(vtkViewport* viewport)
double *vtkCoordinate::GetComputedValue(vtkViewport* viewport)
{
// use our viewport if set
if (this->Viewport)
......@@ -432,7 +438,7 @@ float *vtkCoordinate::GetComputedValue(vtkViewport* viewport)
case VTK_NORMALIZED_VIEWPORT:
case VTK_VIEWPORT:
{
// result stored in computed world value due to float
// result stored in computed world value due to double
// but is really a viewport value
int *v = this->GetComputedViewportValue(viewport);
this->ComputedWorldValue[0] = v[0];
......@@ -442,7 +448,7 @@ float *vtkCoordinate::GetComputedValue(vtkViewport* viewport)
case VTK_NORMALIZED_DISPLAY:
case VTK_DISPLAY:
{
// result stored in computed world value due to float
// result stored in computed world value due to double
// but is really a display value
int *d = this->GetComputedDisplayValue(viewport);
this->ComputedWorldValue[0] = d[0];
......
......@@ -89,13 +89,9 @@ public:
// Description:
// Set/get the value of this coordinate. This can be thought of as
// the position of this coordinate in its coordinate system.
vtkSetVector3Macro(Value,float);
vtkGetVector3Macro(Value,float);
void SetValue(float a, float b) { this->SetValue(a,b,0.0);}
void SetValue(double a, double b) {
this->SetValue((float)a,(float)b); }
void SetValue(double *a) {
this->SetValue((float)a[0],(float)a[1],(float)a[2]); }
vtkSetVector3Macro(Value,double);
vtkGetVector3Macro(Value,double);
void SetValue(double a, double b) { this->SetValue(a,b,0.0);}
// Description:
// If this coordinate is relative to another coordinate,
......@@ -113,20 +109,20 @@ public:
// Description:
// Return the computed value in a specified coordinate system.
float *GetComputedWorldValue(vtkViewport *);
double *GetComputedWorldValue(vtkViewport *);
int *GetComputedViewportValue(vtkViewport *);
int *GetComputedDisplayValue(vtkViewport *);
int *GetComputedLocalDisplayValue(vtkViewport *);
float *GetComputedFloatViewportValue(vtkViewport *);
float *GetComputedFloatDisplayValue(vtkViewport *);
double *GetComputedDoubleViewportValue(vtkViewport *);
double *GetComputedDoubleDisplayValue(vtkViewport *);
// Description:
// GetComputedValue() will return either World, Viewport or
// Display based on what has been set as the coordinate system.
// This is good for objects like vtkLineSource, where the
// user might want to use them as World or Viewport coordinates
float *GetComputedValue(vtkViewport *);
double *GetComputedValue(vtkViewport *);
// Description:
// GetComputedUserDefinedValue() is to be used only when
......@@ -134,25 +130,25 @@ public:
// must subclass vtkCoordinate and override this function,
// when set as the TransformCoordinate in 2D-Mappers, the user
// can customize display of 2D polygons
virtual float *GetComputedUserDefinedValue(vtkViewport *)
virtual double *GetComputedUserDefinedValue(vtkViewport *)
{ return this->Value; }
protected:
vtkCoordinate();
~vtkCoordinate();
float Value[3];
double Value[3];
int CoordinateSystem;
vtkCoordinate *ReferenceCoordinate;
vtkViewport *Viewport;
float ComputedWorldValue[3];
double ComputedWorldValue[3];
int ComputedDisplayValue[2];
int ComputedViewportValue[2];
int Computing;
float ComputedFloatDisplayValue[2];
float ComputedFloatViewportValue[2];
float ComputedUserDefinedValue[3];
double ComputedDoubleDisplayValue[2];
double ComputedDoubleViewportValue[2];
double ComputedUserDefinedValue[3];
private:
vtkCoordinate(const vtkCoordinate&); // Not implemented.
......
......@@ -25,6 +25,7 @@
#include "vtkLargeInteger.h"
#include "vtkLine.h"
#include "vtkLongArray.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkPixel.h"
#include "vtkPointData.h"
......@@ -37,7 +38,7 @@
#include "vtkVertex.h"
#include "vtkVoxel.h"
vtkCxxRevisionMacro(vtkImageData, "1.146");
vtkCxxRevisionMacro(vtkImageData, "1.147");
vtkStandardNewMacro(vtkImageData);
//----------------------------------------------------------------------------
......@@ -499,27 +500,35 @@ void vtkImageData::GetCellBounds(vtkIdType cellId, double bounds[6])
}
bounds[0] = bounds[2] = bounds[4] = VTK_DOUBLE_MAX;
bounds[1] = bounds[3] = bounds[5] = -VTK_DOUBLE_MAX;
// Extract point coordinates
for (loc[2]=kMin; loc[2]<=kMax; loc[2]++)
{
x[2] = origin[2] + (loc[2]+this->Extent[4]) * spacing[2];
bounds[4] = (x[2] < bounds[4] ? x[2] : bounds[4]);
bounds[5] = (x[2] > bounds[5] ? x[2] : bounds[5]);
}
for (loc[1]=jMin; loc[1]<=jMax; loc[1]++)
// carefully compute the bounds
if (kMax >= kMin && jMax >= jMin && iMax >= iMin)
{
x[1] = origin[1] + (loc[1]+this->Extent[2]) * spacing[1];
bounds[2] = (x[1] < bounds[2] ? x[1] : bounds[2]);
bounds[3] = (x[1] > bounds[3] ? x[1] : bounds[3]);
bounds[0] = bounds[2] = bounds[4] = VTK_DOUBLE_MAX;
bounds[1] = bounds[3] = bounds[5] = -VTK_DOUBLE_MAX;
// Extract point coordinates
for (loc[2]=kMin; loc[2]<=kMax; loc[2]++)
{
x[2] = origin[2] + (loc[2]+this->Extent[4]) * spacing[2];
bounds[4] = (x[2] < bounds[4] ? x[2] : bounds[4]);
bounds[5] = (x[2] > bounds[5] ? x[2] : bounds[5]);
}
for (loc[1]=jMin; loc[1]<=jMax; loc[1]++)
{
x[1] = origin[1] + (loc[1]+this->Extent[2]) * spacing[1];
bounds[2] = (x[1] < bounds[2] ? x[1] : bounds[2]);
bounds[3] = (x[1] > bounds[3] ? x[1] : bounds[3]);
}
for (loc[0]=iMin; loc[0]<=iMax; loc[0]++)
{
x[0] = origin[0] + (loc[0]+this->Extent[0]) * spacing[0];
bounds[0] = (x[0] < bounds[0] ? x[0] : bounds[0]);
bounds[1] = (x[0] > bounds[1] ? x[0] : bounds[1]);
}
}
for (loc[0]=iMin; loc[0]<=iMax; loc[0]++)
else
{
x[0] = origin[0] + (loc[0]+this->Extent[0]) * spacing[0];
bounds[0] = (x[0] < bounds[0] ? x[0] : bounds[0]);
bounds[1] = (x[0] > bounds[1] ? x[0] : bounds[1]);
vtkMath::UninitializeBounds(bounds);
}
}
......@@ -819,8 +828,7 @@ void vtkImageData::ComputeBounds()
this->Extent[2] > this->Extent[3] ||
this->Extent[4] > this->Extent[5] )
{
this->Bounds[0] = this->Bounds[2] = this->Bounds[4] = VTK_DOUBLE_MAX;
this->Bounds[1] = this->Bounds[3] = this->Bounds[5] = -VTK_DOUBLE_MAX;
vtkMath::UninitializeBounds(this->Bounds);
return;
}
this->Bounds[0] = origin[0] + (this->Extent[0] * spacing[0]);
......
......@@ -31,7 +31,7 @@
#include "vtkTriangleStrip.h"
#include "vtkVertex.h"
vtkCxxRevisionMacro(vtkPolyData, "1.156");
vtkCxxRevisionMacro(vtkPolyData, "1.157");
vtkStandardNewMacro(vtkPolyData);
//----------------------------------------------------------------------------
......@@ -502,38 +502,31 @@ void vtkPolyData::GetCellBounds(vtkIdType cellId, double bounds[6])
return;
}
bounds[0] = bounds[2] = bounds[4] = VTK_DOUBLE_MAX;
bounds[1] = bounds[3] = bounds[5] = -VTK_DOUBLE_MAX;
for (i=0; i < numPts; i++)
// carefully compute the bounds
if (numPts)
{
this->Points->GetPoint( pts[i], x );
if (x[0] < bounds[0])
{
bounds[0] = x[0];
}
if (x[0] > bounds[1])
this->Points->GetPoint( pts[0], x );
bounds[0] = x[0];
bounds[2] = x[1];
bounds[4] = x[2];
bounds[1] = x[0];
bounds[3] = x[1];
bounds[5] = x[2];
for (i=1; i < numPts; i++)
{
bounds[1] = x[0];
}
if (x[1] < bounds[2])
{
bounds[2] = x[1];
}
if (x[1] > bounds[3])
{
bounds[3] = x[1];
}
if (x[2] < bounds[4])
{
bounds[4] = x[2];
}
if (x[2] > bounds[5])
{
bounds[5] = x[2];
this->Points->GetPoint( pts[i], x );
bounds[0] = (x[0] < bounds[0] ? x[0] : bounds[0]);
bounds[1] = (x[0] > bounds[1] ? x[0] : bounds[1]);
bounds[2] = (x[1] < bounds[2] ? x[1] : bounds[2]);
bounds[3] = (x[1] > bounds[3] ? x[1] : bounds[3]);
bounds[4] = (x[2] < bounds[4] ? x[2] : bounds[4]);
bounds[5] = (x[2] > bounds[5] ? x[2] : bounds[5]);
}
}
else
{
vtkMath::UninitializeBounds(bounds);
}
}
......@@ -555,9 +548,6 @@ void vtkPolyData::ComputeBounds()
vtkIdType npts = 0;
double x[3];
this->Bounds[0] = this->Bounds[2] = this->Bounds[4] = VTK_DOUBLE_MAX;
this->Bounds[1] = this->Bounds[3] = this->Bounds[5] = -VTK_DOUBLE_MAX;
vtkCellArray *cella[4];
cella[0] = this->GetVerts();
......@@ -565,6 +555,11 @@ void vtkPolyData::ComputeBounds()
cella[2] = this->GetPolys();
cella[3] = this->GetStrips();
// carefully compute the bounds
int doneOne = 0;
this->Bounds[0] = this->Bounds[2] = this->Bounds[4] = VTK_DOUBLE_MAX;
this->Bounds[1] = this->Bounds[3] = this->Bounds[5] = -VTK_DOUBLE_MAX;
// Iterate over cells's points
for (t = 0; t < 4; t++)
{
......@@ -573,35 +568,20 @@ void vtkPolyData::ComputeBounds()
for (i = 0; i < npts; i++)
{
this->Points->GetPoint( pts[i], x );
if (x[0] < this->Bounds[0])
{
this->Bounds[0] = x[0];
}
if (x[0] > this->Bounds[1])
{
this->Bounds[1] = x[0