51 vtkInformation *vtkNotUsed(request),
52 vtkInformationVector **inputVector,
53 vtkInformationVector *outputVector)
56 vtkInformation *outInfo = outputVector->GetInformationObject(0);
59 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
60 outInfo->Get(vtkDataObject::DATA_OBJECT()));
62 vtkIdType numPts, numCells;
63 int tenth, count, abort=0;
68 vtkIdList *ptIds, *newPtIds;
71 vtkIdType ptId, cellId, newCellId;
72 vtkPointData *outputPD = output->GetPointData();
73 vtkCellData *outputCD = output->GetCellData();
75 vtkDebugMacro(<<
"Appending data together");
77 double bounds[6], inputBounds[6];
78 vtkMath::UninitializeBounds(bounds);
90 int numInputs = inputVector[0]->GetNumberOfInformationObjects();
91 vtkDataSetAttributes::FieldList ptList(numInputs);
92 vtkDataSetAttributes::FieldList cellList(numInputs);
95 vtkInformation *inInfo = 0;
96 for (idx = 0; idx < numInputs; ++idx)
98 inInfo = inputVector[0]->GetInformationObject(idx);
102 ds = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
106 if ( ds->GetNumberOfPoints() <= 0 && ds->GetNumberOfCells() <= 0 )
111 numPts += ds->GetNumberOfPoints();
112 numCells += ds->GetNumberOfCells();
114 ds->GetBounds(inputBounds);
115 if (vtkMath::AreBoundsInitialized(bounds))
120 if (inputBounds[j] < bounds[j])
122 bounds[j] = inputBounds[j];
124 if (inputBounds[j+1] > bounds[j+1])
126 bounds[j+1] = inputBounds[j+1];
135 bounds[j] = inputBounds[j];
136 bounds[j+1] = inputBounds[j+1];
140 pd = ds->GetPointData();
143 ptList.InitializeFieldList(pd);
148 ptList.IntersectFieldList(pd);
151 cd = ds->GetCellData();
154 cellList.InitializeFieldList(cd);
159 cellList.IntersectFieldList(cd);
166 vtkDebugMacro(<<
"No data to append!");
171 output->Allocate(numCells);
173 outputPD->CopyAllocate(ptList,numPts);
175 outputCD->CopyAllocate(cellList,numCells);
177 newPts = vtkPoints::New();
178 ptIds = vtkIdList::New(); ptIds->Allocate(VTK_CELL_SIZE);
179 newPtIds = vtkIdList::New(); newPtIds->Allocate(VTK_CELL_SIZE);
181 vtkMergePoints* locator = vtkMergePoints::New();
184 locator->InitPointInsertion(newPts,bounds);
187 vtkIdList* ptIdMap = vtkIdList::New();
194 tenth = (numPts + numCells)/10 + 1;
196 for (idx = 0; idx < numInputs && !abort; ++idx)
198 inInfo = inputVector[0]->GetInformationObject(idx);
202 ds = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
205 (ds->GetNumberOfPoints() > 0 || ds->GetNumberOfCells() > 0) )
207 numPts = ds->GetNumberOfPoints();
208 numCells = ds->GetNumberOfCells();
209 pd = ds->GetPointData();
211 ptIdMap->Initialize();
212 ptIdMap->SetNumberOfIds(numPts);
215 for (ptId=0; ptId < numPts && !abort; ptId++)
217 ds->GetPoint(ptId,point);
220 if (locator->InsertUniquePoint(point,newPtId))
222 outputPD->CopyData(ptList,pd,inputCount,ptId,newPtId);
227 newPtId = newPts->InsertNextPoint(point);
228 outputPD->CopyData(ptList,pd,inputCount,ptId,newPtId);
230 ptIdMap->SetId(ptId,newPtId);
234 if (!(count % tenth))
237 this->UpdateProgress(decimal);
238 abort = this->GetAbortExecute();
242 cd = ds->GetCellData();
244 for (cellId=0; cellId<numCells && !abort; cellId++)
246 ds->GetCellPoints(cellId, ptIds);
248 for (i=0; i<ptIds->GetNumberOfIds(); i++)
250 newPtIds->InsertId(i,ptIdMap->GetId(ptIds->GetId(i)));
252 newCellId = output->InsertNextCell(ds->GetCellType(cellId),newPtIds);
253 outputCD->CopyData(cellList,cd,inputCount,cellId,newCellId);
257 if (!(count % tenth))
260 this->UpdateProgress(decimal);
261 abort = this->GetAbortExecute();
270 output->SetPoints(newPts);