}
//$$$$$$$$$$$$$$$$$$
+////////////////////
+%typemap(out) MEDCoupling::MEDCouplingField*
+{
+ $result=convertField($1,$owner);
+}
+
+%typemap(out) MEDCouplingField*
+{
+ $result=convertField($1,$owner);
+}
+//$$$$$$$$$$$$$$$$$$
+
////////////////////
%typemap(out) MEDCoupling::MEDCouplingMultiFields*
{
return ret;
}
+static PyObject *convertField(MEDCoupling::MEDCouplingField *f, int owner)
+{
+ PyObject *ret(NULL);
+ if(!f)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
+ if(dynamic_cast<MEDCoupling::MEDCouplingFieldDouble *>(f))
+ ret=SWIG_NewPointerObj(reinterpret_cast<void*>(f),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,owner);
+ if(dynamic_cast<MEDCoupling::MEDCouplingFieldInt *>(f))
+ ret=SWIG_NewPointerObj(reinterpret_cast<void*>(f),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldInt,owner);
+ if(dynamic_cast<MEDCoupling::MEDCouplingFieldFloat *>(f))
+ ret=SWIG_NewPointerObj(reinterpret_cast<void*>(f),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldFloat,owner);
+ if(!ret)
+ throw INTERP_KERNEL::Exception("Not recognized type of field on downcast !");
+ return ret;
+}
+
static PyObject* convertMultiFields(MEDCoupling::MEDCouplingMultiFields *mfs, int owner)
{
PyObject *ret=0;
#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingMemArray.hxx"
#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingFieldFloat.hxx"
+#include "MEDCouplingFieldInt.hxx"
#include "MEDCouplingGaussLocalization.hxx"
#include "MCAuto.hxx"
return mmuPtr->getGroups(meshDimRelToMax,grps,true);
}
-MCAuto<MEDCoupling::MEDCouplingFieldDouble> MEDCoupling::ReadField(const std::string& fileName)
+MCAuto<MEDCoupling::MEDCouplingField> MEDCoupling::ReadField(const std::string& fileName)
{
std::vector<std::string> fieldNames(GetAllFieldNames(fileName));
std::size_t sz(fieldNames.size());
return ReadField(fileName,fieldNames[0]);
}
-MCAuto<MEDCoupling::MEDCouplingFieldDouble> MEDCoupling::ReadField(const std::string& fileName, const std::string& fieldName)
+MCAuto<MEDCoupling::MEDCouplingField> MEDCoupling::ReadField(const std::string& fileName, const std::string& fieldName)
{
std::vector< std::pair< std::pair<int,int>, double> > iterations(GetAllFieldIterations(fileName,fieldName));
std::size_t sz(iterations.size());
return ReadField(fileName,fieldName,iterations[0].first.first,iterations[0].first.second);
}
-MCAuto<MEDCoupling::MEDCouplingFieldDouble> MEDCoupling::ReadField(const std::string& fileName, const std::string& fieldName, int iteration, int order)
+MCAuto<MEDCoupling::MEDCouplingField> MEDCoupling::ReadField(const std::string& fileName, const std::string& fieldName, int iteration, int order)
{
- MCAuto<MEDFileField1TS> f(MEDFileField1TS::New(fileName,fieldName,iteration,order));
+ MCAuto<MEDFileAnyTypeField1TS> f(MEDFileAnyTypeField1TS::New(fileName,fieldName,iteration,order));
MCAuto<MEDFileMesh> mesh(MEDFileMesh::New(fileName,f->getMeshName()));
- MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret(f->field(mesh));
- return ret;
+ {
+ MCAuto<MEDFileField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileField1TS>(f));
+ if(f1.isNotNull())
+ {
+ MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret(f1->field(mesh));
+ return MEDCoupling::DynamicCast<MEDCouplingFieldDouble,MEDCouplingField>(ret);
+ }
+ }
+ {
+ MCAuto<MEDFileIntField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileIntField1TS>(f));
+ if(f1.isNotNull())
+ {
+ MCAuto<MEDCoupling::MEDCouplingFieldInt> ret(f1->field(mesh));
+ return MEDCoupling::DynamicCast<MEDCouplingFieldInt,MEDCouplingField>(ret);
+ }
+ }
+ {
+ MCAuto<MEDFileFloatField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileFloatField1TS>(f));
+ if(f1.isNotNull())
+ {
+ MCAuto<MEDCoupling::MEDCouplingFieldFloat> ret(f1->field(mesh));
+ return MEDCoupling::DynamicCast<MEDCouplingFieldFloat,MEDCouplingField>(ret);
+ }
+ }
+ throw INTERP_KERNEL::Exception("MEDCoupling::ReadField : only FLOAT32, FLOAT64 and INT32 supported for the moment !");
+ //MCAuto<MEDFileMesh> mesh(MEDFileMesh::New(fileName,f->getMeshName()));
+ //MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret(f->field(mesh));
+ //return ret;
}
MCAuto<MEDCoupling::MEDCouplingFieldDouble> MEDCoupling::ReadField(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
class DataArrayInt;
class MEDCouplingMesh;
class MEDCouplingUMesh;
+ class MEDCouplingField;
class MEDCouplingFieldDouble;
class MEDFileWritable;
MEDLOADER_EXPORT MEDCoupling::MEDCouplingUMesh *ReadUMeshFromFile(const std::string& fileName, const std::string& meshName, int meshDimRelToMax=0);
MEDLOADER_EXPORT MEDCoupling::MEDCouplingUMesh *ReadUMeshFromFile(const std::string& fileName, int meshDimRelToMax=0);
MEDLOADER_EXPORT int ReadUMeshDimFromFile(const std::string& fileName, const std::string& meshName);
- MEDLOADER_EXPORT MCAuto<MEDCoupling::MEDCouplingFieldDouble> ReadField(const std::string& fileName);
- MEDLOADER_EXPORT MCAuto<MEDCoupling::MEDCouplingFieldDouble> ReadField(const std::string& fileName, const std::string& fieldName);
- MEDLOADER_EXPORT MCAuto<MEDCoupling::MEDCouplingFieldDouble> ReadField(const std::string& fileName, const std::string& fieldName, int iteration, int order);
+ MEDLOADER_EXPORT MCAuto<MEDCoupling::MEDCouplingField> ReadField(const std::string& fileName);
+ MEDLOADER_EXPORT MCAuto<MEDCoupling::MEDCouplingField> ReadField(const std::string& fileName, const std::string& fieldName);
+ MEDLOADER_EXPORT MCAuto<MEDCoupling::MEDCouplingField> ReadField(const std::string& fileName, const std::string& fieldName, int iteration, int order);
MEDLOADER_EXPORT MCAuto<MEDCoupling::MEDCouplingFieldDouble> ReadField(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
MEDLOADER_EXPORT std::vector<MEDCoupling::MEDCouplingFieldDouble *> ReadFieldsOnSameMesh(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
const std::vector<std::pair<int,int> >& its);
return ret;
}
- MEDCoupling::MEDCouplingFieldDouble *ReadFieldSwig(const std::string& fileName) throw(INTERP_KERNEL::Exception)
+ MEDCoupling::MEDCouplingField *ReadFieldSwig(const std::string& fileName) throw(INTERP_KERNEL::Exception)
{
- MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret(MEDCoupling::ReadField(fileName));
+ MCAuto<MEDCoupling::MEDCouplingField> ret(MEDCoupling::ReadField(fileName));
return ret.retn();
}
- MEDCoupling::MEDCouplingFieldDouble *ReadFieldSwig(const std::string& fileName, const std::string& fieldName) throw(INTERP_KERNEL::Exception)
+ MEDCoupling::MEDCouplingField *ReadFieldSwig(const std::string& fileName, const std::string& fieldName) throw(INTERP_KERNEL::Exception)
{
- MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret(MEDCoupling::ReadField(fileName,fieldName));
+ MCAuto<MEDCoupling::MEDCouplingField> ret(MEDCoupling::ReadField(fileName,fieldName));
return ret.retn();
}
- MEDCoupling::MEDCouplingFieldDouble *ReadFieldSwig(const std::string& fileName, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+ MEDCoupling::MEDCouplingField *ReadFieldSwig(const std::string& fileName, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
{
- MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret(MEDCoupling::ReadField(fileName,fieldName,iteration,order));
+ MCAuto<MEDCoupling::MEDCouplingField> ret(MEDCoupling::ReadField(fileName,fieldName,iteration,order));
return ret.retn();
}