Salome HOME
[EDF23738] : multi geometric type in a single mesh having structure elements on each...
[tools/medcoupling.git] / src / MEDLoader / MEDFileFieldInternal.cxx
index d482dce60c47d3d70f0fbd6d63cbb014e52179b3..fc228e675ed9dd6888221de48eecd8ffd4bd8ace 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2017-2021  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -32,6 +32,7 @@
 
 #include "CellModel.hxx"
 
+// From MEDLOader.cxx TU
 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
 extern med_geometry_type typmai3[INTERP_KERNEL::NORM_MAXTYPE];
@@ -371,7 +372,8 @@ void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(mcIdType& start, mc
 
 /*!
  * Leaf method of field with profile assignment. This method is the most general one. No optimization is done here.
- * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when split by loc_id).
+ * \param [in] isPflAlone whether there are several profiles or not
+ * \param [in] start starting ID
  * \param [in] multiTypePfl is the end user profile specified in high level API
  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
  * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
@@ -725,7 +727,14 @@ void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileF
   DataArrayInt32 *arrI(dynamic_cast<DataArrayInt32 *>(arr));
   if(arrI)
     {
-      int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
+      Int32 *startFeeding(arrI->getPointer()+_start*nbOfCompo);
+      goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
+      return ;
+    }
+  DataArrayInt64 *arrI64(dynamic_cast<DataArrayInt64 *>(arr));
+  if(arrI64)
+    {
+      Int64 *startFeeding(arrI64->getPointer()+_start*nbOfCompo);
       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
       return ;
     }
@@ -907,8 +916,6 @@ void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, mcIdType& startEn
 
 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
 {
-  TypeOfField type=getType();
-  INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
   med_geometry_type mgeoti;
   med_entity_type menti;
   _father->entriesForMEDfile(getType(),mgeoti,menti);
@@ -919,16 +926,19 @@ void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldN
     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
   const DataArrayDouble *arrD(dynamic_cast<const DataArrayDouble *>(arr));
   const DataArrayInt32 *arrI(dynamic_cast<const DataArrayInt32 *>(arr));
+  const DataArrayInt64 *arrI64(dynamic_cast<const DataArrayInt64 *>(arr));
   const DataArrayFloat *arrF(dynamic_cast<const DataArrayFloat *>(arr));
   const unsigned char *locToWrite=0;
   if(arrD)
     locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
   else if(arrI)
     locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
+  else if(arrI64)
+    locToWrite=reinterpret_cast<const unsigned char *>(arrI64->getConstPointer()+_start*arr->getNumberOfComponents());
   else if(arrF)
     locToWrite=reinterpret_cast<const unsigned char *>(arrF->getConstPointer()+_start*arr->getNumberOfComponents());
   else
-    throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 FLOAT32 and INT32 !");
+    throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 FLOAT32 INT32 and INT64 !");
   MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
                                                    MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,ToMedInt(_nval),
                                                    locToWrite));