Commit 5ff0a170 authored by Will Schroeder's avatar Will Schroeder

Fixed error interpolating attributes with multiple contour values

These changes address issue #17597.
parent c73b01a6
......@@ -20,6 +20,7 @@ vtk_add_test_python(
TestContour3DLinearGrid.py
TestContour3DLinearGrid2.py
TestContour3DLinearGridCompositeInput.py
TestContour3DLinearGridInterpolateAttributes.py,NO_VALID
TestContour3DLinearGridScalarTree.py
TestDecimatePolylineMaximumError.py
TestElevationFilter.py
......
#!/usr/bin/env python
import vtk
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# Set up source for linear cells
cellSource = vtk.vtkCellTypeSource()
cellSource.SetCellType(12)
cellSource.SetBlocksDimensions(10, 10, 10)
cellSource.Update()
# Add several contour values
contour = vtk.vtkContour3DLinearGrid()
contour.SetInputConnection(cellSource.GetOutputPort())
contour.SetInputArrayToProcess(0, 0, 0, vtk.vtkDataObject.FIELD_ASSOCIATION_POINTS, "DistanceToCenter")
contour.SetValue(0, 4)
contour.SetValue(1, 5)
contour.SetValue(2, 6)
contour.SetMergePoints(1)
contour.SetSequentialProcessing(0)
contour.SetInterpolateAttributes(1);
contour.SetComputeNormals(1);
contour.Update()
# Ensure that the number of tuples in the output arrays matches the number of points
output = contour.GetOutput()
ptData = output.GetPointData()
for i in range(ptData.GetNumberOfArrays()):
numTuples = ptData.GetArray(i).GetNumberOfTuples()
numPts = output.GetNumberOfPoints()
print("numTuples: %d numPts: %d" % (numTuples, numPts))
assert(numTuples == numPts)
......@@ -1372,8 +1372,8 @@ template <typename TIds>
int ProcessMerged(vtkIdType numCells, vtkPoints *inPts, CellIter *cellIter,
int sType, void *s, double isoValue, vtkPoints *outPts,
vtkCellArray *newPolys, vtkTypeBool intAttr, vtkDataArray *inScalars,
vtkPointData *inPD, vtkPointData *outPD, vtkScalarTree *st, vtkTypeBool seqProcessing,
int &numThreads, vtkIdType totalPts, vtkIdType totalTris)
vtkPointData *inPD, vtkPointData *outPD, ArrayList *arrays, vtkScalarTree *st,
vtkTypeBool seqProcessing, int &numThreads, vtkIdType totalPts, vtkIdType totalTris)
{
// Extract edges that the contour intersects. Templated on type of scalars.
// List below the explicit choice of scalars that can be processed.
......@@ -1447,19 +1447,18 @@ int ProcessMerged(vtkIdType numCells, vtkPoints *inPts, CellIter *cellIter,
// Now process point data attributes if requested
if ( intAttr )
{
ArrayList arrays;
if ( totalPts <= 0 ) //first contour value generating output
{
outPD->InterpolateAllocate(inPD,numPts);
outPD->RemoveArray(inScalars->GetName());
arrays.ExcludeArray(inScalars);
arrays.AddArrays(numPts,inPD,outPD);
arrays->ExcludeArray(inScalars);
arrays->AddArrays(numPts,inPD,outPD);
}
else
{
arrays.Realloc(totalPts+numPts);
arrays->Realloc(totalPts+numPts);
}
ProduceAttributes<TIds> interpolate(mergeEdges,offsets,&arrays,totalPts);
ProduceAttributes<TIds> interpolate(mergeEdges,offsets,arrays,totalPts);
EXECUTE_SMPFOR(seqProcessing,numPts,interpolate);
}
......@@ -1795,6 +1794,7 @@ ProcessPiece(vtkUnstructuredGrid *input, vtkDataArray *inScalars, vtkPolyData *o
{
vtkPointData *inPD = input->GetPointData();
vtkPointData *outPD = output->GetPointData();
ArrayList arrays;
// Determine the size/type of point and cell ids needed to index points
// and cells. Using smaller ids results in a greatly reduced memory footprint
......@@ -1810,8 +1810,9 @@ ProcessPiece(vtkUnstructuredGrid *input, vtkDataArray *inScalars, vtkPolyData *o
{
if ( ! ProcessMerged<int>(numCells, inPts, cellIter, sType, sPtr, value,
outPts, newPolys, this->InterpolateAttributes,
inScalars, inPD, outPD, stree, this->SequentialProcessing,
this->NumberOfThreadsUsed, totalPts, totalTris) )
inScalars, inPD, outPD, &arrays, stree,
this->SequentialProcessing, this->NumberOfThreadsUsed,
totalPts, totalTris) )
{
return;
}
......@@ -1820,8 +1821,9 @@ ProcessPiece(vtkUnstructuredGrid *input, vtkDataArray *inScalars, vtkPolyData *o
{
if ( ! ProcessMerged<vtkIdType>(numCells, inPts, cellIter, sType, sPtr, value,
outPts, newPolys, this->InterpolateAttributes,
inScalars, inPD, outPD, stree, this->SequentialProcessing,
this->NumberOfThreadsUsed, totalPts, totalTris) )
inScalars, inPD, outPD, &arrays, stree,
this->SequentialProcessing, this->NumberOfThreadsUsed,
totalPts, totalTris) )
{
return;
}
......
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