#include <vtkUnstructuredGrid.h>
#include <vtkVariantArray.h>
#include <vtkWarpScalar.h>
+#include <vtkAppendDataSets.h>
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingFieldFloat.hxx"
}
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());
VTKToMEDMemWriter::WriteMEDFileFromVTKGDS(mfd, input, timeStep, this->CurrentTimeIndex);
VTKToMEDMemWriter::PutFamGrpInfoIfAny(mfd, meshName, groups, fams);
int Write();
vtkGetMacro(WriteAllTimeSteps, int);
vtkSetMacro(WriteAllTimeSteps, int);
+ vtkGetMacro(UnPolygonize, int);
+ vtkSetMacro(UnPolygonize, int);
vtkBooleanMacro(WriteAllTimeSteps, int);
protected:
vtkMEDWriter();
vtkMEDWriter(const vtkMEDWriter&);
void operator=(const vtkMEDWriter&); // Not implemented.
private:
+ int UnPolygonize;
int WriteAllTimeSteps;
int NumberOfTimeSteps;
int CurrentTimeIndex;
<BooleanDomain name="bool" />
<Documentation>When WriteAllTimeSteps is turned ON, the writer is executed once for each timestep available from the reader.</Documentation>
</IntVectorProperty>
+ <IntVectorProperty command="SetUnPolygonize" default_values="0" name="UnPolygonize" number_of_elements="1">
+ <BooleanDomain name="bool" />
+ <Documentation>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</Documentation>
+ </IntVectorProperty>
<Hints>
<Property name="Input" show="0" />
<Property name="FileName" show="0" />