Commit e3f9c88d authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

Simplify vtkAppendPolyData.

vtkAppendPolyData had "fast path" which was no longer needed.
vtkDataSetAttributes/vtkDataArray already uses fast path to copy arrays.
parent f4662727
......@@ -143,11 +143,6 @@ int vtkAppendPolyData::ExecuteAppend(vtkPolyData* output,
vtkCellData *inCD = nullptr;
vtkPointData *outputPD = output->GetPointData();
vtkCellData *outputCD = output->GetCellData();
vtkDataArray *newPtScalars = nullptr;
vtkDataArray *newPtVectors = nullptr;
vtkDataArray *newPtNormals = nullptr;
vtkDataArray *newPtTCoords = nullptr;
vtkDataArray *newPtTensors = nullptr;
vtkIdType *pStrips, *pLines, *pPolys,*pVerts;
vtkDebugMacro(<<"Appending polydata");
......@@ -336,80 +331,6 @@ int vtkAppendPolyData::ExecuteAppend(vtkPolyData* output,
return 0;
}
// These are created manually for faster execution
// Uses the properties of the last input
vtkDataArray *inDA=nullptr;
if ( ptList.IsAttributePresent(vtkDataSetAttributes::SCALARS) > -1 )
{
inDA=inPD->GetScalars();
outputPD->CopyScalarsOff();
newPtScalars = inDA->NewInstance();
newPtScalars->SetNumberOfComponents(inDA->GetNumberOfComponents());
newPtScalars->CopyComponentNames( inDA );
newPtScalars->SetName(inDA->GetName());
newPtScalars->SetNumberOfTuples(numPts);
if (inDA->HasInformation())
{
newPtScalars->CopyInformation(inDA->GetInformation(),/*deep=*/1);
}
}
if ( ptList.IsAttributePresent(vtkDataSetAttributes::VECTORS) > -1 )
{
inDA=inPD->GetVectors();
outputPD->CopyVectorsOff();
newPtVectors = inDA->NewInstance();
newPtVectors->SetNumberOfComponents(inDA->GetNumberOfComponents());
newPtVectors->CopyComponentNames( inDA );
newPtVectors->SetName(inDA->GetName());
newPtVectors->SetNumberOfTuples(numPts);
if (inDA->HasInformation())
{
newPtVectors->CopyInformation(inDA->GetInformation(),/*deep=*/1);
}
}
if ( ptList.IsAttributePresent(vtkDataSetAttributes::TENSORS) > -1 )
{
inDA=inPD->GetTensors();
outputPD->CopyTensorsOff();
newPtTensors = inDA->NewInstance();
newPtTensors->SetNumberOfComponents(inDA->GetNumberOfComponents());
newPtTensors->CopyComponentNames( inDA );
newPtTensors->SetName(inDA->GetName());
newPtTensors->SetNumberOfTuples(numPts);
if (inDA->HasInformation())
{
newPtTensors->CopyInformation(inDA->GetInformation(),/*deep=*/1);
}
}
if ( ptList.IsAttributePresent(vtkDataSetAttributes::NORMALS) > -1 )
{
inDA=inPD->GetNormals();
outputPD->CopyNormalsOff();
newPtNormals = inDA->NewInstance();
newPtNormals->SetNumberOfComponents(inDA->GetNumberOfComponents());
newPtNormals->CopyComponentNames( inDA );
newPtNormals->SetName(inDA->GetName());
newPtNormals->SetNumberOfTuples(numPts);
if (inDA->HasInformation())
{
newPtNormals->CopyInformation(inDA->GetInformation(),/*deep=*/1);
}
}
if ( ptList.IsAttributePresent(vtkDataSetAttributes::TCOORDS) > -1 )
{
inDA=inPD->GetTCoords();
outputPD->CopyTCoordsOff();
newPtTCoords = inDA->NewInstance();
newPtTCoords->SetNumberOfComponents(inDA->GetNumberOfComponents());
newPtTCoords->CopyComponentNames( inDA );
newPtTCoords->SetName(inDA->GetName());
newPtTCoords->SetNumberOfTuples(numPts);
if (inDA->HasInformation())
{
newPtTCoords->CopyInformation(inDA->GetInformation(),/*deep=*/1);
}
}
// Allocate the point and cell data
outputPD->CopyAllocate(ptList,numPts);
outputCD->CopyAllocate(cellList,numCells);
......@@ -447,35 +368,7 @@ int vtkAppendPolyData::ExecuteAppend(vtkPolyData* output,
if (ds->GetNumberOfPoints() > 0)
{
// copy points directly
this->AppendData(newPts->GetData(),
inPts->GetData(), ptOffset);
// copy scalars directly
if (newPtScalars)
{
this->AppendData(newPtScalars, inPD->GetScalars(), ptOffset);
}
// copy normals directly
if (newPtNormals)
{
this->AppendData(newPtNormals, inPD->GetNormals(), ptOffset);
}
// copy vectors directly
if (newPtVectors)
{
this->AppendData(newPtVectors, inPD->GetVectors(), ptOffset);
}
// copy tcoords directly
if (newPtTCoords)
{
this->AppendData(newPtTCoords, inPD->GetTCoords() , ptOffset);
}
// copy tensors directly
if (newPtTensors)
{
this->AppendData(newPtTensors, inPD->GetTensors(), ptOffset);
}
// append the remainder of the field data
this->AppendData(newPts->GetData(), inPts->GetData(), ptOffset);
outputPD->CopyData(ptList, inPD, countPD, ptOffset, numPts, 0);
++countPD;
}
......@@ -514,32 +407,6 @@ int vtkAppendPolyData::ExecuteAppend(vtkPolyData* output,
output->SetPoints(newPts);
newPts->Delete();
if (newPtScalars)
{
output->GetPointData()->SetScalars(newPtScalars);
newPtScalars->Delete();
}
if (newPtNormals)
{
output->GetPointData()->SetNormals(newPtNormals);
newPtNormals->Delete();
}
if (newPtVectors)
{
output->GetPointData()->SetVectors(newPtVectors);
newPtVectors->Delete();
}
if (newPtTCoords)
{
output->GetPointData()->SetTCoords(newPtTCoords);
newPtTCoords->Delete();
}
if (newPtTensors)
{
output->GetPointData()->SetTensors(newPtTensors);
newPtTensors->Delete();
}
if ( newVerts->GetNumberOfCells() > 0 )
{
output->SetVerts(newVerts);
......
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