From: Anthony Geay Date: Thu, 26 Jan 2023 17:17:33 +0000 (+0100) Subject: [EDF26707] : unpolygonize of input dataset before writing it X-Git-Tag: V9_11_0a1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a11f1f5fd9d18f62b9999322de62e703292f9610;p=modules%2Fparavis.git [EDF26707] : unpolygonize of input dataset before writing it --- diff --git a/src/Plugins/MEDWriter/plugin/MEDWriterIO/vtkMEDWriter.cxx b/src/Plugins/MEDWriter/plugin/MEDWriterIO/vtkMEDWriter.cxx index b2af16f1..3b1b235d 100644 --- a/src/Plugins/MEDWriter/plugin/MEDWriterIO/vtkMEDWriter.cxx +++ b/src/Plugins/MEDWriter/plugin/MEDWriterIO/vtkMEDWriter.cxx @@ -55,6 +55,7 @@ #include #include #include +#include #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingFieldFloat.hxx" @@ -183,7 +184,7 @@ static void LoadFamGrpMapInfo(vtkMutableDirectedGraph* sil, std::string& meshNam } vtkMEDWriter::vtkMEDWriter() - : WriteAllTimeSteps(0) + : UnPolygonize(0),WriteAllTimeSteps(0) , NumberOfTimeSteps(0) , CurrentTimeIndex(0) , FileName(0) @@ -261,8 +262,8 @@ int vtkMEDWriter::RequestData( LoadFamGrpMapInfo(famGrpGraph, meshName, groups, fams); } vtkInformation* outInfo(outputVector->GetInformationObject(0)); - vtkDataObject* input(vtkDataObject::SafeDownCast(inputInfo->Get(vtkDataObject::DATA_OBJECT()))); - if (!input) + vtkDataObject* inputBase(vtkDataObject::SafeDownCast(inputInfo->Get(vtkDataObject::DATA_OBJECT()))); + if (!inputBase) throw MZCException( "Not recognized data object in input of the MEDWriter ! Maybe not implemented yet !"); double timeStep; @@ -272,6 +273,22 @@ int vtkMEDWriter::RequestData( timeStep = input->GetInformation()->Get(vtkDataObject::DATA_TIME_STEP()); } //////////// + vtkDataObject* input = inputBase; + vtkSmartPointer inputUnpoly; + if(this->UnPolygonize) + { + vtkPointSet *inputPS = vtkPointSet::SafeDownCast(input); + if(!inputPS) + throw MZCException("UnPolygonize is activated whereas it is not a PointSet type !"); + vtkSmartPointer ads = vtkSmartPointer::New(); + ads->SetInputData(inputPS); + ads->Update(); + vtkDataObject *inputPostPro = ads->GetOutputDataObject(0); + inputPostPro->Register(nullptr); + inputUnpoly.TakeReference(inputPostPro); + input = inputPostPro; + } + //////////// MCAuto mfd(MEDFileData::New()); VTKToMEDMemWriter::WriteMEDFileFromVTKGDS(mfd, input, timeStep, this->CurrentTimeIndex); VTKToMEDMemWriter::PutFamGrpInfoIfAny(mfd, meshName, groups, fams); diff --git a/src/Plugins/MEDWriter/plugin/MEDWriterIO/vtkMEDWriter.h b/src/Plugins/MEDWriter/plugin/MEDWriterIO/vtkMEDWriter.h index 0521bde7..38157283 100644 --- a/src/Plugins/MEDWriter/plugin/MEDWriterIO/vtkMEDWriter.h +++ b/src/Plugins/MEDWriter/plugin/MEDWriterIO/vtkMEDWriter.h @@ -37,6 +37,8 @@ public: int Write(); vtkGetMacro(WriteAllTimeSteps, int); vtkSetMacro(WriteAllTimeSteps, int); + vtkGetMacro(UnPolygonize, int); + vtkSetMacro(UnPolygonize, int); vtkBooleanMacro(WriteAllTimeSteps, int); protected: vtkMEDWriter(); @@ -49,6 +51,7 @@ private: vtkMEDWriter(const vtkMEDWriter&); void operator=(const vtkMEDWriter&); // Not implemented. private: + int UnPolygonize; int WriteAllTimeSteps; int NumberOfTimeSteps; int CurrentTimeIndex; diff --git a/src/Plugins/MEDWriter/plugin/writers.xml b/src/Plugins/MEDWriter/plugin/writers.xml index 29239b8a..895478f8 100644 --- a/src/Plugins/MEDWriter/plugin/writers.xml +++ b/src/Plugins/MEDWriter/plugin/writers.xml @@ -22,6 +22,10 @@ When WriteAllTimeSteps is turned ON, the writer is executed once for each timestep available from the reader. + + + When UnPolygonize is turned ON, the writer preprocess input Data by converting it from PolyData to UnstructuredData. Doing so polygons will be converted into triangles or quadrangles +