diff --git a/Filters/Geometry/vtkDataSetRegionSurfaceFilter.cxx b/Filters/Geometry/vtkDataSetRegionSurfaceFilter.cxx index 04a1bcf6259da16c3478545402b87d9bd3438ba3..f69a804604bb3ff9ec9579b487e1bc4ad32b1558 100644 --- a/Filters/Geometry/vtkDataSetRegionSurfaceFilter.cxx +++ b/Filters/Geometry/vtkDataSetRegionSurfaceFilter.cxx @@ -614,6 +614,7 @@ int vtkDataSetRegionSurfaceFilter::UnstructuredGridExecute( if (this->NonlinearSubdivisionLevel > 1) { // We are going to need parametric coordinates to further subdivide. + std::vector<double> weights(cell->GetNumberOfPoints()); double* pc = cell->GetParametricCoords(); parametricCoords->Reset(); parametricCoords->SetNumberOfComponents(3); @@ -655,8 +656,8 @@ int vtkDataSetRegionSurfaceFilter::UnstructuredGridExecute( inParamCoords[k][0] = 0.5 * (inParamCoords[pt1][0] + inParamCoords[pt2][0]); inParamCoords[k][1] = 0.5 * (inParamCoords[pt1][1] + inParamCoords[pt2][1]); inParamCoords[k][2] = 0.5 * (inParamCoords[pt1][2] + inParamCoords[pt2][2]); - inPts[k] = GetInterpolatedPointId( - inPts[pt1], inPts[pt2], input, cell, inParamCoords[k], newPts, outputPD); + inPts[k] = GetInterpolatedPointId(inPts[pt1], inPts[pt2], input, cell, + inParamCoords[k], weights.data(), newPts, outputPD); } // * 0 // / \ Use the 6 points recorded @@ -666,7 +667,7 @@ int vtkDataSetRegionSurfaceFilter::UnstructuredGridExecute( // / \ / \ . // *-----*-----* // 1 4 2 - const int subtriangles[12] = { 0, 3, 5, 3, 1, 4, 3, 4, 5, 5, 4, 2 }; + static const int subtriangles[12] = { 0, 3, 5, 3, 1, 4, 3, 4, 5, 5, 4, 2 }; for (k = 0; k < 12; k++) { int localId = subtriangles[k]; diff --git a/Filters/Geometry/vtkDataSetSurfaceFilter.cxx b/Filters/Geometry/vtkDataSetSurfaceFilter.cxx index ee5c728c0a2b2ddff2d3d56056621d9e04560225..c1aba920c8d6e4cdd33d990e602c37b2a95b231f 100644 --- a/Filters/Geometry/vtkDataSetSurfaceFilter.cxx +++ b/Filters/Geometry/vtkDataSetSurfaceFilter.cxx @@ -1605,6 +1605,7 @@ int vtkDataSetSurfaceFilter::UnstructuredGridExecuteInternal(vtkUnstructuredGrid } else { + weights.resize(cell->GetNumberOfPoints()); double paramCoordDelta = 1. / (numCellPtsAfterSubdivision - 1); cellIter->GetCell(cell); double inParamCoords[3]; @@ -1614,7 +1615,8 @@ int vtkDataSetSurfaceFilter::UnstructuredGridExecuteInternal(vtkUnstructuredGrid for (j = 0; j < numDeltaPtsAfterSubdivision - 1; j++) { inParamCoords[0] = paramCoordDelta * (numDeltaPtsAfterSubdivision * i + j + 1); - outPtId = GetInterpolatedPointId(input, cell, inParamCoords, newPts, outputPD); + outPtId = GetInterpolatedPointId( + input, cell, inParamCoords, weights.data(), newPts, outputPD); newLines->InsertCellPoint(outPtId); } if (i < numCellPts - 2) @@ -1648,6 +1650,7 @@ int vtkDataSetSurfaceFilter::UnstructuredGridExecuteInternal(vtkUnstructuredGrid { cellIter->GetCell(cell); input->SetCellOrderAndRationalWeights(cellId, cell); + weights.resize(cell->GetNumberOfPoints()); int numCellPtsAfterSubdivision = std::pow(2, this->NonlinearSubdivisionLevel - 1) * (numCellPts - 1) + 1; newLines->InsertNextCell(numCellPtsAfterSubdivision); @@ -1657,7 +1660,8 @@ int vtkDataSetSurfaceFilter::UnstructuredGridExecuteInternal(vtkUnstructuredGrid for (i = 0; i < numCellPtsAfterSubdivision; i++) { inParamCoords[0] = paramCoordDelta * i; - outPtId = GetInterpolatedPointId(input, cell, inParamCoords, newPts, outputPD); + outPtId = + GetInterpolatedPointId(input, cell, inParamCoords, weights.data(), newPts, outputPD); newLines->InsertCellPoint(outPtId); } } @@ -2085,8 +2089,8 @@ int vtkDataSetSurfaceFilter::UnstructuredGridExecuteInternal(vtkUnstructuredGrid inParamCoords[k][0] = 0.5 * (inParamCoords[pt1][0] + inParamCoords[pt2][0]); inParamCoords[k][1] = 0.5 * (inParamCoords[pt1][1] + inParamCoords[pt2][1]); inParamCoords[k][2] = 0.5 * (inParamCoords[pt1][2] + inParamCoords[pt2][2]); - inPts[k] = GetInterpolatedPointId( - inPts[pt1], inPts[pt2], input, cell, inParamCoords[k], newPts, outputPD); + inPts[k] = GetInterpolatedPointId(inPts[pt1], inPts[pt2], input, cell, + inParamCoords[k], weights.data(), newPts, outputPD); } // * 0 // / \ Use the 6 points recorded @@ -2096,7 +2100,7 @@ int vtkDataSetSurfaceFilter::UnstructuredGridExecuteInternal(vtkUnstructuredGrid // / \ / \ . // *-----*-----* // 1 4 2 - const int subtriangles[12] = { 0, 3, 5, 3, 1, 4, 3, 4, 5, 5, 4, 2 }; + static const int subtriangles[12] = { 0, 3, 5, 3, 1, 4, 3, 4, 5, 5, 4, 2 }; for (k = 0; k < 12; k++) { int localId = subtriangles[k]; @@ -2685,31 +2689,39 @@ vtkIdType vtkDataSetSurfaceFilter::GetOutputPointIdAndInterpolate(vtkIdType inPt //------------------------------------------------------------------------------ vtkIdType vtkDataSetSurfaceFilter::GetInterpolatedPointId(vtkIdType edgePtA, vtkIdType edgePtB, vtkDataSet* input, vtkCell* cell, double pcoords[3], vtkPoints* outPts, vtkPointData* outPD) +{ + std::vector<double> weights(cell->GetNumberOfPoints()); + return this->GetInterpolatedPointId( + edgePtA, edgePtB, input, cell, pcoords, weights.data(), outPts, outPD); +} + +//------------------------------------------------------------------------------ +vtkIdType vtkDataSetSurfaceFilter::GetInterpolatedPointId(vtkIdType edgePtA, vtkIdType edgePtB, + vtkDataSet* input, vtkCell* cell, double pcoords[3], double* weights, vtkPoints* outPts, + vtkPointData* outPD) { vtkIdType outPtId = this->EdgeMap->FindEdge(edgePtA, edgePtB); if (outPtId == -1) { int subId = -1; double wcoords[3]; - std::vector<double> weights(cell->GetNumberOfPoints()); - cell->EvaluateLocation(subId, pcoords, wcoords, weights.data()); + cell->EvaluateLocation(subId, pcoords, wcoords, weights); outPtId = outPts->InsertNextPoint(wcoords); - outPD->InterpolatePoint(input->GetPointData(), outPtId, cell->GetPointIds(), weights.data()); + outPD->InterpolatePoint(input->GetPointData(), outPtId, cell->GetPointIds(), weights); this->RecordOrigPointId(outPtId, -1); this->EdgeMap->AddEdge(edgePtA, edgePtB, outPtId); } return outPtId; } -vtkIdType vtkDataSetSurfaceFilter::GetInterpolatedPointId( - vtkDataSet* input, vtkCell* cell, double pcoords[3], vtkPoints* outPts, vtkPointData* outPD) +vtkIdType vtkDataSetSurfaceFilter::GetInterpolatedPointId(vtkDataSet* input, vtkCell* cell, + double pcoords[3], double* weights, vtkPoints* outPts, vtkPointData* outPD) { int subId = -1; double wcoords[3]; - std::vector<double> weights(cell->GetNumberOfPoints()); - cell->EvaluateLocation(subId, pcoords, wcoords, weights.data()); + cell->EvaluateLocation(subId, pcoords, wcoords, weights); vtkIdType outPtId = outPts->InsertNextPoint(wcoords); - outPD->InterpolatePoint(input->GetPointData(), outPtId, cell->GetPointIds(), weights.data()); + outPD->InterpolatePoint(input->GetPointData(), outPtId, cell->GetPointIds(), weights); this->RecordOrigPointId(outPtId, -1); return outPtId; } diff --git a/Filters/Geometry/vtkDataSetSurfaceFilter.h b/Filters/Geometry/vtkDataSetSurfaceFilter.h index e157a6fe019fdb98567e71be07d158524f741850..4d1f49f4b0c5fdc020ce267e4de45bc75dcf0c91 100644 --- a/Filters/Geometry/vtkDataSetSurfaceFilter.h +++ b/Filters/Geometry/vtkDataSetSurfaceFilter.h @@ -320,10 +320,15 @@ protected: class vtkEdgeInterpolationMap; vtkEdgeInterpolationMap* EdgeMap; + VTK_DEPRECATED_IN_9_1_0( + "Use GetInterpolatedPointId(vtkIdType edgePtA, vtkIdType edgePtB, vtkDataSet* input, vtkCell* " + "cell, double pcoords[3], double* weights, vtkPoints* outPts, vtkPointData* outPD) instead") vtkIdType GetInterpolatedPointId(vtkIdType edgePtA, vtkIdType edgePtB, vtkDataSet* input, vtkCell* cell, double pcoords[3], vtkPoints* outPts, vtkPointData* outPD); - vtkIdType GetInterpolatedPointId( - vtkDataSet* input, vtkCell* cell, double pcoords[3], vtkPoints* outPts, vtkPointData* outPD); + vtkIdType GetInterpolatedPointId(vtkIdType edgePtA, vtkIdType edgePtB, vtkDataSet* input, + vtkCell* cell, double pcoords[3], double* weights, vtkPoints* outPts, vtkPointData* outPD); + vtkIdType GetInterpolatedPointId(vtkDataSet* input, vtkCell* cell, double pcoords[3], + double* weights, vtkPoints* outPts, vtkPointData* outPD); vtkIdType NumberOfNewCells; // Better memory allocation for faces (hash)