-// Copyright (C) 2016-2022 CEA/DEN, EDF R&D
+// Copyright (C) 2016-2023 CEA, EDF
//
// 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 <vtkVariantArray.h>
#include <vtkWarpScalar.h>
+#include <vtkAppendDataSets.h>
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingFieldFloat.hxx"
using MEDCoupling::MCAuto;
using MEDCoupling::MEDFileData;
-using VTKToMEDMem::Fam;
-using VTKToMEDMem::Grp;
+using VTKToMEDMemWriter::Fam;
+using VTKToMEDMemWriter::Grp;
-vtkInformationDataObjectMetaDataKey* GetMEDReaderMetaDataIfAny()
+static vtkInformationDataObjectMetaDataKey* GetMEDReaderMetaDataIfAny()
{
- static const char ZE_KEY[] = "vtkMEDReader::META_DATA";
+ static const char ZE_KEY[] = "vtkFileSeriesGroupReader::META_DATA";
MEDCoupling::GlobalDict* gd(MEDCoupling::GlobalDict::GetInstance());
if (!gd->hasKey(ZE_KEY))
return 0;
return reinterpret_cast<vtkInformationDataObjectMetaDataKey*>(pt);
}
-bool IsInformationOK(vtkInformation* info)
+static bool IsInformationOK(vtkInformation* info)
{
vtkInformationDataObjectMetaDataKey* key(GetMEDReaderMetaDataIfAny());
if (!key)
return false;
}
-void LoadFamGrpMapInfo(vtkMutableDirectedGraph* sil, std::string& meshName,
+static void LoadFamGrpMapInfo(vtkMutableDirectedGraph* sil, std::string& meshName,
std::vector<Grp>& groups, std::vector<Fam>& fams)
{
if (!sil)
}
vtkMEDWriter::vtkMEDWriter()
- : WriteAllTimeSteps(0)
+ : UnPolygonize(0),WriteAllTimeSteps(0)
, NumberOfTimeSteps(0)
, CurrentTimeIndex(0)
, FileName(0)
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;
timeStep = input->GetInformation()->Get(vtkDataObject::DATA_TIME_STEP());
}
////////////
+ vtkDataObject* input = inputBase;
+ vtkSmartPointer<vtkDataObject> inputUnpoly;
+ if(this->UnPolygonize)
+ {
+ vtkPointSet *inputPS = vtkPointSet::SafeDownCast(input);
+ if(!inputPS)
+ throw MZCException("UnPolygonize is activated whereas it is not a PointSet type !");
+ vtkSmartPointer<vtkAppendDataSets> ads = vtkSmartPointer<vtkAppendDataSets>::New();
+ ads->SetInputData(inputPS);
+ ads->Update();
+ vtkDataObject *inputPostPro = ads->GetOutputDataObject(0);
+ inputPostPro->Register(nullptr);
+ inputUnpoly.TakeReference(inputPostPro);
+ input = inputPostPro;
+ }
+ ////////////
MCAuto<MEDFileData> mfd(MEDFileData::New());
- WriteMEDFileFromVTKGDS(mfd, input, timeStep, this->CurrentTimeIndex);
- PutFamGrpInfoIfAny(mfd, meshName, groups, fams);
+ VTKToMEDMemWriter::WriteMEDFileFromVTKGDS(mfd, input, timeStep, this->CurrentTimeIndex);
+ VTKToMEDMemWriter::PutFamGrpInfoIfAny(mfd, meshName, groups, fams);
if (this->WriteAllTimeSteps == 0 ||
(this->WriteAllTimeSteps != 0 && this->CurrentTimeIndex == 0))
mfd->write(this->FileName, 2);