Commit 2a5f6610 authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: CHanged bug in modelbounds.

parent b194f2e4
......@@ -90,9 +90,13 @@ public:
vtkSetClampMacro(Eccentricity,float,0.001,LARGE_FLOAT);
vtkGetMacro(Eccentricity,float);
void SetModelBounds(float *bounds);
void SetModelBounds(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax);
// Description:
// Set the (xmin,xmax, ymin,ymax, zmin,zmax) bounding box in which the
// sampling is performed.
vtkSetVectorMacro(ModelBounds,float,6);
vtkGetVectorMacro(ModelBounds,float,6);
void SetModelBounds(float xmin, float xmax, float ymin, float ymax,
float zmin, float zmax);
// Description:
// Turn on/off the generation of elliptical splats.
......
......@@ -71,10 +71,12 @@ public:
vtkSetClampMacro(MaximumDistance,float,0.0,1.0);
vtkGetMacro(MaximumDistance,float);
// Specify the position in space to perform the sampling.
void SetModelBounds(float *bounds);
void SetModelBounds(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax);
// Description:
// Specify the region in space in which to perform the sampling.
vtkSetVectorMacro(ModelBounds,float,6);
vtkGetVectorMacro(ModelBounds,float,6);
void SetModelBounds(float xmin, float xmax, float ymin, float ymax,
float zmin, float zmax);
// Description:
// The outer boundary of the structured point set can be assigned a
......
......@@ -71,9 +71,13 @@ public:
void SetSampleDimensions(int dim[3]);
vtkGetVectorMacro(SampleDimensions,int,3);
void SetModelBounds(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax);
void SetModelBounds(float *bounds);
// Description:
// Specify the region in space over which the tensors are computed. The point
// load is assumed to be applied at top center of the volume.
vtkSetVectorMacro(ModelBounds,float,6);
vtkGetVectorMacro(ModelBounds,float,6);
void SetModelBounds(float xmin, float xmax, float ymin, float ymax,
float zmin, float zmax);
// Description:
// Set/Get Poisson's ratio.
......
......@@ -70,9 +70,12 @@ public:
void SetSampleDimensions(int dim[3]);
vtkGetVectorMacro(SampleDimensions,int,3);
void SetModelBounds(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax);
void SetModelBounds(float *bounds);
// Description:
// Specify the region in space over which the sampling occurs.
vtkSetVectorMacro(ModelBounds,float,6);
vtkGetVectorMacro(ModelBounds,float,6);
void SetModelBounds(float xmin, float xmax, float ymin, float ymax,
float zmin, float zmax);
// Description:
// Turn on/off capping. If capping is on, then the outer boundaries of the
......
......@@ -77,16 +77,19 @@ public:
// Description:
// Specify influence distance of each input point. This distance is a
// fraction of the length of the diagonal of the sample space. Thus values of
// 1.0 will cause each input point to influence all points in the structured
// point dataset. Values less than 1.0 can improve performance significantly.
// fraction of the length of the diagonal of the sample space. Thus values
// of 1.0 will cause each input point to influence all points in the
// structured point dataset. Values less than 1.0 can improve performance
// significantly.
vtkSetClampMacro(MaximumDistance,float,0.0,1.0);
vtkGetMacro(MaximumDistance,float);
// Description:
// Specify the position in space to perform the sampling.
void SetModelBounds(float *bounds);
void SetModelBounds(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax);
vtkSetVectorMacro(ModelBounds,float,6);
vtkGetVectorMacro(ModelBounds,float,6);
void SetModelBounds(float xmin, float xmax, float ymin, float ymax,
float zmin, float zmax);
// Description:
// Set the Null value for output points not receiving a contribution from the
......
......@@ -103,7 +103,6 @@ public:
vtkSetMacro(Interpolation,int);
vtkGetMacro(Interpolation,int);
// Description:
// Description:
// The outer boundary of the sampling volume can be capped (i.e., assigned
// fill value). This will "close" the implicit model if the geometry
......@@ -114,11 +113,18 @@ public:
vtkGetMacro(Capping,int);
vtkBooleanMacro(Capping,int);
void SetModelBounds(float *bounds);
void SetModelBounds(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax);
// Description:
// Define the volume (in world coordinates) in which the sampling is to
// occur. Make sure that the volume is large enough to accomodate the
// motion of the geometry along the path. If the model bounds are set to
// all zero values, the model bounds will be computed automatically from
// the input geometry and path.
vtkSetVectorMacro(ModelBounds,float,6);
vtkGetVectorMacro(ModelBounds,float,6);
void SetModelBounds(float xmin, float xmax, float ymin, float ymax,
float zmin, float zmax);
//overload to check trnasformation matrices
//overload to check transformation matrices
unsigned long int GetMTime();
protected:
......
......@@ -72,39 +72,19 @@ vtkGaussianSplatter::vtkGaussianSplatter()
this->CapValue = LARGE_FLOAT;
}
// Description:
// Set the (xmin,xmax, ymin,ymax, zmin,zmax) bounding box in which the
// sampling is performed.
void vtkGaussianSplatter::SetModelBounds(float *bounds)
void vtkGaussianSplatter::SetModelBounds(float xmin, float xmax, float ymin,
float ymax, float zmin, float zmax)
{
vtkGaussianSplatter::SetModelBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
}
float bounds[6];
void vtkGaussianSplatter::SetModelBounds(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax)
{
if (this->ModelBounds[0] != xmin || this->ModelBounds[1] != xmax ||
this->ModelBounds[2] != ymin || this->ModelBounds[3] != ymax ||
this->ModelBounds[4] != zmin || this->ModelBounds[5] != zmax )
{
float length;
bounds[0] = xmin;
bounds[1] = xmax;
bounds[2] = ymin;
bounds[3] = ymax;
bounds[4] = zmin;
bounds[5] = zmax;
this->Modified();
this->ModelBounds[0] = xmin;
this->ModelBounds[1] = xmax;
this->ModelBounds[2] = ymin;
this->ModelBounds[3] = ymax;
this->ModelBounds[4] = zmin;
this->ModelBounds[5] = zmax;
this->Origin[0] = xmin;
this->Origin[1] = ymin;
this->Origin[2] = zmin;
if ( (length = xmin - xmax) == 0.0 ) length = 1.0;
this->AspectRatio[0] = 1.0;
this->AspectRatio[1] = (ymax - ymin) / length;
this->AspectRatio[2] = (zmax - zmin) / length;
}
this->SetModelBounds(bounds);
}
//
......
......@@ -65,38 +65,19 @@ vtkImplicitModeller::vtkImplicitModeller()
this->CapValue = LARGE_FLOAT;
}
// Description:
// Specify the position in space to perform the sampling.
void vtkImplicitModeller::SetModelBounds(float *bounds)
void vtkImplicitModeller::SetModelBounds(float xmin, float xmax, float ymin,
float ymax, float zmin, float zmax)
{
vtkImplicitModeller::SetModelBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
}
float bounds[6];
void vtkImplicitModeller::SetModelBounds(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax)
{
if (this->ModelBounds[0] != xmin || this->ModelBounds[1] != xmax ||
this->ModelBounds[2] != ymin || this->ModelBounds[3] != ymax ||
this->ModelBounds[4] != zmin || this->ModelBounds[5] != zmax )
{
float length;
bounds[0] = xmin;
bounds[1] = xmax;
bounds[2] = ymin;
bounds[3] = ymax;
bounds[4] = zmin;
bounds[5] = zmax;
this->Modified();
this->ModelBounds[0] = xmin;
this->ModelBounds[1] = xmax;
this->ModelBounds[2] = ymin;
this->ModelBounds[3] = ymax;
this->ModelBounds[4] = zmin;
this->ModelBounds[5] = zmax;
this->Origin[0] = xmin;
this->Origin[1] = ymin;
this->Origin[2] = zmin;
if ( (length = xmax - xmin) == 0.0 ) length = 1.0;
this->AspectRatio[0] = 1.0;
this->AspectRatio[1] = (ymax - ymin) / length;
this->AspectRatio[2] = (zmax - zmin) / length;
}
this->SetModelBounds(bounds);
}
void vtkImplicitModeller::Execute()
......
......@@ -94,31 +94,19 @@ void vtkPointLoad::SetSampleDimensions(int dim[3])
}
}
// Description:
// Specify the region in space over which the tensors are computed. The point
// load is assumed to be applied at top center of the volume.
void vtkPointLoad::SetModelBounds(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax)
void vtkPointLoad::SetModelBounds(float xmin, float xmax, float ymin,
float ymax, float zmin, float zmax)
{
if (this->ModelBounds[0] != xmin || this->ModelBounds[1] != xmax ||
this->ModelBounds[2] != ymin || this->ModelBounds[3] != ymax ||
this->ModelBounds[4] != zmin || this->ModelBounds[5] != zmax )
{
this->Modified();
this->ModelBounds[0] = xmin;
this->ModelBounds[1] = xmax;
this->ModelBounds[2] = ymin;
this->ModelBounds[3] = ymax;
this->ModelBounds[4] = zmin;
this->ModelBounds[5] = zmax;
}
}
float bounds[6];
// Description:
// Specify the region in space over which the tensors are computed. The point
// load is assumed to be applied at top center of the volume.
void vtkPointLoad::SetModelBounds(float *bounds)
{
vtkPointLoad::SetModelBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
bounds[0] = xmin;
bounds[1] = xmax;
bounds[2] = ymin;
bounds[3] = ymax;
bounds[4] = zmin;
bounds[5] = zmax;
this->SetModelBounds(bounds);
}
//
......
......@@ -97,27 +97,19 @@ void vtkSampleFunction::SetSampleDimensions(int dim[3])
// Description:
// Specify the region in space over which the sampling occurs.
void vtkSampleFunction::SetModelBounds(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax)
void vtkSampleFunction::SetModelBounds(float xmin, float xmax, float ymin,
float ymax, float zmin, float zmax)
{
if (this->ModelBounds[0] != xmin || this->ModelBounds[1] != xmax ||
this->ModelBounds[2] != ymin || this->ModelBounds[3] != ymax ||
this->ModelBounds[4] != zmin || this->ModelBounds[5] != zmax )
{
this->Modified();
this->ModelBounds[0] = xmin;
this->ModelBounds[1] = xmax;
this->ModelBounds[2] = ymin;
this->ModelBounds[3] = ymax;
this->ModelBounds[4] = zmin;
this->ModelBounds[5] = zmax;
}
}
float bounds[6];
// Description:
// Specify the region in space over which the sampling occurs.
void vtkSampleFunction::SetModelBounds(float *bounds)
{
vtkSampleFunction::SetModelBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
bounds[0] = xmin;
bounds[1] = xmax;
bounds[2] = ymin;
bounds[3] = ymax;
bounds[4] = zmin;
bounds[5] = zmax;
this->SetModelBounds(bounds);
}
void vtkSampleFunction::Execute()
......
......@@ -63,38 +63,18 @@ vtkShepardMethod::vtkShepardMethod()
this->NullValue = 0.0;
}
// Description:
// Specify the position in space to perform the sampling.
void vtkShepardMethod::SetModelBounds(float *bounds)
{
vtkShepardMethod::SetModelBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
}
void vtkShepardMethod::SetModelBounds(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax)
{
if (this->ModelBounds[0] != xmin || this->ModelBounds[1] != xmax ||
this->ModelBounds[2] != ymin || this->ModelBounds[3] != ymax ||
this->ModelBounds[4] != zmin || this->ModelBounds[5] != zmax )
{
float length;
float bounds[6];
this->Modified();
this->ModelBounds[0] = xmin;
this->ModelBounds[1] = xmax;
this->ModelBounds[2] = ymin;
this->ModelBounds[3] = ymax;
this->ModelBounds[4] = zmin;
this->ModelBounds[5] = zmax;
this->Origin[0] = xmin;
this->Origin[1] = ymin;
this->Origin[2] = zmin;
if ( (length = xmax - xmin) == 0.0 ) length = 1.0;
this->AspectRatio[0] = 1.0;
this->AspectRatio[1] = (ymax - ymin) / length;
this->AspectRatio[2] = (zmax - zmin) / length;
}
bounds[0] = xmin;
bounds[1] = xmax;
bounds[2] = ymin;
bounds[3] = ymax;
bounds[4] = zmin;
bounds[5] = zmax;
this->SetModelBounds(bounds);
}
// Description:
......
......@@ -65,41 +65,19 @@ vtkSweptSurface::vtkSweptSurface()
this->Capping = 1;
}
// Description:
// Define the volume (in world coordinates) in which the sampling is to occur.
// Make sure that the volume is large enough to accomodate the motion of the
// geometry along the path. If the model bounds are set to all zero values, the
// model bounds will be computed automatically from the input and path.
void vtkSweptSurface::SetModelBounds(float *bounds)
void vtkSweptSurface::SetModelBounds(float xmin, float xmax, float ymin,
float ymax, float zmin, float zmax)
{
vtkSweptSurface::SetModelBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
}
float bounds[6];
void vtkSweptSurface::SetModelBounds(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax)
{
if (this->ModelBounds[0] != xmin || this->ModelBounds[1] != xmax ||
this->ModelBounds[2] != ymin || this->ModelBounds[3] != ymax ||
this->ModelBounds[4] != zmin || this->ModelBounds[5] != zmax )
{
float length;
this->Modified();
this->ModelBounds[0] = xmin;
this->ModelBounds[1] = xmax;
this->ModelBounds[2] = ymin;
this->ModelBounds[3] = ymax;
this->ModelBounds[4] = zmin;
this->ModelBounds[5] = zmax;
this->Origin[0] = xmin;
this->Origin[1] = ymin;
this->Origin[2] = zmin;
if ( (length = xmax - xmin) == 0.0 ) length = 1.0;
this->AspectRatio[0] = 1.0;
this->AspectRatio[1] = (ymax - ymin) / length;
this->AspectRatio[2] = (zmax - zmin) / length;
}
bounds[0] = xmin;
bounds[1] = xmax;
bounds[2] = ymin;
bounds[3] = ymax;
bounds[4] = zmin;
bounds[5] = zmax;
this->SetModelBounds(bounds);
}
void vtkSweptSurface::Execute()
......@@ -113,10 +91,10 @@ void vtkSweptSurface::Execute()
int numSteps, stepNum;
int numTransforms, transNum;
vtkActor a;
vtkTransform *t1, *t2;
vtkTransform *transform1, *transform2, t;
float time;
float position[3], position1[3], position2[3];
float orientation[3], orientation1[3], orientation2[3];
float orient[3], orient1[3], orient2[3];
vtkDebugMacro(<<"Creating swept surface");
this->Initialize();
......@@ -145,14 +123,7 @@ void vtkSweptSurface::Execute()
}
this->SetDimensions(this->SampleDimensions);
// if bounds are not specified, compute bounds from path
if (this->ModelBounds[0] >= this->ModelBounds[1] ||
this->ModelBounds[2] >= this->ModelBounds[3] ||
this->ModelBounds[4] >= this->ModelBounds[5])
{
this->ComputeBounds();
}
this->ComputeBounds();
input->GetDimensions(inDim);
input->GetAspectRatio(inAr);
......@@ -167,25 +138,26 @@ void vtkSweptSurface::Execute()
// Sample data at each point in path
//
this->Transforms->InitTraversal();
t2 = this->Transforms->GetNextItem();
t2->Push();
t2->Inverse();
transform2 = this->Transforms->GetNextItem();
transform2->GetInverse(t.GetMatrix());
t.GetPosition(position2[0], position2[1], position2[2]);
t.GetOrientation(orient2[0], orient2[1], orient2[2]);
for (transNum=0; transNum < (numTransforms-1); transNum++)
{
vtkDebugMacro(<<"Injecting between transforms "<< transNum+1 <<" and "
<< transNum+2);
t1 = t2;
t2 = this->Transforms->GetNextItem();
t2->Push();
t2->Inverse();
transform1 = transform2;
transform2 = this->Transforms->GetNextItem();
transform2->GetInverse(t.GetMatrix());
//
// Loop over all points (i.e., voxels), transform into input coordinate system,
// and obtain interpolated value. Then perform union operation.
//
if ( this->Interpolation > 0 ) numSteps = this->Interpolation;
else if ( this->Interpolation < 0 ) numSteps = 1;
else numSteps = this->ComputeNumberOfSteps(t1,t2);
else numSteps = this->ComputeNumberOfSteps(transform1,transform2);
for (stepNum=0; stepNum < numSteps; stepNum++)
{
......@@ -195,34 +167,30 @@ void vtkSweptSurface::Execute()
for (i=0; i<3; i++)
{
position1[i] = position2[i];
orientation1[i] = orientation2[i];
orient1[i] = orient2[i];
}
t2->GetPosition(position2[0], position2[1], position2[2]);
t2->GetOrientation(orientation2[0], orientation2[1], orientation2[2]);
t.GetPosition(position2[0], position2[1], position2[2]);
t.GetOrientation(orient2[0], orient2[1], orient2[2]);
for (i=0; i<3; i++)
{
position[i] = position1[i] + time*(position2[i] - position1[i]);
orientation[i] = orientation1[i] + time*(orientation2[i] - orientation1[i]);
orient[i] = orient1[i] + time*(orient2[i] - orient1[i]);
}
a.SetPosition(position);
a.SetOrientation(orientation);
a.SetOrientation(orient);
this->SampleInput(a.GetMatrix(), inDim, inOrigin, inAr,
inScalars, newScalars);
}
t1->Pop();
}
//finish off last step
a.SetPosition(position2);
a.SetOrientation(orientation2);
a.SetOrientation(orient2);
this->SampleInput(a.GetMatrix(), inDim, inOrigin, inAr,
inScalars, newScalars);
t2->Pop();
// Update ourselves and release memory
this->PointData.SetScalars(newScalars);
newScalars->Delete();
......@@ -249,10 +217,10 @@ void vtkSweptSurface::SampleInput(vtkMatrix4x4& m, int inDim[3],
for (j=0; j<this->SampleDimensions[1]; j++)
{
jOffset = j*this->SampleDimensions[0];
x[1] = this->Origin[1] + k * this->AspectRatio[1];
x[1] = this->Origin[1] + j * this->AspectRatio[1];
for (i=0; i<this->SampleDimensions[0]; i++)
{
x[0] = this->Origin[0] + k * this->AspectRatio[0];
x[0] = this->Origin[0] + i * this->AspectRatio[0];
// transform into local space
m.PointMultiply(x,xTrans);
......@@ -274,10 +242,10 @@ void vtkSweptSurface::SampleInput(vtkMatrix4x4& m, int inDim[3],
idList.SetId(1,idx+1);
idList.SetId(2,idx+1 + inDim[0]);
idList.SetId(3,idx + inDim[0]);
idList.SetId(0,idx + sliceSize);
idList.SetId(1,idx+1 + sliceSize);
idList.SetId(2,idx+1 + inDim[0] + sliceSize);
idList.SetId(3,idx + inDim[0] + sliceSize);
idList.SetId(4,idx + inSliceSize);
idList.SetId(5,idx+1 + inSliceSize);
idList.SetId(6,idx+1 + inDim[0] + inSliceSize);
idList.SetId(7,idx + inDim[0] + inSliceSize);
inScalars->GetScalars(idList,voxelScalars);
......@@ -316,6 +284,27 @@ unsigned long int vtkSweptSurface::GetMTime()
// compute model bounds from geometry and path
void vtkSweptSurface::ComputeBounds()
{
int i, dim;
// if bounds are not specified, compute bounds from path
if (this->ModelBounds[0] >= this->ModelBounds[1] ||
this->ModelBounds[2] >= this->ModelBounds[3] ||
this->ModelBounds[4] >= this->ModelBounds[5])
{
}
else // else use what's specified
{
for (i=0; i<3; i++)
{
this->Origin[i] = this->ModelBounds[2*i];
if ( (dim=this->SampleDimensions[i]) <= 1 )
{
vtkWarningMacro(<<"Dimensions don't specify volume");
}
this->AspectRatio[i] =(this->ModelBounds[2*i+1] - this->ModelBounds[2*i])
/ (dim - 1);
}
}
}
// based on both path and bounding box of input, compute the number of
......
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