if (this->AxisLabelTextProperty &&
this->AxisLabelTextProperty->GetMTime() > this->BuildTime)
{
- if (this->XAxis->GetTitleTextProperty())
+ if (this->XAxis->GetLabelTextProperty())
{
this->XAxis->GetLabelTextProperty()->ShallowCopy(
this->AxisLabelTextProperty);
}
- if (this->YAxis->GetTitleTextProperty())
+ if (this->YAxis->GetLabelTextProperty())
{
this->YAxis->GetLabelTextProperty()->ShallowCopy(
this->AxisLabelTextProperty);
(ds = this->InputList->GetNextDataSet(dsit)); dsNum++)
{
numPts = ds->GetNumberOfPoints();
+ if (numPts == 0)
+ {
+ vtkErrorMacro(<<"No scalar data to plot!");
+ continue;
+ }
if ( this->XValues != VTK_XYPLOT_INDEX )
{
}//over all datasets
}
+//----------------------------------------------------------------------------
+static inline int VISU_XYPlotActorGetComponent(vtkFieldData* field,
+ vtkIdType tuple, int component, double* val)
+{
+ int array_comp;
+ int array_index = field->GetArrayContainingComponent(component, array_comp);
+ if (array_index < 0)
+ {
+ return 0;
+ }
+ vtkDataArray* da = field->GetArray(array_index);
+ if (!da)
+ {
+ // non-numeric array.
+ return 0;
+ }
+ *val = da->GetComponent(tuple, array_comp);
+ return 1;
+}
+
//----------------------------------------------------------------------------
void VISU_XYPlotActor::ComputeDORange(double xrange[2], double yrange[2],
double *lengths)
vtkFieldData *field;
int doNum, numColumns;
vtkIdType numTuples, numRows, num, ptId, maxNum;
- double maxLength=0.0, x, y, xPrev = 0.0;
+ double maxLength=0.0;
+ double x = 0.0;
+ double y = 0.0;
+ double xPrev = 0.0;
vtkDataArray *array;
-
+
+ // NOTE: FieldData can have non-numeric arrays. However, XY plot can only
+ // work on numeric arrays (or vtkDataArray subclasses).
+
xrange[0] = yrange[0] = VTK_DOUBLE_MAX;
xrange[1] = yrange[1] = -VTK_DOUBLE_MAX;
vtkCollectionSimpleIterator doit;
for ( doNum=0, maxNum=0, this->DataObjectInputList->InitTraversal(doit);
(dobj = this->DataObjectInputList->GetNextDataObject(doit)); doNum++)
{
+
lengths[doNum] = 0.0;
field = dobj->GetFieldData();
- numColumns = field->GetNumberOfComponents(); //number of "columns"
+ numColumns = field->GetNumberOfComponents(); //number of "columns"
+ // numColumns includes the components for non-numeric arrays as well.
for (numRows = VTK_LARGE_ID, i=0; i<field->GetNumberOfArrays(); i++)
{
array = field->GetArray(i);
+ if (!array)
+ {
+ // non-numeric array, skip.
+ continue;
+ }
numTuples = array->GetNumberOfTuples();
if ( numTuples < numRows )
{
// gather the information to form a plot
for ( ptId=0; ptId < num; ptId++ )
{
+ int status = 0;
+
if ( this->DataObjectPlotMode == VTK_XYPLOT_ROW )
{
- x = field->GetComponent(this->XComponent->GetValue(doNum), ptId);
+ // x = field->GetComponent(this->XComponent->GetValue(doNum), ptId);
+ status = ::VISU_XYPlotActorGetComponent(field,
+ this->XComponent->GetValue(doNum), ptId, &x);
}
else //if ( this->DataObjectPlotMode == VTK_XYPLOT_COLUMN )
{
- x = field->GetComponent(ptId, this->XComponent->GetValue(doNum));
+ // x = field->GetComponent(ptId, this->XComponent->GetValue(doNum));
+ status = ::VISU_XYPlotActorGetComponent(field,
+ ptId, this->XComponent->GetValue(doNum), &x);
+ }
+ if (!status)
+ {
+ // requested component falls in a non-numeric array, skip it.
+ continue;
}
if ( ptId == 0 )
{
// Get the y-values
for ( ptId=0; ptId < num; ptId++ )
{
+ int status = 0;
if ( this->DataObjectPlotMode == VTK_XYPLOT_ROW )
{
- y = field->GetComponent(this->YComponent->GetValue(doNum), ptId);
+ //y = field->GetComponent(this->YComponent->GetValue(doNum), ptId);
+ status = ::VISU_XYPlotActorGetComponent(field,
+ this->YComponent->GetValue(doNum), ptId, &y);
}
else //if ( this->DataObjectPlotMode == VTK_XYPLOT_COLUMN )
{
- y = field->GetComponent(ptId, this->YComponent->GetValue(doNum));
+ //y = field->GetComponent(ptId, this->YComponent->GetValue(doNum));
+ status = ::VISU_XYPlotActorGetComponent(field,
+ ptId, this->YComponent->GetValue(doNum), &y);
+ }
+ if (!status)
+ {
+ // requested component falls in non-numeric array.
+ // skip.
+ continue;
}
if ( y < yrange[0] )
{
// determine the shape of the field
field = dobj->GetFieldData();
numColumns = field->GetNumberOfComponents(); //number of "columns"
+ // numColumns also includes non-numeric array components.
for (numRows = VTK_LARGE_ID, i=0; i<field->GetNumberOfArrays(); i++)
{
array = field->GetArray(i);
+ if (!array)
+ {
+ // skip non-numeric arrays.
+ continue;
+ }
numTuples = array->GetNumberOfTuples();
if ( numTuples < numRows )
{
// gather the information to form a plot
for ( numLinePts=0, length=0.0, ptId=0; ptId < numPts; ptId++ )
{
+ int status1, status2;
if ( this->DataObjectPlotMode == VTK_XYPLOT_ROW )
{
- x[0] = field->GetComponent(this->XComponent->GetValue(doNum),ptId);
- xyz[1] = field->GetComponent(this->YComponent->GetValue(doNum),ptId);
+ //x[0] = field->GetComponent(this->XComponent->GetValue(doNum),ptId);
+ //xyz[1] = field->GetComponent(this->YComponent->GetValue(doNum),ptId);
+ status1 = ::VISU_XYPlotActorGetComponent(field,
+ this->XComponent->GetValue(doNum), ptId, &x[0]);
+ status2 = ::VISU_XYPlotActorGetComponent(field,
+ this->YComponent->GetValue(doNum), ptId, &xyz[1]);
}
else //if ( this->DataObjectPlotMode == VTK_XYPLOT_COLUMN )
{
- x[0] = field->GetComponent(ptId, this->XComponent->GetValue(doNum));
- xyz[1] = field->GetComponent(ptId, this->YComponent->GetValue(doNum));
+ //x[0] = field->GetComponent(ptId, this->XComponent->GetValue(doNum));
+ //xyz[1] = field->GetComponent(ptId, this->YComponent->GetValue(doNum));
+
+ status1 = ::VISU_XYPlotActorGetComponent(field,
+ ptId, this->XComponent->GetValue(doNum), &x[0]);
+
+ if (!status1)
+ {
+ vtkWarningMacro(<< this->XComponent->GetValue(doNum) << " is a non-numeric component.");
+ }
+
+ status2 = ::VISU_XYPlotActorGetComponent(field,
+ ptId, this->YComponent->GetValue(doNum), &xyz[1]);
+
+ if (!status2)
+ {
+ vtkWarningMacro(<< this->YComponent->GetValue(doNum) << " is a non-numeric component.");
+ }
+ }
+ if (!status1 || !status2)
+ {
+ // component is non-numeric.
+ // Skip it.
+ continue;
}
switch (this->XValues)
}
else
{
+ newPts[0] = -1;
if (x1[0] >= p1[0] && x1[0] <= p2[0] && x1[1] >= p1[1] && x1[1] <= p2[1] )
{//first point in
newPts[0] = pointMap[pts[i]];
}
- else
+ else if (x2[0] >= p1[0] && x2[0] <= p2[0] && x2[1] >= p1[1] && x2[1] <= p2[1] )
{//second point in
newPts[0] = pointMap[pts[i+1]];
}
- for (j=0; j<4; j++)
+
+ //only create cell if either x1 or x2 is inside the range
+ if (newPts[0] >= 0)
{
- this->ClipPlanes->GetPoints()->GetPoint(j, px);
- this->ClipPlanes->GetNormals()->GetTuple(j, n);
- if ( vtkPlane::IntersectWithLine(x1,x2,n,px,t,xint) && t >= 0 && t <= 1.0 )
+ for (j=0; j<4; j++)
{
- newPts[1] = newPoints->InsertNextPoint(xint);
- break;
+ this->ClipPlanes->GetPoints()->GetPoint(j, px);
+ this->ClipPlanes->GetNormals()->GetTuple(j, n);
+ if ( vtkPlane::IntersectWithLine(x1,x2,n,px,t,xint) && t >= 0 && t <= 1.0 )
+ {
+ newPts[1] = newPoints->InsertNextPoint(xint);
+ break;
+ }
}
+ newLines->InsertNextCell(2,newPts);
}
- newLines->InsertNextCell(2,newPts);
}
}
}