-// Copyright (C) 2010-2014 CEA/DEN, EDF R&D
+// Copyright (C) 2010-2016 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include "vtkUnstructuredGrid.h"
#include "MEDUtilities.hxx"
+#include "InterpKernelAutoPtr.hxx"
//vtkCxxRevisionMacro(vtkELNOFilter, "$Revision: 1.2.2.2 $");
vtkStandardNewMacro(vtkELNOFilter);
return 0;
int dictSize(key->Size(info));
- vtkQuadratureSchemeDefinition **dict(new vtkQuadratureSchemeDefinition *[dictSize]);
+ vtkQuadratureSchemeDefinition **dict = new vtkQuadratureSchemeDefinition *[dictSize];
key->GetRange(info, dict, 0, 0, dictSize);
vtkIdType ncell(usgIn->GetNumberOfCells());
}
}
}
+ AttachCellFieldsOn(usgIn,pdOut->GetCellData(),pdOut->GetNumberOfCells());
return 1;
}
this->Superclass::PrintSelf(os, indent);
os << indent << "ShrinkFactor : " << this->ShrinkFactor << endl;
}
+
+/*!
+ * 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);
+ }
+ }
+}