+
+/*!
+ * This method attach fields on cell of \a inGrid and add it as a point data in \a outData.
+ */
+void vtkELNOFilter::AttachCellFieldsOn(vtkUnstructuredGrid *inGrid, vtkCellData *outData, int nbCellsOut)
+{
+ vtkCellData *cd(inGrid->GetCellData());
+ int nbOfArrays(cd->GetNumberOfArrays());
+ vtkIdType nbCells(inGrid->GetNumberOfCells());
+ if(nbOfArrays==0)
+ return ;
+ INTERP_KERNEL::AutoPtr<vtkIdType> tmpPtr(new vtkIdType[nbCells]);
+ for(vtkIdType cellId=0;cellId<nbCells;cellId++)
+ {
+ vtkCell *cell(inGrid->GetCell(cellId));
+ tmpPtr[cellId]=cell->GetNumberOfPoints();
+ }
+ for(int index=0;index<nbOfArrays;index++)
+ {
+ vtkDataArray *data(cd->GetArray(index));
+ vtkDataArray *newArray(data->NewInstance());
+ newArray->SetName(data->GetName());
+ outData->AddArray(newArray);
+ newArray->SetNumberOfComponents(data->GetNumberOfComponents());
+ newArray->SetNumberOfTuples(nbCellsOut);
+ newArray->CopyComponentNames(data);
+ newArray->Delete();
+ vtkIdType offset(0);
+ for(vtkIdType cellId=0;cellId<nbCells;cellId++)
+ {
+ for(vtkIdType j=0;j<tmpPtr[cellId];j++,offset++)
+ newArray->SetTuple(offset,cellId,data);
+ }
+ }
+}