]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
MEDReader : End of debugging session.
authorageay <ageay>
Wed, 31 Jul 2013 10:58:20 +0000 (10:58 +0000)
committerageay <ageay>
Wed, 31 Jul 2013 10:58:20 +0000 (10:58 +0000)
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling/MEDCouplingMemArray.hxx
src/MEDCoupling/MEDCouplingMemArrayChar.cxx
src/MEDCoupling_Swig/MEDCouplingCommon.i
src/MEDLoader/MEDFileFieldOverView.cxx
src/MEDLoader/Swig/MEDLoaderTest4.py

index 4b5b13d317f76dc9f2978c7b5149755d27c9b5c0..db929efcd4f5f83a632348282ba23d4d2abacc6c 100644 (file)
@@ -247,6 +247,42 @@ void DataArray::setInfoOnComponents(const std::vector<std::string>& info) throw(
   _info_on_compo=info;
 }
 
+/*!
+ * This method is only a dispatcher towards DataArrayDouble::setPartOfValues3, DataArrayInt::setPartOfValues3, DataArrayChar::setPartOfValues3 depending on the true
+ * type of \a this and \a aBase.
+ *
+ * \throw If \a aBase and \a this do not have the same type.
+ *
+ * \sa DataArrayDouble::setPartOfValues3, DataArrayInt::setPartOfValues3, DataArrayChar::setPartOfValues3.
+ */
+void DataArray::setPartOfValuesBase3(const DataArray *aBase, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
+{
+  if(!aBase)
+    throw INTERP_KERNEL::Exception("DataArray::setPartOfValuesBase3 : input aBase object is NULL !");
+  DataArrayDouble *this1(dynamic_cast<DataArrayDouble *>(this));
+  DataArrayInt *this2(dynamic_cast<DataArrayInt *>(this));
+  DataArrayChar *this3(dynamic_cast<DataArrayChar *>(this));
+  const DataArrayDouble *a1(dynamic_cast<const DataArrayDouble *>(aBase));
+  const DataArrayInt *a2(dynamic_cast<const DataArrayInt *>(aBase));
+  const DataArrayChar *a3(dynamic_cast<const DataArrayChar *>(aBase));
+  if(this1 && a1)
+    {
+      this1->setPartOfValues3(a1,bgTuples,endTuples,bgComp,endComp,stepComp,strictCompoCompare);
+      return ;
+    }
+  if(this2 && a2)
+    {
+      this2->setPartOfValues3(a2,bgTuples,endTuples,bgComp,endComp,stepComp,strictCompoCompare);
+      return ;
+    }
+  if(this3 && a3)
+    {
+      this3->setPartOfValues3(a3,bgTuples,endTuples,bgComp,endComp,stepComp,strictCompoCompare);
+      return ;
+    }
+  throw INTERP_KERNEL::Exception("DataArray::setPartOfValuesBase3 : input aBase object and this do not have the same type !");
+}
+
 std::vector<std::string> DataArray::getVarsOnComponent() const throw(INTERP_KERNEL::Exception)
 {
   int nbOfCompo=(int)_info_on_compo.size();
@@ -2631,7 +2667,7 @@ void DataArrayDouble::setPartOfValuesAdv(const DataArrayDouble *a, const DataArr
 }
 
 /*!
- * Copy some tuples from another DataArrayDouble (\a a) into contiguous tuples
+ * Copy some tuples from another DataArrayDouble (\a aBase) into contiguous tuples
  * of \a this array. Textual data is not copied. Both arrays must have equal number of
  * components.
  * The tuples to assign to are defined by index of the first tuple, and
@@ -2640,18 +2676,18 @@ void DataArrayDouble::setPartOfValuesAdv(const DataArrayDouble *a, const DataArr
  * All components of selected tuples are copied.
  *  \param [in] tupleIdStart - index of the first tuple of \a this array to assign
  *              values to.
- *  \param [in] a - the array to copy values from.
+ *  \param [in] aBase - the array to copy values from.
  *  \param [in] tuplesSelec - the array specifying tuples of \a a to copy.
  *  \throw If \a this is not allocated.
- *  \throw If \a a is NULL.
- *  \throw If \a a is not allocated.
+ *  \throw If \a aBase is NULL.
+ *  \throw If \a aBase is not allocated.
  *  \throw If \a tuplesSelec is NULL.
  *  \throw If \a tuplesSelec is not allocated.
- *  \throw If <em>this->getNumberOfComponents() != a->getNumberOfComponents()</em>.
+ *  \throw If <em>this->getNumberOfComponents() != aBase->getNumberOfComponents()</em>.
  *  \throw If \a tuplesSelec->getNumberOfComponents() != 1.
  *  \throw If <em>tupleIdStart + tuplesSelec->getNumberOfTuples() > this->getNumberOfTuples().</em>
  *  \throw If any tuple index given by \a tuplesSelec is out of a valid range for 
- *         \a a array.
+ *         \a aBase array.
  */
 void DataArrayDouble::setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
 {
@@ -2691,7 +2727,7 @@ void DataArrayDouble::setContigPartOfSelectedValues(int tupleIdStart, const Data
 }
 
 /*!
- * Copy some tuples from another DataArrayDouble (\a a) into contiguous tuples
+ * Copy some tuples from another DataArrayDouble (\a aBase) into contiguous tuples
  * of \a this array. Textual data is not copied. Both arrays must have equal number of
  * components.
  * The tuples to copy are defined by three values similar to parameters of
@@ -2701,19 +2737,19 @@ void DataArrayDouble::setContigPartOfSelectedValues(int tupleIdStart, const Data
  * All components of selected tuples are copied.
  *  \param [in] tupleIdStart - index of the first tuple of \a this array to assign
  *              values to.
- *  \param [in] a - the array to copy values from.
- *  \param [in] bg - index of the first tuple to copy of the array \a a.
- *  \param [in] end2 - index of the tuple of \a a before which the tuples to copy
+ *  \param [in] aBase - the array to copy values from.
+ *  \param [in] bg - index of the first tuple to copy of the array \a aBase.
+ *  \param [in] end2 - index of the tuple of \a aBase before which the tuples to copy
  *              are located.
  *  \param [in] step - index increment to get index of the next tuple to copy.
  *  \throw If \a this is not allocated.
- *  \throw If \a a is NULL.
- *  \throw If \a a is not allocated.
- *  \throw If <em>this->getNumberOfComponents() != a->getNumberOfComponents()</em>.
+ *  \throw If \a aBase is NULL.
+ *  \throw If \a aBase is not allocated.
+ *  \throw If <em>this->getNumberOfComponents() != aBase->getNumberOfComponents()</em>.
  *  \throw If <em>tupleIdStart + len(range(bg,end2,step)) > this->getNumberOfTuples().</em>
  *  \throw If parameters specifying tuples to copy, do not give a
  *            non-empty range of increasing indices or indices are out of a valid range
- *            for the array \a a.
+ *            for the array \a aBase.
  */
 void DataArrayDouble::setContigPartOfSelectedValues2(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) throw(INTERP_KERNEL::Exception)
 {
@@ -7884,7 +7920,7 @@ void DataArrayInt::setPartOfValuesAdv(const DataArrayInt *a, const DataArrayInt
 }
 
 /*!
- * Copy some tuples from another DataArrayInt (\a a) into contiguous tuples
+ * Copy some tuples from another DataArrayInt (\a aBase) into contiguous tuples
  * of \a this array. Textual data is not copied. Both arrays must have equal number of
  * components.
  * The tuples to assign to are defined by index of the first tuple, and
@@ -7893,18 +7929,18 @@ void DataArrayInt::setPartOfValuesAdv(const DataArrayInt *a, const DataArrayInt
  * All components of selected tuples are copied.
  *  \param [in] tupleIdStart - index of the first tuple of \a this array to assign
  *              values to.
- *  \param [in] a - the array to copy values from.
- *  \param [in] tuplesSelec - the array specifying tuples of \a a to copy.
+ *  \param [in] aBase - the array to copy values from.
+ *  \param [in] tuplesSelec - the array specifying tuples of \a aBase to copy.
  *  \throw If \a this is not allocated.
- *  \throw If \a a is NULL.
- *  \throw If \a a is not allocated.
+ *  \throw If \a aBase is NULL.
+ *  \throw If \a aBase is not allocated.
  *  \throw If \a tuplesSelec is NULL.
  *  \throw If \a tuplesSelec is not allocated.
  *  \throw If <em>this->getNumberOfComponents() != a->getNumberOfComponents()</em>.
  *  \throw If \a tuplesSelec->getNumberOfComponents() != 1.
  *  \throw If <em>tupleIdStart + tuplesSelec->getNumberOfTuples() > this->getNumberOfTuples().</em>
  *  \throw If any tuple index given by \a tuplesSelec is out of a valid range for 
- *         \a a array.
+ *         \a aBase array.
  */
 void DataArrayInt::setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
 {
@@ -7944,7 +7980,7 @@ void DataArrayInt::setContigPartOfSelectedValues(int tupleIdStart, const DataArr
 }
 
 /*!
- * Copy some tuples from another DataArrayInt (\a a) into contiguous tuples
+ * Copy some tuples from another DataArrayInt (\a aBase) into contiguous tuples
  * of \a this array. Textual data is not copied. Both arrays must have equal number of
  * components.
  * The tuples to copy are defined by three values similar to parameters of
@@ -7954,19 +7990,19 @@ void DataArrayInt::setContigPartOfSelectedValues(int tupleIdStart, const DataArr
  * All components of selected tuples are copied.
  *  \param [in] tupleIdStart - index of the first tuple of \a this array to assign
  *              values to.
- *  \param [in] a - the array to copy values from.
- *  \param [in] bg - index of the first tuple to copy of the array \a a.
- *  \param [in] end2 - index of the tuple of \a a before which the tuples to copy
+ *  \param [in] aBase - the array to copy values from.
+ *  \param [in] bg - index of the first tuple to copy of the array \a aBase.
+ *  \param [in] end2 - index of the tuple of \a aBase before which the tuples to copy
  *              are located.
  *  \param [in] step - index increment to get index of the next tuple to copy.
  *  \throw If \a this is not allocated.
- *  \throw If \a a is NULL.
- *  \throw If \a a is not allocated.
- *  \throw If <em>this->getNumberOfComponents() != a->getNumberOfComponents()</em>.
+ *  \throw If \a aBase is NULL.
+ *  \throw If \a aBase is not allocated.
+ *  \throw If <em>this->getNumberOfComponents() != aBase->getNumberOfComponents()</em>.
  *  \throw If <em>tupleIdStart + len(range(bg,end2,step)) > this->getNumberOfTuples().</em>
  *  \throw If parameters specifying tuples to copy, do not give a
  *            non-empty range of increasing indices or indices are out of a valid range
- *            for the array \a a.
+ *            for the array \a aBase.
  */
 void DataArrayInt::setContigPartOfSelectedValues2(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) throw(INTERP_KERNEL::Exception)
 {
index 44b83de9ad996fe98c543ce53a994f2fe1a90f16..a3d4611b1a6411efa6b40a923ebe236aaacf7780 100644 (file)
@@ -134,6 +134,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT std::string getUnitOnComponent(int i) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT int getNumberOfComponents() const { return (int)_info_on_compo.size(); }
+    MEDCOUPLING_EXPORT void setPartOfValuesBase3(const DataArray *aBase, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT virtual DataArray *deepCpy() const throw(INTERP_KERNEL::Exception) = 0;
     MEDCOUPLING_EXPORT virtual bool isAllocated() const throw(INTERP_KERNEL::Exception) = 0;
     MEDCOUPLING_EXPORT virtual void checkAllocated() const throw(INTERP_KERNEL::Exception) = 0;
index 5c827bf8b6e8a53e950795e56cb88055a84a45c2..d363454bb77108e96ae37a6ab66a6d610f70d059 100644 (file)
@@ -1286,7 +1286,7 @@ void DataArrayChar::setPartOfValuesAdv(const DataArrayChar *a, const DataArrayCh
 }
 
 /*!
- * Copy some tuples from another DataArrayChar (\a a) into contiguous tuples
+ * Copy some tuples from another DataArrayChar (\a aBase) into contiguous tuples
  * of \a this array. Textual data is not copied. Both arrays must have equal number of
  * components.
  * The tuples to assign to are defined by index of the first tuple, and
@@ -1295,18 +1295,18 @@ void DataArrayChar::setPartOfValuesAdv(const DataArrayChar *a, const DataArrayCh
  * All components of selected tuples are copied.
  *  \param [in] tupleIdStart - index of the first tuple of \a this array to assign
  *              values to.
- *  \param [in] a - the array to copy values from.
- *  \param [in] tuplesSelec - the array specifying tuples of \a a to copy.
+ *  \param [in] aBase - the array to copy values from.
+ *  \param [in] tuplesSelec - the array specifying tuples of \a aBase to copy.
  *  \throw If \a this is not allocated.
- *  \throw If \a a is NULL.
- *  \throw If \a a is not allocated.
+ *  \throw If \a aBase is NULL.
+ *  \throw If \a aBase is not allocated.
  *  \throw If \a tuplesSelec is NULL.
  *  \throw If \a tuplesSelec is not allocated.
- *  \throw If <em>this->getNumberOfComponents() != a->getNumberOfComponents()</em>.
+ *  \throw If <em>this->getNumberOfComponents() != aBase->getNumberOfComponents()</em>.
  *  \throw If \a tuplesSelec->getNumberOfComponents() != 1.
  *  \throw If <em>tupleIdStart + tuplesSelec->getNumberOfTuples() > this->getNumberOfTuples().</em>
  *  \throw If any tuple index given by \a tuplesSelec is out of a valid range for 
- *         \a a array.
+ *         \a aBase array.
  */
 void DataArrayChar::setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
 {
@@ -1346,7 +1346,7 @@ void DataArrayChar::setContigPartOfSelectedValues(int tupleIdStart, const DataAr
 }
 
 /*!
- * Copy some tuples from another DataArrayChar (\a a) into contiguous tuples
+ * Copy some tuples from another DataArrayChar (\a aBase) into contiguous tuples
  * of \a this array. Textual data is not copied. Both arrays must have equal number of
  * components.
  * The tuples to copy are defined by three values similar to parameters of
@@ -1356,19 +1356,19 @@ void DataArrayChar::setContigPartOfSelectedValues(int tupleIdStart, const DataAr
  * All components of selected tuples are copied.
  *  \param [in] tupleIdStart - index of the first tuple of \a this array to assign
  *              values to.
- *  \param [in] a - the array to copy values from.
- *  \param [in] bg - index of the first tuple to copy of the array \a a.
- *  \param [in] end2 - index of the tuple of \a a before which the tuples to copy
+ *  \param [in] aBase - the array to copy values from.
+ *  \param [in] bg - index of the first tuple to copy of the array \a aBase.
+ *  \param [in] end2 - index of the tuple of \a aBase before which the tuples to copy
  *              are located.
  *  \param [in] step - index increment to get index of the next tuple to copy.
  *  \throw If \a this is not allocated.
- *  \throw If \a a is NULL.
- *  \throw If \a a is not allocated.
- *  \throw If <em>this->getNumberOfComponents() != a->getNumberOfComponents()</em>.
+ *  \throw If \a aBase is NULL.
+ *  \throw If \a aBase is not allocated.
+ *  \throw If <em>this->getNumberOfComponents() != aBase->getNumberOfComponents()</em>.
  *  \throw If <em>tupleIdStart + len(range(bg,end2,step)) > this->getNumberOfTuples().</em>
  *  \throw If parameters specifying tuples to copy, do not give a
  *            non-empty range of increasing indices or indices are out of a valid range
- *            for the array \a a.
+ *            for the array \a aBase.
  */
 void DataArrayChar::setContigPartOfSelectedValues2(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) throw(INTERP_KERNEL::Exception)
 {
index 49c9c16956e8dd0453bf531f0d07b74a3377396f..a5603445d03d82fcaea96dd1cb63332fbeae692c 100644 (file)
@@ -2811,6 +2811,11 @@ namespace ParaMEDMEM
         return MEDCoupling1SGTUMesh::New(name,type);
       }
 
+      MEDCoupling1SGTUMesh(const MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception)
+      {
+        return MEDCoupling1SGTUMesh::New(m);
+      }
+
       std::string __str__() const throw(INTERP_KERNEL::Exception)
       {
         return self->simpleRepr();
@@ -2858,6 +2863,11 @@ namespace ParaMEDMEM
         return MEDCoupling1DGTUMesh::New(name,type);
       }
 
+      MEDCoupling1DGTUMesh(const MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception)
+      {
+        return MEDCoupling1DGTUMesh::New(m);
+      }
+
       std::string __str__() const throw(INTERP_KERNEL::Exception)
       {
         return self->simpleRepr();
index 33045557d8d5504ae5f665616726604e2f2d0143..95f06ad242e1b4dc63288f51c3d46cb66dc29352 100644 (file)
@@ -265,51 +265,108 @@ DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem&
   else
     {
       std::size_t sz(fst.getNumberOfItems());
-      std::vector< MEDCouplingAutoRefCountObjectPtr<DataArray> > arrSafe(sz);
-      std::vector< const DataArray *> arr(sz);
-      for(std::size_t i=0;i<sz;i++)
+      std::set<INTERP_KERNEL::NormalizedCellType> s(_geo_types.begin(),_geo_types.end());
+      if(s.size()!=_geo_types.size())
+        throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 2 !");
+      std::vector< const DataArray *> arr(s.size());
+      std::vector< MEDCouplingAutoRefCountObjectPtr<DataArray> > arrSafe(s.size());
+      int iii(0);
+      int nc(vals->getNumberOfComponents());
+      std::vector<std::string> compInfo(vals->getInfoOnComponents());
+      for(std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator it=_geo_types.begin();it!=_geo_types.end();it++,iii++)
         {
-          const MEDFileField1TSStructItem2& p(fst[i]);
-          const std::pair<int,int>& strtStop(p.getStartStop());
-          std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator it(std::find(_geo_types.begin(),_geo_types.end(),p.getGeo()));
-          if(it==_geo_types.end())
-            throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 1 !");
-          if(std::find(it+1,_geo_types.end(),p.getGeo())!=_geo_types.end())
-            throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 2 !");
-          std::size_t pos(std::distance(_geo_types.begin(),it));
-          const DataArrayInt *thisP(_pfls[pos]),*otherP(p.getPfl(globs));
-          MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->selectByTupleId2(strtStop.first,strtStop.second,1));
-          std::vector<std::string> compInfo(vals->getInfoOnComponents());
-          if(!thisP && !otherP)
+          const DataArrayInt *thisP(_pfls[iii]);
+          std::vector<const MEDFileField1TSStructItem2 *> ps;
+          for(std::size_t i=0;i<sz;i++)
             {
-              arrSafe[i]=ret; arr[i]=ret;
-              continue;
+              const MEDFileField1TSStructItem2& p(fst[i]);
+              if(p.getGeo()==*it)
+                ps.push_back(&p);
             }
-          int nbi(p.getNbOfIntegrationPts(globs)),nc(ret->getNumberOfComponents());
-          if(!thisP && otherP)
+          if(ps.empty())
+            throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 1 !");
+          if(ps.size()==1)
             {
-              MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(otherP->deepCpy());
-              p1->sort(true);
-              p1->checkAllIdsInRange(0,getNumberOfCells(p.getGeo()));
-              p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,p1);
-              ret->rearrange(nbi*nc); ret->renumberInPlace(p1->begin()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo);
-              arrSafe[i]=ret; arr[i]=ret;
-              continue;
+              int nbi(ps[0]->getNbOfIntegrationPts(globs));
+              const DataArrayInt *otherP(ps[0]->getPfl(globs));
+              const std::pair<int,int>& strtStop(ps[0]->getStartStop());
+              MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->selectByTupleId2(strtStop.first,strtStop.second,1));
+              if(!thisP && !otherP)
+                {
+                  arrSafe[iii]=ret; arr[iii]=ret;
+                  continue;
+                }
+              if(thisP && otherP)
+                {
+                  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(otherP->invertArrayN2O2O2N(getNumberOfCells(ps[0]->getGeo())));
+                  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(thisP->deepCpy());
+                  p2->transformWithIndArr(p1->begin(),p1->end());
+                  //p1=p2->getIdsNotEqual(-1);
+                  //p1=p2->selectByTupleIdSafe(p1->begin(),p1->end());
+                  ret->rearrange(nbi*nc); ret=ret->selectByTupleIdSafe(p2->begin(),p2->end()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo);
+                  arrSafe[iii]=ret; arr[iii]=ret;
+                  continue;
+                }
+              if(!thisP && otherP)
+                {
+                  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(otherP->deepCpy());
+                  p1->sort(true);
+                  p1->checkAllIdsInRange(0,getNumberOfCells(ps[0]->getGeo()));
+                  p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,p1);
+                  ret->rearrange(nbi*nc); ret->renumberInPlace(p1->begin()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo);
+                  arrSafe[iii]=ret; arr[iii]=ret;
+                  continue;
+                }
+              throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 3 !");
             }
-          if(thisP && otherP)
+          else
             {
-              MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(otherP->invertArrayN2O2O2N(getNumberOfCells(p.getGeo())));
-              MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(thisP->deepCpy());
-              p2->transformWithIndArr(p1->begin(),p1->end());
-              p1=p2->getIdsNotEqual(-1);
-              p1=p2->selectByTupleIdSafe(p1->begin(),p1->end());
-              ret->rearrange(nbi*nc); ret=ret->selectByTupleIdSafe(p1->begin(),p1->end()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo);
-              arrSafe[i]=ret; arr[i]=ret;
+              std::vector< const DataArrayInt * >otherPS(ps.size());
+              std::vector< const DataArray * > arr2(ps.size());
+              std::vector< MEDCouplingAutoRefCountObjectPtr<DataArray> > arr2Safe(ps.size());
+              std::vector< const DataArrayInt * > nbis(ps.size());
+              std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > nbisSafe(ps.size());
+              int jj(0);
+              for(std::vector<const MEDFileField1TSStructItem2 *>::const_iterator it2=ps.begin();it2!=ps.end();it2++,jj++)
+                {
+                  int nbi((*it2)->getNbOfIntegrationPts(globs));
+                  const DataArrayInt *otherPfl((*it2)->getPfl(globs));
+                  const std::pair<int,int>& strtStop((*it2)->getStartStop());
+                  MEDCouplingAutoRefCountObjectPtr<DataArray> ret2(vals->selectByTupleId2(strtStop.first,strtStop.second,1));
+                  if(!otherPfl)
+                    throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 4 !");
+                  arr2[jj]=ret2; arr2Safe[jj]=ret2; otherPS[jj]=otherPfl;
+                  nbisSafe[jj]=DataArrayInt::New(); nbisSafe[jj]->alloc(otherPfl->getNumberOfTuples(),1); nbisSafe[jj]->fillWithValue(nbi);
+                  nbis[jj]=nbisSafe[jj];
+                }
+              MEDCouplingAutoRefCountObjectPtr<DataArray> arr3(DataArray::Aggregate(arr2));
+              MEDCouplingAutoRefCountObjectPtr<DataArrayInt> otherP(DataArrayInt::Aggregate(otherPS));
+              MEDCouplingAutoRefCountObjectPtr<DataArrayInt> zenbis(DataArrayInt::Aggregate(nbis));
+              MEDCouplingAutoRefCountObjectPtr<DataArrayInt> otherPN(otherP->invertArrayN2O2O2N(getNumberOfCells(*it)));
+              MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1;
+              if(thisP)
+                p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,thisP);
+              else
+                p1=otherP->deepCpy();
+              MEDCouplingAutoRefCountObjectPtr<DataArrayInt> zenbisN(zenbis->renumber(p1->begin()));
+              zenbisN->computeOffsets2();
+              jj=0;
+              for(std::vector<const MEDFileField1TSStructItem2 *>::const_iterator it2=ps.begin();it2!=ps.end();it2++,jj++)
+                {
+                  int nbi((*it2)->getNbOfIntegrationPts(globs));
+                  const DataArrayInt *otherPfl((*it2)->getPfl(globs));
+                  const std::pair<int,int>& strtStop((*it2)->getStartStop());
+                  MEDCouplingAutoRefCountObjectPtr<DataArray> ret2(vals->selectByTupleId2(strtStop.first,strtStop.second,1));
+                  //
+                  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(otherPfl->deepCpy());
+                  p2->transformWithIndArr(otherPN->begin(),otherPN->end());
+                  p2->transformWithIndArr(p1->begin(),p1->end());
+                  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsN(p2->buildExplicitArrByRanges(zenbisN));
+                  arr3->setPartOfValuesBase3(ret2,idsN->begin(),idsN->end(),0,nc,1);
+                }
+              arrSafe[iii]=arr3; arr[iii]=arr3;
               continue;
             }
-          if(thisP && !otherP)
-            throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 3 !");
-          throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 6 !");
         }
       return DataArray::Aggregate(arr);
     }
index 99e1018d1fafe9f4ab4d38ab78fa564e287c2ee1..029e00b6661216a41476e8d61bd7d98c2f140843 100644 (file)
@@ -1593,7 +1593,7 @@ class MEDLoaderTest4(unittest.TestCase):
     def test10(self):
         """ This test plays with fields only on nodes containing profiles.
         """
-        fname="ForMEDReader9.med"
+        fname="ForMEDReader10.med"
         # building a mesh containing 6 tri3 + 5 quad4
         m=MEDCouplingUMesh("mesh",2)
         coords=DataArrayDouble([(0,0),(1,0),(2,0),(3,0),(4,0),(0,1),(1,1),(2,1),(3,1),(4,1),(0,2),(1,2),(2,2),(3,2),(4,2)]) ; coords.setInfoOnComponents(["XX [m]","YYY [km]"])
@@ -1678,6 +1678,211 @@ class MEDLoaderTest4(unittest.TestCase):
         for i in xrange(1,5):
             self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
             pass
+        for i in xrange(5):
+            f=allFMTSLeavesPerCommonSupport[0][0][0][i]
+            fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
+            f.loadArraysIfNecessary()
+            v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray())
+            self.assertEqual(f.getName(),fieldName0)
+            #self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) # not a bug
+            vExp=DataArrayDouble(9*2) ; vExp.iota(0+i*1000) ; vExp.rearrange(2) ; vExp.setInfoOnComponents(['Comp1_0 [m]','Com2_0 [s^2]'])
+            self.assertTrue(v.isEqual(vExp,1e-12))
+            #
+            f=allFMTSLeavesPerCommonSupport[0][0][1][i]
+            fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
+            f.loadArraysIfNecessary()
+            v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray())
+            self.assertEqual(f.getName(),fieldName1)
+            #self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) # not a bug
+            vExp=DataArrayDouble(9*2) ; vExp.iota(100+i*1000) ; vExp.rearrange(2) ; vExp.setInfoOnComponents(['Comp1_1 [m]','Com2_1 [s^2]'])
+            self.assertTrue(v.isEqual(vExp,1e-12))
+            #
+            f=allFMTSLeavesPerCommonSupport[0][0][2][i]
+            fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
+            f.loadArraysIfNecessary()
+            v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray())
+            self.assertEqual(f.getName(),fieldName2)
+            #self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) # not a bug
+            vExp=DataArrayDouble(9*2) ; vExp.iota(200+i*1000) ; vExp.rearrange(2) ; vExp.setInfoOnComponents(['Comp1_2 [m]','Com2_2 [s^2]'])
+            self.assertTrue(v.isEqual(vExp,1e-12))
+            pass
+        pass
+    
+    def test11(self):
+        """ This test is the ultimate test for the profiles with gauss points. It tests that even if there is non contiguous parts in definition of gauss points, it works !
+        WARNING here, as no other discretizations exists, the priority is given to the field -> the mesh is renumbered to accelerate the build of array of field.
+        """
+        fname="ForMEDReader11.med"
+        m=MEDCouplingCMesh("mesh")
+        arr=DataArrayDouble(5) ; arr.iota()
+        m.setCoords(arr,arr)
+        m=m.buildUnstructured() ; m.getCoords().setInfoOnComponents(["XX [m]","YYY [km]"])
+        mm=MEDFileUMesh() ; mm.setMeshes([m])
+        #
+        fieldName0="zeField0"
+        fs0=MEDFileFieldMultiTS()
+        for i in xrange(5):
+            f=MEDFileField1TS()
+            fNode=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fNode.setTime(float(i),i,0)
+            fNode.setName(fieldName0) ; fNode.setMesh(m)
+            fNode.setGaussLocalizationOnCells([0,2,3,4,7,15],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7],[0.8,0.2])
+            fNode.setGaussLocalizationOnCells([1,5,8,9],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3],[0.8,0.05,0.1,0.04,0.01])
+            fNode.setGaussLocalizationOnCells([6,10,13],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2],[0.8,0.05,0.1,0.04])
+            fNode.setGaussLocalizationOnCells([11,12,14],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4,0.8,0.8],[0.8,0.05,0.1,0.01,0.02,0.005,0.005])
+            arr=DataArrayDouble(2*(2*6+5*4+4*3+7*3)) ; arr.iota(0+1000*i) ; arr.rearrange(2)
+            fNode.setArray(arr) ; arr.setInfoOnComponents(["Comp1_0 [m]","Com2_0 [s^2]"]) ; fNode.checkCoherency()
+            f.setFieldNoProfileSBT(fNode)
+            fs0.pushBackTimeStep(f)
+            pass
+        mm.write(fname,2)
+        fs0.write(fname,0)
+        a0Exp=mm.getCoords().deepCpy()
+        del m,mm,fs0,f,fNode
+        ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
+        ms=MEDFileMeshes(fname)
+        fields=MEDFileFields(fname,False)
+        fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+        allFMTSLeavesToDisplay=[]
+        for fields in fields_per_mesh:
+            allFMTSLeavesToDisplay2=[]
+            for fmts in fields:
+                allFMTSLeavesToDisplay2+=fmts.splitDiscretizations()
+                pass
+            allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2)
+            pass
+        self.assertEqual(len(allFMTSLeavesToDisplay),1)
+        self.assertEqual(len(allFMTSLeavesToDisplay[0]),1)
+        allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+        self.assertEqual(len(allFMTSLeavesPerTimeSeries),1) # one time serie here : because the 1 field is defined on the same time steps
+        self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),1)
+        allFMTSLeavesPerCommonSupport=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesPerTimeSeries[0],ms[ms.getMeshesNames()[0]])
+        self.assertEqual(len(allFMTSLeavesPerCommonSupport),1)
+        self.assertEqual(len(allFMTSLeavesPerCommonSupport[0][0]),1)
+        #
+        mst=MEDFileMeshStruct.New(ms[0])
+        #
+        fcscp=allFMTSLeavesPerCommonSupport[0][1]
+        mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+        mml2=mml.prepare()
+        self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
+        a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
+        self.assertTrue(a0.isEqual(a0Exp,1e-12))
+        self.assertTrue(a1.isEqual(DataArrayByte([9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9])))
+        self.assertTrue(a2.isEqual(DataArrayInt([4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64])))
+        self.assertTrue(a3.isEqual(DataArrayInt([4,1,0,5,6,4,3,2,7,8,4,4,3,8,9,4,6,5,10,11,4,9,8,13,14,4,19,18,23,24,4,2,1,6,7,4,7,6,11,12,4,11,10,15,16,4,12,11,16,17,4,8,7,12,13,4,13,12,17,18,4,17,16,21,22,4,14,13,18,19,4,16,15,20,21,4,18,17,22,23]))) # <- here the mesh is renumbered : the mesh is equal to m[[0,2,3,4,7,15, 1,5,8,9, 6,10,13, 11,12,14]]
+        self.assertTrue(a4 is None)
+        self.assertTrue(a5 is None)
+        for i in xrange(1,5):
+            self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
+            pass
+        for i in xrange(5):
+            f=allFMTSLeavesPerCommonSupport[0][0][0][i]
+            fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
+            f.loadArraysIfNecessary()
+            v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray())
+            self.assertEqual(f.getName(),fieldName0)
+            self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer())
+            vExp=DataArrayDouble([0.,1.,2.,3.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.,25.,44.,45.,46.,47.,126.,127.,128.,129.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,26.,27.,28.,29.,30.,31.,32.,33.,34.,35.,48.,49.,50.,51.,52.,53.,54.,55.,56.,57.,58.,59.,60.,61.,62.,63.,64.,65.,66.,67.,36.,37.,38.,39.,40.,41.,42.,43.,68.,69.,70.,71.,72.,73.,74.,75.,104.,105.,106.,107.,108.,109.,110.,111.,76.,77.,78.,79.,80.,81.,82.,83.,84.,85.,86.,87.,88.,89.,90.,91.,92.,93.,94.,95.,96.,97.,98.,99.,100.,101.,102.,103.,112.,113.,114.,115.,116.,117.,118.,119.,120.,121.,122.,123.,124.,125.],65,2) ; vExp.setInfoOnComponents(['Comp1_0 [m]','Com2_0 [s^2]'])
+            vExp+=i*1000
+            self.assertTrue(v.isEqual(vExp,1e-12))
+            pass
+        pass
+
+    def test12(self):
+        """ This test is the second ultimate test for the profiles with gauss points.
+        This test is close to test11 but here a 2nd field on cells without profile. So here the mesh is expected to be the same than m.
+        """
+        fname="ForMEDReader12.med"
+        m=MEDCouplingCMesh("mesh")
+        arr=DataArrayDouble(5) ; arr.iota()
+        m.setCoords(arr,arr)
+        m=m.buildUnstructured() ; m.getCoords().setInfoOnComponents(["XX [m]","YYY [km]"])
+        mm=MEDFileUMesh() ; mm.setMeshes([m])
+        #
+        fieldName0="zeField0"
+        fieldName1="zeField1"
+        fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS()
+        for i in xrange(5):
+            f=MEDFileField1TS()
+            fNode=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fNode.setTime(float(i),i,0)
+            fNode.setName(fieldName0) ; fNode.setMesh(m)
+            fNode.setGaussLocalizationOnCells([0,2,3,4,7,15],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7],[0.8,0.2])
+            fNode.setGaussLocalizationOnCells([1,5,8,9],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3],[0.8,0.05,0.1,0.04,0.01])
+            fNode.setGaussLocalizationOnCells([6,10,13],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2],[0.8,0.05,0.1,0.04])
+            fNode.setGaussLocalizationOnCells([11,12,14],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4,0.8,0.8],[0.8,0.05,0.1,0.01,0.02,0.005,0.005])
+            arr=DataArrayDouble(2*(2*6+5*4+4*3+7*3)) ; arr.iota(0+1000*i) ; arr.rearrange(2)
+            fNode.setArray(arr) ; arr.setInfoOnComponents(["Comp1_0 [m]","Com2_0 [s^2]"]) ; fNode.checkCoherency()
+            f.setFieldNoProfileSBT(fNode)
+            fs0.pushBackTimeStep(f)
+            #
+            f=MEDFileField1TS()
+            fNode=MEDCouplingFieldDouble(ON_CELLS) ; fNode.setTime(float(i),i,0)
+            fNode.setName(fieldName1) ; fNode.setMesh(m)
+            arr=DataArrayDouble(2*16) ; arr.iota(300+1000*i) ; arr.rearrange(2)
+            fNode.setArray(arr) ; arr.setInfoOnComponents(["Comp1_1 [m]","Com2_1 [s^2]"]) ; fNode.checkCoherency()
+            f.setFieldNoProfileSBT(fNode)
+            fs1.pushBackTimeStep(f)
+            pass
+        mm.write(fname,2)
+        fs0.write(fname,0) ; fs1.write(fname,0)
+        a0Exp=mm.getCoords().deepCpy()
+        del m,mm,fs0,fs1,f,fNode
+        ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
+        ms=MEDFileMeshes(fname)
+        fields=MEDFileFields(fname,False)
+        fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+        allFMTSLeavesToDisplay=[]
+        for fields in fields_per_mesh:
+            allFMTSLeavesToDisplay2=[]
+            for fmts in fields:
+                allFMTSLeavesToDisplay2+=fmts.splitDiscretizations()
+                pass
+            allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2)
+            pass
+        self.assertEqual(len(allFMTSLeavesToDisplay),1)
+        self.assertEqual(len(allFMTSLeavesToDisplay[0]),2)
+        allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+        self.assertEqual(len(allFMTSLeavesPerTimeSeries),1) # one time serie here : because the 2 fields are defined on the same time steps
+        self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),2)
+        allFMTSLeavesPerCommonSupport=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesPerTimeSeries[0],ms[ms.getMeshesNames()[0]])
+        self.assertEqual(len(allFMTSLeavesPerCommonSupport),1)
+        self.assertEqual(len(allFMTSLeavesPerCommonSupport[0][0]),2)
+        #
+        mst=MEDFileMeshStruct.New(ms[0])
+        #
+        fcscp=allFMTSLeavesPerCommonSupport[0][1]
+        mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+        mml2=mml.prepare()
+        self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
+        a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
+        self.assertTrue(a0.isEqual(a0Exp,1e-12))
+        self.assertTrue(a1.isEqual(DataArrayByte([9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9])))
+        self.assertTrue(a2.isEqual(DataArrayInt([4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64])))
+        self.assertTrue(a3.isEqual(DataArrayInt([4,1,0,5,6,4,2,1,6,7,4,3,2,7,8,4,4,3,8,9,4,6,5,10,11,4,7,6,11,12,4,8,7,12,13,4,9,8,13,14,4,11,10,15,16,4,12,11,16,17,4,13,12,17,18,4,14,13,18,19,4,16,15,20,21,4,17,16,21,22,4,18,17,22,23,4,19,18,23,24]))) # <- here the mesh is NOT renumbered : the mesh is equal to m
+        self.assertTrue(a4 is None)
+        self.assertTrue(a5 is None)
+        for i in xrange(1,5):
+            self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
+            pass
+        for i in xrange(5):
+            f=allFMTSLeavesPerCommonSupport[0][0][0][i]
+            fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
+            f.loadArraysIfNecessary()
+            v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray())
+            self.assertEqual(f.getName(),fieldName0)
+            #self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) # not a bug : huge reordering performed !
+            vExp=DataArrayDouble(65*2) ; vExp.iota(0+i*1000) ; vExp.rearrange(2) ; vExp.setInfoOnComponents(['Comp1_0 [m]','Com2_0 [s^2]'])
+            self.assertTrue(v.isEqual(vExp,1e-12))
+            #
+            f=allFMTSLeavesPerCommonSupport[0][0][1][i]
+            fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
+            f.loadArraysIfNecessary()
+            v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray())
+            self.assertEqual(f.getName(),fieldName1)
+            self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) # not a bug : huge reordering performed !
+            vExp=DataArrayDouble(16*2) ; vExp.iota(300+i*1000) ; vExp.rearrange(2) ; vExp.setInfoOnComponents(['Comp1_1 [m]','Com2_1 [s^2]'])
+            self.assertTrue(v.isEqual(vExp,1e-12))
+            pass
         pass
 
     pass