X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPlugins%2FMEDReader%2FIO%2FvtkELNOFilter.cxx;h=5bd75e61691a7a1c5c69ac279b6c4763a930ba75;hb=f24ad457e027761c8df0671ba283a27af1ae3511;hp=8af029279e19edbd389e9d1bd8f5518d6126a85a;hpb=31c4fb7eb65d19f8b21266c38a0460e37fc9d39a;p=modules%2Fparavis.git diff --git a/src/Plugins/MEDReader/IO/vtkELNOFilter.cxx b/src/Plugins/MEDReader/IO/vtkELNOFilter.cxx index 8af02927..5bd75e61 100644 --- a/src/Plugins/MEDReader/IO/vtkELNOFilter.cxx +++ b/src/Plugins/MEDReader/IO/vtkELNOFilter.cxx @@ -1,4 +1,4 @@ -// 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 @@ -33,6 +33,7 @@ #include "vtkUnstructuredGrid.h" #include "MEDUtilities.hxx" +#include "InterpKernelAutoPtr.hxx" //vtkCxxRevisionMacro(vtkELNOFilter, "$Revision: 1.2.2.2 $"); vtkStandardNewMacro(vtkELNOFilter); @@ -73,7 +74,7 @@ int vtkELNOFilter::RequestData(vtkInformation *request, vtkInformationVector **i 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()); @@ -158,6 +159,7 @@ int vtkELNOFilter::RequestData(vtkInformation *request, vtkInformationVector **i } } } + AttachCellFieldsOn(usgIn,pdOut->GetCellData(),pdOut->GetNumberOfCells()); return 1; } @@ -166,3 +168,38 @@ void vtkELNOFilter::PrintSelf(ostream& os, vtkIndent indent) 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 tmpPtr(new vtkIdType[nbCells]); + for(vtkIdType cellId=0;cellIdGetCell(cellId)); + tmpPtr[cellId]=cell->GetNumberOfPoints(); + } + for(int index=0;indexGetArray(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;cellIdSetTuple(offset,cellId,data); + } + } +}