]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Target MEDReader
authorageay <ageay>
Wed, 24 Jul 2013 09:00:48 +0000 (09:00 +0000)
committerageay <ageay>
Wed, 24 Jul 2013 09:00:48 +0000 (09:00 +0000)
src/MEDLoader/MEDFileFieldOverView.cxx
src/MEDLoader/MEDFileFieldOverView.hxx

index 98fbbf48ce44f4e76fd30714a493cc8ee0b7803d..ab12329ca69c4140d18fb1ee4ae27ba4baec794d 100644 (file)
@@ -179,6 +179,18 @@ void MEDFileField1TSStructItem2::checkInRange(int nbOfEntity, int nip, const MED
     }
 }
 
+bool MEDFileField1TSStructItem2::isFastlyEqual(int& startExp, INTERP_KERNEL::NormalizedCellType gt, const char *pflName) const
+{
+  if(startExp!=_start_end.first)
+    return false;
+  if(gt!=_geo_type)
+    return false;
+  if(getPflName()!=pflName)
+    return false;
+  startExp=_start_end.second;
+  return true;
+}
+
 bool MEDFileField1TSStructItem2::operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception)
 {
   //_nb_of_entity is not taken into account here. It is not a bug, because no mesh consideration needed here to perform fast compare.
@@ -867,6 +879,58 @@ void MEDMeshMultiLev::setNodeReduction(const DataArrayInt *nr)
   _node_reduction=const_cast<DataArrayInt*>(nr);
 }
 
+bool MEDMeshMultiLev::isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
+{
+  if(fst.getType()==ON_NODES)
+    {
+      if(fst.getNumberOfItems()!=1)
+        throw INTERP_KERNEL::Exception("MEDMeshMultiLev::isFastlyTheSameStruct : unexpected situation for nodes !");
+      const MEDFileField1TSStructItem2& p(fst[0]);
+      std::string pflName(p.getPflName());
+      const DataArrayInt *nr(_node_reduction);
+      if(pflName.empty() && !nr)
+        return true;
+      if(pflName==nr->getName())
+        return true;
+      return false;
+    }
+  else
+    {
+      std::size_t sz(fst.getNumberOfItems());
+      if(sz!=_geo_types.size())
+        return false;
+      int strt(0);
+      for(std::size_t i=0;i<sz;i++)
+        {
+          const MEDFileField1TSStructItem2& p(fst[i]);
+          if(!p.isFastlyEqual(strt,_geo_types[i],getPflNameOfId(i).c_str()))
+            return false;
+        }
+      return true;
+    }
+}
+
+DataArray *MEDMeshMultiLev::buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const throw(INTERP_KERNEL::Exception)
+{
+  MEDCouplingAutoRefCountObjectPtr<DataArray> ret(const_cast<DataArray *>(vals)); ret->incrRef();
+  if(isFastlyTheSameStruct(fst,globs))
+    return ret.retn();
+  //else
+  //  return constructDataArray(fst,globs,vals);
+  return 0;
+}
+
+std::string MEDMeshMultiLev::getPflNameOfId(int id) const
+{
+  std::size_t sz(_pfls.size());
+  if(id<0 || id>=sz)
+    throw INTERP_KERNEL::Exception("MEDMeshMultiLev::getPflNameOfId : invalid input id !");
+  const DataArrayInt *pfl(_pfls[id]);
+  if(!pfl)
+    return std::string("");
+  return pfl->getName();
+}
+
 MEDMeshMultiLev::MEDMeshMultiLev()
 {
 }
index e8866b543ba4437c75bbb3b73626981284beaa04..15b1d266db91066746f53c4477ab718e143529d7 100644 (file)
@@ -62,7 +62,9 @@ namespace ParaMEDMEM
     int _nb_nodes;
     std::vector< std::vector<int> > _geo_types_distrib;
   }; 
-
+  
+  class MEDFileField1TSStructItem;
+  
   class MEDMeshMultiLev : public RefCountObject
   {
   public:
@@ -72,8 +74,12 @@ namespace ParaMEDMEM
     static MEDMeshMultiLev *New(const MEDFileMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
     static MEDMeshMultiLev *NewOnlyOnNode(const MEDFileMesh *m, const DataArrayInt *pflOnNode) throw(INTERP_KERNEL::Exception);
     void setNodeReduction(const DataArrayInt *nr);
+    bool isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
+    DataArray *buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const throw(INTERP_KERNEL::Exception);
     virtual void selectPartOfNodes(const DataArrayInt *pflNodes) throw(INTERP_KERNEL::Exception) = 0;
     virtual MEDMeshMultiLev *prepare() const throw(INTERP_KERNEL::Exception) = 0;
+  protected:
+    std::string getPflNameOfId(int id) const;
   protected:
     MEDMeshMultiLev();
     MEDMeshMultiLev(const MEDMeshMultiLev& other);
@@ -161,6 +167,7 @@ namespace ParaMEDMEM
     std::string getPflName() const;
     //! warning this method also set _nb_of_entity attribute !
     void checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
+    bool isFastlyEqual(int& startExp, INTERP_KERNEL::NormalizedCellType gt, const char *pflName) const;
     bool operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception);
     bool isCellSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
     bool isNodeSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
@@ -211,9 +218,9 @@ namespace ParaMEDMEM
     bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception);
     MEDMeshMultiLev *buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
     bool isDataSetSupportFastlyEqualTo(const MEDFileField1TSStruct& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
+    static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt);
   private:
     MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst);
-    static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt);
     bool presenceOfCellDiscr(int& pos) const throw(INTERP_KERNEL::Exception);
     bool presenceOfPartialNodeDiscr(int& pos) const throw(INTERP_KERNEL::Exception);
   private: