00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __MEDLOADER_HXX__
00021 #define __MEDLOADER_HXX__
00022
00023 #include "MEDLoaderDefines.hxx"
00024 #include "InterpKernelException.hxx"
00025 #include "MEDCouplingRefCountObject.hxx"
00026 #include "NormalizedUnstructuredMesh.hxx"
00027
00028 #include <list>
00029 #include <vector>
00030
00031 namespace ParaMEDMEM
00032 {
00033 class DataArrayInt;
00034 class MEDCouplingUMesh;
00035 class MEDCouplingFieldDouble;
00036 }
00037
00038 class MEDLOADER_EXPORT MEDLoader
00039 {
00040 public:
00041 class MEDConnOfOneElemType
00042 {
00043 public:
00044 MEDConnOfOneElemType(INTERP_KERNEL::NormalizedCellType type, int *conn, int *index, int *fam, int lgth, int connLgth);
00045 INTERP_KERNEL::NormalizedCellType getType() const { return _type; }
00046 int getLength() const { return _lgth; }
00047 int getConnLength() const { return _conn_lgth; }
00048 int *getArray() const { return _conn; }
00049 int *getIndex() const { return _index; }
00050 int *getFam() const { return _fam; }
00051 void setGlobal(int *global);
00052 const int *getGlobal() const { return _global; }
00053 void releaseArray();
00054 private:
00055 int _lgth;
00056 int *_fam;
00057 int *_conn;
00058 int *_index;
00059 int *_global;
00060 int _conn_lgth;
00061 INTERP_KERNEL::NormalizedCellType _type;
00062 };
00063
00064 class MEDFieldDoublePerCellType
00065 {
00066 public:
00067 MEDFieldDoublePerCellType(INTERP_KERNEL::NormalizedCellType type, double *values, int ncomp, int ntuple, const int *cellIdPerType, const char *locName);
00068 INTERP_KERNEL::NormalizedCellType getType() const { return _type; }
00069 int getNbComp() const { return _ncomp; }
00070 int getNbOfTuple() const { return _ntuple; }
00071 int getNbOfValues() const { return _ncomp*_ntuple; }
00072 double *getArray() const { return _values; }
00073 const std::string& getLocName() const { return _loc_name; }
00074 const std::vector<int>& getCellIdPerType() const { return _cell_id_per_type; }
00075 void releaseArray();
00076 private:
00077 int _ntuple;
00078 int _ncomp;
00079 double *_values;
00080 std::string _loc_name;
00081 std::vector<int> _cell_id_per_type;
00082 INTERP_KERNEL::NormalizedCellType _type;
00083 };
00084
00085 static void setEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception);
00086 static void setCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception);
00087 static void setTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception);
00088 static void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception);
00089 static std::vector<std::string> GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception);
00090 static std::vector<std::string> GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
00091 static std::vector<std::string> GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
00092 static std::vector<std::string> GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
00093 static std::vector<std::string> GetMeshFamiliesNamesOnGroup(const char *fileName, const char *meshName, const char *grpName) throw(INTERP_KERNEL::Exception);
00094 static std::vector<std::string> GetMeshGroupsNamesOnFamily(const char *fileName, const char *meshName, const char *famName) throw(INTERP_KERNEL::Exception);
00095 static std::vector<std::string> GetAllFieldNames(const char *fileName) throw(INTERP_KERNEL::Exception);
00096 static std::vector<std::string> GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
00097 static std::vector<ParaMEDMEM::TypeOfField> GetTypesOfField(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception);
00098 static std::vector<std::string> GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
00099 static std::vector<std::string> GetCellFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
00100 static std::vector<std::string> GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
00101 static std::vector< std::pair<int,int> > GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception);
00102 static std::vector< std::pair<int,int> > GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception);
00103 static std::vector< std::pair<int,int> > GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception);
00104 static std::vector< std::pair< std::pair<int,int>, double> > GetAllFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception);
00105 static double GetTimeAttachedOnFieldIteration(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
00106 static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& fams) throw(INTERP_KERNEL::Exception);
00107 static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& grps) throw(INTERP_KERNEL::Exception);
00108 static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
00109 static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
00110 static int ReadUMeshDimFromFile(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
00111 static ParaMEDMEM::MEDCouplingFieldDouble *ReadField(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
00112 static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
00113 const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
00114 static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsCellOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
00115 const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
00116 static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsNodeOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
00117 const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
00118 static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsGaussOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
00119 const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
00120 static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsGaussNEOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
00121 const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
00122 static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
00123 static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
00124 static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
00125 static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
00126 static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
00127 static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
00128 static void WriteUMeshesPartition(const char *fileName, const char *meshName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
00129 static void WriteUMeshesPartitionDep(const char *fileName, const char *meshName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
00130 static void WriteUMeshes(const char *fileName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
00131 static void WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
00132 static void WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
00133 static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
00134 private:
00135 MEDLoader();
00136 public:
00137 static double _EPS_FOR_NODE_COMP;
00138 static int _COMP_FOR_CELL;
00139 static int _TOO_LONG_STR;
00140 };
00141
00142 #endif