From: rnv Date: Tue, 14 Apr 2015 12:49:55 +0000 (+0300) Subject: Implementation of the '22884: EDF 9622 MED: Filter pipeline Gauss Points + ExtractGro... X-Git-Tag: V7_6_0b1^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b3cf21be6ea6647a3571c031ac9a1993bd0a280e;p=modules%2Fparavis.git Implementation of the '22884: EDF 9622 MED: Filter pipeline Gauss Points + ExtractGroup is not working' issue. --- diff --git a/src/Plugins/MEDReader/IO/CMakeLists.txt b/src/Plugins/MEDReader/IO/CMakeLists.txt index 0ecbbbb9..48865a67 100644 --- a/src/Plugins/MEDReader/IO/CMakeLists.txt +++ b/src/Plugins/MEDReader/IO/CMakeLists.txt @@ -27,7 +27,7 @@ IF(HDF5_IS_PARALLEL) ADD_DEFINITIONS("-DMEDREADER_USE_MPI") ENDIF(HDF5_IS_PARALLEL) -SET(MEDReader_CLASSES vtkMEDReader vtkExtractGroup vtkELNOMeshFilter vtkELNOSurfaceFilter vtkELNOFilter vtkExtractCellType) +SET(MEDReader_CLASSES vtkMEDReader vtkExtractGroup vtkELNOMeshFilter vtkELNOSurfaceFilter vtkELNOFilter vtkExtractCellType vtkMEDQuadraturePointsGenerator) SET(MEDReader_SRCS) SET(MEDReader_HDRS) diff --git a/src/Plugins/MEDReader/IO/vtkMEDQuadraturePointsGenerator.cxx b/src/Plugins/MEDReader/IO/vtkMEDQuadraturePointsGenerator.cxx new file mode 100644 index 00000000..452123ba --- /dev/null +++ b/src/Plugins/MEDReader/IO/vtkMEDQuadraturePointsGenerator.cxx @@ -0,0 +1,134 @@ +// Copyright (C) 2010-2015 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Roman NIKOLAEV + +//Local includes +#include "vtkMEDQuadraturePointsGenerator.h" +#include "MEDFileFieldRepresentationTree.hxx" + +//VTK includes +#include +#include +#include +#include +#include +#include +#include +#include + +//----------------------------------------------------------------------------- +vtkStandardNewMacro(vtkMEDQuadraturePointsGenerator); + +//----------------------------------------------------------------------------- +vtkMEDQuadraturePointsGenerator::vtkMEDQuadraturePointsGenerator() +{ +} + +//----------------------------------------------------------------------------- +vtkMEDQuadraturePointsGenerator::~vtkMEDQuadraturePointsGenerator() +{} + + +//----------------------------------------------------------------------------- +int vtkMEDQuadraturePointsGenerator::RequestData( + vtkInformation* request, + vtkInformationVector **input, + vtkInformationVector *output) +{ + if (this->Superclass::RequestData(request, input, output) == 0 ) + { + return 0; + } + + //Fill MED internal array + vtkDataObject *tmpDataObj; + + // Get the input. + tmpDataObj = input[0]->GetInformationObject(0)->Get(vtkDataObject::DATA_OBJECT()); + vtkUnstructuredGrid *usgIn = vtkUnstructuredGrid::SafeDownCast(tmpDataObj); + // Get the output. + tmpDataObj = output->GetInformationObject(0)->Get(vtkDataObject::DATA_OBJECT()); + vtkPolyData *pdOut = vtkPolyData::SafeDownCast(tmpDataObj); + vtkDataArray* offsets = this->GetInputArrayToProcess(0, input); + + if (usgIn == NULL || pdOut == NULL || offsets == NULL ) + { + vtkErrorMacro("Filter data has not been configured correctly. Aborting."); + return 1; + } + + vtkInformation *info = offsets->GetInformation(); + vtkInformationQuadratureSchemeDefinitionVectorKey *key + = vtkQuadratureSchemeDefinition::DICTIONARY(); + if (!key->Has(info)) + { + vtkErrorMacro( + << "Dictionary is not present in array " + << offsets->GetName() << " " << offsets + << " Aborting."); + return 0; + } + + vtkIdType nCells = usgIn->GetNumberOfCells(); + int dictSize = key->Size(info); + vtkQuadratureSchemeDefinition **dict + = new vtkQuadratureSchemeDefinition *[dictSize]; + key->GetRange(info, dict, 0, 0, dictSize); + + // Loop over all fields to map the internal MED cell array to the points array + int nCArrays = usgIn->GetCellData()->GetNumberOfArrays(); + for (int i = 0; iGetCellData()->GetArray(i); + if ( !array ) + { + continue; + } + std::string arrName = array->GetName(); + if ( arrName == MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_CELL_NAME ) + { + vtkDataArray *out_id_cells = array->NewInstance(); + out_id_cells->SetName(MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_NODE_NAME); + out_id_cells->SetNumberOfComponents(array->GetNumberOfComponents()); + out_id_cells->CopyComponentNames( array ); + for (int cellId = 0; cellId < nCells; cellId++) + { + int cellType = usgIn->GetCellType(cellId); + + // a simple check to see if a scheme really exists for this cell type. + // should not happen if the cell type has not been modified. + if (dict[cellType] == NULL) + { + continue; + } + + int np = dict[cellType]->GetNumberOfQuadraturePoints(); + for (int id = 0; id < np; id++) + { + out_id_cells->InsertNextTuple(cellId, array); + } + } + out_id_cells->Squeeze(); + pdOut->GetPointData()->AddArray(out_id_cells); + out_id_cells->Delete(); + } + } + delete[] dict; + return 1; +} diff --git a/src/Plugins/MEDReader/IO/vtkMEDQuadraturePointsGenerator.h b/src/Plugins/MEDReader/IO/vtkMEDQuadraturePointsGenerator.h new file mode 100644 index 00000000..95098314 --- /dev/null +++ b/src/Plugins/MEDReader/IO/vtkMEDQuadraturePointsGenerator.h @@ -0,0 +1,46 @@ +// Copyright (C) 2010-2015 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Roman NIKOLAEV + +#ifndef vtkMEDQuadraturePointsGenerator_h +#define vtkMEDQuadraturePointsGenerator_h + +#include // For export macro +#include + +class vtkInformation; +class vtkInformationVector; + +class VTKFILTERSGENERAL_EXPORT vtkMEDQuadraturePointsGenerator : public vtkQuadraturePointsGenerator +{ +public: + vtkTypeMacro(vtkMEDQuadraturePointsGenerator,vtkQuadraturePointsGenerator); + static vtkMEDQuadraturePointsGenerator *New(); + +protected: + + int RequestData(vtkInformation *req, vtkInformationVector **input, vtkInformationVector *output); + vtkMEDQuadraturePointsGenerator(); + virtual ~vtkMEDQuadraturePointsGenerator(); +private: + vtkMEDQuadraturePointsGenerator(const vtkMEDQuadraturePointsGenerator &); // Not implemented + void operator=(const vtkMEDQuadraturePointsGenerator &); // Not implemented +}; + +#endif diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml b/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml index 80d730b3..64b3169f 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml +++ b/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml @@ -294,7 +294,7 @@ - +