}
}
+class MEDFileFieldLin2QuadVisitor : public MEDFileFieldVisitor
+{
+public:
+ MEDFileFieldLin2QuadVisitor(const MEDFileUMesh *lin, const MEDFileUMesh *quad, const MEDFileFieldGlobsReal *linGlobs, MEDFileFields* outFs):_lin(lin),_quad(quad),_lin_globs(linGlobs),_out_fs(outFs),_gt(INTERP_KERNEL::NORM_ERROR) { }
+ void newFieldEntry(const MEDFileAnyTypeFieldMultiTSWithoutSDA *field) { if(field->getMeshName()!=_lin->getName()) return; _cur_fmts=MEDFileFieldMultiTS::New(); }
+ void endFieldEntry(const MEDFileAnyTypeFieldMultiTSWithoutSDA *field) { if(_cur_fmts.isNotNull()) { if(_cur_fmts->getNumberOfTS()>0) _out_fs->pushField(_cur_fmts); } }
+ //
+ void newTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA *ts);
+ void endTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA *ts) { if(_cur_f1ts.isNotNull() && _cur_fmts.isNotNull()) { _cur_fmts->pushBackTimeStep(_cur_f1ts); } }
+ //
+ void newMeshEntry(const MEDFileFieldPerMesh *fpm);
+ void endMeshEntry(const MEDFileFieldPerMesh *fpm) { }
+ //
+ void newPerMeshPerTypeEntry(const MEDFileFieldPerMeshPerTypeCommon *pmpt);
+ void endPerMeshPerTypeEntry(const MEDFileFieldPerMeshPerTypeCommon *pmpt) { }
+ //
+ void newPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc *pmptpd);
+private:
+ const MEDFileUMesh *_lin;
+ const MEDFileUMesh *_quad;
+ const MEDFileFieldGlobsReal *_lin_globs;
+ MEDFileFields *_out_fs;
+ MCAuto<MEDFileFieldMultiTS> _cur_fmts;
+ MCAuto<MEDFileField1TS> _cur_f1ts;
+ INTERP_KERNEL::NormalizedCellType _gt;
+};
+
+void MEDFileFieldLin2QuadVisitor::newPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc *pmptpd)
+{
+ if(_cur_f1ts.isNull())
+ return;
+ if(pmptpd->getType()!=ON_NODES)
+ return;// Only node-fields need care
+ MEDFileAnyTypeField1TSWithoutSDA *ct(_cur_f1ts->contentNotNullBase());
+ MEDFileFieldPerMeshPerTypePerDisc *pmtd(ct->getLeafGivenMeshAndTypeAndLocId(_lin->getName(),_gt,pmptpd->getLocId()));
+}
+
+void MEDFileFieldLin2QuadVisitor::newPerMeshPerTypeEntry(const MEDFileFieldPerMeshPerTypeCommon *pmpt)
+{
+ const MEDFileFieldPerMeshPerType *pmpt2(dynamic_cast<const MEDFileFieldPerMeshPerType *>(pmpt));
+ if(!pmpt2)
+ throw INTERP_KERNEL::Exception("MEDFileFieldLin2QuadVisitor::newPerMeshPerTypeEntry : not managed for structure elements !");
+ if(pmpt2->getNumberOfLoc()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileFieldLin2QuadVisitor::newPerMeshPerTypeEntry : not managed for multi discr per timestep !");
+ _gt=pmpt->getGeoType();
+}
+
+void MEDFileFieldLin2QuadVisitor::newMeshEntry(const MEDFileFieldPerMesh *fpm)
+{
+ if(fpm->getMeshName()!=_lin->getName())
+ throw INTERP_KERNEL::Exception("MEDFileFieldLin2QuadVisitor::newMeshEntry : mismatch into meshName !");
+}
+
+void MEDFileFieldLin2QuadVisitor::newTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA *ts)
+{
+ if(!ts)
+ return ;
+ const MEDFileField1TSWithoutSDA *tsd(dynamic_cast<const MEDFileField1TSWithoutSDA *>(ts));
+ if(!tsd)
+ return ;
+ MCAuto<MEDFileAnyTypeField1TSWithoutSDA> contentCpy(ts->deepCopy());
+ MCAuto<MEDFileField1TSWithoutSDA> contentCpy2(DynamicCastSafe<MEDFileAnyTypeField1TSWithoutSDA,MEDFileField1TSWithoutSDA>(contentCpy));
+ if(contentCpy2.isNotNull())
+ return;
+ _cur_f1ts=MEDFileField1TS::New(*contentCpy2,true);
+ _cur_f1ts->shallowCpyGlobs(*_lin_globs);
+}
+
+/*!
+ * \a newQuad is expected to be the result of MEDFileUMesh::linearToQuadratic of \a oldLin
+ */
+MCAuto<MEDFileFields> MEDFileFields::linearToQuadratic(const MEDFileMeshes *oldLin, const MEDFileMeshes *newQuad) const
+{
+ if(!oldLin || !newQuad)
+ throw INTERP_KERNEL::Exception("MEDFileFields::linearToQuadratic : input meshes must be non NULL !");
+ MCAuto<MEDFileFields> ret(MEDFileFields::New());
+ for(int i=0;i<oldLin->getNumberOfMeshes();i++)
+ {
+ MEDFileMesh *mm(oldLin->getMeshAtPos(i));
+ if(!mm)
+ continue;
+ MEDFileUMesh *mmu(dynamic_cast<MEDFileUMesh *>(mm));
+ if(!mmu)
+ continue;
+ MEDFileMesh *mmq(newQuad->getMeshWithName(mmu->getName()));
+ MEDFileUMesh *mmqu(dynamic_cast<MEDFileUMesh *>(mmq));
+ if(!mmqu)
+ {
+ std::ostringstream oss; oss << "MEDFileFields::linearToQuadratic : mismatch of name between input meshes for name \"" << mmu->getName() << "\"";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ MEDFileFieldLin2QuadVisitor vis(mmu,mmqu,this,ret);
+ accept(vis);
+ }
+ return ret;
+}
+
MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
{
if(i<0 || i>=(int)_fields.size())