Commit e492c476 authored by Bill Lorensen's avatar Bill Lorensen
Browse files

BUG: Misleading error message.

The error "Bad plane coordinate system" can appear when using
SetPoint1 or SetPoint2. The UpdatePlane() method is called by the
methods SetPoint1 or 2. UpdatePlane() will report a bad coordinate
system if the resulting normal is of 0 length. The error message can
be premature if a subsequent SetPoint2 or 1 creates a valid coordinate
system.

This fix moves the error message from UpdatePlane() into
RequestData(), where an improper coordinate system is a valid error.
parent 00b6cd7a
......@@ -96,8 +96,10 @@ int vtkPlaneSource::RequestData(
v1[i] = this->Point1[i] - this->Origin[i];
v2[i] = this->Point2[i] - this->Origin[i];
}
if ( !this->UpdatePlane(v1,v2) )
{
vtkErrorMacro(<<"Bad plane coordinate system");
return 0;
}
......@@ -241,8 +243,9 @@ void vtkPlaneSource::SetNormal(double nx, double ny, double nz)
// instance variables as necessary (i.e., translate the plane).
void vtkPlaneSource::SetCenter(double center[3])
{
if ( this->Center[0] == center[0] && this->Center[1] == center[1] &&
this->Center[2] == center[2] )
if ( this->Center[0] == center[0] &&
this->Center[1] == center[1] &&
this->Center[2] == center[2] )
{
return; //no change
}
......@@ -307,7 +310,8 @@ void vtkPlaneSource::SetPoint1(double pnt[3])
// modifies the normal and origin
void vtkPlaneSource::SetPoint2(double pnt[3])
{
if ( this->Point2[0] == pnt[0] && this->Point2[1] == pnt[1] &&
if ( this->Point2[0] == pnt[0] &&
this->Point2[1] == pnt[1] &&
this->Point2[2] == pnt[2] )
{
return; //no change
......@@ -382,7 +386,6 @@ int vtkPlaneSource::UpdatePlane(double v1[3], double v2[3])
vtkMath::Cross(v1,v2,this->Normal);
if ( vtkMath::Normalize(this->Normal) == 0.0 )
{
vtkErrorMacro(<<"Bad plane coordinate system");
return 0;
}
else
......@@ -398,24 +401,29 @@ void vtkPlaneSource::PrintSelf(ostream& os, vtkIndent indent)
os << indent << "X Resolution: " << this->XResolution << "\n";
os << indent << "Y Resolution: " << this->YResolution << "\n";
os << indent << "Origin: (" << this->Origin[0] << ", "
<< this->Origin[1] << ", "
<< this->Origin[2] << ")\n";
os << indent << "Point 1: (" << this->Point1[0] << ", "
<< this->Point1[1] << ", "
<< this->Point1[2] << ")\n";
os << indent << "Point 2: (" << this->Point2[0] << ", "
<< this->Point2[1] << ", "
<< this->Point2[2] << ")\n";
os << indent << "Normal: (" << this->Normal[0] << ", "
<< this->Normal[1] << ", "
<< this->Normal[2] << ")\n";
os << indent << "Center: (" << this->Center[0] << ", "
<< this->Center[1] << ", "
<< this->Center[2] << ")\n";
os << indent << "Origin: ("
<< this->Origin[0] << ", "
<< this->Origin[1] << ", "
<< this->Origin[2] << ")\n";
os << indent << "Point 1: ("
<< this->Point1[0] << ", "
<< this->Point1[1] << ", "
<< this->Point1[2] << ")\n";
os << indent << "Point 2: ("
<< this->Point2[0] << ", "
<< this->Point2[1] << ", "
<< this->Point2[2] << ")\n";
os << indent << "Normal: ("
<< this->Normal[0] << ", "
<< this->Normal[1] << ", "
<< this->Normal[2] << ")\n";
os << indent << "Center: ("
<< this->Center[0] << ", "
<< this->Center[1] << ", "
<< this->Center[2] << ")\n";
}
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