]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Merge from V6_2_BR 23/12/2010
authorvsr <vsr@opencascade.com>
Fri, 24 Dec 2010 08:17:27 +0000 (08:17 +0000)
committervsr <vsr@opencascade.com>
Fri, 24 Dec 2010 08:17:27 +0000 (08:17 +0000)
71 files changed:
doc/doxygen/Doxyfile_med_user.in
doc/doxygen/Makefile.am
src/INTERP_KERNEL/Bases/InterpKernelAutoPtr.hxx [new file with mode: 0644]
src/INTERP_KERNEL/Bases/Makefile.am
src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx
src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx
src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx
src/MEDCoupling/MEDCouplingCMesh.cxx
src/MEDCoupling/MEDCouplingCMesh.hxx
src/MEDCoupling/MEDCouplingExtrudedMesh.cxx
src/MEDCoupling/MEDCouplingExtrudedMesh.hxx
src/MEDCoupling/MEDCouplingFieldDiscretization.cxx
src/MEDCoupling/MEDCouplingFieldDouble.cxx
src/MEDCoupling/MEDCouplingFieldDouble.hxx
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling/MEDCouplingMemArray.hxx
src/MEDCoupling/MEDCouplingMesh.hxx
src/MEDCoupling/MEDCouplingPointSet.cxx
src/MEDCoupling/MEDCouplingPointSet.hxx
src/MEDCoupling/MEDCouplingTimeDiscretization.cxx
src/MEDCoupling/MEDCouplingTimeDiscretization.hxx
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling/MEDCouplingUMesh.hxx
src/MEDCoupling/MEDCouplingUMeshDesc.cxx
src/MEDCoupling/MEDCouplingUMeshDesc.hxx
src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx
src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx
src/MEDCoupling_Swig/MEDCoupling.i [new file with mode: 0644]
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py
src/MEDCoupling_Swig/MEDCouplingDataForTest.py
src/MEDCoupling_Swig/MEDCouplingRemapper.i [new file with mode: 0644]
src/MEDCoupling_Swig/MEDCouplingRemapperTest.py
src/MEDCoupling_Swig/MEDCouplingTypemaps.i
src/MEDCoupling_Swig/Makefile.am
src/MEDCoupling_Swig/libMEDCouplingRemapper_Swig.i [deleted file]
src/MEDCoupling_Swig/libMEDCoupling_Swig.i [deleted file]
src/MEDCoupling_Swig/libMEDCoupling_Swig.py [new file with mode: 0644]
src/MEDLoader/MEDFileBasis.cxx [new file with mode: 0644]
src/MEDLoader/MEDFileBasis.hxx [new file with mode: 0644]
src/MEDLoader/MEDFileMesh.cxx [new file with mode: 0644]
src/MEDLoader/MEDFileMesh.hxx [new file with mode: 0644]
src/MEDLoader/MEDFileMeshElt.cxx [new file with mode: 0644]
src/MEDLoader/MEDFileMeshElt.hxx [new file with mode: 0644]
src/MEDLoader/MEDFileMeshLL.cxx [new file with mode: 0644]
src/MEDLoader/MEDFileMeshLL.hxx [new file with mode: 0644]
src/MEDLoader/MEDFileUtilities.cxx [new file with mode: 0644]
src/MEDLoader/MEDFileUtilities.hxx [new file with mode: 0644]
src/MEDLoader/MEDLoader.cxx
src/MEDLoader/MEDLoader.hxx
src/MEDLoader/Makefile.am
src/MEDLoader/Swig/MEDLoader.i [new file with mode: 0644]
src/MEDLoader/Swig/MEDLoaderDataForTest.py
src/MEDLoader/Swig/MEDLoaderTest.py
src/MEDLoader/Swig/MEDLoaderTest2.py
src/MEDLoader/Swig/MEDLoaderTest3.py [new file with mode: 0644]
src/MEDLoader/Swig/MEDLoaderTypemaps.i
src/MEDLoader/Swig/Makefile.am
src/MEDLoader/Swig/libMEDLoader_Swig.i [deleted file]
src/MEDLoader/Swig/libMEDLoader_Swig.py [new file with mode: 0644]
src/MEDLoader/Test/MEDLoaderTest.cxx
src/ParaMEDMEM/ICoCoMEDField.cxx
src/ParaMEDMEM_Swig/Makefile.am
src/ParaMEDMEM_Swig/ParaMEDMEM.i [new file with mode: 0644]
src/ParaMEDMEM_Swig/ParaMEDMEM.py [deleted file]
src/ParaMEDMEM_Swig/ParaMEDMEM.typemap [new file with mode: 0644]
src/ParaMEDMEM_Swig/libParaMEDMEM_Swig.i [deleted file]
src/ParaMEDMEM_Swig/libParaMEDMEM_Swig.typemap [deleted file]
src/ParaMEDMEM_Swig/test_InterpKernelDEC.py
src/ParaMEDMEM_Swig/test_StructuredCoincidentDEC.py [new file with mode: 0755]
src/ParaMEDMEM_Swig/test_StructuredCoincodentDEC.py [deleted file]

index ef07e414c2b7bc0d73f771a7e913f373630bf637..01b76df5c9526e2ee77f532f4d1bfb93e1281351 100644 (file)
@@ -71,6 +71,7 @@ WARN_LOGFILE           = log_user
 INPUT                  = @srcdir@ \
                          @srcdir@/../../src/ParaMEDMEM \
                          @srcdir@/../../src/INTERP_KERNEL \
+                        @srcdir@/../../src/INTERP_KERNEL/Bases \
                          @srcdir@/../../src/INTERP_KERNEL/Geometric2D \
                          @srcdir@/../../src/MEDCoupling \
                         @srcdir@/../../src/MEDLoader \
@@ -89,6 +90,7 @@ FILE_PATTERNS          = MEDMEM_Mesh.* \
                          ExplicitCoincidentDEC.* \
                          NonCoincidentDEC.* \
                          CommInterface.* \
+                        NormalizedUnstructuredMesh.* \
                          Interpolation2D.* \
                          Interpolation3D.* \
                          Interpolation3DSurf.* \
index 178b3c6885e1df5de1fb1b8e401de856f8b12649..b49523f5f6ce6d7b261ee216c776606269b26e9d 100644 (file)
@@ -43,10 +43,18 @@ clean-local:
 
 EXTRA_DIST += figures \
              main.dox \
+             Geometric2D.dox \
              MED_class.dox \
              biblio.dox \
+             barycoords.dox \
+             dualmesh.dox \
+             extractor.dox \
              field.dox \
              grid.dox \
+             interpkernel.dox \
+             medcoupling.dox \
+             medloader.dox \
+             medmem.dox \
              medsplitter.dox \
              mesh.dox \
              meshing.dox \
diff --git a/src/INTERP_KERNEL/Bases/InterpKernelAutoPtr.hxx b/src/INTERP_KERNEL/Bases/InterpKernelAutoPtr.hxx
new file mode 100644 (file)
index 0000000..5851a24
--- /dev/null
@@ -0,0 +1,45 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __INTERPKERNELAUTOPTR_HXX__
+#define __INTERPKERNELAUTOPTR_HXX__
+
+namespace INTERP_KERNEL
+{
+  template<class T>
+  class AutoPtr
+  {
+  public:
+    AutoPtr(T *ptr=0):_ptr(ptr) {  }
+    ~AutoPtr() { destroyPtr(); }
+    AutoPtr &operator=(T *ptr) { destroyPtr(); _ptr=ptr; return *this; }
+    T *operator->() { return _ptr ; }
+    const T *operator->() const { return _ptr; }
+    T& operator*() { return *_ptr; }
+    const T& operator*() const { return *_ptr; }
+    operator T *() { return _ptr; }
+    operator const T *() const { return _ptr; }
+  private:
+    void destroyPtr() { delete [] _ptr; }
+  private:
+    T *_ptr;
+  };
+}
+
+#endif
index fc89569bc3422e42cad1f617e3f62cc04899da6b..4b74948f3ff45bef548b68f6f049d30a39fc4e30 100755 (executable)
@@ -32,7 +32,8 @@ NormalizedUnstructuredMesh.hxx  \
 InterpKernelStlExt.hxx          \
 InterpKernelHashMap.hxx         \
 InterpKernelHashTable.hxx       \
-InterpKernelHashFun.hxx
+InterpKernelHashFun.hxx         \
+InterpKernelAutoPtr.hxx
 
 # Libraries targets
 
index ee7116fd2e32d62a3196951cc9c0a62a8fea25a5..479b5c78ec8c201e50fbc57b3c36efdf5aee2f41 100644 (file)
 #include <sstream>
 #include <algorithm>
 
+#ifdef _POSIX_MAPPED_FILES
+#include <sys/mman.h>
+#else
+#ifdef WNT
+#include <windows.h>
+#endif
+#endif
+
 const char *INTERP_KERNEL::AsmX86::OPS[NB_OF_OPS]={"mov","push","pop","fld","faddp","fsubp","fmulp","fdivp","fcos","fsin","fabs","fchs","fsqrt","sub","add","ret","leave","movsd","fst"};
 
 std::vector<char> INTERP_KERNEL::AsmX86::convertIntoMachineLangage(const std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
@@ -33,11 +41,20 @@ std::vector<char> INTERP_KERNEL::AsmX86::convertIntoMachineLangage(const std::ve
   return ret;
 }
 
-char *INTERP_KERNEL::AsmX86::convertMachineLangageInBasic(const std::vector<char>& ml, int& lgth) const
+char *INTERP_KERNEL::AsmX86::copyToExecMemZone(const std::vector<char>& ml, unsigned& offset) const
 {
-  lgth=ml.size();
-  char *ret=new char[lgth];
-  std::copy(ml.begin(),ml.end(),ret);
+  char *ret=0;
+  int lgth=ml.size();
+#ifdef _POSIX_MAPPED_FILES
+  ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0);
+#else
+#ifdef WNT
+  HANDLE h=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,lgth,NULL);
+  ret=(char *)MapViewOfFile(h,FILE_MAP_EXECUTE | FILE_MAP_READ | FILE_MAP_WRITE,0,0,lgth);
+#endif
+#endif
+  if(ret)
+    std::copy(ml.begin(),ml.end(),ret);
   return ret;
 }
 
index 11b8733e5040701355a8d6237167d728ea36345c..fd7bc9afc840417159687d4451c1d85ed96120d5 100644 (file)
@@ -32,7 +32,7 @@ namespace INTERP_KERNEL
   {
   public:
     std::vector<char> convertIntoMachineLangage(const std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
-    char *convertMachineLangageInBasic(const std::vector<char>& ml, int& lgth) const;
+    char *copyToExecMemZone(const std::vector<char>& ml, unsigned& offset) const;
   private:
     void convertOneInstructionInML(const std::string& inst, std::vector<char>& ml) const throw(INTERP_KERNEL::Exception);
   private:
index 585fac2f832a1ff3d6c4162e90854de62a304efb..1f6b497b5fd10c7aee297bc290d57b9ba6ce5a6b 100644 (file)
 #include <iostream>
 #include <algorithm>
 
-#ifdef _POSIX_MAPPED_FILES
-#include <sys/mman.h>
-#else
-#ifdef WNT
-#include <windows.h>
-#endif
-#endif
-
 using namespace INTERP_KERNEL;
 
 const char LeafExprVar::END_OF_RECOGNIZED_VAR[]="Vec";
@@ -719,21 +711,8 @@ char *ExprParser::compileX86() const
   for(std::vector<char>::const_iterator iter=output.begin();iter!=output.end();iter++)
     std::cout << std::hex << (int)((unsigned char)(*iter)) << " ";
   std::cout << std::endl;
-  int lgth;
-  char *lm=asmb.convertMachineLangageInBasic(output,lgth);
-  char *ret=0;
-#ifdef _POSIX_MAPPED_FILES
-  ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0);
-#else
-#ifdef WNT
-  HANDLE h=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,lgth,NULL);
-  ret=(char *)MapViewOfFile(h,FILE_MAP_EXECUTE | FILE_MAP_READ | FILE_MAP_WRITE,0,0,lgth);
-#endif
-#endif
-  if(ret)
-    std::copy(lm,lm+lgth,ret);
-  delete [] lm;
-  return ret;
+  unsigned offset;
+  return asmb.copyToExecMemZone(output,offset);
 }
 
 char *ExprParser::compileX86_64() const
@@ -757,21 +736,8 @@ char *ExprParser::compileX86_64() const
   for(std::vector<char>::const_iterator iter=output.begin();iter!=output.end();iter++)
     std::cout << std::hex << (int)((unsigned char)(*iter)) << " ";
   std::cout << std::endl;
-  int lgth;
-  char *lm=asmb.convertMachineLangageInBasic(output,lgth);
-  char *ret=0;
-#ifdef _POSIX_MAPPED_FILES
-  ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0);
-#else
-#ifdef WNT
-  HANDLE h=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,lgth,NULL);
-  ret=(char *)MapViewOfFile(h,FILE_MAP_EXECUTE | FILE_MAP_READ | FILE_MAP_WRITE,0,0,lgth);
-#endif
-#endif
-  if(ret)
-    std::copy(lm,lm+lgth,ret);
-  delete [] lm;
-  return ret;
+  unsigned offset;
+  return asmb.copyToExecMemZone(output,offset);
 }
 
 void ExprParser::compileX86LowLev(std::vector<std::string>& ass) const
@@ -782,9 +748,9 @@ void ExprParser::compileX86LowLev(std::vector<std::string>& ass) const
     {
       for(std::list<ExprParser>::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++)
         (*iter).compileX86LowLev(ass);
-      for(std::list<Function *>::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++)
-        (*iter2)->operateX86(ass);
     }
+  for(std::list<Function *>::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++)
+    (*iter2)->operateX86(ass);
 }
 
 void ExprParser::compileX86_64LowLev(std::vector<std::string>& ass) const
@@ -795,9 +761,9 @@ void ExprParser::compileX86_64LowLev(std::vector<std::string>& ass) const
     {
       for(std::list<ExprParser>::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++)
         (*iter).compileX86_64LowLev(ass);
-      for(std::list<Function *>::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++)
-        (*iter2)->operateX86(ass);
     }
+  for(std::list<Function *>::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++)
+    (*iter2)->operateX86(ass);
 }
 
 void LeafExprVal::compileX86(std::vector<std::string>& ass) const
index 4c49d3b93d482b8e50a29f01f60023c2a312c735..9ec8bec952fbd9703780ff7760b44e96bb11b184 100644 (file)
@@ -37,11 +37,11 @@ MEDCouplingCMesh::MEDCouplingCMesh(const MEDCouplingCMesh& other, bool deepCpy):
   if(deepCpy)
     {
       if(other._x_array)
-        _x_array=_x_array->deepCopy();
+        _x_array=_x_array->deepCpy();
       if(other._y_array)
-        _y_array=_y_array->deepCopy();
+        _y_array=_y_array->deepCpy();
       if(other._z_array)
-        _z_array=_z_array->deepCopy();
+        _z_array=_z_array->deepCpy();
     }
   else
     {
@@ -436,7 +436,7 @@ void MEDCouplingCMesh::setCoords(DataArrayDouble *coordsX, DataArrayDouble *coor
   declareAsNew();
 }
 
-MEDCouplingUMesh *MEDCouplingCMesh::buildUnstructured() const
+MEDCouplingUMesh *MEDCouplingCMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception)
 {
   int spaceDim=getSpaceDimension();
   MEDCouplingUMesh *ret=MEDCouplingUMesh::New(getName(),spaceDim);
index c7d9e879255b8c37815e9200f1e1750c135a004a..3d047a6eb974ac6fd4fcabcf92eac71f2c2f4a13 100644 (file)
@@ -63,7 +63,7 @@ namespace ParaMEDMEM
                    DataArrayDouble *coordsY=0,
                    DataArrayDouble *coordsZ=0);
     // tools
-    MEDCouplingUMesh *buildUnstructured() const;
+    MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
     MEDCouplingMesh *buildPart(const int *start, const int *end) const;
     MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const;
     DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
index 84a9d451c383b10dfc61be6933bd7a58676ac77a..d386e340e5035e81a43d62be94f090f94f67a679 100644 (file)
@@ -104,7 +104,7 @@ MEDCouplingExtrudedMesh::MEDCouplingExtrudedMesh(const MEDCouplingExtrudedMesh&
     {
       _mesh2D=other._mesh2D->clone(true);
       _mesh1D=other._mesh1D->clone(true);
-      _mesh3D_ids=other._mesh3D_ids->deepCopy();
+      _mesh3D_ids=other._mesh3D_ids->deepCpy();
     }
   else
     {
@@ -323,13 +323,18 @@ void MEDCouplingExtrudedMesh::renumberCells(const int *old2NewBg, bool check) th
 
 MEDCouplingUMesh *MEDCouplingExtrudedMesh::build3DUnstructuredMesh() const
 {
-  MEDCouplingUMesh *ret=_mesh2D->buildExtrudedMeshFromThis(_mesh1D,0);
+  MEDCouplingUMesh *ret=_mesh2D->buildExtrudedMesh(_mesh1D,0);
   const int *renum=_mesh3D_ids->getConstPointer();
   ret->renumberCells(renum,false);
   ret->setName(getName());
   return ret;
 }
 
+MEDCouplingUMesh *MEDCouplingExtrudedMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception)
+{
+  return build3DUnstructuredMesh();
+}
+
 MEDCouplingFieldDouble *MEDCouplingExtrudedMesh::getMeasureField(bool) const
 {
   std::string name="MeasureOfMesh_";
index 36317241094095a07590764e652b78401c4a31ad..d5025341eb453753d820839a7456ace144acf892 100644 (file)
@@ -65,6 +65,7 @@ namespace ParaMEDMEM
     MEDCouplingUMesh *getMesh1D() const { return _mesh1D; }
     DataArrayInt *getMesh3DIds() const { return _mesh3D_ids; }
     MEDCouplingUMesh *build3DUnstructuredMesh() const;
+    MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDouble *getMeasureField(bool) const;
     MEDCouplingFieldDouble *getMeasureFieldOnNode(bool) const;
     MEDCouplingFieldDouble *buildOrthogonalField() const;
index e5ad06173e7aeb7237f5eca79db95e789ab8c0a7..d5c1a1e8c4d0ac6570fc9ac5f3bf5be45cc81301 100644 (file)
@@ -259,7 +259,7 @@ void MEDCouplingFieldDiscretization::renumberEntitiesFromO2NArr(const int *old2N
   int oldNbOfElems=arr->getNumberOfTuples();
   int nbOfComp=arr->getNumberOfComponents();
   int newNbOfTuples=(*std::max_element(old2NewPtr,old2NewPtr+oldNbOfElems))+1;
-  DataArrayDouble *arrCpy=arr->deepCopy();
+  DataArrayDouble *arrCpy=arr->deepCpy();
   const double *ptSrc=arrCpy->getConstPointer();
   arr->reAlloc(newNbOfTuples);
   double *ptToFill=arr->getPointer();
@@ -291,7 +291,7 @@ void MEDCouplingFieldDiscretization::renumberEntitiesFromO2NArr(const int *old2N
 void MEDCouplingFieldDiscretization::renumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const char *msg)
 {
   int nbOfComp=arr->getNumberOfComponents();
-  DataArrayDouble *arrCpy=arr->deepCopy();
+  DataArrayDouble *arrCpy=arr->deepCpy();
   const double *ptSrc=arrCpy->getConstPointer();
   arr->reAlloc(new2OldSz);
   double *ptToFill=arr->getPointer();
@@ -586,7 +586,7 @@ MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell(con
 {
   DataArrayInt *arr=other._discr_per_cell;
   if(arr)
-    _discr_per_cell=arr->deepCopy();
+    _discr_per_cell=arr->deepCpy();
 }
 
 void MEDCouplingFieldDiscretizationPerCell::updateTime()
index 60b5caab8a255079a3e5b76d3596c12789e0a79c..d24f36c1208399b05d85dc5fe75d1c9d3db76ecf 100644 (file)
@@ -52,6 +52,11 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::cloneWithMesh(bool recDeepCpy) c
   return ret;
 }
 
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::deepCpy() const
+{
+  return cloneWithMesh(true);
+}
+
 MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const
 {
   MEDCouplingTimeDiscretization *tdo=_time_discr->buildNewTimeReprFromThis(_time_discr,td,deepCpy);
@@ -221,6 +226,39 @@ bool MEDCouplingFieldDouble::areCompatibleForMul(const MEDCouplingField *other)
   return true;
 }
 
+/*!
+ * Method with same principle than MEDCouplingFieldDouble::areStrictlyCompatible method except that
+ * number of components between 'this' and 'other' can be different here (for operator/).
+ */
+bool MEDCouplingFieldDouble::areCompatibleForDiv(const MEDCouplingField *other) const
+{
+  if(!MEDCouplingField::areStrictlyCompatible(other))
+    return false;
+  const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
+  if(!otherC)
+    return false;
+  if(_nature!=otherC->_nature)
+    return false;
+  if(!_time_discr->areStrictlyCompatibleForDiv(otherC->_time_discr))
+    return false;
+  return true;
+}
+
+/*!
+ * This method is invocated before any attempt of melding. This method is very close to areStrictlyCompatible,
+ * except that 'this' and other can have different number of components.
+ */
+bool MEDCouplingFieldDouble::areCompatibleForMeld(const MEDCouplingFieldDouble *other) const
+{
+  if(!MEDCouplingField::areStrictlyCompatible(other))
+    return false;
+  if(_nature!=other->_nature)
+    return false;
+  if(!_time_discr->areCompatibleForMeld(other->_time_discr))
+    return false;
+  return true;
+}
+
 /*!
  * This method performs a clone of mesh and a renumbering of underlying cells of it. The number of cells remains the same.
  * The values of field are impacted in consequence to have the same geometrical field.
@@ -1033,6 +1071,29 @@ bool MEDCouplingFieldDouble::mergeNodes(double eps) throw(INTERP_KERNEL::Excepti
   return true;
 }
 
+/*!
+ * Merge nodes with (barycenter computation) of underlying mesh. In case of some node will be merged the underlying mesh instance will change.
+ */
+bool MEDCouplingFieldDouble::mergeNodes2(double eps) throw(INTERP_KERNEL::Exception)
+{
+  const MEDCouplingPointSet *meshC=dynamic_cast<const MEDCouplingPointSet *>(_mesh);
+  if(!meshC)
+    throw INTERP_KERNEL::Exception("Invalid support mesh to apply mergeNodes on it : must be a MEDCouplingPointSet one !");
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCpy());
+  bool ret;
+  int ret2;
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->mergeNodes2(eps,ret,ret2);
+  if(!ret)//no nodes have been merged.
+    return ret;
+  std::vector<DataArrayDouble *> arrays;
+  _time_discr->getArrays(arrays);
+  for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
+    if(*iter)
+      _type->renumberValuesOnNodes(arr->getConstPointer(),*iter);
+  setMesh(meshC2);
+  return true;
+}
+
 /*!
  * This method applyies ParaMEDMEM::MEDCouplingPointSet::zipCoords method on 'this->_mesh' that should be set and of type ParaMEDMEM::MEDCouplingPointSet.
  * If some nodes have disappeared true is returned.
@@ -1221,7 +1282,7 @@ void MEDCouplingFieldDouble::sortPerTuple(bool asc) throw(INTERP_KERNEL::Excepti
   _time_discr->sortPerTuple(asc);
 }
 
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
 {
   if(!f1->areCompatibleForMerge(f2))
     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply mergeFields on them !");
@@ -1229,6 +1290,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const MEDCouplingFie
   const MEDCouplingMesh *m2=f2->getMesh();
   MEDCouplingMesh *m=m1->mergeMyselfWith(m2);
   MEDCouplingTimeDiscretization *td=f1->_time_discr->aggregate(f2->_time_discr);
+  td->copyTinyAttrFrom(*f1->_time_discr);
   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
   ret->setMesh(m);
   m->decrRef();
@@ -1237,7 +1299,48 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const MEDCouplingFie
   return ret;
 }
 
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const std::vector<const MEDCouplingFieldDouble *>& a) throw(INTERP_KERNEL::Exception)
+{
+  if(a.size()<=1)
+    throw INTERP_KERNEL::Exception("FieldDouble::mergeFields : size of array must be > 1 !");
+  std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > ms(a.size());
+  std::vector< const MEDCouplingUMesh *> ms2(a.size());
+  std::vector< const MEDCouplingTimeDiscretization *> tds(a.size());
+  std::vector<const MEDCouplingFieldDouble *>::const_iterator it=a.begin();
+  const MEDCouplingFieldDouble *ref=(*it++);
+  for(;it!=a.end();it++)
+    if(!ref->areCompatibleForMerge(*it))
+      throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply mergeFields on them !");
+  for(int i=0;i<(int)a.size();i++)
+    {
+      if(!a[i]->getMesh())
+        throw INTERP_KERNEL::Exception("mergeFields : A field as no underlying mesh !");
+      ms[i]=a[i]->getMesh()->buildUnstructured();
+      ms2[i]=ms[i];
+      tds[i]=a[i]->_time_discr;
+    }
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MEDCouplingUMesh::mergeUMeshes(ms2);
+  MEDCouplingTimeDiscretization *td=tds[0]->aggregate(tds);
+  td->copyTinyAttrFrom(*(a[0]->_time_discr));
+  MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(a[0]->getNature(),td,a[0]->_type->clone());
+  ret->setMesh(m);
+  ret->setName(a[0]->getName());
+  ret->setDescription(a[0]->getDescription());
+  return ret;
+}
+
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::meldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
+{
+  if(!f1->areCompatibleForMeld(f2))
+    throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply meldFields on them !");
+  MEDCouplingTimeDiscretization *td=f1->_time_discr->meld(f2->_time_discr);
+  td->copyTinyAttrFrom(*f1->_time_discr);
+  MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
+  ret->setMesh(f1->getMesh());
+  return ret;
+}
+
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
 {
   if(!f1->areStrictlyCompatible(f2))
     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply dotFields on them !");
@@ -1248,7 +1351,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::dotFields(const MEDCouplingField
   return ret;
 }
 
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
 {
   if(!f1->areStrictlyCompatible(f2))
     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply crossProductFields on them !");
@@ -1259,7 +1362,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::crossProductFields(const MEDCoup
   return ret;
 }
 
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
 {
   if(!f1->areStrictlyCompatible(f2))
     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply maxFields on them !");
@@ -1270,7 +1373,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxFields(const MEDCouplingField
   return ret;
 }
 
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
 {
   if(!f1->areStrictlyCompatible(f2))
     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply minFields on them !");
@@ -1281,7 +1384,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::minFields(const MEDCouplingField
   return ret;
 }
 
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::addFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::addFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
 {
   if(!f1->areStrictlyCompatible(f2))
     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply addFields on them !");
@@ -1292,7 +1395,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::addFields(const MEDCouplingField
   return ret;
 }
 
-const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator+=(const MEDCouplingFieldDouble& other)
+const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
 {
   if(!areStrictlyCompatible(&other))
     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply += on them !");
@@ -1300,7 +1403,7 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator+=(const MEDCoupli
   return *this;
 }
 
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::substractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::substractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
 {
   if(!f1->areStrictlyCompatible(f2))
     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply substractFields on them !");
@@ -1311,7 +1414,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::substractFields(const MEDCouplin
   return ret;
 }
 
-const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator-=(const MEDCouplingFieldDouble& other)
+const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
 {
   if(!areStrictlyCompatible(&other))
     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply -= on them !");
@@ -1319,7 +1422,7 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator-=(const MEDCoupli
   return *this;
 }
 
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::multiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::multiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
 {
   if(!f1->areCompatibleForMul(f2))
     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply multiplyFields on them !");
@@ -1330,7 +1433,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::multiplyFields(const MEDCoupling
   return ret;
 }
 
-const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator*=(const MEDCouplingFieldDouble& other)
+const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
 {
   if(!areCompatibleForMul(&other))
     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply *= on them !");
@@ -1338,9 +1441,9 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator*=(const MEDCoupli
   return *this;
 }
 
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::divideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::divideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
 {
-  if(!f1->areStrictlyCompatible(f2))
+  if(!f1->areCompatibleForDiv(f2))
     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply divideFields on them !");
   MEDCouplingTimeDiscretization *td=f1->_time_discr->divide(f2->_time_discr);
   td->copyTinyAttrFrom(*f1->_time_discr);
@@ -1349,9 +1452,9 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::divideFields(const MEDCouplingFi
   return ret;
 }
 
-const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator/=(const MEDCouplingFieldDouble& other)
+const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
 {
-  if(!areStrictlyCompatible(&other))
+  if(!areCompatibleForDiv(&other))
     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply /= on them !");
   _time_discr->divideEqual(other._time_discr);
   return *this;
index 19f804c3183559b5259860e8876c53eefa9d4a4a..719bc41c80b6b253cc1b469ed161f73e9d39cb4c 100644 (file)
@@ -41,6 +41,8 @@ namespace ParaMEDMEM
     bool areCompatibleForMerge(const MEDCouplingField *other) const;
     bool areStrictlyCompatible(const MEDCouplingField *other) const;
     bool areCompatibleForMul(const MEDCouplingField *other) const;
+    bool areCompatibleForDiv(const MEDCouplingField *other) const;
+    bool areCompatibleForMeld(const MEDCouplingFieldDouble *other) const;
     void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
     void renumberCellsWithoutMesh(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
     void renumberNodes(const int *old2NewBg) throw(INTERP_KERNEL::Exception);
@@ -48,6 +50,7 @@ namespace ParaMEDMEM
     DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDouble *buildSubPart(const DataArrayInt *part) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDouble *buildSubPart(const int *partBg, const int *partEnd) const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *deepCpy() const;
     MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
     MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const;
     MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const;
@@ -112,6 +115,7 @@ namespace ParaMEDMEM
     void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);
     void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);
     bool mergeNodes(double eps) throw(INTERP_KERNEL::Exception);
+    bool mergeNodes2(double eps) throw(INTERP_KERNEL::Exception);
     bool zipCoords() throw(INTERP_KERNEL::Exception);
     bool zipConnectivity(int compType) throw(INTERP_KERNEL::Exception);
     bool simplexize(int policy) throw(INTERP_KERNEL::Exception);
@@ -128,27 +132,29 @@ namespace ParaMEDMEM
     MEDCouplingFieldDouble *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
     void setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
     void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
-    static MEDCouplingFieldDouble *mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
-    static MEDCouplingFieldDouble *dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
-    MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const { return dotFields(this,&other); }
-    static MEDCouplingFieldDouble *crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
-    MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const { return crossProductFields(this,&other); }
-    static MEDCouplingFieldDouble *maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
-    MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const { return maxFields(this,&other); }
-    static MEDCouplingFieldDouble *minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
-    MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const { return minFields(this,&other); }
-    MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const { return addFields(this,&other); }
-    const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other);
-    static MEDCouplingFieldDouble *addFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
-    MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const { return substractFields(this,&other); }
-    const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other);
-    static MEDCouplingFieldDouble *substractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
-    MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const { return multiplyFields(this,&other); }
-    const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other);
-    static MEDCouplingFieldDouble *multiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
-    MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const { return divideFields(this,&other); }
-    const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other);
-    static MEDCouplingFieldDouble *divideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
+    static MEDCouplingFieldDouble *mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+    static MEDCouplingFieldDouble *mergeFields(const std::vector<const MEDCouplingFieldDouble *>& a) throw(INTERP_KERNEL::Exception);
+    static MEDCouplingFieldDouble *meldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+    static MEDCouplingFieldDouble *dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return dotFields(this,&other); }
+    static MEDCouplingFieldDouble *crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return crossProductFields(this,&other); }
+    static MEDCouplingFieldDouble *maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return maxFields(this,&other); }
+    static MEDCouplingFieldDouble *minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return minFields(this,&other); }
+    MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return addFields(this,&other); }
+    const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+    static MEDCouplingFieldDouble *addFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return substractFields(this,&other); }
+    const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+    static MEDCouplingFieldDouble *substractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return multiplyFields(this,&other); }
+    const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+    static MEDCouplingFieldDouble *multiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return divideFields(this,&other); }
+    const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+    static MEDCouplingFieldDouble *divideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
   private:
     MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td);
     MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy);
index 1b4a20b49b0745204d143bc040715c75e2019b31..d0596e3394704216173ace64ce4bff4fa2749e5d 100644 (file)
@@ -131,15 +131,15 @@ void DataArrayDouble::checkAllocated() const throw(INTERP_KERNEL::Exception)
     throw INTERP_KERNEL::Exception("DataArrayDouble::checkAllocated : Array is defined but not allocated ! Call alloc or setValues method first !");
 }
 
-DataArrayDouble *DataArrayDouble::deepCopy() const
+DataArrayDouble *DataArrayDouble::deepCpy() const
 {
   return new DataArrayDouble(*this);
 }
 
-DataArrayDouble *DataArrayDouble::performCpy(bool deepCpy) const
+DataArrayDouble *DataArrayDouble::performCpy(bool dCpy) const
 {
-  if(deepCpy)
-    return deepCopy();
+  if(dCpy)
+    return deepCpy();
   else
     {
       incrRef();
@@ -403,6 +403,29 @@ DataArrayDouble *DataArrayDouble::selectByTupleId(const int *new2OldBg, const in
   return ret;
 }
 
+/*!
+ * This method is equivalent to DataArrayInt::selectByTupleId except that an analyze to the content of input range to check that it will not lead to memory corruption !
+ */
+DataArrayDouble *DataArrayDouble::selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception)
+{
+  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
+  int nbComp=getNumberOfComponents();
+  int oldNbOfTuples=getNumberOfTuples();
+  ret->alloc(std::distance(new2OldBg,new2OldEnd),nbComp);
+  ret->copyStringInfoFrom(*this);
+  double *pt=ret->getPointer();
+  const double *srcPt=getConstPointer();
+  int i=0;
+  for(const int *w=new2OldBg;w!=new2OldEnd;w++,i++)
+    if(*w>=0 && *w<oldNbOfTuples)
+      std::copy(srcPt+(*w)*nbComp,srcPt+((*w)+1)*nbComp,pt+i*nbComp);
+    else
+      throw INTERP_KERNEL::Exception("DataArrayInt::selectByTupleIdSafe : some ids has been detected to be out of [0,this->getNumberOfTuples) !");
+  ret->copyStringInfoFrom(*this);
+  ret->incrRef();
+  return ret;
+}
+
 /*!
  * This methods has a similar behaviour than std::string::substr. This method returns a newly created DataArrayInt that is part of this with same number of components.
  * The intervall is specified by [tupleIdBg,tupleIdEnd) except if tupleIdEnd ==-1 in this case the [tupleIdBg,this->end()) will be kept.
@@ -461,6 +484,25 @@ DataArrayDouble *DataArrayDouble::changeNbOfComponents(int newNbOfComp, double d
   return ret;
 }
 
+/*!
+ * Contrary to DataArrayDouble::changeNbOfComponents method this method is \b not const. The content 
+ * This method \b do \b not change the content of data but changes the splitting of this data seen by the caller.
+ * This method makes the assumption that 'this' is already allocated. If not an exception will be thrown.
+ * This method checks that getNbOfElems()%newNbOfCompo==0. If not an exception will be throw !
+ * This method erases all components info set before call !
+ */
+void DataArrayDouble::rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception)
+{
+  checkAllocated();
+  int nbOfElems=getNbOfElems();
+  if(nbOfElems%newNbOfCompo!=0)
+    throw INTERP_KERNEL::Exception("DataArrayDouble::rearrange : nbOfElems%newNbOfCompo!=0 !");
+  _nb_of_tuples=nbOfElems/newNbOfCompo;
+  _info_on_compo.clear();
+  _info_on_compo.resize(newNbOfCompo);
+  declareAsNew();
+}
+
 DataArrayDouble *DataArrayDouble::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
 {
   checkAllocated();
@@ -479,6 +521,37 @@ DataArrayDouble *DataArrayDouble::keepSelectedComponents(const std::vector<int>&
   return ret;
 }
 
+/*!
+ * This method melds the components of 'this' with components of 'other'.
+ * After this call in case of success, 'this' will contain a number of components equal to the sum of 'this'
+ * before the call and the number of components of 'other'.
+ * This method expects that 'this' and 'other' have exactly the same number of tuples. If not an exception is thrown.
+ */
+void DataArrayDouble::meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception)
+{
+  checkAllocated();
+  other->checkAllocated();
+  int nbOfTuples=getNumberOfTuples();
+  if(nbOfTuples!=other->getNumberOfTuples())
+    throw INTERP_KERNEL::Exception("DataArrayDouble::meldWith : mismatch of number of tuples !");
+  int nbOfComp1=getNumberOfComponents();
+  int nbOfComp2=other->getNumberOfComponents();
+  double *newArr=new double[nbOfTuples*(nbOfComp1+nbOfComp2)];
+  double *w=newArr;
+  const double *inp1=getConstPointer();
+  const double *inp2=other->getConstPointer();
+  for(int i=0;i<nbOfTuples;i++,inp1+=nbOfComp1,inp2+=nbOfComp2)
+    {
+      w=std::copy(inp1,inp1+nbOfComp1,w);
+      w=std::copy(inp2,inp2+nbOfComp2,w);
+    }
+  useArray(newArr,true,CPP_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
+  std::vector<int> compIds(nbOfComp2);
+  for(int i=0;i<nbOfComp2;i++)
+    compIds[i]=nbOfComp1+i;
+  copyPartOfStringInfoFrom2(compIds,*other);
+}
+
 void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception)
 {
   copyPartOfStringInfoFrom2(compoIds,*a);
@@ -1035,16 +1108,74 @@ DataArrayInt *DataArrayDouble::getIdsInRange(double vmin, double vmax) const thr
 
 DataArrayDouble *DataArrayDouble::aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
 {
-  int nbOfComp=a1->getNumberOfComponents();
-  if(nbOfComp!=a2->getNumberOfComponents())
-    throw INTERP_KERNEL::Exception("Nb of components mismatch for array aggregation !");
-  int nbOfTuple1=a1->getNumberOfTuples();
-  int nbOfTuple2=a2->getNumberOfTuples();
+  std::vector<const DataArrayDouble *> tmp(2);
+  tmp[0]=a1; tmp[1]=a2;
+  return aggregate(tmp);
+}
+
+DataArrayDouble *DataArrayDouble::aggregate(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception)
+{
+  if(a.empty())
+    throw INTERP_KERNEL::Exception("DataArrayDouble::aggregate : input list must be NON EMPTY !");
+  std::vector<const DataArrayDouble *>::const_iterator it=a.begin();
+  int nbOfComp=(*it)->getNumberOfComponents();
+  int nbt=(*it++)->getNumberOfTuples();
+  for(int i=1;it!=a.end();it++,i++)
+    {
+      if((*it)->getNumberOfComponents()!=nbOfComp)
+        throw INTERP_KERNEL::Exception("DataArrayDouble::aggregate : Nb of components mismatch for array aggregation !");
+      nbt+=(*it)->getNumberOfTuples();
+    }
   DataArrayDouble *ret=DataArrayDouble::New();
-  ret->alloc(nbOfTuple1+nbOfTuple2,nbOfComp);
-  double *pt=std::copy(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple1*nbOfComp,ret->getPointer());
-  std::copy(a2->getConstPointer(),a2->getConstPointer()+nbOfTuple2*nbOfComp,pt);
-  ret->copyStringInfoFrom(*a1);
+  ret->alloc(nbt,nbOfComp);
+  double *pt=ret->getPointer();
+  for(it=a.begin();it!=a.end();it++)
+    pt=std::copy((*it)->getConstPointer(),(*it)->getConstPointer()+(*it)->getNbOfElems(),pt);
+  ret->copyStringInfoFrom(*(a[0]));
+  return ret;
+}
+
+DataArrayDouble *DataArrayDouble::meld(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+{
+  std::vector<const DataArrayDouble *> arr(2);
+  arr[0]=a1; arr[1]=a2;
+  return meld(arr);
+}
+
+DataArrayDouble *DataArrayDouble::meld(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception)
+{
+  if(a.empty())
+    throw INTERP_KERNEL::Exception("DataArrayDouble::meld : array must be NON empty !");
+  std::vector<const DataArrayDouble *>::const_iterator it;
+  for(it=a.begin();it!=a.end();it++)
+    (*it)->checkAllocated();
+  it=a.begin();
+  int nbOfTuples=(*it)->getNumberOfTuples();
+  std::vector<int> nbc(a.size());
+  std::vector<const double *> pts(a.size());
+  nbc[0]=(*it)->getNumberOfComponents();
+  pts[0]=(*it++)->getConstPointer();
+  for(int i=1;it!=a.end();it++,i++)
+    {
+      if(nbOfTuples!=(*it)->getNumberOfTuples())
+        throw INTERP_KERNEL::Exception("DataArrayDouble::meld : mismatch of number of tuples !");
+      nbc[i]=(*it)->getNumberOfComponents();
+      pts[i]=(*it)->getConstPointer();
+    }
+  int totalNbOfComp=std::accumulate(nbc.begin(),nbc.end(),0);
+  DataArrayDouble *ret=DataArrayDouble::New();
+  ret->alloc(nbOfTuples,totalNbOfComp);
+  double *retPtr=ret->getPointer();
+  for(int i=0;i<nbOfTuples;i++)
+    for(int j=0;j<(int)a.size();j++)
+      {
+        retPtr=std::copy(pts[j],pts[j]+nbc[j],retPtr);
+        pts[j]+=nbc[j];
+      }
+  int k=0;
+  for(int i=0;i<(int)a.size();i++)
+    for(int j=0;j<nbc[i];j++,k++)
+      ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j).c_str());
   return ret;
 }
 
@@ -1270,28 +1401,63 @@ void DataArrayDouble::multiplyEqual(const DataArrayDouble *other) throw(INTERP_K
 
 DataArrayDouble *DataArrayDouble::divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
 {
-  int nbOfComp=a1->getNumberOfComponents();
-  if(nbOfComp!=a2->getNumberOfComponents())
-    throw INTERP_KERNEL::Exception("Nb of components mismatch for array divide !");
   int nbOfTuple=a1->getNumberOfTuples();
-  if(nbOfTuple!=a2->getNumberOfTuples())
+  int nbOfTuple2=a2->getNumberOfTuples();
+  int nbOfComp=a1->getNumberOfComponents();
+  int nbOfComp2=a2->getNumberOfComponents();
+  if(nbOfTuple!=nbOfTuple2)
     throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array divide !");
-  DataArrayDouble *ret=DataArrayDouble::New();
-  ret->alloc(nbOfTuple,nbOfComp);
-  std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::divides<double>());
-  ret->copyStringInfoFrom(*a1);
+  DataArrayDouble *ret=0;
+  if(nbOfComp==nbOfComp2)
+    {
+      ret=DataArrayDouble::New();
+      ret->alloc(nbOfTuple,nbOfComp);
+      std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::divides<double>());
+      ret->copyStringInfoFrom(*a1);
+    }
+  else
+    {
+      if(nbOfComp2==1)
+        {
+          ret=DataArrayDouble::New();
+          ret->alloc(nbOfTuple,nbOfComp);
+          const double *a2Ptr=a2->getConstPointer();
+          const double *a1Ptr=a1->getConstPointer();
+          double *res=ret->getPointer();
+          for(int i=0;i<nbOfTuple;i++)
+            res=std::transform(a1Ptr+i*nbOfComp,a1Ptr+(i+1)*nbOfComp,res,std::bind2nd(std::divides<double>(),a2Ptr[i]));
+          ret->copyStringInfoFrom(*a1);
+        }
+      else
+        throw INTERP_KERNEL::Exception("Nb of components mismatch for array divide !");
+    }
   return ret;
 }
 
 void DataArrayDouble::divideEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception)
 {
-  int nbOfComp=getNumberOfComponents();
-  if(nbOfComp!=other->getNumberOfComponents())
-    throw INTERP_KERNEL::Exception("Nb of components mismatch for array divideEqual !");
   int nbOfTuple=getNumberOfTuples();
-  if(nbOfTuple!=other->getNumberOfTuples())
+  int nbOfTuple2=other->getNumberOfTuples();
+  int nbOfComp=getNumberOfComponents();
+  int nbOfComp2=other->getNumberOfComponents();
+  if(nbOfTuple!=nbOfTuple2)
     throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array divideEqual !");
-  std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::divides<double>());
+  if(nbOfComp==nbOfComp2)
+    {
+      std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::divides<double>());
+    }
+  else
+    {
+      if(nbOfComp2==1)
+        {
+          const double *ptr=other->getConstPointer();
+          double *myPtr=getPointer();
+          for(int i=0;i<nbOfTuple;i++)
+            myPtr=std::transform(myPtr,myPtr+nbOfComp,myPtr,std::bind2nd(std::divides<double>(),ptr[i]));
+        }
+      else
+        throw INTERP_KERNEL::Exception("Nb of components mismatch for array divideEqual !");
+    }
   declareAsNew();
 }
 
@@ -1311,15 +1477,15 @@ void DataArrayInt::checkAllocated() const throw(INTERP_KERNEL::Exception)
     throw INTERP_KERNEL::Exception("DataArrayInt::checkAllocated : Array is defined but not allocated ! Call alloc or setValues method first !");
 }
 
-DataArrayInt *DataArrayInt::deepCopy() const
+DataArrayInt *DataArrayInt::deepCpy() const
 {
   return new DataArrayInt(*this);
 }
 
-DataArrayInt *DataArrayInt::performCpy(bool deepCpy) const
+DataArrayInt *DataArrayInt::performCpy(bool dCpy) const
 {
-  if(deepCpy)
-    return deepCopy();
+  if(dCpy)
+    return deepCpy();
   else
     {
       incrRef();
@@ -1579,6 +1745,29 @@ DataArrayInt *DataArrayInt::selectByTupleId(const int *new2OldBg, const int *new
   return ret;
 }
 
+/*!
+ * This method is equivalent to DataArrayInt::selectByTupleId except that an analyze to the content of input range to check that it will not lead to memory corruption !
+ */
+DataArrayInt *DataArrayInt::selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception)
+{
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+  int nbComp=getNumberOfComponents();
+  int oldNbOfTuples=getNumberOfTuples();
+  ret->alloc(std::distance(new2OldBg,new2OldEnd),nbComp);
+  ret->copyStringInfoFrom(*this);
+  int *pt=ret->getPointer();
+  const int *srcPt=getConstPointer();
+  int i=0;
+  for(const int *w=new2OldBg;w!=new2OldEnd;w++,i++)
+    if(*w>=0 && *w<oldNbOfTuples)
+      std::copy(srcPt+(*w)*nbComp,srcPt+((*w)+1)*nbComp,pt+i*nbComp);
+    else
+      throw INTERP_KERNEL::Exception("DataArrayInt::selectByTupleIdSafe : some ids has been detected to be out of [0,this->getNumberOfTuples) !");
+  ret->copyStringInfoFrom(*this);
+  ret->incrRef();
+  return ret;
+}
+
 /*!
  * This method checks that 'this' is with numberofcomponents == 1 and that it is equal to
  * stdext::iota() of size getNumberOfTuples. This method is particalary usefull for DataArrayInt instances
@@ -1649,6 +1838,25 @@ DataArrayInt *DataArrayInt::substr(int tupleIdBg, int tupleIdEnd) const throw(IN
   return ret;
 }
 
+/*!
+ * Contrary to DataArrayInt::changeNbOfComponents method this method is \b not const. The content 
+ * This method \b do \b not change the content of data but changes the splitting of this data seen by the caller.
+ * This method makes the assumption that 'this' is already allocated. If not an exception will be thrown.
+ * This method checks that getNbOfElems()%newNbOfCompo==0. If not an exception will be throw !
+ * This method erases all components info set before call !
+ */
+void DataArrayInt::rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception)
+{
+  checkAllocated();
+  int nbOfElems=getNbOfElems();
+  if(nbOfElems%newNbOfCompo!=0)
+    throw INTERP_KERNEL::Exception("DataArrayInt::rearrange : nbOfElems%newNbOfCompo!=0 !");
+  _nb_of_tuples=nbOfElems/newNbOfCompo;
+  _info_on_compo.clear();
+  _info_on_compo.resize(newNbOfCompo);
+  declareAsNew();
+}
+
 /*!
  * This method builds a new instance of DataArrayInt (to deal with) that is reduction or an extension of 'this'.
  * if 'newNbOfComp' < this->getNumberOfComponents() a reduction is done and for each tuple 'newNbOfComp' first components are kept.
@@ -1705,6 +1913,37 @@ DataArrayInt *DataArrayInt::keepSelectedComponents(const std::vector<int>& compo
   return ret;
 }
 
+/*!
+ * This method melds the components of 'this' with components of 'other'.
+ * After this call in case of success, 'this' will contain a number of components equal to the sum of 'this'
+ * before the call and the number of components of 'other'.
+ * This method expects that 'this' and 'other' have exactly the same number of tuples. If not an exception is thrown.
+ */
+void DataArrayInt::meldWith(const DataArrayInt *other) throw(INTERP_KERNEL::Exception)
+{
+  checkAllocated();
+  other->checkAllocated();
+  int nbOfTuples=getNumberOfTuples();
+  if(nbOfTuples!=other->getNumberOfTuples())
+    throw INTERP_KERNEL::Exception("DataArrayInt::meldWith : mismatch of number of tuples !");
+  int nbOfComp1=getNumberOfComponents();
+  int nbOfComp2=other->getNumberOfComponents();
+  int *newArr=new int[nbOfTuples*(nbOfComp1+nbOfComp2)];
+  int *w=newArr;
+  const int *inp1=getConstPointer();
+  const int *inp2=other->getConstPointer();
+  for(int i=0;i<nbOfTuples;i++,inp1+=nbOfComp1,inp2+=nbOfComp2)
+    {
+      w=std::copy(inp1,inp1+nbOfComp1,w);
+      w=std::copy(inp2,inp2+nbOfComp2,w);
+    }
+  useArray(newArr,true,CPP_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
+  std::vector<int> compIds(nbOfComp2);
+  for(int i=0;i<nbOfComp2;i++)
+    compIds[i]=nbOfComp1+i;
+  copyPartOfStringInfoFrom2(compIds,*other);
+}
+
 void DataArrayInt::setSelectedComponents(const DataArrayInt *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception)
 {
   copyPartOfStringInfoFrom2(compoIds,*a);
@@ -1778,6 +2017,76 @@ DataArrayInt *DataArrayInt::aggregate(const DataArrayInt *a1, const DataArrayInt
   return ret;
 }
 
+int DataArrayInt::getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
+{
+  if(getNumberOfComponents()!=1)
+    throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : must be applied on DataArrayDouble with only one component !");
+  int nbOfTuples=getNumberOfTuples();
+  if(nbOfTuples<=0)
+    throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : array exists but number of tuples must be > 0 !");
+  const int *vals=getConstPointer();
+  const int *loc=std::max_element(vals,vals+nbOfTuples);
+  tupleId=std::distance(vals,loc);
+  return *loc;
+}
+
+int DataArrayInt::getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
+{
+  if(getNumberOfComponents()!=1)
+    throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : must be applied on DataArrayDouble with only one component !");
+  int nbOfTuples=getNumberOfTuples();
+  if(nbOfTuples<=0)
+    throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : array exists but number of tuples must be > 0 !");
+  const int *vals=getConstPointer();
+  const int *loc=std::min_element(vals,vals+nbOfTuples);
+  tupleId=std::distance(vals,loc);
+  return *loc;
+}
+
+DataArrayInt *DataArrayInt::meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception)
+{
+  std::vector<const DataArrayInt *> arr(2);
+  arr[0]=a1; arr[1]=a2;
+  return meld(arr);
+}
+
+DataArrayInt *DataArrayInt::meld(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception)
+{
+  if(a.empty())
+    throw INTERP_KERNEL::Exception("DataArrayInt::meld : array must be NON empty !");
+  std::vector<const DataArrayInt *>::const_iterator it;
+  for(it=a.begin();it!=a.end();it++)
+    (*it)->checkAllocated();
+  it=a.begin();
+  int nbOfTuples=(*it)->getNumberOfTuples();
+  std::vector<int> nbc(a.size());
+  std::vector<const int *> pts(a.size());
+  nbc[0]=(*it)->getNumberOfComponents();
+  pts[0]=(*it++)->getConstPointer();
+  for(int i=1;it!=a.end();it++,i++)
+    {
+      if(nbOfTuples!=(*it)->getNumberOfTuples())
+        throw INTERP_KERNEL::Exception("DataArrayInt::meld : mismatch of number of tuples !");
+      nbc[i]=(*it)->getNumberOfComponents();
+      pts[i]=(*it)->getConstPointer();
+    }
+  int totalNbOfComp=std::accumulate(nbc.begin(),nbc.end(),0);
+  DataArrayInt *ret=DataArrayInt::New();
+  ret->alloc(nbOfTuples,totalNbOfComp);
+  int *retPtr=ret->getPointer();
+  for(int i=0;i<nbOfTuples;i++)
+    for(int j=0;j<(int)a.size();j++)
+      {
+        retPtr=std::copy(pts[j],pts[j]+nbc[j],retPtr);
+        pts[j]+=nbc[j];
+      }
+  int k=0;
+  for(int i=0;i<(int)a.size();i++)
+    for(int j=0;j<nbc[i];j++,k++)
+      ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j).c_str());
+  return ret;
+}
+
 /*!
  * This method create a minimal partition of groups 'groups' the std::iota array of size 'newNb'.
  * This method returns an array of size 'newNb' that specifies for each item at which familyId it owns to, and this method returns
@@ -1829,6 +2138,143 @@ DataArrayInt *DataArrayInt::makePartition(const std::vector<DataArrayInt *>& gro
   return ret;
 }
 
+DataArrayInt *DataArrayInt::buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception)
+{
+   checkAllocated();
+   if(getNumberOfComponents()!=1)
+     throw INTERP_KERNEL::Exception("DataArrayInt::buildComplement : only single component allowed !");
+   std::vector<bool> tmp(nbOfElement);
+   const int *pt=getConstPointer();
+   int nbOfTuples=getNumberOfTuples();
+   for(const int *w=pt;w!=pt+nbOfTuples;w++)
+     if(*w>=0 && *w<nbOfElement)
+       tmp[*w]=true;
+     else
+       throw INTERP_KERNEL::Exception("DataArrayInt::buildComplement : an element is not in valid range : [0,nbOfElement) !");
+   int nbOfRetVal=std::count(tmp.begin(),tmp.end(),false);
+   DataArrayInt *ret=DataArrayInt::New();
+   ret->alloc(nbOfRetVal,1);
+   int j=0;
+   int *retPtr=ret->getPointer();
+   for(int i=0;i<nbOfElement;i++)
+     if(!tmp[i])
+       retPtr[j++]=i;
+   return ret;
+}
+
+DataArrayInt *DataArrayInt::buildSubstraction(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
+{
+  checkAllocated();
+  other->checkAllocated();
+  if(getNumberOfComponents()!=1)
+     throw INTERP_KERNEL::Exception("DataArrayInt::buildSubstraction : only single component allowed !");
+  if(other->getNumberOfComponents()!=1)
+     throw INTERP_KERNEL::Exception("DataArrayInt::buildSubstraction : only single component allowed for other type !");
+  const int *pt=getConstPointer();
+  int nbOfTuples=getNumberOfTuples();
+  std::set<int> s1(pt,pt+nbOfTuples);
+  pt=other->getConstPointer();
+  nbOfTuples=other->getNumberOfTuples();
+  std::set<int> s2(pt,pt+nbOfTuples);
+  std::vector<int> r;
+  std::set_difference(s1.begin(),s1.end(),s2.begin(),s2.end(),std::back_insert_iterator< std::vector<int> >(r));
+  DataArrayInt *ret=DataArrayInt::New();
+  ret->alloc(r.size(),1);
+  std::copy(r.begin(),r.end(),ret->getPointer());
+  return ret;
+}
+
+DataArrayInt *DataArrayInt::buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
+{
+  checkAllocated();
+  other->checkAllocated();
+  if(getNumberOfComponents()!=1)
+     throw INTERP_KERNEL::Exception("DataArrayInt::buildUnion : only single component allowed !");
+  if(other->getNumberOfComponents()!=1)
+     throw INTERP_KERNEL::Exception("DataArrayInt::buildUnion : only single component allowed for other type !");
+  int tmp1;
+  int valm=getMinValue(tmp1);
+  valm=std::min(other->getMinValue(tmp1),valm);
+  if(valm<0)
+    throw INTERP_KERNEL::Exception("DataArrayInt::buildUnion : a negative value has been detected !");
+  //
+  const int *pt=getConstPointer();
+  int nbOfTuples=getNumberOfTuples();
+  std::set<int> s1(pt,pt+nbOfTuples);
+  pt=other->getConstPointer();
+  nbOfTuples=other->getNumberOfTuples();
+  std::set<int> s2(pt,pt+nbOfTuples);
+  std::vector<int> r;
+  std::set_union(s1.begin(),s1.end(),s2.begin(),s2.end(),std::back_insert_iterator< std::vector<int> >(r));
+  DataArrayInt *ret=DataArrayInt::New();
+  ret->alloc(r.size(),1);
+  std::copy(r.begin(),r.end(),ret->getPointer());
+  return ret;
+}
+
+DataArrayInt *DataArrayInt::buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
+{
+  checkAllocated();
+  other->checkAllocated();
+  if(getNumberOfComponents()!=1)
+     throw INTERP_KERNEL::Exception("DataArrayInt::buildIntersection : only single component allowed !");
+  if(other->getNumberOfComponents()!=1)
+     throw INTERP_KERNEL::Exception("DataArrayInt::buildIntersection : only single component allowed for other type !");
+  int tmp1;
+  int valm=getMinValue(tmp1);
+  valm=std::min(other->getMinValue(tmp1),valm);
+  if(valm<0)
+    throw INTERP_KERNEL::Exception("DataArrayInt::buildIntersection : a negative value has been detected !");
+  //
+  const int *pt=getConstPointer();
+  int nbOfTuples=getNumberOfTuples();
+  std::set<int> s1(pt,pt+nbOfTuples);
+  pt=other->getConstPointer();
+  nbOfTuples=other->getNumberOfTuples();
+  std::set<int> s2(pt,pt+nbOfTuples);
+  std::vector<int> r;
+  std::set_intersection(s1.begin(),s1.end(),s2.begin(),s2.end(),std::back_insert_iterator< std::vector<int> >(r));
+  DataArrayInt *ret=DataArrayInt::New();
+  ret->alloc(r.size(),1);
+  std::copy(r.begin(),r.end(),ret->getPointer());
+  return ret;
+}
+
+/*!
+ * This method could be usefull for returned DataArrayInt marked as index. Some methods that generate such DataArrayInt instances:
+ * - ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity
+ * - ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivityIndex
+ * This method makes the assumption that 'this' is allocated and has exactly one component and 2 or more tuples. If not an exception is thrown.
+ * This method retrives a newly created DataArrayInt instance with 1 component and this->getNumberOfTuples()-1 tuples.
+ * If this contains [1,3,6,7,7,9,15] -> returned array will contain [2,3,1,0,2,6].
+ */
+DataArrayInt *DataArrayInt::deltaShiftIndex() const throw(INTERP_KERNEL::Exception)
+{
+  checkAllocated();
+  if(getNumberOfComponents()!=1)
+     throw INTERP_KERNEL::Exception("DataArrayInt::deltaShiftIndex : only single component allowed !");
+  int nbOfTuples=getNumberOfTuples();
+  if(nbOfTuples<2)
+    throw INTERP_KERNEL::Exception("DataArrayInt::deltaShiftIndex : 1 tuple at least must be present in 'this' !");
+  const int *ptr=getPointer();
+  DataArrayInt *ret=DataArrayInt::New();
+  ret->alloc(nbOfTuples-1,1);
+  int *out=ret->getPointer();
+  std::transform(ptr+1,ptr+nbOfTuples,ptr,out,std::minus<int>());
+  return ret;
+}
+
+/*!
+ * This method returns all different values found in 'this'.
+ */
+std::set<int> DataArrayInt::getDifferentValues() const throw(INTERP_KERNEL::Exception)
+{
+  checkAllocated();
+  std::set<int> ret;
+  ret.insert(getConstPointer(),getConstPointer()+getNbOfElems());
+  return ret;
+}
+
 int *DataArrayInt::checkAndPreparePermutation(const int *start, const int *end)
 {
   int sz=std::distance(start,end);
index 57d7d8a0a26154d791f07c855744513ee0f8d4e2..c3259e03b6e2b4af63118a74eb84018440ef95f6 100644 (file)
@@ -25,6 +25,7 @@
 #include "MEDCouplingRefCountObject.hxx"
 #include "InterpKernelException.hxx"
 
+#include <set>
 #include <string>
 #include <vector>
 #include <iterator>
@@ -118,7 +119,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT static DataArrayDouble *New();
     MEDCOUPLING_EXPORT bool isAllocated() const;
     MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception);
-    MEDCOUPLING_EXPORT DataArrayDouble *deepCopy() const;
+    MEDCOUPLING_EXPORT DataArrayDouble *deepCpy() const;
     MEDCOUPLING_EXPORT DataArrayDouble *performCpy(bool deepCpy) const;
     MEDCOUPLING_EXPORT void alloc(int nbOfTuple, int nbOfCompo);
     MEDCOUPLING_EXPORT void fillWithZero() throw(INTERP_KERNEL::Exception);
@@ -144,13 +145,17 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT DataArrayDouble *renumberR(const int *new2Old) const;
     MEDCOUPLING_EXPORT DataArrayDouble *renumberAndReduce(const int *old2New, int newNbOfTuple) const;
     MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const;
+    MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayDouble *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayDouble *changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT void meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void getTuple(int tupleId, double *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
     MEDCOUPLING_EXPORT double getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
     MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); }
+    MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
     MEDCOUPLING_EXPORT double *getPointer() const { return _mem.getPointer(); }
     MEDCOUPLING_EXPORT static void setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet);
     MEDCOUPLING_EXPORT const double *getConstPointer() const { return _mem.getConstPointer(); }
@@ -185,6 +190,9 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT static DataArrayDouble *aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT static DataArrayDouble *aggregate(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT static DataArrayDouble *meld(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT static DataArrayDouble *meld(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT static DataArrayDouble *dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT static DataArrayDouble *crossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT static DataArrayDouble *max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
@@ -211,7 +219,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT static DataArrayInt *New();
     MEDCOUPLING_EXPORT bool isAllocated() const;
     MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception);
-    MEDCOUPLING_EXPORT DataArrayInt *deepCopy() const;
+    MEDCOUPLING_EXPORT DataArrayInt *deepCpy() const;
     MEDCOUPLING_EXPORT DataArrayInt *performCpy(bool deepCpy) const;
     MEDCOUPLING_EXPORT void alloc(int nbOfTuple, int nbOfCompo);
     MEDCOUPLING_EXPORT bool isEqual(const DataArrayInt& other) const;
@@ -239,22 +247,36 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT DataArrayInt *renumberR(const int *new2Old) const;
     MEDCOUPLING_EXPORT DataArrayInt *renumberAndReduce(const int *old2NewBg, int newNbOfTuple) const;
     MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const;
+    MEDCOUPLING_EXPORT DataArrayInt *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT bool isIdentity() const;
     MEDCOUPLING_EXPORT bool isUniform(int val) const;
     MEDCOUPLING_EXPORT DataArrayInt *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayInt *changeNbOfComponents(int newNbOfComp, int dftValue) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayInt *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT void meldWith(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayInt *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void getTuple(int tupleId, int *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
     MEDCOUPLING_EXPORT int getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
-    MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
+    MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); }
+    MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
     MEDCOUPLING_EXPORT int *getPointer() const { return _mem.getPointer(); }
     MEDCOUPLING_EXPORT static void setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet);
     MEDCOUPLING_EXPORT const int *getConstPointer() const { return _mem.getConstPointer(); }
     MEDCOUPLING_EXPORT DataArrayInt *getIdsEqual(int val) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayInt *getIdsEqualList(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT int getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT int getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT static DataArrayInt *aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2);
+    MEDCOUPLING_EXPORT static DataArrayInt *meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT static DataArrayInt *meld(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT static DataArrayInt *makePartition(const std::vector<DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups);
+    MEDCOUPLING_EXPORT DataArrayInt *buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT DataArrayInt *buildSubstraction(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT DataArrayInt *buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT DataArrayInt *buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT DataArrayInt *deltaShiftIndex() const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT std::set<int> getDifferentValues() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
     MEDCOUPLING_EXPORT void writeOnPlace(int id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
     //! nothing to do here because this class does not aggregate any TimeLabel instance.
index 75ed3f30927e46264b30d70f77b2bdf8776c661d..d5b8286764fd127ec3b068a19c4ed59f83bea609 100644 (file)
@@ -40,6 +40,7 @@ namespace ParaMEDMEM
 
   class DataArrayInt;
   class DataArrayDouble;
+  class MEDCouplingUMesh;
   class MEDCouplingFieldDouble;
 
   class MEDCOUPLING_EXPORT MEDCouplingMesh : public RefCountObject, public TimeLabel
@@ -91,6 +92,7 @@ namespace ParaMEDMEM
     virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const = 0;
     virtual MEDCouplingMesh *buildPart(const int *start, const int *end) const = 0;
     virtual MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const = 0;
+    virtual MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception) = 0;
     virtual DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception) = 0;
     virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const;
     static MEDCouplingMesh *mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2);
index e587b297892922b0055e8192947ba52c141c6915..d4812d83a36a31c1bbd707d70cfbd4b8a24c58b1 100644 (file)
@@ -326,6 +326,38 @@ void MEDCouplingPointSet::renumberNodes(const int *newNodeNumbers, int newNbOfNo
   newCoords->decrRef();
 }
 
+/*
+ * This method renumber 'this' using 'newNodeNumbers' array of size this->getNumberOfNodes.
+ * newNbOfNodes specifies the *std::max_element(newNodeNumbers,newNodeNumbers+this->getNumberOfNodes())
+ * This value is asked because often known by the caller of this method.
+ * Contrary to ParaMEDMEM::MEDCouplingPointSet::renumberNodes method for merged nodes the barycenter of them is computed here.
+ *
+ * @param newNodeNumbers array specifying the new numbering.
+ * @param newNbOfNodes the new number of nodes.
+ */
+void MEDCouplingPointSet::renumberNodes2(const int *newNodeNumbers, int newNbOfNodes)
+{
+  DataArrayDouble *newCoords=DataArrayDouble::New();
+  std::vector<int> div(newNbOfNodes);
+  int spaceDim=getSpaceDimension();
+  newCoords->alloc(newNbOfNodes,spaceDim);
+  newCoords->copyStringInfoFrom(*_coords);
+  newCoords->fillWithZero();
+  int oldNbOfNodes=getNumberOfNodes();
+  double *ptToFill=newCoords->getPointer();
+  const double *oldCoordsPtr=_coords->getConstPointer();
+  for(int i=0;i<oldNbOfNodes;i++)
+    {
+      std::transform(oldCoordsPtr+i*spaceDim,oldCoordsPtr+(i+1)*spaceDim,ptToFill+newNodeNumbers[i]*spaceDim,
+                     ptToFill+newNodeNumbers[i]*spaceDim,std::plus<double>());
+      div[newNodeNumbers[i]]++;
+    }
+  for(int i=0;i<newNbOfNodes;i++)
+    ptToFill=std::transform(ptToFill,ptToFill+spaceDim,ptToFill,std::bind2nd(std::multiplies<double>(),1./(double)div[i]));
+  setCoords(newCoords);
+  newCoords->decrRef();
+}
+
 /*!
  * This method fills bbox params like that : bbox[0]=XMin, bbox[1]=XMax, bbox[2]=YMin...
  * The returned bounding box is arranged along trihedron.
@@ -513,7 +545,7 @@ void MEDCouplingPointSet::findNodesOnPlane(const double *pt, const double *vec,
 /*!
  * merge _coords arrays of m1 and m2 and returns the union. The returned instance is newly created with ref count == 1.
  */
-DataArrayDouble *MEDCouplingPointSet::mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2)
+DataArrayDouble *MEDCouplingPointSet::mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception)
 {
   int spaceDim=m1->getSpaceDimension();
   if(spaceDim!=m2->getSpaceDimension())
@@ -521,6 +553,30 @@ DataArrayDouble *MEDCouplingPointSet::mergeNodesArray(const MEDCouplingPointSet
   return DataArrayDouble::aggregate(m1->getCoords(),m2->getCoords());
 }
 
+DataArrayDouble *MEDCouplingPointSet::mergeNodesArray(const std::vector<const MEDCouplingPointSet *>& ms) throw(INTERP_KERNEL::Exception)
+{
+  if(ms.empty())
+    throw INTERP_KERNEL::Exception("MEDCouplingPointSet::mergeNodesArray : input array must be NON EMPTY !");
+  std::vector<const MEDCouplingPointSet *>::const_iterator it=ms.begin();
+  std::vector<const DataArrayDouble *> coo(ms.size());
+  int spaceDim=(*it)->getSpaceDimension();
+  coo[0]=(*it++)->getCoords();
+  for(int i=1;it!=ms.end();it++,i++)
+    {
+      const DataArrayDouble *tmp=(*it)->getCoords();
+      if(tmp)
+        {
+          if((*it)->getSpaceDimension()==spaceDim)
+            coo[i]=tmp;
+          else
+            throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of mergeNodesArray !");
+        }
+      else
+        throw INTERP_KERNEL::Exception("Empty coords detected during call of mergeNodesArray !");
+    }
+  return DataArrayDouble::aggregate(coo);
+}
+
 /*!
  * Factory to build new instance of instanciable subclasses of MEDCouplingPointSet.
  * This method is used during unserialization process.
index 21cb749b4b2c70c151222a364dc0cba207ccda7b..4a51adf5bb35bc9adccb6b15a2fa07e9c3cf43be 100644 (file)
@@ -54,6 +54,7 @@ namespace ParaMEDMEM
     bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const;
     bool areCoordsEqualWithoutConsideringStr(const MEDCouplingPointSet& other, double prec) const;
     virtual DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes) = 0;
+    virtual DataArrayInt *mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes) = 0;
     DataArrayInt *buildPermArrayForMergeNode(int limitNodeId, double precision, bool& areNodesMerged, int& newNbOfNodes) const;
     std::vector<int> getNodeIdsNearPoint(const double *pos, double eps) const throw(INTERP_KERNEL::Exception);
     void getNodeIdsNearPoints(const double *pos, int nbOfNodes, double eps, std::vector<int>& c, std::vector<int>& cI) const throw(INTERP_KERNEL::Exception);
@@ -70,7 +71,8 @@ namespace ParaMEDMEM
     void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
     virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0;
     void findNodesOnPlane(const double *pt, const double *vec, double eps, std::vector<int>& nodes) const throw(INTERP_KERNEL::Exception);
-    static DataArrayDouble *mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2);
+    static DataArrayDouble *mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception);
+    static DataArrayDouble *mergeNodesArray(const std::vector<const MEDCouplingPointSet *>& ms) throw(INTERP_KERNEL::Exception);
     static MEDCouplingPointSet *buildInstanceFromMeshType(MEDCouplingMeshType type);
     static void rotate2DAlg(const double *center, double angle, int nbNodes, double *coords);
     static void rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords);
@@ -82,6 +84,7 @@ namespace ParaMEDMEM
     virtual void findBoundaryNodes(std::vector<int>& nodes) const = 0;
     virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const = 0;
     virtual void renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
+    virtual void renumberNodes2(const int *newNodeNumbers, int newNbOfNodes);
     virtual bool isEmptyMesh(const std::vector<int>& tinyInfo) const = 0;
     //! size of returned tinyInfo must be always the same.
     void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
index a150a9cd4e15c2585651a1bc16986efa76c3fccf..8757e8c1092291a5bf95e84dec851c9483716cb1 100644 (file)
@@ -115,6 +115,19 @@ bool MEDCouplingTimeDiscretization::areStrictlyCompatible(const MEDCouplingTimeD
   return true;
 }
 
+bool MEDCouplingTimeDiscretization::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+{
+  if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
+    return false;
+  if(_array==0 && other->_array==0)
+    return true;
+  if(_array==0 || other->_array==0)
+    return false;
+  if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples())
+    return false;
+  return true;
+}
+
 bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
 {
   if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
@@ -131,6 +144,21 @@ bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(const MEDCouplin
   return true;
 }
 
+bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+{
+  if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
+    return false;
+  if(_array==0 && other->_array==0)
+    return true;
+  if(_array==0 || other->_array==0)
+    return false;
+  int nbC1=_array->getNumberOfComponents();
+  int nbC2=other->_array->getNumberOfComponents();
+  if(nbC1!=nbC2 && nbC2!=1)
+    return false;
+  return true;
+}
+
 bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
 {
   if(!areStrictlyCompatible(other))
@@ -708,6 +736,22 @@ bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDi
   return otherC!=0;
 }
 
+bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+{
+  if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
+    return false;
+  const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+  return otherC!=0;
+}
+
+bool MEDCouplingNoTimeLabel::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+{
+  if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
+    return false;
+  const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+  return otherC!=0;
+}
+
 bool MEDCouplingNoTimeLabel::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
 {
   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
@@ -731,6 +775,36 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCoupli
     throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !");
   DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray());
   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
+  ret->setArray(arr,0);
+  arr->decrRef();
+  return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
+{
+  std::vector<const DataArrayDouble *> a(other.size());
+  int i=0;
+  for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
+    {
+      const MEDCouplingNoTimeLabel *itC=dynamic_cast<const MEDCouplingNoTimeLabel *>(*it);
+      if(!itC)
+        throw INTERP_KERNEL::Exception("NoTimeLabel::aggregate on mismatched time discretization !");
+      a[i]=itC->getArray();
+    }
+  DataArrayDouble *arr=DataArrayDouble::aggregate(a);
+  MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
+  ret->setArray(arr,0);
+  arr->decrRef();
+  return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::meld(const MEDCouplingTimeDiscretization *other) const
+{
+  const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+  if(!otherC)
+    throw INTERP_KERNEL::Exception("NoTimeLabel::meld on mismatched time discretization !");
+  DataArrayDouble *arr=DataArrayDouble::meld(getArray(),other->getArray());
+  MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
   ret->setTimeTolerance(getTimeTolerance());
   ret->setArray(arr,0);
   arr->decrRef();
@@ -986,6 +1060,22 @@ bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeD
   return otherC!=0;
 }
 
+bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+{
+  if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
+    return false;
+  const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
+  return otherC!=0;
+}
+
+bool MEDCouplingWithTimeStep::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+{
+  if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
+    return false;
+  const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
+  return otherC!=0;
+}
+
 bool MEDCouplingWithTimeStep::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
 {
   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
@@ -1030,12 +1120,38 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCoupl
     throw INTERP_KERNEL::Exception("WithTimeStep::aggregation on mismatched time discretization !");
   DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray());
   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
-  ret->setTimeTolerance(getTimeTolerance());
   ret->setArray(arr,0);
   arr->decrRef();
-  int tmp1,tmp2;
-  double tmp3=getStartTime(tmp1,tmp2);
-  ret->setStartTime(tmp3,tmp1,tmp2);
+  return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
+{
+  std::vector<const DataArrayDouble *> a(other.size());
+  int i=0;
+  for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
+    {
+      const MEDCouplingWithTimeStep *itC=dynamic_cast<const MEDCouplingWithTimeStep *>(*it);
+      if(!itC)
+        throw INTERP_KERNEL::Exception("WithTimeStep::aggregate on mismatched time discretization !");
+      a[i]=itC->getArray();
+    }
+  DataArrayDouble *arr=DataArrayDouble::aggregate(a);
+  MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
+  ret->setArray(arr,0);
+  arr->decrRef();
+  return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::meld(const MEDCouplingTimeDiscretization *other) const
+{
+  const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
+  if(!otherC)
+    throw INTERP_KERNEL::Exception("WithTimeStep::meld on mismatched time discretization !");
+  DataArrayDouble *arr=DataArrayDouble::meld(getArray(),other->getArray());
+  MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
+  ret->setArray(arr,0);
+  arr->decrRef();
   return ret;
 }
 
@@ -1335,7 +1451,23 @@ bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTime
 
 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
 {
-  if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other))
+  if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
+    return false;
+  const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+  return otherC!=0;
+}
+
+bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+{
+  if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
+    return false;
+  const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+  return otherC!=0;
+}
+
+bool MEDCouplingConstOnTimeInterval::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+{
+  if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
     return false;
   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
   return otherC!=0;
@@ -1421,19 +1553,44 @@ void MEDCouplingConstOnTimeInterval::checkTimePresence(double time) const throw(
 
 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const
 {
-   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+  const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
   if(!otherC)
     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregation on mismatched time discretization !");
   DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray());
   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
+  ret->setArray(arr,0);
+  arr->decrRef();
+  return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
+{
+  std::vector<const DataArrayDouble *> a(other.size());
+  int i=0;
+  for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
+    {
+      const MEDCouplingConstOnTimeInterval *itC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(*it);
+      if(!itC)
+        throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregate on mismatched time discretization !");
+      a[i]=itC->getArray();
+    }
+  DataArrayDouble *arr=DataArrayDouble::aggregate(a);
+  MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
+  ret->setArray(arr,0);
+  arr->decrRef();
+  return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::meld(const MEDCouplingTimeDiscretization *other) const
+{
+  const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+  if(!otherC)
+    throw INTERP_KERNEL::Exception("ConstOnTimeInterval::meld on mismatched time discretization !");
+  DataArrayDouble *arr=DataArrayDouble::meld(getArray(),other->getArray());
+  MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
   ret->setTimeTolerance(getTimeTolerance());
   ret->setArray(arr,0);
   arr->decrRef();
-  int tmp1,tmp2;
-  double tmp3=getStartTime(tmp1,tmp2);
-  ret->setStartTime(tmp3,tmp1,tmp2);
-  tmp3=getEndTime(tmp1,tmp2);
-  ret->setEndTime(tmp3,tmp1,tmp2);
   return ret;
 }
 
@@ -1859,7 +2016,15 @@ bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretization *o
   if(!MEDCouplingTimeDiscretization::areCompatible(other))
     return false;
   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
-  return otherC!=0;
+  if(otherC==0)
+    return false;
+  if(_end_array==0 && otherC->_end_array==0)
+    return true;
+  if(_end_array==0 || otherC->_end_array==0)
+    return false;
+  if(_end_array->getNumberOfComponents()!=otherC->_end_array->getNumberOfComponents())
+    return false;
+  return true;
 }
 
 bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const
@@ -1878,6 +2043,32 @@ bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDis
   return otherC!=0;
 }
 
+bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+{
+  if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
+    return false;
+  const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
+  if(otherC==0)
+    return false;
+  if(_end_array==0 && otherC->_end_array==0)
+    return true;
+  if(_end_array==0 || otherC->_end_array==0)
+    return false;
+  int nbC1=_end_array->getNumberOfComponents();
+  int nbC2=otherC->_end_array->getNumberOfComponents();
+  if(nbC1!=nbC2 && nbC2!=1)
+    return false;
+  return true;
+}
+
+bool MEDCouplingLinearTime::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+{
+  if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
+    return false;
+  const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
+  return otherC!=0;
+}
+
 /*!
  * vals is expected to be of size 2*_array->getNumberOfTuples()==_array->getNumberOfTuples()+_end_array->getNumberOfTuples()
  */
@@ -1938,6 +2129,44 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const MEDCouplin
   DataArrayDouble *arr1=DataArrayDouble::aggregate(getArray(),other->getArray());
   DataArrayDouble *arr2=DataArrayDouble::aggregate(getEndArray(),other->getEndArray());
   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+  ret->setArray(arr1,0);
+  arr1->decrRef();
+  ret->setEndArray(arr2,0);
+  arr2->decrRef();
+  return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
+{
+  std::vector<const DataArrayDouble *> a(other.size());
+  std::vector<const DataArrayDouble *> b(other.size());
+  int i=0;
+  for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
+    {
+      const MEDCouplingLinearTime *itC=dynamic_cast<const MEDCouplingLinearTime *>(*it);
+      if(!itC)
+        throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::aggregate on mismatched time discretization !");
+      a[i]=itC->getArray();
+      b[i]=itC->getEndArray();
+    }
+  DataArrayDouble *arr=DataArrayDouble::aggregate(a);
+  DataArrayDouble *arr2=DataArrayDouble::aggregate(b);
+  MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+  ret->setArray(arr,0);
+  arr->decrRef();
+  ret->setEndArray(arr2,0);
+  arr2->decrRef();
+  return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::meld(const MEDCouplingTimeDiscretization *other) const
+{
+  const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
+  if(!otherC)
+    throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !");
+  DataArrayDouble *arr1=DataArrayDouble::meld(getArray(),other->getArray());
+  DataArrayDouble *arr2=DataArrayDouble::meld(getEndArray(),other->getEndArray());
+  MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
   ret->setTimeTolerance(getTimeTolerance());
   ret->setArray(arr1,0);
   arr1->decrRef();
index e826e12ced90714acd1fe1f42f579d4ce4080243..88b020eb1db2b8fb047c1a8e34ac5e36d752321d 100644 (file)
@@ -46,6 +46,8 @@ namespace ParaMEDMEM
     virtual bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
     virtual bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const;
     virtual bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
+    virtual bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
+    virtual bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
     virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
     virtual bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
     virtual MEDCouplingTimeDiscretization *buildNewTimeReprFromThis(const MEDCouplingTimeDiscretization *other,
@@ -53,6 +55,8 @@ namespace ParaMEDMEM
     virtual std::string getStringRepr() const = 0;
     virtual TypeOfTimeDiscretization getEnum() const = 0;
     virtual MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const = 0;
+    virtual MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const = 0;
+    virtual MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const = 0;
     virtual MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const = 0;
     virtual MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const = 0;
     virtual MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const = 0;
@@ -133,6 +137,8 @@ namespace ParaMEDMEM
     std::string getStringRepr() const;
     TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
     MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
+    MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
+    MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
     MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
     MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
     MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
@@ -150,6 +156,8 @@ namespace ParaMEDMEM
     bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
     bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const;
     bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
+    bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
+    bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
     MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
     void checkNoTimePresence() const throw(INTERP_KERNEL::Exception) { }
     void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
@@ -180,6 +188,8 @@ namespace ParaMEDMEM
     void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other);
     TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
     MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
+    MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
+    MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
     MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
     MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
     MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
@@ -197,6 +207,8 @@ namespace ParaMEDMEM
     bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
     bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const;
     bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
+    bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
+    bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
     void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
     void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
     void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
@@ -236,6 +248,8 @@ namespace ParaMEDMEM
     bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
     bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const;
     bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
+    bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
+    bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
     bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
     bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
     std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
@@ -245,6 +259,8 @@ namespace ParaMEDMEM
     TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
     std::string getStringRepr() const;
     MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
+    MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
+    MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
     MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
     MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
     MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
@@ -331,10 +347,14 @@ namespace ParaMEDMEM
     bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
     bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const;
     bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
+    bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
+    bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
     void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
     void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
     void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception);
     MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
+    MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
+    MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
     MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
     MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
     MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
index 2fb724a8db49575e0e7df044268363889431164c..02a5a58716e580f5bcf6e3c35fea1f0b79f1e452 100644 (file)
@@ -154,14 +154,25 @@ void MEDCouplingUMesh::allocateCells(int nbOfCells)
  * @param size number of nodes constituting this cell.
  * @param nodalConnOfCell the connectivity of the cell to add.
  */
-void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell)
+void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell) throw(INTERP_KERNEL::Exception)
 {
-  int *pt=_nodal_connec_index->getPointer();
-  int idx=pt[_iterator];
-
-  _nodal_connec->writeOnPlace(idx,type,nodalConnOfCell,size);
-  _types.insert(type);
-  pt[++_iterator]=idx+size+1;
+  const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type);
+  if((int)cm.getDimension()==_mesh_dim)
+    {
+      int *pt=_nodal_connec_index->getPointer();
+      int idx=pt[_iterator];
+      
+      _nodal_connec->writeOnPlace(idx,type,nodalConnOfCell,size);
+      _types.insert(type);
+      pt[++_iterator]=idx+size+1;
+    }
+  else
+    {
+      std::ostringstream oss; oss << "MEDCouplingUMesh::insertNextCell : cell type " << cm.getRepr() << " has a dimension " << cm.getDimension();
+      oss << " whereas Mesh Dimension of current UMesh instance is set to " << _mesh_dim << " ! Please invoke \"setMeshDimension\" method before or invoke ";
+      oss << "\"MEDCouplingUMesh::New\" static method with 2 parameters name and meshDimension !";
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
 }
 
 /*!
@@ -358,7 +369,7 @@ void MEDCouplingUMesh::checkFastEquivalWith(const MEDCouplingMesh *other, double
  * \b WARNING this method do the assumption that connectivity lies on the coordinates set.
  * For speed reasons no check of this will be done.
  */
-void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const
+void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const throw(INTERP_KERNEL::Exception)
 {
   checkFullyDefined();
   int nbOfNodes=getNumberOfNodes();
@@ -398,7 +409,7 @@ void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataA
  * \b WARNING this method do the assumption that connectivity lies on the coordinates set.
  * For speed reasons no check of this will be done.
  */
-MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const
+MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception)
 {
   checkFullyDefined();
   int nbOfCells=getNumberOfCells();
@@ -624,7 +635,7 @@ void MEDCouplingUMesh::unPolyze()
  * The size of returned array is the number of nodes of the old (previous to the call of this method) number of nodes.
  * -1 values in returned array means that the corresponding old node is no more used.
  */
-DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer()
+DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer() throw(INTERP_KERNEL::Exception)
 {
   int nbOfNodes=getNumberOfNodes();
   DataArrayInt *ret=DataArrayInt::New();
@@ -827,7 +838,7 @@ void MEDCouplingUMesh::findCommonCellsBase(int compType, std::vector<int>& res,
  *                 2 : nodal. cell1 and cell2 are equal if and only if cell1 and cell2 have same type and have the same nodes constituting connectivity. This is the laziest policy.
  * @return the correspondance array old to new.
  */
-DataArrayInt *MEDCouplingUMesh::zipConnectivityTraducer(int compType)
+DataArrayInt *MEDCouplingUMesh::zipConnectivityTraducer(int compType) throw(INTERP_KERNEL::Exception)
 {
   int spaceDim=getSpaceDimension();
   int nbOfCells=getNumberOfCells();
@@ -895,6 +906,25 @@ DataArrayInt *MEDCouplingUMesh::zipConnectivityTraducer(int compType)
   return ret;
 }
 
+/*!
+ * This method makes the assumption that 'this' and 'other' share the same coords. If not an exception will be thrown !
+ * This method tries to determine if 'other' is fully included in 'this'. To compute that, this method works with connectivity as MEDCouplingUMesh::zipConnectivityTraducer method does. 
+ * This method has two outputs :
+ *
+ * @param compType is the comparison type. The possible values of this parameter are described in ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer method
+ * @param arr is an output parameter that returns a \b newly created instance. This array is of size 'other->getNumberOfCells()'.
+ * @return If 'other' is fully included in 'this 'true is returned. If not false is returned.
+ */
+bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayInt *& arr) const throw(INTERP_KERNEL::Exception)
+{
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=mergeUMeshesOnSameCoords(this,other);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n=mesh->zipConnectivityTraducer(compType);
+  int nbOfCells=getNumberOfCells();
+  arr=o2n->substr(nbOfCells);
+  int tmp;
+  return arr->getMaxValue(tmp)<nbOfCells;
+}
+
 /*!
  * @param areNodesMerged if at least two nodes have been merged.
  * @return old to new node correspondance.
@@ -907,6 +937,17 @@ DataArrayInt *MEDCouplingUMesh::mergeNodes(double precision, bool& areNodesMerge
   return ret;
 }
 
+/*!
+ * Idem ParaMEDMEM::MEDCouplingUMesh::mergeNodes method except that the merged nodes are meld into the barycenter of them.
+ */
+DataArrayInt *MEDCouplingUMesh::mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes)
+{
+  DataArrayInt *ret=buildPermArrayForMergeNode(-1,precision,areNodesMerged,newNbOfNodes);
+  if(areNodesMerged)
+    renumberNodes2(ret->getConstPointer(),newNbOfNodes);
+  return ret;
+}
+
 /*!
  * This method tries to use 'other' coords and use it for 'this'. If no exception was thrown after the call of this method :
  * this->_coords==other->_coords. If not a exception is thrown this remains unchanged.
@@ -947,7 +988,7 @@ void MEDCouplingUMesh::tryToShareSameCoordsPermute(const MEDCouplingPointSet& ot
  * build a sub part of 'this'. This sub part is defined by the cell ids contained in the array in [begin,end).
  * @param begin begin of array containing the cell ids to keep.
  * @param end end of array of cell ids to keep. \b WARNING end param is \b not included ! Idem STL standard definitions.
- * @param keepCoords that specifies if you want or not to keep coords as this or zip it (see zipCoords)
+ * @param keepCoords that specifies if you want or not to keep coords as this or zip it (see ParaMEDMEM::MEDCouplingUMesh::zipCoords). If true zipCoords is \b NOT called, if false, zipCoords is called.
  */
 MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelf(const int *begin, const int *end, bool keepCoords) const
 {
@@ -1042,7 +1083,7 @@ MEDCouplingPointSet *MEDCouplingUMesh::buildFacePartOfMySelfNode(const int *begi
 /*!
  * This method returns a mesh with meshDim=this->getMeshDimension()-1.
  * This returned mesh contains cells that are linked with one and only one cell of this.
- * @param keepCoords specifies if zipCoords is called on returned mesh before being returned.
+ * @param keepCoords specifies if ParaMEDMEM::MEDCouplingUMesh::zipCoords is called on returned mesh before being returned. If true zipCoords is \b NOT called, if false, zipCoords is called.
  * @return mesh with ref counter equal to 1.
  */
 MEDCouplingPointSet *MEDCouplingUMesh::buildBoundaryMesh(bool keepCoords) const
@@ -1101,6 +1142,12 @@ void MEDCouplingUMesh::findBoundaryNodes(std::vector<int>& nodes) const
   meshDM1->decrRef();
 }
 
+MEDCouplingUMesh *MEDCouplingUMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception)
+{
+  incrRef();
+  return const_cast<MEDCouplingUMesh *>(this);
+}
+
 /*
  * This method renumber 'this' using 'newNodeNumbers' array of size this->getNumberOfNodes.
  * newNbOfNodes specifies the *std::max_element(newNodeNumbers,newNodeNumbers+this->getNumberOfNodes())
@@ -1116,6 +1163,22 @@ void MEDCouplingUMesh::renumberNodes(const int *newNodeNumbers, int newNbOfNodes
   renumberNodesInConn(newNodeNumbers);
 }
 
+/*
+ * This method renumber 'this' using 'newNodeNumbers' array of size this->getNumberOfNodes.
+ * newNbOfNodes specifies the *std::max_element(newNodeNumbers,newNodeNumbers+this->getNumberOfNodes())
+ * This value is asked because often known by the caller of this method.
+ * This method, contrary to MEDCouplingMesh::renumberCells does NOT conserve the number of nodes before and after.
+ * The difference with ParaMEDMEM::MEDCouplingUMesh::renumberNodes method is in the fact that the barycenter of merged nodes is computed here.
+ *
+ * @param newNodeNumbers array specifying the new numbering.
+ * @param newNbOfNodes the new number of nodes.
+ */
+void MEDCouplingUMesh::renumberNodes2(const int *newNodeNumbers, int newNbOfNodes)
+{
+  MEDCouplingPointSet::renumberNodes2(newNodeNumbers,newNbOfNodes);
+  renumberNodesInConn(newNodeNumbers);
+}
+
 /*!
  * This method renumbers nodes in connectivity only without any reference with coords.
  * Use it with care !
@@ -1728,35 +1791,52 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureFieldOnNode(bool isAbs) cons
  */
 MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const
 {
-  if(getMeshDimension()!=2)
-    throw INTERP_KERNEL::Exception("Expected a umesh with meshDim == 2 !");
+  if((getMeshDimension()!=2) && (getMeshDimension()!=1 || getSpaceDimension()!=2))
+    throw INTERP_KERNEL::Exception("Expected a umesh with ( meshDim == 2 spaceDim == 2 or 3 ) or ( meshDim == 1 spaceDim == 2 ) !");
   MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
   DataArrayDouble *array=DataArrayDouble::New();
   int nbOfCells=getNumberOfCells();
-  array->alloc(nbOfCells,3);
+  int nbComp=getMeshDimension()+1;
+  array->alloc(nbOfCells,nbComp);
   double *vals=array->getPointer();
   const int *connI=_nodal_connec_index->getConstPointer();
   const int *conn=_nodal_connec->getConstPointer();
   const double *coords=_coords->getConstPointer();
-  DataArrayDouble *loc=getBarycenterAndOwner();
-  const double *locPtr=loc->getConstPointer();
-  if(getSpaceDimension()==3)
+  if(getMeshDimension()==2)
     {
-      for(int i=0;i<nbOfCells;i++,vals+=3)
+      if(getSpaceDimension()==3)
         {
-          int offset=connI[i];
-          INTERP_KERNEL::crossprod<3>(locPtr+3*i,coords+3*conn[offset+1],coords+3*conn[offset+2],vals);
-          double n=INTERP_KERNEL::norm<3>(vals);
-          std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies<double>(),1./n));
+          DataArrayDouble *loc=getBarycenterAndOwner();
+          const double *locPtr=loc->getConstPointer();
+          for(int i=0;i<nbOfCells;i++,vals+=3)
+            {
+              int offset=connI[i];
+              INTERP_KERNEL::crossprod<3>(locPtr+3*i,coords+3*conn[offset+1],coords+3*conn[offset+2],vals);
+              double n=INTERP_KERNEL::norm<3>(vals);
+              std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies<double>(),1./n));
+            }
+          loc->decrRef();
+        }
+      else
+        {
+          for(int i=0;i<nbOfCells;i++)
+            { vals[3*i]=0.; vals[3*i+1]=0.; vals[3*i+2]=1.; }
         }
     }
-  else
+  else//meshdimension==1
     {
+      double tmp[2];
       for(int i=0;i<nbOfCells;i++)
-        { vals[3*i]=0.; vals[3*i+1]=0.; vals[3*i+2]=1.; }
+        {
+          int offset=connI[i];
+          std::transform(coords+2*conn[offset+2],coords+2*conn[offset+2]+2,coords+2*conn[offset+1],tmp,std::minus<double>());
+          double n=INTERP_KERNEL::norm<2>(tmp);
+          std::transform(tmp,tmp+2,tmp,std::bind2nd(std::multiplies<double>(),1./n));
+          *vals++=-tmp[1];
+          *vals++=tmp[0];
+        }
     }
   ret->setArray(array);
-  loc->decrRef();
   array->decrRef();
   ret->setMesh(this);
   return ret;
@@ -2015,18 +2095,18 @@ void MEDCouplingUMesh::checkButterflyCells(std::vector<int>& cells) const
  * \b 1 for translation and rotation around point of 'mesh1D'.
  * @return an unstructured mesh with meshDim==3 and spaceDim==3. The returned mesh has the same coords than 'this'.  
  */
-MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy)
+MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy)
 {
   checkFullyDefined();
   mesh1D->checkFullyDefined();
   if(!mesh1D->isContiguous1D())
-    throw INTERP_KERNEL::Exception("buildExtrudedMeshFromThis : 1D mesh passed in parameter is not contiguous !");
+    throw INTERP_KERNEL::Exception("buildExtrudedMesh : 1D mesh passed in parameter is not contiguous !");
   if(getSpaceDimension()!=mesh1D->getSpaceDimension())
-    throw INTERP_KERNEL::Exception("Invalid call to buildExtrudedMeshFromThis this and mesh1D must have same dimension !");
+    throw INTERP_KERNEL::Exception("Invalid call to buildExtrudedMesh this and mesh1D must have same dimension !");
   if((getMeshDimension()!=2 || getSpaceDimension()!=3) && (getMeshDimension()!=1 || getSpaceDimension()!=2))
-    throw INTERP_KERNEL::Exception("Invalid 'this' for buildExtrudedMeshFromThis method : must be (meshDim==2 and spaceDim==3) or (meshDim==1 and spaceDim==2) !");
+    throw INTERP_KERNEL::Exception("Invalid 'this' for buildExtrudedMesh method : must be (meshDim==2 and spaceDim==3) or (meshDim==1 and spaceDim==2) !");
   if(mesh1D->getMeshDimension()!=1)
-    throw INTERP_KERNEL::Exception("Invalid 'mesh1D' for buildExtrudedMeshFromThis method : must be meshDim==1 !");
+    throw INTERP_KERNEL::Exception("Invalid 'mesh1D' for buildExtrudedMesh method : must be meshDim==1 !");
   bool isQuad=false;
   if(isPresenceOfQuadratic())
     {
@@ -2061,7 +2141,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThis(const MEDCouplingU
 }
 
 /*!
- * This method incarnates the policy 0 for MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This method incarnates the policy 0 for MEDCouplingUMesh::buildExtrudedMesh method.
  * @param mesh1D is the input 1D mesh used for translation computation.
  * @return newCoords new coords filled by this method. 
  */
@@ -2107,7 +2187,7 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslation(const MEDCoupli
 }
 
 /*!
- * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method.
  * @param mesh1D is the input 1D mesh used for translation and automatic rotation computation.
  * @return newCoords new coords filled by this method. 
  */
@@ -2121,7 +2201,7 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation(const
 }
 
 /*!
- * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method.
  * @param mesh1D is the input 1D mesh used for translation and automatic rotation computation.
  * @return newCoords new coords filled by this method. 
  */
@@ -2139,7 +2219,7 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D(con
   double *retPtr=ret->getPointer();
   retPtr=std::copy(getCoords()->getConstPointer(),getCoords()->getConstPointer()+getCoords()->getNbOfElems(),retPtr);
   MEDCouplingUMesh *tmp=MEDCouplingUMesh::New();
-  DataArrayDouble *tmp2=getCoords()->deepCopy();
+  DataArrayDouble *tmp2=getCoords()->deepCpy();
   tmp->setCoords(tmp2);
   tmp2->decrRef();
   const double *coo1D=mesh1D->getCoords()->getConstPointer();
@@ -2167,7 +2247,7 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D(con
 }
 
 /*!
- * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method.
  * @param mesh1D is the input 1D mesh used for translation and automatic rotation computation.
  * @return newCoords new coords filled by this method. 
  */
@@ -2185,7 +2265,7 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D(con
   double *retPtr=ret->getPointer();
   retPtr=std::copy(getCoords()->getConstPointer(),getCoords()->getConstPointer()+getCoords()->getNbOfElems(),retPtr);
   MEDCouplingUMesh *tmp=MEDCouplingUMesh::New();
-  DataArrayDouble *tmp2=getCoords()->deepCopy();
+  DataArrayDouble *tmp2=getCoords()->deepCpy();
   tmp->setCoords(tmp2);
   tmp2->decrRef();
   const double *coo1D=mesh1D->getCoords()->getConstPointer();
@@ -2237,7 +2317,7 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D(con
 
 /*!
  * This method is private because not easy to use for end user. This method is const contrary to
- * MEDCouplingUMesh::buildExtrudedMeshFromThis method because this->_coords are expected to contain
+ * MEDCouplingUMesh::buildExtrudedMesh method because this->_coords are expected to contain
  * the coords sorted slice by slice.
  * @param isQuad specifies presence of quadratic cells.
  */
@@ -3085,7 +3165,7 @@ DataArrayInt *MEDCouplingUMesh::rearrange2ConsecutiveCellTypes()
 }
 
 /*!
- * This methods split this into as mush as untructured meshes that consecutive set of same type cells.
+ * This method splits 'this' into as mush as untructured meshes that consecutive set of same type cells.
  * So this method has typically a sense if MEDCouplingUMesh::checkConsecutiveCellTypes has a sense.
  * This method makes asumption that connectivity is correctly set before calling.
  */
@@ -3215,44 +3295,83 @@ DataArrayDouble *MEDCouplingUMesh::getBarycenterAndOwner() const
  * Returns a newly created mesh (with ref count ==1) that contains merge of 'mesh1' and 'other'.
  * The coords of 'mesh2' are added at the end of coords of 'mesh1'.
  */
-MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2)
+MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception)
 {
-  MEDCouplingUMesh *ret=MEDCouplingUMesh::New();
-  ret->setName("merge");
-  DataArrayDouble *pts=mergeNodesArray(mesh1,mesh2);
+  std::vector<const MEDCouplingUMesh *> tmp(2);
+  tmp[0]=const_cast<MEDCouplingUMesh *>(mesh1); tmp[1]=const_cast<MEDCouplingUMesh *>(mesh2);
+  return mergeUMeshes(tmp);
+}
+
+MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshes(std::vector<const MEDCouplingUMesh *>& a) throw(INTERP_KERNEL::Exception)
+{
+  if(a.empty())
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::mergeUMeshes : input array must be NON EMPTY !");
+  std::vector<const MEDCouplingUMesh *>::const_iterator it=a.begin();
+  int meshDim=(*it)->getMeshDimension();
+  int nbOfCells=(*it)->getNumberOfCells();
+  int meshLgth=(*it++)->getMeshLength();
+  for(;it!=a.end();it++)
+    {
+      if(meshDim!=(*it)->getMeshDimension())
+        throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, mergeMeshes impossible !");
+      nbOfCells+=(*it)->getNumberOfCells();
+      meshLgth+=(*it)->getMeshLength();
+    }
+  std::vector<const MEDCouplingPointSet *> aps(a.size());
+  std::copy(a.begin(),a.end(),aps.begin());
+  DataArrayDouble *pts=mergeNodesArray(aps);
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New("merge",meshDim);
   ret->setCoords(pts);
   pts->decrRef();
-  int meshDim=mesh1->getMeshDimension();
-  if(meshDim!=mesh2->getMeshDimension())
-    throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, mergeMeshes impossible !");
-  ret->setMeshDimension(meshDim);
-  int delta=mesh1->getMeshLength();
-  int pos=mesh1->getNumberOfCells();
-  int nbOfCells2=mesh2->getNumberOfCells();
-  int end=mesh1->getNumberOfCells()+nbOfCells2+1;
-  DataArrayInt *nodalIndex=DataArrayInt::aggregate(mesh1->getNodalConnectivityIndex(),
-                                                   mesh2->getNodalConnectivityIndex(),1);
-  std::transform(nodalIndex->getConstPointer()+pos+1,nodalIndex->getConstPointer()+end,
-                 nodalIndex->getPointer()+pos+1,std::bind2nd(std::plus<int>(),delta));
-  DataArrayInt *newNodal2=mesh2->getNodalConnectivity()->deepCopy();
-  delta=mesh1->getNumberOfNodes();
-  const int *nI2=mesh2->getNodalConnectivityIndex()->getConstPointer();
-  int *pt=newNodal2->getPointer();
-  for(int i=0;i<nbOfCells2;i++)
-    {
-      pt++;
-      for(int j=0;j<nI2[i+1]-nI2[i]-1;j++,pt++)
-        if(*pt!=-1)
-          *pt+=delta;
-    }
-  DataArrayInt *nodal=DataArrayInt::aggregate(mesh1->getNodalConnectivity(),newNodal2,0);
-  newNodal2->decrRef();
-  ret->setConnectivity(nodal,nodalIndex,true);
-  nodalIndex->decrRef();
-  nodal->decrRef();
+  DataArrayInt *c=DataArrayInt::New();
+  c->alloc(meshLgth,1);
+  int *cPtr=c->getPointer();
+  DataArrayInt *cI=DataArrayInt::New();
+  cI->alloc(nbOfCells+1,1);
+  int *cIPtr=cI->getPointer();
+  *cIPtr++=0;
+  int offset=0;
+  int offset2=0;
+  for(it=a.begin();it!=a.end();it++)
+    {
+      int curNbOfCell=(*it)->getNumberOfCells();
+      const int *curCI=(*it)->_nodal_connec_index->getConstPointer();
+      const int *curC=(*it)->_nodal_connec->getConstPointer();
+      cIPtr=std::transform(curCI+1,curCI+curNbOfCell+1,cIPtr,std::bind2nd(std::plus<int>(),offset));
+      for(int j=0;j<curNbOfCell;j++)
+        {
+          const int *src=curC+curCI[j];
+          *cPtr++=*src++;
+          for(;src!=curC+curCI[j+1];src++,cPtr++)
+            {
+              if(*src!=-1)
+                *cPtr=*src+offset2;
+              else
+                *cPtr=-1;
+            }
+        }
+      offset=curCI[curNbOfCell];
+      offset2+=(*it)->getNumberOfNodes();
+    }
+  //
+  ret->setConnectivity(c,cI,true);
+  c->decrRef();
+  cI->decrRef();
+  ret->incrRef();
   return ret;
 }
 
+/*!
+ * Idem mergeUMeshes except that 'meshes' are expected to lyie on the same coords and 'meshes' have the same meshdim.
+ * 'meshes' must be a non empty vector.
+ */
+MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception)
+{
+  std::vector<MEDCouplingUMesh *> tmp(2);
+  tmp[0]=const_cast<MEDCouplingUMesh *>(mesh1); tmp[1]=const_cast<MEDCouplingUMesh *>(mesh2);
+  return mergeUMeshesOnSameCoords(tmp);
+}
+
 /*!
  * Idem mergeUMeshes except that 'meshes' are expected to lyie on the same coords and 'meshes' have the same meshdim.
  * 'meshes' must be a non empty vector.
index df4ddd292337228ebca3c69c4d310bba73d4a18c..3594338ea392c417c4891250b253623089f87488 100644 (file)
@@ -47,7 +47,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT void checkCoherency() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void setMeshDimension(int meshDim);
     MEDCOUPLING_EXPORT void allocateCells(int nbOfCells);
-    MEDCOUPLING_EXPORT void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell);
+    MEDCOUPLING_EXPORT void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void finishInsertingCells();
     MEDCOUPLING_EXPORT const std::set<INTERP_KERNEL::NormalizedCellType>& getAllTypes() const { return _types; }
     MEDCOUPLING_EXPORT void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true);
@@ -80,18 +80,22 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT bool areCellsFrom2MeshEqual(const MEDCouplingUMesh *other, int cellId, double prec) const;
     MEDCOUPLING_EXPORT void convertToPolyTypes(const std::vector<int>& cellIdsToConvert);
     MEDCOUPLING_EXPORT void unPolyze();
-    MEDCOUPLING_EXPORT DataArrayInt *zipCoordsTraducer();
-    MEDCOUPLING_EXPORT DataArrayInt *zipConnectivityTraducer(int compType);
-    MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const;
-    MEDCOUPLING_EXPORT MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const;
+    MEDCOUPLING_EXPORT DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT DataArrayInt *zipConnectivityTraducer(int compType) throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT bool areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayInt *& arr) const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes);
+    MEDCOUPLING_EXPORT DataArrayInt *mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes);
     MEDCOUPLING_EXPORT void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelf(const int *begin, const int *end, bool keepCoords) const;
     MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const;
     MEDCOUPLING_EXPORT MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const;
+    MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void findBoundaryNodes(std::vector<int>& nodes) const;
     MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const;
     MEDCOUPLING_EXPORT void renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
+    MEDCOUPLING_EXPORT void renumberNodes2(const int *newNodeNumbers, int newNbOfNodes);
     MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems);
     MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems);
@@ -106,7 +110,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const;
     MEDCOUPLING_EXPORT void checkButterflyCells(std::vector<int>& cells) const;
     MEDCOUPLING_EXPORT void getBoundingBoxForBBTree(std::vector<double>& bbox) const;
-    MEDCOUPLING_EXPORT MEDCouplingUMesh *buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy);
+    MEDCOUPLING_EXPORT MEDCouplingUMesh *buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy);
     MEDCOUPLING_EXPORT bool isFullyQuadratic() const;
     MEDCOUPLING_EXPORT bool isPresenceOfQuadratic() const;
     MEDCOUPLING_EXPORT void convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception);
@@ -134,7 +138,9 @@ namespace ParaMEDMEM
     //
     MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
     MEDCOUPLING_EXPORT DataArrayDouble *getBarycenterAndOwner() const;
-    MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2);
+    MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshes(std::vector<const MEDCouplingUMesh *>& a) throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshesOnSameCoords(const std::vector<MEDCouplingUMesh *>& meshes);
     MEDCOUPLING_EXPORT static MEDCouplingUMesh *fuseUMeshesOnSameCoords(const std::vector<MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& corr);
     MEDCOUPLING_EXPORT static bool isPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords);
index e8629b7b81ada122576ad10d38751fa74e4a0b6b..e0cff180d7e7b5181af696beb7c6ada9b510b36f 100644 (file)
@@ -338,6 +338,13 @@ DataArrayInt *MEDCouplingUMeshDesc::mergeNodes(double precision, bool& areNodesM
   return 0;
 }
 
+DataArrayInt *MEDCouplingUMeshDesc::mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes)
+{
+  //not implemented yet.
+  areNodesMerged=false;
+  return 0;
+}
+
 void MEDCouplingUMeshDesc::tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception)
 {
   throw INTERP_KERNEL::Exception("Not implemented yet !");
@@ -377,6 +384,11 @@ MEDCouplingPointSet *MEDCouplingUMeshDesc::buildBoundaryMesh(bool keepCoords) co
   return 0;
 }
 
+MEDCouplingUMesh *MEDCouplingUMeshDesc::buildUnstructured() const throw(INTERP_KERNEL::Exception)
+{
+  throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::buildUnstructured : not implemented yet !");
+}
+
 void MEDCouplingUMeshDesc::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
 {
   throw INTERP_KERNEL::Exception("Available for UMesh desc but not implemented yet !");
index f11fe94a40ebbb15eba3b5a8190cba413709923c..1924108e9fd04af15754e32cb3b02251d6860122 100644 (file)
@@ -62,6 +62,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems);
     MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps, std::vector<int>& elems);
     MEDCOUPLING_EXPORT DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes);
+    MEDCOUPLING_EXPORT DataArrayInt *mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes);
     MEDCOUPLING_EXPORT void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const;
     MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const;
@@ -69,6 +70,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void findBoundaryNodes(std::vector<int>& nodes) const;
     MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const;
+    MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
index 4982c2e7af424926314f211ef81a4e3326c20835..54bcaa886fea061b572e98e4bb2ab4e908be8ff8 100644 (file)
@@ -160,6 +160,22 @@ namespace ParaMEDMEM
     CPPUNIT_TEST( testExtrudedMesh7 );
     CPPUNIT_TEST( testSimplexize1 );
     CPPUNIT_TEST( testSimplexize2 );
+    CPPUNIT_TEST( testDAMeld1 );
+    CPPUNIT_TEST( testFieldMeld1 );
+    CPPUNIT_TEST( testMergeNodes2 );
+    CPPUNIT_TEST( testMergeField2 );
+    CPPUNIT_TEST( testDAIBuildComplement1 );
+    CPPUNIT_TEST( testDAIBuildUnion1 );
+    CPPUNIT_TEST( testDAIBuildIntersection1 );
+    CPPUNIT_TEST( testDAIDeltaShiftIndex1 );
+    CPPUNIT_TEST( testDaDoubleSelectByTupleIdSafe1 );
+    CPPUNIT_TEST( testAreCellsIncludedIn1 );
+    CPPUNIT_TEST( testDAIBuildSubstraction1 );
+    CPPUNIT_TEST( testBuildOrthogonalField2 );
+    CPPUNIT_TEST( testUMInsertNextCell1 );
+    CPPUNIT_TEST( testFieldOperatorDivDiffComp1 );
+    CPPUNIT_TEST( testDARearrange1 );
+    CPPUNIT_TEST( testGetDifferentValues1 );
     //MEDCouplingBasicsTestInterp.cxx
     CPPUNIT_TEST( test2DInterpP0P0_1 );
     CPPUNIT_TEST( test2DInterpP0P0PL_1 );
@@ -348,6 +364,22 @@ namespace ParaMEDMEM
     void testExtrudedMesh7();
     void testSimplexize1();
     void testSimplexize2();
+    void testDAMeld1();
+    void testFieldMeld1();
+    void testMergeNodes2();
+    void testMergeField2();
+    void testDAIBuildComplement1();
+    void testDAIBuildUnion1();
+    void testDAIBuildIntersection1();
+    void testDAIDeltaShiftIndex1();
+    void testDaDoubleSelectByTupleIdSafe1();
+    void testAreCellsIncludedIn1();
+    void testDAIBuildSubstraction1();
+    void testBuildOrthogonalField2();
+    void testUMInsertNextCell1();
+    void testFieldOperatorDivDiffComp1();
+    void testDARearrange1();
+    void testGetDifferentValues1();
     //MEDCouplingBasicsTestInterp.cxx
     void test2DInterpP0P0_1();
     void test2DInterpP0P0PL_1();
index ffa8b6a759498ef924fac8840ceadbf820047f5f..98f0f6b72f133d1d5897a9150b521e3e7f647791 100644 (file)
@@ -325,7 +325,7 @@ void MEDCouplingBasicsTest::testDeepCopy()
   std::fill(array->getPointer(),array->getPointer()+5*3,7.);
   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,array->getIJ(3,2),1e-14);
   double *tmp1=array->getPointer();
-  DataArrayDouble *array2=array->deepCopy();
+  DataArrayDouble *array2=array->deepCpy();
   double *tmp2=array2->getPointer();
   CPPUNIT_ASSERT(tmp1!=tmp2);
   array->decrRef();
@@ -337,7 +337,7 @@ void MEDCouplingBasicsTest::testDeepCopy()
   std::fill(array3->getPointer(),array3->getPointer()+5*3,17);
   CPPUNIT_ASSERT_EQUAL(17,array3->getIJ(3,2));
   int *tmp3=array3->getPointer();
-  DataArrayInt *array4=array3->deepCopy();
+  DataArrayInt *array4=array3->deepCpy();
   int *tmp4=array4->getPointer();
   CPPUNIT_ASSERT(tmp3!=tmp4);
   array3->decrRef();
@@ -873,7 +873,7 @@ void MEDCouplingBasicsTest::testEqualFieldDouble()
   CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
   CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
   //
-  DataArrayDouble *arr2=arr->deepCopy();
+  DataArrayDouble *arr2=arr->deepCpy();
   fieldOnCells2->setArray(arr2);
   arr2->decrRef();
   CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
@@ -1049,7 +1049,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh2()
 }
 
 /*!
- * This test check MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This test check MEDCouplingUMesh::buildExtrudedMesh method.
  */
 void MEDCouplingBasicsTest::testExtrudedMesh3()
 {
@@ -1060,7 +1060,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh3()
   double center[3]={0.,0.,0.};
   double vector[3]={0,1,0};
   m2->rotate(center,vector,-M_PI/2.);
-  MEDCouplingUMesh *m3=m1->buildExtrudedMeshFromThis(m2,0);
+  MEDCouplingUMesh *m3=m1->buildExtrudedMesh(m2,0);
   //
   MEDCouplingExtrudedMesh *m4=MEDCouplingExtrudedMesh::New(m3,m1,0);
   CPPUNIT_ASSERT_EQUAL(15,m4->getNumberOfCells());
@@ -1085,7 +1085,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh3()
   //play with polygons and polyedrons
   std::vector<int> cells(2); cells[0]=2; cells[1]=3;
   m1->convertToPolyTypes(cells);
-  m3=m1->buildExtrudedMeshFromThis(m2,0);
+  m3=m1->buildExtrudedMesh(m2,0);
   CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_HEXA8,(int)m3->getTypeOfCell(0));
   CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_PENTA6,(int)m3->getTypeOfCell(1));
   CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_POLYHED,(int)m3->getTypeOfCell(2));
@@ -1107,7 +1107,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh3()
 }
 
 /*!
- * This test check MEDCouplingUMesh::buildExtrudedMeshFromThis method, but also, MEDCouplingExtrudedMesh following methods :
+ * This test check MEDCouplingUMesh::buildExtrudedMesh method, but also, MEDCouplingExtrudedMesh following methods :
  * getCellContainingPoint getMeasureField getNodeIdsOfCell getCoordinateOfNode getTypeOfCell build3DUnstructuredMesh.
  */
 void MEDCouplingBasicsTest::testExtrudedMesh4()
@@ -1121,7 +1121,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh4()
   double center[3]={0.,0.,0.};
   double vector[3]={0.,1.,0.};
   m2->rotate(center,vector,-M_PI/2.);
-  MEDCouplingUMesh *m3=m1->buildExtrudedMeshFromThis(m2,0);
+  MEDCouplingUMesh *m3=m1->buildExtrudedMesh(m2,0);
   const int expected1[15]= {1,3,2,0,6,5,7,10,11,8,12,9,14,13,4};
   const int rexpected1[15]={3, 0, 2, 1, 14, 5, 4, 6, 9, 11, 7, 8, 10, 13, 12};
   m3->renumberCells(expected1,false);
index 2b2f4de2a7e13aab51094892ceaee1f36077e765..6bbc8b2091eb042f730fc3448a3c5a08f8eb602c 100644 (file)
@@ -215,7 +215,7 @@ void MEDCouplingBasicsTest::testCellOrientation2()
   double center[3]={0.,0.,0.};
   double vector[3]={0.,1.,0.};
   m4->rotate(center,vector,-M_PI/2.);
-  MEDCouplingUMesh *m5=m3->buildExtrudedMeshFromThis(m4,0);
+  MEDCouplingUMesh *m5=m3->buildExtrudedMesh(m4,0);
   res1.clear();
   m5->arePolyhedronsNotCorrectlyOriented(res1);
   CPPUNIT_ASSERT_EQUAL(15,(int)res1.size());
@@ -902,7 +902,7 @@ void MEDCouplingBasicsTest::testCopyTinyStringsFromOnFields()
   a1->fillWithZero();
   a1->setInfoOnComponent(0,"c");
   a1->setInfoOnComponent(1,"d");
-  DataArrayDouble *a2=a1->deepCopy();
+  DataArrayDouble *a2=a1->deepCpy();
   a2->setInfoOnComponent(0,"e");
   a2->setInfoOnComponent(1,"f");
   f->setArray(a1);
@@ -3376,7 +3376,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh5()
   DataArrayDouble *g=f->getCoords()->applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
   DataArrayDouble *h=g->fromPolarToCart();
   f->setCoords(h);
-  MEDCouplingUMesh *i=c->buildExtrudedMeshFromThis(f,1);
+  MEDCouplingUMesh *i=c->buildExtrudedMesh(f,1);
   CPPUNIT_ASSERT_EQUAL(52,i->getNumberOfNodes());
   bool tmp2;
   int tmp3;
@@ -3440,7 +3440,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh6()
   //
   const double center[2]={0.,0.};
   f->rotate(center,0,M_PI/3);
-  MEDCouplingUMesh *g=c->buildExtrudedMeshFromThis(f,0);
+  MEDCouplingUMesh *g=c->buildExtrudedMesh(f,0);
   g->checkCoherency();
   const double expected1[]={ 0.4330127018922193, 0.4330127018922193, 0.649519052838329, 1.2990381056766578, 1.299038105676658, 1.948557158514987, 2.1650635094610955, 2.1650635094610964, 3.2475952641916446, 3.031088913245533, 3.0310889132455352, 4.546633369868303 };
   MEDCouplingFieldDouble *f1=g->getMeasureField(true);
@@ -3488,7 +3488,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh7()
   DataArrayDouble *g=f->getCoords()->applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
   DataArrayDouble *h=g->fromPolarToCart();
   f->setCoords(h);
-  MEDCouplingUMesh *i=c->buildExtrudedMeshFromThis(f,1);
+  MEDCouplingUMesh *i=c->buildExtrudedMesh(f,1);
   CPPUNIT_ASSERT_EQUAL(52,i->getNumberOfNodes());
   bool tmp2;
   int tmp3;
@@ -3502,7 +3502,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh7()
   DataArrayDouble *g2=h->applyFunc(3,"13.5/3.5*x*IVec+0*JVec+13.5/3.5*y*KVec");
   f->setCoords(g2);
   i->changeSpaceDimension(3);
-  MEDCouplingUMesh *i3=i->buildExtrudedMeshFromThis(f,1);
+  MEDCouplingUMesh *i3=i->buildExtrudedMesh(f,1);
   MEDCouplingFieldDouble *f2=i3->getMeasureField(true);
   tmp=i->mergeNodes(1e-9,tmp2,tmp3);
   CPPUNIT_ASSERT(tmp2);
@@ -3618,3 +3618,561 @@ void MEDCouplingBasicsTest::testSimplexize2()
   f1->decrRef();
   m->decrRef();
 }
+
+void MEDCouplingBasicsTest::testDAMeld1()
+{
+  DataArrayDouble *da1=DataArrayDouble::New();
+  da1->alloc(7,2);
+  DataArrayDouble *da2=DataArrayDouble::New();
+  da2->alloc(7,1);
+  //
+  da1->fillWithValue(7.);
+  da2->iota(0.);
+  DataArrayDouble *da3=da2->applyFunc(3,"10*x*IVec+100*x*JVec+1000*x*KVec");
+  //
+  da1->setInfoOnComponent(0,"c0da1");
+  da1->setInfoOnComponent(1,"c1da1");
+  da3->setInfoOnComponent(0,"c0da3");
+  da3->setInfoOnComponent(1,"c1da3");
+  da3->setInfoOnComponent(2,"c2da3");
+  //
+  DataArrayDouble *da1C=da1->deepCpy();
+  da1->meldWith(da3);
+  CPPUNIT_ASSERT_EQUAL(5,da1->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(7,da1->getNumberOfTuples());
+  CPPUNIT_ASSERT(da1->getInfoOnComponent(0)=="c0da1");
+  CPPUNIT_ASSERT(da1->getInfoOnComponent(1)=="c1da1");
+  CPPUNIT_ASSERT(da1->getInfoOnComponent(2)=="c0da3");
+  CPPUNIT_ASSERT(da1->getInfoOnComponent(3)=="c1da3");
+  CPPUNIT_ASSERT(da1->getInfoOnComponent(4)=="c2da3");
+  //
+  const double expected1[35]={7.,7.,0.,0.,0., 7.,7.,10.,100.,1000., 7.,7.,20.,200.,2000., 7.,7.,30.,300.,3000., 7.,7.,40.,400.,4000.,7.,7.,50.,500.,5000.,7.,7.,60.,600.,6000.};
+  for(int i=0;i<35;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da1->getIJ(0,i),1e-10);
+  //
+  DataArrayInt *dai1=da1C->convertToIntArr();
+  DataArrayInt *dai3=da3->convertToIntArr();
+  dai1->meldWith(dai3);
+  CPPUNIT_ASSERT_EQUAL(5,dai1->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(7,dai1->getNumberOfTuples());
+  CPPUNIT_ASSERT(dai1->getInfoOnComponent(0)=="c0da1");
+  CPPUNIT_ASSERT(dai1->getInfoOnComponent(1)=="c1da1");
+  CPPUNIT_ASSERT(dai1->getInfoOnComponent(2)=="c0da3");
+  CPPUNIT_ASSERT(dai1->getInfoOnComponent(3)=="c1da3");
+  CPPUNIT_ASSERT(dai1->getInfoOnComponent(4)=="c2da3");
+  for(int i=0;i<35;i++)
+    CPPUNIT_ASSERT_EQUAL((int)expected1[i],dai1->getIJ(0,i));
+  // test of static method DataArrayDouble::meld
+  DataArrayDouble *da4=DataArrayDouble::meld(da1C,da3);
+  CPPUNIT_ASSERT_EQUAL(5,da4->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(7,da4->getNumberOfTuples());
+  CPPUNIT_ASSERT(da4->getInfoOnComponent(0)=="c0da1");
+  CPPUNIT_ASSERT(da4->getInfoOnComponent(1)=="c1da1");
+  CPPUNIT_ASSERT(da4->getInfoOnComponent(2)=="c0da3");
+  CPPUNIT_ASSERT(da4->getInfoOnComponent(3)=="c1da3");
+  CPPUNIT_ASSERT(da4->getInfoOnComponent(4)=="c2da3");
+  for(int i=0;i<35;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da4->getIJ(0,i),1e-10);
+  // test of static method DataArrayInt::meld
+  dai1->decrRef();
+  dai1=da1C->convertToIntArr();
+  DataArrayInt *dai4=DataArrayInt::meld(dai1,dai3);
+  CPPUNIT_ASSERT_EQUAL(5,dai4->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(7,dai4->getNumberOfTuples());
+  CPPUNIT_ASSERT(dai4->getInfoOnComponent(0)=="c0da1");
+  CPPUNIT_ASSERT(dai4->getInfoOnComponent(1)=="c1da1");
+  CPPUNIT_ASSERT(dai4->getInfoOnComponent(2)=="c0da3");
+  CPPUNIT_ASSERT(dai4->getInfoOnComponent(3)=="c1da3");
+  CPPUNIT_ASSERT(dai4->getInfoOnComponent(4)=="c2da3");
+  for(int i=0;i<35;i++)
+    CPPUNIT_ASSERT_EQUAL((int)expected1[i],dai4->getIJ(0,i));
+  //
+  dai4->decrRef();
+  da4->decrRef();
+  dai3->decrRef();
+  dai1->decrRef();
+  da1C->decrRef();
+  da1->decrRef();
+  da2->decrRef();
+  da3->decrRef();
+}
+
+void MEDCouplingBasicsTest::testFieldMeld1()
+{
+  MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
+  MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+  f1->setMesh(m);
+  DataArrayDouble *da1=DataArrayDouble::New();
+  const double arr1[5]={12.,23.,34.,45.,56.};
+  da1->alloc(5,1);
+  std::copy(arr1,arr1+5,da1->getPointer());
+  da1->setInfoOnComponent(0,"aaa");
+  f1->setArray(da1);
+  f1->setTime(3.4,2,1);
+  f1->checkCoherency();
+  //
+  MEDCouplingFieldDouble *f2=f1->deepCpy();
+  f2->setMesh(f1->getMesh());
+  f2->checkCoherency();
+  f2->changeNbOfComponents(2,5.);
+  (*f2)=5.;
+  f2->getArray()->setInfoOnComponent(0,"bbb");
+  f2->getArray()->setInfoOnComponent(1,"ccc");
+  f2->checkCoherency();
+  //
+  MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::meldFields(f2,f1);
+  f3->checkCoherency();
+  CPPUNIT_ASSERT_EQUAL(5,f3->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(3,f3->getNumberOfComponents());
+  CPPUNIT_ASSERT(f3->getArray()->getInfoOnComponent(0)=="bbb");
+  CPPUNIT_ASSERT(f3->getArray()->getInfoOnComponent(1)=="ccc");
+  CPPUNIT_ASSERT(f3->getArray()->getInfoOnComponent(2)=="aaa");
+  const double expected1[15]={5.,5.,12.,5.,5.,23.,5.,5.,34.,5.,5.,45.,5.,5.,56.};
+  for(int i=0;i<15;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f3->getIJ(0,i),1e-12);
+  int dt,it;
+  double time=f3->getTime(dt,it);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(3.4,time,1e-14);
+  CPPUNIT_ASSERT_EQUAL(2,dt);
+  CPPUNIT_ASSERT_EQUAL(1,it);
+  //
+  MEDCouplingFieldDouble *f4=f2->buildNewTimeReprFromThis(NO_TIME,false);
+  MEDCouplingFieldDouble *f5=f1->buildNewTimeReprFromThis(NO_TIME,false);
+  MEDCouplingFieldDouble *f6=MEDCouplingFieldDouble::meldFields(f4,f5);
+  f6->checkCoherency();
+  CPPUNIT_ASSERT_EQUAL(5,f6->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(3,f6->getNumberOfComponents());
+  CPPUNIT_ASSERT(f6->getArray()->getInfoOnComponent(0)=="bbb");
+  CPPUNIT_ASSERT(f6->getArray()->getInfoOnComponent(1)=="ccc");
+  CPPUNIT_ASSERT(f6->getArray()->getInfoOnComponent(2)=="aaa");
+  for(int i=0;i<15;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f6->getIJ(0,i),1e-12);
+  //
+  f6->decrRef();
+  f4->decrRef();
+  f5->decrRef();
+  f3->decrRef();
+  da1->decrRef();
+  f2->decrRef();
+  f1->decrRef();
+  m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testMergeNodes2()
+{
+  MEDCouplingUMesh *m1=build2DTargetMesh_1();
+  MEDCouplingUMesh *m2=build2DTargetMesh_1();
+  const double vec[2]={0.002,0.};
+  m2->translate(vec);
+  //
+  std::vector<const MEDCouplingUMesh *> tmp(2);
+  tmp[0]=m1;
+  tmp[1]=m2;
+  MEDCouplingUMesh *m3=MEDCouplingUMesh::mergeUMeshes(tmp);
+  bool b;
+  int newNbOfNodes;
+  DataArrayInt *da=m3->mergeNodes2(0.01,b,newNbOfNodes);
+  CPPUNIT_ASSERT_EQUAL(9,m3->getNumberOfNodes());
+  const double expected1[18]={-0.299,-0.3, 0.201,-0.3, 0.701,-0.3, -0.299,0.2, 0.201,0.2, 0.701,0.2, -0.299,0.7, 0.201,0.7, 0.701,0.7};
+  for(int i=0;i<18;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],m3->getCoords()->getIJ(0,i),1e-13);
+  //
+  da->decrRef();
+  m3->decrRef();
+  m1->decrRef();
+  m2->decrRef();
+}
+
+void MEDCouplingBasicsTest::testMergeField2()
+{
+  MEDCouplingUMesh *m=build2DTargetMesh_1();
+  MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+  f1->setMesh(m);
+  DataArrayDouble *arr=DataArrayDouble::New();
+  arr->alloc(5,2);
+  arr->fillWithValue(2.);
+  f1->setArray(arr);
+  arr->decrRef();
+  MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+  f2->setMesh(m);
+  arr=DataArrayDouble::New();
+  arr->alloc(5,2);
+  arr->fillWithValue(5.);
+  f2->setArray(arr);
+  arr->decrRef();
+  MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+  f3->setMesh(m);
+  arr=DataArrayDouble::New();
+  arr->alloc(5,2);
+  arr->fillWithValue(7.);
+  f3->setArray(arr);
+  arr->decrRef();
+  //
+  std::vector<const MEDCouplingFieldDouble *> tmp(3);
+  tmp[0]=f1; tmp[1]=f2; tmp[2]=f3;
+  MEDCouplingFieldDouble *f4=MEDCouplingFieldDouble::mergeFields(tmp);
+  CPPUNIT_ASSERT_EQUAL(15,f4->getMesh()->getNumberOfCells());
+  const double expected1[30]={2.,2.,2.,2.,2.,2.,2.,2.,2.,2., 5.,5.,5.,5.,5.,5.,5.,5.,5.,5., 7.,7.,7.,7.,7.,7.,7.,7.,7.,7.};
+  for(int i=0;i<30;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f4->getIJ(0,i),1.e-13);
+  //
+  f4->decrRef();
+  f1->decrRef();
+  f2->decrRef();
+  f3->decrRef();
+  m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIBuildComplement1()
+{
+  DataArrayInt *a=DataArrayInt::New();
+  const int tab[4]={3,1,7,8};
+  a->alloc(4,1);
+  std::copy(tab,tab+4,a->getPointer());
+  DataArrayInt *b=a->buildComplement(12);
+  CPPUNIT_ASSERT_EQUAL(8,b->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(1,b->getNumberOfComponents());
+  const int expected1[8]={0,2,4,5,6,9,10,11};
+  for(int i=0;i<8;i++)
+    CPPUNIT_ASSERT_EQUAL(expected1[i],b->getIJ(0,i));
+  b->decrRef();
+  a->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIBuildUnion1()
+{
+  DataArrayInt *a=DataArrayInt::New();
+  const int tab1[4]={3,1,7,8};
+  a->alloc(4,1);
+  std::copy(tab1,tab1+4,a->getPointer());
+  DataArrayInt *c=DataArrayInt::New();
+  const int tab2[5]={5,3,0,18,8};
+  c->alloc(5,1);
+  std::copy(tab2,tab2+5,c->getPointer());
+  DataArrayInt *b=a->buildUnion(c);
+  CPPUNIT_ASSERT_EQUAL(7,b->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(1,b->getNumberOfComponents());
+  const int expected1[7]={0,1,3,5,7,8,18};
+  for(int i=0;i<7;i++)
+    CPPUNIT_ASSERT_EQUAL(expected1[i],b->getIJ(0,i));
+  c->decrRef();
+  b->decrRef();
+  a->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIBuildIntersection1()
+{
+  DataArrayInt *a=DataArrayInt::New();
+  const int tab1[4]={3,1,7,8};
+  a->alloc(4,1);
+  std::copy(tab1,tab1+4,a->getPointer());
+  DataArrayInt *c=DataArrayInt::New();
+  const int tab2[5]={5,3,0,18,8};
+  c->alloc(5,1);
+  std::copy(tab2,tab2+5,c->getPointer());
+  DataArrayInt *b=a->buildIntersection(c);
+  CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(1,b->getNumberOfComponents());
+  const int expected1[2]={3,8};
+  for(int i=0;i<2;i++)
+    CPPUNIT_ASSERT_EQUAL(expected1[i],b->getIJ(0,i));
+  c->decrRef();
+  b->decrRef();
+  a->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIDeltaShiftIndex1()
+{
+  DataArrayInt *a=DataArrayInt::New();
+  const int tab[7]={1,3,6,7,7,9,15};
+  a->alloc(7,1);
+  std::copy(tab,tab+7,a->getPointer());
+  DataArrayInt *b=a->deltaShiftIndex();
+  CPPUNIT_ASSERT_EQUAL(6,b->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(1,b->getNumberOfComponents());
+  const int expected1[6]={2,3,1,0,2,6};
+  for(int i=0;i<6;i++)
+    CPPUNIT_ASSERT_EQUAL(expected1[i],b->getIJ(0,i));
+  b->decrRef();
+  a->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDaDoubleSelectByTupleIdSafe1()
+{
+  DataArrayDouble *a=DataArrayDouble::New();
+  a->alloc(7,2);
+  a->setInfoOnComponent(0,"toto");
+  a->setInfoOnComponent(1,"tata");
+  const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1};
+  std::copy(arr1,arr1+14,a->getPointer());
+  //
+  const int arr2[7]={4,2,0,6,5};
+  DataArrayDouble *b=a->selectByTupleIdSafe(arr2,arr2+5);
+  CPPUNIT_ASSERT_EQUAL(5,b->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents());
+  CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto");
+  CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata");
+  const double expected1[10]={5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1};
+  for(int i=0;i<10;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14);
+  const int arr4[5]={4,-1,0,6,5};
+  CPPUNIT_ASSERT_THROW(a->selectByTupleIdSafe(arr4,arr4+5),INTERP_KERNEL::Exception);
+  const int arr5[5]={4,2,0,6,7};
+  CPPUNIT_ASSERT_THROW(a->selectByTupleIdSafe(arr5,arr5+5),INTERP_KERNEL::Exception);
+  b->decrRef();
+  a->decrRef();
+  //
+  DataArrayInt *c=DataArrayInt::New();
+  c->alloc(7,2);
+  c->setInfoOnComponent(0,"toto");
+  c->setInfoOnComponent(1,"tata");
+  const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17};
+  std::copy(arr3,arr3+14,c->getPointer());
+  DataArrayInt *d=c->selectByTupleIdSafe(arr2,arr2+5);
+  CPPUNIT_ASSERT_EQUAL(5,d->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents());
+  CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto");
+  CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata");
+  const int expected2[10]={5,15,3,13,1,11,7,17,6,16};
+  for(int i=0;i<10;i++)
+    CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i));
+  CPPUNIT_ASSERT_THROW(c->selectByTupleIdSafe(arr4,arr4+5),INTERP_KERNEL::Exception);
+  CPPUNIT_ASSERT_THROW(c->selectByTupleIdSafe(arr5,arr5+5),INTERP_KERNEL::Exception);
+  c->decrRef();
+  d->decrRef();
+}
+
+void MEDCouplingBasicsTest::testAreCellsIncludedIn1()
+{
+  MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
+  const int pt[2]={1,3};
+  MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->buildPartOfMySelf(pt,pt+2,true);
+  DataArrayInt *tmp;
+  CPPUNIT_ASSERT(m->areCellsIncludedIn(m2,0,tmp));
+  CPPUNIT_ASSERT_EQUAL(2,tmp->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(1,tmp->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(pt[0],tmp->getIJ(0,0));
+  CPPUNIT_ASSERT_EQUAL(pt[1],tmp->getIJ(0,1));
+  tmp->decrRef();
+  CPPUNIT_ASSERT(!m2->areCellsIncludedIn(m,0,tmp));
+  tmp->decrRef();
+  m2->decrRef();
+  m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIBuildSubstraction1()
+{
+  DataArrayInt *a=DataArrayInt::New();
+  const int aa[]={2,3,6,8,9};
+  a->alloc(5,1);
+  std::copy(aa,aa+5,a->getPointer());
+  DataArrayInt *b=DataArrayInt::New();
+  const int bb[]={1,3,5,9,11};
+  b->alloc(5,1);
+  std::copy(bb,bb+5,b->getPointer());
+  //
+  DataArrayInt *c=a->buildSubstraction(b);
+  CPPUNIT_ASSERT_EQUAL(3,c->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(1,c->getNumberOfComponents());
+  const int expected1[3]={2,6,8};
+  CPPUNIT_ASSERT(std::equal(expected1,expected1+3,c->getConstPointer()));
+  //
+  c->decrRef();
+  b->decrRef();
+  a->decrRef();
+}
+
+void MEDCouplingBasicsTest::testBuildOrthogonalField2()
+{
+  MEDCouplingUMesh *m=build2DTargetMesh_1();
+  DataArrayInt *d1=DataArrayInt::New();
+  DataArrayInt *d2=DataArrayInt::New();
+  DataArrayInt *d3=DataArrayInt::New();
+  DataArrayInt *d4=DataArrayInt::New();
+  MEDCouplingUMesh *m1=m->buildDescendingConnectivity(d1,d2,d3,d4);
+  //
+  MEDCouplingFieldDouble *f1=m1->buildOrthogonalField();
+  DataArrayDouble *da1=f1->getArray();
+  CPPUNIT_ASSERT_EQUAL(2,da1->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(13,da1->getNumberOfTuples());
+  //
+  const double expected1[26]={-1.,0.,0.,1.,1.,0.,0.,-1.,0.707106781186548,0.707106781186548,0.,-1.,0.,1.,1.,0.,0.,1.,1.,0.,-1.,0.,0.,1.,1.,0.};
+  for(int i=0;i<26;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da1->getIJ(0,i),1e-14);
+  //
+  f1->decrRef();
+  m1->decrRef();
+  d1->decrRef();
+  d2->decrRef();
+  d3->decrRef();
+  d4->decrRef();
+  m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMInsertNextCell1()
+{
+  double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
+  int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
+  MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
+  targetMesh->allocateCells(5);
+  CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn),INTERP_KERNEL::Exception);
+  targetMesh->setMeshDimension(2);
+  targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
+  CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn),INTERP_KERNEL::Exception);
+  CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn),INTERP_KERNEL::Exception);
+  CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,1,targetConn),INTERP_KERNEL::Exception);
+  targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
+  targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
+  targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
+  targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
+  targetMesh->finishInsertingCells();
+  DataArrayDouble *myCoords=DataArrayDouble::New();
+  myCoords->alloc(9,2);
+  std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
+  targetMesh->setCoords(myCoords);
+  myCoords->decrRef();
+  targetMesh->checkCoherency();
+  targetMesh->decrRef();
+}
+
+void MEDCouplingBasicsTest::testFieldOperatorDivDiffComp1()
+{
+  MEDCouplingUMesh *m=build2DTargetMesh_1();
+  DataArrayInt *d1=DataArrayInt::New();
+  DataArrayInt *d2=DataArrayInt::New();
+  DataArrayInt *d3=DataArrayInt::New();
+  DataArrayInt *d4=DataArrayInt::New();
+  MEDCouplingUMesh *m1=m->buildDescendingConnectivity(d1,d2,d3,d4);
+  //
+  MEDCouplingFieldDouble *f1=m1->buildOrthogonalField();
+  const double arr1[13]={2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.};
+  DataArrayDouble *arr=DataArrayDouble::New();
+  arr->alloc(13,1);
+  std::copy(arr1,arr1+13,arr->getPointer());
+  MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_CELLS);
+  f2->setArray(arr);
+  f2->setMesh(m1);
+  f2->checkCoherency();
+  //
+  MEDCouplingFieldDouble *f3=(*f1)/(*f2);
+  CPPUNIT_ASSERT_THROW((*f2)/(*f1),INTERP_KERNEL::Exception);
+  f3->checkCoherency();
+  (*f1)/=(*f2);
+  CPPUNIT_ASSERT(f1->isEqual(f3,1e-10,1e-10));
+  CPPUNIT_ASSERT_THROW((*f2)/=(*f1),INTERP_KERNEL::Exception);
+  const double expected1[26]={-0.5, 0.0, 0.0, 0.33333333333333331, 0.25, 0.0, 0.0, -0.20000000000000001, 0.117851130197758, 0.117851130197758, 0.0, -0.14285714285714285, 0.0, 0.125, 0.1111111111111111, 0.0, 0.0, 0.10000000000000001, 0.090909090909090912, 0.0, -0.083333333333333329, 0.0, 0.0, 0.076923076923076927, 0.071428571428571425, 0.0};
+  for(int i=0;i<26;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f3->getIJ(0,i),1e-10);
+  //
+  f3->decrRef();
+  f2->decrRef();
+  arr->decrRef();
+  f1->decrRef();
+  m1->decrRef();
+  d1->decrRef();
+  d2->decrRef();
+  d3->decrRef();
+  d4->decrRef();
+  m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDARearrange1()
+{
+  DataArrayInt *da1=DataArrayInt::New();
+  da1->alloc(12,1);
+  da1->iota(0);
+  const int *ptr=da1->getConstPointer();
+  //
+  CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(12,da1->getNumberOfTuples());
+  da1->rearrange(4);
+  CPPUNIT_ASSERT(ptr==da1->getConstPointer());
+  CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfTuples());
+  for(int i=0;i<12;i++)
+    CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i));
+  //
+  da1->rearrange(6);
+  CPPUNIT_ASSERT(ptr==da1->getConstPointer());
+  CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(6,da1->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(2,da1->getNumberOfTuples());
+  for(int i=0;i<12;i++)
+    CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i));
+  //
+  CPPUNIT_ASSERT_THROW(da1->rearrange(7),INTERP_KERNEL::Exception);
+  //
+  da1->rearrange(12);
+  CPPUNIT_ASSERT(ptr==da1->getConstPointer());
+  CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(12,da1->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfTuples());
+  for(int i=0;i<12;i++)
+    CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i));
+  //
+  da1->rearrange(3);
+  CPPUNIT_ASSERT(ptr==da1->getConstPointer());
+  CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples());
+  for(int i=0;i<12;i++)
+    CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i));
+  //double
+  DataArrayDouble *da2=da1->convertToDblArr();
+  da1->decrRef();
+  const double *ptr2=da2->getConstPointer();
+  //
+  CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
+  da2->rearrange(4);
+  CPPUNIT_ASSERT(ptr2==da2->getConstPointer());
+  CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfTuples());
+  for(int i=0;i<12;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14);
+  //
+  da2->rearrange(6);
+  CPPUNIT_ASSERT(ptr2==da2->getConstPointer());
+  CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(6,da2->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(2,da2->getNumberOfTuples());
+  for(int i=0;i<12;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14);
+  //
+  CPPUNIT_ASSERT_THROW(da2->rearrange(7),INTERP_KERNEL::Exception);
+  //
+  da2->rearrange(1);
+  CPPUNIT_ASSERT(ptr2==da2->getConstPointer());
+  CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(12,da2->getNumberOfTuples());
+  for(int i=0;i<12;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14);
+  //
+  da2->rearrange(3);
+  CPPUNIT_ASSERT(ptr2==da2->getConstPointer());
+  CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
+  for(int i=0;i<12;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14);
+  da2->decrRef();
+}
+
+void MEDCouplingBasicsTest::testGetDifferentValues1()
+{
+  DataArrayInt *da1=DataArrayInt::New();
+  const int arr[12]={1,2,3,2,2,3,5,1,5,5,2,2};
+  da1->alloc(4,3);
+  std::copy(arr,arr+12,da1->getPointer());
+  std::set<int> s=da1->getDifferentValues();
+  const int expected1[4]={1,2,3,5};
+  CPPUNIT_ASSERT_EQUAL(4,(int)s.size());
+  CPPUNIT_ASSERT(std::equal(expected1,expected1+4,s.begin()));
+  da1->decrRef();
+}
+
diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i
new file mode 100644 (file)
index 0000000..57fd239
--- /dev/null
@@ -0,0 +1,1727 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module MEDCoupling
+
+#define MEDCOUPLING_EXPORT
+
+%include std_vector.i
+%include std_string.i
+
+%{
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingExtrudedMesh.hxx"
+#include "MEDCouplingCMesh.hxx"
+#include "MEDCouplingField.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingGaussLocalization.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MEDCouplingTypemaps.i"
+
+#include "InterpKernelAutoPtr.hxx"
+
+using namespace ParaMEDMEM;
+using namespace INTERP_KERNEL;
+%}
+
+%template(ivec) std::vector<int>;
+%template(dvec) std::vector<double>;
+%template(svec) std::vector<std::string>;
+
+%typemap(out) ParaMEDMEM::MEDCouplingMesh*
+{
+  $result=convertMesh($1,$owner);
+}
+
+%typemap(out) ParaMEDMEM::MEDCouplingPointSet*
+{
+  $result=convertMesh($1,$owner);
+}
+
+#ifdef WITH_NUMPY2
+%init %{ import_array(); %}
+#endif
+
+%feature("autodoc", "1");
+%feature("docstring");
+
+%newobject ParaMEDMEM::MEDCouplingField::buildMeasureField;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::New;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::getArray;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::getEndArray;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::mergeFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::meldFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::doublyContractedProduct;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::determinant;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::eigenValues;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::eigenVectors;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::inverse;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::trace;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::deviator;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::magnitude;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::maxPerTuple;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::keepSelectedComponents;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::dotFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::dot;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::crossProductFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::crossProduct;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::maxFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::max;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::minFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::min;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::getIdsInRange;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator+;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator-;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator*;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator/;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::clone;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::cloneWithMesh;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::deepCpy;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildNewTimeReprFromThis;
+%newobject ParaMEDMEM::DataArrayInt::New;
+%newobject ParaMEDMEM::DataArrayInt::convertToDblArr;
+%newobject ParaMEDMEM::DataArrayInt::deepCpy;
+%newobject ParaMEDMEM::DataArrayInt::performCpy;
+%newobject ParaMEDMEM::DataArrayInt::substr;
+%newobject ParaMEDMEM::DataArrayInt::changeNbOfComponents;
+%newobject ParaMEDMEM::DataArrayInt::keepSelectedComponents;
+%newobject ParaMEDMEM::DataArrayInt::selectByTupleId;
+%newobject ParaMEDMEM::DataArrayInt::selectByTupleIdSafe;
+%newobject ParaMEDMEM::DataArrayInt::renumber;
+%newobject ParaMEDMEM::DataArrayInt::renumberR;
+%newobject ParaMEDMEM::DataArrayInt::renumberAndReduce;
+%newobject ParaMEDMEM::DataArrayInt::invertArrayO2N2N2O;
+%newobject ParaMEDMEM::DataArrayInt::invertArrayN2O2O2N;
+%newobject ParaMEDMEM::DataArrayInt::getIdsEqual;
+%newobject ParaMEDMEM::DataArrayInt::getIdsEqualList;
+%newobject ParaMEDMEM::DataArrayInt::aggregate;
+%newobject ParaMEDMEM::DataArrayInt::meld;
+%newobject ParaMEDMEM::DataArrayInt::fromNoInterlace;
+%newobject ParaMEDMEM::DataArrayInt::toNoInterlace;
+%newobject ParaMEDMEM::DataArrayInt::buildComplement;
+%newobject ParaMEDMEM::DataArrayInt::buildUnion;
+%newobject ParaMEDMEM::DataArrayInt::buildSubstraction;
+%newobject ParaMEDMEM::DataArrayInt::buildIntersection;
+%newobject ParaMEDMEM::DataArrayInt::deltaShiftIndex;
+%newobject ParaMEDMEM::DataArrayDouble::New;
+%newobject ParaMEDMEM::DataArrayDouble::convertToIntArr;
+%newobject ParaMEDMEM::DataArrayDouble::deepCpy;
+%newobject ParaMEDMEM::DataArrayDouble::performCpy;
+%newobject ParaMEDMEM::DataArrayDouble::aggregate;
+%newobject ParaMEDMEM::DataArrayDouble::meld;
+%newobject ParaMEDMEM::DataArrayDouble::dot;
+%newobject ParaMEDMEM::DataArrayDouble::crossProduct;
+%newobject ParaMEDMEM::DataArrayDouble::add;
+%newobject ParaMEDMEM::DataArrayDouble::substract;
+%newobject ParaMEDMEM::DataArrayDouble::multiply;
+%newobject ParaMEDMEM::DataArrayDouble::divide;
+%newobject ParaMEDMEM::DataArrayDouble::substr;
+%newobject ParaMEDMEM::DataArrayDouble::changeNbOfComponents;
+%newobject ParaMEDMEM::DataArrayDouble::keepSelectedComponents;
+%newobject ParaMEDMEM::DataArrayDouble::getIdsInRange;
+%newobject ParaMEDMEM::DataArrayDouble::selectByTupleId;
+%newobject ParaMEDMEM::DataArrayDouble::selectByTupleIdSafe;
+%newobject ParaMEDMEM::DataArrayDouble::applyFunc;
+%newobject ParaMEDMEM::DataArrayDouble::doublyContractedProduct;
+%newobject ParaMEDMEM::DataArrayDouble::determinant;
+%newobject ParaMEDMEM::DataArrayDouble::eigenValues;
+%newobject ParaMEDMEM::DataArrayDouble::eigenVectors;
+%newobject ParaMEDMEM::DataArrayDouble::inverse;
+%newobject ParaMEDMEM::DataArrayDouble::trace;
+%newobject ParaMEDMEM::DataArrayDouble::deviator;
+%newobject ParaMEDMEM::DataArrayDouble::magnitude;
+%newobject ParaMEDMEM::DataArrayDouble::maxPerTuple;
+%newobject ParaMEDMEM::DataArrayDouble::renumber;
+%newobject ParaMEDMEM::DataArrayDouble::renumberR;
+%newobject ParaMEDMEM::DataArrayDouble::renumberAndReduce;
+%newobject ParaMEDMEM::DataArrayDouble::fromNoInterlace;
+%newobject ParaMEDMEM::DataArrayDouble::toNoInterlace;
+%newobject ParaMEDMEM::DataArrayDouble::fromPolarToCart;
+%newobject ParaMEDMEM::DataArrayDouble::fromCylToCart;
+%newobject ParaMEDMEM::DataArrayDouble::fromSpherToCart;
+%newobject ParaMEDMEM::MEDCouplingMesh::getCoordinatesAndOwner;
+%newobject ParaMEDMEM::MEDCouplingMesh::getBarycenterAndOwner;
+%newobject ParaMEDMEM::MEDCouplingMesh::buildOrthogonalField;
+%newobject ParaMEDMEM::MEDCouplingMesh::getCellIdsFullyIncludedInNodeIds;
+%newobject ParaMEDMEM::MEDCouplingMesh::mergeMyselfWith;
+%newobject ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic;
+%newobject ParaMEDMEM::MEDCouplingMesh::getMeasureField;
+%newobject ParaMEDMEM::MEDCouplingMesh::simplexize;
+%newobject ParaMEDMEM::MEDCouplingMesh::buildUnstructured;
+%newobject ParaMEDMEM::MEDCouplingPointSet::zipCoordsTraducer;
+%newobject ParaMEDMEM::MEDCouplingPointSet::buildBoundaryMesh;
+%newobject ParaMEDMEM::MEDCouplingPointSet::mergeNodesArray;
+%newobject ParaMEDMEM::MEDCouplingPointSet::buildInstanceFromMeshType;
+%newobject ParaMEDMEM::MEDCouplingUMesh::New;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivity;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivityIndex;
+%newobject ParaMEDMEM::MEDCouplingUMesh::clone;
+%newobject ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer;
+%newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity;
+%newobject ParaMEDMEM::MEDCouplingUMesh::buildExtrudedMesh;
+%newobject ParaMEDMEM::MEDCouplingUMesh::mergeUMeshes;
+%newobject ParaMEDMEM::MEDCouplingUMesh::mergeUMeshesOnSameCoords;
+%newobject ParaMEDMEM::MEDCouplingUMesh::buildNewNumberingFromCommNodesFrmt;
+%newobject ParaMEDMEM::MEDCouplingUMesh::rearrange2ConsecutiveCellTypes;
+%newobject ParaMEDMEM::MEDCouplingUMesh::convertCellArrayPerGeoType;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec;
+%newobject ParaMEDMEM::MEDCouplingUMesh::buildDirectionVectorField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getEdgeRatioField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getAspectRatioField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getWarpField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getSkewField;
+%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::New;
+%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::build3DUnstructuredMesh;
+%newobject ParaMEDMEM::MEDCouplingCMesh::New;
+%newobject ParaMEDMEM::MEDCouplingCMesh::getCoordsAt;
+%feature("unref") DataArrayDouble "$this->decrRef();"
+%feature("unref") MEDCouplingPointSet "$this->decrRef();"
+%feature("unref") MEDCouplingMesh "$this->decrRef();"
+%feature("unref") MEDCouplingUMesh "$this->decrRef();"
+%feature("unref") MEDCouplingExtrudedMesh "$this->decrRef();"
+%feature("unref") MEDCouplingCMesh "$this->decrRef();"
+%feature("unref") DataArrayInt "$this->decrRef();"
+%feature("unref") MEDCouplingField "$this->decrRef();"
+%feature("unref") MEDCouplingFieldDouble "$this->decrRef();"
+
+%rename(assign) *::operator=;
+%ignore ParaMEDMEM::MemArray::operator=;
+%ignore ParaMEDMEM::MemArray::operator[];
+%ignore ParaMEDMEM::MEDCouplingPointSet::getCoords();
+%ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo;
+%ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationDblInfo;
+%ignore ParaMEDMEM::MEDCouplingGaussLocalization::fillWithValues;
+%ignore ParaMEDMEM::MEDCouplingGaussLocalization::buildNewInstanceFromTinyInfo;
+
+%rename (Exception) InterpKernelException;
+%nodefaultctor;
+
+namespace INTERP_KERNEL
+{
+  class Exception
+  {
+  public:
+    Exception(const char* what);
+    ~Exception() throw ();
+    const char *what() const throw ();
+  };
+}
+
+%include "MEDCouplingTimeLabel.hxx"
+%include "MEDCouplingRefCountObject.hxx"
+
+namespace ParaMEDMEM
+{
+  typedef enum
+    {
+      UNSTRUCTURED = 5,
+      UNSTRUCTURED_DESC = 6,
+      CARTESIAN = 7,
+      EXTRUDED = 8
+    } MEDCouplingMeshType;
+
+  class DataArrayInt;
+  class DataArrayDouble;
+  class MEDCouplingUMesh;
+  class MEDCouplingFieldDouble;
+
+  class MEDCouplingMesh : public RefCountObject, public TimeLabel
+  {
+  public:
+    void setName(const char *name) { _name=name; }
+    const char *getName() const { return _name.c_str(); }
+    virtual MEDCouplingMeshType getType() const throw(INTERP_KERNEL::Exception) = 0;
+    bool isStructured() const throw(INTERP_KERNEL::Exception);
+    virtual bool isEqual(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception);
+    virtual bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception) = 0;
+    virtual void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
+    virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0;
+    virtual int getNumberOfCells() const throw(INTERP_KERNEL::Exception) = 0;
+    virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception) = 0;
+    virtual int getSpaceDimension() const throw(INTERP_KERNEL::Exception) = 0;
+    virtual int getMeshDimension() const throw(INTERP_KERNEL::Exception) = 0;
+    virtual DataArrayDouble *getCoordinatesAndOwner() const throw(INTERP_KERNEL::Exception) = 0;
+    virtual DataArrayDouble *getBarycenterAndOwner() const throw(INTERP_KERNEL::Exception) = 0;
+    virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception) = 0;
+    virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const throw(INTERP_KERNEL::Exception) = 0;
+    virtual std::string simpleRepr() const = 0;
+    virtual std::string advancedRepr() const = 0;
+    // tools
+    virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception) = 0;
+    virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const throw(INTERP_KERNEL::Exception) = 0;
+    virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception);
+    virtual MEDCouplingFieldDouble *buildOrthogonalField() const throw(INTERP_KERNEL::Exception) = 0;
+    virtual MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
+    virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception) = 0;
+    virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception);
+    virtual DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
+    static MEDCouplingMesh *mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2) throw(INTERP_KERNEL::Exception);
+    %extend
+       {
+         std::string __str__() const
+         {
+           return self->simpleRepr();
+         }
+
+         int getCellContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception)
+         {
+           int sz;
+           double *pos=convertPyToNewDblArr2(p,&sz);
+           int ret=self->getCellContainingPoint(pos,eps);
+           delete [] pos;
+           return ret;
+         }
+         
+         void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception)
+         {
+           int size;
+           INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+           self->renumberCells(tmp,check);
+         }
+
+         PyObject *checkGeoEquivalWith(const MEDCouplingMesh *other, int levOfCheck, double prec) const throw(INTERP_KERNEL::Exception)
+         {
+           DataArrayInt *cellCor, *nodeCor;
+           self->checkGeoEquivalWith(other,levOfCheck,prec,cellCor,nodeCor);
+           PyObject *res = PyList_New(2);
+           PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(cellCor),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, cellCor?SWIG_POINTER_OWN | 0:0 ));
+           PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(nodeCor),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, nodeCor?SWIG_POINTER_OWN | 0:0 ));
+           return res;
+         }
+         DataArrayInt *getCellIdsFullyIncludedInNodeIds(PyObject *li) const throw(INTERP_KERNEL::Exception)
+         {
+           int size;
+           INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+           DataArrayInt *ret=self->getCellIdsFullyIncludedInNodeIds(tmp,tmp+size);
+           return ret;
+         }
+         PyObject *getNodeIdsOfCell(int cellId) const throw(INTERP_KERNEL::Exception)
+         {
+           std::vector<int> conn;
+           self->getNodeIdsOfCell(cellId,conn);
+           return convertIntArrToPyList2(conn);
+         }
+
+         PyObject *getCoordinatesOfNode(int nodeId) const throw(INTERP_KERNEL::Exception)
+         {
+           std::vector<double> coo;
+           self->getCoordinatesOfNode(nodeId,coo);
+           return convertDblArrToPyList2(coo);
+         }
+
+         void scale(PyObject *point, double factor) throw(INTERP_KERNEL::Exception)
+         {
+           int sz;
+           double *p=convertPyToNewDblArr2(point,&sz);
+           self->scale(p,factor);
+           delete [] p;
+         }
+
+         PyObject *getBoundingBox() const throw(INTERP_KERNEL::Exception)
+         {
+           int spaceDim=self->getSpaceDimension();
+           double *tmp=new double[2*spaceDim];
+           self->getBoundingBox(tmp);
+           PyObject *ret=convertDblArrToPyListOfTuple(tmp,2,spaceDim);
+           delete [] tmp;
+           return ret;
+         }
+
+        PyObject *buildPart(PyObject *li) const throw(INTERP_KERNEL::Exception)
+         {
+           int size;
+           INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+           MEDCouplingMesh *ret=self->buildPart(tmp,tmp+size);
+           return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+         }
+
+        PyObject *buildPartAndReduceNodes(PyObject *li) const throw(INTERP_KERNEL::Exception)
+        {
+          int size;
+          INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+          DataArrayInt *arr=0;
+          MEDCouplingMesh *ret=self->buildPartAndReduceNodes(tmp,tmp+size,arr);
+          PyObject *res = PyList_New(2);
+          PyObject *obj0=convertMesh(ret, SWIG_POINTER_OWN | 0 );
+          PyObject *obj1=SWIG_NewPointerObj(SWIG_as_voidptr(arr),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
+          PyList_SetItem(res,0,obj0);
+          PyList_SetItem(res,1,obj1);
+          return res;
+        }
+
+         void translate(PyObject *vector) throw(INTERP_KERNEL::Exception)
+         {
+           int sz;
+           INTERP_KERNEL::AutoPtr<double> v=convertPyToNewDblArr2(vector,&sz);
+           self->translate(v);
+         }
+
+         void rotate(PyObject *center, PyObject *vector, double alpha) throw(INTERP_KERNEL::Exception)
+         {
+           int sz;
+           INTERP_KERNEL::AutoPtr<double> c=convertPyToNewDblArr2(center,&sz);
+           if(!c)
+             return ;
+           INTERP_KERNEL::AutoPtr<double> v=convertPyToNewDblArr2(vector,&sz);
+           if(!v)
+             { return ; }
+           self->rotate(c,v,alpha);
+         }
+       }
+  };
+}
+
+%include "MEDCouplingMemArray.hxx"
+%include "NormalizedUnstructuredMesh.hxx"
+%include "MEDCouplingNatureOfField.hxx"
+%include "MEDCouplingTimeDiscretization.hxx"
+%include "MEDCouplingGaussLocalization.hxx"
+
+namespace ParaMEDMEM
+{
+  class MEDCouplingPointSet : public ParaMEDMEM::MEDCouplingMesh
+    {
+    public:
+      void updateTime();
+      void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
+      DataArrayDouble *getCoordinatesAndOwner() const throw(INTERP_KERNEL::Exception);
+      bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const throw(INTERP_KERNEL::Exception);
+      void zipCoords() throw(INTERP_KERNEL::Exception);
+      double getCaracteristicDimension() const throw(INTERP_KERNEL::Exception);
+      void changeSpaceDimension(int newSpaceDim, double dftVal=0.) throw(INTERP_KERNEL::Exception);
+      void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
+      virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0;
+      static DataArrayDouble *mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception);
+      static MEDCouplingPointSet *buildInstanceFromMeshType(MEDCouplingMeshType type) throw(INTERP_KERNEL::Exception);
+      virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const throw(INTERP_KERNEL::Exception) = 0;
+      virtual bool isEmptyMesh(const std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception) = 0;
+      //! size of returned tinyInfo must be always the same.
+      void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const throw(INTERP_KERNEL::Exception);
+      void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const throw(INTERP_KERNEL::Exception);
+      void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const throw(INTERP_KERNEL::Exception);
+      void unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+                           const std::vector<std::string>& littleStrings) throw(INTERP_KERNEL::Exception);
+      virtual void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems) throw(INTERP_KERNEL::Exception) = 0;
+      virtual DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception) = 0;
+      %extend 
+         {
+           std::string __str__() const
+           {
+             return self->simpleRepr();
+           }
+           
+           PyObject *buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex) const throw(INTERP_KERNEL::Exception)
+           {
+             int newNbOfNodes;
+             DataArrayInt *ret0=self->buildNewNumberingFromCommonNodesFormat(comm,commIndex,newNbOfNodes);
+             PyObject *res = PyList_New(2);
+             PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+             PyList_SetItem(res,1,SWIG_From_int(newNbOfNodes));
+             return res;
+           }
+           
+           PyObject *findCommonNodes(int limitNodeId, double prec) const throw(INTERP_KERNEL::Exception)
+           {
+             DataArrayInt *comm, *commIndex;
+             self->findCommonNodes(limitNodeId,prec,comm,commIndex);
+             PyObject *res = PyList_New(2);
+             PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(comm),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+             PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(commIndex),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+             return res;
+           }
+           
+           PyObject *getCoords() const throw(INTERP_KERNEL::Exception)
+           {
+             DataArrayDouble *ret1=self->getCoords();
+             ret1->incrRef();
+             return SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,SWIG_POINTER_OWN | 0);
+           }
+           PyObject *buildPartOfMySelf(PyObject *li, bool keepCoords) const throw(INTERP_KERNEL::Exception)
+           {
+             int size;
+             INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+             MEDCouplingPointSet *ret=self->buildPartOfMySelf(tmp,tmp+size,keepCoords);
+             return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+           }
+           PyObject *buildPartOfMySelfNode(PyObject *li, bool fullyIn) const throw(INTERP_KERNEL::Exception)
+           {
+             int size;
+             INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+             MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(tmp,(int *)tmp+size,fullyIn);
+             return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+           }
+           PyObject *buildFacePartOfMySelfNode(PyObject *li, bool fullyIn) const throw(INTERP_KERNEL::Exception)
+           {
+             int size;
+             INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+             MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(tmp,(int *)tmp+size,fullyIn);
+             return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+           }
+           PyObject *findBoundaryNodes() const throw(INTERP_KERNEL::Exception)
+           {
+             std::vector<int> nodes;
+             self->findBoundaryNodes(nodes);
+             return convertIntArrToPyList2(nodes);
+           }
+           void renumberNodes(PyObject *li, int newNbOfNodes) throw(INTERP_KERNEL::Exception)
+           {
+             int size;
+             INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+             self->renumberNodes(tmp,newNbOfNodes);
+           }
+           void renumberNodes2(PyObject *li, int newNbOfNodes) throw(INTERP_KERNEL::Exception)
+           {
+             int size;
+             INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+             self->renumberNodes2(tmp,newNbOfNodes);
+           }
+           PyObject *findNodesOnPlane(PyObject *pt, PyObject *vec, double eps) const throw(INTERP_KERNEL::Exception)
+             {
+               std::vector<int> nodes;
+               int sz;
+               double *p=convertPyToNewDblArr2(pt,&sz);
+               double *v=convertPyToNewDblArr2(vec,&sz);
+               self->findNodesOnPlane(p,v,eps,nodes);
+               delete [] v;
+               delete [] p;
+               return convertIntArrToPyList2(nodes);
+             }
+           PyObject *getNodeIdsNearPoint(PyObject *pt, double eps) const throw(INTERP_KERNEL::Exception)
+           {
+             int size;
+             double *pos=convertPyToNewDblArr2(pt,&size);
+             if(size<self->getSpaceDimension())
+               {
+                 delete [] pos;
+                 throw INTERP_KERNEL::Exception("getNodeIdsNearPoint : to tiny array ! must be at least of size SpaceDim !");
+               }
+             std::vector<int> tmp;
+             try
+               {
+                 tmp=self->getNodeIdsNearPoint(pos,eps);
+               }
+             catch(INTERP_KERNEL::Exception& e)
+               {
+                 delete [] pos;
+                 throw e;
+               }
+             delete [] pos;
+             return convertIntArrToPyList2(tmp);
+           }
+
+           PyObject *getNodeIdsNearPoints(PyObject *pt, int nbOfNodes, double eps) const throw(INTERP_KERNEL::Exception)
+           {
+             std::vector<int> c,cI;
+             int size;
+             double *pos=convertPyToNewDblArr2(pt,&size);
+             if(size<self->getSpaceDimension()*nbOfNodes)
+               {
+                 delete [] pos;
+                 throw INTERP_KERNEL::Exception("getNodeIdsNearPoints : to tiny array ! must be at least of size SpaceDim*nbOfNodes !");
+               }
+             try
+               {
+                 self->getNodeIdsNearPoints(pos,nbOfNodes,eps,c,cI);
+               }
+             catch(INTERP_KERNEL::Exception& e)
+               {
+                 delete [] pos;
+                 throw e;
+               }
+             delete [] pos;
+             PyObject *ret=PyTuple_New(2);
+             PyTuple_SetItem(ret,0,convertIntArrToPyList2(c));
+             PyTuple_SetItem(ret,1,convertIntArrToPyList2(cI));
+             return ret;
+           }
+
+           PyObject *giveElemsInBoundingBox(PyObject *bbox, double eps) throw(INTERP_KERNEL::Exception)
+           {
+             std::vector<int> elems;
+             int size;
+             double *tmp=convertPyToNewDblArr2(bbox,&size);
+             self->giveElemsInBoundingBox(tmp,eps,elems);
+             delete [] tmp;
+             return convertIntArrToPyList2(elems);
+           }
+
+           static void rotate2DAlg(PyObject *center, double angle, int nbNodes, PyObject *coords) throw(INTERP_KERNEL::Exception)
+           {
+             int sz;
+             double *c=convertPyToNewDblArr2(center,&sz);
+             double *coo=convertPyToNewDblArr2(coords,&sz);
+             ParaMEDMEM::MEDCouplingPointSet::rotate2DAlg(c,angle,nbNodes,coo);
+             for(int i=0;i<sz;i++)
+               PyList_SetItem(coords,i,PyFloat_FromDouble(coo[i]));
+             delete [] coo;
+             delete [] c;
+           }
+           static void rotate3DAlg(PyObject *center, PyObject *vect, double angle, int nbNodes, PyObject *coords) throw(INTERP_KERNEL::Exception)
+           {
+             int sz,sz2;
+             double *c=convertPyToNewDblArr2(center,&sz);
+             double *coo=convertPyToNewDblArr2(coords,&sz);
+             double *v=convertPyToNewDblArr2(vect,&sz2);
+             ParaMEDMEM::MEDCouplingPointSet::rotate3DAlg(c,v,angle,nbNodes,coo);
+             for(int i=0;i<sz;i++)
+               PyList_SetItem(coords,i,PyFloat_FromDouble(coo[i]));
+             delete [] coo;
+             delete [] c;
+           }
+         }
+    };
+  
+  class MEDCouplingUMesh : public ParaMEDMEM::MEDCouplingPointSet
+  {
+  public:
+    static MEDCouplingUMesh *New();
+    static MEDCouplingUMesh *New(const char *meshName, int meshDim);
+    MEDCouplingUMesh *clone(bool recDeepCpy) const;
+    void updateTime();
+    void checkCoherency() const throw(INTERP_KERNEL::Exception);
+    void setMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception);
+    void allocateCells(int nbOfCells) throw(INTERP_KERNEL::Exception);
+    void finishInsertingCells() throw(INTERP_KERNEL::Exception);
+    void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true) throw(INTERP_KERNEL::Exception);
+    INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const throw(INTERP_KERNEL::Exception);
+    int getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception);
+    int getMeshLength() const throw(INTERP_KERNEL::Exception);
+    void computeTypes() throw(INTERP_KERNEL::Exception);
+    std::string reprConnectivityOfThis() const throw(INTERP_KERNEL::Exception);
+    //tools
+    bool checkConsecutiveCellTypes() const throw(INTERP_KERNEL::Exception);
+    DataArrayInt *rearrange2ConsecutiveCellTypes() throw(INTERP_KERNEL::Exception);
+    DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception);
+    DataArrayInt *zipConnectivityTraducer(int compType) throw(INTERP_KERNEL::Exception);
+    void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const throw(INTERP_KERNEL::Exception);
+    MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception);
+    void orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Exception);
+    bool isPresenceOfQuadratic() const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *buildDirectionVectorField() const throw(INTERP_KERNEL::Exception);
+    bool isContiguous1D() const throw(INTERP_KERNEL::Exception);
+    void convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception);
+    void convertDegeneratedCells() throw(INTERP_KERNEL::Exception);
+    bool areOnlySimplexCells() const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *getEdgeRatioField() const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *getAspectRatioField() const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *getWarpField() const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception);
+    static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
+    static MEDCouplingUMesh *mergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
+    %extend {
+      std::string __str__() const
+      {
+        return self->simpleRepr();
+      }
+      void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, PyObject *li) throw(INTERP_KERNEL::Exception)
+      {
+        int sz;
+        INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&sz);
+        self->insertNextCell(type,size,tmp);
+      }
+      DataArrayInt *getNodalConnectivity() const throw(INTERP_KERNEL::Exception)
+      {
+        DataArrayInt *ret=self->getNodalConnectivity();
+        if(ret)
+          ret->incrRef();
+        return ret;
+      }
+      DataArrayInt *getNodalConnectivityIndex() const throw(INTERP_KERNEL::Exception)
+      {
+        DataArrayInt *ret=self->getNodalConnectivityIndex();
+        if(ret)
+          ret->incrRef();
+        return ret;
+      }
+      PyObject *getAllTypes() const throw(INTERP_KERNEL::Exception)
+      {
+        std::set<INTERP_KERNEL::NormalizedCellType> result=self->getAllTypes();
+        std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iL=result.begin();
+        PyObject *res = PyList_New(result.size());
+        for (int i=0;iL!=result.end(); i++, iL++)
+          PyList_SetItem(res,i,PyInt_FromLong(*iL));
+        return res;
+      }
+      PyObject *mergeNodes(double precision) throw(INTERP_KERNEL::Exception)
+      {
+        bool ret1;
+        int ret2;
+        DataArrayInt *ret0=self->mergeNodes(precision,ret1,ret2);
+        PyObject *res = PyList_New(3);
+        PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        PyList_SetItem(res,1,SWIG_From_bool(ret1));
+        PyList_SetItem(res,2,SWIG_From_int(ret2));
+        return res;
+      }
+      PyObject *mergeNodes2(double precision) throw(INTERP_KERNEL::Exception)
+      {
+        bool ret1;
+        int ret2;
+        DataArrayInt *ret0=self->mergeNodes2(precision,ret1,ret2);
+        PyObject *res = PyList_New(3);
+        PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        PyList_SetItem(res,1,SWIG_From_bool(ret1));
+        PyList_SetItem(res,2,SWIG_From_int(ret2));
+        return res;
+      }
+      PyObject *checkButterflyCells() throw(INTERP_KERNEL::Exception)
+      {
+        std::vector<int> cells;
+        self->checkButterflyCells(cells);
+        return convertIntArrToPyList2(cells);
+      }
+
+      PyObject *splitByType() const throw(INTERP_KERNEL::Exception)
+      {
+        std::vector<MEDCouplingUMesh *> ms=self->splitByType();
+        int sz=ms.size();
+        PyObject *ret = PyList_New(sz);
+        for(int i=0;i<sz;i++)
+          PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(ms[i]),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
+        return ret;
+      }
+
+      PyObject *keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, PyObject *ids) const throw(INTERP_KERNEL::Exception)
+      {
+        std::vector<int> idsPerGeoType;
+        convertPyToNewIntArr3(ids,idsPerGeoType);
+        MEDCouplingUMesh *ret=self->keepSpecifiedCells(type,idsPerGeoType);
+        return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 );
+      }
+
+      bool checkConsecutiveCellTypesAndOrder(PyObject *li) const throw(INTERP_KERNEL::Exception)
+      {
+        int sz;
+        INTERP_KERNEL::AutoPtr<INTERP_KERNEL::NormalizedCellType> order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz);
+        bool ret=self->checkConsecutiveCellTypesAndOrder(order,order+sz);
+        return ret;
+      }
+
+      DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(PyObject *li) const throw(INTERP_KERNEL::Exception)
+      {
+        int sz;
+        INTERP_KERNEL::AutoPtr<INTERP_KERNEL::NormalizedCellType> order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz);
+        DataArrayInt *ret=self->getRenumArrForConsecutiveCellTypesSpec(order,(INTERP_KERNEL::NormalizedCellType *)order+sz);
+        return ret;
+      }
+
+      PyObject *getCellsContainingPoints(PyObject *p, int nbOfPoints, double eps) const throw(INTERP_KERNEL::Exception)
+      {
+        int sz;
+        double *pos=convertPyToNewDblArr2(p,&sz);
+        std::vector<int> elts,eltsIndex;
+        self->getCellsContainingPoints(pos,nbOfPoints,eps,elts,eltsIndex);
+        delete [] pos;
+        PyObject *ret=PyList_New(2);
+        PyList_SetItem(ret,0,convertIntArrToPyList2(elts));
+        PyList_SetItem(ret,1,convertIntArrToPyList2(eltsIndex));
+        return ret;
+      }
+
+      PyObject *getCellsContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception)
+      {
+        int sz;
+        double *pos=convertPyToNewDblArr2(p,&sz);
+        std::vector<int> elts;
+        self->getCellsContainingPoint(pos,eps,elts);
+        delete [] pos;
+        return convertIntArrToPyList2(elts);
+      }
+
+      static PyObject *mergeUMeshesOnSameCoords(PyObject *ms) throw(INTERP_KERNEL::Exception)
+      {
+        std::vector<ParaMEDMEM::MEDCouplingUMesh *> meshes;
+        if(PyList_Check(ms))
+          {
+            int sz=PyList_Size(ms);
+            meshes.resize(sz);
+            for(int i=0;i<sz;i++)
+              {
+                PyObject *o=PyList_GetItem(ms,i);
+                void *arg;
+                SWIG_ConvertPtr(o,&arg,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, 0 |  0 );
+                meshes[i]=reinterpret_cast<ParaMEDMEM::MEDCouplingUMesh *>(arg);
+              }
+          }
+        else
+          {
+            PyErr_SetString(PyExc_TypeError,"mergeUMeshesOnSameCoords : not a list as first parameter");
+            PyErr_Print();
+            return 0;
+          }
+        MEDCouplingUMesh *ret=MEDCouplingUMesh::mergeUMeshesOnSameCoords(meshes);
+        return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+      }
+
+      static PyObject *fuseUMeshesOnSameCoords(PyObject *ms, int compType) throw(INTERP_KERNEL::Exception)
+      {
+        int sz;
+        std::vector<MEDCouplingUMesh *> meshes;
+        convertPyObjToVecUMeshes(ms,meshes);
+        std::vector<DataArrayInt *> corr;
+        MEDCouplingUMesh *um=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,compType,corr);
+        sz=corr.size();
+        PyObject *ret1=PyList_New(sz);
+        for(int i=0;i<sz;i++)
+          PyList_SetItem(ret1,i,SWIG_NewPointerObj(SWIG_as_voidptr(corr[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        PyObject *ret=PyList_New(2);
+        PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(um),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
+        PyList_SetItem(ret,1,ret1);
+        return ret;
+      }
+
+      PyObject *are2DCellsNotCorrectlyOriented(PyObject *vec, bool polyOnly) const throw(INTERP_KERNEL::Exception)
+      {
+        std::vector<int> cells;
+        int sz;
+        double *v=convertPyToNewDblArr2(vec,&sz);
+        try
+          {
+            self->are2DCellsNotCorrectlyOriented(v,polyOnly,cells);
+          }
+        catch(INTERP_KERNEL::Exception& e)
+          {
+            delete [] v;
+            throw e;
+          }
+        delete [] v;
+        return convertIntArrToPyList2(cells);
+      }
+
+      void orientCorrectly2DCells(PyObject *vec, bool polyOnly) throw(INTERP_KERNEL::Exception)
+      {
+        int sz;
+        double *v=convertPyToNewDblArr2(vec,&sz);
+        try
+          {
+            self->orientCorrectly2DCells(v,polyOnly);
+          }
+        catch(INTERP_KERNEL::Exception& e)
+          {
+            delete [] v;
+            throw e;
+          }
+        delete [] v;
+      }
+      
+      PyObject *arePolyhedronsNotCorrectlyOriented() const throw(INTERP_KERNEL::Exception)
+      {
+        std::vector<int> cells;
+        self->arePolyhedronsNotCorrectlyOriented(cells);
+        return convertIntArrToPyList2(cells);
+      }
+
+      PyObject *getFastAveragePlaneOfThis() const throw(INTERP_KERNEL::Exception)
+      {
+        double vec[3];
+        double pos[3];
+        self->getFastAveragePlaneOfThis(vec,pos);
+        double vals[6];
+        std::copy(vec,vec+3,vals);
+        std::copy(pos,pos+3,vals+3);
+        return convertDblArrToPyListOfTuple(vals,3,2);
+      }
+      
+      static MEDCouplingUMesh *mergeUMeshes(PyObject *li) throw(INTERP_KERNEL::Exception)
+      {
+        std::vector<const ParaMEDMEM::MEDCouplingUMesh *> tmp;
+        convertPyObjToVecUMeshesCst(li,tmp);
+        return MEDCouplingUMesh::mergeUMeshes(tmp);
+      }
+
+      PyObject *areCellsIncludedIn(const MEDCouplingUMesh *other, int compType) const throw(INTERP_KERNEL::Exception)
+      {
+        DataArrayInt *ret1;
+        bool ret0=self->areCellsIncludedIn(other,compType,ret1);
+        PyObject *ret=PyTuple_New(2);
+        PyObject *ret0Py=ret0?Py_True:Py_False;
+        Py_XINCREF(ret0Py);
+        PyTuple_SetItem(ret,0,ret0Py);
+        PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        return ret;
+      }
+
+      PyObject *buildDescendingConnectivity() const throw(INTERP_KERNEL::Exception)
+      {
+        MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
+        MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
+        MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d2=DataArrayInt::New();
+        MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d3=DataArrayInt::New();
+        MEDCouplingUMesh *m=self->buildDescendingConnectivity(d0,d1,d2,d3);
+        PyObject *ret=PyTuple_New(5);
+        PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(m),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
+        PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(d2),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(d3),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        d0->incrRef();
+        d1->incrRef();
+        d2->incrRef();
+        d3->incrRef();
+        return ret;
+      }
+    }
+    void convertToPolyTypes(const std::vector<int>& cellIdsToConvert) throw(INTERP_KERNEL::Exception);
+    void unPolyze() throw(INTERP_KERNEL::Exception);
+    MEDCouplingUMesh *buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy) throw(INTERP_KERNEL::Exception);
+  };
+
+  class MEDCouplingExtrudedMesh : public ParaMEDMEM::MEDCouplingMesh
+  {
+  public:
+    static MEDCouplingExtrudedMesh *New(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception);
+    MEDCouplingUMesh *build3DUnstructuredMesh() const throw(INTERP_KERNEL::Exception);
+    %extend {
+      std::string __str__() const
+      {
+        return self->simpleRepr();
+      }
+      PyObject *getMesh2D() const throw(INTERP_KERNEL::Exception)
+      {
+        MEDCouplingUMesh *ret=self->getMesh2D();
+        ret->incrRef();
+        return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+      }
+      PyObject *getMesh1D() const throw(INTERP_KERNEL::Exception)
+      {
+        MEDCouplingUMesh *ret=self->getMesh1D();
+        ret->incrRef();
+        return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+      }
+      PyObject *getMesh3DIds() const throw(INTERP_KERNEL::Exception)
+      {
+        DataArrayInt *ret=self->getMesh3DIds();
+        ret->incrRef();
+        return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
+      } 
+    }
+  };
+
+  class MEDCouplingCMesh : public ParaMEDMEM::MEDCouplingMesh
+  {
+  public:
+    static MEDCouplingCMesh *New();
+    void setCoords(DataArrayDouble *coordsX,
+                   DataArrayDouble *coordsY=0,
+                   DataArrayDouble *coordsZ=0) throw(INTERP_KERNEL::Exception);
+    void setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KERNEL::Exception);
+    %extend {
+      std::string __str__() const
+      {
+        return self->simpleRepr();
+      }
+      DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception)
+      {
+        DataArrayDouble *ret=self->getCoordsAt(i);
+        if(ret)
+          ret->incrRef();
+        return ret;
+      }
+    }
+  };
+}
+
+%extend ParaMEDMEM::DataArray
+{
+  void copyPartOfStringInfoFrom(const DataArray& other, PyObject *li) throw(INTERP_KERNEL::Exception)
+  {
+    std::vector<int> tmp;
+    convertPyToNewIntArr3(li,tmp);
+    self->copyPartOfStringInfoFrom(other,tmp);
+  }
+
+  void copyPartOfStringInfoFrom2(PyObject *li, const DataArray& other) throw(INTERP_KERNEL::Exception)
+  {
+    std::vector<int> tmp;
+    convertPyToNewIntArr3(li,tmp);
+    self->copyPartOfStringInfoFrom2(tmp,other);
+  }
+}
+
+%extend ParaMEDMEM::DataArrayDouble
+ {
+   std::string __str__() const
+   {
+     return self->repr();
+   }
+
+   void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple) throw(INTERP_KERNEL::Exception)
+   {
+     double *tmp=new double[nbOfTuples*nbOfElsPerTuple];
+     try
+       {
+         fillArrayWithPyListDbl(li,tmp,nbOfTuples*nbOfElsPerTuple,0.);
+       }
+     catch(INTERP_KERNEL::Exception& e)
+       {
+         delete [] tmp;
+         throw e;
+       }
+     self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple);
+   }
+
+   PyObject *getValues() throw(INTERP_KERNEL::Exception)
+   {
+     const double *vals=self->getPointer();
+     return convertDblArrToPyList(vals,self->getNbOfElems());
+   }
+
+   PyObject *getValuesAsTuple() throw(INTERP_KERNEL::Exception)
+   {
+     const double *vals=self->getPointer();
+     int nbOfComp=self->getNumberOfComponents();
+     int nbOfTuples=self->getNumberOfTuples();
+     return convertDblArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
+   }
+
+   DataArrayDouble *renumber(PyObject *li) throw(INTERP_KERNEL::Exception)
+   {
+     int size;
+     INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+     if(size!=self->getNumberOfTuples())
+       {
+         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+       }
+     DataArrayDouble *ret=self->renumber(tmp);
+     return ret;
+   }
+
+   DataArrayDouble *renumberR(PyObject *li) throw(INTERP_KERNEL::Exception)
+   {
+     int size;
+     INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+     if(size!=self->getNumberOfTuples())
+       {
+         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+       }
+     DataArrayDouble *ret=self->renumberR(tmp);
+     return ret;
+   }
+
+   DataArrayDouble *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception)
+   {
+     int size;
+     INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+     if(size!=self->getNumberOfTuples())
+       {
+         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+       }
+     DataArrayDouble *ret=self->renumberAndReduce(tmp,newNbOfTuple);
+     return ret;
+   }
+
+   void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception)
+   {
+     int size;
+     INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+     if(size!=self->getNumberOfTuples())
+       {
+         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+       }
+     self->renumberInPlace(tmp);
+   }
+
+   void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception)
+   {
+     int size;
+     INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+     if(size!=self->getNumberOfTuples())
+       {
+         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+       }
+     self->renumberInPlaceR(tmp);
+   }
+
+   DataArrayDouble *selectByTupleId(PyObject *li) const throw(INTERP_KERNEL::Exception)
+   {
+     int size;
+     INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+     DataArrayDouble *ret=self->selectByTupleId(tmp,tmp+size);
+     return ret;
+   }
+
+   DataArrayDouble *selectByTupleIdSafe(PyObject *li) const throw(INTERP_KERNEL::Exception)
+   {
+     int size;
+     INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+     DataArrayDouble *ret=self->selectByTupleIdSafe(tmp,tmp+size);
+     return ret;
+   }
+
+   PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception)
+   {
+     int tmp;
+     double r1=self->getMaxValue(tmp);
+     PyObject *ret=PyTuple_New(2);
+     PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
+     PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
+     return ret;
+   }
+
+   PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception)
+   {
+     DataArrayInt *tmp;
+     double r1=self->getMaxValue2(tmp);
+     PyObject *ret=PyTuple_New(2);
+     PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
+     PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+     return ret;
+   }
+
+   PyObject *getMinValue() const throw(INTERP_KERNEL::Exception)
+   {
+     int tmp;
+     double r1=self->getMinValue(tmp);
+     PyObject *ret=PyTuple_New(2);
+     PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
+     PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
+     return ret;
+   }
+
+   PyObject *getMinValue2() const throw(INTERP_KERNEL::Exception)
+   {
+     DataArrayInt *tmp;
+     double r1=self->getMinValue2(tmp);
+     PyObject *ret=PyTuple_New(2);
+     PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
+     PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+     return ret;
+   }
+
+   PyObject *accumulate() const throw(INTERP_KERNEL::Exception)
+   {
+     int sz=self->getNumberOfComponents();
+     double *tmp=new double[sz];
+     try
+       {
+         self->accumulate(tmp);
+       }
+     catch(INTERP_KERNEL::Exception& e)
+       {
+         delete [] tmp;
+         throw e;
+       }
+     PyObject *ret=convertDblArrToPyList(tmp,sz);
+     delete [] tmp;
+     return ret;
+   }
+   
+   DataArrayDouble *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
+   {
+     std::vector<int> tmp;
+     convertPyToNewIntArr3(li,tmp);
+     return self->keepSelectedComponents(tmp);
+   }
+
+   void setSelectedComponents(const DataArrayDouble *a, PyObject *li) throw(INTERP_KERNEL::Exception)
+   {
+     std::vector<int> tmp;
+     convertPyToNewIntArr3(li,tmp);
+     self->setSelectedComponents(a,tmp);
+   }
+   
+   PyObject *getTuple(int tupleId) throw(INTERP_KERNEL::Exception)
+   {
+     int sz=self->getNumberOfComponents();
+     INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
+     self->getTuple(tupleId,tmp);
+     return convertDblArrToPyList(tmp,sz);
+   }
+
+   static DataArrayDouble *aggregate(PyObject *li) throw(INTERP_KERNEL::Exception)
+   {
+     std::vector<const DataArrayDouble *> tmp;
+     convertPyObjToVecDataArrayDblCst(li,tmp);
+     return DataArrayDouble::aggregate(tmp);
+   }
+
+   static DataArrayDouble *meld(PyObject *li) throw(INTERP_KERNEL::Exception)
+   {
+     std::vector<const DataArrayDouble *> tmp;
+     convertPyObjToVecDataArrayDblCst(li,tmp);
+     return DataArrayDouble::meld(tmp);
+   }
+ };
+
+%extend ParaMEDMEM::DataArrayInt
+ {
+   std::string __str__() const
+   {
+     return self->repr();
+   }
+
+   PyObject *getDifferentValues(bool val) const throw(INTERP_KERNEL::Exception)
+   {
+     std::set<int> ret=self->getDifferentValues();
+     return convertIntArrToPyList3(ret);
+   }
+
+   void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple) throw(INTERP_KERNEL::Exception)
+   {
+     int *tmp=new int[nbOfTuples*nbOfElsPerTuple];
+     try
+       {
+         fillArrayWithPyListInt(li,tmp,nbOfTuples*nbOfElsPerTuple,0.);
+       }
+     catch(INTERP_KERNEL::Exception& e)
+       {
+         delete [] tmp;
+         throw e;
+       }
+     self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple);
+   }
+
+   PyObject *getValues() throw(INTERP_KERNEL::Exception)
+   {
+     const int *vals=self->getPointer();
+     return convertIntArrToPyList(vals,self->getNbOfElems());
+   }
+
+   PyObject *getValuesAsTuple() throw(INTERP_KERNEL::Exception)
+   {
+     const int *vals=self->getPointer();
+     int nbOfComp=self->getNumberOfComponents();
+     int nbOfTuples=self->getNumberOfTuples();
+     return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
+   }
+
+   static PyObject *makePartition(PyObject *gps, int newNb) throw(INTERP_KERNEL::Exception)
+   {
+     std::vector<DataArrayInt *> groups;
+     std::vector< std::vector<int> > fidsOfGroups;
+     convertPyObjToVecDataArrayInt(gps,groups);
+     ParaMEDMEM::DataArrayInt *ret0=ParaMEDMEM::DataArrayInt::makePartition(groups,newNb,fidsOfGroups);
+     PyObject *ret = PyList_New(2);
+     PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+     int sz=fidsOfGroups.size();
+     PyObject *ret1 = PyList_New(sz);
+     for(int i=0;i<sz;i++)
+       PyList_SetItem(ret1,i,convertIntArrToPyList2(fidsOfGroups[i]));
+     PyList_SetItem(ret,1,ret1);
+     return ret;
+   }
+
+   void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception)
+   {
+     int size;
+     INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+     if(size!=self->getNumberOfTuples())
+       {
+         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+       }
+     self->renumberInPlace(tmp);
+   }
+
+   void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception)
+   {
+     int size;
+     INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+     if(size!=self->getNumberOfTuples())
+       {
+         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+       }
+     self->renumberInPlaceR(tmp);
+   }
+
+   DataArrayInt *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception)
+   {
+     int size;
+     INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+     if(size!=self->getNumberOfTuples())
+       {
+         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+       }
+     DataArrayInt *ret=self->renumberAndReduce(tmp,newNbOfTuple);
+     return ret;
+   }
+
+   DataArrayInt *renumber(PyObject *li) throw(INTERP_KERNEL::Exception)
+   {
+     int size;
+     INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+     if(size!=self->getNumberOfTuples())
+       {
+         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+       }
+     DataArrayInt *ret=self->renumber(tmp);
+     return ret;
+   }
+
+   DataArrayInt *renumberR(PyObject *li) throw(INTERP_KERNEL::Exception)
+   {
+     int size;
+     INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+     if(size!=self->getNumberOfTuples())
+       {
+         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+       }
+     DataArrayInt *ret=self->renumberR(tmp);
+     return ret;
+   }
+
+   DataArrayInt *selectByTupleId(PyObject *li) const throw(INTERP_KERNEL::Exception)
+   {
+     int size;
+     INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+     DataArrayInt *ret=self->selectByTupleId(tmp,tmp+size);
+     return ret;
+   }
+
+   DataArrayInt *selectByTupleIdSafe(PyObject *li) const throw(INTERP_KERNEL::Exception)
+   {
+     int size;
+     INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+     DataArrayInt *ret=self->selectByTupleIdSafe(tmp,tmp+size);
+     return ret;
+   }
+
+   DataArrayInt *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
+   {
+     std::vector<int> tmp;
+     convertPyToNewIntArr3(li,tmp);
+     return self->keepSelectedComponents(tmp);
+   }
+
+   void setSelectedComponents(const DataArrayInt *a, PyObject *li) throw(INTERP_KERNEL::Exception)
+   {
+     std::vector<int> tmp;
+     convertPyToNewIntArr3(li,tmp);
+     self->setSelectedComponents(a,tmp);
+   }
+
+   PyObject *getTuple(int tupleId) throw(INTERP_KERNEL::Exception)
+   {
+     int sz=self->getNumberOfComponents();
+     INTERP_KERNEL::AutoPtr<int> tmp=new int[sz];
+     self->getTuple(tupleId,tmp);
+     return convertIntArrToPyList(tmp,sz);
+   }
+
+   static DataArrayInt *meld(PyObject *li) throw(INTERP_KERNEL::Exception)
+   {
+     std::vector<const DataArrayInt *> tmp;
+     convertPyObjToVecDataArrayIntCst(li,tmp);
+     return DataArrayInt::meld(tmp);
+   }
+
+   PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception)
+   {
+     int tmp;
+     int r1=self->getMaxValue(tmp);
+     PyObject *ret=PyTuple_New(2);
+     PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
+     PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
+     return ret;
+   }
+
+   PyObject *getMinValue() const throw(INTERP_KERNEL::Exception)
+   {
+     int tmp;
+     int r1=self->getMinValue(tmp);
+     PyObject *ret=PyTuple_New(2);
+     PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
+     PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
+     return ret;
+   }
+ };
+
+namespace ParaMEDMEM
+{
+  class MEDCouplingField : public ParaMEDMEM::RefCountObject, public ParaMEDMEM::TimeLabel
+  {
+  public:
+    virtual void checkCoherency() const throw(INTERP_KERNEL::Exception);
+    virtual bool areCompatibleForMerge(const MEDCouplingField *other) const throw(INTERP_KERNEL::Exception);
+    virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const throw(INTERP_KERNEL::Exception);
+    virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const throw(INTERP_KERNEL::Exception);
+    void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
+    void setName(const char *name) throw(INTERP_KERNEL::Exception);
+    const char *getDescription() const throw(INTERP_KERNEL::Exception);
+    void setDescription(const char *desc) throw(INTERP_KERNEL::Exception);
+    const char *getName() const throw(INTERP_KERNEL::Exception);
+    TypeOfField getTypeOfField() const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDiscretization *getDiscretization() const throw(INTERP_KERNEL::Exception);
+    void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
+                                    const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
+    void clearGaussLocalizations() throw(INTERP_KERNEL::Exception);
+    MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception);
+    int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception);
+    int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception);
+    const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
+    %extend {
+      PyObject *getMesh() const throw(INTERP_KERNEL::Exception)
+      {
+        MEDCouplingMesh *ret1=(MEDCouplingMesh *)self->getMesh();
+        if(ret1)
+          ret1->incrRef();
+        return convertMesh(ret1, SWIG_POINTER_OWN | 0 );
+      }
+
+      PyObject *buildSubMeshData(PyObject *li) const throw(INTERP_KERNEL::Exception)
+      {
+        int size;
+        INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+        DataArrayInt *ret1;
+        MEDCouplingMesh *ret0=self->buildSubMeshData(tmp,tmp+size,ret1);
+        PyObject *res = PyList_New(2);
+        PyList_SetItem(res,0,convertMesh(ret0, SWIG_POINTER_OWN | 0 ));
+        PyList_SetItem(res,1,SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0));
+        return res;
+      }
+      void setGaussLocalizationOnCells(PyObject *li, const std::vector<double>& refCoo,
+                                       const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception)
+      {
+        int size;
+        INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+        try
+          {
+            self->setGaussLocalizationOnCells(tmp,tmp+size,refCoo,gsCoo,wg);
+          }
+        catch(INTERP_KERNEL::Exception& e)
+          {
+            throw e;
+          }
+      }
+      PyObject *getCellIdsHavingGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception)
+      {
+        std::vector<int> tmp;
+        self->getCellIdsHavingGaussLocalization(locId,tmp);
+        return convertIntArrToPyList2(tmp);
+      }
+    }
+  };
+
+  class MEDCouplingFieldDouble : public ParaMEDMEM::MEDCouplingField
+  {
+  public:
+    static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=NO_TIME);
+    void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
+    void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
+    std::string simpleRepr() const;
+    std::string advancedRepr() const;
+    MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
+    MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const;
+    MEDCouplingFieldDouble *deepCpy() const;
+    MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const throw(INTERP_KERNEL::Exception);
+    TypeOfTimeDiscretization getTimeDiscretization() const throw(INTERP_KERNEL::Exception);
+    void checkCoherency() const throw(INTERP_KERNEL::Exception);
+    double getIJ(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception);
+    double getIJK(int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
+    void setArray(DataArrayDouble *array) throw(INTERP_KERNEL::Exception);
+    void setEndArray(DataArrayDouble *array) throw(INTERP_KERNEL::Exception);
+    void setTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception);
+    void setStartTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception);
+    void setEndTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception);
+    void applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception);
+    int getNumberOfComponents() const throw(INTERP_KERNEL::Exception);
+    int getNumberOfTuples() const throw(INTERP_KERNEL::Exception);
+    int getNumberOfValues() const throw(INTERP_KERNEL::Exception);
+    NatureOfField getNature() const throw(INTERP_KERNEL::Exception);
+    void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
+    void setTimeTolerance(double val) throw(INTERP_KERNEL::Exception);
+    double getTimeTolerance() const throw(INTERP_KERNEL::Exception);
+    void updateTime() throw(INTERP_KERNEL::Exception);
+    void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);
+    void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);
+    bool mergeNodes(double eps) throw(INTERP_KERNEL::Exception);
+    bool mergeNodes2(double eps) throw(INTERP_KERNEL::Exception);
+    bool zipCoords() throw(INTERP_KERNEL::Exception);
+    bool zipConnectivity(int compType) throw(INTERP_KERNEL::Exception);
+    bool simplexize(int policy) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *determinant() const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *eigenValues() const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *eigenVectors() const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *inverse() const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *trace() const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *deviator() const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *magnitude() const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception);
+    void changeNbOfComponents(int newNbOfComp, double dftValue=0.) throw(INTERP_KERNEL::Exception);
+    void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble &operator=(double value) throw(INTERP_KERNEL::Exception);
+    void fillFromAnalytic(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
+    void applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
+    void applyFunc(int nbOfComp, double val) throw(INTERP_KERNEL::Exception);
+    void applyFunc(const char *func) throw(INTERP_KERNEL::Exception);
+    void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception);
+    void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception);
+    double accumulate(int compId) const throw(INTERP_KERNEL::Exception);
+    double getMaxValue() const throw(INTERP_KERNEL::Exception);
+    double getMinValue() const throw(INTERP_KERNEL::Exception);
+    double getAverageValue() const throw(INTERP_KERNEL::Exception);
+    double getWeightedAverageValue() const throw(INTERP_KERNEL::Exception);
+    double integral(int compId, bool isWAbs) const throw(INTERP_KERNEL::Exception);
+    double normL1(int compId) const throw(INTERP_KERNEL::Exception);
+    double normL2(int compId) const throw(INTERP_KERNEL::Exception);
+    DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *buildSubPart(const DataArrayInt *part) const throw(INTERP_KERNEL::Exception);
+    static MEDCouplingFieldDouble *mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+    static MEDCouplingFieldDouble *meldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+    static MEDCouplingFieldDouble *dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+    static MEDCouplingFieldDouble *crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+    static MEDCouplingFieldDouble *maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+    static MEDCouplingFieldDouble *minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+    const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+    const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+    const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+    const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+    %extend {
+      std::string __str__() const
+      {
+        return self->simpleRepr();
+      }
+
+      DataArrayDouble *getArray() const throw(INTERP_KERNEL::Exception)
+      {
+        DataArrayDouble *ret=self->getArray();
+        if(ret)
+          ret->incrRef();
+        return ret;
+      }
+
+      DataArrayDouble *getEndArray() const throw(INTERP_KERNEL::Exception)
+      {
+        DataArrayDouble *ret=self->getEndArray();
+        if(ret)
+          ret->incrRef();
+        return ret;
+      }
+
+      PyObject *getValueOn(PyObject *sl) const throw(INTERP_KERNEL::Exception)
+      {
+        int sz;
+        double *spaceLoc=convertPyToNewDblArr2(sl,&sz);
+        sz=self->getNumberOfComponents();
+        double *res=new double[sz];
+        try
+          {
+            self->getValueOn(spaceLoc,res);
+          }
+        catch(INTERP_KERNEL::Exception& e)
+          {
+            delete [] spaceLoc;
+            delete [] res;
+            throw e;
+          }
+        delete [] spaceLoc;
+        PyObject *ret=convertDblArrToPyList(res,sz);
+        delete [] res;
+        return ret;
+      }
+      PyObject *getValueOn(PyObject *sl, double time) const throw(INTERP_KERNEL::Exception)
+      {
+        int sz;
+        double *spaceLoc=convertPyToNewDblArr2(sl,&sz);
+        sz=self->getNumberOfComponents();
+        double *res=new double[sz];
+        try
+          {
+            self->getValueOn(spaceLoc,time,res);
+          }
+        catch(INTERP_KERNEL::Exception& e)
+          {
+            delete [] spaceLoc;
+            delete [] res;
+            throw e;
+          }
+        delete [] spaceLoc;
+        PyObject *ret=convertDblArrToPyList(res,sz);
+        delete [] res;
+        return ret;
+      }
+      void setValues(PyObject *li) throw(INTERP_KERNEL::Exception)
+      {
+        if(self->getArray()!=0)
+          {
+            int sz;
+            double *tmp=convertPyToNewDblArr2(li,&sz);
+            int nbTuples=self->getArray()->getNumberOfTuples();
+            int nbOfCompo=self->getArray()->getNumberOfComponents();
+            self->getArray()->useArray(tmp,true,CPP_DEALLOC,nbTuples,nbOfCompo);
+          }
+        else
+          PyErr_SetString(PyExc_TypeError,"setValuesCpy : field must contain an array behind");
+      }
+      PyObject *getTime() throw(INTERP_KERNEL::Exception)
+      {
+        int tmp1,tmp2;
+        double tmp0=self->getTime(tmp1,tmp2);
+        PyObject *res = PyList_New(3);
+        PyList_SetItem(res,0,SWIG_From_double(tmp0));
+        PyList_SetItem(res,1,SWIG_From_int(tmp1));
+        PyList_SetItem(res,2,SWIG_From_int(tmp2));
+        return res;
+      }
+
+      PyObject *getStartTime() throw(INTERP_KERNEL::Exception)
+      {
+        int tmp1,tmp2;
+        double tmp0=self->getStartTime(tmp1,tmp2);
+        PyObject *res = PyList_New(3);
+        PyList_SetItem(res,0,SWIG_From_double(tmp0));
+        PyList_SetItem(res,1,SWIG_From_int(tmp1));
+        PyList_SetItem(res,2,SWIG_From_int(tmp2));
+        return res;
+      }
+
+      PyObject *getEndTime() throw(INTERP_KERNEL::Exception)
+      {
+        int tmp1,tmp2;
+        double tmp0=self->getEndTime(tmp1,tmp2);
+        PyObject *res = PyList_New(3);
+        PyList_SetItem(res,0,SWIG_From_double(tmp0));
+        PyList_SetItem(res,1,SWIG_From_int(tmp1));
+        PyList_SetItem(res,2,SWIG_From_int(tmp2));
+        return res;
+      }
+      PyObject *accumulate() const throw(INTERP_KERNEL::Exception)
+      {
+        int sz=self->getNumberOfComponents();
+        double *tmp=new double[sz];
+        self->accumulate(tmp);
+        PyObject *ret=convertDblArrToPyList(tmp,sz);
+        delete [] tmp;
+        return ret;
+      }
+      PyObject *integral(bool isWAbs) const throw(INTERP_KERNEL::Exception)
+      {
+        int sz=self->getNumberOfComponents();
+        double *tmp=new double[sz];
+        self->integral(isWAbs,tmp);
+        PyObject *ret=convertDblArrToPyList(tmp,sz);
+        delete [] tmp;
+        return ret;
+      }
+      PyObject *normL1() const throw(INTERP_KERNEL::Exception)
+      {
+        int sz=self->getNumberOfComponents();
+        double *tmp=new double[sz];
+        self->normL1(tmp);
+        PyObject *ret=convertDblArrToPyList(tmp,sz);
+        delete [] tmp;
+        return ret;
+      }
+      PyObject *normL2() const throw(INTERP_KERNEL::Exception)
+      {
+        int sz=self->getNumberOfComponents();
+        double *tmp=new double[sz];
+        self->normL2(tmp);
+        PyObject *ret=convertDblArrToPyList(tmp,sz);
+        delete [] tmp;
+        return ret;
+      }
+
+      void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception)
+      {
+        int size;
+        INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+        try
+          {
+            self->renumberCells(tmp,check);
+          }
+        catch(INTERP_KERNEL::Exception& e)
+          {
+            throw e;
+          }
+      }
+      void renumberNodes(PyObject *li) throw(INTERP_KERNEL::Exception)
+      {
+        int size;
+        INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+        try
+          {
+            self->renumberNodes(tmp);
+          }
+        catch(INTERP_KERNEL::Exception& e)
+          {
+            throw e;
+          }
+      }
+
+      MEDCouplingFieldDouble *buildSubPart(PyObject *li) const throw(INTERP_KERNEL::Exception)
+      {
+        int size;
+        INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+        MEDCouplingFieldDouble *ret=0;
+        try
+          {
+            ret=self->buildSubPart(tmp,tmp+size);
+          }
+        catch(INTERP_KERNEL::Exception& e)
+          {
+            throw e;
+          }
+        return ret;
+      }
+
+      PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception)
+      {
+        DataArrayInt *tmp;
+        double r1=self->getMaxValue2(tmp);
+        PyObject *ret=PyTuple_New(2);
+        PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
+        PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        return ret;
+      }
+      
+      PyObject *getMinValue2() const throw(INTERP_KERNEL::Exception)
+      {
+        DataArrayInt *tmp;
+        double r1=self->getMinValue2(tmp);
+        PyObject *ret=PyTuple_New(2);
+        PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
+        PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        return ret;
+      }
+      
+      MEDCouplingFieldDouble *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
+      {
+        std::vector<int> tmp;
+        convertPyToNewIntArr3(li,tmp);
+        return self->keepSelectedComponents(tmp);
+      }
+
+      void setSelectedComponents(const MEDCouplingFieldDouble *f, PyObject *li) throw(INTERP_KERNEL::Exception)
+      {
+        std::vector<int> tmp;
+        convertPyToNewIntArr3(li,tmp);
+        self->setSelectedComponents(f,tmp);
+      }
+
+      static MEDCouplingFieldDouble *mergeFields(PyObject *li) throw(INTERP_KERNEL::Exception)
+      {
+        std::vector<const MEDCouplingFieldDouble *> tmp;
+        convertPyObjToVecFieldDblCst(li,tmp);
+        return MEDCouplingFieldDouble::mergeFields(tmp);
+      }
+    }
+  };
+}
index 25119adda93dba35f79ba1bf140f52e5d99c08f2..0139b3836adaa8469cdd0afdecf92cd26f8d71f5 100644 (file)
@@ -18,7 +18,7 @@
 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-from libMEDCoupling_Swig import *
+from MEDCoupling import *
 import unittest
 from math import pi,e,sqrt
 from MEDCouplingDataForTest import MEDCouplingDataForTest
@@ -182,13 +182,13 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         array=DataArrayDouble.New();
         array.setValues(5*3*[7.],5,3);
         self.assertEqual(array.getIJ(3,2),7.);
-        array2=array.deepCopy();
+        array2=array.deepCpy();
         self.assertEqual(array2.getIJ(3,2),7.)
         #
         array3=DataArrayInt.New();
         array3.setValues(5*3*[17],5,3);
         self.assertEqual(array3.getIJ(3,2),17);
-        array4=array3.deepCopy();
+        array4=array3.deepCpy();
         self.assertEqual(array4.getIJ(3,2),17);
         pass
     def testRevNodal(self):
@@ -594,7 +594,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
         self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
         #
-        arr2=arr.deepCopy();
+        arr2=arr.deepCpy();
         fieldOnCells2.setArray(arr2);
         self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
         self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
@@ -693,7 +693,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         center=[0.,0.,0.]
         vector=[0.,1.,0.]
         m2.rotate(center,vector,-pi/2.);
-        m3=m1.buildExtrudedMeshFromThis(m2,0);
+        m3=m1.buildExtrudedMesh(m2,0);
         #
         m4=MEDCouplingExtrudedMesh.New(m3,m1,0);
         self.assertEqual(15,m4.getNumberOfCells());
@@ -713,7 +713,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         #play with polygons and polyedrons
         cells=[2,3]
         m1.convertToPolyTypes(cells);
-        m3=m1.buildExtrudedMeshFromThis(m2,0);
+        m3=m1.buildExtrudedMesh(m2,0);
         self.assertEqual(NORM_HEXA8,m3.getTypeOfCell(0));
         self.assertEqual(NORM_PENTA6,m3.getTypeOfCell(1));
         self.assertEqual(NORM_POLYHED,m3.getTypeOfCell(2));
@@ -738,7 +738,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         center=[0.,0.,0.]
         vector=[0.,1.,0.]
         m2.rotate(center,vector,-pi/2.);
-        m3=m1.buildExtrudedMeshFromThis(m2,0);
+        m3=m1.buildExtrudedMesh(m2,0);
         expected1=[1,3,2,0,6,5,7,10,11,8,12,9,14,13,4]
         rexpected1=[3, 0, 2, 1, 14, 5, 4, 6, 9, 11, 7, 8, 10, 13, 12]
         m3.renumberCells(expected1,False);
@@ -1889,7 +1889,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         center=[0.,0.,0.]
         vector=[0.,1.,0.]
         m4.rotate(center,vector,-pi/2.);
-        m5=m3.buildExtrudedMeshFromThis(m4,0);
+        m5=m3.buildExtrudedMesh(m4,0);
         res1=m5.arePolyhedronsNotCorrectlyOriented();
         self.assertEqual(15,len(res1));
         m5.orientCorrectlyPolyhedrons();
@@ -2485,7 +2485,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         a1.fillWithZero();
         a1.setInfoOnComponent(0,"c");
         a1.setInfoOnComponent(1,"d");
-        a2=a1.deepCopy();
+        a2=a1.deepCpy();
         a2.setInfoOnComponent(0,"e");
         a2.setInfoOnComponent(1,"f");
         f.setArray(a1);
@@ -4542,6 +4542,11 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         arr1=[1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.]
         a1=DataArrayDouble.New();
         a1.setValues(arr1,5,4);
+        expp=[21.,22.,23.,24.]
+        self.assertEqual(4,len(a1.getTuple(2)));
+        for i in xrange(4):
+            self.assertAlmostEqual(expp[i],a1.getTuple(2)[i],12)
+            pass
         a1.setInfoOnComponent(0,"aaaa");
         a1.setInfoOnComponent(1,"bbbb");
         a1.setInfoOnComponent(2,"cccc");
@@ -4561,6 +4566,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
             self.assertAlmostEqual(expected1[i],a2.getIJ(0,i),14);
             pass
         a3=a1.convertToIntArr();
+        self.assertEqual([21,22,23,24],a3.getTuple(2))
         a4=a3.keepSelectedComponents(arr2V);
         self.assertEqual(6,a4.getNumberOfComponents());
         self.assertEqual(5,a4.getNumberOfTuples());
@@ -4985,7 +4991,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         g=f.getCoords().applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
         h=g.fromPolarToCart();
         f.setCoords(h);
-        i=c.buildExtrudedMeshFromThis(f,1);
+        i=c.buildExtrudedMesh(f,1);
         self.assertEqual(52,i.getNumberOfNodes());
         tmp,tmp2,tmp3=i.mergeNodes(1e-9);
         self.assertTrue(tmp2);
@@ -5033,7 +5039,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         #
         center=[0.,0.]
         f.rotate(center,[],pi/3);
-        g=c.buildExtrudedMeshFromThis(f,0);
+        g=c.buildExtrudedMesh(f,0);
         g.checkCoherency();
         expected1=[ 0.4330127018922193, 0.4330127018922193, 0.649519052838329, 1.2990381056766578, 1.299038105676658, 1.948557158514987, 2.1650635094610955, 2.1650635094610964, 3.2475952641916446, 3.031088913245533, 3.0310889132455352, 4.546633369868303 ]
         f1=g.getMeasureField(True);
@@ -5066,7 +5072,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         g=f.getCoords().applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
         h=g.fromPolarToCart();
         f.setCoords(h);
-        i=c.buildExtrudedMeshFromThis(f,1);
+        i=c.buildExtrudedMesh(f,1);
         self.assertEqual(52,i.getNumberOfNodes());
         tmp,tmp2,tmp3=i.mergeNodes(1e-9);
         self.assertTrue(tmp2);
@@ -5077,7 +5083,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         g2=h.applyFunc(3,"13.5/3.5*x*IVec+0*JVec+13.5/3.5*y*KVec");
         f.setCoords(g2);
         i.changeSpaceDimension(3);
-        i3=i.buildExtrudedMeshFromThis(f,1);
+        i3=i.buildExtrudedMesh(f,1);
         f2=i3.getMeasureField(True);
         tmp,tmp2,tmp3=i.mergeNodes(1e-9);
         self.assertTrue(tmp2);
@@ -5165,6 +5171,531 @@ class MEDCouplingBasicsTest(unittest.TestCase):
             pass
         #
         pass
+
+    def testDAMeld1(self):
+        da1=DataArrayDouble.New();
+        da1.alloc(7,2);
+        da2=DataArrayDouble.New();
+        da2.alloc(7,1);
+        #
+        da1.fillWithValue(7.);
+        da2.iota(0.);
+        da3=da2.applyFunc(3,"10*x*IVec+100*x*JVec+1000*x*KVec");
+        #
+        da1.setInfoOnComponent(0,"c0da1");
+        da1.setInfoOnComponent(1,"c1da1");
+        da3.setInfoOnComponent(0,"c0da3");
+        da3.setInfoOnComponent(1,"c1da3");
+        da3.setInfoOnComponent(2,"c2da3");
+        #
+        da1C=da1.deepCpy();
+        da1.meldWith(da3);
+        self.assertEqual(5,da1.getNumberOfComponents());
+        self.assertEqual(7,da1.getNumberOfTuples());
+        self.assertTrue(da1.getInfoOnComponent(0)=="c0da1");
+        self.assertTrue(da1.getInfoOnComponent(1)=="c1da1");
+        self.assertTrue(da1.getInfoOnComponent(2)=="c0da3");
+        self.assertTrue(da1.getInfoOnComponent(3)=="c1da3");
+        self.assertTrue(da1.getInfoOnComponent(4)=="c2da3");
+        #
+        expected1=[7.,7.,0.,0.,0., 7.,7.,10.,100.,1000., 7.,7.,20.,200.,2000., 7.,7.,30.,300.,3000., 7.,7.,40.,400.,4000.,7.,7.,50.,500.,5000.,7.,7.,60.,600.,6000.]
+        for i in xrange(35):
+            self.assertAlmostEqual(expected1[i],da1.getIJ(0,i),10);
+            pass
+        #
+        dai1=da1C.convertToIntArr();
+        dai3=da3.convertToIntArr();
+        dai1.meldWith(dai3);
+        self.assertEqual(5,dai1.getNumberOfComponents());
+        self.assertEqual(7,dai1.getNumberOfTuples());
+        self.assertTrue(dai1.getInfoOnComponent(0)=="c0da1");
+        self.assertTrue(dai1.getInfoOnComponent(1)=="c1da1");
+        self.assertTrue(dai1.getInfoOnComponent(2)=="c0da3");
+        self.assertTrue(dai1.getInfoOnComponent(3)=="c1da3");
+        self.assertTrue(dai1.getInfoOnComponent(4)=="c2da3");
+        for i in xrange(35):
+            self.assertEqual(int(expected1[i]),dai1.getIJ(0,i));
+            pass
+        # test of static method DataArrayDouble::meld
+        da4=DataArrayDouble.meld(da1C,da3);
+        tmp=DataArrayDouble.meld([da1C,da3]);
+        self.assertTrue(da4.isEqual(tmp,1e-10))
+        self.assertEqual(5,da4.getNumberOfComponents());
+        self.assertEqual(7,da4.getNumberOfTuples());
+        self.assertTrue(da4.getInfoOnComponent(0)=="c0da1");
+        self.assertTrue(da4.getInfoOnComponent(1)=="c1da1");
+        self.assertTrue(da4.getInfoOnComponent(2)=="c0da3");
+        self.assertTrue(da4.getInfoOnComponent(3)=="c1da3");
+        self.assertTrue(da4.getInfoOnComponent(4)=="c2da3");
+        for i in xrange(35):
+            self.assertAlmostEqual(expected1[i],da4.getIJ(0,i),10);
+            pass
+        # test of static method DataArrayInt::meld
+        dai1=da1C.convertToIntArr();
+        dai4=DataArrayInt.meld(dai1,dai3);
+        tmp=DataArrayInt.meld([dai1,dai3]);
+        self.assertTrue(dai4.isEqual(tmp))
+        self.assertEqual(5,dai4.getNumberOfComponents());
+        self.assertEqual(7,dai4.getNumberOfTuples());
+        self.assertTrue(dai4.getInfoOnComponent(0)=="c0da1");
+        self.assertTrue(dai4.getInfoOnComponent(1)=="c1da1");
+        self.assertTrue(dai4.getInfoOnComponent(2)=="c0da3");
+        self.assertTrue(dai4.getInfoOnComponent(3)=="c1da3");
+        self.assertTrue(dai4.getInfoOnComponent(4)=="c2da3");
+        for i in xrange(35):
+            self.assertEqual(int(expected1[i]),dai4.getIJ(0,i));
+            pass
+        pass
+
+    def testFieldMeld1(self):
+        m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+        f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+        f1.setMesh(m);
+        da1=DataArrayDouble.New();
+        arr1=[12.,23.,34.,45.,56.]
+        da1.setValues(arr1,5,1);
+        da1.setInfoOnComponent(0,"aaa");
+        f1.setArray(da1);
+        f1.setTime(3.4,2,1);
+        f1.checkCoherency();
+        #
+        f2=f1.deepCpy();
+        f2.setMesh(f1.getMesh());
+        f2.checkCoherency();
+        f2.changeNbOfComponents(2,5.);
+        f2.assign(5.);
+        f2.getArray().setInfoOnComponent(0,"bbb");
+        f2.getArray().setInfoOnComponent(1,"ccc");
+        f2.checkCoherency();
+        #
+        f3=MEDCouplingFieldDouble.meldFields(f2,f1);
+        f3.checkCoherency();
+        self.assertEqual(5,f3.getNumberOfTuples());
+        self.assertEqual(3,f3.getNumberOfComponents());
+        self.assertTrue(f3.getArray().getInfoOnComponent(0)=="bbb");
+        self.assertTrue(f3.getArray().getInfoOnComponent(1)=="ccc");
+        self.assertTrue(f3.getArray().getInfoOnComponent(2)=="aaa");
+        expected1=[5.,5.,12.,5.,5.,23.,5.,5.,34.,5.,5.,45.,5.,5.,56.]
+        for i in xrange(15):
+            self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),12);
+            pass
+        time,dt,it=f3.getTime();
+        self.assertAlmostEqual(3.4,time,14);
+        self.assertEqual(2,dt);
+        self.assertEqual(1,it);
+        #
+        f4=f2.buildNewTimeReprFromThis(NO_TIME,False);
+        f5=f1.buildNewTimeReprFromThis(NO_TIME,False);
+        f6=MEDCouplingFieldDouble.meldFields(f4,f5);
+        f6.checkCoherency();
+        self.assertEqual(5,f6.getNumberOfTuples());
+        self.assertEqual(3,f6.getNumberOfComponents());
+        self.assertTrue(f6.getArray().getInfoOnComponent(0)=="bbb");
+        self.assertTrue(f6.getArray().getInfoOnComponent(1)=="ccc");
+        self.assertTrue(f6.getArray().getInfoOnComponent(2)=="aaa");
+        for i in xrange(15):
+            self.assertAlmostEqual(expected1[i],f6.getIJ(0,i),12);
+            pass
+        #
+        pass
+
+    def testMergeNodes2(self):
+        m1=MEDCouplingDataForTest.build2DTargetMesh_1();
+        m2=MEDCouplingDataForTest.build2DTargetMesh_1();
+        vec=[0.002,0.]
+        m2.translate(vec);
+        #
+        m3=MEDCouplingUMesh.mergeUMeshes([m1,m2]);
+        da,b,newNbOfNodes=m3.mergeNodes2(0.01);
+        self.assertEqual(9,m3.getNumberOfNodes());
+        expected1=[-0.299,-0.3, 0.201,-0.3, 0.701,-0.3, -0.299,0.2, 0.201,0.2, 0.701,0.2, -0.299,0.7, 0.201,0.7, 0.701,0.7]
+        for i in xrange(18):
+            self.assertAlmostEqual(expected1[i],m3.getCoords().getIJ(0,i),13);
+            pass
+        #
+        pass
+
+    def testMergeField2(self):
+        m=MEDCouplingDataForTest.build2DTargetMesh_1();
+        f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+        f1.setMesh(m);
+        arr=DataArrayDouble.New();
+        arr.alloc(5,2);
+        arr.fillWithValue(2.);
+        f1.setArray(arr);
+        f2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+        f2.setMesh(m);
+        arr=DataArrayDouble.New();
+        arr.alloc(5,2);
+        arr.fillWithValue(5.);
+        f2.setArray(arr);
+        f3=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+        f3.setMesh(m);
+        arr=DataArrayDouble.New();
+        arr.alloc(5,2);
+        arr.fillWithValue(7.);
+        f3.setArray(arr);
+        #
+        f4=MEDCouplingFieldDouble.mergeFields([f1,f2,f3]);
+        self.assertEqual(15,f4.getMesh().getNumberOfCells());
+        expected1=[2.,2.,2.,2.,2.,2.,2.,2.,2.,2., 5.,5.,5.,5.,5.,5.,5.,5.,5.,5., 7.,7.,7.,7.,7.,7.,7.,7.,7.,7.]
+        for i in xrange(30):
+            self.assertAlmostEqual(expected1[i],f4.getIJ(0,i),13);
+            pass
+        #
+        pass
+
+    def testDAIBuildComplement1(self):
+        a=DataArrayInt.New();
+        tab=[3,1,7,8]
+        a.setValues(tab,4,1);
+        b=a.buildComplement(12);
+        self.assertEqual(8,b.getNumberOfTuples());
+        self.assertEqual(1,b.getNumberOfComponents());
+        expected1=[0,2,4,5,6,9,10,11]
+        for i in xrange(8):
+            self.assertEqual(expected1[i],b.getIJ(0,i));
+            pass
+        pass
+
+    def testDAIBuildUnion1(self):
+        a=DataArrayInt.New();
+        tab1=[3,1,7,8]
+        a.setValues(tab1,4,1);
+        c=DataArrayInt.New();
+        tab2=[5,3,0,18,8]
+        c.setValues(tab2,5,1);
+        b=a.buildUnion(c);
+        self.assertEqual(7,b.getNumberOfTuples());
+        self.assertEqual(1,b.getNumberOfComponents());
+        expected1=[0,1,3,5,7,8,18]
+        for i in xrange(7):
+            self.assertEqual(expected1[i],b.getIJ(0,i));
+            pass
+        pass
+
+    def testDAIBuildIntersection1(self):
+        a=DataArrayInt.New();
+        tab1=[3,1,7,8]
+        a.setValues(tab1,4,1);
+        c=DataArrayInt.New();
+        tab2=[5,3,0,18,8]
+        c.setValues(tab2,5,1);
+        b=a.buildIntersection(c);
+        self.assertEqual(2,b.getNumberOfTuples());
+        self.assertEqual(1,b.getNumberOfComponents());
+        expected1=[3,8]
+        for i in xrange(2):
+            self.assertEqual(expected1[i],b.getIJ(0,i));
+            pass
+        pass
+
+    def testDAIDeltaShiftIndex1(self):
+        a=DataArrayInt.New();
+        tab=[1,3,6,7,7,9,15]
+        a.setValues(tab,7,1);
+        b=a.deltaShiftIndex();
+        self.assertEqual(6,b.getNumberOfTuples());
+        self.assertEqual(1,b.getNumberOfComponents());
+        expected1=[2,3,1,0,2,6]
+        for i in xrange(6):
+            self.assertEqual(expected1[i],b.getIJ(0,i));
+            pass
+        pass
+
+    def testDaDoubleSelectByTupleIdSafe1(self):
+        a=DataArrayDouble.New();
+        arr1=[1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1]
+        a.setValues(arr1,7,2);
+        a.setInfoOnComponent(0,"toto");
+        a.setInfoOnComponent(1,"tata");
+        #
+        arr2=[4,2,0,6,5]
+        b=a.selectByTupleIdSafe(arr2);
+        self.assertEqual(5,b.getNumberOfTuples());
+        self.assertEqual(2,b.getNumberOfComponents());
+        self.assertTrue(b.getInfoOnComponent(0)=="toto");
+        self.assertTrue(b.getInfoOnComponent(1)=="tata");
+        expected1=[5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1]
+        for i in xrange(10):
+            self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
+            pass
+        arr4=[4,-1,0,6,5]
+        self.assertRaises(Exception,a.selectByTupleIdSafe,arr4);
+        arr5=[4,2,0,6,7]
+        self.assertRaises(Exception,a.selectByTupleIdSafe,arr5);
+        #
+        c=DataArrayInt.New();
+        arr3=[1,11,2,12,3,13,4,14,5,15,6,16,7,17]
+        c.setValues(arr3,7,2);
+        c.setInfoOnComponent(0,"toto");
+        c.setInfoOnComponent(1,"tata");
+        d=c.selectByTupleIdSafe(arr2);
+        self.assertEqual(5,d.getNumberOfTuples());
+        self.assertEqual(2,d.getNumberOfComponents());
+        self.assertTrue(d.getInfoOnComponent(0)=="toto");
+        self.assertTrue(d.getInfoOnComponent(1)=="tata");
+        expected2=[5,15,3,13,1,11,7,17,6,16]
+        for i in xrange(10):
+            self.assertEqual(expected2[i],d.getIJ(0,i));
+            pass
+        self.assertRaises(Exception,c.selectByTupleIdSafe,arr4);
+        self.assertRaises(Exception,c.selectByTupleIdSafe,arr5);
+        pass
+
+    def testAreCellsIncludedIn1(self):
+        m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+        pt=[1,3]
+        m2=m.buildPartOfMySelf(pt,True);
+        ret,tmp=m.areCellsIncludedIn(m2,0)
+        self.assertTrue(ret);
+        self.assertEqual(2,tmp.getNumberOfTuples());
+        self.assertEqual(1,tmp.getNumberOfComponents());
+        self.assertEqual(pt[0],tmp.getIJ(0,0));
+        self.assertEqual(pt[1],tmp.getIJ(0,1));
+        ret,tmp=m2.areCellsIncludedIn(m,0)
+        self.assertTrue(not ret);
+        pass
+
+    def testSwigErrorProtection1(self):
+        m=MEDCouplingDataForTest.build3DTargetMesh_1();
+        m.rotate([0.,0.,0.],[0.3,0.6,1.2],0.37)
+        m.rotate([0.,0.,0.],[0.3,6,1.2],0.37)
+        self.assertRaises(Exception,m.rotate,[0.,0.,0.],(0.3,6,"1.2"),0.37)
+        self.assertRaises(Exception,m.rotate,[0.,"0.",0.],[0.3,0.6,1.2],0.37)
+        self.assertRaises(Exception,m.rotate,[0.,0.,0.],[0.3,'0.6',1.2],0.37)
+        m2=m.buildPartOfMySelf([2,5],True)
+        m3=m.buildPartOfMySelf((2,5),True)
+        self.assertTrue(m2.isEqual(m3,1e-12))
+        self.assertRaises(Exception,m.buildPartOfMySelf,[2,5.],True)
+        da1=m.getCoords().keepSelectedComponents([1])
+        da2=m.getCoords().keepSelectedComponents((1,))
+        self.assertTrue(da1.isEqual(da2,1e-12))
+        self.assertRaises(Exception,m.getCoords().keepSelectedComponents,["1"])
+        pass
+
+    def testDAIBuildSubstraction1(self):
+        a=DataArrayInt.New()
+        aa=[2,3,6,8,9]
+        a.setValues(aa,5,1)
+        b=DataArrayInt.New()
+        bb=[1,3,5,9,11]
+        b.setValues(bb,5,1)
+        self.assertEqual([2,6,8],a.buildSubstraction(b).getValues())
+        pass
+
+    def testBuildOrthogonalField2(self):
+        m=MEDCouplingDataForTest.build2DTargetMesh_1();
+        d1=DataArrayInt.New();
+        d2=DataArrayInt.New();
+        d3=DataArrayInt.New();
+        d4=DataArrayInt.New();
+        m1=m.buildDescendingConnectivity(d1,d2,d3,d4);
+        #
+        f1=m1.buildOrthogonalField();
+        da1=f1.getArray();
+        self.assertEqual(2,da1.getNumberOfComponents());
+        self.assertEqual(13,da1.getNumberOfTuples());
+        #
+        expected1=[-1.,0.,0.,1.,1.,0.,0.,-1.,0.707106781186548,0.707106781186548,0.,-1.,0.,1.,1.,0.,0.,1.,1.,0.,-1.,0.,0.,1.,1.,0.];
+        for i in xrange(26):
+            self.assertAlmostEqual(expected1[i],da1.getIJ(0,i),14);
+            pass
+        pass
+
+    def testSwigErrorProtection2(self):
+        m=MEDCouplingDataForTest.build2DTargetMesh_1();
+        coo=m.getCoords()
+        c=m.getNodalConnectivity()
+        ci=m.getNodalConnectivityIndex()
+        del m
+        self.assertEqual(2,coo.getNumberOfComponents());
+        self.assertEqual(6,ci.getNumberOfTuples());
+        self.assertEqual(23,c.getNumberOfTuples());
+        m=MEDCouplingDataForTest.build2DTargetMesh_1();
+        f=m.getMeasureField(True)
+        c=f.getArray()
+        del f
+        self.assertEqual(1,c.getNumberOfComponents());
+        m=MEDCouplingCMesh.New()
+        x=DataArrayDouble.New()
+        x.setValues([1.,2.,4.],3,1)
+        m.setCoordsAt(0,x)
+        del x
+        xx=m.getCoordsAt(0)
+        del m
+        self.assertEqual(3,xx.getNumberOfTuples());
+        #
+        m=MEDCouplingDataForTest.build2DTargetMesh_1();
+        f=m.getMeasureField(True)
+        m2=f.getMesh()
+        del m
+        del f
+        self.assertEqual(5,m2.getNumberOfCells());
+        pass
+
+    def testUMInsertNextCell1(self):
+        targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ]
+        targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]
+        targetMesh=MEDCouplingUMesh.New();
+        targetMesh.allocateCells(5);
+        self.assertRaises(Exception,targetMesh.insertNextCell,NORM_QUAD4,4,targetConn[0:4])
+        targetMesh.setMeshDimension(2);
+        targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4])
+        self.assertRaises(Exception,targetMesh.insertNextCell,NORM_TETRA4,4,targetConn[0:4])
+        self.assertRaises(Exception,targetMesh.insertNextCell,NORM_SEG2,2,targetConn[0:2])
+        self.assertRaises(Exception,targetMesh.insertNextCell,NORM_POINT0,1,targetConn[0:1])
+        targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7])
+        targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10])
+        targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14])
+        targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18])
+        targetMesh.finishInsertingCells();
+        myCoords=DataArrayDouble.New();
+        myCoords.setValues(targetCoords,9,2);
+        targetMesh.setCoords(myCoords);
+        targetMesh.checkCoherency();
+        pass
+
+    def testFieldOperatorDivDiffComp1(self):
+        m=MEDCouplingDataForTest.build2DTargetMesh_1();
+        m1,d0,d1,d2,d3=m.buildDescendingConnectivity();
+        #
+        f1=m1.buildOrthogonalField();
+        arr1=[2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.]
+        arr=DataArrayDouble.New();
+        arr.setValues(arr1,13,1);
+        f2=MEDCouplingFieldDouble.New(ON_CELLS);
+        f2.setArray(arr);
+        f2.setMesh(m1);
+        f2.checkCoherency();
+        #
+        f3=f1/f2;
+        self.assertRaises(Exception,f2.__div__,f1)
+        f3.checkCoherency();
+        f1/=f2;
+        #self.assertRaises(Exception,f2.__idiv__,f1) # mem leaks
+        self.assertTrue(f1.isEqual(f3,1e-10,1e-10));
+        expected1=[-0.5, 0.0, 0.0, 0.33333333333333331, 0.25, 0.0, 0.0, -0.20000000000000001, 0.117851130197758, 0.117851130197758, 0.0, -0.14285714285714285, 0.0, 0.125, 0.1111111111111111, 0.0, 0.0, 0.10000000000000001, 0.090909090909090912, 0.0, -0.083333333333333329, 0.0, 0.0, 0.076923076923076927, 0.071428571428571425, 0.0]
+        for i in xrange(26):
+            self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),10);
+            pass
+        pass
+
+    def testDARearrange1(self):
+        da1=DataArrayInt.New();
+        da1.alloc(12,1);
+        da1.iota(0);
+        #
+        self.assertEqual(12,da1.getNbOfElems());
+        self.assertEqual(1,da1.getNumberOfComponents());
+        self.assertEqual(12,da1.getNumberOfTuples());
+        da1.rearrange(4);
+        self.assertEqual(12,da1.getNbOfElems());
+        self.assertEqual(4,da1.getNumberOfComponents());
+        self.assertEqual(3,da1.getNumberOfTuples());
+        for i in xrange(12):
+            self.assertEqual(i,da1.getIJ(0,i));
+        #
+        da1.rearrange(6);
+        self.assertEqual(12,da1.getNbOfElems());
+        self.assertEqual(6,da1.getNumberOfComponents());
+        self.assertEqual(2,da1.getNumberOfTuples());
+        for i in xrange(12):
+            self.assertEqual(i,da1.getIJ(0,i));
+        #
+        self.assertRaises(da1.rearrange(7),Exception);
+        #
+        da1.rearrange(12);
+        self.assertEqual(12,da1.getNbOfElems());
+        self.assertEqual(12,da1.getNumberOfComponents());
+        self.assertEqual(1,da1.getNumberOfTuples());
+        for i in xrange(12):
+            self.assertEqual(i,da1.getIJ(0,i));
+        #
+        da1.rearrange(3);
+        self.assertEqual(12,da1.getNbOfElems());
+        self.assertEqual(3,da1.getNumberOfComponents());
+        self.assertEqual(4,da1.getNumberOfTuples());
+        for i in xrange(12):
+            self.assertEqual(i,da1.getIJ(0,i));
+        #double
+        da2=da1.convertToDblArr();
+        #
+        self.assertEqual(12,da2.getNbOfElems());
+        self.assertEqual(3,da2.getNumberOfComponents());
+        self.assertEqual(4,da2.getNumberOfTuples());
+        da2.rearrange(4);
+        self.assertEqual(12,da2.getNbOfElems());
+        self.assertEqual(4,da2.getNumberOfComponents());
+        self.assertEqual(3,da2.getNumberOfTuples());
+        for i in xrange(12):
+            self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
+        #
+        da2.rearrange(6);
+        self.assertEqual(12,da2.getNbOfElems());
+        self.assertEqual(6,da2.getNumberOfComponents());
+        self.assertEqual(2,da2.getNumberOfTuples());
+        for i in xrange(12):
+            self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
+        #
+        self.assertRaises(da2.rearrange(7),Exception);
+        #
+        da2.rearrange(1);
+        self.assertTrue(ptr2==da2.getConstPointer());
+        self.assertEqual(12,da2.getNbOfElems());
+        self.assertEqual(1,da2.getNumberOfComponents());
+        self.assertEqual(12,da2.getNumberOfTuples());
+        for i in xrange(12):
+            self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
+        #
+        da2.rearrange(3);
+        self.assertEqual(12,da2.getNbOfElems());
+        self.assertEqual(3,da2.getNumberOfComponents());
+        self.assertEqual(4,da2.getNumberOfTuples());
+        for i in xrange(12):
+            self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
+        pass
+
+    def testDARearrange1(self):
+        da1=DataArrayInt.New();
+        arr=[1,2,3,2,2,3,5,1,5,5,2,2]
+        da1.setValues(arr,4,3);
+        s=da1.getDifferentValues(True);# API different from C++ because SWIG complains...
+        expected1=[1,2,3,5]
+        self.assertEqual(expected1,s);
+        pass
+
+    def testSwigErrorProtection3(self):
+        da=DataArrayInt.New()
+        da.setValues([1,2,3,4],4,3)
+        self.assertEqual([1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0],da.getValues())
+        self.assertEqual(3,da.getNumberOfComponents());
+        self.assertEqual(4,da.getNumberOfTuples());
+        da=DataArrayInt.New()
+        da.setValues((1,2,3,4,4,3),4,3)
+        self.assertEqual([1, 2, 3, 4, 4, 3, 0, 0, 0, 0, 0, 0],da.getValues())
+        self.assertEqual(3,da.getNumberOfComponents());
+        self.assertEqual(4,da.getNumberOfTuples());
+        da.setValues(10*[1]+290*[2],4,3)
+        self.assertEqual(10*[1]+[2,2],da.getValues())
+        self.assertEqual(3,da.getNumberOfComponents());
+        self.assertEqual(4,da.getNumberOfTuples());
+        #
+        da=DataArrayDouble.New()
+        da.setValues([1,2,3.,4],4,3)
+        self.assertEqual([1., 2., 3., 4., 0., 0., 0., 0., 0., 0., 0., 0.],da.getValues())
+        self.assertEqual(3,da.getNumberOfComponents());
+        self.assertEqual(4,da.getNumberOfTuples());
+        da=DataArrayDouble.New()
+        da.setValues((1,2,3,4.,4,3),4,3)
+        self.assertEqual([1., 2., 3., 4., 4., 3., 0., 0., 0., 0., 0., 0.],da.getValues())
+        self.assertEqual(3,da.getNumberOfComponents());
+        self.assertEqual(4,da.getNumberOfTuples());
+        da.setValues(10*[1]+290*[2],4,3)
+        self.assertEqual(10*[1.]+[2.,2.],da.getValues())
+        self.assertEqual(3,da.getNumberOfComponents());
+        self.assertEqual(4,da.getNumberOfTuples());
+        pass
     
     def setUp(self):
         pass
index d152e2a4b21a237f4bc9db43af093c99e0fa4f41..e00c447eab6905f710dfc6d28bcc16ae8a4fa4eb 100644 (file)
@@ -18,7 +18,7 @@
 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-from libMEDCoupling_Swig import *
+from MEDCoupling import *
 
 class MEDCouplingDataForTest:
     def build2DTargetMesh_1(cls):
diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapper.i b/src/MEDCoupling_Swig/MEDCouplingRemapper.i
new file mode 100644 (file)
index 0000000..ae383b8
--- /dev/null
@@ -0,0 +1,42 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module MEDCouplingRemapper
+
+#define MEDCOUPLING_EXPORT
+#define INTERPKERNEL_EXPORT
+#define MEDCOUPLINGREMAPPER_EXPORT
+
+%{
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingField.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingRemapper.hxx"
+
+using namespace ParaMEDMEM;
+using namespace INTERP_KERNEL;
+%}
+
+%newobject ParaMEDMEM::MEDCouplingRemapper::transferField;
+%newobject ParaMEDMEM::MEDCouplingRemapper::reverseTransferField;
+
+%include "MEDCoupling.i"
+%include "InterpolationOptions.hxx"
+%include "MEDCouplingRemapper.hxx"
index 4be38ae907c7445dc07df35c813a9d9bcd34f410..4f38166b5ad9bbbea4fe27ce405f0133cd2c86ef 100644 (file)
@@ -18,7 +18,7 @@
 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-from libMEDCouplingRemapper_Swig import *
+from MEDCouplingRemapper import *
 from math import *
 import unittest
 
index d1af65ba8c5de44a72e184d3b96bf33215cc5320..42dcee2779550bec12b38e59391869c9b43b91e9 100644 (file)
@@ -21,7 +21,7 @@
 #include <numpy/arrayobject.h>
 #endif
 
-static PyObject* convertMesh(ParaMEDMEM::MEDCouplingMesh* mesh, int owner)
+static PyObject* convertMesh(ParaMEDMEM::MEDCouplingMesh* mesh, int owner) throw(INTERP_KERNEL::Exception)
 {
   PyObject *ret=0;
   if(dynamic_cast<ParaMEDMEM::MEDCouplingUMesh *>(mesh))
@@ -32,13 +32,14 @@ static PyObject* convertMesh(ParaMEDMEM::MEDCouplingMesh* mesh, int owner)
     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingCMesh,owner);
   if(!ret)
     {
-      PyErr_SetString(PyExc_TypeError,"Not recognized type of mesh on downcast !");
-      PyErr_Print();
+      const char msg[]="Not recognized type of mesh on downcast !";
+      PyErr_SetString(PyExc_TypeError,msg);
+      throw INTERP_KERNEL::Exception(msg);
     }
   return ret;
 }
 
-static PyObject *convertIntArrToPyList(const int *ptr, int size)
+static PyObject *convertIntArrToPyList(const int *ptr, int size) throw(INTERP_KERNEL::Exception)
 {
 #ifndef WITH_NUMPY2
   PyObject *ret=PyList_New(size);
@@ -53,7 +54,7 @@ static PyObject *convertIntArrToPyList(const int *ptr, int size)
 #endif
 }
 
-static PyObject *convertIntArrToPyList2(const std::vector<int>& v)
+static PyObject *convertIntArrToPyList2(const std::vector<int>& v) throw(INTERP_KERNEL::Exception)
 {
 #ifndef WITH_NUMPY2
   int size=v.size();
@@ -69,7 +70,17 @@ static PyObject *convertIntArrToPyList2(const std::vector<int>& v)
 #endif
 }
 
-static PyObject *convertIntArrToPyListOfTuple(const int *vals, int nbOfComp, int nbOfTuples)
+static PyObject *convertIntArrToPyList3(const std::set<int>& v) throw(INTERP_KERNEL::Exception)
+{
+  int size=v.size();
+  PyObject *ret=PyList_New(size);
+  std::set<int>::const_iterator it=v.begin();
+  for(int i=0;i<size;i++,it++)
+    PyList_SetItem(ret,i,PyInt_FromLong(*it));
+  return ret;
+}
+
+static PyObject *convertIntArrToPyListOfTuple(const int *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception)
 {
   PyObject *ret=PyList_New(nbOfTuples);
   for(int i=0;i<nbOfTuples;i++)
@@ -82,7 +93,7 @@ static PyObject *convertIntArrToPyListOfTuple(const int *vals, int nbOfComp, int
   return ret;
 }
 
-static int *convertPyToNewIntArr2(PyObject *pyLi, int *size)
+static int *convertPyToNewIntArr2(PyObject *pyLi, int *size) throw(INTERP_KERNEL::Exception)
 {
   if(PyList_Check(pyLi))
     {
@@ -99,9 +110,31 @@ static int *convertPyToNewIntArr2(PyObject *pyLi, int *size)
           else
             {
               delete [] tmp;
-              PyErr_SetString(PyExc_TypeError,"list must contain integers only");
-              PyErr_Print();
-              return NULL;
+              const char msg[]="list must contain integers only";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
+            }
+        }
+      return tmp;
+    }
+  else if(PyTuple_Check(pyLi))
+    {
+      *size=PyTuple_Size(pyLi);
+      int *tmp=new int[*size];
+      for(int i=0;i<*size;i++)
+        {
+          PyObject *o=PyTuple_GetItem(pyLi,i);
+          if(PyInt_Check(o))
+            {
+              int val=(int)PyInt_AS_LONG(o);
+              tmp[i]=val;
+            }
+          else
+            {
+              delete [] tmp;
+              const char msg[]="tuple must contain integers only";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
             }
         }
       return tmp;
@@ -109,9 +142,9 @@ static int *convertPyToNewIntArr2(PyObject *pyLi, int *size)
   else
     {
 #ifndef WITH_NUMPY2
-      PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr2 : not a list");
-      PyErr_Print();
-      return 0;
+      const char msg[]="convertPyToNewIntArr2 : not a list";
+      PyErr_SetString(PyExc_TypeError,msg);
+      throw INTERP_KERNEL::Exception(msg);
 #else
       if(PyArray_Check(pyLi))
         {
@@ -122,15 +155,15 @@ static int *convertPyToNewIntArr2(PyObject *pyLi, int *size)
         }
       else
         {
-          PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr2 : not a list nor PyArray");
-          PyErr_Print();
-          return 0;
+          const char msg[]="convertPyToNewIntArr2 : not a list nor PyArray";
+          PyErr_SetString(PyExc_TypeError,msg);
+          throw INTERP_KERNEL::Exception(msg);
         }
 #endif
     }
 }
 
-static void convertPyToNewIntArr3(PyObject *pyLi, std::vector<int>& arr)
+static void convertPyToNewIntArr3(PyObject *pyLi, std::vector<int>& arr) throw(INTERP_KERNEL::Exception)
 {
   if(PyList_Check(pyLi))
     {
@@ -146,17 +179,38 @@ static void convertPyToNewIntArr3(PyObject *pyLi, std::vector<int>& arr)
             }
           else
             {
-              PyErr_SetString(PyExc_TypeError,"list must contain integers only");
-              PyErr_Print();
+              const char msg[]="list must contain integers only";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
+            }
+        }
+    }
+  else if(PyTuple_Check(pyLi))
+    {
+      int size=PyTuple_Size(pyLi);
+      arr.resize(size);
+      for(int i=0;i<size;i++)
+        {
+          PyObject *o=PyTuple_GetItem(pyLi,i);
+          if(PyInt_Check(o))
+            {
+              int val=(int)PyInt_AS_LONG(o);
+              arr[i]=val;
+            }
+          else
+            {
+              const char msg[]="tuple must contain integers only";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
             }
         }
     }
   else
     {
 #ifndef WITH_NUMPY2
-      PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr3 : not a list");
-      PyErr_Print();
-      return ;
+      const char msg[]="convertPyToNewIntArr3 : not a list";
+      PyErr_SetString(PyExc_TypeError,msg);
+      throw INTERP_KERNEL::Exception(msg);
 #else
       if(PyArray_Check(pyLi))
         {
@@ -168,15 +222,72 @@ static void convertPyToNewIntArr3(PyObject *pyLi, std::vector<int>& arr)
         }
       else
         {
-          PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr3 : not a list nor PyArray");
-          PyErr_Print();
-          return ;
+          const char msg[]="convertPyToNewIntArr3 : not a list nor PyArray";
+          PyErr_SetString(PyExc_TypeError,msg);
+          throw INTERP_KERNEL::Exception(msg);
         }
 #endif
     }
 }
 
-static PyObject *convertDblArrToPyList(const double *ptr, int size)
+static void fillArrayWithPyListInt(PyObject *pyLi, int *arrToFill, int sizeOfArray, int dftVal) throw(INTERP_KERNEL::Exception)
+{
+  if(PyList_Check(pyLi))
+    {
+      int size=PyList_Size(pyLi);
+      for(int i=0;i<size;i++)
+        {
+          PyObject *o=PyList_GetItem(pyLi,i);
+          if(PyInt_Check(o))
+            {
+              int val=(int)PyInt_AS_LONG(o);
+              if(i<sizeOfArray)
+                arrToFill[i]=val;
+            }
+          else
+            {
+              const char msg[]="list must contain integers only";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
+            }
+        }
+      for(int i=size;i<sizeOfArray;i++)
+        arrToFill[i]=dftVal;
+      return;
+      
+    }
+  else if(PyTuple_Check(pyLi))
+    {
+      int size=PyTuple_Size(pyLi);
+      for(int i=0;i<size;i++)
+        {
+          PyObject *o=PyTuple_GetItem(pyLi,i);
+          if(PyInt_Check(o))
+            {
+              int val=(int)PyInt_AS_LONG(o);
+              if(i<sizeOfArray)
+                arrToFill[i]=val;
+            }
+          else
+            {
+              const char msg[]="tuple must contain integers only";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
+            }
+        }
+      for(int i=size;i<sizeOfArray;i++)
+        arrToFill[i]=dftVal;
+      return;
+    }
+  else
+    {
+      const char msg[]="fillArrayWithPyListInt : not a list";
+      PyErr_SetString(PyExc_TypeError,msg);
+      throw INTERP_KERNEL::Exception(msg);
+    }
+}
+
+static PyObject *convertDblArrToPyList(const double *ptr, int size) throw(INTERP_KERNEL::Exception)
 {
   PyObject *ret=PyList_New(size);
   for(int i=0;i<size;i++)
@@ -184,7 +295,7 @@ static PyObject *convertDblArrToPyList(const double *ptr, int size)
   return ret;
 }
 
-static PyObject *convertDblArrToPyList2(const std::vector<double>& v)
+static PyObject *convertDblArrToPyList2(const std::vector<double>& v) throw(INTERP_KERNEL::Exception)
 {
   int size=v.size();
   PyObject *ret=PyList_New(size);
@@ -193,7 +304,7 @@ static PyObject *convertDblArrToPyList2(const std::vector<double>& v)
   return ret;
 }
 
-static PyObject *convertDblArrToPyListOfTuple(const double *vals, int nbOfComp, int nbOfTuples)
+static PyObject *convertDblArrToPyListOfTuple(const double *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception)
 {
   PyObject *ret=PyList_New(nbOfTuples);
   for(int i=0;i<nbOfTuples;i++)
@@ -206,7 +317,7 @@ static PyObject *convertDblArrToPyListOfTuple(const double *vals, int nbOfComp,
   return ret;
 }
 
-static double *convertPyToNewDblArr2(PyObject *pyLi, int *size)
+static double *convertPyToNewDblArr2(PyObject *pyLi, int *size) throw(INTERP_KERNEL::Exception)
 {
   if(PyList_Check(pyLi))
     {
@@ -220,24 +331,127 @@ static double *convertPyToNewDblArr2(PyObject *pyLi, int *size)
               double val=PyFloat_AS_DOUBLE(o);
               tmp[i]=val;
             }
+          else if(PyInt_Check(o))
+            {
+              long val0=PyInt_AS_LONG(o);
+              double val=val0;
+              tmp[i]=val;
+            }
+          else
+            {
+              delete [] tmp;
+              const char msg[]="convertPyToNewDblArr2 : list must contain floats/integers only";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
+            }
+        }
+      return tmp;
+    }
+  else if(PyTuple_Check(pyLi))
+    {
+      *size=PyTuple_Size(pyLi);
+      double *tmp=new double[*size];
+      for(int i=0;i<*size;i++)
+        {
+          PyObject *o=PyTuple_GetItem(pyLi,i);
+          if(PyFloat_Check(o))
+            {
+              double val=PyFloat_AS_DOUBLE(o);
+              tmp[i]=val;
+            }
+          else if(PyInt_Check(o))
+            {
+              long val0=PyInt_AS_LONG(o);
+              double val=val0;
+              tmp[i]=val;
+            }
           else
             {
-              PyErr_SetString(PyExc_TypeError,"convertPyToNewDblArr2 : list must contain floats only");
-              PyErr_Print();
-              return NULL;
+              delete [] tmp;
+              const char msg[]="convertPyToNewDblArr2 : tuple must contain floats/integers only";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
             }
         }
       return tmp;
     }
   else
     {
-      PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr : not a list");
-      PyErr_Print();
-      return 0;
+      const char msg[]="convertPyToNewDblArr2 : not a list";
+      PyErr_SetString(PyExc_TypeError,msg);
+      throw INTERP_KERNEL::Exception(msg);
     }
 }
 
-void convertPyObjToVecUMeshes(PyObject *ms, std::vector<ParaMEDMEM::MEDCouplingUMesh *>& v)
+static void fillArrayWithPyListDbl(PyObject *pyLi, double *arrToFill, int sizeOfArray, double dftVal) throw(INTERP_KERNEL::Exception)
+{
+  if(PyList_Check(pyLi))
+    {
+      int size=PyList_Size(pyLi);
+      for(int i=0;i<size;i++)
+        {
+          PyObject *o=PyList_GetItem(pyLi,i);
+          if(PyFloat_Check(o))
+            {
+              double val=PyFloat_AS_DOUBLE(o);
+              if(i<sizeOfArray)
+                arrToFill[i]=val;
+            }
+          else if(PyInt_Check(o))
+            {
+              long val0=PyInt_AS_LONG(o);
+              double val=val0;
+              if(i<sizeOfArray)
+                arrToFill[i]=val;
+            }
+          else
+            {
+              const char msg[]="fillArrayWithPyListDbl : list must contain floats/integers only";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
+            }
+        }
+      for(int i=size;i<sizeOfArray;i++)
+        arrToFill[i]=dftVal;
+      return;
+    }
+  else if(PyTuple_Check(pyLi))
+    {
+      int size=PyTuple_Size(pyLi);
+      for(int i=0;i<size;i++)
+        {
+          PyObject *o=PyTuple_GetItem(pyLi,i);
+          if(PyFloat_Check(o))
+            {
+              double val=PyFloat_AS_DOUBLE(o);
+              arrToFill[i]=val;
+            }
+          else if(PyInt_Check(o))
+            {
+              long val0=PyInt_AS_LONG(o);
+              double val=val0;
+              arrToFill[i]=val;
+            }
+          else
+            {
+              const char msg[]="fillArrayWithPyListDbl : tuple must contain floats/integers only";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
+            }
+        }
+      for(int i=size;i<sizeOfArray;i++)
+        arrToFill[i]=dftVal;
+      return ;
+    }
+  else
+    {
+      const char msg[]="convertPyToNewIntArr : not a list";
+      PyErr_SetString(PyExc_TypeError,msg);
+      throw INTERP_KERNEL::Exception(msg);
+    }
+}
+
+void convertPyObjToVecUMeshes(PyObject *ms, std::vector<ParaMEDMEM::MEDCouplingUMesh *>& v) throw(INTERP_KERNEL::Exception)
 {
   if(PyList_Check(ms))
     {
@@ -250,9 +464,9 @@ void convertPyObjToVecUMeshes(PyObject *ms, std::vector<ParaMEDMEM::MEDCouplingU
           int status=SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,0|0);
           if(!SWIG_IsOK(status))
             {
-              PyErr_SetString(PyExc_TypeError,"list must contain only DataArrayInt");
-              PyErr_Print();
-              return;
+              const char msg[]="list must contain only MEDCouplingUMesh";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
             }
           ParaMEDMEM::MEDCouplingUMesh *arg=reinterpret_cast< ParaMEDMEM::MEDCouplingUMesh * >(argp);
           v[i]=arg;
@@ -260,12 +474,129 @@ void convertPyObjToVecUMeshes(PyObject *ms, std::vector<ParaMEDMEM::MEDCouplingU
     }
   else
     {
-      PyErr_SetString(PyExc_TypeError,"convertPyObjToVecUMeshes : not a list");
-      PyErr_Print();
+      const char msg[]="convertPyObjToVecUMeshes : not a list";
+      PyErr_SetString(PyExc_TypeError,msg);
+      throw INTERP_KERNEL::Exception(msg);
+    }
+}
+
+void convertPyObjToVecUMeshesCst(PyObject *ms, std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& v) throw(INTERP_KERNEL::Exception)
+{
+  if(PyList_Check(ms))
+    {
+      int size=PyList_Size(ms);
+      v.resize(size);
+      for(int i=0;i<size;i++)
+        {
+          PyObject *obj=PyList_GetItem(ms,i);
+          void *argp;
+          int status=SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,0|0);
+          if(!SWIG_IsOK(status))
+            {
+              const char msg[]="list must contain only MEDCouplingUMesh";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
+            }
+          const ParaMEDMEM::MEDCouplingUMesh *arg=reinterpret_cast< const ParaMEDMEM::MEDCouplingUMesh * >(argp);
+          v[i]=arg;
+        }
+    }
+  else
+    {
+      const char msg[]="convertPyObjToVecUMeshesCst : not a list";
+      PyErr_SetString(PyExc_TypeError,msg);
+      throw INTERP_KERNEL::Exception(msg);
+    }
+}
+
+void convertPyObjToVecDataArrayDblCst(PyObject *ms, std::vector<const ParaMEDMEM::DataArrayDouble *>& v) throw(INTERP_KERNEL::Exception)
+{
+  if(PyList_Check(ms))
+    {
+      int size=PyList_Size(ms);
+      v.resize(size);
+      for(int i=0;i<size;i++)
+        {
+          PyObject *obj=PyList_GetItem(ms,i);
+          void *argp;
+          int status=SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+          if(!SWIG_IsOK(status))
+            {
+              const char msg[]="list must contain only DataArrayDouble";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
+            }
+          const ParaMEDMEM::DataArrayDouble *arg=reinterpret_cast< const ParaMEDMEM::DataArrayDouble * >(argp);
+          v[i]=arg;
+        }
+    }
+  else
+    {
+      const char msg[]="convertPyObjToVecDataArrayDblCst : not a list";
+      PyErr_SetString(PyExc_TypeError,msg);
+      throw INTERP_KERNEL::Exception(msg);
+    }
+}
+
+void convertPyObjToVecFieldDblCst(PyObject *ms, std::vector<const ParaMEDMEM::MEDCouplingFieldDouble *>& v) throw(INTERP_KERNEL::Exception)
+{
+  if(PyList_Check(ms))
+    {
+      int size=PyList_Size(ms);
+      v.resize(size);
+      for(int i=0;i<size;i++)
+        {
+          PyObject *obj=PyList_GetItem(ms,i);
+          void *argp;
+          int status=SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble,0|0);
+          if(!SWIG_IsOK(status))
+            {
+              const char msg[]="list must contain only MEDCouplingFieldDouble";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
+            }
+          const ParaMEDMEM::MEDCouplingFieldDouble *arg=reinterpret_cast< const ParaMEDMEM::MEDCouplingFieldDouble * >(argp);
+          v[i]=arg;
+        }
+    }
+  else
+    {
+      const char msg[]="convertPyObjToVecFieldDblCst : not a list";
+      PyErr_SetString(PyExc_TypeError,msg);
+      throw INTERP_KERNEL::Exception(msg);
+    }
+}
+
+void convertPyObjToVecDataArrayInt(PyObject *ms, std::vector<ParaMEDMEM::DataArrayInt *>& v) throw(INTERP_KERNEL::Exception)
+{
+  if(PyList_Check(ms))
+    {
+      int size=PyList_Size(ms);
+      v.resize(size);
+      for(int i=0;i<size;i++)
+        {
+          PyObject *obj=PyList_GetItem(ms,i);
+          void *argp;
+          int status=SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
+          if(!SWIG_IsOK(status))
+            {
+              const char msg[]="list must contain only DataArrayInt";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
+            }
+          ParaMEDMEM::DataArrayInt *arg=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
+          v[i]=arg;
+        }
+    }
+  else
+    {
+      const char msg[]="convertPyObjToVecDataArrayInt : not a list";
+      PyErr_SetString(PyExc_TypeError,msg);
+      throw INTERP_KERNEL::Exception(msg);
     }
 }
 
-void convertPyObjToVecDataArrayInt(PyObject *ms, std::vector<ParaMEDMEM::DataArrayInt *>& v)
+void convertPyObjToVecDataArrayIntCst(PyObject *ms, std::vector<const ParaMEDMEM::DataArrayInt *>& v) throw(INTERP_KERNEL::Exception)
 {
   if(PyList_Check(ms))
     {
@@ -278,9 +609,9 @@ void convertPyObjToVecDataArrayInt(PyObject *ms, std::vector<ParaMEDMEM::DataArr
           int status=SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
           if(!SWIG_IsOK(status))
             {
-              PyErr_SetString(PyExc_TypeError,"list must contain only DataArrayInt");
-              PyErr_Print();
-              return;
+              const char msg[]="list must contain only DataArrayInt";
+              PyErr_SetString(PyExc_TypeError,msg);
+              throw INTERP_KERNEL::Exception(msg);
             }
           ParaMEDMEM::DataArrayInt *arg=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
           v[i]=arg;
@@ -288,7 +619,8 @@ void convertPyObjToVecDataArrayInt(PyObject *ms, std::vector<ParaMEDMEM::DataArr
     }
   else
     {
-      PyErr_SetString(PyExc_TypeError,"convertPyObjToVecDataArrayInt : not a list");
-      PyErr_Print();
+      const char msg[]="convertPyObjToVecDataArrayInt : not a list";
+      PyErr_SetString(PyExc_TypeError,msg);
+      throw INTERP_KERNEL::Exception(msg);
     }
 }
index fd14551f1c4025d69dcc1a88d7f9bc1168fb5d98..5770f5c85a782ceb597f0515c9e3eaf8bc6df653 100644 (file)
 #
 include $(top_srcdir)/adm_local/unix/make_common_starter.am
 
-lib_LTLIBRARIES = _libMEDCoupling_Swig.la _libMEDCouplingRemapper_Swig.la
+lib_LTLIBRARIES = _MEDCoupling.la _MEDCouplingRemapper.la
 
 salomeinclude_HEADERS =  \
-       libMEDCoupling_Swig.i libMEDCouplingRemapper_Swig.i MEDCouplingTypemaps.i
+       MEDCoupling.i MEDCouplingRemapper.i MEDCouplingTypemaps.i
 
-BUILT_SOURCES = libMEDCoupling_SwigWRAP.cxx libMEDCouplingRemapper_SwigWRAP.cxx
+BUILT_SOURCES = MEDCouplingWRAP.cxx MEDCouplingRemapperWRAP.cxx
 
 SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../MEDCoupling -I$(srcdir)/../INTERP_KERNEL/Bases -I$(srcdir)/../INTERP_KERNEL
 
-dist__libMEDCoupling_Swig_la_SOURCES   = libMEDCoupling_Swig.i MEDCouplingTypemaps.i
-nodist__libMEDCoupling_Swig_la_SOURCES = libMEDCoupling_SwigWRAP.cxx
-libMEDCoupling_Swig.py: libMEDCoupling_SwigWRAP.cxx
+dist__MEDCoupling_la_SOURCES   = MEDCoupling.i MEDCouplingTypemaps.i
+nodist__MEDCoupling_la_SOURCES = MEDCouplingWRAP.cxx
+MEDCoupling.py: MEDCouplingWRAP.cxx
 
-libMEDCoupling_SwigWRAP.cxx: libMEDCoupling_Swig.i MEDCouplingTypemaps.i
+MEDCouplingWRAP.cxx: MEDCoupling.i MEDCouplingTypemaps.i
        $(SWIG) $(SWIG_FLAGS) -o $@  $<
 
-_libMEDCoupling_Swig_la_CPPFLAGS = $(PYTHON_INCLUDES) \
+_MEDCoupling_la_CPPFLAGS = $(PYTHON_INCLUDES) \
        @CXXTMPDPTHFLAGS@ -I$(srcdir)/../MEDCoupling -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Bases
 
-_libMEDCoupling_Swig_la_LDFLAGS  = -module $(PYTHON_LIBS) \
+_MEDCoupling_la_LDFLAGS  = -module $(PYTHON_LIBS) \
        ../MEDCoupling/libmedcoupling.la ../INTERP_KERNEL/libinterpkernel.la
 
-dist__libMEDCouplingRemapper_Swig_la_SOURCES   = libMEDCouplingRemapper_Swig.i
-nodist__libMEDCouplingRemapper_Swig_la_SOURCES = libMEDCouplingRemapper_SwigWRAP.cxx
-libMEDCouplingRemapper_Swig.py: libMEDCouplingRemapper_SwigWRAP.cxx
+dist__MEDCouplingRemapper_la_SOURCES = MEDCouplingRemapper.i
+nodist__MEDCouplingRemapper_la_SOURCES = MEDCouplingRemapperWRAP.cxx
+MEDCouplingRemapper.py: MEDCouplingRemapperWRAP.cxx
 
-libMEDCouplingRemapper_SwigWRAP.cxx: libMEDCouplingRemapper_Swig.i MEDCouplingTypemaps.i
+MEDCouplingRemapperWRAP.cxx: MEDCouplingRemapper.i MEDCouplingTypemaps.i
        $(SWIG) $(SWIG_FLAGS) -o $@  $<
 
-_libMEDCouplingRemapper_Swig_la_CPPFLAGS = $(PYTHON_INCLUDES) \
+_MEDCouplingRemapper_la_CPPFLAGS = $(PYTHON_INCLUDES) \
        @CXXTMPDPTHFLAGS@ -I$(srcdir)/../MEDCoupling -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Bases
 
-_libMEDCouplingRemapper_Swig_la_LDFLAGS  = -module $(PYTHON_LIBS) \
+_MEDCouplingRemapper_la_LDFLAGS  = -module $(PYTHON_LIBS) \
        ../MEDCoupling/libmedcouplingremapper.la ../INTERP_KERNEL/libinterpkernel.la
 
-CLEANFILES = libMEDCoupling_SwigWRAP.cxx libMEDCoupling_Swig.py libMEDCouplingRemapper_SwigWRAP.cxx libMEDCouplingRemapper_Swig.py
+CLEANFILES = MEDCouplingWRAP.cxx MEDCoupling.py MEDCouplingRemapperWRAP.cxx MEDCouplingRemapper.py
 
-dist_salomescript_DATA= MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py libMEDCoupling_Swig.py libMEDCouplingRemapper_Swig.py MEDCouplingDataForTest.py
+dist_salomescript_DATA= MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py MEDCoupling.py MEDCouplingRemapper.py MEDCouplingDataForTest.py libMEDCoupling_Swig.py
 
 UNIT_TEST_PROG = MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py
 
diff --git a/src/MEDCoupling_Swig/libMEDCouplingRemapper_Swig.i b/src/MEDCoupling_Swig/libMEDCouplingRemapper_Swig.i
deleted file mode 100644 (file)
index b46f819..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-//  Copyright (C) 2007-2010  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
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-%module libMEDCouplingRemapper_Swig
-
-#define MEDCOUPLING_EXPORT
-#define INTERPKERNEL_EXPORT
-#define MEDCOUPLINGREMAPPER_EXPORT
-
-%{
-#include "MEDCouplingMemArray.hxx"
-#include "MEDCouplingUMesh.hxx"
-#include "MEDCouplingField.hxx"
-#include "MEDCouplingFieldDouble.hxx"
-#include "MEDCouplingRemapper.hxx"
-
-using namespace ParaMEDMEM;
-using namespace INTERP_KERNEL;
-%}
-
-%newobject ParaMEDMEM::MEDCouplingRemapper::transferField;
-%newobject ParaMEDMEM::MEDCouplingRemapper::reverseTransferField;
-
-%include "libMEDCoupling_Swig.i"
-%include "InterpolationOptions.hxx"
-%include "MEDCouplingRemapper.hxx"
diff --git a/src/MEDCoupling_Swig/libMEDCoupling_Swig.i b/src/MEDCoupling_Swig/libMEDCoupling_Swig.i
deleted file mode 100644 (file)
index 65112f6..0000000
+++ /dev/null
@@ -1,1551 +0,0 @@
-//  Copyright (C) 2007-2010  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
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-%module libMEDCoupling_Swig
-
-#define MEDCOUPLING_EXPORT
-
-%include std_vector.i
-%include std_string.i
-
-%{
-#include "MEDCouplingMemArray.hxx"
-#include "MEDCouplingUMesh.hxx"
-#include "MEDCouplingExtrudedMesh.hxx"
-#include "MEDCouplingCMesh.hxx"
-#include "MEDCouplingField.hxx"
-#include "MEDCouplingFieldDouble.hxx"
-#include "MEDCouplingGaussLocalization.hxx"
-#include "MEDCouplingTypemaps.i"
-
-using namespace ParaMEDMEM;
-using namespace INTERP_KERNEL;
-%}
-
-%template(ivec) std::vector<int>;
-%template(dvec) std::vector<double>;
-%template(svec) std::vector<std::string>;
-
-%typemap(out) ParaMEDMEM::MEDCouplingMesh*
-{
-  $result=convertMesh($1,$owner);
-}
-
-%typemap(out) ParaMEDMEM::MEDCouplingPointSet*
-{
-  $result=convertMesh($1,$owner);
-}
-
-#ifdef WITH_NUMPY2
-%init %{ import_array(); %}
-#endif
-
-%feature("autodoc", "1");
-%feature("docstring");
-
-%newobject ParaMEDMEM::MEDCouplingField::buildMeasureField;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::New;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::mergeFields;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::doublyContractedProduct;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::determinant;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::eigenValues;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::eigenVectors;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::inverse;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::trace;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::deviator;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::magnitude;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::maxPerTuple;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::keepSelectedComponents;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::dotFields;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::dot;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::crossProductFields;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::crossProduct;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::maxFields;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::max;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::minFields;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::min;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::getIdsInRange;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator+;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator-;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator*;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator/;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::clone;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::cloneWithMesh;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildNewTimeReprFromThis;
-%newobject ParaMEDMEM::DataArrayInt::New;
-%newobject ParaMEDMEM::DataArrayInt::convertToDblArr;
-%newobject ParaMEDMEM::DataArrayInt::deepCopy;
-%newobject ParaMEDMEM::DataArrayInt::performCpy;
-%newobject ParaMEDMEM::DataArrayInt::substr;
-%newobject ParaMEDMEM::DataArrayInt::changeNbOfComponents;
-%newobject ParaMEDMEM::DataArrayInt::keepSelectedComponents;
-%newobject ParaMEDMEM::DataArrayInt::selectByTupleId;
-%newobject ParaMEDMEM::DataArrayInt::renumber;
-%newobject ParaMEDMEM::DataArrayInt::renumberR;
-%newobject ParaMEDMEM::DataArrayInt::renumberAndReduce;
-%newobject ParaMEDMEM::DataArrayInt::invertArrayO2N2N2O;
-%newobject ParaMEDMEM::DataArrayInt::invertArrayN2O2O2N;
-%newobject ParaMEDMEM::DataArrayInt::getIdsEqual;
-%newobject ParaMEDMEM::DataArrayInt::getIdsEqualList;
-%newobject ParaMEDMEM::DataArrayInt::aggregate;
-%newobject ParaMEDMEM::DataArrayInt::fromNoInterlace;
-%newobject ParaMEDMEM::DataArrayInt::toNoInterlace;
-%newobject ParaMEDMEM::DataArrayDouble::New;
-%newobject ParaMEDMEM::DataArrayDouble::convertToIntArr;
-%newobject ParaMEDMEM::DataArrayDouble::deepCopy;
-%newobject ParaMEDMEM::DataArrayDouble::performCpy;
-%newobject ParaMEDMEM::DataArrayDouble::aggregate;
-%newobject ParaMEDMEM::DataArrayDouble::dot;
-%newobject ParaMEDMEM::DataArrayDouble::crossProduct;
-%newobject ParaMEDMEM::DataArrayDouble::add;
-%newobject ParaMEDMEM::DataArrayDouble::substract;
-%newobject ParaMEDMEM::DataArrayDouble::multiply;
-%newobject ParaMEDMEM::DataArrayDouble::divide;
-%newobject ParaMEDMEM::DataArrayDouble::substr;
-%newobject ParaMEDMEM::DataArrayDouble::changeNbOfComponents;
-%newobject ParaMEDMEM::DataArrayDouble::keepSelectedComponents;
-%newobject ParaMEDMEM::DataArrayDouble::getIdsInRange;
-%newobject ParaMEDMEM::DataArrayDouble::selectByTupleId;
-%newobject ParaMEDMEM::DataArrayDouble::applyFunc;
-%newobject ParaMEDMEM::DataArrayDouble::doublyContractedProduct;
-%newobject ParaMEDMEM::DataArrayDouble::determinant;
-%newobject ParaMEDMEM::DataArrayDouble::eigenValues;
-%newobject ParaMEDMEM::DataArrayDouble::eigenVectors;
-%newobject ParaMEDMEM::DataArrayDouble::inverse;
-%newobject ParaMEDMEM::DataArrayDouble::trace;
-%newobject ParaMEDMEM::DataArrayDouble::deviator;
-%newobject ParaMEDMEM::DataArrayDouble::magnitude;
-%newobject ParaMEDMEM::DataArrayDouble::maxPerTuple;
-%newobject ParaMEDMEM::DataArrayDouble::renumber;
-%newobject ParaMEDMEM::DataArrayDouble::renumberR;
-%newobject ParaMEDMEM::DataArrayDouble::renumberAndReduce;
-%newobject ParaMEDMEM::DataArrayDouble::fromNoInterlace;
-%newobject ParaMEDMEM::DataArrayDouble::toNoInterlace;
-%newobject ParaMEDMEM::DataArrayDouble::fromPolarToCart;
-%newobject ParaMEDMEM::DataArrayDouble::fromCylToCart;
-%newobject ParaMEDMEM::DataArrayDouble::fromSpherToCart;
-%newobject ParaMEDMEM::MEDCouplingMesh::getCoordinatesAndOwner;
-%newobject ParaMEDMEM::MEDCouplingMesh::getBarycenterAndOwner;
-%newobject ParaMEDMEM::MEDCouplingMesh::buildOrthogonalField;
-%newobject ParaMEDMEM::MEDCouplingMesh::getCellIdsFullyIncludedInNodeIds;
-%newobject ParaMEDMEM::MEDCouplingMesh::mergeMyselfWith;
-%newobject ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic;
-%newobject ParaMEDMEM::MEDCouplingMesh::getMeasureField;
-%newobject ParaMEDMEM::MEDCouplingMesh::simplexize;
-%newobject ParaMEDMEM::MEDCouplingPointSet::zipCoordsTraducer;
-%newobject ParaMEDMEM::MEDCouplingPointSet::buildBoundaryMesh;
-%newobject ParaMEDMEM::MEDCouplingUMesh::New;
-%newobject ParaMEDMEM::MEDCouplingUMesh::clone;
-%newobject ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer;
-%newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity;
-%newobject ParaMEDMEM::MEDCouplingUMesh::buildExtrudedMeshFromThis;
-%newobject ParaMEDMEM::MEDCouplingUMesh::mergeUMeshes;
-%newobject ParaMEDMEM::MEDCouplingUMesh::buildNewNumberingFromCommNodesFrmt;
-%newobject ParaMEDMEM::MEDCouplingUMesh::rearrange2ConsecutiveCellTypes;
-%newobject ParaMEDMEM::MEDCouplingUMesh::convertCellArrayPerGeoType;
-%newobject ParaMEDMEM::MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec;
-%newobject ParaMEDMEM::MEDCouplingUMesh::buildDirectionVectorField;
-%newobject ParaMEDMEM::MEDCouplingUMesh::getEdgeRatioField;
-%newobject ParaMEDMEM::MEDCouplingUMesh::getAspectRatioField;
-%newobject ParaMEDMEM::MEDCouplingUMesh::getWarpField;
-%newobject ParaMEDMEM::MEDCouplingUMesh::getSkewField;
-%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::New;
-%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::build3DUnstructuredMesh;
-%newobject ParaMEDMEM::MEDCouplingCMesh::New;
-%newobject ParaMEDMEM::MEDCouplingCMesh::buildUnstructured;
-%feature("unref") DataArrayDouble "$this->decrRef();"
-%feature("unref") MEDCouplingPointSet "$this->decrRef();"
-%feature("unref") MEDCouplingMesh "$this->decrRef();"
-%feature("unref") MEDCouplingUMesh "$this->decrRef();"
-%feature("unref") MEDCouplingExtrudedMesh "$this->decrRef();"
-%feature("unref") MEDCouplingCMesh "$this->decrRef();"
-%feature("unref") DataArrayInt "$this->decrRef();"
-%feature("unref") MEDCouplingField "$this->decrRef();"
-%feature("unref") MEDCouplingFieldDouble "$this->decrRef();"
-
-%rename(assign) *::operator=;
-%ignore ParaMEDMEM::MemArray::operator=;
-%ignore ParaMEDMEM::MemArray::operator[];
-%ignore ParaMEDMEM::MEDCouplingPointSet::getCoords();
-%ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo;
-%ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationDblInfo;
-%ignore ParaMEDMEM::MEDCouplingGaussLocalization::fillWithValues;
-%ignore ParaMEDMEM::MEDCouplingGaussLocalization::buildNewInstanceFromTinyInfo;
-
-%rename (Exception) InterpKernelException;
-%nodefaultctor;
-
-namespace INTERP_KERNEL
-{
-  class Exception
-  {
-  public:
-    Exception(const char* what);
-    ~Exception() throw ();
-    const char *what() const throw ();
-  };
-}
-
-%include "MEDCouplingTimeLabel.hxx"
-%include "MEDCouplingRefCountObject.hxx"
-
-namespace ParaMEDMEM
-{
-  typedef enum
-    {
-      UNSTRUCTURED = 5,
-      UNSTRUCTURED_DESC = 6,
-      CARTESIAN = 7,
-      EXTRUDED = 8
-    } MEDCouplingMeshType;
-
-  class DataArrayInt;
-  class DataArrayDouble;
-  class MEDCouplingFieldDouble;
-
-  class MEDCouplingMesh : public RefCountObject, public TimeLabel
-  {
-  public:
-    void setName(const char *name) { _name=name; }
-    const char *getName() const { return _name.c_str(); }
-    virtual MEDCouplingMeshType getType() const = 0;
-    bool isStructured() const;
-    virtual bool isEqual(const MEDCouplingMesh *other, double prec) const;
-    virtual bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const = 0;
-    virtual void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
-    virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0;
-    virtual int getNumberOfCells() const throw(INTERP_KERNEL::Exception) = 0;
-    virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception) = 0;
-    virtual int getSpaceDimension() const throw(INTERP_KERNEL::Exception) = 0;
-    virtual int getMeshDimension() const throw(INTERP_KERNEL::Exception) = 0;
-    virtual DataArrayDouble *getCoordinatesAndOwner() const = 0;
-    virtual DataArrayDouble *getBarycenterAndOwner() const = 0;
-    virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const = 0;
-    virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const = 0;
-    virtual std::string simpleRepr() const = 0;
-    virtual std::string advancedRepr() const = 0;
-    // tools
-    virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const = 0;
-    virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const = 0;
-    virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception);
-    virtual MEDCouplingFieldDouble *buildOrthogonalField() const = 0;
-    virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception) = 0;
-    virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const;
-    virtual DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
-    static MEDCouplingMesh *mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2);
-    %extend
-       {
-         std::string __str__() const
-         {
-           return self->simpleRepr();
-         }
-
-         int getCellContainingPoint(PyObject *p, double eps) const
-         {
-           int sz;
-           double *pos=convertPyToNewDblArr2(p,&sz);
-           int ret=self->getCellContainingPoint(pos,eps);
-           delete [] pos;
-           return ret;
-         }
-         
-         void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception)
-         {
-           int size;
-           int *tmp=convertPyToNewIntArr2(li,&size);
-           self->renumberCells(tmp,check);
-           delete [] tmp;
-         }
-
-         PyObject *checkGeoEquivalWith(const MEDCouplingMesh *other, int levOfCheck, double prec) const throw(INTERP_KERNEL::Exception)
-         {
-           DataArrayInt *cellCor, *nodeCor;
-           self->checkGeoEquivalWith(other,levOfCheck,prec,cellCor,nodeCor);
-           PyObject *res = PyList_New(2);
-           PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(cellCor),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, cellCor?SWIG_POINTER_OWN | 0:0 ));
-           PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(nodeCor),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, nodeCor?SWIG_POINTER_OWN | 0:0 ));
-           return res;
-         }
-         DataArrayInt *getCellIdsFullyIncludedInNodeIds(PyObject *li) const
-         {
-           int size;
-           int *tmp=convertPyToNewIntArr2(li,&size);
-           DataArrayInt *ret=self->getCellIdsFullyIncludedInNodeIds(tmp,tmp+size);
-           delete [] tmp;
-           return ret;
-         }
-         PyObject *getNodeIdsOfCell(int cellId) const
-         {
-           std::vector<int> conn;
-           self->getNodeIdsOfCell(cellId,conn);
-           return convertIntArrToPyList2(conn);
-         }
-
-         PyObject *getCoordinatesOfNode(int nodeId) const
-         {
-           std::vector<double> coo;
-           self->getCoordinatesOfNode(nodeId,coo);
-           return convertDblArrToPyList2(coo);
-         }
-
-         void scale(PyObject *point, double factor)
-         {
-           int sz;
-           double *p=convertPyToNewDblArr2(point,&sz);
-           self->scale(p,factor);
-           delete [] p;
-         }
-
-         PyObject *getBoundingBox() const throw(INTERP_KERNEL::Exception)
-         {
-           int spaceDim=self->getSpaceDimension();
-           double *tmp=new double[2*spaceDim];
-           self->getBoundingBox(tmp);
-           PyObject *ret=convertDblArrToPyListOfTuple(tmp,2,spaceDim);
-           delete [] tmp;
-           return ret;
-         }
-
-        PyObject *buildPart(PyObject *li) const
-         {
-           int size;
-           int *tmp=convertPyToNewIntArr2(li,&size);
-           MEDCouplingMesh *ret=self->buildPart(tmp,tmp+size);
-           delete [] tmp;
-           return convertMesh(ret, SWIG_POINTER_OWN | 0 );
-         }
-
-        PyObject *buildPartAndReduceNodes(PyObject *li) const
-        {
-          int size;
-          int *tmp=convertPyToNewIntArr2(li,&size);
-          DataArrayInt *arr=0;
-          MEDCouplingMesh *ret=self->buildPartAndReduceNodes(tmp,tmp+size,arr);
-          PyObject *res = PyList_New(2);
-          PyObject *obj0=convertMesh(ret, SWIG_POINTER_OWN | 0 );
-          PyObject *obj1=SWIG_NewPointerObj(SWIG_as_voidptr(arr),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
-          PyList_SetItem(res,0,obj0);
-          PyList_SetItem(res,1,obj1);
-          return res;
-        }
-
-         void translate(PyObject *vector)
-         {
-           int sz;
-           double *v=convertPyToNewDblArr2(vector,&sz);
-           self->translate(v);
-           delete [] v;
-         }
-
-         void rotate(PyObject *center, PyObject *vector, double alpha)
-         {
-           int sz;
-           double *c=convertPyToNewDblArr2(center,&sz);
-           if(!c)
-             return ;
-           double *v=convertPyToNewDblArr2(vector,&sz);
-           if(!v)
-             { delete [] c; return ; }
-           self->rotate(c,v,alpha);
-           delete [] c;
-           delete [] v;
-         }
-       }
-  };
-}
-
-%include "MEDCouplingMemArray.hxx"
-%include "NormalizedUnstructuredMesh.hxx"
-%include "MEDCouplingNatureOfField.hxx"
-%include "MEDCouplingTimeDiscretization.hxx"
-%include "MEDCouplingGaussLocalization.hxx"
-
-namespace ParaMEDMEM
-{
-  class MEDCouplingPointSet : public ParaMEDMEM::MEDCouplingMesh
-    {
-    public:
-      void updateTime();
-      void setCoords(DataArrayDouble *coords);
-      DataArrayDouble *getCoordinatesAndOwner() const;
-      bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const;
-      void zipCoords();
-      double getCaracteristicDimension() const;
-      void changeSpaceDimension(int newSpaceDim, double dftVal=0.) throw(INTERP_KERNEL::Exception);
-      void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
-      virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0;
-      static DataArrayDouble *mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2);
-      static MEDCouplingPointSet *buildInstanceFromMeshType(MEDCouplingMeshType type);
-      virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const = 0;
-      virtual bool isEmptyMesh(const std::vector<int>& tinyInfo) const = 0;
-      //! size of returned tinyInfo must be always the same.
-      void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
-      void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
-      void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
-      void unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
-                           const std::vector<std::string>& littleStrings);
-      virtual void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems) = 0;
-      virtual DataArrayInt *zipCoordsTraducer() = 0;
-      %extend 
-         {
-           std::string __str__() const
-           {
-             return self->simpleRepr();
-           }
-           
-           PyObject *buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex) const
-           {
-             int newNbOfNodes;
-             DataArrayInt *ret0=self->buildNewNumberingFromCommonNodesFormat(comm,commIndex,newNbOfNodes);
-             PyObject *res = PyList_New(2);
-             PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
-             PyList_SetItem(res,1,SWIG_From_int(newNbOfNodes));
-             return res;
-           }
-           
-           PyObject *findCommonNodes(int limitNodeId, double prec) const
-           {
-             DataArrayInt *comm, *commIndex;
-             self->findCommonNodes(limitNodeId,prec,comm,commIndex);
-             PyObject *res = PyList_New(2);
-             PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(comm),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
-             PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(commIndex),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
-             return res;
-           }
-           
-           PyObject *getCoords() const
-           {
-             DataArrayDouble *ret1=self->getCoords();
-             ret1->incrRef();
-             return SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,SWIG_POINTER_OWN | 0);
-           }
-           PyObject *buildPartOfMySelf(PyObject *li, bool keepCoords) const
-           {
-             int size;
-             int *tmp=convertPyToNewIntArr2(li,&size);
-             MEDCouplingPointSet *ret=self->buildPartOfMySelf(tmp,tmp+size,keepCoords);
-             delete [] tmp;
-             return convertMesh(ret, SWIG_POINTER_OWN | 0 );
-           }
-           PyObject *buildPartOfMySelfNode(PyObject *li, bool fullyIn) const
-           {
-             int size;
-             int *tmp=convertPyToNewIntArr2(li,&size);
-             MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(tmp,tmp+size,fullyIn);
-             delete [] tmp;
-             return convertMesh(ret, SWIG_POINTER_OWN | 0 );
-           }
-           PyObject *buildFacePartOfMySelfNode(PyObject *li, bool fullyIn) const
-           {
-             int size;
-             int *tmp=convertPyToNewIntArr2(li,&size);
-             MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(tmp,tmp+size,fullyIn);
-             delete [] tmp;
-             return convertMesh(ret, SWIG_POINTER_OWN | 0 );
-           }
-           PyObject *findBoundaryNodes() const
-           {
-             std::vector<int> nodes;
-             self->findBoundaryNodes(nodes);
-             return convertIntArrToPyList2(nodes);
-           }
-           void renumberNodes(PyObject *li, int newNbOfNodes)
-           {
-             int size;
-             int *tmp=convertPyToNewIntArr2(li,&size);
-             self->renumberNodes(tmp,newNbOfNodes);
-             delete [] tmp;
-           }
-           PyObject *findNodesOnPlane(PyObject *pt, PyObject *vec, double eps) const throw(INTERP_KERNEL::Exception)
-             {
-               std::vector<int> nodes;
-               int sz;
-               double *p=convertPyToNewDblArr2(pt,&sz);
-               double *v=convertPyToNewDblArr2(vec,&sz);
-               self->findNodesOnPlane(p,v,eps,nodes);
-               delete [] v;
-               delete [] p;
-               return convertIntArrToPyList2(nodes);
-             }
-           PyObject *getNodeIdsNearPoint(PyObject *pt, double eps) const throw(INTERP_KERNEL::Exception)
-           {
-             int size;
-             double *pos=convertPyToNewDblArr2(pt,&size);
-             if(size<self->getSpaceDimension())
-               {
-                 delete [] pos;
-                 throw INTERP_KERNEL::Exception("getNodeIdsNearPoint : to tiny array ! must be at least of size SpaceDim !");
-               }
-             std::vector<int> tmp;
-             try
-               {
-                 tmp=self->getNodeIdsNearPoint(pos,eps);
-               }
-             catch(INTERP_KERNEL::Exception& e)
-               {
-                 delete [] pos;
-                 throw e;
-               }
-             delete [] pos;
-             return convertIntArrToPyList2(tmp);
-           }
-
-           PyObject *getNodeIdsNearPoints(PyObject *pt, int nbOfNodes, double eps) const throw(INTERP_KERNEL::Exception)
-           {
-             std::vector<int> c,cI;
-             int size;
-             double *pos=convertPyToNewDblArr2(pt,&size);
-             if(size<self->getSpaceDimension()*nbOfNodes)
-               {
-                 delete [] pos;
-                 throw INTERP_KERNEL::Exception("getNodeIdsNearPoints : to tiny array ! must be at least of size SpaceDim*nbOfNodes !");
-               }
-             try
-               {
-                 self->getNodeIdsNearPoints(pos,nbOfNodes,eps,c,cI);
-               }
-             catch(INTERP_KERNEL::Exception& e)
-               {
-                 delete [] pos;
-                 throw e;
-               }
-             delete [] pos;
-             PyObject *ret=PyTuple_New(2);
-             PyTuple_SetItem(ret,0,convertIntArrToPyList2(c));
-             PyTuple_SetItem(ret,1,convertIntArrToPyList2(cI));
-             return ret;
-           }
-
-           PyObject *giveElemsInBoundingBox(PyObject *bbox, double eps)
-           {
-             std::vector<int> elems;
-             int size;
-             double *tmp=convertPyToNewDblArr2(bbox,&size);
-             self->giveElemsInBoundingBox(tmp,eps,elems);
-             delete [] tmp;
-             return convertIntArrToPyList2(elems);
-           }
-
-           static void rotate2DAlg(PyObject *center, double angle, int nbNodes, PyObject *coords)
-           {
-             int sz;
-             double *c=convertPyToNewDblArr2(center,&sz);
-             double *coo=convertPyToNewDblArr2(coords,&sz);
-             ParaMEDMEM::MEDCouplingPointSet::rotate2DAlg(c,angle,nbNodes,coo);
-             for(int i=0;i<sz;i++)
-               PyList_SetItem(coords,i,PyFloat_FromDouble(coo[i]));
-             delete [] coo;
-             delete [] c;
-           }
-           static void rotate3DAlg(PyObject *center, PyObject *vect, double angle, int nbNodes, PyObject *coords)
-           {
-             int sz,sz2;
-             double *c=convertPyToNewDblArr2(center,&sz);
-             double *coo=convertPyToNewDblArr2(coords,&sz);
-             double *v=convertPyToNewDblArr2(vect,&sz2);
-             ParaMEDMEM::MEDCouplingPointSet::rotate3DAlg(c,v,angle,nbNodes,coo);
-             for(int i=0;i<sz;i++)
-               PyList_SetItem(coords,i,PyFloat_FromDouble(coo[i]));
-             delete [] coo;
-             delete [] c;
-           }
-         }
-    };
-  
-  class MEDCouplingUMesh : public ParaMEDMEM::MEDCouplingPointSet
-  {
-  public:
-    static MEDCouplingUMesh *New();
-    static MEDCouplingUMesh *New(const char *meshName, int meshDim);
-    MEDCouplingUMesh *clone(bool recDeepCpy) const;
-    void updateTime();
-    void checkCoherency() const throw(INTERP_KERNEL::Exception);
-    void setMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception);
-    void allocateCells(int nbOfCells);
-    void finishInsertingCells();
-    void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true);
-    DataArrayInt *getNodalConnectivity() const;
-    DataArrayInt *getNodalConnectivityIndex() const;
-    INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
-    int getNumberOfNodesInCell(int cellId) const;
-    int getMeshLength() const;
-    void computeTypes();
-    std::string reprConnectivityOfThis() const;
-    //tools
-    bool checkConsecutiveCellTypes() const;
-    DataArrayInt *rearrange2ConsecutiveCellTypes();
-    DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception);
-    DataArrayInt *zipConnectivityTraducer(int compType);
-    void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const;
-    MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const;
-    void orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Exception);
-    bool isPresenceOfQuadratic() const;
-    MEDCouplingFieldDouble *buildDirectionVectorField() const;
-    bool isContiguous1D() const throw(INTERP_KERNEL::Exception);
-    void convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception);
-    void convertDegeneratedCells() throw(INTERP_KERNEL::Exception);
-    bool areOnlySimplexCells() const throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *getEdgeRatioField() const throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *getAspectRatioField() const throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *getWarpField() const throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception);
-    %extend {
-      std::string __str__() const
-      {
-        return self->simpleRepr();
-      }
-      void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, PyObject *li)
-      {
-        int sz;
-        int *tmp=convertPyToNewIntArr2(li,&sz);
-        self->insertNextCell(type,size,tmp);
-        delete [] tmp;
-      }
-      PyObject *getAllTypes() const
-      {
-        std::set<INTERP_KERNEL::NormalizedCellType> result=self->getAllTypes();
-        std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iL=result.begin();
-        PyObject *res = PyList_New(result.size());
-        for (int i=0;iL!=result.end(); i++, iL++)
-          PyList_SetItem(res,i,PyInt_FromLong(*iL));
-        return res;
-      }
-      PyObject *mergeNodes(double precision)
-      {
-        bool ret1;
-        int ret2;
-        DataArrayInt *ret0=self->mergeNodes(precision,ret1,ret2);
-        PyObject *res = PyList_New(3);
-        PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
-        PyList_SetItem(res,1,SWIG_From_bool(ret1));
-        PyList_SetItem(res,2,SWIG_From_int(ret2));
-        return res;
-      }
-      PyObject *checkButterflyCells()
-      {
-        std::vector<int> cells;
-        self->checkButterflyCells(cells);
-        return convertIntArrToPyList2(cells);
-      }
-
-      PyObject *splitByType() const
-      {
-        std::vector<MEDCouplingUMesh *> ms=self->splitByType();
-        int sz=ms.size();
-        PyObject *ret = PyList_New(sz);
-        for(int i=0;i<sz;i++)
-          PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(ms[i]),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
-        return ret;
-      }
-
-      PyObject *keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, PyObject *ids) const
-      {
-        std::vector<int> idsPerGeoType;
-        convertPyToNewIntArr3(ids,idsPerGeoType);
-        MEDCouplingUMesh *ret=self->keepSpecifiedCells(type,idsPerGeoType);
-        return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 );
-      }
-
-      bool checkConsecutiveCellTypesAndOrder(PyObject *li) const
-      {
-        int sz;
-        INTERP_KERNEL::NormalizedCellType *order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz);
-        bool ret=self->checkConsecutiveCellTypesAndOrder(order,order+sz);
-        delete [] order;
-        return ret;
-      }
-
-      DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(PyObject *li) const
-      {
-        int sz;
-        INTERP_KERNEL::NormalizedCellType *order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz);
-        DataArrayInt *ret=self->getRenumArrForConsecutiveCellTypesSpec(order,order+sz);
-        delete [] order;
-        return ret;
-      }
-
-      PyObject *getCellsContainingPoints(PyObject *p, int nbOfPoints, double eps) const
-      {
-        int sz;
-        double *pos=convertPyToNewDblArr2(p,&sz);
-        std::vector<int> elts,eltsIndex;
-        self->getCellsContainingPoints(pos,nbOfPoints,eps,elts,eltsIndex);
-        delete [] pos;
-        PyObject *ret=PyList_New(2);
-        PyList_SetItem(ret,0,convertIntArrToPyList2(elts));
-        PyList_SetItem(ret,1,convertIntArrToPyList2(eltsIndex));
-        return ret;
-      }
-
-      PyObject *getCellsContainingPoint(PyObject *p, double eps) const
-      {
-        int sz;
-        double *pos=convertPyToNewDblArr2(p,&sz);
-        std::vector<int> elts;
-        self->getCellsContainingPoint(pos,eps,elts);
-        delete [] pos;
-        return convertIntArrToPyList2(elts);
-      }
-
-      static PyObject *mergeUMeshesOnSameCoords(PyObject *ms) throw(INTERP_KERNEL::Exception)
-      {
-        std::vector<ParaMEDMEM::MEDCouplingUMesh *> meshes;
-        if(PyList_Check(ms))
-          {
-            int sz=PyList_Size(ms);
-            meshes.resize(sz);
-            for(int i=0;i<sz;i++)
-              {
-                PyObject *o=PyList_GetItem(ms,i);
-                void *arg;
-                SWIG_ConvertPtr(o,&arg,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, 0 |  0 );
-                meshes[i]=reinterpret_cast<ParaMEDMEM::MEDCouplingUMesh *>(arg);
-              }
-          }
-        else
-          {
-            PyErr_SetString(PyExc_TypeError,"mergeUMeshesOnSameCoords : not a list as first parameter");
-            PyErr_Print();
-            return 0;
-          }
-        MEDCouplingUMesh *ret=MEDCouplingUMesh::mergeUMeshesOnSameCoords(meshes);
-        return convertMesh(ret, SWIG_POINTER_OWN | 0 );
-      }
-
-      static PyObject *fuseUMeshesOnSameCoords(PyObject *ms, int compType)
-      {
-        int sz;
-        std::vector<MEDCouplingUMesh *> meshes;
-        convertPyObjToVecUMeshes(ms,meshes);
-        std::vector<DataArrayInt *> corr;
-        MEDCouplingUMesh *um=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,compType,corr);
-        sz=corr.size();
-        PyObject *ret1=PyList_New(sz);
-        for(int i=0;i<sz;i++)
-          PyList_SetItem(ret1,i,SWIG_NewPointerObj(SWIG_as_voidptr(corr[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
-        PyObject *ret=PyList_New(2);
-        PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(um),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
-        PyList_SetItem(ret,1,ret1);
-        return ret;
-      }
-
-      PyObject *are2DCellsNotCorrectlyOriented(PyObject *vec, bool polyOnly) const throw(INTERP_KERNEL::Exception)
-      {
-        std::vector<int> cells;
-        int sz;
-        double *v=convertPyToNewDblArr2(vec,&sz);
-        try
-          {
-            self->are2DCellsNotCorrectlyOriented(v,polyOnly,cells);
-          }
-        catch(INTERP_KERNEL::Exception& e)
-          {
-            delete [] v;
-            throw e;
-          }
-        delete [] v;
-        return convertIntArrToPyList2(cells);
-      }
-
-      void orientCorrectly2DCells(PyObject *vec, bool polyOnly) throw(INTERP_KERNEL::Exception)
-      {
-        int sz;
-        double *v=convertPyToNewDblArr2(vec,&sz);
-        try
-          {
-            self->orientCorrectly2DCells(v,polyOnly);
-          }
-        catch(INTERP_KERNEL::Exception& e)
-          {
-            delete [] v;
-            throw e;
-          }
-        delete [] v;
-      }
-      
-      PyObject *arePolyhedronsNotCorrectlyOriented() const throw(INTERP_KERNEL::Exception)
-      {
-        std::vector<int> cells;
-        self->arePolyhedronsNotCorrectlyOriented(cells);
-        return convertIntArrToPyList2(cells);
-      }
-
-      PyObject *getFastAveragePlaneOfThis() const throw(INTERP_KERNEL::Exception)
-      {
-        double vec[3];
-        double pos[3];
-        self->getFastAveragePlaneOfThis(vec,pos);
-        double vals[6];
-        std::copy(vec,vec+3,vals);
-        std::copy(pos,pos+3,vals+3);
-        return convertDblArrToPyListOfTuple(vals,3,2);
-      }
-    }
-    void convertToPolyTypes(const std::vector<int>& cellIdsToConvert);
-    void unPolyze();
-    MEDCouplingUMesh *buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy);
-    static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
-  };
-
-  class MEDCouplingExtrudedMesh : public ParaMEDMEM::MEDCouplingMesh
-  {
-  public:
-    static MEDCouplingExtrudedMesh *New(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception);
-    MEDCouplingUMesh *build3DUnstructuredMesh() const;
-    %extend {
-      std::string __str__() const
-      {
-        return self->simpleRepr();
-      }
-      PyObject *getMesh2D() const
-      {
-        MEDCouplingUMesh *ret=self->getMesh2D();
-        ret->incrRef();
-        return convertMesh(ret, SWIG_POINTER_OWN | 0 );
-      }
-      PyObject *getMesh1D() const
-      {
-        MEDCouplingUMesh *ret=self->getMesh1D();
-        ret->incrRef();
-        return convertMesh(ret, SWIG_POINTER_OWN | 0 );
-      }
-      PyObject *getMesh3DIds() const
-      {
-        DataArrayInt *ret=self->getMesh3DIds();
-        ret->incrRef();
-        return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
-      } 
-    }
-  };
-
-  class MEDCouplingCMesh : public ParaMEDMEM::MEDCouplingMesh
-  {
-  public:
-    static MEDCouplingCMesh *New();
-    void setCoords(DataArrayDouble *coordsX,
-                   DataArrayDouble *coordsY=0,
-                   DataArrayDouble *coordsZ=0);
-    void setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KERNEL::Exception);
-    MEDCouplingUMesh *buildUnstructured() const;
-    %extend {
-      std::string __str__() const
-      {
-        return self->simpleRepr();
-      }
-    }
-  };
-}
-
-%extend ParaMEDMEM::DataArray
-{
-  void copyPartOfStringInfoFrom(const DataArray& other, PyObject *li) throw(INTERP_KERNEL::Exception)
-  {
-    std::vector<int> tmp;
-    convertPyToNewIntArr3(li,tmp);
-    self->copyPartOfStringInfoFrom(other,tmp);
-  }
-
-  void copyPartOfStringInfoFrom2(PyObject *li, const DataArray& other) throw(INTERP_KERNEL::Exception)
-  {
-    std::vector<int> tmp;
-    convertPyToNewIntArr3(li,tmp);
-    self->copyPartOfStringInfoFrom2(tmp,other);
-  }
-}
-
-%extend ParaMEDMEM::DataArrayDouble
- {
-   std::string __str__() const
-   {
-     return self->repr();
-   }
-
-   void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple)
-   {
-     int sz;
-     double *tmp=convertPyToNewDblArr2(li,&sz);
-     self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple);
-   }
-
-   PyObject *getValues()
-   {
-     const double *vals=self->getPointer();
-     return convertDblArrToPyList(vals,self->getNbOfElems());
-   }
-
-   PyObject *getValuesAsTuple()
-   {
-     const double *vals=self->getPointer();
-     int nbOfComp=self->getNumberOfComponents();
-     int nbOfTuples=self->getNumberOfTuples();
-     return convertDblArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
-   }
-
-   DataArrayDouble *renumber(PyObject *li) throw(INTERP_KERNEL::Exception)
-   {
-     int size;
-     int *tmp=convertPyToNewIntArr2(li,&size);
-     if(size!=self->getNumberOfTuples())
-       {
-         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
-            delete [] tmp;
-       }
-     DataArrayDouble *ret=self->renumber(tmp);
-     delete [] tmp;
-     return ret;
-   }
-
-   DataArrayDouble *renumberR(PyObject *li) throw(INTERP_KERNEL::Exception)
-   {
-     int size;
-     int *tmp=convertPyToNewIntArr2(li,&size);
-     if(size!=self->getNumberOfTuples())
-       {
-         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
-            delete [] tmp;
-       }
-     DataArrayDouble *ret=self->renumberR(tmp);
-     delete [] tmp;
-     return ret;
-   }
-
-   DataArrayDouble *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception)
-   {
-     int size;
-     int *tmp=convertPyToNewIntArr2(li,&size);
-     if(size!=self->getNumberOfTuples())
-       {
-         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
-            delete [] tmp;
-       }
-     DataArrayDouble *ret=self->renumberAndReduce(tmp,newNbOfTuple);
-     delete [] tmp;
-     return ret;
-   }
-
-   void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception)
-   {
-     int size;
-     int *tmp=convertPyToNewIntArr2(li,&size);
-     if(size!=self->getNumberOfTuples())
-       {
-         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
-            delete [] tmp;
-       }
-     self->renumberInPlace(tmp);
-     delete [] tmp;
-   }
-
-   void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception)
-   {
-     int size;
-     int *tmp=convertPyToNewIntArr2(li,&size);
-     if(size!=self->getNumberOfTuples())
-       {
-         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
-            delete [] tmp;
-       }
-     self->renumberInPlaceR(tmp);
-     delete [] tmp;
-   }
-
-   DataArrayDouble *selectByTupleId(PyObject *li) const
-   {
-     int size;
-     int *tmp=convertPyToNewIntArr2(li,&size);
-     DataArrayDouble *ret=self->selectByTupleId(tmp,tmp+size);
-     delete [] tmp;
-     return ret;
-   }
-
-   PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception)
-   {
-     int tmp;
-     double r1=self->getMaxValue(tmp);
-     PyObject *ret=PyTuple_New(2);
-     PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
-     PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
-     return ret;
-   }
-
-   PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception)
-   {
-     DataArrayInt *tmp;
-     double r1=self->getMaxValue2(tmp);
-     PyObject *ret=PyTuple_New(2);
-     PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
-     PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
-     return ret;
-   }
-
-   PyObject *getMinValue() const throw(INTERP_KERNEL::Exception)
-   {
-     int tmp;
-     double r1=self->getMinValue(tmp);
-     PyObject *ret=PyTuple_New(2);
-     PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
-     PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
-     return ret;
-   }
-
-   PyObject *getMinValue2() const throw(INTERP_KERNEL::Exception)
-   {
-     DataArrayInt *tmp;
-     double r1=self->getMinValue2(tmp);
-     PyObject *ret=PyTuple_New(2);
-     PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
-     PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
-     return ret;
-   }
-
-   PyObject *accumulate() const throw(INTERP_KERNEL::Exception)
-   {
-     int sz=self->getNumberOfComponents();
-     double *tmp=new double[sz];
-     try
-       {
-         self->accumulate(tmp);
-       }
-     catch(INTERP_KERNEL::Exception& e)
-       {
-         delete [] tmp;
-         throw e;
-       }
-     PyObject *ret=convertDblArrToPyList(tmp,sz);
-     delete [] tmp;
-     return ret;
-   }
-   
-   DataArrayDouble *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
-   {
-     std::vector<int> tmp;
-     convertPyToNewIntArr3(li,tmp);
-     return self->keepSelectedComponents(tmp);
-   }
-
-   void setSelectedComponents(const DataArrayDouble *a, PyObject *li) throw(INTERP_KERNEL::Exception)
-   {
-     std::vector<int> tmp;
-     convertPyToNewIntArr3(li,tmp);
-     self->setSelectedComponents(a,tmp);
-   }
- };
-
-%extend ParaMEDMEM::DataArrayInt
- {
-   std::string __str__() const
-   {
-     return self->repr();
-   }
-
-   void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple)
-   {
-     int size;
-     int *tmp=convertPyToNewIntArr2(li,&size);
-     self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple);
-   }
-
-   PyObject *getValues()
-   {
-     const int *vals=self->getPointer();
-     return convertIntArrToPyList(vals,self->getNbOfElems());
-   }
-
-   PyObject *getValuesAsTuple()
-   {
-     const int *vals=self->getPointer();
-     int nbOfComp=self->getNumberOfComponents();
-     int nbOfTuples=self->getNumberOfTuples();
-     return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
-   }
-
-   static PyObject *makePartition(PyObject *gps, int newNb)
-   {
-     std::vector<DataArrayInt *> groups;
-     std::vector< std::vector<int> > fidsOfGroups;
-     convertPyObjToVecDataArrayInt(gps,groups);
-     ParaMEDMEM::DataArrayInt *ret0=ParaMEDMEM::DataArrayInt::makePartition(groups,newNb,fidsOfGroups);
-     PyObject *ret = PyList_New(2);
-     PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
-     int sz=fidsOfGroups.size();
-     PyObject *ret1 = PyList_New(sz);
-     for(int i=0;i<sz;i++)
-       PyList_SetItem(ret1,i,convertIntArrToPyList2(fidsOfGroups[i]));
-     PyList_SetItem(ret,1,ret1);
-     return ret;
-   }
-
-   void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception)
-   {
-     int size;
-     int *tmp=convertPyToNewIntArr2(li,&size);
-     if(size!=self->getNumberOfTuples())
-       {
-         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
-         delete [] tmp;
-       }
-     self->renumberInPlace(tmp);
-     delete [] tmp;
-   }
-
-   void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception)
-   {
-     int size;
-     int *tmp=convertPyToNewIntArr2(li,&size);
-     if(size!=self->getNumberOfTuples())
-       {
-         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
-            delete [] tmp;
-       }
-     self->renumberInPlaceR(tmp);
-     delete [] tmp;
-   }
-
-   DataArrayInt *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception)
-   {
-     int size;
-     int *tmp=convertPyToNewIntArr2(li,&size);
-     if(size!=self->getNumberOfTuples())
-       {
-         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
-            delete [] tmp;
-       }
-     DataArrayInt *ret=self->renumberAndReduce(tmp,newNbOfTuple);
-     delete [] tmp;
-     return ret;
-   }
-
-   DataArrayInt *renumber(PyObject *li) throw(INTERP_KERNEL::Exception)
-   {
-     int size;
-     int *tmp=convertPyToNewIntArr2(li,&size);
-     if(size!=self->getNumberOfTuples())
-       {
-         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
-         delete [] tmp;
-       }
-     DataArrayInt *ret=self->renumber(tmp);
-     delete [] tmp;
-     return ret;
-   }
-
-   DataArrayInt *renumberR(PyObject *li) throw(INTERP_KERNEL::Exception)
-   {
-     int size;
-     int *tmp=convertPyToNewIntArr2(li,&size);
-     if(size!=self->getNumberOfTuples())
-       {
-         throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
-         delete [] tmp;
-       }
-     DataArrayInt *ret=self->renumberR(tmp);
-     delete [] tmp;
-     return ret;
-   }
-
-   DataArrayInt *selectByTupleId(PyObject *li) const
-   {
-     int size;
-     int *tmp=convertPyToNewIntArr2(li,&size);
-     DataArrayInt *ret=self->selectByTupleId(tmp,tmp+size);
-     delete [] tmp;
-     return ret;
-   }
-
-   DataArrayInt *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
-   {
-     std::vector<int> tmp;
-     convertPyToNewIntArr3(li,tmp);
-     return self->keepSelectedComponents(tmp);
-   }
-
-   void setSelectedComponents(const DataArrayInt *a, PyObject *li) throw(INTERP_KERNEL::Exception)
-   {
-     std::vector<int> tmp;
-     convertPyToNewIntArr3(li,tmp);
-     self->setSelectedComponents(a,tmp);
-   }
- };
-
-namespace ParaMEDMEM
-{
-  class MEDCouplingField : public ParaMEDMEM::RefCountObject, public ParaMEDMEM::TimeLabel
-  {
-  public:
-    virtual void checkCoherency() const throw(INTERP_KERNEL::Exception);
-    virtual bool areCompatibleForMerge(const MEDCouplingField *other) const;
-    virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
-    virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
-    void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh);
-    void setName(const char *name);
-    const char *getDescription() const;
-    void setDescription(const char *desc);
-    const char *getName() const;
-    TypeOfField getTypeOfField() const;
-    MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDiscretization *getDiscretization() const;
-    void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
-                                    const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
-    void clearGaussLocalizations();
-    MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception);
-    int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception);
-    int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception);
-    const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
-    %extend {
-      PyObject *getMesh() const
-      {
-        MEDCouplingMesh *ret1=(MEDCouplingMesh *)self->getMesh();
-        ret1->incrRef();
-        return convertMesh(ret1, SWIG_POINTER_OWN | 0 );
-      }
-
-      PyObject *buildSubMeshData(PyObject *li) const
-      {
-        int size;
-        int *tmp=convertPyToNewIntArr2(li,&size);
-        DataArrayInt *ret1;
-        MEDCouplingMesh *ret0=self->buildSubMeshData(tmp,tmp+size,ret1);
-        delete [] tmp;
-        PyObject *res = PyList_New(2);
-        PyList_SetItem(res,0,convertMesh(ret0, SWIG_POINTER_OWN | 0 ));
-        PyList_SetItem(res,1,SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0));
-        return res;
-      }
-      void setGaussLocalizationOnCells(PyObject *li, const std::vector<double>& refCoo,
-                                       const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception)
-      {
-        int size;
-        int *tmp=convertPyToNewIntArr2(li,&size);
-        try
-          {
-            self->setGaussLocalizationOnCells(tmp,tmp+size,refCoo,gsCoo,wg);
-          }
-        catch(INTERP_KERNEL::Exception& e)
-          {
-            delete [] tmp;
-            throw e;
-          }
-        delete [] tmp;
-      }
-      PyObject *getCellIdsHavingGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception)
-      {
-        std::vector<int> tmp;
-        self->getCellIdsHavingGaussLocalization(locId,tmp);
-        return convertIntArrToPyList2(tmp);
-      }
-    }
-  };
-
-  class MEDCouplingFieldDouble : public ParaMEDMEM::MEDCouplingField
-  {
-  public:
-    static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=NO_TIME);
-    void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
-    void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
-    std::string simpleRepr() const;
-    std::string advancedRepr() const;
-    MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
-    MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const;
-    MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const;
-    TypeOfTimeDiscretization getTimeDiscretization() const;
-    void checkCoherency() const throw(INTERP_KERNEL::Exception);
-    double getIJ(int tupleId, int compoId) const;
-    double getIJK(int cellId, int nodeIdInCell, int compoId) const;
-    void setArray(DataArrayDouble *array) throw(INTERP_KERNEL::Exception);
-    void setEndArray(DataArrayDouble *array) throw(INTERP_KERNEL::Exception);
-    void setTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception);
-    void setStartTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception);
-    void setEndTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception);
-    DataArrayDouble *getArray() const throw(INTERP_KERNEL::Exception);
-    DataArrayDouble *getEndArray() const throw(INTERP_KERNEL::Exception);
-    void applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception);
-    int getNumberOfComponents() const throw(INTERP_KERNEL::Exception);
-    int getNumberOfTuples() const throw(INTERP_KERNEL::Exception);
-    int getNumberOfValues() const throw(INTERP_KERNEL::Exception);
-    NatureOfField getNature() const { return _nature; }
-    void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
-    void setTimeTolerance(double val);
-    double getTimeTolerance() const;
-    void updateTime();
-    void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);
-    void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);
-    bool mergeNodes(double eps) throw(INTERP_KERNEL::Exception);
-    bool zipCoords() throw(INTERP_KERNEL::Exception);
-    bool zipConnectivity(int compType) throw(INTERP_KERNEL::Exception);
-    bool simplexize(int policy) throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *determinant() const throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *eigenValues() const throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *eigenVectors() const throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *inverse() const throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *trace() const throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *deviator() const throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *magnitude() const throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception);
-    void changeNbOfComponents(int newNbOfComp, double dftValue=0.) throw(INTERP_KERNEL::Exception);
-    void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble &operator=(double value) throw(INTERP_KERNEL::Exception);
-    void fillFromAnalytic(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
-    void applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
-    void applyFunc(int nbOfComp, double val) throw(INTERP_KERNEL::Exception);
-    void applyFunc(const char *func) throw(INTERP_KERNEL::Exception);
-    void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception);
-    void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception);
-    double accumulate(int compId) const throw(INTERP_KERNEL::Exception);
-    double getMaxValue() const throw(INTERP_KERNEL::Exception);
-    double getMinValue() const throw(INTERP_KERNEL::Exception);
-    double getAverageValue() const throw(INTERP_KERNEL::Exception);
-    double getWeightedAverageValue() const throw(INTERP_KERNEL::Exception);
-    double integral(int compId, bool isWAbs) const throw(INTERP_KERNEL::Exception);
-    double normL1(int compId) const throw(INTERP_KERNEL::Exception);
-    double normL2(int compId) const throw(INTERP_KERNEL::Exception);
-    DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *buildSubPart(const DataArrayInt *part) const throw(INTERP_KERNEL::Exception);
-    static MEDCouplingFieldDouble *mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
-    static MEDCouplingFieldDouble *dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
-    MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const;
-    static MEDCouplingFieldDouble *crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
-    MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const;
-    static MEDCouplingFieldDouble *maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
-    MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const;
-    static MEDCouplingFieldDouble *minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
-    MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const;
-    MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
-    const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
-    const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
-    const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
-    MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
-    const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
-    %extend {
-      std::string __str__() const
-      {
-        return self->simpleRepr();
-      }
-      PyObject *getValueOn(PyObject *sl) const throw(INTERP_KERNEL::Exception)
-      {
-        int sz;
-        double *spaceLoc=convertPyToNewDblArr2(sl,&sz);
-        sz=self->getNumberOfComponents();
-        double *res=new double[sz];
-        try
-          {
-            self->getValueOn(spaceLoc,res);
-          }
-        catch(INTERP_KERNEL::Exception& e)
-          {
-            delete [] spaceLoc;
-            delete [] res;
-            throw e;
-          }
-        delete [] spaceLoc;
-        PyObject *ret=convertDblArrToPyList(res,sz);
-        delete [] res;
-        return ret;
-      }
-      PyObject *getValueOn(PyObject *sl, double time) const throw(INTERP_KERNEL::Exception)
-      {
-        int sz;
-        double *spaceLoc=convertPyToNewDblArr2(sl,&sz);
-        sz=self->getNumberOfComponents();
-        double *res=new double[sz];
-        try
-          {
-            self->getValueOn(spaceLoc,time,res);
-          }
-        catch(INTERP_KERNEL::Exception& e)
-          {
-            delete [] spaceLoc;
-            delete [] res;
-            throw e;
-          }
-        delete [] spaceLoc;
-        PyObject *ret=convertDblArrToPyList(res,sz);
-        delete [] res;
-        return ret;
-      }
-      void setValues(PyObject *li)
-      {
-        if(self->getArray()!=0)
-          {
-            int sz;
-            double *tmp=convertPyToNewDblArr2(li,&sz);
-            int nbTuples=self->getArray()->getNumberOfTuples();
-            int nbOfCompo=self->getArray()->getNumberOfComponents();
-            self->getArray()->useArray(tmp,true,CPP_DEALLOC,nbTuples,nbOfCompo);
-          }
-        else
-          PyErr_SetString(PyExc_TypeError,"setValuesCpy : field must contain an array behind");
-      }
-      PyObject *getTime()
-      {
-        int tmp1,tmp2;
-        double tmp0=self->getTime(tmp1,tmp2);
-        PyObject *res = PyList_New(3);
-        PyList_SetItem(res,0,SWIG_From_double(tmp0));
-        PyList_SetItem(res,1,SWIG_From_int(tmp1));
-        PyList_SetItem(res,2,SWIG_From_int(tmp2));
-        return res;
-      }
-
-      PyObject *getStartTime()
-      {
-        int tmp1,tmp2;
-        double tmp0=self->getStartTime(tmp1,tmp2);
-        PyObject *res = PyList_New(3);
-        PyList_SetItem(res,0,SWIG_From_double(tmp0));
-        PyList_SetItem(res,1,SWIG_From_int(tmp1));
-        PyList_SetItem(res,2,SWIG_From_int(tmp2));
-        return res;
-      }
-
-      PyObject *getEndTime()
-      {
-        int tmp1,tmp2;
-        double tmp0=self->getEndTime(tmp1,tmp2);
-        PyObject *res = PyList_New(3);
-        PyList_SetItem(res,0,SWIG_From_double(tmp0));
-        PyList_SetItem(res,1,SWIG_From_int(tmp1));
-        PyList_SetItem(res,2,SWIG_From_int(tmp2));
-        return res;
-      }
-      PyObject *accumulate() const
-      {
-        int sz=self->getNumberOfComponents();
-        double *tmp=new double[sz];
-        self->accumulate(tmp);
-        PyObject *ret=convertDblArrToPyList(tmp,sz);
-        delete [] tmp;
-        return ret;
-      }
-      PyObject *integral(bool isWAbs) const
-      {
-        int sz=self->getNumberOfComponents();
-        double *tmp=new double[sz];
-        self->integral(isWAbs,tmp);
-        PyObject *ret=convertDblArrToPyList(tmp,sz);
-        delete [] tmp;
-        return ret;
-      }
-      PyObject *normL1() const throw(INTERP_KERNEL::Exception)
-      {
-        int sz=self->getNumberOfComponents();
-        double *tmp=new double[sz];
-        self->normL1(tmp);
-        PyObject *ret=convertDblArrToPyList(tmp,sz);
-        delete [] tmp;
-        return ret;
-      }
-      PyObject *normL2() const throw(INTERP_KERNEL::Exception)
-      {
-        int sz=self->getNumberOfComponents();
-        double *tmp=new double[sz];
-        self->normL2(tmp);
-        PyObject *ret=convertDblArrToPyList(tmp,sz);
-        delete [] tmp;
-        return ret;
-      }
-
-      void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception)
-      {
-        int size;
-        int *tmp=convertPyToNewIntArr2(li,&size);
-        try
-          {
-            self->renumberCells(tmp,check);
-          }
-        catch(INTERP_KERNEL::Exception& e)
-          {
-            delete [] tmp;
-            throw e;
-          }
-        delete [] tmp;
-      }
-      void renumberNodes(PyObject *li) throw(INTERP_KERNEL::Exception)
-      {
-        int size;
-        int *tmp=convertPyToNewIntArr2(li,&size);
-        try
-          {
-            self->renumberNodes(tmp);
-          }
-        catch(INTERP_KERNEL::Exception& e)
-          {
-            delete [] tmp;
-            throw e;
-          }
-        delete [] tmp;
-      }
-
-      MEDCouplingFieldDouble *buildSubPart(PyObject *li) const throw(INTERP_KERNEL::Exception)
-      {
-        int size;
-        int *tmp=convertPyToNewIntArr2(li,&size);
-        MEDCouplingFieldDouble *ret=0;
-        try
-          {
-            ret=self->buildSubPart(tmp,tmp+size);
-          }
-        catch(INTERP_KERNEL::Exception& e)
-          {
-            delete [] tmp;
-            throw e;
-          }
-        delete [] tmp;
-        return ret;
-      }
-
-      PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception)
-      {
-        DataArrayInt *tmp;
-        double r1=self->getMaxValue2(tmp);
-        PyObject *ret=PyTuple_New(2);
-        PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
-        PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
-        return ret;
-      }
-      
-      PyObject *getMinValue2() const throw(INTERP_KERNEL::Exception)
-      {
-        DataArrayInt *tmp;
-        double r1=self->getMinValue2(tmp);
-        PyObject *ret=PyTuple_New(2);
-        PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
-        PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
-        return ret;
-      }
-      
-      MEDCouplingFieldDouble *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
-      {
-        std::vector<int> tmp;
-        convertPyToNewIntArr3(li,tmp);
-        return self->keepSelectedComponents(tmp);
-      }
-
-      void setSelectedComponents(const MEDCouplingFieldDouble *f, PyObject *li) throw(INTERP_KERNEL::Exception)
-      {
-        std::vector<int> tmp;
-        convertPyToNewIntArr3(li,tmp);
-        self->setSelectedComponents(f,tmp);
-      }
-    }
-  };
-}
diff --git a/src/MEDCoupling_Swig/libMEDCoupling_Swig.py b/src/MEDCoupling_Swig/libMEDCoupling_Swig.py
new file mode 100644 (file)
index 0000000..5ffbc1e
--- /dev/null
@@ -0,0 +1,28 @@
+#  -*- coding: iso-8859-1 -*-
+#  Copyright (C) 2007-2010  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
+#  License as published by the Free Software Foundation; either
+#  version 2.1 of the License.
+#
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  Lesser General Public License for more details.
+#
+#  You should have received a copy of the GNU Lesser General Public
+#  License along with this library; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+print """
+***********************************************************************
+***********************************************************************
+libMEDCoupling_Swig module DEPRECATED !
+Please use instead \"import MEDCoupling\" or \"from MEDCoupling import *\"
+***********************************************************************
+***********************************************************************
+"""
diff --git a/src/MEDLoader/MEDFileBasis.cxx b/src/MEDLoader/MEDFileBasis.cxx
new file mode 100644 (file)
index 0000000..0fedbd2
--- /dev/null
@@ -0,0 +1,48 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDFileBasis.hxx"
+
+#include <cstring>
+
+using namespace ParaMEDMEM;
+
+MEDFileString::MEDFileString(int maxLgth):_max_lgth(maxLgth),_content(new char[maxLgth+1])
+{
+  std::fill(_content,_content+maxLgth+1,'\0');
+}
+
+MEDFileString::~MEDFileString()
+{
+  delete [] _content;
+}
+
+void MEDFileString::set(const char *s) throw(INTERP_KERNEL::Exception)
+{
+  if((int)strlen(s)>_max_lgth)
+    throw INTERP_KERNEL::Exception("Name is too long to be stored in MEDfile !");
+  std::fill(_content,_content+_max_lgth+1,'\0');
+  strcpy(_content,s);
+}
+
+std::string MEDFileString::getRepr() const
+{
+  return std::string(_content);
+}
+
diff --git a/src/MEDLoader/MEDFileBasis.hxx b/src/MEDLoader/MEDFileBasis.hxx
new file mode 100644 (file)
index 0000000..6e53946
--- /dev/null
@@ -0,0 +1,61 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDFILEBASIS_HXX__
+#define __MEDFILEBASIS_HXX__
+
+#include "InterpKernelException.hxx"
+
+#include <string>
+#include <vector>
+
+namespace ParaMEDMEM
+{
+  class MEDFileString
+  {
+  public:
+    MEDFileString(int maxLgth);
+    ~MEDFileString();
+    void set(const char *s) throw(INTERP_KERNEL::Exception);
+    char *getPointer() { return _content; }
+    const char *getReprForWrite() const { return _content; }
+    std::string getRepr() const;
+  private:
+    int _max_lgth;
+    char *_content;
+  };
+
+
+  class MEDFileMultiString
+  {
+  public:
+    MEDFileMultiString(int nbOfCompo, int maxLgthPerCompo);
+    ~MEDFileMultiString();
+    void set(int compoId, const char *s);
+    const char *getReprForWrite() const;
+    std::vector<std::string> getRepr() const;
+    std::string getReprPerComp(int compId) const;
+  private:
+    int _nb_of_comp;
+    int _max_lgth_per_comp;
+    char *_content;
+  };
+}
+
+#endif
diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx
new file mode 100644 (file)
index 0000000..5e336bb
--- /dev/null
@@ -0,0 +1,666 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDFileMesh.hxx"
+#include "MEDFileUtilities.hxx"
+#include "MEDLoader.hxx"
+#include "MEDLoaderBase.hxx"
+
+#include "MEDCouplingUMesh.hxx"
+
+#include "InterpKernelAutoPtr.hxx"
+
+using namespace ParaMEDMEM;
+
+MEDFileMesh *MEDFileMesh::New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
+{
+  throw INTERP_KERNEL::Exception("Not implemented yet !");
+}
+
+MEDFileUMesh *MEDFileUMesh::New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
+{
+  return new MEDFileUMesh(fileName,mName);
+}
+
+MEDFileUMesh *MEDFileUMesh::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+  std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
+  if(ms.empty())
+    {
+      std::ostringstream oss; oss << "MEDFileUMesh::New : no meshes in file \"" << fileName << "\" !";
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  return new MEDFileUMesh(fileName,ms.front().c_str());
+}
+
+MEDFileUMesh *MEDFileUMesh::New()
+{
+  return new MEDFileUMesh;
+}
+
+MEDFileUMesh::MEDFileUMesh():_too_long_str(0)
+{
+}
+
+MEDFileUMesh::MEDFileUMesh(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
+  try:_too_long_str(0)
+  {
+    MEDFileUtilities::CheckFileForRead(fileName);
+    med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE);
+    MEDFileUMeshL2 loaderl2;
+    loaderl2.loadAll(fid,MEDFileUMeshL2::getMeshIdFromName(fid,mName),mName);
+    int lev=loaderl2.getNumberOfLevels();
+     _ms.resize(lev);
+     for(int i=0;i<lev;i++)
+       {
+         if(!loaderl2.emptyLev(i))
+           _ms[i]=new MEDFileUMeshSplitL1(loaderl2,mName,i);
+         else
+           _ms[i]=0;
+       }
+    MEDFileUMeshL2::readFamiliesAndGrps(fid,mName,_families,_groups);
+    MEDfermer(fid);
+    //
+    setName(loaderl2.getName());
+    setDescription(loaderl2.getDescription());
+    _coords=loaderl2.getCoords();
+    _fam_coords=loaderl2.getCoordsFamily();
+    _num_coords=loaderl2.getCoordsNum();
+  }
+catch(INTERP_KERNEL::Exception& e)
+  {
+    throw e;
+  }
+
+MEDFileUMesh::~MEDFileUMesh()
+{
+}
+
+void MEDFileUMesh::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+  if(_name.empty())
+    throw INTERP_KERNEL::Exception("MEDFileUMesh : name is empty. MED file ask for a NON EMPTY name !");
+  med_mode_acces medmod=MEDFileUtilities::TraduceWriteMode(mode);
+  med_idt fid=MEDouvrir((char *)fileName,medmod);
+  std::ostringstream oss; oss << "MEDFileUMesh : error on attempt to write in file : \"" << fileName << "\""; 
+  MEDFileUtilities::CheckMEDCode(fid,fid,oss.str().c_str());
+  const DataArrayDouble *coo=_coords;
+  INTERP_KERNEL::AutoPtr<char> maa=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM);
+  INTERP_KERNEL::AutoPtr<char> desc=MEDLoaderBase::buildEmptyString(MED_TAILLE_DESC);
+  MEDLoaderBase::safeStrCpy(_name.c_str(),MED_TAILLE_NOM,maa,_too_long_str);
+  MEDLoaderBase::safeStrCpy(_desc_name.c_str(),MED_TAILLE_DESC,desc,_too_long_str);
+  int spaceDim=coo?coo->getNumberOfComponents():0;
+  MEDmaaCr(fid,maa,spaceDim,MED_NON_STRUCTURE,desc);
+  MEDdimEspaceCr(fid,maa,spaceDim);
+  MEDFileUMeshL2::writeCoords(fid,maa,_coords,_fam_coords,_num_coords);
+  int mdim=getMeshDimension();
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++)
+    if((const MEDFileUMeshSplitL1 *)(*it)!=0)
+      (*it)->write(fid,maa,mdim);
+  MEDFileUMeshL2::writeFamiliesAndGrps(fid,maa,_families,_groups);
+  MEDfermer(fid);
+}
+
+int MEDFileUMesh::getNumberOfNonEmptyLevels() const
+{
+  int ret=0;
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++)
+    if((const MEDFileUMeshSplitL1 *)(*it)!=0)
+      if(!(*it)->empty())
+        ret++;
+  return ret;
+}
+
+std::vector<int> MEDFileUMesh::getNonEmptyLevels() const
+{
+  std::vector<int> ret;
+  int lev=0;
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev--)
+    if((const MEDFileUMeshSplitL1 *)(*it)!=0)
+      if(!(*it)->empty())
+        ret.push_back(lev);
+  return ret;
+}
+
+std::vector<int> MEDFileUMesh::getNonEmptyLevelsExt() const
+{
+  std::vector<int> ret0=getNonEmptyLevels();
+  if((const DataArrayDouble *) _coords)
+    {
+      std::vector<int> ret(ret0.size()+1);
+      ret[0]=1;
+      std::copy(ret0.begin(),ret0.end(),ret.begin()+1);
+      return ret;
+    }
+  return ret0;
+}
+
+int MEDFileUMesh::getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception)
+{
+  std::string oname(name);
+  std::map<std::string, int>::const_iterator it=_families.find(oname);
+  std::vector<std::string> fams=getFamiliesNames();
+  if(it==_families.end())
+    {
+      std::ostringstream oss; oss << "No such familyname \"" << name << "\" !\nAvailable families are :";
+      std::copy(fams.begin(),fams.end(),std::ostream_iterator<std::string>(oss," "));
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  return (*it).second;
+}
+
+std::vector<int> MEDFileUMesh::getFamiliesIds(const std::vector<std::string>& famNames) const throw(INTERP_KERNEL::Exception)
+{
+  std::vector<int> famIds;
+  for(std::vector<std::string>::const_iterator it=famNames.begin();it!=famNames.end();it++)
+    {
+      std::map<std::string,int>::const_iterator it2=_families.find(*it);
+      if(it2==_families.end())
+        {
+          std::ostringstream oss; oss << "No such family in mesh \"" << _name << "\" : " << *it; 
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+      famIds.push_back((*it2).second);
+    }
+  return famIds;
+}
+
+std::string MEDFileUMesh::getFamilyNameGivenId(int id) const throw(INTERP_KERNEL::Exception)
+{
+  for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
+    if((*it).second==id)
+      return (*it).first;
+  std::ostringstream oss; oss << "MEDFileUMesh::getFamilyNameGivenId : no such family id : " << id;
+  throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+int MEDFileUMesh::getMeshDimension() const
+{
+  int lev=0;
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev++)
+    if((const MEDFileUMeshSplitL1 *)(*it)!=0)
+      return (*it)->getMeshDimension()+lev;
+  throw INTERP_KERNEL::Exception("MEDFileUMesh::getMeshDimension : impossible to find a mesh dimension !");
+}
+
+int MEDFileUMesh::getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+{
+  if(meshDimRelToMaxExt==1)
+    {
+      if(!((const DataArrayDouble *)_coords))
+        throw INTERP_KERNEL::Exception("MEDFileUMesh::getSizeAtLevel : no coordinates specified !");
+      return _coords->getNumberOfTuples();
+    }
+  MEDCouplingUMesh *m=getMeshAtRank(meshDimRelToMaxExt,false);
+  return m->getNumberOfCells();
+}
+
+const DataArrayInt *MEDFileUMesh::getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+{
+  if(meshDimRelToMaxExt==1)
+    {
+      if(!((const DataArrayInt *)_fam_coords))
+        throw INTERP_KERNEL::Exception("MEDFileUMesh::getFamilyFieldAtLevel : no coordinates specified !");
+      return _fam_coords;
+    }
+  const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+  return l1->getFamilyField();
+}
+
+std::vector<std::string> MEDFileUMesh::getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception)
+{
+  std::string oname(name);
+  std::map<std::string, std::vector<std::string> >::const_iterator it=_groups.find(oname);
+  std::vector<std::string> grps=getGroupsNames();
+  if(it==_groups.end())
+    {
+      std::ostringstream oss; oss << "No such groupname \"" << name << "\" !\nAvailable groups are :";
+      std::copy(grps.begin(),grps.end(),std::ostream_iterator<std::string>(oss," "));
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  return (*it).second;
+}
+
+std::vector<std::string> MEDFileUMesh::getGroupsNames() const
+{
+  std::vector<std::string> ret(_groups.size());
+  int i=0;
+  for(std::map<std::string, std::vector<std::string> >::const_iterator it=_groups.begin();it!=_groups.end();it++,i++)
+    ret[i]=(*it).first;
+  return ret;
+}
+
+std::vector<std::string> MEDFileUMesh::getFamiliesNames() const
+{
+  std::vector<std::string> ret(_families.size());
+  int i=0;
+  for(std::map<std::string, int >::const_iterator it=_families.begin();it!=_families.end();it++,i++)
+    ret[i]=(*it).first;
+  return ret;
+}
+
+void MEDFileUMesh::removeGroup(const char *name) throw(INTERP_KERNEL::Exception)
+{
+  std::string oname(name);
+  std::map<std::string, std::vector<std::string> >::iterator it=_groups.find(oname);
+  std::vector<std::string> grps=getGroupsNames();
+  if(it==_groups.end())
+    {
+      std::ostringstream oss; oss << "No such groupname \"" << name << "\" !\nAvailable groups are :";
+      std::copy(grps.begin(),grps.end(),std::ostream_iterator<std::string>(oss," "));
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  _groups.erase(it);
+}
+
+void MEDFileUMesh::removeFamily(const char *name) throw(INTERP_KERNEL::Exception)
+{
+  std::string oname(name);
+  std::map<std::string, int >::iterator it=_families.find(oname);
+  std::vector<std::string> fams=getFamiliesNames();
+  if(it==_families.end())
+    {
+      std::ostringstream oss; oss << "No such familyname \"" << name << "\" !\nAvailable families are :";
+      std::copy(fams.begin(),fams.end(),std::ostream_iterator<std::string>(oss," "));
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  _families.erase(it);
+}
+
+void MEDFileUMesh::changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
+{
+  std::string oname(oldName);
+  std::map<std::string, std::vector<std::string> >::iterator it=_groups.find(oname);
+  std::vector<std::string> grps=getGroupsNames();
+  if(it==_groups.end())
+    {
+      std::ostringstream oss; oss << "No such groupname \"" << oldName << "\" !\nAvailable groups are :";
+      std::copy(grps.begin(),grps.end(),std::ostream_iterator<std::string>(oss," "));
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  std::string nname(newName);
+  it=_groups.find(nname);
+  if(it!=_groups.end())
+    {
+      std::ostringstream oss; oss << "Such groupname \"" << newName << " already exists ! Kill it before !";
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  std::vector<std::string> cpy=(*it).second;
+  _groups.erase(it);
+  _groups[newName]=cpy;
+}
+
+void MEDFileUMesh::changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
+{
+  std::string oname(oldName);
+  std::map<std::string, int >::iterator it=_families.find(oname);
+  std::vector<std::string> fams=getFamiliesNames();
+  if(it==_families.end())
+    {
+      std::ostringstream oss; oss << "No such familyname \"" << oldName << "\" !\nAvailable families are :";
+      std::copy(fams.begin(),fams.end(),std::ostream_iterator<std::string>(oss," "));
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  std::string nname(newName);
+  it=_families.find(nname);
+  if(it!=_families.end())
+    {
+      std::ostringstream oss; oss << "Such familyname \"" << newName << " already exists ! Kill it before !";
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  int cpy=(*it).second;
+  _families.erase(it);
+  _families[newName]=cpy;
+}
+
+DataArrayDouble *MEDFileUMesh::getCoords() const
+{
+  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp(_coords);
+  if((DataArrayDouble *)tmp)
+    {
+      tmp->incrRef();
+      return tmp;
+    }
+  return 0;
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getGroup(int meshDimRelToMax, const char *grp, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  std::vector<std::string> tmp(1);
+  tmp[0]=grp;
+  MEDCouplingUMesh *ret=getGroups(meshDimRelToMax,tmp,renum);
+  ret->setName(grp);
+  return ret;
+}
+
+DataArrayInt *MEDFileUMesh::getGroupArr(int meshDimRelToMax, const char *grp, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  std::vector<std::string> tmp(1);
+  tmp[0]=grp;
+  DataArrayInt *ret=getGroupsArr(meshDimRelToMax,tmp,renum);
+  ret->setName(grp);
+  return ret;
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getGroups(int meshDimRelToMax, const std::vector<std::string>& grps, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  std::set<std::string> fams;
+  for(std::vector<std::string>::const_iterator it=grps.begin();it!=grps.end();it++)
+    {
+      std::map<std::string, std::vector<std::string> >::const_iterator it2=_groups.find(*it);
+      if(it2==_groups.end())
+        {
+          std::ostringstream oss; oss << "No such group in mesh \"" << _name << "\" : " << *it; 
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+      fams.insert((*it2).second.begin(),(*it2).second.end());
+    }
+  std::vector<std::string> fams2(fams.begin(),fams.end());
+  return getFamilies(meshDimRelToMax,fams2,renum);
+}
+
+DataArrayInt *MEDFileUMesh::getGroupsArr(int meshDimRelToMax, const std::vector<std::string>& grps, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  std::set<std::string> fams;
+  for(std::vector<std::string>::const_iterator it=grps.begin();it!=grps.end();it++)
+    {
+      std::map<std::string, std::vector<std::string> >::const_iterator it2=_groups.find(*it);
+      if(it2==_groups.end())
+        {
+          std::ostringstream oss; oss << "No such group in mesh \"" << _name << "\" : " << *it; 
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+      fams.insert((*it2).second.begin(),(*it2).second.end());
+    }
+  std::vector<std::string> fams2(fams.begin(),fams.end());
+  return getFamiliesArr(meshDimRelToMax,fams2,renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getFamily(int meshDimRelToMax, const char *fam, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  std::vector<std::string> tmp(1);
+  tmp[0]=fam;
+  MEDCouplingUMesh *ret=getFamilies(meshDimRelToMax,tmp,renum);
+  ret->setName(fam);
+  return ret;
+}
+
+DataArrayInt *MEDFileUMesh::getFamilyArr(int meshDimRelToMax, const char *fam, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  std::vector<std::string> tmp(1);
+  tmp[0]=fam;
+  DataArrayInt *ret=getFamiliesArr(meshDimRelToMax,tmp,renum);
+  ret->setName(fam);
+  return ret;
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getFamilies(int meshDimRelToMax, const std::vector<std::string>& fams, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  std::vector<int> famIds=getFamiliesIds(fams);
+  const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMax);
+  return l1->getFamilyPart(famIds,renum);
+}
+
+DataArrayInt *MEDFileUMesh::getFamiliesArr(int meshDimRelToMax, const std::vector<std::string>& fams, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  std::vector<int> famIds=getFamiliesIds(fams);
+  const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMax);
+  return l1->getFamilyPartArr(famIds,renum);
+}
+
+DataArrayInt *MEDFileUMesh::getNodeGroupArr(const char *grp, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  std::vector<std::string> tmp(1);
+  tmp[0]=grp;
+  DataArrayInt *ret=getNodeGroupsArr(tmp,renum);
+  ret->setName(grp);
+  return ret;
+}
+
+DataArrayInt *MEDFileUMesh::getNodeGroupsArr(const std::vector<std::string>& grps, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  std::set<std::string> fams;
+  for(std::vector<std::string>::const_iterator it=grps.begin();it!=grps.end();it++)
+    {
+      std::map<std::string, std::vector<std::string> >::const_iterator it2=_groups.find(*it);
+      if(it2==_groups.end())
+        {
+          std::ostringstream oss; oss << "No such group in mesh \"" << _name << "\" : " << *it; 
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+      fams.insert((*it2).second.begin(),(*it2).second.end());
+    }
+  std::vector<std::string> fams2(fams.begin(),fams.end());
+  return getNodeFamiliesArr(fams2,renum);
+}
+
+DataArrayInt *MEDFileUMesh::getNodeFamilyArr(const char *fam, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  std::vector<std::string> tmp(1);
+  tmp[0]=fam;
+  DataArrayInt *ret=getNodeFamiliesArr(tmp,renum);
+  ret->setName(fam);
+  return ret;
+}
+
+DataArrayInt *MEDFileUMesh::getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  std::vector<int> famIds=getFamiliesIds(fams);
+  DataArrayInt *da=_fam_coords->getIdsEqualList(famIds);
+  if(renum)
+    return MEDFileUMeshSplitL1::renumber(_num_coords,da);
+  return da;
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getMeshAtRank(int meshDimRelToMax, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMax);
+  return l1->getWholeMesh(renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getRank0Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  return getMeshAtRank(0,renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getRankM1Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  return getMeshAtRank(-1,renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getRankM2Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  return getMeshAtRank(-2,renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getRankM3Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
+{
+  return getMeshAtRank(-3,renum);
+}
+
+const MEDFileUMeshSplitL1 *MEDFileUMesh::getMeshAtLevSafe(int meshDimRelToMax) const throw(INTERP_KERNEL::Exception)
+{
+  int tracucedRk=-meshDimRelToMax;
+  if(tracucedRk>=(int)_ms.size())
+    throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! To low !");
+  if((const MEDFileUMeshSplitL1 *)_ms[tracucedRk]==0)
+    throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !");
+  return _ms[tracucedRk];
+}
+
+MEDFileUMeshSplitL1 *MEDFileUMesh::getMeshAtLevSafe(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
+{
+  int tracucedRk=-meshDimRelToMax;
+  if(tracucedRk>=(int)_ms.size())
+    throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! To low !");
+  if((const MEDFileUMeshSplitL1 *)_ms[tracucedRk]==0)
+    throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !");
+  return _ms[tracucedRk];
+}
+
+void MEDFileUMesh::checkMeshDimCoherency(int meshDim, int meshDimRelToMax) const throw(INTERP_KERNEL::Exception)
+{
+  if(-meshDimRelToMax>=(int)_ms.size())
+    throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMeshDimCoherency : The meshdim of mesh is not managed by 'this' !");
+  int i=0;
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,i++)
+    {
+      if(((const MEDFileUMeshSplitL1*) (*it))!=0)
+        {
+          int ref=(*it)->getMeshDimension();
+          if(ref+i!=meshDim+meshDimRelToMax)
+            throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMeshDimCoherency : no coherency between levels !");
+        }
+    }
+}
+
+void MEDFileUMesh::setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception)
+{
+  coords->checkAllocated();
+  int nbOfTuples=coords->getNumberOfTuples();
+  _coords=coords;
+  coords->incrRef();
+  _fam_coords=DataArrayInt::New();
+  _fam_coords->alloc(nbOfTuples,1);
+  _fam_coords->fillWithZero();
+}
+
+void MEDFileUMesh::setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector<DataArrayInt *>& grps, bool renum) throw(INTERP_KERNEL::Exception)
+{
+  if(grps.empty())
+    return ;
+  std::set<std::string> grpsName;
+  for(std::vector<DataArrayInt *>::const_iterator it=grps.begin();it!=grps.end();it++)
+    grpsName.insert((*it)->getName());
+  if(grpsName.size()!=grps.size())
+    throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsAtLevel : groups name must be different each other !");
+  if(grpsName.find(std::string(""))!=grpsName.end())
+    throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsAtLevel : groups name must be different empty string !");
+  /*  int sz=getSizeAtLevel(meshDimRelToMaxExt);
+  if(!renum)
+    {
+      
+    }*/
+}
+
+void MEDFileUMesh::eraseGroupsAtLevel(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception)
+{
+  if(meshDimRelToMaxExt==1)
+    {
+      if((DataArrayInt *)_fam_coords)
+        _fam_coords->fillWithZero();
+      return ;
+    }
+  MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+  l1->eraseFamilyField();
+  optimizeFamilies();
+}
+
+void MEDFileUMesh::optimizeFamilies() throw(INTERP_KERNEL::Exception)
+{
+  std::vector<int> levs=getNonEmptyLevelsExt();
+  std::set<int> allFamsIds;
+  for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
+    {
+      const DataArrayInt *ffield=getFamilyFieldAtLevel(*it);
+      std::set<int> ids=ffield->getDifferentValues();
+      std::set<int> res;
+      std::set_union(ids.begin(),ids.end(),allFamsIds.begin(),allFamsIds.end(),std::inserter(res,res.begin()));
+      allFamsIds=res;
+    }
+}
+
+void MEDFileUMesh::setFamilyField(DataArrayInt *arr, const std::vector< std::vector< int > > &userfids, const std::vector<std::string>& grpNames) throw(INTERP_KERNEL::Exception)
+{
+  
+}
+
+void MEDFileUMesh::addNodeGroup(const std::string& name, const std::vector<int>& ids) throw(INTERP_KERNEL::Exception)
+{
+  const DataArrayDouble *coords=_coords;
+  if(!coords)
+    throw INTERP_KERNEL::Exception("addNodeGroup : no coords set !");
+  DataArrayInt *sub=_fam_coords->selectByTupleIdSafe(&ids[0],&ids[0]+ids.size());
+  std::set<int> ssub(sub->getConstPointer(),sub->getConstPointer()+sub->getNumberOfTuples());
+  
+}
+
+void MEDFileUMesh::setFamilyNameAttachedOnId(int id, const std::string& newFamName) throw(INTERP_KERNEL::Exception)
+{
+  std::string oldName=getFamilyNameGivenId(id);
+  _families.erase(oldName);
+  _families[newFamName]=id;
+}
+
+void MEDFileUMesh::setMeshAtRank(int meshDimRelToMax, MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception)
+{
+  std::vector<int> levSet=getNonEmptyLevels();
+  if(std::find(levSet.begin(),levSet.end(),meshDimRelToMax)==levSet.end())
+    {
+      if((DataArrayDouble *)_coords==0)
+        {
+          DataArrayDouble *c=m->getCoords();
+          if(c)
+            c->incrRef();
+          _coords=c;
+        }
+      else
+        {
+          if(m->getCoords()!=_coords)
+            throw INTERP_KERNEL::Exception("MEDFileUMesh::setMeshAtRank : Invalid Given Mesh ! The coordinates are not the same ! try to use tryToShareSameCoords !");
+          int sz=(-meshDimRelToMax)+1;
+          if(sz>=(int)_ms.size())
+            _ms.resize(sz);
+          checkMeshDimCoherency(m->getMeshDimension(),sz);
+          _ms[sz]=new MEDFileUMeshSplitL1(m);
+        }
+    }
+}
+
+void MEDFileUMesh::setGroupsFromScratch(int meshDimRelToMax, const std::vector<MEDCouplingUMesh *>& ms) throw(INTERP_KERNEL::Exception)
+{
+  if(ms.empty())
+    throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsFromScratch : expecting a non empty vector !");
+  int sz=(-meshDimRelToMax)+1;
+  if(sz>=(int)_ms.size())
+    _ms.resize(sz);
+  checkMeshDimCoherency(ms[0]->getMeshDimension(),meshDimRelToMax);
+  DataArrayDouble *coo=checkMultiMesh(ms);
+  if((DataArrayDouble *)_coords==0)
+    {
+      coo->incrRef();
+      _coords=coo;
+    }
+  else
+    if((DataArrayDouble *)_coords!=coo)
+      throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsFromScratch : coordinates mismatches !");
+  _ms[-meshDimRelToMax]->setGroupsFromScratch(ms,_families,_groups);
+}
+
+void MEDFileUMesh::setGroupsOnSetMesh(int meshDimRelToMax, const std::vector<MEDCouplingUMesh *>& ms) throw(INTERP_KERNEL::Exception)
+{
+  if(ms.empty())
+    throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsOnSetMesh : expecting a non empty vector !");
+  
+}
+
+DataArrayDouble *MEDFileUMesh::checkMultiMesh(const std::vector<MEDCouplingUMesh *>& ms) const throw(INTERP_KERNEL::Exception)
+{
+  return 0;
+}
diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx
new file mode 100644 (file)
index 0000000..d5378c5
--- /dev/null
@@ -0,0 +1,124 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDFILEMESH_HXX__
+#define __MEDFILEMESH_HXX__
+
+#include "MEDFileMeshLL.hxx"
+
+#include <map>
+
+namespace ParaMEDMEM
+{
+  class MEDFileMesh : public RefCountObject
+  {
+  public:
+    static MEDFileMesh *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+    void setName(const char *name) { _name=name; }
+    const char *getName() const { return _name.c_str(); }
+    void setUnivName(const char *name) { _univ_name=name; }
+    const char *getUnivName() const { return _univ_name.c_str(); }
+    void setDescription(const char *name) { _desc_name=name; }
+    const char *getDescription() const { return _desc_name.c_str(); }
+  protected:
+    std::string _name;
+    std::string _univ_name;
+    std::string _desc_name;
+  };
+
+  class MEDFileUMesh : public MEDFileMesh
+  {
+  public:
+    static MEDFileUMesh *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+    static MEDFileUMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+    static MEDFileUMesh *New();
+    ~MEDFileUMesh();
+    //
+    void removeGroup(const char *name) throw(INTERP_KERNEL::Exception);
+    void removeFamily(const char *name) throw(INTERP_KERNEL::Exception);
+    void changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
+    void changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
+    //
+    void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+    int getNumberOfLevels() const { return _ms.size(); }
+    int getNumberOfNonEmptyLevels() const;
+    int getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception);
+    std::vector<int> getFamiliesIds(const std::vector<std::string>& famNames) const throw(INTERP_KERNEL::Exception);
+    std::string getFamilyNameGivenId(int id) const throw(INTERP_KERNEL::Exception);
+    int getMeshDimension() const;
+    int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
+    const DataArrayInt *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
+    std::vector<std::string> getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
+    std::vector<std::string> getGroupsNames() const;
+    std::vector<std::string> getFamiliesNames() const;
+    std::vector<int> getNonEmptyLevels() const;
+    std::vector<int> getNonEmptyLevelsExt() const;
+    DataArrayDouble *getCoords() const;
+    MEDCouplingUMesh *getGroup(int meshDimRelToMax, const char *grp, bool renum=true) const throw(INTERP_KERNEL::Exception);
+    DataArrayInt *getGroupArr(int meshDimRelToMax, const char *grp, bool renum=true) const throw(INTERP_KERNEL::Exception);
+    MEDCouplingUMesh *getGroups(int meshDimRelToMax, const std::vector<std::string>& grps, bool renum=true) const throw(INTERP_KERNEL::Exception);
+    DataArrayInt *getGroupsArr(int meshDimRelToMax, const std::vector<std::string>& grps, bool renum=true) const throw(INTERP_KERNEL::Exception);
+    MEDCouplingUMesh *getFamily(int meshDimRelToMax, const char *fam, bool renum=true) const throw(INTERP_KERNEL::Exception);
+    DataArrayInt *getFamilyArr(int meshDimRelToMax, const char *fam, bool renum=true) const throw(INTERP_KERNEL::Exception);
+    MEDCouplingUMesh *getFamilies(int meshDimRelToMax, const std::vector<std::string>& fams, bool renum=true) const throw(INTERP_KERNEL::Exception);
+    DataArrayInt *getFamiliesArr(int meshDimRelToMax, const std::vector<std::string>& fams, bool renum=true) const throw(INTERP_KERNEL::Exception);
+    DataArrayInt *getNodeGroupArr(const char *grp, bool renum=true) const throw(INTERP_KERNEL::Exception);
+    DataArrayInt *getNodeGroupsArr(const std::vector<std::string>& grps, bool renum=true) const throw(INTERP_KERNEL::Exception);
+    DataArrayInt *getNodeFamilyArr(const char *fam, bool renum=true) const throw(INTERP_KERNEL::Exception);
+    DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=true) const throw(INTERP_KERNEL::Exception);
+    MEDCouplingUMesh *getMeshAtRank(int meshDimRelToMax, bool renum=true) const throw(INTERP_KERNEL::Exception);
+    MEDCouplingUMesh *getRank0Mesh(bool renum=true) const throw(INTERP_KERNEL::Exception);
+    MEDCouplingUMesh *getRankM1Mesh(bool renum=true) const throw(INTERP_KERNEL::Exception);
+    MEDCouplingUMesh *getRankM2Mesh(bool renum=true) const throw(INTERP_KERNEL::Exception);
+    MEDCouplingUMesh *getRankM3Mesh(bool renum=true) const throw(INTERP_KERNEL::Exception);
+    //
+    void setFamilyNameAttachedOnId(int id, const std::string& newFamName) throw(INTERP_KERNEL::Exception);
+    void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
+    void setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector<DataArrayInt *>& grps, bool renum=true) throw(INTERP_KERNEL::Exception);
+    void eraseGroupsAtLevel(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception);
+    void setFamilyField(DataArrayInt *arr, const std::vector< std::vector< int > > &userfids, const std::vector<std::string>& grpNames) throw(INTERP_KERNEL::Exception);
+    void addNodeGroup(const std::string& name, const std::vector<int>& ids) throw(INTERP_KERNEL::Exception);
+    void setMeshAtRank(int meshDimRelToMax, MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception);
+    void setGroupsFromScratch(int meshDimRelToMax, const std::vector<MEDCouplingUMesh *>& ms) throw(INTERP_KERNEL::Exception);
+    void setGroupsOnSetMesh(int meshDimRelToMax, const std::vector<MEDCouplingUMesh *>& ms) throw(INTERP_KERNEL::Exception);
+    void optimizeFamilies() throw(INTERP_KERNEL::Exception);
+  private:
+    MEDFileUMesh();
+    MEDFileUMesh(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+    const MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMax) const throw(INTERP_KERNEL::Exception);
+    MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMax) throw(INTERP_KERNEL::Exception);
+    void checkMeshDimCoherency(int meshDim, int meshDimRelToMax) const throw(INTERP_KERNEL::Exception);
+    DataArrayDouble *checkMultiMesh(const std::vector<MEDCouplingUMesh *>& ms) const throw(INTERP_KERNEL::Exception);
+  private:
+    std::map<std::string, std::vector<std::string> > _groups;
+    std::map<std::string,int> _families;
+    std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> > _ms;
+    MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
+    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_coords;
+    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_coords;
+    int _too_long_str;
+  };
+
+
+  class MEDFileCMesh : public MEDFileMesh
+  {
+  };
+}
+
+#endif
diff --git a/src/MEDLoader/MEDFileMeshElt.cxx b/src/MEDLoader/MEDFileMeshElt.cxx
new file mode 100644 (file)
index 0000000..9fa3dfb
--- /dev/null
@@ -0,0 +1,253 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDFileMeshElt.hxx"
+
+#include "MEDCouplingUMesh.hxx"
+
+#include "InterpKernelAutoPtr.hxx"
+#include "CellModel.hxx"
+
+extern med_geometrie_element typmai3[32];
+
+using namespace ParaMEDMEM;
+
+MEDFileUMeshPerType *MEDFileUMeshPerType::New(med_idt fid, const char *mName, int mdim, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType geoElt2)
+{
+  med_entite_maillage whichEntity;
+  if(!isExisting(fid,mName,geoElt,whichEntity))
+    return 0;
+  return new MEDFileUMeshPerType(fid,mName,mdim,geoElt,geoElt2,whichEntity);
+}
+
+bool MEDFileUMeshPerType::isExisting(med_idt fid, const char *mName, med_geometrie_element geoElt, med_entite_maillage& whichEntity)
+{
+  static const med_entite_maillage entities[3]={MED_MAILLE,MED_FACE,MED_ARETE};
+  int nbOfElt=0;
+  for(int i=0;i<3;i++)
+    {
+      int tmp=MEDnEntMaa(fid,(char *)mName,MED_CONN,entities[i],geoElt,MED_NOD);
+      if(tmp>nbOfElt)
+        {
+          nbOfElt=tmp;
+          whichEntity=entities[i];
+        }
+    }
+  return nbOfElt>0;
+}
+
+int MEDFileUMeshPerType::getDim() const
+{
+  const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(_type);
+  return cm.getDimension();
+}
+
+MEDFileUMeshPerType::MEDFileUMeshPerType(med_idt fid, const char *mName, int mdim, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType type,
+                                         med_entite_maillage entity):_type(type),_entity(entity)
+{
+  int curNbOfElem=MEDnEntMaa(fid,(char *)mName,MED_CONN,entity,geoElt,MED_NOD);
+  if(type!=INTERP_KERNEL::NORM_POLYGON && type!=INTERP_KERNEL::NORM_POLYHED)
+    {
+      loadFromStaticType(fid,mName,mdim,curNbOfElem,geoElt,type,entity);
+      return;
+    }
+  if(type==INTERP_KERNEL::NORM_POLYGON)
+    {
+      loadPolyg(fid,mName,mdim,curNbOfElem,geoElt,entity);
+      return;
+    }
+  //if(type==INTERP_KERNEL::NORM_POLYHED)
+  loadPolyh(fid,mName,mdim,curNbOfElem,geoElt,entity);
+}
+
+void MEDFileUMeshPerType::loadFromStaticType(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType type,
+                                             med_entite_maillage entity)
+{
+  _conn=DataArrayInt::New();
+  int nbOfNodesPerCell=(geoElt%100);
+  _conn->alloc((nbOfNodesPerCell+1)*curNbOfElem,1);
+  _conn_index=DataArrayInt::New();
+  _conn_index->alloc(curNbOfElem+1,1);
+  int *connTab=new int[(nbOfNodesPerCell)*curNbOfElem];
+  _num=DataArrayInt::New();
+  _num->alloc(curNbOfElem,1);
+  char *noms=new char[MED_TAILLE_PNOM*curNbOfElem+1];
+  med_booleen inoele, inuele;
+  _fam=DataArrayInt::New();
+  _fam->alloc(curNbOfElem,1);
+  MEDelementsLire(fid,(char *)mName,mdim,connTab,MED_FULL_INTERLACE,noms,&inoele,_num->getPointer(),&inuele,_fam->getPointer(),curNbOfElem,entity,geoElt,MED_NOD);
+  delete [] noms;
+  int *w1=_conn->getPointer();
+  int *w2=_conn_index->getPointer();
+  *w2++=0;
+  const int *wi=connTab;
+  for(int i=0;i<curNbOfElem;i++,wi+=nbOfNodesPerCell,w2++)
+    {
+      *w1++=(int)type;
+      w1=std::transform(wi,wi+nbOfNodesPerCell,w1,std::bind2nd(std::plus<int>(),-1));
+      *w2=w2[-1]+nbOfNodesPerCell+1;
+    }
+  delete [] connTab;
+  if(!inuele)
+    _num=0;
+}
+
+void MEDFileUMeshPerType::loadPolyg(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt,
+                                    med_entite_maillage entity)
+{
+  med_int arraySize;
+  MEDpolygoneInfo(fid,(char *)mName,entity,MED_NOD,&arraySize);
+  _conn_index=DataArrayInt::New();
+  _conn_index->alloc(curNbOfElem+1,1);
+  _conn=DataArrayInt::New();
+  _conn->alloc(arraySize+curNbOfElem,1);
+  _num=DataArrayInt::New();
+  _num->alloc(curNbOfElem,1);
+  _fam=DataArrayInt::New();
+  _fam->alloc(curNbOfElem,1);
+  int *locConn=new int[arraySize];
+  MEDpolygoneConnLire(fid,(char *)mName,_conn_index->getPointer(),curNbOfElem+1,locConn,entity,MED_NOD);
+  int *w1=_conn->getPointer();
+  int *w2=_conn_index->getPointer();
+  const int *wi=locConn;
+  for(int i=0;i<curNbOfElem;i++,w2++)
+    {
+      *w1++=(int)INTERP_KERNEL::NORM_POLYGON;
+      w1=std::transform(wi,wi+(w2[1]-w2[0]),w1,std::bind2nd(std::plus<int>(),-1));
+      *w2=*w2-1+i;
+    }
+  *w2=*w2-1+curNbOfElem;
+  delete [] locConn;
+  MEDfamLire(fid,(char *)mName,_fam->getPointer(),curNbOfElem,entity,MED_POLYGONE);
+  if(MEDnumLire(fid,(char *)mName,_num->getPointer(),curNbOfElem,entity,MED_POLYGONE)!=0)
+    _num=0;
+}
+
+void MEDFileUMeshPerType::loadPolyh(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt,
+                                    med_entite_maillage entity)
+{
+  med_int indexFaceLgth,connFaceLgth;
+  MEDpolyedreInfo(fid,(char*)mName,MED_NOD,&indexFaceLgth,&connFaceLgth);
+  int *index=new int[curNbOfElem+1];
+  int *indexFace=new int[indexFaceLgth];
+  int *locConn=new int[connFaceLgth];
+  _fam=DataArrayInt::New();
+  _fam->alloc(curNbOfElem,1);
+  MEDpolyedreConnLire(fid,(char *)mName,index,curNbOfElem+1,indexFace,indexFaceLgth,locConn,MED_NOD);
+  MEDfamLire(fid,(char *)mName,_fam->getPointer(),curNbOfElem,MED_MAILLE,MED_POLYEDRE);
+  int arraySize=connFaceLgth;
+  for(int i=0;i<curNbOfElem;i++)
+    arraySize+=index[i+1]-index[i]-1;
+  _conn=DataArrayInt::New();
+  _conn->alloc(arraySize+curNbOfElem,1);
+  int *wFinalConn=_conn->getPointer();
+  _conn_index=DataArrayInt::New();
+  _conn_index->alloc(curNbOfElem+1,1);
+  int *finalIndex=_conn_index->getPointer();
+  finalIndex[0]=0;
+  for(int i=0;i<curNbOfElem;i++)
+    {
+      *wFinalConn++=(int)INTERP_KERNEL::NORM_POLYHED;
+      finalIndex[i+1]=finalIndex[i]+index[i+1]-index[i]-1+indexFace[index[i+1]-1]-indexFace[index[i]-1]+1;
+      wFinalConn=std::transform(locConn+indexFace[index[i]-1]-1,locConn+indexFace[index[i]]-1,wFinalConn,std::bind2nd(std::plus<int>(),-1));
+      for(int j=index[i];j<index[i+1]-1;j++)
+        {
+          *wFinalConn++=-1;
+          wFinalConn=std::transform(locConn+indexFace[j]-1,locConn+indexFace[j+1]-1,wFinalConn,std::bind2nd(std::plus<int>(),-1));
+        }
+    }
+  delete [] index;
+  delete [] locConn;
+  delete [] indexFace;
+  _num=DataArrayInt::New();
+  _num->alloc(curNbOfElem,1);
+  if(MEDnumLire(fid,(char *)mName,_num->getPointer(),curNbOfElem,MED_MAILLE,MED_POLYEDRE)!=0)
+    _num=0;
+}
+
+void MEDFileUMeshPerType::write(med_idt fid, const char *mname, int mdim, const MEDCouplingUMesh *m, const DataArrayInt *fam, const DataArrayInt *num)
+{
+  int nbOfCells=m->getNumberOfCells();
+  if(nbOfCells<1)
+    return ;
+  INTERP_KERNEL::NormalizedCellType ikt=m->getTypeOfCell(0);
+  const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(ikt);
+  med_geometrie_element curMedType=typmai3[(int)ikt];
+  const int *conn=m->getNodalConnectivity()->getConstPointer();
+  const int *connI=m->getNodalConnectivityIndex()->getConstPointer();
+  if(ikt!=INTERP_KERNEL::NORM_POLYGON && ikt!=INTERP_KERNEL::NORM_POLYHED)
+    {
+      int nbNodesPerCell=cm.getNumberOfNodes();
+      INTERP_KERNEL::AutoPtr<int> tab=new int[nbNodesPerCell*nbOfCells];
+      int *w=tab;
+      for(int i=0;i<nbOfCells;i++)
+        w=std::transform(conn+connI[i]+1,conn+connI[i+1],w,std::bind2nd(std::plus<int>(),1));
+      MEDconnEcr(fid,(char *)mname,mdim,tab,MED_FULL_INTERLACE,nbOfCells,MED_MAILLE,curMedType,MED_NOD);
+    }
+  else
+    {
+      if(ikt==INTERP_KERNEL::NORM_POLYGON)
+        {
+          INTERP_KERNEL::AutoPtr<int> tab1=new int[nbOfCells+1];
+          INTERP_KERNEL::AutoPtr<int> tab2=new int[m->getMeshLength()];
+          int *wI=tab1; *wI=1;
+          int *w=tab2;
+          for(int i=0;i<nbOfCells;i++,wI++)
+            {
+              wI[1]=wI[0]+connI[i+1]-connI[i]-1;
+              w=std::transform(conn+connI[i]+1,conn+connI[i+1],w,std::bind2nd(std::plus<int>(),1));
+            }
+          MEDpolygoneConnEcr(fid,(char *)mname,tab1,nbOfCells,tab2,MED_MAILLE,MED_NOD);
+        }
+      else
+        {
+          int meshLgth=m->getMeshLength();
+          int nbOfFaces=std::count(conn,conn+meshLgth,-1)+nbOfCells;
+          INTERP_KERNEL::AutoPtr<int> tab1=new int[nbOfCells+1];
+          int *w1=tab1; *w1=1;
+          INTERP_KERNEL::AutoPtr<int> tab2=new int[nbOfFaces+1];
+          int *w2=tab2; *w2=1;
+          INTERP_KERNEL::AutoPtr<int> bigtab=new int[meshLgth-nbOfCells];
+          int *bt=bigtab;
+          for(int i=0;i<nbOfCells;i++,w1++)
+            {
+              int nbOfFaces=0;
+              for(const int *w=conn+connI[i]+1;w!=conn+connI[i+1];w2++)
+                {
+                  const int *wend=std::find(w,conn+connI[i+1],-1);
+                  bt=std::transform(w,wend,bt,std::bind2nd(std::plus<int>(),1));
+                  int nbOfNode=std::distance(w,wend);
+                  w2[1]=w2[0]+nbOfNode;
+                  if(wend!=conn+connI[i+1])
+                    w=wend+1;
+                  else
+                    w=wend;
+                  nbOfFaces++;
+                }
+              w1[1]=w1[0]+nbOfFaces;
+            }
+          MEDpolyedreConnEcr(fid,(char *)mname,tab1,nbOfCells+1,tab2,nbOfFaces+1,
+                             bigtab,MED_NOD);
+        }
+    }
+  if(fam)
+    MEDfamEcr(fid,(char *)mname,(int *)fam->getConstPointer(),nbOfCells,MED_MAILLE,curMedType);
+  if(num)
+    MEDnumEcr(fid,(char *)mname,(int *)num->getConstPointer(),nbOfCells,MED_MAILLE,curMedType);
+}
diff --git a/src/MEDLoader/MEDFileMeshElt.hxx b/src/MEDLoader/MEDFileMeshElt.hxx
new file mode 100644 (file)
index 0000000..732ca2b
--- /dev/null
@@ -0,0 +1,67 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDFILEMESHELT_HXX__
+#define __MEDFILEMESHELT_HXX__
+
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
+#include "NormalizedUnstructuredMesh.hxx"
+
+extern "C"
+{
+#include "med.h"
+}
+
+namespace ParaMEDMEM
+{
+  class MEDCouplingUMesh;
+
+  class MEDFileUMeshPerType : public RefCountObject
+  {
+  public:
+    static MEDFileUMeshPerType *New(med_idt fid, const char *mName, int mdim, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType geoElt2);
+    static bool isExisting(med_idt fid, const char *mName, med_geometrie_element geoElt, med_entite_maillage& whichEntity);
+    int getDim() const;
+    const DataArrayInt *getNodal() const { return _conn; }
+    const DataArrayInt *getNodalIndex() const { return _conn_index; }
+    const DataArrayInt *getFam() const { return _fam; }
+    const DataArrayInt *getNum() const { return _num; }
+    static void write(med_idt fid, const char *mname, int mdim, const MEDCouplingUMesh *m, const DataArrayInt *fam, const DataArrayInt *num);
+  private:
+    MEDFileUMeshPerType(med_idt fid, const char *mName, int mdim, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType type,
+                        med_entite_maillage entity);
+    void loadFromStaticType(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType type,
+                            med_entite_maillage entity);
+    void loadPolyg(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt,
+                   med_entite_maillage entity);
+    void loadPolyh(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt,
+                   med_entite_maillage entity);
+  private:
+    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _conn;
+    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _conn_index;
+    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num;
+    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam;
+    INTERP_KERNEL::NormalizedCellType _type;
+    med_entite_maillage _entity;
+  };
+}
+
+#endif
diff --git a/src/MEDLoader/MEDFileMeshLL.cxx b/src/MEDLoader/MEDFileMeshLL.cxx
new file mode 100644 (file)
index 0000000..1599200
--- /dev/null
@@ -0,0 +1,431 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDFileMeshLL.hxx"
+#include "MEDLoaderBase.hxx"
+
+#include "MEDCouplingUMesh.hxx"
+
+#include "InterpKernelAutoPtr.hxx"
+
+#include <set>
+
+extern med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE+2];
+extern INTERP_KERNEL::NormalizedCellType typmai2[MED_NBR_GEOMETRIE_MAILLE+2];
+extern med_geometrie_element typmainoeud[1];
+
+using namespace ParaMEDMEM;
+
+MEDFileMeshL2::MEDFileMeshL2():_name(MED_TAILLE_NOM),_description(MED_TAILLE_DESC)
+{
+}
+
+MEDFileUMeshL2::MEDFileUMeshL2()
+{
+}
+
+void MEDFileUMeshL2::loadAll(med_idt fid, int mId, const char *mName)
+{
+  _name.set(mName);
+  med_maillage type_maillage;
+  med_int Mdim;
+  if(MEDmaaInfo(fid,mId,(char *)mName,&Mdim,&type_maillage,_description.getPointer())!=0)
+    throw INTERP_KERNEL::Exception("A problem has been detected when trying to get info on mesh !");
+  if(type_maillage!=MED_NON_STRUCTURE)
+    throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected an unstructured one whereas in file it is not an unstructured !");
+  loadConnectivity(fid,Mdim,mName);
+  loadCoords(fid,mId,Mdim,mName);
+}
+
+void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const char *mName)
+{
+  _per_type_mesh.resize(1);
+  _per_type_mesh[0].clear();
+  for(int j=0;j<MED_NBR_GEOMETRIE_MAILLE+2;j++)
+    {
+      MEDFileUMeshPerType *tmp=MEDFileUMeshPerType::New(fid,mName,mdim,typmai[j],typmai2[j]);
+      if(tmp)
+        _per_type_mesh[0].push_back(tmp);
+    }
+  sortTypes();
+}
+
+void MEDFileUMeshL2::loadCoords(med_idt fid, int mId, int mdim, const char *mName) throw(INTERP_KERNEL::Exception)
+{
+  med_int edim=MEDdimEspaceLire(fid,(char *)mName);
+  int spaceDim=std::max((int)mdim,(int)edim);
+  int nCoords=MEDnEntMaa(fid,(char *)mName,MED_COOR,MED_NOEUD,(med_geometrie_element)0,(med_connectivite)0);
+  _coords=DataArrayDouble::New();
+  _coords->alloc(nCoords,spaceDim);
+  double *coordsPtr=_coords->getPointer();
+  med_repere repere;
+  char *comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
+  char *unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
+  MEDcoordLire(fid,(char *)mName,spaceDim,coordsPtr,MED_FULL_INTERLACE,MED_ALL,NULL,0,&repere,comp,unit);
+  _fam_coords=DataArrayInt::New();
+  _fam_coords->alloc(nCoords,1);
+  _num_coords=DataArrayInt::New();
+  _num_coords->alloc(nCoords,1);
+  MEDfamLire(fid,(char *)mName,_fam_coords->getPointer(),nCoords,MED_NOEUD,MED_NONE);
+  if(MEDnumLire(fid,(char *)mName,_num_coords->getPointer(),nCoords,MED_NOEUD,MED_NONE)!=0)
+    _num_coords=0;
+  for(int i=0;i<spaceDim;i++)
+    {
+      std::string n,u;
+      std::string info=MEDLoaderBase::buildUnionUnit(comp+i*MED_TAILLE_PNOM,MED_TAILLE_PNOM,unit+i*MED_TAILLE_PNOM,MED_TAILLE_PNOM);
+      _coords->setInfoOnComponent(i,info.c_str());
+    }
+  delete [] comp;
+  delete [] unit;
+}
+
+void MEDFileUMeshL2::sortTypes()
+{
+  std::set<int> mdims;
+  std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> > tmp(_per_type_mesh[0]);
+  _per_type_mesh.clear();
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=tmp.begin();it!=tmp.end();it++)
+    mdims.insert((*it)->getDim());
+  if(mdims.empty())
+    return;
+  int mdim=*mdims.rbegin();
+  _per_type_mesh.resize(mdim+1);
+  for(int dim=mdim+1;dim!=0;dim--)
+    {
+      std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& elt=_per_type_mesh[mdim+1-dim];
+      for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=tmp.begin();it!=tmp.end();it++)
+        if((*it)->getDim()==dim-1)
+          elt.push_back(*it);
+    }
+}
+
+int MEDFileUMeshL2::getMeshIdFromName(med_idt fid, const char *mname) throw(INTERP_KERNEL::Exception)
+{
+  med_maillage type_maillage;
+  char maillage_description[MED_TAILLE_DESC+1];
+  med_int dim;
+  char nommaa[MED_TAILLE_NOM+1];
+  med_int n=MEDnMaa(fid);
+  bool found=false;
+  int ret=-1;
+  std::vector<std::string> ms;
+  for(int i=0;i<n;i++)
+    {
+      MEDmaaInfo(fid,i+1,nommaa,&dim,&type_maillage,maillage_description);
+      std::string cur=MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa));
+      ms.push_back(cur);
+      if(cur==mname)
+        {
+          found=true;
+          ret=i+1;
+        }
+    }
+  if(!found)
+    {
+      std::ostringstream oss;
+      oss << "No such meshname (" << mname <<  ") in file ! Must be in :";
+      std::copy(ms.begin(),ms.end(),std::ostream_iterator<std::string>(oss,", "));
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  return ret;
+}
+
+void MEDFileUMeshL2::readFamiliesAndGrps(med_idt fid, const char *meshName, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps)
+{
+  char nomfam[MED_TAILLE_NOM+1];
+  med_int numfam;
+  int nfam=MEDnFam(fid,(char *)meshName);
+  for(int i=0;i<nfam;i++)
+    {
+      int ngro=MEDnGroupe(fid,(char *)meshName,i+1);
+      med_int natt=MEDnAttribut(fid,(char *)meshName,i+1);
+      med_int *attide=new int[natt];
+      med_int *attval=new int[natt];
+      char *attdes=new char[MED_TAILLE_DESC*natt+1];
+      char *gro=new char[MED_TAILLE_LNOM*ngro+1];
+      MEDfamInfo(fid,(char *)meshName,i+1,nomfam,&numfam,attide,attval,attdes,&natt,gro,&ngro);
+      std::string famName=MEDLoaderBase::buildStringFromFortran(nomfam,MED_TAILLE_LNOM);
+      fams[famName]=numfam;
+      for(int j=0;j<ngro;j++)
+        {
+          std::string groupname=MEDLoaderBase::buildStringFromFortran(gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
+          grps[groupname].push_back(famName);
+        }
+      delete [] attdes;
+      delete [] gro;
+      delete [] attide;
+      delete [] attval;
+    }
+}
+
+void MEDFileUMeshL2::writeFamiliesAndGrps(med_idt fid, const char *mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps)
+{
+  for(std::map<std::string,int>::const_iterator it=fams.begin();it!=fams.end();it++)
+    {
+      std::vector<std::string> grpsOfFam;
+      for(std::map<std::string, std::vector<std::string> >::const_iterator it1=grps.begin();it1!=grps.end();it1++)
+        {
+          if(std::find((*it1).second.begin(),(*it1).second.end(),(*it).first)!=(*it1).second.end())
+            grpsOfFam.push_back((*it1).first);
+        }
+      int ngro=grpsOfFam.size();
+      INTERP_KERNEL::AutoPtr<char> groName=MEDLoaderBase::buildEmptyString(MED_TAILLE_LNOM*ngro);
+      int i=0;
+      for(std::vector<std::string>::const_iterator it2=grpsOfFam.begin();it2!=grpsOfFam.end();it2++,i++)
+        MEDLoaderBase::safeStrCpy((*it2).c_str(),MED_TAILLE_LNOM-1,groName+i*MED_TAILLE_LNOM,0);//tony too long
+      INTERP_KERNEL::AutoPtr<char> famName=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM);
+      MEDLoaderBase::safeStrCpy((*it).first.c_str(),MED_TAILLE_NOM,famName,0);//tony too long
+      MEDfamCr(fid,(char *)mname,famName,(*it).second,0,0,0,0,groName,ngro);
+    }
+}
+
+void MEDFileUMeshL2::writeCoords(med_idt fid, const char *mname, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords)
+{
+  if(!coords)
+    return ;
+  int spaceDim=coords->getNumberOfComponents();
+  INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
+  INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
+  for(int i=0;i<spaceDim;i++)
+    {
+      std::string info=coords->getInfoOnComponent(i);
+      std::string c,u;
+      MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
+      MEDLoaderBase::safeStrCpy(c.c_str(),MED_TAILLE_PNOM-1,comp+i*MED_TAILLE_PNOM,0);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
+      MEDLoaderBase::safeStrCpy(u.c_str(),MED_TAILLE_PNOM-1,unit+i*MED_TAILLE_PNOM,0);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
+    }
+  MEDcoordEcr(fid,(char *)mname,spaceDim,coords->getPointer(),MED_FULL_INTERLACE,coords->getNumberOfTuples(),MED_CART,comp,unit);
+  MEDfamEcr(fid,(char *)mname,famCoords->getPointer(),famCoords->getNumberOfTuples(),MED_NOEUD,MED_NONE);
+  if(numCoords)
+    MEDnumEcr(fid,(char *)mname,numCoords->getPointer(),numCoords->getNumberOfTuples(),MED_NOEUD,MED_NONE);
+}
+
+bool MEDFileUMeshL2::isFamDefinedOnLev(int levId) const
+{
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
+    if((*it)->getFam()==0)
+      return false;
+  return true;
+}
+
+bool MEDFileUMeshL2::isNumDefinedOnLev(int levId) const
+{
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
+    if((*it)->getNum()==0)
+      return false;
+  return true;
+}
+
+MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *mName, int id)
+{
+  const std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& v=l2.getLev(id);
+  if(v.empty())
+    return;
+  int sz=v.size();
+  std::vector<MEDCouplingUMesh *> ms(sz);
+  for(int i=0;i<sz;i++)
+    {
+      MEDCouplingUMesh *tmp=MEDCouplingUMesh::New("",v[i]->getDim());
+      MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp2=l2.getCoords();
+      tmp->setCoords(tmp2);
+      tmp->setConnectivity(const_cast<DataArrayInt *>(v[i]->getNodal()),const_cast<DataArrayInt *>(v[i]->getNodalIndex()));
+      ms[i]=tmp;
+    }
+  _m_by_types=MEDCouplingUMesh::mergeUMeshesOnSameCoords(ms);
+  _m_by_types->setName(mName);
+  if(l2.isFamDefinedOnLev(id))
+    {
+      int nbOfCells=_m_by_types->getNumberOfCells();
+      _fam=DataArrayInt::New();
+      _fam->alloc(nbOfCells,1);
+      int *w=_fam->getPointer();
+      for(int i=0;i<sz;i++)
+        w=std::copy(v[i]->getFam()->getConstPointer(),v[i]->getFam()->getConstPointer()+v[i]->getFam()->getNumberOfTuples(),w);
+    }
+  if(l2.isNumDefinedOnLev(id))
+    {
+      int nbOfCells=_m_by_types->getNumberOfCells();
+      _num=DataArrayInt::New();
+      _num->alloc(nbOfCells,1);
+      int *w=_num->getPointer();
+      for(int i=0;i<sz;i++)
+        w=std::copy(v[i]->getNum()->getConstPointer(),v[i]->getNum()->getConstPointer()+v[i]->getNum()->getNumberOfTuples(),w);
+      _m=(MEDCouplingUMesh *)_m_by_types->deepCpy();
+      _m->renumberCells(_num->getConstPointer(),true);
+    }
+  else
+    _m=_m_by_types;
+  for(int i=0;i<sz;i++)
+    ms[i]->decrRef();
+}
+
+MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m)
+{
+  m->incrRef();
+  _m=m;
+  _m_by_types=(MEDCouplingUMesh *)_m->deepCpy();
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_m_by_types->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_NBR_GEOMETRIE_MAILLE+2);
+  _num=da->invertArrayO2N2N2O(m->getNumberOfCells());
+  _fam=DataArrayInt::New();
+  _fam->alloc(m->getNumberOfCells(),1);
+  _fam->fillWithValue(0);
+  _m_by_types->renumberCells(da->getConstPointer(),false);
+}
+
+bool MEDFileUMeshSplitL1::empty() const
+{
+  return ((const MEDCouplingUMesh *)_m_by_types)==0;
+}
+
+int MEDFileUMeshSplitL1::getMeshDimension() const
+{
+  return _m_by_types->getMeshDimension();
+}
+
+MEDCouplingUMesh *MEDFileUMeshSplitL1::getFamilyPart(const std::vector<int>& ids, bool renum) const
+{
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> eltsToKeep=_fam->getIdsEqualList(ids);
+  MEDCouplingUMesh *m=(MEDCouplingUMesh *)_m_by_types->buildPartOfMySelf(eltsToKeep->getConstPointer(),eltsToKeep->getConstPointer()+eltsToKeep->getNumberOfTuples(),true);
+  if(renum)
+    return renumIfNeeded(m,eltsToKeep->getConstPointer());
+  return m;
+}
+
+DataArrayInt *MEDFileUMeshSplitL1::getFamilyPartArr(const std::vector<int>& ids, bool renum) const
+{
+  DataArrayInt *da=_fam->getIdsEqualList(ids);
+  if(renum)
+    return renumIfNeededArr(da);
+  return da;
+}
+
+MEDCouplingUMesh *MEDFileUMeshSplitL1::getWholeMesh(bool renum) const
+{
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tmp;
+  if(renum)
+    tmp=_m;
+  else
+    tmp=_m_by_types;
+  tmp->incrRef();
+  return tmp;
+}
+
+const DataArrayInt *MEDFileUMeshSplitL1::getFamilyField() const
+{
+  return _fam;
+}
+
+void MEDFileUMeshSplitL1::eraseFamilyField()
+{
+  _fam->fillWithZero();
+}
+
+/*!
+ * This method ignores _m and _m_by_types.
+ */
+void MEDFileUMeshSplitL1::setGroupsFromScratch(const std::vector<MEDCouplingUMesh *>& ms, std::map<std::string,int>& familyIds,
+                                               std::map<std::string, std::vector<std::string> >& groups) throw(INTERP_KERNEL::Exception)
+{
+  int sz=ms.size();
+  std::vector< DataArrayInt * > corr;
+  _m=MEDCouplingUMesh::fuseUMeshesOnSameCoords(ms,0,corr);
+  std::vector< std::vector<int> > fidsOfGroups;
+  _fam=DataArrayInt::makePartition(corr,_m->getNumberOfCells(),fidsOfGroups);
+  int nbOfCells=_m->getNumberOfCells();
+  std::map<int,std::string> newfams;
+  std::map<int,int> famIdTrad;
+  traduceFamilyNumber(fidsOfGroups,familyIds,famIdTrad,newfams);
+  for(int i=0;i<sz;i++)
+    corr[i]->decrRef();
+  int *w=_fam->getPointer();
+  for(int i=0;i<nbOfCells;i++,w++)
+    *w=famIdTrad[*w];
+}
+
+void MEDFileUMeshSplitL1::write(med_idt fid, const char *mName, int mdim) const
+{
+  std::vector<MEDCouplingUMesh *> ms=_m_by_types->splitByType();
+  int start=0;
+  for(std::vector<MEDCouplingUMesh *>::const_iterator it=ms.begin();it!=ms.end();it++)
+    {
+      int nbCells=(*it)->getNumberOfCells();
+      int end=start+nbCells;
+      DataArrayInt *fam=0,*num=0;
+      if((const DataArrayInt *)_fam)
+        fam=_fam->substr(start,end);
+      if((const DataArrayInt *)_num)
+        num=_num->substr(start,end);
+      MEDFileUMeshPerType::write(fid,mName,mdim,(*it),fam,num);
+      if(fam)
+        fam->decrRef();
+      if(num)
+        num->decrRef();
+      (*it)->decrRef();
+      start=end;
+    }
+}
+
+MEDCouplingUMesh *MEDFileUMeshSplitL1::renumIfNeeded(MEDCouplingUMesh *m, const int *cellIds) const
+{
+  if((const DataArrayInt *)_num==0)
+    return m;
+  if(cellIds==0)
+    m->renumberCells(_num->getConstPointer(),true);
+  else
+    {
+      MEDCouplingAutoRefCountObjectPtr<DataArrayInt> locnum=_num->selectByTupleId(cellIds,cellIds+m->getNumberOfCells());
+      m->renumberCells(locnum->getConstPointer(),true);
+    }
+  return m;
+}
+
+DataArrayInt *MEDFileUMeshSplitL1::renumber(const DataArrayInt *renum, DataArrayInt *da)
+{
+  if((const DataArrayInt *)renum==0)
+    return da;
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> locnum=renum->selectByTupleId(da->getConstPointer(),da->getConstPointer()+da->getNumberOfTuples());
+  da->decrRef();
+  locnum->incrRef();
+  return locnum;
+}
+
+DataArrayInt *MEDFileUMeshSplitL1::renumIfNeededArr(DataArrayInt *da) const
+{
+  return renumber(_num,da);
+}
+
+std::vector<int> MEDFileUMeshSplitL1::getNewFamiliesNumber(int nb, const std::map<std::string,int>& families)
+{
+  int id=-1;
+  for(std::map<std::string,int>::const_iterator it=families.begin();it!=families.end();it++)
+    id=std::max(id,(*it).second);
+  if(id==-1)
+    id=0;
+  std::vector<int> ret(nb);
+  for(int i=1;i<=nb;i++)
+    ret[i]=id+i;
+  return ret;
+}
+
+void MEDFileUMeshSplitL1::traduceFamilyNumber(const std::vector< std::vector<int> >& fidsGrps, std::map<std::string,int>& familyIds,
+                                              std::map<int,int>& famIdTrad, std::map<int,std::string>& newfams)
+{
+  std::set<int> allfids;
+  
+}
diff --git a/src/MEDLoader/MEDFileMeshLL.hxx b/src/MEDLoader/MEDFileMeshLL.hxx
new file mode 100644 (file)
index 0000000..57ecb63
--- /dev/null
@@ -0,0 +1,112 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDFILEMESHLL_HXX__
+#define __MEDFILEMESHLL_HXX__
+
+#include "MEDFileBasis.hxx"
+#include "MEDFileMeshElt.hxx"
+
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
+extern "C"
+{
+#include "med.h"
+}
+
+#include <map>
+
+namespace ParaMEDMEM
+{
+  class MEDCouplingUMesh;
+
+  class MEDFileMeshL2 : public RefCountObject
+  {
+  public:
+    MEDFileMeshL2();
+    const char *getName() const { return _name.getReprForWrite(); }
+    const char *getDescription() const { return _description.getReprForWrite(); } 
+  protected:
+    MEDFileString _name;
+    MEDFileString _description;
+  };
+
+  class MEDFileUMeshL2 : public MEDFileMeshL2
+  {
+  public:
+    MEDFileUMeshL2();
+    void loadAll(med_idt fid, int mId, const char *mName);
+    void loadConnectivity(med_idt fid, int mdim, const char *mName);
+    void loadCoords(med_idt fid, int mId, int mdim, const char *mName) throw(INTERP_KERNEL::Exception);
+    int getNumberOfLevels() const { return _per_type_mesh.size(); }
+    bool emptyLev(int levId) const { return _per_type_mesh[levId].empty(); }
+    const std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& getLev(int levId) const { return _per_type_mesh[levId]; }
+    bool isFamDefinedOnLev(int levId) const;
+    bool isNumDefinedOnLev(int levId) const;
+    MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> getCoords() const { return _coords; }
+    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> getCoordsFamily() const { return _fam_coords; }
+    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> getCoordsNum() const { return _num_coords; }
+    static int getMeshIdFromName(med_idt fid, const char *mname) throw(INTERP_KERNEL::Exception);
+    static void readFamiliesAndGrps(med_idt fid, const char *mname, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps);
+    static void writeFamiliesAndGrps(med_idt fid, const char *mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps);
+    static void writeCoords(med_idt fid, const char *mname, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords);
+  private:
+    void sortTypes();
+  private:
+    std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> > > _per_type_mesh;
+    MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
+    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_coords;
+    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_coords;
+  };
+
+  class MEDFileUMeshL2CMesh : public MEDFileMeshL2
+  {
+  };
+
+  class MEDFileUMeshSplitL1 : public RefCountObject
+  {
+  public:
+    MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *mName, int id);
+    MEDFileUMeshSplitL1(MEDCouplingUMesh *m);
+    bool empty() const;
+    int getMeshDimension() const;
+    MEDCouplingUMesh *getFamilyPart(const std::vector<int>& ids, bool renum) const;
+    DataArrayInt *getFamilyPartArr(const std::vector<int>& ids, bool renum) const;
+    MEDCouplingUMesh *getWholeMesh(bool renum) const;
+    const DataArrayInt *getFamilyField() const;
+    void eraseFamilyField();
+    void setGroupsFromScratch(const std::vector<MEDCouplingUMesh *>& ms, std::map<std::string,int>& familyIds,
+                              std::map<std::string, std::vector<std::string> >& groups) throw(INTERP_KERNEL::Exception);
+    void write(med_idt fid, const char *mName, int mdim) const;
+    static std::vector<int> getNewFamiliesNumber(int nb, const std::map<std::string,int>& families);
+    static void traduceFamilyNumber(const std::vector< std::vector<int> >& fidsGrps, std::map<std::string,int>& familyIds,
+                                    std::map<int,int>& famIdTrad, std::map<int,std::string>& newfams);
+    static DataArrayInt *renumber(const DataArrayInt *renum, DataArrayInt *da);
+  private:
+    MEDCouplingUMesh *renumIfNeeded(MEDCouplingUMesh *m, const int *cellIds) const;
+    DataArrayInt *renumIfNeededArr(DataArrayInt *da) const;
+  private:
+    MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> _m_by_types;
+    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam;
+    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num;
+    MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> _m;
+  };
+}
+
+#endif
diff --git a/src/MEDLoader/MEDFileUtilities.cxx b/src/MEDLoader/MEDFileUtilities.cxx
new file mode 100644 (file)
index 0000000..222d8a8
--- /dev/null
@@ -0,0 +1,90 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDFileUtilities.hxx"
+#include "MEDLoaderBase.hxx"
+
+#include <sstream>
+
+med_mode_acces MEDFileUtilities::TraduceWriteMode(int medloaderwritemode) throw(INTERP_KERNEL::Exception)
+{
+  switch(medloaderwritemode)
+    {
+    case 2:
+      return MED_CREATION;
+    case 1:
+      return MED_LECTURE_AJOUT;
+    case 0:
+      return MED_LECTURE_ECRITURE;
+    default:
+      throw INTERP_KERNEL::Exception("Invalid write mode specified ! must be 0(write with no question), 1(append) or 2(creation)");
+    }
+}
+
+void MEDFileUtilities::CheckMEDCode(int code, med_idt fid, const char *msg) throw(INTERP_KERNEL::Exception)
+{
+  if(code==-1)
+    {
+      std::ostringstream oss;
+      oss << "MEDFile has returned an error code (" << code <<") : " << msg;
+      MEDfermer(fid);
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+}
+
+void MEDFileUtilities::CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+  int status=MEDLoaderBase::getStatusOfFile(fileName);
+  std::ostringstream oss;
+  oss << " File : \"" << fileName << "\"";
+  switch(status)
+    {
+    case MEDLoaderBase::DIR_LOCKED:
+      {
+        oss << " has been detected as unreadable : impossible to read anything !";
+        throw INTERP_KERNEL::Exception(oss.str().c_str());
+      }
+    case MEDLoaderBase::NOT_EXIST:
+      {
+        oss << " has been detected as NOT EXISTING : impossible to read anything !";
+        throw INTERP_KERNEL::Exception(oss.str().c_str());
+      }
+    case MEDLoaderBase::EXIST_WRONLY:
+      {
+        oss << " has been detected as WRITE ONLY : impossible to read anything !";
+        throw INTERP_KERNEL::Exception(oss.str().c_str());
+      }
+    }
+  int fid=MEDouvrir((char *)fileName,MED_LECTURE);
+  if(fid<0)
+    {
+      oss << " has been detected as unreadable by MED file : impossible to read anything !";
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  oss << " has been detected readable but ";
+  int major,minor,release;
+  MEDversionLire(fid,&major,&minor,&release);
+  if(major<2 || (major==2 && minor<2))
+    {
+      oss << "version of MED file is < 2.2 : impossible to read anything !";
+      MEDfermer(fid);
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  MEDfermer(fid);
+}
diff --git a/src/MEDLoader/MEDFileUtilities.hxx b/src/MEDLoader/MEDFileUtilities.hxx
new file mode 100644 (file)
index 0000000..05f3f4e
--- /dev/null
@@ -0,0 +1,37 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDFILEUTILITIES_HXX__
+#define __MEDFILEUTILITIES_HXX__
+
+#include "InterpKernelException.hxx"
+
+extern "C"
+{
+#include "med.h"
+}
+
+namespace MEDFileUtilities
+{
+  med_mode_acces TraduceWriteMode(int medloaderwritemode) throw(INTERP_KERNEL::Exception);
+  void CheckMEDCode(int code, med_idt fid, const char *msg) throw(INTERP_KERNEL::Exception);
+  void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception);
+}
+  
+#endif
index cde077cee2c0cf085b15299049b3aafc47f18f26..15f179b3bc0d8b43343a83b5cc8b6e564674f4e5 100644 (file)
 
 #include "MEDLoader.hxx"
 #include "MEDLoaderBase.hxx"
+#include "MEDFileUtilities.hxx"
 #include "CellModel.hxx"
 #include "MEDCouplingUMesh.hxx"
 #include "MEDCouplingMemArray.hxx"
 #include "MEDCouplingFieldDouble.hxx"
 #include "MEDCouplingGaussLocalization.hxx"
 
+#include "InterpKernelAutoPtr.hxx"
+
 extern "C"
 {
 #include "med.h"
@@ -37,6 +40,7 @@ extern "C"
 #include <iterator>
 #include <algorithm>
 #include <numeric>
+#include <limits>
 
 med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE+2] = { MED_POINT1,
                                                              MED_SEG2,
@@ -300,43 +304,7 @@ void MEDLoaderNS::fillGaussDataOnField(const char *fileName, const std::list<MED
 
 void MEDLoader::CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception)
 {
-  int status=MEDLoaderBase::getStatusOfFile(fileName);
-  std::ostringstream oss;
-  oss << " File : \"" << fileName << "\"";
-  switch(status)
-    {
-    case MEDLoaderBase::DIR_LOCKED:
-      {
-        oss << " has been detected as unreadable : impossible to read anything !";
-        throw INTERP_KERNEL::Exception(oss.str().c_str());
-      }
-    case MEDLoaderBase::NOT_EXIST:
-      {
-        oss << " has been detected as NOT EXISTING : impossible to read anything !";
-        throw INTERP_KERNEL::Exception(oss.str().c_str());
-      }
-    case MEDLoaderBase::EXIST_WRONLY:
-      {
-        oss << " has been detected as WRITE ONLY : impossible to read anything !";
-        throw INTERP_KERNEL::Exception(oss.str().c_str());
-      }
-    }
-  int fid=MEDouvrir((char *)fileName,MED_LECTURE);
-  if(fid<0)
-    {
-      oss << " has been detected as unreadable by MED file : impossible to read anything !";
-      throw INTERP_KERNEL::Exception(oss.str().c_str());
-    }
-  oss << " has been detected readable but ";
-  int major,minor,release;
-  MEDversionLire(fid,&major,&minor,&release);
-  if(major<2 || (major==2 && minor<2))
-    {
-      oss << "version of MED file is < 2.2 : impossible to read anything !";
-      MEDfermer(fid);
-      throw INTERP_KERNEL::Exception(oss.str().c_str());
-    }
-  MEDfermer(fid);
+  MEDFileUtilities::CheckFileForRead(fileName);
 }
 
 std::vector<std::string> MEDLoader::GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception)
@@ -434,6 +402,72 @@ std::vector<std::string> MEDLoader::GetMeshFamiliesNames(const char *fileName, c
   MEDfermer(fid);
   return ret;
 }
+
+std::vector<std::string> MEDLoader::GetMeshFamiliesNamesOnGroup(const char *fileName, const char *meshName, const char *grpName) throw(INTERP_KERNEL::Exception)
+{
+  CheckFileForRead(fileName);
+  med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE);
+  med_int nfam=MEDnFam(fid,(char *)meshName);
+  std::vector<std::string> ret;
+  char nomfam[MED_TAILLE_NOM+1];
+  med_int numfam;
+  for(int i=0;i<nfam;i++)
+    {
+      int ngro=MEDnGroupe(fid,(char *)meshName,i+1);
+      med_int natt=MEDnAttribut(fid,(char *)meshName,i+1);
+      INTERP_KERNEL::AutoPtr<med_int> attide=new int[natt];
+      INTERP_KERNEL::AutoPtr<med_int> attval=new int[natt];
+      INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_TAILLE_DESC*natt+1];
+      INTERP_KERNEL::AutoPtr<char> gro=new char[MED_TAILLE_LNOM*ngro+1];
+      MEDfamInfo(fid,(char *)meshName,i+1,nomfam,&numfam,attide,attval,attdes,&natt,gro,&ngro);
+      std::string cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam));
+      for(int j=0;j<ngro;j++)
+        {
+          std::string cur2=MEDLoaderBase::buildStringFromFortran(gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
+          if(cur2==grpName)
+            ret.push_back(cur);
+        }
+    }
+  MEDfermer(fid);
+  return ret;
+}
+
+std::vector<std::string> MEDLoader::GetMeshGroupsNamesOnFamily(const char *fileName, const char *meshName, const char *famName) throw(INTERP_KERNEL::Exception)
+{
+  CheckFileForRead(fileName);
+  med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE);
+  med_int nfam=MEDnFam(fid,(char *)meshName);
+  std::vector<std::string> ret;
+  char nomfam[MED_TAILLE_NOM+1];
+  med_int numfam;
+  bool found=false;
+  for(int i=0;i<nfam && !found;i++)
+    {
+      int ngro=MEDnGroupe(fid,(char *)meshName,i+1);
+      med_int natt=MEDnAttribut(fid,(char *)meshName,i+1);
+      INTERP_KERNEL::AutoPtr<med_int> attide=new int[natt];
+      INTERP_KERNEL::AutoPtr<med_int> attval=new int[natt];
+      INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_TAILLE_DESC*natt+1];
+      INTERP_KERNEL::AutoPtr<char> gro=new char[MED_TAILLE_LNOM*ngro+1];
+      MEDfamInfo(fid,(char *)meshName,i+1,nomfam,&numfam,attide,attval,attdes,&natt,gro,&ngro);
+      std::string cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam));
+      found=(cur==famName);
+      if(found)
+        for(int j=0;j<ngro;j++)
+          {
+            std::string cur=MEDLoaderBase::buildStringFromFortran(gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
+            ret.push_back(cur);
+          }
+    }
+  MEDfermer(fid);
+  if(!found)
+    {
+      std::ostringstream oss;
+      oss << "MEDLoader::GetMeshGroupsNamesOnFamily : no such family \"" << famName << "\" in file \"" << fileName << "\" in mesh \"" << meshName << "\" !";
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  return ret;
+}
   
 std::vector<std::string> MEDLoader::GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception)
 {
@@ -812,7 +846,7 @@ double MEDLoader::GetTimeAttachedOnFieldIteration(const char *fileName, const ch
   //
   bool found=false;
   bool found2=false;
-  double ret;
+  double ret=std::numeric_limits<double>::max();
   for(int i=0;i<nbFields && !found;i++)
     {
       med_int ncomp=MEDnChamp(fid,i+1);
@@ -1743,6 +1777,8 @@ int MEDLoaderNS::buildMEDSubConnectivityOfOneType(const std::vector<const DataAr
 MEDCouplingUMesh *MEDLoaderNS::readUMeshFromFileLev1(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<int>& ids,
                                                      const std::vector<INTERP_KERNEL::NormalizedCellType>& typesToKeep, unsigned& meshDimExtract, int *&cellRenum) throw(INTERP_KERNEL::Exception)
 {
+  if(meshDimRelToMax>0)
+    throw INTERP_KERNEL::Exception("meshDimRelToMax must be <=0 !");
   //Extraction data from MED file.
   med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE);
   std::string trueMeshName;
@@ -1791,7 +1827,7 @@ ParaMEDMEM::MEDCouplingFieldDouble *MEDLoaderNS::readFieldDoubleLev2(const char
         {
           std::vector<int> ci(cellIds.size());
           std::transform(cellIds.begin(),cellIds.end(),ci.begin(),std::bind2nd(std::plus<int>(),-1));
-          ParaMEDMEM::MEDCouplingUMesh *mesh2;
+          ParaMEDMEM::MEDCouplingUMesh *mesh2=0;
           if(typeOfOutField==ON_CELLS)
             {
               if(newMesh)
index b90cad0f778f4114ed85c22b9cbd7b5bda3ad8df..caf103fc5a960a617025073fa21016eff1dd3fd1 100644 (file)
@@ -90,6 +90,8 @@ class MEDLOADER_EXPORT MEDLoader
   static std::vector<std::string> GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
   static std::vector<std::string> GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
   static std::vector<std::string> GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
+  static std::vector<std::string> GetMeshFamiliesNamesOnGroup(const char *fileName, const char *meshName, const char *grpName) throw(INTERP_KERNEL::Exception);
+  static std::vector<std::string> GetMeshGroupsNamesOnFamily(const char *fileName, const char *meshName, const char *famName) throw(INTERP_KERNEL::Exception);
   static std::vector<std::string> GetAllFieldNames(const char *fileName) throw(INTERP_KERNEL::Exception);
   static std::vector<std::string> GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
   static std::vector<ParaMEDMEM::TypeOfField> GetTypesOfField(const char *fileName, const char *fieldName, const char *meshName) throw(INTERP_KERNEL::Exception);
index 3a2fbb7608bd22f46993b7e5411eafd93bd28908..484e22f69a561d3a4a85e8cad620be3b157757d5 100755 (executable)
@@ -36,10 +36,13 @@ lib_LTLIBRARIES = libmedloader.la
 
 salomeinclude_HEADERS= \
 MEDLoaderDefines.hxx \
-MEDLoader.hxx MEDLoaderBase.hxx
+MEDLoader.hxx MEDLoaderBase.hxx MEDFileUtilities.hxx MEDFileMesh.hxx MEDFileMeshLL.hxx \
+MEDFileMeshElt.hxx MEDFileBasis.hxx
 
 dist_libmedloader_la_SOURCES= \
-MEDLoader.cxx MEDLoaderBase.cxx
+MEDLoader.cxx MEDLoaderBase.cxx MEDFileUtilities.cxx      \
+MEDFileMesh.cxx MEDFileMeshElt.cxx MEDFileBasis.cxx       \
+MEDFileMeshLL.cxx
 
 libmedloader_la_CPPFLAGS= $(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \
        -I$(srcdir)/../INTERP_KERNEL \
diff --git a/src/MEDLoader/Swig/MEDLoader.i b/src/MEDLoader/Swig/MEDLoader.i
new file mode 100644 (file)
index 0000000..e6f960b
--- /dev/null
@@ -0,0 +1,212 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module MEDLoader
+
+#define MEDCOUPLING_EXPORT
+#define MEDLOADER_EXPORT
+
+%include "MEDCoupling.i"
+
+%{
+#include "MEDLoader.hxx"
+#include "MEDFileMesh.hxx"
+#include "MEDLoaderTypemaps.i"
+
+using namespace ParaMEDMEM;
+%}
+
+#if SWIG_VERSION >= 0x010329
+%template()  std::vector<std::string>;
+#endif
+
+%typemap(out) ParaMEDMEM::MEDFileMesh*
+{
+  $result=convertMEDFileMesh($1,$owner);
+}
+
+%newobject MEDLoader::ReadUMeshFromFamilies;
+%newobject MEDLoader::ReadUMeshFromGroups;
+%newobject MEDLoader::ReadUMeshFromFile;
+%newobject MEDLoader::ReadField;
+%newobject MEDLoader::ReadFieldCell;
+%newobject MEDLoader::ReadFieldNode;
+%newobject MEDLoader::ReadFieldGauss;
+%newobject MEDLoader::ReadFieldGaussNE;
+%newobject ParaMEDMEM::MEDFileUMesh::New;
+%newobject ParaMEDMEM::MEDFileUMesh::getCoords;
+%newobject ParaMEDMEM::MEDFileUMesh::getGroup;
+%newobject ParaMEDMEM::MEDFileUMesh::getGroups;
+%newobject ParaMEDMEM::MEDFileUMesh::getFamily;
+%newobject ParaMEDMEM::MEDFileUMesh::getFamilies;
+%newobject ParaMEDMEM::MEDFileUMesh::getGroupArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getGroupsArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getFamilyArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getFamiliesArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getNodeGroupArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getNodeGroupsArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getNodeFamilyArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getNodeFamiliesArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getMeshAtRank;
+%newobject ParaMEDMEM::MEDFileUMesh::getRank0Mesh;
+%newobject ParaMEDMEM::MEDFileUMesh::getRankM1Mesh;
+%newobject ParaMEDMEM::MEDFileUMesh::getRankM2Mesh;
+%newobject ParaMEDMEM::MEDFileUMesh::getRankM3Mesh;
+
+class MEDLoader
+{
+public:
+  static void setEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception);
+  static void setCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception);
+  static void setTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception);
+  static void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception);
+  static std::vector<std::string> GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception);
+  static std::vector<std::string> GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+  static std::vector<std::string> GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
+  static std::vector<std::string> GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
+  static std::vector<std::string> GetMeshFamiliesNamesOnGroup(const char *fileName, const char *meshName, const char *grpName) throw(INTERP_KERNEL::Exception);
+  static std::vector<std::string> GetMeshGroupsNamesOnFamily(const char *fileName, const char *meshName, const char *famName) throw(INTERP_KERNEL::Exception);
+  static std::vector<std::string> GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
+  static std::vector<std::string> GetAllFieldNames(const char *fileName) throw(INTERP_KERNEL::Exception);
+  static std::vector<std::string> GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
+  static std::vector<std::string> GetCellFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
+  static std::vector<std::string> GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
+  static double GetTimeAttachedOnFieldIteration(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+  %extend
+     {
+       static PyObject *GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+       {
+         std::vector< std::pair<int,int> > res=MEDLoader::GetFieldIterations(type,fileName,meshName,fieldName);
+         PyObject *ret=PyList_New(res.size());
+         int rk=0;
+         for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
+           {
+             PyObject *elt=PyTuple_New(2);
+             PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
+             PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
+             PyList_SetItem(ret,rk,elt);
+           }
+         return ret;
+       }
+
+       static PyObject *GetAllFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+       {
+         std::vector< std::pair< std::pair<int,int>, double> > res=MEDLoader::GetAllFieldIterations(fileName,meshName,fieldName);
+         PyObject *ret=PyList_New(res.size());
+         int rk=0;
+         for(std::vector< std::pair< std::pair<int,int>, double> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
+           {
+             PyObject *elt=PyTuple_New(3);
+             PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first.first));
+             PyTuple_SetItem(elt,1,SWIG_From_int((*iter).first.second));
+             PyTuple_SetItem(elt,2,SWIG_From_double((*iter).second));
+             PyList_SetItem(ret,rk,elt);
+           }
+         return ret;
+       }
+
+       static PyObject *GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+       {
+         std::vector< std::pair<int,int> > res=MEDLoader::GetCellFieldIterations(fileName,meshName,fieldName);
+         PyObject *ret=PyList_New(res.size());
+         int rk=0;
+         for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
+           {
+             PyObject *elt=PyTuple_New(2);
+             PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
+             PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
+             PyList_SetItem(ret,rk,elt);
+           }
+         return ret;
+       }
+       static PyObject *GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+       {
+         std::vector< std::pair<int,int> > res=MEDLoader::GetNodeFieldIterations(fileName,meshName,fieldName);
+         PyObject *ret=PyList_New(res.size());
+         int rk=0;
+         for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
+           {
+             PyObject *elt=PyTuple_New(2);
+             PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
+             PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
+             PyList_SetItem(ret,rk,elt);
+           }
+         return ret;
+       }
+       static PyObject *ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax,
+                                             const char *fieldName, PyObject *liIts) throw(INTERP_KERNEL::Exception)
+       {
+         std::vector<std::pair<int,int> > its=convertTimePairIdsFromPy(liIts);
+         std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> res=MEDLoader::ReadFieldsOnSameMesh(type,fileName,meshName,meshDimRelToMax,fieldName,its);
+         return convertFieldDoubleVecToPy(res);
+       }
+       static void WriteUMeshesPartition(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
+       {
+         std::vector<ParaMEDMEM::MEDCouplingUMesh *> v=convertFieldDoubleVecFromPy(li);
+         MEDLoader::WriteUMeshesPartition(fileName,meshName,v,writeFromScratch);
+       }
+       static void WriteUMeshesPartitionDep(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
+       {
+         std::vector<ParaMEDMEM::MEDCouplingUMesh *> v=convertFieldDoubleVecFromPy(li);
+         MEDLoader::WriteUMeshesPartitionDep(fileName,meshName,v,writeFromScratch);
+       }
+       static void WriteUMeshes(const char *fileName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
+       {
+         std::vector<ParaMEDMEM::MEDCouplingUMesh *> v=convertFieldDoubleVecFromPy(li);
+         std::vector<const ParaMEDMEM::MEDCouplingUMesh *> v2(v.begin(),v.end());
+         MEDLoader::WriteUMeshes(fileName,v2,writeFromScratch);
+       }
+       static PyObject *GetTypesOfField(const char *fileName, const char *fieldName, const char *meshName) throw(INTERP_KERNEL::Exception)
+       {
+         std::vector< ParaMEDMEM::TypeOfField > v=MEDLoader::GetTypesOfField(fileName,fieldName,meshName);
+         int size=v.size();
+         PyObject *ret=PyList_New(size);
+         for(int i=0;i<size;i++)
+           PyList_SetItem(ret,i,PyInt_FromLong((int)v[i]));
+         return ret;
+       }
+       static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, PyObject *li) throw(INTERP_KERNEL::Exception)
+       {
+         std::vector<std::string> grps;
+         converPyListToVecString(li,grps);
+         return MEDLoader::ReadUMeshFromGroups(fileName,meshName,meshDimRelToMax,grps);
+       }
+       static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, PyObject *li) throw(INTERP_KERNEL::Exception)
+       {
+         std::vector<std::string> fams;
+         converPyListToVecString(li,fams);
+         return MEDLoader::ReadUMeshFromFamilies(fileName,meshName,meshDimRelToMax,fams);
+       }
+     }
+  static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
+  static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
+  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);
+  static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+  static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+  static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+  static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+  static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
+  static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
+  static void WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
+  static void WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
+  static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
+};
+
+%include "MEDFileMesh.hxx"
+
index 2ec4ac83720cc60ebddefcb87a0913bfd7b4c464..a0f370d8d193210f85128f1fac83a129c0f2d541 100644 (file)
@@ -18,7 +18,7 @@
 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-from libMEDLoader_Swig import *
+from MEDLoader import *
 from math import pi,e,sqrt
 
 class MEDLoaderDataForTest:
@@ -195,7 +195,7 @@ class MEDLoaderDataForTest:
         vec=[0.,1.,0.]
         pt=[0.,0.,0.]
         m1d.rotate(pt,vec,-pi/2.);
-        ret=m3dsurf.buildExtrudedMeshFromThis(m1d,0);
+        ret=m3dsurf.buildExtrudedMesh(m1d,0);
         return ret;
 
     def buildVecFieldOnCells_1(cls):
index e0c9a080ab9885a7e9c872ca6fdc8ebbf2f8e03e..8b9e8348a7c702154ea5464c7cda2f9ecd089aec 100644 (file)
@@ -18,7 +18,7 @@
 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-from libMEDLoader_Swig import *
+import MEDLoader
 import unittest
 from math import pi,e,sqrt
 from MEDLoaderDataForTest import MEDLoaderDataForTest
@@ -27,52 +27,52 @@ class MEDLoaderTest(unittest.TestCase):
     def testMesh1DRW(self):
         mesh=MEDLoaderDataForTest.build1DMesh_1();
         mesh.checkCoherency();
-        MEDLoader.WriteUMesh("Pyfile1.med",mesh,True);
-        mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile1.med",mesh.getName(),0);
+        MEDLoader.MEDLoader.WriteUMesh("Pyfile1.med",mesh,True);
+        mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile1.med",mesh.getName(),0);
         self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
         pass
 
     def testMesh2DCurveRW(self):
         mesh=MEDLoaderDataForTest.build2DCurveMesh_1();
         mesh.checkCoherency();
-        MEDLoader.WriteUMesh("Pyfile2.med",mesh,True);
-        mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile2.med",mesh.getName(),0);
+        MEDLoader.MEDLoader.WriteUMesh("Pyfile2.med",mesh,True);
+        mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile2.med",mesh.getName(),0);
         self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
         pass
 
     def testMesh2DRW(self):
         mesh=MEDLoaderDataForTest.build2DMesh_1();
         mesh.checkCoherency();
-        MEDLoader.WriteUMesh("Pyfile3.med",mesh,True);
-        mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile3.med",mesh.getName(),0);
+        MEDLoader.MEDLoader.WriteUMesh("Pyfile3.med",mesh,True);
+        mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile3.med",mesh.getName(),0);
         self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
         pass
 
     def testMesh3DSurfRW(self):
         mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
         mesh.checkCoherency();
-        MEDLoader.WriteUMesh("Pyfile4.med",mesh,True);
-        mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile4.med",mesh.getName(),0);
+        MEDLoader.MEDLoader.WriteUMesh("Pyfile4.med",mesh,True);
+        mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile4.med",mesh.getName(),0);
         self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
         pass
 
     def testMesh3DRW(self):
         mesh=MEDLoaderDataForTest.build3DMesh_1();
         mesh.checkCoherency();
-        MEDLoader.WriteUMesh("Pyfile5.med",mesh,True);
-        mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile5.med",mesh.getName(),0);
+        MEDLoader.MEDLoader.WriteUMesh("Pyfile5.med",mesh,True);
+        mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile5.med",mesh.getName(),0);
         self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
         pass
 
     def testFieldRW1(self):
         f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
-        MEDLoader.WriteField("Pyfile6.med",f1,True);
-        f2=MEDLoader.ReadFieldCell("Pyfile6.med",f1.getMesh().getName(),0,f1.getName(),0,1);
+        MEDLoader.MEDLoader.WriteField("Pyfile6.med",f1,True);
+        f2=MEDLoader.MEDLoader.ReadFieldCell("Pyfile6.med",f1.getMesh().getName(),0,f1.getName(),0,1);
         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
         #
         f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
-        MEDLoader.WriteField("Pyfile7.med",f1,True);
-        f2=MEDLoader.ReadFieldNode("Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3);
+        MEDLoader.MEDLoader.WriteField("Pyfile7.med",f1,True);
+        f2=MEDLoader.MEDLoader.ReadFieldNode("Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3);
         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
         pass
 
@@ -81,46 +81,46 @@ class MEDLoaderTest(unittest.TestCase):
         VAL1=12345.67890314;
         VAL2=-1111111111111.;
         f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
-        MEDLoader.WriteField(fileName,f1,True);
+        MEDLoader.MEDLoader.WriteField(fileName,f1,True);
         f1.setTime(10.,8,9);
         f1.getArray().setIJ(0,0,VAL1);
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
         f1.setTime(10.14,18,19);
         f1.getArray().setIJ(0,0,VAL2);
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
         #retrieving time steps...
-        f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),8,9);
+        f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),8,9);
         f1.setTime(10.,8,9);
         f1.getArray().setIJ(0,0,VAL1);
         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
-        f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),0,1);
+        f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),0,1);
         f3=MEDLoaderDataForTest.buildVecFieldOnCells_1();
         self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
-        f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),18,19);
+        f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),18,19);
         f1.setTime(10.14,18,19);
         f1.getArray().setIJ(0,0,VAL2);
         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
         #test of throw on invalid (dt,it)
-        self.assertRaises(Exception,MEDLoader.ReadFieldCell,fileName,f1.getMesh().getName(),0,f1.getName(),28,19);
+        self.assertRaises(Exception,MEDLoader.MEDLoader.ReadFieldCell,fileName,f1.getMesh().getName(),0,f1.getName(),28,19);
         #ON NODES
         f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
         fileName2="Pyfile9.med";
-        MEDLoader.WriteField(fileName2,f1,True);
+        MEDLoader.MEDLoader.WriteField(fileName2,f1,True);
         f1.setTime(110.,108,109);
         tmp=f1.getArray().getPointer();
         f1.getArray().setIJ(0,3,VAL1);
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
         f1.setTime(210.,208,209);
         f1.getArray().setIJ(0,3,VAL2);
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
-        f2=MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),108,109);
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
+        f2=MEDLoader.MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),108,109);
         f1.setTime(110.,108,109);
         f1.getArray().setIJ(0,3,VAL1);
         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
-        f2=MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),2,3);
+        f2=MEDLoader.MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),2,3);
         f3=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
         self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
-        f2=MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),208,209);
+        f2=MEDLoader.MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),208,209);
         f1.setTime(210.,208,209);
         f1.getArray().setIJ(0,3,VAL2);
         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
@@ -142,72 +142,72 @@ class MEDLoaderTest(unittest.TestCase):
         f1.setTime(10.,8,9);
         tmp=f1.getArray().getPointer();
         f1.getArray().setIJ(0,0,VAL1);
-        MEDLoader.WriteField(fileName,f1,True);
+        MEDLoader.MEDLoader.WriteField(fileName,f1,True);
         f1.setTime(10.14,18,19);
         f1.getArray().setIJ(0,0,VAL2);
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
         f1.getMesh().setName(name2);
         f1.setTime(10.55,28,29);
         f1.getArray().setIJ(0,0,3*VAL1);
-        MEDLoader.WriteField(fileName,f1,False);
-        vec=MEDLoader.GetMeshNamesOnField(fileName,name1);
+        MEDLoader.MEDLoader.WriteField(fileName,f1,False);
+        vec=MEDLoader.MEDLoader.GetMeshNamesOnField(fileName,name1);
         self.assertEqual(2,len(vec));
         self.assertTrue(vec[0]==name3);
         self.assertTrue(vec[1]==name2);
         f1.setTime(10.66,38,39);
         f1.getArray().setIJ(0,0,3*VAL2);
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
         f1.setTime(10.77,48,49);
         f1.getArray().setIJ(0,0,4*VAL2);
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
         #ON NODES
         f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
         f1.setName(name1);
         f1.getMesh().setName(name2);
         f1.setTime(110.,8,9);
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
         f1.setTime(110.,108,109);
         tmp=f1.getArray().getPointer();
         f1.getArray().setIJ(0,3,VAL1);
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
         f1.setTime(210.,208,209);
         f1.getArray().setIJ(0,3,VAL2);
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
         #
-        it1=MEDLoader.GetCellFieldIterations(fileName,name3,name1);
+        it1=MEDLoader.MEDLoader.GetCellFieldIterations(fileName,name3,name1);
         self.assertEqual(2,len(it1));
         self.assertEqual(8,it1[0][0]); self.assertEqual(9,it1[0][1]);
         self.assertEqual(18,it1[1][0]); self.assertEqual(19,it1[1][1]);
-        it2=MEDLoader.GetCellFieldIterations(fileName,name2,name1);
+        it2=MEDLoader.MEDLoader.GetCellFieldIterations(fileName,name2,name1);
         self.assertEqual(3,len(it2));
         self.assertEqual(28,it2[0][0]); self.assertEqual(29,it2[0][1]);
         self.assertEqual(38,it2[1][0]); self.assertEqual(39,it2[1][1]);
         self.assertEqual(48,it2[2][0]); self.assertEqual(49,it2[2][1]);
-        it3=MEDLoader.GetNodeFieldIterations(fileName,name2,name1);
+        it3=MEDLoader.MEDLoader.GetNodeFieldIterations(fileName,name2,name1);
         self.assertEqual(3,len(it3));
         self.assertEqual(8,it3[0][0]); self.assertEqual(9,it3[0][1]);
         self.assertEqual(108,it3[1][0]); self.assertEqual(109,it3[1][1]);
         self.assertEqual(208,it3[2][0]); self.assertEqual(209,it3[2][1]);
-        it4=MEDLoader.GetNodeFieldIterations(fileName,name3,name1);
+        it4=MEDLoader.MEDLoader.GetNodeFieldIterations(fileName,name3,name1);
         self.assertTrue(len(it4)==0);
         #
         #
-        f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,8,9);
+        f1=MEDLoader.MEDLoader.ReadFieldCell(fileName,name3,0,name1,8,9);
         self.assertAlmostEqual(VAL1,f1.getArray().getIJ(0,0),13);
-        f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,18,19);
+        f1=MEDLoader.MEDLoader.ReadFieldCell(fileName,name3,0,name1,18,19);
         self.assertAlmostEqual(VAL2,f1.getArray().getIJ(0,0),13);
-        f1=MEDLoader.ReadFieldCell(fileName,name2,0,name1,28,29);
+        f1=MEDLoader.MEDLoader.ReadFieldCell(fileName,name2,0,name1,28,29);
         self.assertAlmostEqual(3*VAL1,f1.getArray().getIJ(0,0),13);
-        f1=MEDLoader.ReadFieldCell(fileName,name2,0,name1,38,39);
+        f1=MEDLoader.MEDLoader.ReadFieldCell(fileName,name2,0,name1,38,39);
         self.assertAlmostEqual(3*VAL2,f1.getArray().getIJ(0,0),13);
-        f1=MEDLoader.ReadFieldCell(fileName,name2,0,name1,48,49);
+        f1=MEDLoader.MEDLoader.ReadFieldCell(fileName,name2,0,name1,48,49);
         self.assertAlmostEqual(4*VAL2,f1.getArray().getIJ(0,0),13);
         #
-        f1=MEDLoader.ReadFieldNode(fileName,name2,0,name1,8,9);
+        f1=MEDLoader.MEDLoader.ReadFieldNode(fileName,name2,0,name1,8,9);
         self.assertAlmostEqual(71.,f1.getArray().getIJ(0,3),13);
-        f1=MEDLoader.ReadFieldNode(fileName,name2,0,name1,108,109);
+        f1=MEDLoader.MEDLoader.ReadFieldNode(fileName,name2,0,name1,108,109);
         self.assertAlmostEqual(VAL1,f1.getArray().getIJ(0,3),13);
-        f1=MEDLoader.ReadFieldNode(fileName,name2,0,name1,208,209);
+        f1=MEDLoader.MEDLoader.ReadFieldNode(fileName,name2,0,name1,208,209);
         self.assertAlmostEqual(VAL2,f1.getArray().getIJ(0,3),13);
         pass
 
@@ -220,66 +220,78 @@ class MEDLoaderTest(unittest.TestCase):
         part2=[3,4,13,14]
         mesh3=mesh1.buildPartOfMySelf(part2,True);
         mesh3.setName("mesh3");
-        mesh4=MEDCouplingUMesh.New();
+        mesh4=MEDLoader.MEDCouplingUMesh.New();
         mesh4.setName("mesh4");
         mesh4.setMeshDimension(3);
         mesh4.allocateCells(1);
         conn=[0,11,1,3]
-        mesh4.insertNextCell(NORM_TETRA4,4,conn[0:4])
+        mesh4.insertNextCell(MEDLoader.NORM_TETRA4,4,conn[0:4])
         mesh4.finishInsertingCells();
         mesh4.setCoords(mesh1.getCoords());
         meshes=[mesh1,mesh2,mesh3,mesh4]
         mnane="3DToto";
-        MEDLoader.WriteUMeshesPartition(fileName,mnane,meshes,True);
+        MEDLoader.MEDLoader.WriteUMeshesPartition(fileName,mnane,meshes,True);
         #
-        mesh5=MEDLoader.ReadUMeshFromFile(fileName,mnane);
+        mesh5=MEDLoader.MEDLoader.ReadUMeshFromFile(fileName,mnane);
         mesh1.setName(mnane);
         part3=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]
         mesh6=mesh5.buildPartOfMySelf(part3,True);
         mesh6.setName(mnane);
         self.assertTrue(mesh6.isEqual(mesh1,1e-12));
-        grps=MEDLoader.GetMeshGroupsNames(fileName,mnane);
+        grps=MEDLoader.MEDLoader.GetMeshGroupsNames(fileName,mnane);
         self.assertEqual(4,len(grps));
         grps.index("mesh2");
         grps.index("mesh3");
         grps.index("mesh4");
         grps.index("3DMesh_1");
         #
-        vec=["mesh2"];
-        mesh2_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
+        vec=("mesh2",);
+        mesh2_2=MEDLoader.MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
         self.assertTrue(mesh2_2.isEqual(mesh2,1e-12));
         vec=["mesh3"];
-        mesh3_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
+        mesh3_2=MEDLoader.MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
         self.assertTrue(mesh3_2.isEqual(mesh3,1e-12));
         vec=["mesh4"];
-        mesh4_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
+        mesh4_2=MEDLoader.MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
         self.assertTrue(mesh4_2.isEqual(mesh4,1e-12));
-        vec=["3DMesh_1"];
-        mesh1_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
+        vec="3DMesh_1";
+        mesh1_2=MEDLoader.MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
         mesh1.setName("3DMesh_1");
         self.assertTrue(mesh1_2.isEqual(mesh1,1e-12));
         #
         vec=["Family_4","Family_2"];
-        mesh2_2=MEDLoader.ReadUMeshFromFamilies(fileName,mnane,0,vec);
+        mesh2_2=MEDLoader.MEDLoader.ReadUMeshFromFamilies(fileName,mnane,0,vec);
         mesh2_2.setName("mesh2");
         self.assertTrue(mesh2_2.isEqual(mesh2,1e-12));
+        #
+        ret=MEDLoader.MEDLoader.GetMeshFamiliesNamesOnGroup(fileName,"3DToto","3DMesh_1");
+        self.assertEqual(4,len(ret));
+        self.assertEqual(ret[0],"Family_1");
+        self.assertEqual(ret[1],"Family_2");
+        self.assertEqual(ret[2],"Family_3");
+        self.assertEqual(ret[3],"Family_4");
+        #
+        ret1=MEDLoader.MEDLoader.GetMeshGroupsNamesOnFamily(fileName,"3DToto","Family_2");
+        self.assertEqual(2,len(ret1));
+        self.assertEqual(ret1[0],"3DMesh_1");
+        self.assertEqual(ret1[1],"mesh2");
         pass
 
     def testFieldProfilRW1(self):
         fileName="Pyfile12.med";
         mesh1=MEDLoaderDataForTest.build3DMesh_1();
         da,b,newNbOfNodes=mesh1.mergeNodes(1e-12);
-        MEDLoader.WriteUMesh(fileName,mesh1,True);
+        MEDLoader.MEDLoader.WriteUMesh(fileName,mesh1,True);
         part1=[1,2,4,13,15]
         mesh2=mesh1.buildPartOfMySelf(part1,True);
         mesh2.setName(mesh1.getName());#<- important for the test
         #
         nbOfCells=mesh2.getNumberOfCells();
         self.assertEqual(5,nbOfCells);
-        f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+        f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_CELLS,MEDLoader.ONE_TIME);
         f1.setName("VectorFieldOnCells");
         f1.setMesh(mesh2);
-        array=DataArrayDouble.New();
+        array=MEDLoader.DataArrayDouble.New();
         array.alloc(nbOfCells,2);
         f1.setArray(array);
         arr1=[71.,171.,10.,110.,20.,120.,30.,130.,40.,140.]
@@ -287,9 +299,9 @@ class MEDLoaderTest(unittest.TestCase):
         f1.setTime(3.14,2,7);
         f1.checkCoherency();
         #
-        MEDLoader.WriteField(fileName,f1,False);#<- False important for the test
+        MEDLoader.MEDLoader.WriteField(fileName,f1,False);#<- False important for the test
         #
-        f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
+        f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
         f2.checkCoherency();
         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
         #
@@ -298,16 +310,16 @@ class MEDLoaderTest(unittest.TestCase):
     def testFieldGaussRW1(self):
         fileName="Pyfile13.med";
         f1=MEDLoaderDataForTest.buildVecFieldOnGauss_1();
-        MEDLoader.WriteField(fileName,f1,True);
-        f2=MEDLoader.ReadField(ON_GAUSS_PT,fileName,f1.getMesh().getName(),0,f1.getName(),1,5);
+        MEDLoader.MEDLoader.WriteField(fileName,f1,True);
+        f2=MEDLoader.MEDLoader.ReadField(MEDLoader.ON_GAUSS_PT,fileName,f1.getMesh().getName(),0,f1.getName(),1,5);
         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
         pass
 
     def testFieldGaussNERW1(self):
         fileName="Pyfile14.med";
         f1=MEDLoaderDataForTest.buildVecFieldOnGaussNE_1();
-        MEDLoader.WriteField(fileName,f1,True);
-        f2=MEDLoader.ReadField(ON_GAUSS_NE,fileName,f1.getMesh().getName(),0,f1.getName(),1,5);
+        MEDLoader.MEDLoader.WriteField(fileName,f1,True);
+        f2=MEDLoader.MEDLoader.ReadField(MEDLoader.ON_GAUSS_NE,fileName,f1.getMesh().getName(),0,f1.getName(),1,5);
         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
         pass
 
@@ -317,8 +329,8 @@ class MEDLoaderTest(unittest.TestCase):
         renumber1=[2,5,1,0,3,4]
         mesh.renumberCells(renumber1,False);
         mesh.checkCoherency();
-        MEDLoader.WriteUMesh(fileName,mesh,True);
-        mesh_rw=MEDLoader.ReadUMeshFromFile(fileName,mesh.getName(),0);
+        MEDLoader.MEDLoader.WriteUMesh(fileName,mesh,True);
+        mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile(fileName,mesh.getName(),0);
         self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
         pass
 
@@ -333,23 +345,23 @@ class MEDLoaderTest(unittest.TestCase):
         m.renumberCells(renum,False);
         m.orientCorrectlyPolyhedrons();
         # Writing
-        MEDLoader.WriteUMesh(fileName,m,True);
+        MEDLoader.MEDLoader.WriteUMesh(fileName,m,True);
         f1Tmp=m.getMeasureField(False);
-        f1=f1Tmp.buildNewTimeReprFromThis(ONE_TIME,False);
+        f1=f1Tmp.buildNewTimeReprFromThis(MEDLoader.ONE_TIME,False);
         f1.setTime(0.,1,2);
         f_1=f1.cloneWithMesh(True);
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
         f1.applyFunc("2*x");
         f1.setTime(0.01,3,4);
         f_2=f1.cloneWithMesh(True);
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
         f1.applyFunc("2*x/3");
         f1.setTime(0.02,5,6);
         f_3=f1.cloneWithMesh(True);
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
         # Reading
         its=[(1,2),(3,4),(5,6)];
-        fs=MEDLoader.ReadFieldsOnSameMesh(ON_CELLS,fileName,f_1.getMesh().getName(),0,f_1.getName(),its);
+        fs=MEDLoader.MEDLoader.ReadFieldsOnSameMesh(MEDLoader.ON_CELLS,fileName,f_1.getMesh().getName(),0,f_1.getName(),its);
         self.assertEqual(3,len(fs));
         self.assertTrue(fs[0].isEqual(f_1,1e-12,1e-12));
         self.assertTrue(fs[1].isEqual(f_2,1e-12,1e-12));
@@ -367,18 +379,18 @@ class MEDLoaderTest(unittest.TestCase):
         m2d.renumberCells(renumber,False);
         m2d.setName("ExampleOfMultiDimW");
         meshes=[m2d,m3d]
-        MEDLoader.WriteUMeshes(fileName,meshes,True);
-        m3d_bis=MEDLoader.ReadUMeshFromFile(fileName,m2d.getName(),0);
+        MEDLoader.MEDLoader.WriteUMeshes(fileName,meshes,True);
+        m3d_bis=MEDLoader.MEDLoader.ReadUMeshFromFile(fileName,m2d.getName(),0);
         self.assertTrue(not m3d_bis.isEqual(m3d,1e-12));
         m3d_bis.setName(m3d.getName());
         self.assertTrue(m3d_bis.isEqual(m3d,1e-12));
-        m2d_bis=MEDLoader.ReadUMeshFromFile(fileName,m2d.getName(),-1);#-1 for faces
+        m2d_bis=MEDLoader.MEDLoader.ReadUMeshFromFile(fileName,m2d.getName(),-1);#-1 for faces
         self.assertTrue(m2d_bis.isEqual(m2d,1e-12));
         # Creation of a field on faces.
-        f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+        f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_CELLS,MEDLoader.ONE_TIME);
         f1.setName("FieldOnFacesShuffle");
         f1.setMesh(m2d);
-        array=DataArrayDouble.New();
+        array=MEDLoader.DataArrayDouble.New();
         arr1=[71.,171.,10.,110.,20.,120.,30.,130.,40.,140.]
         array.setValues(arr1,m2d.getNumberOfCells(),2);
         array.setInfoOnComponent(0,"plkj (mm)");
@@ -387,8 +399,8 @@ class MEDLoaderTest(unittest.TestCase):
         tmp=array.setValues(arr1,m2d.getNumberOfCells(),2);
         f1.setTime(3.14,2,7);
         f1.checkCoherency();
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
-        f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),-1,f1.getName(),2,7);
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+        f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),-1,f1.getName(),2,7);
         self.assertTrue(f2.isEqual(f1,1e-12,1e-12));
         pass
 
@@ -397,11 +409,11 @@ class MEDLoaderTest(unittest.TestCase):
         fileName2="Pyfile20.med";
         m=MEDLoaderDataForTest.build2DMesh_1();
         nbOfNodes=m.getNumberOfNodes();
-        MEDLoader.WriteUMesh(fileName,m,True);
-        f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
+        MEDLoader.MEDLoader.WriteUMesh(fileName,m,True);
+        f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
         f1.setName("VFieldOnNodes");
         f1.setMesh(m);
-        array=DataArrayDouble.New();
+        array=MEDLoader.DataArrayDouble.New();
         arr1=[1.,101.,2.,102.,3.,103.,4.,104.,5.,105.,6.,106.,7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.]
         array.setValues(arr1,nbOfNodes,2);
         f1.setArray(array);
@@ -412,17 +424,17 @@ class MEDLoaderTest(unittest.TestCase):
         arr2=[2,4,5,3,6,7]
         f2=f1.buildSubPart(arr2);
         f2.getMesh().setName(f1.getMesh().getName());
-        MEDLoader.WriteField(fileName,f2,False);#<- False important for the test
+        MEDLoader.MEDLoader.WriteField(fileName,f2,False);#<- False important for the test
         #
-        f3=MEDLoader.ReadFieldNode(fileName,f2.getMesh().getName(),0,f2.getName(),2,7);
+        f3=MEDLoader.MEDLoader.ReadFieldNode(fileName,f2.getMesh().getName(),0,f2.getName(),2,7);
         f3.checkCoherency();
         self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
         #
         arr3=[1,3,0,5,2,4]
         f2.renumberNodes(arr3);
-        MEDLoader.WriteUMesh(fileName2,m,True);
-        MEDLoader.WriteField(fileName2,f2,False);#<- False important for the test
-        f3=MEDLoader.ReadFieldNode(fileName2,f2.getMesh().getName(),0,f2.getName(),2,7);
+        MEDLoader.MEDLoader.WriteUMesh(fileName2,m,True);
+        MEDLoader.MEDLoader.WriteField(fileName2,f2,False);#<- False important for the test
+        f3=MEDLoader.MEDLoader.ReadFieldNode(fileName2,f2.getMesh().getName(),0,f2.getName(),2,7);
         f3.checkCoherency();
         self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
         #
@@ -431,14 +443,14 @@ class MEDLoaderTest(unittest.TestCase):
     def testFieldNodeProfilRW2(self):
         fileName="Pyfile23.med";
         mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
-        MEDLoader.WriteUMesh(fileName,mesh,True);
+        MEDLoader.MEDLoader.WriteUMesh(fileName,mesh,True);
         #
-        f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
+        f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
         f1.setName("FieldMix");
         f1.setMesh(mesh);
         arr2=[1071.,1171.,1010.,1110.,1020.,1120.,1030.,1130.,1040.,1140.,1050.,1150.,
               1060.,1160.,1070.,1170.,1080.,1180.,1090.,1190.,1091.,1191.,1092.,1192.];
-        array=DataArrayDouble.New();
+        array=MEDLoader.DataArrayDouble.New();
         array.setValues(arr2,12,2);
         f1.setArray(array);
         array.setInfoOnComponent(0,"plkj (mm)");
@@ -449,8 +461,8 @@ class MEDLoaderTest(unittest.TestCase):
         renumArr=[3,7,2,1,5,11,10,0,9,6,8,4]
         f1.renumberNodes(renumArr);
         f1.checkCoherency();
-        MEDLoader.WriteField(fileName,f1,False);#<- False important for the test
-        f2=MEDLoader.ReadFieldNode(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
+        MEDLoader.MEDLoader.WriteField(fileName,f1,False);#<- False important for the test
+        f2=MEDLoader.MEDLoader.ReadFieldNode(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
         self.assertTrue(f2.isEqual(f1,1e-12,1e-12));
         #
         pass
@@ -458,10 +470,10 @@ class MEDLoaderTest(unittest.TestCase):
     def testMixCellAndNodesFieldRW1(self):
         fileName="Pyfile21.med";
         mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
-        f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+        f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_CELLS,MEDLoader.ONE_TIME);
         f1.setName("FieldMix");
         f1.setMesh(mesh);
-        array=DataArrayDouble.New();
+        array=MEDLoader.DataArrayDouble.New();
         f1.setArray(array);
         arr1=[71.,171.,10.,110.,20.,120.,30.,130.,40.,140.,50.,150.]
         array.setValues(arr1,6,2);
@@ -470,10 +482,10 @@ class MEDLoaderTest(unittest.TestCase):
         f1.setTime(3.14,2,7);
         f1.checkCoherency();
         #
-        f2=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
+        f2=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
         f2.setName("FieldMix");
         f2.setMesh(mesh);
-        array=DataArrayDouble.New();
+        array=MEDLoader.DataArrayDouble.New();
         f2.setArray(array);
         arr2=[1071.,1171.,1010.,1110.,1020.,1120.,1030.,1130.,1040.,1140.,1050.,1150.,
               1060.,1160.,1070.,1170.,1080.,1180.,1090.,1190.,1091.,1191.,1092.,1192.]
@@ -483,26 +495,26 @@ class MEDLoaderTest(unittest.TestCase):
         f2.setTime(3.17,2,7);
         f2.checkCoherency();
         #
-        MEDLoader.WriteField(fileName,f1,True);
-        ts=MEDLoader.GetTypesOfField(fileName,f1.getName(),f1.getMesh().getName());
+        MEDLoader.MEDLoader.WriteField(fileName,f1,True);
+        ts=MEDLoader.MEDLoader.GetTypesOfField(fileName,f1.getName(),f1.getMesh().getName());
         self.assertEqual(1,len(ts));
-        self.assertEqual(ON_CELLS,ts[0]);
-        fs=MEDLoader.GetAllFieldNamesOnMesh(fileName,f1.getMesh().getName());
+        self.assertEqual(MEDLoader.ON_CELLS,ts[0]);
+        fs=MEDLoader.MEDLoader.GetAllFieldNamesOnMesh(fileName,f1.getMesh().getName());
         self.assertEqual(1,len(fs));
         self.assertTrue(fs[0]=="FieldMix");
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f2);
-        fs=MEDLoader.GetAllFieldNamesOnMesh(fileName,f1.getMesh().getName());
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f2);
+        fs=MEDLoader.MEDLoader.GetAllFieldNamesOnMesh(fileName,f1.getMesh().getName());
         self.assertEqual(1,len(fs));
         self.assertTrue(fs[0]=="FieldMix");
         #
-        ts=MEDLoader.GetTypesOfField(fileName,f1.getName(),f1.getMesh().getName());
+        ts=MEDLoader.MEDLoader.GetTypesOfField(fileName,f1.getName(),f1.getMesh().getName());
         self.assertEqual(2,len(ts));
-        self.assertEqual(ON_NODES,ts[0]);
-        self.assertEqual(ON_CELLS,ts[1]);
+        self.assertEqual(MEDLoader.ON_NODES,ts[0]);
+        self.assertEqual(MEDLoader.ON_CELLS,ts[1]);
         #
-        f3=MEDLoader.ReadFieldNode(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
+        f3=MEDLoader.MEDLoader.ReadFieldNode(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
         self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
-        f3=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
+        f3=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
         self.assertTrue(f3.isEqual(f1,1e-12,1e-12));
         #
         pass
@@ -510,27 +522,27 @@ class MEDLoaderTest(unittest.TestCase):
     def testGetAllFieldNamesRW1(self):
         fileName="Pyfile22.med";
         mesh=MEDLoaderDataForTest.build2DMesh_2();
-        f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
+        f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
         f1.setName("Field1");
         f1.setTime(3.44,5,6);
         f1.setMesh(mesh);
         f1.fillFromAnalytic(2,"x+y");
-        MEDLoader.WriteField(fileName,f1,True);
+        MEDLoader.MEDLoader.WriteField(fileName,f1,True);
         f1.setTime(1002.3,7,8);
         f1.fillFromAnalytic(2,"x+77.*y");
-        MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+        MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
         f1.setName("Field2");
-        MEDLoader.WriteField(fileName,f1,False);
+        MEDLoader.MEDLoader.WriteField(fileName,f1,False);
         f1.setName("Field3");
         mesh.setName("2DMesh_2Bis");
-        MEDLoader.WriteField(fileName,f1,False);
-        f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+        MEDLoader.MEDLoader.WriteField(fileName,f1,False);
+        f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_CELLS,MEDLoader.ONE_TIME);
         f1.setName("Field8");
         f1.setTime(8.99,7,9);
         f1.setMesh(mesh);
         f1.fillFromAnalytic(3,"3*x+y");
-        MEDLoader.WriteField(fileName,f1,False);
-        fs=MEDLoader.GetAllFieldNames(fileName);
+        MEDLoader.MEDLoader.WriteField(fileName,f1,False);
+        fs=MEDLoader.MEDLoader.GetAllFieldNames(fileName);
         self.assertEqual(4,len(fs));
         self.assertTrue(fs[0]=="Field1");
         self.assertTrue(fs[1]=="Field2");
index bc39c1bc01ffa15137a296017b10bbb0978f1066..bace6ddbcb28454a6fdb697deed9b9a60f51d5e3 100644 (file)
@@ -18,7 +18,7 @@
 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-from libMEDLoader_Swig import *
+from MEDLoader import *
 import unittest
 from math import pi,e,sqrt
 from MEDLoaderDataForTest import MEDLoaderDataForTest
diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py
new file mode 100644 (file)
index 0000000..532292e
--- /dev/null
@@ -0,0 +1,92 @@
+#  -*- coding: iso-8859-1 -*-
+#  Copyright (C) 2007-2010  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
+#  License as published by the Free Software Foundation; either
+#  version 2.1 of the License.
+#
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  Lesser General Public License for more details.
+#
+#  You should have received a copy of the GNU Lesser General Public
+#  License along with this library; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from MEDLoader import *
+import unittest
+from math import pi,e,sqrt
+from MEDLoaderDataForTest import MEDLoaderDataForTest
+
+class MEDLoaderTest(unittest.TestCase):
+    def testMEDMesh1(self):
+        fileName="Pyfile18.med"
+        mname="ExampleOfMultiDimW"
+        medmesh=MEDFileUMesh.New(fileName,mname)
+        self.assertEqual((0,-1),medmesh.getNonEmptyLevels())
+        m1_0=medmesh.getRank0Mesh()
+        m1_1=MEDLoader.ReadUMeshFromFile(fileName,mname,0)
+        self.assertTrue(m1_0.isEqual(m1_1,1e-12));
+        m2_0=medmesh.getRankM1Mesh()
+        m2_1=MEDLoader.ReadUMeshFromFile(fileName,mname,-1)
+        self.assertTrue(m2_0.isEqual(m2_1,1e-12));
+        pass
+    def testMEDMesh2(self):
+        fileName="Pyfile10.med"
+        mname="3DToto"
+        outFileName="MEDFileMesh1.med"
+        medmesh=MEDFileUMesh.New(fileName,mname)
+        self.assertEqual((0,),medmesh.getNonEmptyLevels())
+        m1_0=medmesh.getRank0Mesh()
+        m1_1=MEDLoader.ReadUMeshFromFile(fileName,mname,0)
+        self.assertTrue(m1_0.isEqual(m1_1,1e-12));
+        g1_0=medmesh.getGroup(0,"mesh2")
+        g1_1=MEDLoader.ReadUMeshFromGroups(fileName,mname,0,["mesh2"]);
+        self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+        g1_0=medmesh.getGroup(0,"mesh3")
+        g1_1=MEDLoader.ReadUMeshFromGroups(fileName,mname,0,["mesh3"]);
+        self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+        g1_0=medmesh.getGroups(0,["mesh3","mesh2"])
+        g1_1=MEDLoader.ReadUMeshFromGroups(fileName,mname,0,["mesh3","mesh2"]);
+        g1_1.setName(g1_0.getName())
+        self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+        g1_0=medmesh.getFamily(0,"Family_2")
+        g1_1=MEDLoader.ReadUMeshFromFamilies(fileName,mname,0,["Family_2"]);
+        self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+        g1_0=medmesh.getFamilies(0,["Family_2","Family_4"])
+        g1_1=MEDLoader.ReadUMeshFromFamilies(fileName,mname,0,["Family_2","Family_4"]);
+        g1_1.setName(g1_0.getName())
+        self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+        self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+        medmesh.write(outFileName,2);
+        self.assertEqual([2,3,5,14,16],medmesh.getGroupArr(0,"mesh2").getValues());
+        self.assertEqual([2,3,16],medmesh.getFamilyArr(0,"Family_2").getValues());
+        self.assertEqual([2,3,5,14,16],medmesh.getFamiliesArr(0,["Family_4","Family_2"]).getValues());
+        self.assertEqual([19,2,3,4,5,14,15,16],medmesh.getGroupsArr(0,["mesh2","mesh4","mesh3"]).getValues());
+        famn=medmesh.getFamilyNameGivenId(0)
+        self.assertEqual(range(60),medmesh.getNodeFamilyArr(famn).getValues());
+        # without renum
+        self.assertEqual([2,3,5,14,16],medmesh.getGroupArr(0,"mesh2",False).getValues());
+        self.assertEqual([2,3,16],medmesh.getFamilyArr(0,"Family_2",False).getValues());
+        self.assertEqual([2,3,5,14,16],medmesh.getFamiliesArr(0,["Family_4","Family_2"],False).getValues());
+        self.assertEqual([0,2,3,4,5,14,15,16],medmesh.getGroupsArr(0,["mesh2","mesh3","mesh4"],False).getValues());
+        self.assertEqual(range(60),medmesh.getNodeFamilyArr(famn,False).getValues());
+        pass
+    def testMEDMesh3(self):
+        mm=MEDFileUMesh.New()
+        mm.setName("MyFirstMEDCouplingMEDmesh")
+        mm.setDescription("IHopeToConvinceLastMEDMEMUsers")
+        c=DataArrayDouble.New()
+        coords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ];
+        c.setValues(coords,9,2)
+        mm.setCoords(c)
+        mm.addNodeGroup
+        pass
+    pass
+
+unittest.main()
index 94811c36da981c2cc8ed75da202d4bad8fd301f8..b6f40fa23a11baea42a9714086893ded7a2bd87a 100644 (file)
 
 #include <vector>
 
+static PyObject* convertMEDFileMesh(ParaMEDMEM::MEDFileMesh* mesh, int owner)
+{
+  PyObject *ret=0;
+  if(dynamic_cast<ParaMEDMEM::MEDFileUMesh *>(mesh))
+    ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDFileUMesh,owner);
+  if(dynamic_cast<ParaMEDMEM::MEDFileCMesh *>(mesh))
+    ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDFileCMesh,owner);
+  if(!ret)
+    {
+      PyErr_SetString(PyExc_TypeError,"Not recognized type of MEDFileMesh on downcast !");
+      PyErr_Print();
+    }
+  return ret;
+}
+
 static std::vector<std::pair<int,int> > convertTimePairIdsFromPy(PyObject *pyLi)
 {
   std::vector<std::pair<int,int> > ret;
@@ -87,6 +102,45 @@ static std::vector<std::pair<int,int> > convertTimePairIdsFromPy(PyObject *pyLi)
   return ret;
 }
 
+static void converPyListToVecString(PyObject *pyLi, std::vector<std::string>& v)
+{
+  if(PyList_Check(pyLi))
+    {
+      int size=PyList_Size(pyLi);
+      v.resize(size);
+      for(int i=0;i<size;i++)
+        {
+          PyObject *o=PyList_GetItem(pyLi,i);
+          if(!PyString_Check(o))
+            throw INTERP_KERNEL::Exception("In list passed in argument some elements are NOT strings ! Expected a list containing only strings !");
+          const char *st=PyString_AsString(o);
+          v[i]=std::string(st);
+        }
+    }
+  else if(PyTuple_Check(pyLi))
+    {
+      int size=PyTuple_Size(pyLi);
+      v.resize(size);
+      for(int i=0;i<size;i++)
+        {
+          PyObject *o=PyTuple_GetItem(pyLi,i);
+          if(!PyString_Check(o))
+            throw INTERP_KERNEL::Exception("In tuple passed in argument some elements are NOT strings ! Expected a tuple containing only strings !");
+          const char *st=PyString_AsString(o);
+          v[i]=std::string(st);
+        }
+    }
+  else if(PyString_Check(pyLi))
+    {
+      v.resize(1);
+      v[0]=std::string((const char *)PyString_AsString(pyLi));
+    }
+  else
+    {
+      throw INTERP_KERNEL::Exception("Unrecognized python argument : expected a list of string or tuple of string or string !");
+    }
+}
+
 static PyObject *convertFieldDoubleVecToPy(const std::vector<ParaMEDMEM::MEDCouplingFieldDouble *>& li)
 {
   int sz=li.size();
index ab110a19dbe1f0b0a0aa097d49e3c2e1868c80cb..dcdff94c211ad6e720cd23eb3278cc505ad01c85 100644 (file)
 #
 include $(top_srcdir)/adm_local/unix/make_common_starter.am
 
-lib_LTLIBRARIES = _libMEDLoader_Swig.la
+lib_LTLIBRARIES = _MEDLoader.la
 
 salomeinclude_HEADERS =  \
-       libMEDLoader_Swig.i MEDLoaderTypemaps.i
+       MEDLoader.i MEDLoaderTypemaps.i
 
-SWIG_DEF = libMEDLoader_Swig.i MEDLoaderTypemaps.i
+SWIG_DEF = MEDLoader.i MEDLoaderTypemaps.i
 
 SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../../MEDCoupling -I$(srcdir)/../../MEDCoupling_Swig \
        -I$(srcdir)/../../INTERP_KERNEL -I$(srcdir)/../../INTERP_KERNEL/Bases
 
-dist__libMEDLoader_Swig_la_SOURCES   = $(SWIG_DEF)
-nodist__libMEDLoader_Swig_la_SOURCES = libMEDLoader_Swig_wrap.cxx
-libMEDLoader_Swig.py: libMEDLoader_Swig_wrap.cxx
+dist__MEDLoader_la_SOURCES   = $(SWIG_DEF)
+nodist__MEDLoader_la_SOURCES = MEDLoader_wrap.cxx
+MEDLoader.py: MEDLoader_wrap.cxx
 
-libMEDLoader_Swig_wrap.cxx: $(SWIG_DEF)
+MEDLoader_wrap.cxx: $(SWIG_DEF)
        $(SWIG) $(SWIG_FLAGS) -o $@  $<
 
-_libMEDLoader_Swig_la_CPPFLAGS = $(PYTHON_INCLUDES) \
+_MEDLoader_la_CPPFLAGS = $(PYTHON_INCLUDES) \
        $(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \
        -I$(srcdir)/../../INTERP_KERNEL \
        -I$(srcdir)/.. -I$(srcdir)/../../MEDCoupling_Swig -I$(srcdir)/../../INTERP_KERNEL/Bases \
        -I$(srcdir)/../../MEDCoupling
 
-_libMEDLoader_Swig_la_LDFLAGS  = -module $(MED2_LIBS) $(HDF5_LIBS) $(PYTHON_LIBS) \
+_MEDLoader_la_LDFLAGS  = -module $(MED2_LIBS) $(HDF5_LIBS) $(PYTHON_LIBS) \
        ../../MEDCoupling/libmedcoupling.la ../../INTERP_KERNEL/libinterpkernel.la \
        ../libmedloader.la
 
-CLEANFILES = libMEDLoader_Swig_wrap.cxx libMEDLoader_Swig.py
+CLEANFILES = MEDLoader_wrap.cxx MEDLoader.py
 
-dist_salomescript_DATA= libMEDLoader_Swig.py MEDLoaderDataForTest.py MEDLoaderTest.py MEDLoaderTest2.py
+dist_salomescript_DATA= MEDLoaderDataForTest.py MEDLoaderTest.py MEDLoaderTest2.py MEDLoaderTest3.py libMEDLoader_Swig.py
+nodist_salomescript_DATA = MEDLoader.py
 
 UNIT_TEST_PROG = MEDLoaderTest.py MEDLoaderTest2.py
\ No newline at end of file
diff --git a/src/MEDLoader/Swig/libMEDLoader_Swig.i b/src/MEDLoader/Swig/libMEDLoader_Swig.i
deleted file mode 100644 (file)
index 5feded4..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-//  Copyright (C) 2007-2010  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
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-%module libMEDLoader_Swig
-
-#define MEDCOUPLING_EXPORT
-#define MEDLOADER_EXPORT
-
-%include "libMEDCoupling_Swig.i"
-
-%{
-#include "MEDLoader.hxx"
-#include "MEDLoaderTypemaps.i"
-%}
-
-#if SWIG_VERSION >= 0x010329
-%template()  std::vector<std::string>;
-#endif
-
-%newobject MEDLoader::ReadUMeshFromFamilies;
-%newobject MEDLoader::ReadUMeshFromGroups;
-%newobject MEDLoader::ReadUMeshFromFile;
-%newobject MEDLoader::ReadField;
-%newobject MEDLoader::ReadFieldCell;
-%newobject MEDLoader::ReadFieldNode;
-%newobject MEDLoader::ReadFieldGauss;
-%newobject MEDLoader::ReadFieldGaussNE;
-
-class MEDLoader
-{
-public:
-  static void setEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception);
-  static void setCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception);
-  static void setTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception);
-  static void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception);
-  static std::vector<std::string> GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception);
-  static std::vector<std::string> GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
-  static std::vector<std::string> GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
-  static std::vector<std::string> GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
-  static std::vector<std::string> GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
-  static std::vector<std::string> GetAllFieldNames(const char *fileName) throw(INTERP_KERNEL::Exception);
-  static std::vector<std::string> GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
-  static std::vector<std::string> GetCellFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
-  static std::vector<std::string> GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
-  static double GetTimeAttachedOnFieldIteration(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
-  %extend
-     {
-       static PyObject *GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
-       {
-         std::vector< std::pair<int,int> > res=MEDLoader::GetFieldIterations(type,fileName,meshName,fieldName);
-         PyObject *ret=PyList_New(res.size());
-         int rk=0;
-         for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
-           {
-             PyObject *elt=PyTuple_New(2);
-             PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
-             PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
-             PyList_SetItem(ret,rk,elt);
-           }
-         return ret;
-       }
-
-       static PyObject *GetAllFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
-       {
-         std::vector< std::pair< std::pair<int,int>, double> > res=MEDLoader::GetAllFieldIterations(fileName,meshName,fieldName);
-         PyObject *ret=PyList_New(res.size());
-         int rk=0;
-         for(std::vector< std::pair< std::pair<int,int>, double> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
-           {
-             PyObject *elt=PyTuple_New(3);
-             PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first.first));
-             PyTuple_SetItem(elt,1,SWIG_From_int((*iter).first.second));
-             PyTuple_SetItem(elt,2,SWIG_From_double((*iter).second));
-             PyList_SetItem(ret,rk,elt);
-           }
-         return ret;
-       }
-
-       static PyObject *GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
-       {
-         std::vector< std::pair<int,int> > res=MEDLoader::GetCellFieldIterations(fileName,meshName,fieldName);
-         PyObject *ret=PyList_New(res.size());
-         int rk=0;
-         for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
-           {
-             PyObject *elt=PyTuple_New(2);
-             PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
-             PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
-             PyList_SetItem(ret,rk,elt);
-           }
-         return ret;
-       }
-       static PyObject *GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
-       {
-         std::vector< std::pair<int,int> > res=MEDLoader::GetNodeFieldIterations(fileName,meshName,fieldName);
-         PyObject *ret=PyList_New(res.size());
-         int rk=0;
-         for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
-           {
-             PyObject *elt=PyTuple_New(2);
-             PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
-             PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
-             PyList_SetItem(ret,rk,elt);
-           }
-         return ret;
-       }
-       static PyObject *ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax,
-                                             const char *fieldName, PyObject *liIts) throw(INTERP_KERNEL::Exception)
-       {
-         std::vector<std::pair<int,int> > its=convertTimePairIdsFromPy(liIts);
-         std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> res=MEDLoader::ReadFieldsOnSameMesh(type,fileName,meshName,meshDimRelToMax,fieldName,its);
-         return convertFieldDoubleVecToPy(res);
-       }
-       static void WriteUMeshesPartition(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
-       {
-         std::vector<ParaMEDMEM::MEDCouplingUMesh *> v=convertFieldDoubleVecFromPy(li);
-         MEDLoader::WriteUMeshesPartition(fileName,meshName,v,writeFromScratch);
-       }
-       static void WriteUMeshesPartitionDep(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
-       {
-         std::vector<ParaMEDMEM::MEDCouplingUMesh *> v=convertFieldDoubleVecFromPy(li);
-         MEDLoader::WriteUMeshesPartitionDep(fileName,meshName,v,writeFromScratch);
-       }
-       static void WriteUMeshes(const char *fileName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
-       {
-         std::vector<ParaMEDMEM::MEDCouplingUMesh *> v=convertFieldDoubleVecFromPy(li);
-         std::vector<const ParaMEDMEM::MEDCouplingUMesh *> v2(v.begin(),v.end());
-         MEDLoader::WriteUMeshes(fileName,v2,writeFromScratch);
-       }
-       static PyObject *GetTypesOfField(const char *fileName, const char *fieldName, const char *meshName) throw(INTERP_KERNEL::Exception)
-       {
-         std::vector< ParaMEDMEM::TypeOfField > v=MEDLoader::GetTypesOfField(fileName,fieldName,meshName);
-         int size=v.size();
-         PyObject *ret=PyList_New(size);
-         for(int i=0;i<size;i++)
-           PyList_SetItem(ret,i,PyInt_FromLong((int)v[i]));
-         return ret;
-       }
-     }
-  static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& fams) throw(INTERP_KERNEL::Exception);
-  static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& grps) throw(INTERP_KERNEL::Exception);
-  static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
-  static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
-  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);
-  static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
-  static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
-  static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
-  static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
-  static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
-  static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
-  static void WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
-  static void WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
-  static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
-};
diff --git a/src/MEDLoader/Swig/libMEDLoader_Swig.py b/src/MEDLoader/Swig/libMEDLoader_Swig.py
new file mode 100644 (file)
index 0000000..774e3b4
--- /dev/null
@@ -0,0 +1,28 @@
+#  -*- coding: iso-8859-1 -*-
+#  Copyright (C) 2007-2010  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
+#  License as published by the Free Software Foundation; either
+#  version 2.1 of the License.
+#
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  Lesser General Public License for more details.
+#
+#  You should have received a copy of the GNU Lesser General Public
+#  License along with this library; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+print """
+**********************************************************************
+**********************************************************************
+libMEDLoader_Swig module DEPRECATED !
+Please use instead \"import MEDLoader\" or \"from MEDLoader import *\"
+**********************************************************************
+**********************************************************************
+"""
index 6dadebf4835764ec2f52e21bfeab2e10d0666f35..83bb4c6ac37cc7de28be6b7332e3cb953547b675 100644 (file)
@@ -330,6 +330,18 @@ void MEDLoaderTest::testMultiMeshRW1()
   CPPUNIT_ASSERT(mesh2_2->isEqual(mesh2,1e-12));
   mesh2_2->decrRef();
   //
+  std::vector<std::string> ret=MEDLoader::GetMeshFamiliesNamesOnGroup(fileName,"3DToto","3DMesh_1");
+  CPPUNIT_ASSERT_EQUAL(4,(int)ret.size());
+  CPPUNIT_ASSERT(ret[0]=="Family_1");
+  CPPUNIT_ASSERT(ret[1]=="Family_2");
+  CPPUNIT_ASSERT(ret[2]=="Family_3");
+  CPPUNIT_ASSERT(ret[3]=="Family_4");
+  //
+  std::vector<std::string> ret1=MEDLoader::GetMeshGroupsNamesOnFamily(fileName,"3DToto","Family_2");
+  CPPUNIT_ASSERT_EQUAL(2,(int)ret1.size());
+  CPPUNIT_ASSERT(ret1[0]=="3DMesh_1");
+  CPPUNIT_ASSERT(ret1[1]=="mesh2");
+  //
   mesh4->decrRef();
   mesh3->decrRef();
   mesh2->decrRef();
@@ -934,7 +946,7 @@ MEDCouplingUMesh *MEDLoaderTest::build3DMesh_2()
   const double vec[3]={0.,1.,0.};
   const double pt[3]={0.,0.,0.};
   m1d->rotate(pt,vec,-M_PI/2.);
-  MEDCouplingUMesh *ret=m3dsurf->buildExtrudedMeshFromThis(m1d,0);
+  MEDCouplingUMesh *ret=m3dsurf->buildExtrudedMesh(m1d,0);
   m1d->decrRef();
   m3dsurf->decrRef();
   return ret;
index cc3b61dd55dc90a5db07ce836812989dbbafdd52..f3f9e66a028932000d712c760298ea1d3b52d0a6 100644 (file)
@@ -88,6 +88,7 @@ namespace ICoCo
     //creating a connectivity table that complies to MED (1 indexing)
     //and passing it to _mesh
     int* conn=new int[triofield._nodes_per_elem];
+    _mesh->setMeshDimension(triofield._mesh_dim);
     for (int i=0; i<triofield._nb_elems;i++)
       {
         for(int j=0;j<triofield._nodes_per_elem;j++)
@@ -98,7 +99,6 @@ namespace ICoCo
       }
     delete[] conn;
     
-    _mesh->setMeshDimension(triofield._mesh_dim);
     _mesh->finishInsertingCells();
     
     //field on the sending end
index c65f7eaced7a4e7c142d822936a7a9154118fd1d..e1b74305cf8be4695de9a48f9e7fb7c1f3dfe98a 100644 (file)
 #
 include $(top_srcdir)/adm_local/unix/make_common_starter.am
 
-lib_LTLIBRARIES = _libParaMEDMEM_Swig.la
+lib_LTLIBRARIES = _ParaMEDMEM.la
 
 salomeinclude_HEADERS =  \
-       libParaMEDMEM_Swig.i
+       ParaMEDMEM.i
 
-SWIG_DEF = libParaMEDMEM_Swig.i libParaMEDMEM_Swig.typemap
+SWIG_DEF = ParaMEDMEM.i ParaMEDMEM.typemap
 
 SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) $(MPI_INCLUDES)  -I$(srcdir)/../ParaMEDMEM -I$(srcdir)/../MEDCoupling -I$(srcdir)/../MEDCoupling_Swig \
        -I$(srcdir)/../MEDLoader/Swig -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Bases -I$(srcdir)/../ParaMEDLoader        \
        -I$(srcdir)/../MEDLoader
 
-dist__libParaMEDMEM_Swig_la_SOURCES   = $(SWIG_DEF)
-nodist__libParaMEDMEM_Swig_la_SOURCES = libParaMEDMEM_Swig_wrap.cxx
-libParaMEDMEM_Swig.py: libParaMEDMEM_Swig_wrap.cxx
+dist__ParaMEDMEM_la_SOURCES   = $(SWIG_DEF)
+nodist__ParaMEDMEM_la_SOURCES = ParaMEDMEM_wrap.cxx
+ParaMEDMEM.py : ParaMEDMEM_wrap.cxx
 
-libParaMEDMEM_Swig_wrap.cxx: $(SWIG_DEF)
+ParaMEDMEM_wrap.cxx: $(SWIG_DEF)
        $(SWIG) $(SWIG_FLAGS) -o $@  $<
 
-_libParaMEDMEM_Swig_la_CPPFLAGS = $(PYTHON_INCLUDES) \
+_ParaMEDMEM_la_CPPFLAGS = $(PYTHON_INCLUDES) \
        $(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \
        -I$(srcdir)/../INTERP_KERNEL \
        $(MPI_INCLUDES) -I$(srcdir)/../ParaMEDMEM -I$(srcdir)/../MEDCoupling_Swig -I$(srcdir)/../INTERP_KERNEL/Bases \
        -I$(srcdir)/../MEDCoupling -I$(srcdir)/../ParaMEDLoader -I$(srcdir)/../MEDLoader -I$(srcdir)/../MEDLoader/Swig
 
-_libParaMEDMEM_Swig_la_LDFLAGS  = -module $(MED2_LIBS) $(HDF5_LIBS) $(PYTHON_LIBS) $(MPI_LIBS) \
+_ParaMEDMEM_la_LDFLAGS  = -module $(MED2_LIBS) $(HDF5_LIBS) $(PYTHON_LIBS) $(MPI_LIBS) \
        ../MEDCoupling/libmedcoupling.la ../INTERP_KERNEL/libinterpkernel.la \
        ../ParaMEDMEM/libparamedmem.la ../ParaMEDLoader/libparamedloader.la
 
 if MED_ENABLE_KERNEL
-  _libParaMEDMEM_Swig_la_CPPFLAGS += ${KERNEL_CXXFLAGS}
-  _libParaMEDMEM_Swig_la_LDFLAGS  += ${KERNEL_LDFLAGS} -lSALOMELocalTrace
+  _ParaMEDMEM_la_CPPFLAGS += ${KERNEL_CXXFLAGS}
+  _ParaMEDMEM_la_LDFLAGS  += ${KERNEL_LDFLAGS} -lSALOMELocalTrace
 endif
 
-CLEANFILES = libParaMEDMEM_Swig_wrap.cxx libParaMEDMEM_Swig.py
+CLEANFILES = ParaMEDMEM_wrap.cxx ParaMEDMEM.py
 
 dist_salomescript_DATA= test_InterpKernelDEC.py \
                        test_NonCoincidentDEC.py \
-                       test_StructuredCoincodentDEC.py \
-                       ParaMEDMEM.py libParaMEDMEM_Swig.py
+                       test_StructuredCoincidentDEC.py \
+                       ParaMEDMEM.py
diff --git a/src/ParaMEDMEM_Swig/ParaMEDMEM.i b/src/ParaMEDMEM_Swig/ParaMEDMEM.i
new file mode 100644 (file)
index 0000000..0462d02
--- /dev/null
@@ -0,0 +1,261 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module ParaMEDMEM
+
+%include "ParaMEDMEM.typemap"
+%include "MEDCoupling.i"
+%include "MEDLoader.i"
+
+%{
+#include "CommInterface.hxx"
+#include "ProcessorGroup.hxx"
+#include "Topology.hxx"
+#include "MPIProcessorGroup.hxx"
+#include "DEC.hxx"
+#include "InterpKernelDEC.hxx"
+#include "NonCoincidentDEC.hxx"
+#include "StructuredCoincidentDEC.hxx"
+#include "ParaMESH.hxx"
+#include "ParaFIELD.hxx"
+#include "ICoCoMEDField.hxx"
+#include "ComponentTopology.hxx"
+
+#include <mpi.h>
+
+using namespace ParaMEDMEM;
+using namespace ICoCo;
+      
+enum mpi_constants { mpi_comm_world, mpi_comm_self, mpi_double, mpi_int };
+%}
+
+%include "CommInterface.hxx"
+%include "ProcessorGroup.hxx"
+%include "DECOptions.hxx"
+%include "ParaMESH.hxx"
+%include "ParaFIELD.hxx"
+%include "MPIProcessorGroup.hxx"
+%include "ComponentTopology.hxx"
+%include "DEC.hxx"
+%include "InterpKernelDEC.hxx"
+%include "StructuredCoincidentDEC.hxx"
+
+%rename(ICoCoMEDField) ICoCo::MEDField;
+%include "ICoCoMEDField.hxx"
+
+%nodefaultctor;
+
+/* This object can be used only if MED_ENABLE_FVM is defined*/
+#ifdef MED_ENABLE_FVM
+class NonCoincidentDEC : public DEC
+{
+public:
+  NonCoincidentDEC(ProcessorGroup& source, ProcessorGroup& target);
+};
+#endif
+
+%extend ParaMEDMEM::ParaMESH
+{
+  PyObject *getGlobalNumberingCell2() const
+  {
+    const int *tmp=self->getGlobalNumberingCell();
+    int size=self->getCellMesh()->getNumberOfCells();
+    PyObject *ret=PyList_New(size);
+    for(int i=0;i<size;i++)
+      PyList_SetItem(ret,i,PyInt_FromLong(tmp[i])); 
+    return ret;
+  }
+
+  PyObject *getGlobalNumberingFace2() const
+  {
+    const int *tmp=self->getGlobalNumberingFace();
+    int size=self->getFaceMesh()->getNumberOfCells();
+    PyObject *ret=PyList_New(size);
+    for(int i=0;i<size;i++)
+      PyList_SetItem(ret,i,PyInt_FromLong(tmp[i])); 
+    return ret;
+  }
+
+  PyObject *getGlobalNumberingNode2() const
+  {
+    const int *tmp=self->getGlobalNumberingNode();
+    int size=self->getCellMesh()->getNumberOfNodes();
+    PyObject *ret=PyList_New(size);
+    for(int i=0;i<size;i++)
+      PyList_SetItem(ret,i,PyInt_FromLong(tmp[i])); 
+    return ret;
+  }
+}
+
+//=============================================================================================
+// Interface for MPI-realization-specific constants like MPI_COMM_WORLD.
+//
+// Type and values of constants like MPI_COMM_WORLD depends on MPI realization
+// and usually such constants actually are macros. To have such symbols in python
+// and translate them into correct values we use the following technique.
+// We define some constants (enum mpi_constants) and map them into real MPI values
+// using typemaps, and we create needed python symbols equal to 'mpi_constants'
+// via %pythoncode directive.
+
+// Constants corresponding to similar MPI definitions
+enum mpi_constants { mpi_comm_world, mpi_comm_self, mpi_double, mpi_int };
+
+// Map mpi_comm_world and mpi_comm_self -> MPI_COMM_WORLD and MPI_COMM_SELF
+%typemap(in) MPI_Comm
+{ 
+  switch (PyInt_AsLong($input))
+    {
+    case mpi_comm_world: $1 = MPI_COMM_WORLD; break;
+    case mpi_comm_self:  $1 = MPI_COMM_SELF;  break;
+    default:
+      PyErr_SetString(PyExc_TypeError,"unexpected value of MPI_Comm");
+      return NULL;
+    }
+}
+// Map mpi_double and mpi_int -> MPI_DOUBLE and MPI_INT
+%typemap(in) MPI_Datatype
+{ 
+  switch (PyInt_AsLong($input))
+    {
+    case mpi_double:     $1 = MPI_DOUBLE;     break;
+    case mpi_int:        $1 = MPI_INT;        break;
+    default:
+      PyErr_SetString(PyExc_TypeError,"unexpected value of MPI_Datatype");
+      return NULL;
+    }
+}
+// The following code gets inserted into the result python file:
+// create needed python symbols
+%pythoncode %{
+MPI_COMM_WORLD = mpi_comm_world
+MPI_COMM_SELF  = mpi_comm_self
+MPI_DOUBLE     = mpi_double
+MPI_INT        = mpi_int
+%}
+//=============================================================================================
+
+// ==============
+// MPI_Comm_size
+// ==============
+%inline %{ PyObject* MPI_Comm_size(MPI_Comm comm)
+  {
+    int res = 0;
+    int err = MPI_Comm_size(comm, &res);
+    if ( err != MPI_SUCCESS )
+      {
+        PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Comm_size()");
+        return NULL;
+      }
+    return PyInt_FromLong( res );
+  } %}
+
+// ==============
+// MPI_Comm_rank
+// ==============
+%inline %{ PyObject* MPI_Comm_rank(MPI_Comm comm)
+  {
+    int res = 0;
+    int err = MPI_Comm_rank(comm, &res);
+    if ( err != MPI_SUCCESS )
+      {
+        PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Comm_rank()");
+        return NULL;
+      }
+    return PyInt_FromLong( res );
+  } 
+  %}
+
+int MPI_Init(int *argc, char ***argv );
+int MPI_Barrier(MPI_Comm comm);
+int MPI_Finalize();
+
+// ==========
+// MPI_Bcast
+// ==========
+
+%inline %{ PyObject* MPI_Bcast(PyObject* buffer, int nb, MPI_Datatype type, int root, MPI_Comm c)
+  {
+    // buffer must be a list
+    if (!PyList_Check(buffer))
+      {
+        PyErr_SetString(PyExc_TypeError, "buffer is expected to be a list");
+        return NULL;
+      }
+    // check list size
+    int aSize = PyList_Size(buffer);
+    if ( aSize != nb )
+      {
+        std::ostringstream stream; stream << "buffer is expected to be of size " << nb;
+        PyErr_SetString(PyExc_ValueError, stream.str().c_str());
+        return NULL;
+      }
+    // allocate and fill a buffer
+    void* aBuf = 0;
+    int* intBuf = 0;
+    double* dblBuf = 0;
+    if ( type == MPI_DOUBLE )
+      {
+        aBuf = (void*) ( dblBuf = new double[ nb ] );
+        for ( int i = 0; i < aSize; ++i )
+          dblBuf[i] = PyFloat_AS_DOUBLE( PyList_GetItem( buffer, i ));
+      }
+    else if ( type == MPI_INT )
+      {
+        aBuf = (void*) ( intBuf = new int[ nb ] );
+        for ( int i = 0; i < aSize; ++i )
+          intBuf[i] = int( PyInt_AS_LONG( PyList_GetItem( buffer, i )));
+      }
+    else
+      {
+        PyErr_SetString(PyExc_TypeError, "Only MPI_DOUBLE and MPI_INT supported");
+        return NULL;
+      }
+    // call MPI_Bcast
+    int err = MPI_Bcast(aBuf, nb, type, root, c);
+    // treat error
+    if ( err != MPI_SUCCESS )
+      {
+        PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Bcast()");
+        delete [] intBuf; delete [] dblBuf;
+        return NULL;
+      }
+    // put recieved data into the list
+    int pyerr = 0;
+    if ( type == MPI_DOUBLE )
+      {
+        for ( int i = 0; i < aSize && !pyerr; ++i )
+          pyerr = PyList_SetItem(buffer, i, PyFloat_FromDouble( dblBuf[i] ));
+        delete [] dblBuf;
+      }
+    else
+      {
+        for ( int i = 0; i < aSize && !pyerr; ++i )
+          pyerr = PyList_SetItem(buffer, i, PyInt_FromLong( intBuf[i] ));
+        delete [] intBuf;
+      }
+    if ( pyerr )
+      {
+        PyErr_SetString(PyExc_RuntimeError, "Error of PyList_SetItem()");
+        return NULL;
+      }
+    return PyInt_FromLong( err );
+
+  }
+  %}
+
diff --git a/src/ParaMEDMEM_Swig/ParaMEDMEM.py b/src/ParaMEDMEM_Swig/ParaMEDMEM.py
deleted file mode 100644 (file)
index 207d944..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#  -*- coding: iso-8859-1 -*-
-#  Copyright (C) 2007-2010  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
-#  License as published by the Free Software Foundation; either
-#  version 2.1 of the License.
-#
-#  This library is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#  Lesser General Public License for more details.
-#
-#  You should have received a copy of the GNU Lesser General Public
-#  License along with this library; if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-#
-#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-from libParaMEDMEM_Swig import *
diff --git a/src/ParaMEDMEM_Swig/ParaMEDMEM.typemap b/src/ParaMEDMEM_Swig/ParaMEDMEM.typemap
new file mode 100644 (file)
index 0000000..f73253e
--- /dev/null
@@ -0,0 +1,84 @@
+//  Copyright (C) 2007-2010  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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%include std_set.i
+%include std_string.i
+
+%template() std::set<int>;
+
+// Creates "int *argc, char ***argv" parameters from input list
+%typemap(in) (int *argc, char ***argv) {
+  int i;
+  if (!PyList_Check($input)) {
+    PyErr_SetString(PyExc_ValueError, "Expecting a list");
+    return NULL;
+  }
+  int aSize = PyList_Size($input);
+  $1 = &aSize;
+  char** aStrs = (char **) malloc((aSize+1)*sizeof(char *));
+  for (i = 0; i < aSize; i++) {
+    PyObject *s = PyList_GetItem($input,i);
+    if (!PyString_Check(s)) {
+        free(aStrs);
+        PyErr_SetString(PyExc_ValueError, "List items must be strings");
+        return NULL;
+    }
+    aStrs[i] = PyString_AsString(s);
+  }
+  aStrs[i] = 0;
+  $2 = &aStrs;
+}
+
+%typemap(freearg) (int *argc, char ***argv) {
+   if ($2) free(*($2));
+}
+
+/*  MACRO: IN typemap for std::set<TYPE> C++ object */
+%define TYPEMAP_INPUT_SET_BY_VALUE( TYPE )
+{
+  /* typemap in for set<TYPE> */
+  /* Check if is a list */
+  if (PyList_Check($input))
+  {
+    int size = PyList_Size($input);
+    std::set< TYPE > tmpSet;
+
+    for (int i=0; i < size; i++)
+    {
+      PyObject * tmp = PyList_GetItem($input,i);
+      TYPE elem = PyInt_AsLong(tmp);
+      tmpSet.insert(elem);
+    }
+    $1 = tmpSet;
+  }
+  else
+  {
+    PyErr_SetString(PyExc_TypeError,"not a list");
+    return NULL;
+  }
+}
+%enddef
+
+%typemap(in) std::set<int>
+{ 
+  TYPEMAP_INPUT_SET_BY_VALUE( int ) 
+}
+%typecheck(SWIG_TYPECHECK_POINTER) std::set<int> {
+  $1 = PyList_Check($input) ? 1 : 0;
+}
diff --git a/src/ParaMEDMEM_Swig/libParaMEDMEM_Swig.i b/src/ParaMEDMEM_Swig/libParaMEDMEM_Swig.i
deleted file mode 100644 (file)
index 21ccd0a..0000000
+++ /dev/null
@@ -1,261 +0,0 @@
-//  Copyright (C) 2007-2010  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
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-%module libParaMEDMEM_Swig
-
-%include "libParaMEDMEM_Swig.typemap"
-%include "libMEDCoupling_Swig.i"
-%include "libMEDLoader_Swig.i"
-
-%{
-#include "CommInterface.hxx"
-#include "ProcessorGroup.hxx"
-#include "Topology.hxx"
-#include "MPIProcessorGroup.hxx"
-#include "DEC.hxx"
-#include "InterpKernelDEC.hxx"
-#include "NonCoincidentDEC.hxx"
-#include "StructuredCoincidentDEC.hxx"
-#include "ParaMESH.hxx"
-#include "ParaFIELD.hxx"
-#include "ICoCoMEDField.hxx"
-#include "ComponentTopology.hxx"
-
-#include <mpi.h>
-
-using namespace ParaMEDMEM;
-using namespace ICoCo;
-      
-enum mpi_constants { mpi_comm_world, mpi_comm_self, mpi_double, mpi_int };
-%}
-
-%include "CommInterface.hxx"
-%include "ProcessorGroup.hxx"
-%include "DECOptions.hxx"
-%include "ParaMESH.hxx"
-%include "ParaFIELD.hxx"
-%include "MPIProcessorGroup.hxx"
-%include "ComponentTopology.hxx"
-%include "DEC.hxx"
-%include "InterpKernelDEC.hxx"
-%include "StructuredCoincidentDEC.hxx"
-
-%rename(ICoCoMEDField) ICoCo::MEDField;
-%include "ICoCoMEDField.hxx"
-
-%nodefaultctor;
-
-/* This object can be used only if MED_ENABLE_FVM is defined*/
-#ifdef MED_ENABLE_FVM
-class NonCoincidentDEC : public DEC
-{
-public:
-  NonCoincidentDEC(ProcessorGroup& source, ProcessorGroup& target);
-};
-#endif
-
-%extend ParaMEDMEM::ParaMESH
-{
-  PyObject *getGlobalNumberingCell2() const
-  {
-    const int *tmp=self->getGlobalNumberingCell();
-    int size=self->getCellMesh()->getNumberOfCells();
-    PyObject *ret=PyList_New(size);
-    for(int i=0;i<size;i++)
-      PyList_SetItem(ret,i,PyInt_FromLong(tmp[i])); 
-    return ret;
-  }
-
-  PyObject *getGlobalNumberingFace2() const
-  {
-    const int *tmp=self->getGlobalNumberingFace();
-    int size=self->getFaceMesh()->getNumberOfCells();
-    PyObject *ret=PyList_New(size);
-    for(int i=0;i<size;i++)
-      PyList_SetItem(ret,i,PyInt_FromLong(tmp[i])); 
-    return ret;
-  }
-
-  PyObject *getGlobalNumberingNode2() const
-  {
-    const int *tmp=self->getGlobalNumberingNode();
-    int size=self->getCellMesh()->getNumberOfNodes();
-    PyObject *ret=PyList_New(size);
-    for(int i=0;i<size;i++)
-      PyList_SetItem(ret,i,PyInt_FromLong(tmp[i])); 
-    return ret;
-  }
-}
-
-//=============================================================================================
-// Interface for MPI-realization-specific constants like MPI_COMM_WORLD.
-//
-// Type and values of constants like MPI_COMM_WORLD depends on MPI realization
-// and usually such constants actually are macros. To have such symbols in python
-// and translate them into correct values we use the following technique.
-// We define some constants (enum mpi_constants) and map them into real MPI values
-// using typemaps, and we create needed python symbols equal to 'mpi_constants'
-// via %pythoncode directive.
-
-// Constants corresponding to similar MPI definitions
-enum mpi_constants { mpi_comm_world, mpi_comm_self, mpi_double, mpi_int };
-
-// Map mpi_comm_world and mpi_comm_self -> MPI_COMM_WORLD and MPI_COMM_SELF
-%typemap(in) MPI_Comm
-{ 
-  switch (PyInt_AsLong($input))
-    {
-    case mpi_comm_world: $1 = MPI_COMM_WORLD; break;
-    case mpi_comm_self:  $1 = MPI_COMM_SELF;  break;
-    default:
-      PyErr_SetString(PyExc_TypeError,"unexpected value of MPI_Comm");
-      return NULL;
-    }
-}
-// Map mpi_double and mpi_int -> MPI_DOUBLE and MPI_INT
-%typemap(in) MPI_Datatype
-{ 
-  switch (PyInt_AsLong($input))
-    {
-    case mpi_double:     $1 = MPI_DOUBLE;     break;
-    case mpi_int:        $1 = MPI_INT;        break;
-    default:
-      PyErr_SetString(PyExc_TypeError,"unexpected value of MPI_Datatype");
-      return NULL;
-    }
-}
-// The following code gets inserted into the result python file:
-// create needed python symbols
-%pythoncode %{
-MPI_COMM_WORLD = mpi_comm_world
-MPI_COMM_SELF  = mpi_comm_self
-MPI_DOUBLE     = mpi_double
-MPI_INT        = mpi_int
-%}
-//=============================================================================================
-
-// ==============
-// MPI_Comm_size
-// ==============
-%inline %{ PyObject* MPI_Comm_size(MPI_Comm comm)
-  {
-    int res = 0;
-    int err = MPI_Comm_size(comm, &res);
-    if ( err != MPI_SUCCESS )
-      {
-        PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Comm_size()");
-        return NULL;
-      }
-    return PyInt_FromLong( res );
-  } %}
-
-// ==============
-// MPI_Comm_rank
-// ==============
-%inline %{ PyObject* MPI_Comm_rank(MPI_Comm comm)
-  {
-    int res = 0;
-    int err = MPI_Comm_rank(comm, &res);
-    if ( err != MPI_SUCCESS )
-      {
-        PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Comm_rank()");
-        return NULL;
-      }
-    return PyInt_FromLong( res );
-  } 
-  %}
-
-int MPI_Init(int *argc, char ***argv );
-int MPI_Barrier(MPI_Comm comm);
-int MPI_Finalize();
-
-// ==========
-// MPI_Bcast
-// ==========
-
-%inline %{ PyObject* MPI_Bcast(PyObject* buffer, int nb, MPI_Datatype type, int root, MPI_Comm c)
-  {
-    // buffer must be a list
-    if (!PyList_Check(buffer))
-      {
-        PyErr_SetString(PyExc_TypeError, "buffer is expected to be a list");
-        return NULL;
-      }
-    // check list size
-    int aSize = PyList_Size(buffer);
-    if ( aSize != nb )
-      {
-        std::ostringstream stream; stream << "buffer is expected to be of size " << nb;
-        PyErr_SetString(PyExc_ValueError, stream.str().c_str());
-        return NULL;
-      }
-    // allocate and fill a buffer
-    void* aBuf = 0;
-    int* intBuf = 0;
-    double* dblBuf = 0;
-    if ( type == MPI_DOUBLE )
-      {
-        aBuf = (void*) ( dblBuf = new double[ nb ] );
-        for ( int i = 0; i < aSize; ++i )
-          dblBuf[i] = PyFloat_AS_DOUBLE( PyList_GetItem( buffer, i ));
-      }
-    else if ( type == MPI_INT )
-      {
-        aBuf = (void*) ( intBuf = new int[ nb ] );
-        for ( int i = 0; i < aSize; ++i )
-          intBuf[i] = int( PyInt_AS_LONG( PyList_GetItem( buffer, i )));
-      }
-    else
-      {
-        PyErr_SetString(PyExc_TypeError, "Only MPI_DOUBLE and MPI_INT supported");
-        return NULL;
-      }
-    // call MPI_Bcast
-    int err = MPI_Bcast(aBuf, nb, type, root, c);
-    // treat error
-    if ( err != MPI_SUCCESS )
-      {
-        PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Bcast()");
-        delete [] intBuf; delete [] dblBuf;
-        return NULL;
-      }
-    // put recieved data into the list
-    int pyerr = 0;
-    if ( type == MPI_DOUBLE )
-      {
-        for ( int i = 0; i < aSize && !pyerr; ++i )
-          pyerr = PyList_SetItem(buffer, i, PyFloat_FromDouble( dblBuf[i] ));
-        delete [] dblBuf;
-      }
-    else
-      {
-        for ( int i = 0; i < aSize && !pyerr; ++i )
-          pyerr = PyList_SetItem(buffer, i, PyInt_FromLong( intBuf[i] ));
-        delete [] intBuf;
-      }
-    if ( pyerr )
-      {
-        PyErr_SetString(PyExc_RuntimeError, "Error of PyList_SetItem()");
-        return NULL;
-      }
-    return PyInt_FromLong( err );
-
-  }
-  %}
-
diff --git a/src/ParaMEDMEM_Swig/libParaMEDMEM_Swig.typemap b/src/ParaMEDMEM_Swig/libParaMEDMEM_Swig.typemap
deleted file mode 100644 (file)
index f73253e..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-//  Copyright (C) 2007-2010  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
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-%include std_set.i
-%include std_string.i
-
-%template() std::set<int>;
-
-// Creates "int *argc, char ***argv" parameters from input list
-%typemap(in) (int *argc, char ***argv) {
-  int i;
-  if (!PyList_Check($input)) {
-    PyErr_SetString(PyExc_ValueError, "Expecting a list");
-    return NULL;
-  }
-  int aSize = PyList_Size($input);
-  $1 = &aSize;
-  char** aStrs = (char **) malloc((aSize+1)*sizeof(char *));
-  for (i = 0; i < aSize; i++) {
-    PyObject *s = PyList_GetItem($input,i);
-    if (!PyString_Check(s)) {
-        free(aStrs);
-        PyErr_SetString(PyExc_ValueError, "List items must be strings");
-        return NULL;
-    }
-    aStrs[i] = PyString_AsString(s);
-  }
-  aStrs[i] = 0;
-  $2 = &aStrs;
-}
-
-%typemap(freearg) (int *argc, char ***argv) {
-   if ($2) free(*($2));
-}
-
-/*  MACRO: IN typemap for std::set<TYPE> C++ object */
-%define TYPEMAP_INPUT_SET_BY_VALUE( TYPE )
-{
-  /* typemap in for set<TYPE> */
-  /* Check if is a list */
-  if (PyList_Check($input))
-  {
-    int size = PyList_Size($input);
-    std::set< TYPE > tmpSet;
-
-    for (int i=0; i < size; i++)
-    {
-      PyObject * tmp = PyList_GetItem($input,i);
-      TYPE elem = PyInt_AsLong(tmp);
-      tmpSet.insert(elem);
-    }
-    $1 = tmpSet;
-  }
-  else
-  {
-    PyErr_SetString(PyExc_TypeError,"not a list");
-    return NULL;
-  }
-}
-%enddef
-
-%typemap(in) std::set<int>
-{ 
-  TYPEMAP_INPUT_SET_BY_VALUE( int ) 
-}
-%typecheck(SWIG_TYPECHECK_POINTER) std::set<int> {
-  $1 = PyList_Check($input) ? 1 : 0;
-}
index 2a9a77d29098ca2daa128fcfede1a092c1aaa360..b436a518966e9a75c912514909dd95a5567f11a0 100755 (executable)
@@ -19,7 +19,7 @@
 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-from libParaMEDMEM_Swig import *
+from ParaMEDMEM import *
 import sys, os
 import unittest
 import math
diff --git a/src/ParaMEDMEM_Swig/test_StructuredCoincidentDEC.py b/src/ParaMEDMEM_Swig/test_StructuredCoincidentDEC.py
new file mode 100755 (executable)
index 0000000..a687f06
--- /dev/null
@@ -0,0 +1,128 @@
+#!/usr/bin/env python
+#  -*- coding: iso-8859-1 -*-
+#  Copyright (C) 2007-2010  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
+#  License as published by the Free Software Foundation; either
+#  version 2.1 of the License.
+#
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  Lesser General Public License for more details.
+#
+#  You should have received a copy of the GNU Lesser General Public
+#  License along with this library; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from ParaMEDMEM import *
+import sys, os
+import unittest
+import math
+
+class ParaMEDMEMBasicsTest2(unittest.TestCase):
+    def testStructuredCoincidentDEC(self):
+        MPI_Init(sys.argv)
+        #
+        size = MPI_Comm_size(MPI_COMM_WORLD)
+        rank = MPI_Comm_rank(MPI_COMM_WORLD)
+        #
+        if size < 4:
+            raise RuntimeError, "Expect MPI_COMM_WORLD size >= 4"
+        #
+        interface = CommInterface()
+        #
+        self_group   = MPIProcessorGroup(interface, rank, rank)
+        target_group = MPIProcessorGroup(interface, 3, size-1)
+        source_group = MPIProcessorGroup(interface, 0, 2)
+        #
+        mesh      = 0
+        support   = 0
+        paramesh  = 0
+        parafield = 0
+        comptopo  = 0
+        icocofield= 0
+        #
+        data_dir = os.environ['MED_ROOT_DIR']
+        tmp_dir  = os.environ['TMP']
+        if tmp_dir == '':
+            tmp_dir = "/tmp"
+            pass
+        
+        filename_xml1    = data_dir + "/share/salome/resources/med/square1_split"
+        filename_2       = data_dir + "/share/salome/resources/med/square1.med"
+        filename_seq_wr  = tmp_dir + "/"
+        filename_seq_med = tmp_dir + "/myWrField_seq_pointe221.med"
+        
+        dec = StructuredCoincidentDEC(source_group, target_group)
+        MPI_Barrier(MPI_COMM_WORLD)
+        if source_group.containsMyRank():
+            filename = filename_xml1 + str(rank+1) + ".med"
+            meshname = "Mesh_2_" + str(rank+1)
+            mesh=MEDLoader.ReadUMeshFromFile(filename,meshname,0)
+            paramesh=ParaMESH(mesh,source_group,"source mesh")
+            comptopo=ComponentTopology(6)
+            parafield=ParaFIELD(ON_CELLS,NO_TIME,paramesh,comptopo)
+            parafield.getField().setNature(ConservativeVolumic)
+            nb_local=mesh.getNumberOfCells()
+            global_numbering=paramesh.getGlobalNumberingCell2()
+            value = []
+            for ielem in range(nb_local):
+                for icomp in range(6):
+                    value.append(global_numbering[ielem]*6.0+icomp);
+                    pass
+                pass
+            parafield.getField().setValues(value)
+            icocofield = ICoCoMEDField(mesh,parafield.getField())
+            dec.setMethod("P0")  
+            dec.attachLocalField(parafield)      
+            dec.synchronize()
+            dec.sendData()
+            pass
+
+        if target_group.containsMyRank():
+            meshname2 = "Mesh_2"
+            mesh=MEDLoader.ReadUMeshFromFile(filename_2, meshname2,0)
+            paramesh=ParaMESH(mesh, self_group, "target mesh")
+            comptopo=ComponentTopology(6,target_group)
+            parafield=ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo)
+            parafield.getField().setNature(ConservativeVolumic)
+            nb_local=mesh.getNumberOfCells()
+            value = [0.0]*(nb_local*comptopo.nbLocalComponents())
+            parafield.getField().setValues(value)
+            icocofield = ICoCoMEDField(mesh,parafield.getField())
+            dec.setMethod("P0")
+            dec.attachLocalField(parafield)
+            dec.synchronize()
+            dec.recvData()
+            recv_value = parafield.getField().getArray().getValues()
+            for i in range(nb_local):
+                first=comptopo.firstLocalComponent()
+                for icomp in range(comptopo.nbLocalComponents()):
+                    self.failUnless(math.fabs(recv_value[i*comptopo.nbLocalComponents()+icomp]-
+                                              (float)(i*6+icomp+first))<1e-12)
+                    pass
+                pass
+            pass
+        comptopo=0
+        interface = 0
+        mesh       =0
+        support    =0
+        paramesh   =0
+        parafield  =0
+        icocofield =0
+        dec=0
+        self_group =0
+        target_group = 0
+        source_group = 0
+        MPI_Barrier(MPI_COMM_WORLD)
+        MPI_Finalize()
+        print "End of test StructuredCoincidentDEC"
+        pass
+
+    
+unittest.main()
diff --git a/src/ParaMEDMEM_Swig/test_StructuredCoincodentDEC.py b/src/ParaMEDMEM_Swig/test_StructuredCoincodentDEC.py
deleted file mode 100755 (executable)
index 95a184e..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-#!/usr/bin/env python
-#  -*- coding: iso-8859-1 -*-
-#  Copyright (C) 2007-2010  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
-#  License as published by the Free Software Foundation; either
-#  version 2.1 of the License.
-#
-#  This library is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#  Lesser General Public License for more details.
-#
-#  You should have received a copy of the GNU Lesser General Public
-#  License along with this library; if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-#
-#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-from libParaMEDMEM_Swig import *
-import sys, os
-import unittest
-import math
-
-class ParaMEDMEMBasicsTest2(unittest.TestCase):
-    def testStructuredCoincidentDEC(self):
-        MPI_Init(sys.argv)
-        #
-        size = MPI_Comm_size(MPI_COMM_WORLD)
-        rank = MPI_Comm_rank(MPI_COMM_WORLD)
-        #
-        if size < 4:
-            raise RuntimeError, "Expect MPI_COMM_WORLD size >= 4"
-        #
-        interface = CommInterface()
-        #
-        self_group   = MPIProcessorGroup(interface, rank, rank)
-        target_group = MPIProcessorGroup(interface, 3, size-1)
-        source_group = MPIProcessorGroup(interface, 0, 2)
-        #
-        mesh      = 0
-        support   = 0
-        paramesh  = 0
-        parafield = 0
-        comptopo  = 0
-        icocofield= 0
-        #
-        data_dir = os.environ['MED_ROOT_DIR']
-        tmp_dir  = os.environ['TMP']
-        if tmp_dir == '':
-            tmp_dir = "/tmp"
-            pass
-        
-        filename_xml1    = data_dir + "/share/salome/resources/med/square1_split"
-        filename_2       = data_dir + "/share/salome/resources/med/square1.med"
-        filename_seq_wr  = tmp_dir + "/"
-        filename_seq_med = tmp_dir + "/myWrField_seq_pointe221.med"
-        
-        dec = StructuredCoincidentDEC(source_group, target_group)
-        MPI_Barrier(MPI_COMM_WORLD)
-        if source_group.containsMyRank():
-            filename = filename_xml1 + str(rank+1) + ".med"
-            meshname = "Mesh_2_" + str(rank+1)
-            mesh=MEDLoader.ReadUMeshFromFile(filename,meshname,0)
-            paramesh=ParaMESH(mesh,source_group,"source mesh")
-            comptopo=ComponentTopology(6)
-            parafield=ParaFIELD(ON_CELLS,NO_TIME,paramesh,comptopo)
-            parafield.getField().setNature(ConservativeVolumic)
-            nb_local=mesh.getNumberOfCells()
-            global_numbering=paramesh.getGlobalNumberingCell2()
-            value = []
-            for ielem in range(nb_local):
-                for icomp in range(6):
-                    value.append(global_numbering[ielem]*6.0+icomp);
-                    pass
-                pass
-            parafield.getField().setValues(value)
-            icocofield = ICoCoMEDField(mesh,parafield.getField())
-            dec.setMethod("P0")  
-            dec.attachLocalField(parafield)      
-            dec.synchronize()
-            dec.sendData()
-            pass
-
-        if target_group.containsMyRank():
-            meshname2 = "Mesh_2"
-            mesh=MEDLoader.ReadUMeshFromFile(filename_2, meshname2,0)
-            paramesh=ParaMESH(mesh, self_group, "target mesh")
-            comptopo=ComponentTopology(6,target_group)
-            parafield=ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo)
-            parafield.getField().setNature(ConservativeVolumic)
-            nb_local=mesh.getNumberOfCells()
-            value = [0.0]*(nb_local*comptopo.nbLocalComponents())
-            parafield.getField().setValues(value)
-            icocofield = ICoCoMEDField(mesh,parafield.getField())
-            dec.setMethod("P0")
-            dec.attachLocalField(parafield)
-            dec.synchronize()
-            dec.recvData()
-            recv_value = parafield.getField().getArray().getValues()
-            for i in range(nb_local):
-                first=comptopo.firstLocalComponent()
-                for icomp in range(comptopo.nbLocalComponents()):
-                    self.failUnless(math.fabs(recv_value[i*comptopo.nbLocalComponents()+icomp]-
-                                              (float)(i*6+icomp+first))<1e-12)
-                    pass
-                pass
-            pass
-        comptopo=0
-        interface = 0
-        mesh       =0
-        support    =0
-        paramesh   =0
-        parafield  =0
-        icocofield =0
-        dec=0
-        self_group =0
-        target_group = 0
-        source_group = 0
-        MPI_Barrier(MPI_COMM_WORLD)
-        MPI_Finalize()
-        print "End of test StructuredCoincidentDEC"
-        pass
-
-    
-unittest.main()