Salome HOME
Add structured image grid meshes into MEDCoupling.
authorgeay <anthony.geay@cea.fr>
Mon, 28 Apr 2014 15:46:02 +0000 (17:46 +0200)
committergeay <anthony.geay@cea.fr>
Mon, 28 Apr 2014 15:46:02 +0000 (17:46 +0200)
17 files changed:
src/MEDCoupling/CMakeLists.txt
src/MEDCoupling/MEDCouplingCMesh.cxx
src/MEDCoupling/MEDCouplingCMesh.hxx
src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx
src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx
src/MEDCoupling/MEDCouplingIMesh.cxx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingIMesh.hxx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling/MEDCouplingMemArray.hxx
src/MEDCoupling/MEDCouplingMesh.cxx
src/MEDCoupling/MEDCouplingMesh.hxx
src/MEDCouplingCorba/CMakeLists.txt
src/MEDCouplingCorba/Client/CMakeLists.txt
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py
src/MEDCoupling_Swig/MEDCouplingCommon.i
src/MEDCoupling_Swig/MEDCouplingMemArray.i
src/MEDCoupling_Swig/MEDCouplingTypemaps.i

index bc89616716a13412e7b5089920285cdfd6203f17..6af998f0cc1e28887bee5ebc8cf07b191d0ebeab 100644 (file)
@@ -40,6 +40,7 @@ SET(medcoupling_SOURCES
   MEDCouplingMemArrayChar.cxx
   MEDCouplingTimeLabel.cxx
   MEDCouplingCMesh.cxx
   MEDCouplingMemArrayChar.cxx
   MEDCouplingTimeLabel.cxx
   MEDCouplingCMesh.cxx
+  MEDCouplingIMesh.cxx
   MEDCouplingCurveLinearMesh.cxx
   MEDCouplingStructuredMesh.cxx
   MEDCouplingTimeDiscretization.cxx
   MEDCouplingCurveLinearMesh.cxx
   MEDCouplingStructuredMesh.cxx
   MEDCouplingTimeDiscretization.cxx
index 22851038d77b2d9677d558dc37a6bb39364a5f0f..3eeadc1423d2a5db19d2b1f3f7d2c63ef2eea5a1 100644 (file)
@@ -128,11 +128,11 @@ std::vector<const BigMemoryObject *> MEDCouplingCMesh::getDirectChildren() const
  * @throw if other and this have not same mesh type.
  */
 void MEDCouplingCMesh::copyTinyStringsFrom(const MEDCouplingMesh *other)
  * @throw if other and this have not same mesh type.
  */
 void MEDCouplingCMesh::copyTinyStringsFrom(const MEDCouplingMesh *other)
-{ 
-  const MEDCouplingCMesh *otherC=dynamic_cast<const MEDCouplingCMesh *>(other);
+{
+  MEDCouplingStructuredMesh::copyTinyStringsFrom(other);
+  const MEDCouplingCMesh *otherC(dynamic_cast<const MEDCouplingCMesh *>(other));
   if(!otherC)
     throw INTERP_KERNEL::Exception("MEDCouplingCMesh::copyTinyStringsFrom : meshes have not same type !");
   if(!otherC)
     throw INTERP_KERNEL::Exception("MEDCouplingCMesh::copyTinyStringsFrom : meshes have not same type !");
-  MEDCouplingStructuredMesh::copyTinyStringsFrom(other);
   if(_x_array && otherC->_x_array)
     _x_array->copyStringInfoFrom(*otherC->_x_array);
   if(_y_array && otherC->_y_array)
   if(_x_array && otherC->_x_array)
     _x_array->copyStringInfoFrom(*otherC->_x_array);
   if(_y_array && otherC->_y_array)
@@ -151,7 +151,7 @@ bool MEDCouplingCMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec
       reason="mesh given in input is not castable in MEDCouplingCMesh !";
       return false;
     }
       reason="mesh given in input is not castable in MEDCouplingCMesh !";
       return false;
     }
-  if(!MEDCouplingMesh::isEqualIfNotWhy(other,prec,reason))
+  if(!MEDCouplingStructuredMesh::isEqualIfNotWhy(other,prec,reason))
     return false;
   const DataArrayDouble *thisArr[3]={_x_array,_y_array,_z_array};
   const DataArrayDouble *otherArr[3]={otherC->_x_array,otherC->_y_array,otherC->_z_array};
     return false;
   const DataArrayDouble *thisArr[3]={_x_array,_y_array,_z_array};
   const DataArrayDouble *otherArr[3]={otherC->_x_array,otherC->_y_array,otherC->_z_array};
@@ -202,14 +202,13 @@ void MEDCouplingCMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int ce
 
 /*!
  * Nothing is done here (except to check that the other is a ParaMEDMEM::MEDCouplingCMesh instance too).
 
 /*!
  * Nothing is done here (except to check that the other is a ParaMEDMEM::MEDCouplingCMesh instance too).
- * The user intend that the nodes are the same, so by construction of ParaMEDMEM::MEDCouplingCMesh, 'this' and 'other' are the same !
+ * The user intend that the nodes are the same, so by construction of ParaMEDMEM::MEDCouplingCMesh, \a this and \a other are the same !
  */
 void MEDCouplingCMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
                                                        DataArrayInt *&cellCor) const
 {
  */
 void MEDCouplingCMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
                                                        DataArrayInt *&cellCor) const
 {
-  const MEDCouplingCMesh *otherC=dynamic_cast<const MEDCouplingCMesh *>(other);
-  if(!otherC)
-    throw INTERP_KERNEL::Exception("MEDCouplingCMesh::checkDeepEquivalOnSameNodesWith : other is NOT a cartesian mesh ! Impossible to check equivalence !");
+  if(!isEqualWithoutConsideringStr(other,prec))
+    throw INTERP_KERNEL::Exception("MEDCouplingCMesh::checkDeepEquivalOnSameNodesWith : Meshes are not the same !");
 }
 
 void MEDCouplingCMesh::checkCoherency() const
 }
 
 void MEDCouplingCMesh::checkCoherency() const
@@ -342,10 +341,10 @@ std::vector<int> MEDCouplingCMesh::getNodeGridStructure() const
 MEDCouplingStructuredMesh *MEDCouplingCMesh::buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const
 {
   checkCoherency();
 MEDCouplingStructuredMesh *MEDCouplingCMesh::buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const
 {
   checkCoherency();
-  int dim(getMeshDimension());
+  int dim(getSpaceDimension());
   if(dim!=(int)cellPart.size())
     {
   if(dim!=(int)cellPart.size())
     {
-      std::ostringstream oss; oss << "MEDCouplingCMesh::buildStructuredSubPart : the mesh dimension is " << dim << " and cell part size is " << cellPart.size() << " !";
+      std::ostringstream oss; oss << "MEDCouplingCMesh::buildStructuredSubPart : the space dimension is " << dim << " and cell part size is " << cellPart.size() << " !";
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
   MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> ret(dynamic_cast<MEDCouplingCMesh *>(deepCpy()));
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
   MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> ret(dynamic_cast<MEDCouplingCMesh *>(deepCpy()));
@@ -388,7 +387,7 @@ std::string MEDCouplingCMesh::simpleRepr() const
   double tt=getTime(tmpp1,tmpp2);
   ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n";
   ret << "Iteration : " << tmpp1  << " Order : " << tmpp2 << "\n";
   double tt=getTime(tmpp1,tmpp2);
   ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n";
   ret << "Iteration : " << tmpp1  << " Order : " << tmpp2 << "\n";
-  ret << "Mesh and SpaceDimension dimension : " << getSpaceDimension() << "\n\nArrays :\n________\n\n";
+  ret << "Space dimension : " << getSpaceDimension() << "\n\nArrays :\n________\n\n";
   if(_x_array)
     {
       ret << "X Array :\n";
   if(_x_array)
     {
       ret << "X Array :\n";
@@ -646,7 +645,7 @@ int MEDCouplingCMesh::getCellContainingPoint(const double *pos, double eps) cons
 
 void MEDCouplingCMesh::rotate(const double *center, const double *vector, double angle)
 {
 
 void MEDCouplingCMesh::rotate(const double *center, const double *vector, double angle)
 {
-  throw INTERP_KERNEL::Exception("No rotation available on CMesh : Traduce it to StructuredMesh to apply it !");
+  throw INTERP_KERNEL::Exception("No rotation available on CMesh : Traduce it to untructured mesh to apply it !");
 }
 
 /*!
 }
 
 /*!
index 8011fb8ca8ad2ddbd82ce452a8097d5d7e76f1d6..92909bea39b6b04e87657926a943595b2ee4371d 100644 (file)
@@ -26,9 +26,6 @@
 
 namespace ParaMEDMEM
 {
 
 namespace ParaMEDMEM
 {
-  class DataArrayDouble;
-  class MEDCouplingUMesh;
-
   class MEDCouplingCMesh : public MEDCouplingStructuredMesh
   {
   public:
   class MEDCouplingCMesh : public MEDCouplingStructuredMesh
   {
   public:
index c96ed77f10278c3e7f605c6fdc3c6610fee5718d..6745edac48acd42c6233e43a1d22b90e9cad433e 100644 (file)
@@ -168,14 +168,13 @@ void MEDCouplingCurveLinearMesh::checkDeepEquivalWith(const MEDCouplingMesh *oth
 
 /*!
  * Nothing is done here (except to check that the other is a ParaMEDMEM::MEDCouplingCurveLinearMesh instance too).
 
 /*!
  * Nothing is done here (except to check that the other is a ParaMEDMEM::MEDCouplingCurveLinearMesh instance too).
- * The user intend that the nodes are the same, so by construction of ParaMEDMEM::MEDCouplingCurveLinearMesh, 'this' and 'other' are the same !
+ * The user intend that the nodes are the same, so by construction of ParaMEDMEM::MEDCouplingCurveLinearMesh, \a this and \a other are the same !
  */
 void MEDCouplingCurveLinearMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
                                                                  DataArrayInt *&cellCor) const
 {
  */
 void MEDCouplingCurveLinearMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
                                                                  DataArrayInt *&cellCor) const
 {
-  const MEDCouplingCurveLinearMesh *otherC=dynamic_cast<const MEDCouplingCurveLinearMesh *>(other);
-  if(!otherC)
-    throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkDeepEquivalOnSameNodesWith : other is NOT a cartesian mesh ! Impossible to check equivalence !");
+  if(!isEqualWithoutConsideringStr(other,prec))
+    throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkDeepEquivalOnSameNodesWith : Meshes are not the same !");
 }
 
 void MEDCouplingCurveLinearMesh::checkCoherency() const
 }
 
 void MEDCouplingCurveLinearMesh::checkCoherency() const
@@ -345,11 +344,11 @@ std::vector<int> MEDCouplingCurveLinearMesh::getNodeGridStructure() const
 MEDCouplingStructuredMesh *MEDCouplingCurveLinearMesh::buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const
 {
   checkCoherency();
 MEDCouplingStructuredMesh *MEDCouplingCurveLinearMesh::buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const
 {
   checkCoherency();
-  int dim(getMeshDimension());
+  int dim(getSpaceDimension());
   std::vector<int> dims(getMeshDimension());
   if(dim!=(int)cellPart.size())
     {
   std::vector<int> dims(getMeshDimension());
   if(dim!=(int)cellPart.size())
     {
-      std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::buildStructuredSubPart : the mesh dimension is " << dim << " and cell part size is " << cellPart.size() << " !";
+      std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::buildStructuredSubPart : the space dimension is " << dim << " and cell part size is " << cellPart.size() << " !";
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
   std::vector< std::pair<int,int> > nodePartFormat(cellPart);
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
   std::vector< std::pair<int,int> > nodePartFormat(cellPart);
index 56505d9211bd267aa86a584b0f11dc465ecd1811..98be1d7792aa4cf632d2f2dae5e6b996533a9ecb 100644 (file)
@@ -27,9 +27,6 @@
 
 namespace ParaMEDMEM
 {
 
 namespace ParaMEDMEM
 {
-  class DataArrayDouble;
-  class MEDCouplingUMesh;
-
   class MEDCouplingCurveLinearMesh : public MEDCouplingStructuredMesh
   {
   public:
   class MEDCouplingCurveLinearMesh : public MEDCouplingStructuredMesh
   {
   public:
diff --git a/src/MEDCoupling/MEDCouplingIMesh.cxx b/src/MEDCoupling/MEDCouplingIMesh.cxx
new file mode 100644 (file)
index 0000000..6ef737b
--- /dev/null
@@ -0,0 +1,755 @@
+// Copyright (C) 2007-2014  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, or (at your option) any later version.
+//
+// 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
+//
+// Author : Anthony Geay (CEA/DEN)
+
+#include "MEDCouplingIMesh.hxx"
+#include "MEDCouplingCMesh.hxx"
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+
+#include <functional>
+#include <algorithm>
+#include <sstream>
+#include <numeric>
+
+using namespace ParaMEDMEM;
+
+MEDCouplingIMesh::MEDCouplingIMesh():_space_dim(-1)
+{
+  _origin[0]=0.; _origin[1]=0.; _origin[2]=0.;
+  _dxyz[0]=0.; _dxyz[1]=0.; _dxyz[2]=0.;
+  _structure[0]=0; _structure[1]=0; _structure[2]=0;
+}
+
+MEDCouplingIMesh::MEDCouplingIMesh(const MEDCouplingIMesh& other, bool deepCopy):MEDCouplingStructuredMesh(other,deepCopy),_space_dim(other._space_dim),_axis_unit(other._axis_unit)
+{
+  _origin[0]=other._origin[0]; _origin[1]=other._origin[1]; _origin[2]=other._origin[2];
+  _dxyz[0]=other._dxyz[0]; _dxyz[1]=other._dxyz[1]; _dxyz[2]=other._dxyz[2];
+  _structure[0]=other._structure[0]; _structure[1]=other._structure[1]; _structure[2]=other._structure[2];
+}
+
+MEDCouplingIMesh::~MEDCouplingIMesh()
+{
+}
+
+MEDCouplingIMesh *MEDCouplingIMesh::New()
+{
+  return new MEDCouplingIMesh;
+}
+
+MEDCouplingIMesh *MEDCouplingIMesh::New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
+                                        const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop)
+{
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> ret(new MEDCouplingIMesh);
+  ret->setName(meshName);
+  ret->setSpaceDimension(spaceDim);
+  ret->setNodeStruct(nodeStrctStart,nodeStrctStop);
+  ret->setOrigin(originStart,originStop);
+  ret->setDXYZ(dxyzStart,dxyzStop);
+  return ret.retn();
+}
+
+MEDCouplingMesh *MEDCouplingIMesh::deepCpy() const
+{
+  return clone(true);
+}
+
+MEDCouplingIMesh *MEDCouplingIMesh::clone(bool recDeepCpy) const
+{
+  return new MEDCouplingIMesh(*this,recDeepCpy);
+}
+
+void MEDCouplingIMesh::setNodeStruct(const int *nodeStrctStart, const int *nodeStrctStop)
+{
+  checkSpaceDimension();
+  int sz((int)std::distance(nodeStrctStart,nodeStrctStop));
+  if(sz!=_space_dim)
+    throw INTERP_KERNEL::Exception("MEDCouplingIMesh::setNodeStruct : input vector of node structure has not the right size ! Or change space dimension before calling it !");
+  std::copy(nodeStrctStart,nodeStrctStop,_structure);
+  declareAsNew();
+}
+
+std::vector<int> MEDCouplingIMesh::getNodeStruct() const
+{
+  checkSpaceDimension();
+  return std::vector<int>(_structure,_structure+_space_dim);
+}
+
+void MEDCouplingIMesh::setOrigin(const double *originStart, const double *originStop)
+{
+  checkSpaceDimension();
+  int sz((int)std::distance(originStart,originStop));
+  if(sz!=_space_dim)
+    throw INTERP_KERNEL::Exception("MEDCouplingIMesh::setOrigin : input vector of origin vector has not the right size ! Or change space dimension before calling it !");
+  std::copy(originStart,originStop,_origin);
+  declareAsNew();
+}
+
+std::vector<double> MEDCouplingIMesh::getOrigin() const
+{
+  checkSpaceDimension();
+  return std::vector<double>(_origin,_origin+_space_dim);
+}
+
+void MEDCouplingIMesh::setDXYZ(const double *dxyzStart, const double *dxyzStop)
+{
+  checkSpaceDimension();
+  int sz((int)std::distance(dxyzStart,dxyzStop));
+  if(sz!=_space_dim)
+    throw INTERP_KERNEL::Exception("MEDCouplingIMesh::setDXYZ : input vector of dxyz vector has not the right size ! Or change space dimension before calling it !");
+  std::copy(dxyzStart,dxyzStop,_dxyz);
+  declareAsNew();
+}
+
+std::vector<double> MEDCouplingIMesh::getDXYZ() const
+{
+  checkSpaceDimension();
+  return std::vector<double>(_dxyz,_dxyz+_space_dim);
+}
+
+void MEDCouplingIMesh::setAxisUnit(const std::string& unitName)
+{
+  _axis_unit=unitName;
+  declareAsNew();
+}
+
+std::string MEDCouplingIMesh::getAxisUnit() const
+{
+  return _axis_unit;
+}
+
+/*!
+ * This method returns the measure of any cell in \a this.
+ * This specific method of image grid mesh utilizes the fact that any cell in \a this have the same measure.
+ * The value returned by this method is those used to feed the returned field in the MEDCouplingIMesh::getMeasureField.
+ *
+ * \sa getMeasureField
+ */
+double MEDCouplingIMesh::getMeasureOfAnyCell() const
+{
+  checkCoherency();
+  int dim(getSpaceDimension());
+  double ret(1.);
+  for(int i=0;i<dim;i++)
+    ret*=fabs(_dxyz[i]);
+  return ret;
+}
+
+/*!
+ * This method is allows to convert \a this into MEDCouplingCMesh instance.
+ * This method is the middle level between MEDCouplingIMesh and the most general MEDCouplingUMesh.
+ * This method is useful for MED writers that do not have still the image grid support.
+ *
+ * \sa MEDCouplingMesh::buildUnstructured
+ */
+MEDCouplingCMesh *MEDCouplingIMesh::convertToCartesian() const
+{
+  checkCoherency();
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> ret(MEDCouplingCMesh::New());
+  try
+  { ret->copyTinyInfoFrom(this); }
+  catch(INTERP_KERNEL::Exception& e) { }
+  int spaceDim(getSpaceDimension());
+  std::vector<std::string> infos(buildInfoOnComponents());
+  for(int i=0;i<spaceDim;i++)
+    {
+      MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr(DataArrayDouble::New()); arr->alloc(_structure[i],1); arr->setInfoOnComponent(0,infos[i]);
+      arr->iota(); arr->applyLin(_dxyz[i],_origin[i]);
+      ret->setCoordsAt(i,arr);
+    }
+  return ret.retn();
+}
+
+void MEDCouplingIMesh::setSpaceDimension(int spaceDim)
+{
+  if(spaceDim==_space_dim)
+    return ;
+  CheckSpaceDimension(spaceDim);
+  _space_dim=spaceDim;
+  declareAsNew();
+}
+
+void MEDCouplingIMesh::updateTime() const
+{
+}
+
+std::size_t MEDCouplingIMesh::getHeapMemorySizeWithoutChildren() const
+{
+  return MEDCouplingStructuredMesh::getHeapMemorySizeWithoutChildren();
+}
+
+std::vector<const BigMemoryObject *> MEDCouplingIMesh::getDirectChildren() const
+{
+  return std::vector<const BigMemoryObject *>();
+}
+
+/*!
+ * This method copyies all tiny strings from other (name and components name).
+ * @throw if other and this have not same mesh type.
+ */
+void MEDCouplingIMesh::copyTinyStringsFrom(const MEDCouplingMesh *other)
+{ 
+  const MEDCouplingIMesh *otherC=dynamic_cast<const MEDCouplingIMesh *>(other);
+  if(!otherC)
+    throw INTERP_KERNEL::Exception("MEDCouplingIMesh::copyTinyStringsFrom : meshes have not same type !");
+  MEDCouplingStructuredMesh::copyTinyStringsFrom(other);
+  declareAsNew();
+}
+
+bool MEDCouplingIMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const
+{
+  if(!other)
+    throw INTERP_KERNEL::Exception("MEDCouplingIMesh::isEqualIfNotWhy : input other pointer is null !");
+  const MEDCouplingIMesh *otherC(dynamic_cast<const MEDCouplingIMesh *>(other));
+  if(!otherC)
+    {
+      reason="mesh given in input is not castable in MEDCouplingIMesh !";
+      return false;
+    }
+  if(!MEDCouplingStructuredMesh::isEqualIfNotWhy(other,prec,reason))
+    return false;
+  if(!isEqualWithoutConsideringStrInternal(otherC,prec,reason))
+    return false;
+  if(_axis_unit!=otherC->_axis_unit)
+    {
+      reason="The units of axis are not the same !";
+      return false;
+    }
+  return true;
+}
+
+bool MEDCouplingIMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const
+{
+  const MEDCouplingIMesh *otherC=dynamic_cast<const MEDCouplingIMesh *>(other);
+  if(!otherC)
+    return false;
+  std::string tmp;
+  return isEqualWithoutConsideringStrInternal(other,prec,tmp);
+}
+
+bool MEDCouplingIMesh::isEqualWithoutConsideringStrInternal(const MEDCouplingMesh *other, double prec, std::string& reason) const
+{
+  const MEDCouplingIMesh *otherC=dynamic_cast<const MEDCouplingIMesh *>(other);
+  if(!otherC)
+    return false;
+  if(_space_dim!=otherC->_space_dim)
+    {
+      std::ostringstream oss;
+      oss << "The spaceDimension of this (" << _space_dim << ") is not equal to those of other (" << otherC->_space_dim << ") !";
+      return false;
+    }
+  checkSpaceDimension();
+  for(int i=0;i<_space_dim;i++)
+    {
+      if(fabs(_origin[i]-otherC->_origin[i])>prec)
+        {
+          std::ostringstream oss;
+          oss << "The origin of this and other differs at " << i << " !";
+          reason=oss.str();
+          return false;
+        }
+    }
+  for(int i=0;i<_space_dim;i++)
+    {
+      if(fabs(_dxyz[i]-otherC->_dxyz[i])>prec)
+        {
+          std::ostringstream oss;
+          oss << "The delta of this and other differs at " << i << " !";
+          reason=oss.str();
+          return false;
+        }
+    }
+  for(int i=0;i<_space_dim;i++)
+    {
+      if(_structure[i]!=otherC->_structure[i])
+        {
+          std::ostringstream oss;
+          oss << "The structure of this and other differs at " << i << " !";
+          reason=oss.str();
+          return false;
+        }
+    }
+  return true;
+}
+
+void MEDCouplingIMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
+                                            DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const
+{
+  if(!isEqualWithoutConsideringStr(other,prec))
+    throw INTERP_KERNEL::Exception("MEDCouplingIMesh::checkDeepEquivalWith : Meshes are not the same !");
+}
+
+/*!
+ * Nothing is done here (except to check that the other is a ParaMEDMEM::MEDCouplingIMesh instance too).
+ * The user intend that the nodes are the same, so by construction of ParaMEDMEM::MEDCouplingIMesh, \a this and \a other are the same !
+ */
+void MEDCouplingIMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
+                                                       DataArrayInt *&cellCor) const
+{
+  if(!isEqualWithoutConsideringStr(other,prec))
+    throw INTERP_KERNEL::Exception("MEDCouplingIMesh::checkDeepEquivalOnSameNodesWith : Meshes are not the same !");
+}
+
+void MEDCouplingIMesh::checkCoherency() const
+{
+  checkSpaceDimension();
+  for(int i=0;i<_space_dim;i++)
+    if(_structure[i]<1)
+      {
+        std::ostringstream oss; oss << "MEDCouplingIMesh::checkCoherency : On axis " << i << "/" << _space_dim << ", number of nodes is equal to " << _structure[i] << " ! must be >=1 !";
+        throw INTERP_KERNEL::Exception(oss.str().c_str());
+      }
+}
+
+void MEDCouplingIMesh::checkCoherency1(double eps) const
+{
+  checkCoherency();
+}
+
+void MEDCouplingIMesh::checkCoherency2(double eps) const
+{
+  checkCoherency1(eps);
+}
+
+void MEDCouplingIMesh::getSplitCellValues(int *res) const
+{
+  int meshDim(getMeshDimension());
+  for(int l=0;l<meshDim;l++)
+    {
+      int val=1;
+      for(int p=0;p<meshDim-l-1;p++)
+        val*=_structure[p]-1;
+      res[meshDim-l-1]=val;
+    }
+}
+
+void MEDCouplingIMesh::getSplitNodeValues(int *res) const
+{
+  int spaceDim(getSpaceDimension());
+  for(int l=0;l<spaceDim;l++)
+    {
+      int val=1;
+      for(int p=0;p<spaceDim-l-1;p++)
+        val*=_structure[p];
+      res[spaceDim-l-1]=val;
+    }
+}
+
+void MEDCouplingIMesh::getNodeGridStructure(int *res) const
+{
+  checkSpaceDimension();
+  std::copy(_structure,_structure+_space_dim,res);
+}
+
+std::vector<int> MEDCouplingIMesh::getNodeGridStructure() const
+{
+  checkSpaceDimension();
+  std::vector<int> ret(_structure,_structure+_space_dim);
+  return ret;
+}
+
+MEDCouplingStructuredMesh *MEDCouplingIMesh::buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const
+{
+  checkCoherency();
+  int dim(getSpaceDimension());
+  if(dim!=(int)cellPart.size())
+    {
+      std::ostringstream oss; oss << "MEDCouplingIMesh::buildStructuredSubPart : the space dimension is " << dim << " and cell part size is " << cellPart.size() << " !";
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  double retOrigin[3]={0.,0.,0.};
+  int retStruct[3]={0,0,0};
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> ret(dynamic_cast<MEDCouplingIMesh *>(deepCpy()));
+  for(int i=0;i<dim;i++)
+    {
+      int startNode(cellPart[i].first),endNode(cellPart[i].second+1);
+      int myDelta(endNode-startNode);
+      if(startNode<0 || startNode>=_structure[i])
+        {
+          std::ostringstream oss; oss << "MEDCouplingIMesh::buildStructuredSubPart : At dimension #" << i << " the start node id is " << startNode << " it should be in [0," << _structure[i] << ") !";
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+      if(myDelta<0 || myDelta>_structure[i])
+        {
+          std::ostringstream oss; oss << "MEDCouplingIMesh::buildStructuredSubPart : Along dimension #" << i << " the number of nodes is " << _structure[i] << ", and you are requesting for " << myDelta << " nodes wide range !" << std::endl;
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+      retOrigin[i]=_origin[i]+startNode*_dxyz[i];
+      retStruct[i]=myDelta;
+    }
+  ret->setNodeStruct(retStruct,retStruct+dim);
+  ret->setOrigin(retOrigin,retOrigin+dim);
+  ret->checkCoherency();
+  return ret.retn();
+}
+
+/*!
+ * Return the space dimension of \a this.
+ */
+int MEDCouplingIMesh::getSpaceDimension() const
+{
+  return _space_dim;
+}
+
+void MEDCouplingIMesh::getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const
+{
+  int tmp[3];
+  int spaceDim(getSpaceDimension());
+  getSplitNodeValues(tmp);
+  int tmp2[3];
+  GetPosFromId(nodeId,spaceDim,tmp,tmp2);
+  for(int j=0;j<spaceDim;j++)
+    coo.push_back(_origin[j]+_dxyz[j]*tmp2[j]);
+}
+
+std::string MEDCouplingIMesh::simpleRepr() const
+{
+  std::ostringstream ret;
+  ret << "Image grid with name : \"" << getName() << "\"\n";
+  ret << "Description of mesh : \"" << getDescription() << "\"\n";
+  int tmpp1,tmpp2;
+  double tt(getTime(tmpp1,tmpp2));
+  int spaceDim(_space_dim);
+  ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n";
+  ret << "Iteration : " << tmpp1  << " Order : " << tmpp2 << "\n";
+  ret << "Space dimension : " << spaceDim << "\n";
+  if(spaceDim<0 || spaceDim>3)
+    return ret.str();
+  ret << "The nodal structure is : "; std::copy(_structure,_structure+spaceDim,std::ostream_iterator<int>(ret," ")); ret << "\n";
+  ret << "The origin position is [" << _axis_unit << "]: ";
+  std::copy(_origin,_origin+spaceDim,std::ostream_iterator<double>(ret," ")); ret << "\n";
+  ret << "The intervals along axis are : ";
+  std::copy(_dxyz,_dxyz+spaceDim,std::ostream_iterator<double>(ret," ")); ret << "\n";
+  return ret.str();
+}
+
+std::string MEDCouplingIMesh::advancedRepr() const
+{
+  return simpleRepr();
+}
+
+void MEDCouplingIMesh::getBoundingBox(double *bbox) const
+{
+  checkCoherency();
+  int dim(getSpaceDimension());
+  for(int idim=0; idim<dim; idim++)
+    {
+      bbox[2*idim]=_origin[idim];
+      bbox[2*idim+1]=_origin[idim]+_dxyz[idim]*_structure[idim];
+    }
+}
+
+/*!
+ * Returns a new MEDCouplingFieldDouble containing volumes of cells constituting \a this
+ * mesh.<br>
+ * For 1D cells, the returned field contains lengths.<br>
+ * For 2D cells, the returned field contains areas.<br>
+ * For 3D cells, the returned field contains volumes.
+ *  \param [in] isAbs - a not used parameter.
+ *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble on cells
+ *         and one time . The caller is to delete this field using decrRef() as it is no
+ *         more needed.
+ */
+MEDCouplingFieldDouble *MEDCouplingIMesh::getMeasureField(bool isAbs) const
+{
+  checkCoherency();
+  std::string name="MeasureOfMesh_";
+  name+=getName();
+  int nbelem(getNumberOfCells());
+  MEDCouplingFieldDouble *field(MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME));
+  field->setName(name);
+  DataArrayDouble* array(DataArrayDouble::New());
+  array->alloc(nbelem,1);
+  array->fillWithValue(getMeasureOfAnyCell());
+  field->setArray(array) ;
+  array->decrRef();
+  field->setMesh(const_cast<MEDCouplingIMesh *>(this));
+  field->synchronizeTimeWithMesh();
+  return field;
+}
+
+/*!
+ * not implemented yet !
+ */
+MEDCouplingFieldDouble *MEDCouplingIMesh::getMeasureFieldOnNode(bool isAbs) const
+{
+  throw INTERP_KERNEL::Exception("MEDCouplingIMesh::getMeasureFieldOnNode : not implemented yet !");
+  //return 0;
+}
+
+int MEDCouplingIMesh::getCellContainingPoint(const double *pos, double eps) const
+{
+  int dim(getSpaceDimension()),ret(0),coeff(1);
+  for(int i=0;i<dim;i++)
+    {
+      int nbOfCells(_structure[i]-1);
+      double ref(pos[i]);
+      int tmp((ref-_origin[i])/_dxyz[i]);
+      if(tmp>=0 && tmp<nbOfCells)
+        {
+          ret+=coeff*tmp;
+          coeff*=nbOfCells;
+        }
+      else
+        return -1;
+    }
+  return ret;
+}
+
+void MEDCouplingIMesh::rotate(const double *center, const double *vector, double angle)
+{
+  throw INTERP_KERNEL::Exception("No rotation available on IMesh : Traduce it to unstructured mesh to apply it !");
+}
+
+/*!
+ * Translates all nodes of \a this mesh by a given vector. Actually, it adds each
+ * component of the \a vector to all node coordinates of a corresponding axis.
+ *  \param [in] vector - the translation vector whose size must be not less than \a
+ *         this->getSpaceDimension().
+ */
+void MEDCouplingIMesh::translate(const double *vector)
+{
+  checkSpaceDimension();
+  int dim(getSpaceDimension());
+  std::transform(_origin,_origin+dim,vector,_origin,std::plus<double>());
+  declareAsNew();
+}
+
+/*!
+ * Applies scaling transformation to all nodes of \a this mesh.
+ *  \param [in] point - coordinates of a scaling center. This array is to be of
+ *         size \a this->getSpaceDimension() at least.
+ *  \param [in] factor - a scale factor.
+ */
+void MEDCouplingIMesh::scale(const double *point, double factor)
+{
+  checkSpaceDimension();
+  int dim(getSpaceDimension());
+  std::transform(_origin,_origin+dim,point,_origin,std::minus<double>());
+  std::transform(_origin,_origin+dim,_origin,std::bind2nd(std::multiplies<double>(),factor));
+  std::transform(_dxyz,_dxyz+dim,_dxyz,std::bind2nd(std::multiplies<double>(),factor));
+  std::transform(_origin,_origin+dim,point,_origin,std::plus<double>());
+  declareAsNew();
+}
+
+MEDCouplingMesh *MEDCouplingIMesh::mergeMyselfWith(const MEDCouplingMesh *other) const
+{
+  //not implemented yet !
+  return 0;
+}
+
+/*!
+ * Returns a new DataArrayDouble holding coordinates of all nodes of \a this mesh.
+ *  \return DataArrayDouble * - a new instance of DataArrayDouble, of size \a
+ *          this->getNumberOfNodes() tuples per \a this->getSpaceDimension()
+ *          components. The caller is to delete this array using decrRef() as it is
+ *          no more needed.
+ */
+DataArrayDouble *MEDCouplingIMesh::getCoordinatesAndOwner() const
+{
+  checkCoherency();
+  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(DataArrayDouble::New());
+  int spaceDim(getSpaceDimension()),nbNodes(getNumberOfNodes());
+  ret->alloc(nbNodes,spaceDim);
+  double *pt(ret->getPointer());
+  ret->setInfoOnComponents(buildInfoOnComponents());
+  int tmp2[3],tmp[3];
+  getSplitNodeValues(tmp);
+  for(int i=0;i<nbNodes;i++)
+    {
+      GetPosFromId(i,spaceDim,tmp,tmp2);
+      for(int j=0;j<spaceDim;j++)
+        pt[i*spaceDim+j]=_dxyz[j]*tmp2[j]+_origin[j];
+    }
+  return ret.retn();
+}
+
+/*!
+ * Returns a new DataArrayDouble holding barycenters of all cells. The barycenter is
+ * computed by averaging coordinates of cell nodes.
+ *  \return DataArrayDouble * - a new instance of DataArrayDouble, of size \a
+ *          this->getNumberOfCells() tuples per \a this->getSpaceDimension()
+ *          components. The caller is to delete this array using decrRef() as it is
+ *          no more needed.
+ */
+DataArrayDouble *MEDCouplingIMesh::getBarycenterAndOwner() const
+{
+  checkCoherency();
+  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(DataArrayDouble::New());
+  int spaceDim(getSpaceDimension()),nbCells(getNumberOfCells()),tmp[3],tmp2[3];
+  ret->alloc(nbCells,spaceDim);
+  double *pt(ret->getPointer()),shiftOrigin[3];
+  std::transform(_dxyz,_dxyz+spaceDim,shiftOrigin,std::bind2nd(std::multiplies<double>(),0.5));
+  std::transform(_origin,_origin+spaceDim,shiftOrigin,shiftOrigin,std::plus<double>());
+  getSplitCellValues(tmp);
+  ret->setInfoOnComponents(buildInfoOnComponents());
+  for(int i=0;i<nbCells;i++)
+    {
+      GetPosFromId(i,spaceDim,tmp,tmp2);
+      for(int j=0;j<spaceDim;j++)
+        pt[i*spaceDim+j]=_dxyz[j]*tmp2[j]+shiftOrigin[j];
+    }
+  return ret.retn();
+}
+
+DataArrayDouble *MEDCouplingIMesh::computeIsoBarycenterOfNodesPerCell() const
+{
+  return MEDCouplingIMesh::getBarycenterAndOwner();
+}
+
+void MEDCouplingIMesh::renumberCells(const int *old2NewBg, bool check)
+{
+  throw INTERP_KERNEL::Exception("Functionnality of renumbering cell not available for IMesh !");
+}
+
+void MEDCouplingIMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+{
+  int it,order;
+  double time(getTime(it,order));
+  tinyInfo.clear();
+  tinyInfoD.clear();
+  littleStrings.clear();
+  littleStrings.push_back(getName());
+  littleStrings.push_back(getDescription());
+  littleStrings.push_back(getTimeUnit());
+  littleStrings.push_back(getAxisUnit());
+  tinyInfo.push_back(it);
+  tinyInfo.push_back(order);
+  tinyInfo.push_back(_space_dim);
+  tinyInfo.insert(tinyInfo.end(),_structure,_structure+3);
+  tinyInfoD.push_back(time);
+  tinyInfoD.insert(tinyInfoD.end(),_dxyz,_dxyz+3);
+  tinyInfoD.insert(tinyInfoD.end(),_origin,_origin+3);
+}
+
+void MEDCouplingIMesh::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
+{
+  a1->alloc(0,1);
+  a2->alloc(0,1);
+}
+
+void MEDCouplingIMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const
+{
+  a1=DataArrayInt::New();
+  a1->alloc(0,1);
+  a2=DataArrayDouble::New();
+  a2->alloc(0,1);
+}
+
+void MEDCouplingIMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+                                       const std::vector<std::string>& littleStrings)
+{
+  setName(littleStrings[0]);
+  setDescription(littleStrings[1]);
+  setTimeUnit(littleStrings[2]);
+  setAxisUnit(littleStrings[3]);
+  setTime(tinyInfoD[0],tinyInfo[0],tinyInfo[1]);
+  _space_dim=tinyInfo[2];
+  _structure[0]=tinyInfo[3]; _structure[1]=tinyInfo[4]; _structure[2]=tinyInfo[5];
+  _dxyz[0]=tinyInfoD[1]; _dxyz[1]=tinyInfoD[2]; _dxyz[2]=tinyInfoD[3];
+  _origin[0]=tinyInfoD[4]; _origin[1]=tinyInfoD[5]; _origin[2]=tinyInfoD[6];
+  declareAsNew();
+}
+
+void MEDCouplingIMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const
+{
+  checkCoherency();
+  std::ostringstream extent;
+  for(int i=0;i<3;i++)
+    {
+      if(i<_space_dim)
+        { extent << "0 " <<  _structure[i]-1 << " "; }
+      else
+        { extent << "0 0 "; }
+    }
+  ofs << "  <" << getVTKDataSetType() << " WholeExtent=\"" << extent.str() << "\">\n";
+  ofs << "    <Piece Extent=\"" << extent.str() << "\">\n";
+  ofs << "      <PointData>\n" << pointData << std::endl;
+  ofs << "      </PointData>\n";
+  ofs << "      <CellData>\n" << cellData << std::endl;
+  ofs << "      </CellData>\n";
+  ofs << "      <Coordinates>\n";
+  ofs << "      </Coordinates>\n";
+  ofs << "    </Piece>\n";
+  ofs << "  </" << getVTKDataSetType() << ">\n";
+}
+
+void MEDCouplingIMesh::reprQuickOverview(std::ostream& stream) const
+{
+  stream << "MEDCouplingIMesh C++ instance at " << this << ". Name : \"" << getName() << "\". Space dimension : " << _space_dim << ".";
+  if(_space_dim<0 || _space_dim>3)
+    return ;
+  stream << "\n";
+  std::ostringstream stream0,stream1;
+  int nbNodes(1),nbCells(0);
+  bool isPb(false);
+  for(int i=0;i<_space_dim;i++)
+    {
+      char tmp('X'+i);
+      int tmpNodes(_structure[i]);
+      stream1 << "- Axis " << tmp << " : " << tmpNodes << " nodes (orig=" << _origin[i] << ", inter=" << _dxyz[i] << ").";
+      if(i!=_space_dim-1)
+        stream1 << std::endl;
+      if(tmpNodes>=1)
+        nbNodes*=tmpNodes;
+      else
+        isPb=true;
+      if(tmpNodes>=2)
+        nbCells=nbCells==0?tmpNodes-1:nbCells*(tmpNodes-1);
+    }
+  if(!isPb)
+    {
+      stream0 << "Number of cells : " << nbCells << ", Number of nodes : " << nbNodes;
+      stream << stream0.str();
+      if(_space_dim>0)
+        stream << std::endl;
+    }
+  stream << stream1.str();
+}
+
+std::string MEDCouplingIMesh::getVTKDataSetType() const
+{
+  return std::string("ImageData");
+}
+
+std::vector<std::string> MEDCouplingIMesh::buildInfoOnComponents() const
+{
+  checkSpaceDimension();
+  int dim(getSpaceDimension());
+  std::vector<std::string> ret(dim);
+  for(int i=0;i<dim;i++)
+    {
+      std::ostringstream oss;
+      char tmp('X'+i); oss << tmp;
+      ret[i]=DataArray::BuildInfoFromVarAndUnit(oss.str(),_axis_unit);
+    }
+  return ret;
+}
+
+void MEDCouplingIMesh::checkSpaceDimension() const
+{
+  CheckSpaceDimension(_space_dim);
+}
+
+void MEDCouplingIMesh::CheckSpaceDimension(int spaceDim)
+{
+  if(spaceDim<0 || spaceDim>3)
+    throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CheckSpaceDimension : input spaceDim must be in [0,1,2,3] !");
+}
+
diff --git a/src/MEDCoupling/MEDCouplingIMesh.hxx b/src/MEDCoupling/MEDCouplingIMesh.hxx
new file mode 100644 (file)
index 0000000..ecd6790
--- /dev/null
@@ -0,0 +1,115 @@
+// Copyright (C) 2007-2014  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, or (at your option) any later version.
+//
+// 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
+//
+// Author : Anthony Geay (CEA/DEN)
+
+#ifndef __PARAMEDMEM_MEDCOUPLINGIMESH_HXX__
+#define __PARAMEDMEM_MEDCOUPLINGIMESH_HXX__
+
+#include "MEDCoupling.hxx"
+#include "MEDCouplingStructuredMesh.hxx"
+
+namespace ParaMEDMEM
+{
+  class MEDCouplingCMesh;
+
+  class MEDCouplingIMesh : public MEDCouplingStructuredMesh
+  {
+  public:
+    MEDCOUPLING_EXPORT static MEDCouplingIMesh *New();
+    MEDCOUPLING_EXPORT static MEDCouplingIMesh *New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
+                                                    const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
+    //
+    MEDCOUPLING_EXPORT void setSpaceDimension(int spaceDim);
+    MEDCOUPLING_EXPORT void setNodeStruct(const int *nodeStrctStart, const int *nodeStrctStop);
+    MEDCOUPLING_EXPORT std::vector<int> getNodeStruct() const;
+    MEDCOUPLING_EXPORT void setOrigin(const double *originStart, const double *originStop);
+    MEDCOUPLING_EXPORT std::vector<double> getOrigin() const;
+    MEDCOUPLING_EXPORT void setDXYZ(const double *dxyzStart, const double *dxyzStop);
+    MEDCOUPLING_EXPORT std::vector<double> getDXYZ() const;
+    MEDCOUPLING_EXPORT void setAxisUnit(const std::string& unitName);
+    MEDCOUPLING_EXPORT std::string getAxisUnit() const;
+    MEDCOUPLING_EXPORT double getMeasureOfAnyCell() const;
+    MEDCOUPLING_EXPORT MEDCouplingCMesh *convertToCartesian() const;
+    //
+    MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
+    MEDCOUPLING_EXPORT MEDCouplingIMesh *clone(bool recDeepCpy) const;
+    MEDCOUPLING_EXPORT void updateTime() const;
+    MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+    MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
+    MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return IMAGE_GRID; }
+    MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other);
+    MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const;
+    MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
+    MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
+                                                 DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const;
+    MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
+                                                            DataArrayInt *&cellCor) const;
+    MEDCOUPLING_EXPORT void checkCoherency() const;
+    MEDCOUPLING_EXPORT void checkCoherency1(double eps=1e-12) const;
+    MEDCOUPLING_EXPORT void checkCoherency2(double eps=1e-12) const;
+    MEDCOUPLING_EXPORT int getSpaceDimension() const;
+    MEDCOUPLING_EXPORT void getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const;
+    MEDCOUPLING_EXPORT std::string simpleRepr() const;
+    MEDCOUPLING_EXPORT std::string advancedRepr() const;
+    // tools
+    MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const;
+    MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
+    MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const;
+    MEDCOUPLING_EXPORT int getCellContainingPoint(const double *pos, double eps) const;
+    MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle);
+    MEDCOUPLING_EXPORT void translate(const double *vector);
+    MEDCOUPLING_EXPORT void scale(const double *point, double factor);
+    MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
+    MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const;
+    MEDCOUPLING_EXPORT DataArrayDouble *getBarycenterAndOwner() const;
+    MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const;
+    MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true);
+    //some useful methods
+    MEDCOUPLING_EXPORT void getSplitCellValues(int *res) const;
+    MEDCOUPLING_EXPORT void getSplitNodeValues(int *res) const;
+    MEDCOUPLING_EXPORT void getNodeGridStructure(int *res) const;
+    MEDCOUPLING_EXPORT std::vector<int> getNodeGridStructure() const;
+    MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const;
+    //serialisation-unserialization
+    MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
+    MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
+    MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
+    MEDCOUPLING_EXPORT void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+                                            const std::vector<std::string>& littleStrings);
+    MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
+  private:
+    MEDCouplingIMesh();
+    MEDCouplingIMesh(const MEDCouplingIMesh& other, bool deepCpy);
+    ~MEDCouplingIMesh();
+    void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const;
+    std::string getVTKDataSetType() const;
+    bool isEqualWithoutConsideringStrInternal(const MEDCouplingMesh *other, double prec, std::string& reason) const;
+    std::vector<std::string> buildInfoOnComponents() const;
+    void checkSpaceDimension() const;
+    static void CheckSpaceDimension(int spaceDim);
+  private:
+    int _space_dim;
+    double _origin[3];
+    double _dxyz[3];
+    int _structure[3];
+    std::string _axis_unit;
+  };
+}
+
+#endif
index e37a72b8c829278f59e3fc1b7b89fcfe186f8f37..6845713ebf5948c09c08597951ee923697323837 100644 (file)
@@ -422,6 +422,18 @@ std::string DataArray::GetUnitFromInfo(const std::string& info)
   return info.substr(p1+1,p2-p1-1);
 }
 
   return info.substr(p1+1,p2-p1-1);
 }
 
+/*!
+ * This method put in info format the result of the merge of \a var and \a unit.
+ * The standard format for that is "var [unit]".
+ * Inversely you can retrieve the var part or the unit part of info string using resp. GetVarNameFromInfo and GetUnitFromInfo.
+ */
+std::string DataArray::BuildInfoFromVarAndUnit(const std::string& var, const std::string& unit)
+{
+  std::ostringstream oss;
+  oss << var << " [" << unit << "]";
+  return oss.str();
+}
+
 /*!
  * Returns a new DataArray by concatenating all given arrays, so that (1) the number
  * of tuples in the result array is a sum of the number of tuples of given arrays and (2)
 /*!
  * Returns a new DataArray by concatenating all given arrays, so that (1) the number
  * of tuples in the result array is a sum of the number of tuples of given arrays and (2)
index 48a1ea3d394533371f6841df5e640b1ee2bc6fa6..d77572698b98b294d1b612c7cae0ca4a444d0f34 100644 (file)
@@ -167,6 +167,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step);
     MEDCOUPLING_EXPORT static std::string GetVarNameFromInfo(const std::string& info);
     MEDCOUPLING_EXPORT static std::string GetUnitFromInfo(const std::string& info);
     MEDCOUPLING_EXPORT static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step);
     MEDCOUPLING_EXPORT static std::string GetVarNameFromInfo(const std::string& info);
     MEDCOUPLING_EXPORT static std::string GetUnitFromInfo(const std::string& info);
+    MEDCOUPLING_EXPORT static std::string BuildInfoFromVarAndUnit(const std::string& var, const std::string& unit);
     MEDCOUPLING_EXPORT static DataArray *Aggregate(const std::vector<const DataArray *>& arrs);
     MEDCOUPLING_EXPORT virtual void reprStream(std::ostream& stream) const = 0;
     MEDCOUPLING_EXPORT virtual void reprZipStream(std::ostream& stream) const = 0;
     MEDCOUPLING_EXPORT static DataArray *Aggregate(const std::vector<const DataArray *>& arrs);
     MEDCOUPLING_EXPORT virtual void reprStream(std::ostream& stream) const = 0;
     MEDCOUPLING_EXPORT virtual void reprZipStream(std::ostream& stream) const = 0;
index aefddd462facedd7ad188162ba59fa53ddb2bbec..241e05120a5c3fa1e648a504cd4962df91be3434 100644 (file)
@@ -329,10 +329,10 @@ void MEDCouplingMesh::copyTinyStringsFrom(const MEDCouplingMesh *other)
  */
 void MEDCouplingMesh::copyTinyInfoFrom(const MEDCouplingMesh *other)
 {
  */
 void MEDCouplingMesh::copyTinyInfoFrom(const MEDCouplingMesh *other)
 {
-  copyTinyStringsFrom(other);
   _time=other->_time;
   _iteration=other->_iteration;
   _order=other->_order;
   _time=other->_time;
   _iteration=other->_iteration;
   _order=other->_order;
+  copyTinyStringsFrom(other);
 }
 
 /*!
 }
 
 /*!
index ad1102c0d15477892e28ca910044ba21062805f5..8eae2e543a43423353a8f5bf16e5027128c17eb7 100644 (file)
@@ -41,7 +41,8 @@ namespace ParaMEDMEM
       EXTRUDED = 8,
       CURVE_LINEAR = 9,
       SINGLE_STATIC_GEO_TYPE_UNSTRUCTURED = 10,
       EXTRUDED = 8,
       CURVE_LINEAR = 9,
       SINGLE_STATIC_GEO_TYPE_UNSTRUCTURED = 10,
-      SINGLE_DYNAMIC_GEO_TYPE_UNSTRUCTURED = 11
+      SINGLE_DYNAMIC_GEO_TYPE_UNSTRUCTURED = 11,
+      IMAGE_GRID = 12
     } MEDCouplingMeshType;
   // -- WARNING this enum must be synchronized with MEDCouplingCommon.i file ! --
 
     } MEDCouplingMeshType;
   // -- WARNING this enum must be synchronized with MEDCouplingCommon.i file ! --
 
index 7e1ee213d31318947c924a33f37fd29cb90cef73..a05d4511bfa9c126ee37e9c87909d54fbe7649df 100644 (file)
@@ -45,6 +45,7 @@ SET(medcouplingcorba_SOURCES
   MEDCoupling1SGTUMeshServant.cxx
   MEDCoupling1GTUMeshServant.cxx
   MEDCouplingCMeshServant.cxx
   MEDCoupling1SGTUMeshServant.cxx
   MEDCoupling1GTUMeshServant.cxx
   MEDCouplingCMeshServant.cxx
+  MEDCouplingIMeshServant.cxx
   MEDCouplingUMeshServant.cxx
   MEDCouplingFieldServant.cxx
   MEDCouplingFieldDoubleServant.cxx
   MEDCouplingUMeshServant.cxx
   MEDCouplingFieldServant.cxx
   MEDCouplingFieldDoubleServant.cxx
index ffdc3f4e8b6d26c476ee7ecd88820f87328e705e..356213dcb3f13618e05230beb98ce1893d2787c5 100644 (file)
@@ -30,6 +30,7 @@ SET(medcouplingclient_SOURCES
   DataArrayDoubleClient.cxx
   DataArrayIntClient.cxx
   MEDCouplingCMeshClient.cxx
   DataArrayDoubleClient.cxx
   DataArrayIntClient.cxx
   MEDCouplingCMeshClient.cxx
+  MEDCouplingIMeshClient.cxx
   MEDCoupling1SGTUMeshClient.cxx
   MEDCoupling1DGTUMeshClient.cxx
   MEDCouplingCurveLinearMeshClient.cxx
   MEDCoupling1SGTUMeshClient.cxx
   MEDCoupling1DGTUMeshClient.cxx
   MEDCouplingCurveLinearMeshClient.cxx
index d21ab4ffdcd45b93afd60c0635489f984d3056d1..fbc3370fec890ca0eb6e7c0419f21db45a1a8912 100644 (file)
@@ -14789,6 +14789,139 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         j,k,l=r
         assert(inp.isEqual(DataArrayInt([a,b,c,d,e,f,g,h,i,j,k,l],4,3)))
         pass
         j,k,l=r
         assert(inp.isEqual(DataArrayInt([a,b,c,d,e,f,g,h,i,j,k,l],4,3)))
         pass
+
+    def testSwig2IMesh1(self):
+        """ 1st test of image grid mesh.
+        """
+        m=MEDCouplingIMesh()
+        self.assertEqual(m.getSpaceDimension(),-1)
+        self.assertEqual(1,len(m.__repr__().split("\n")))
+        self.assertEqual(6,len(m.__str__().split("\n")))
+        self.assertRaises(InterpKernelException,m.getNodeStruct)
+        self.assertRaises(InterpKernelException,m.getOrigin)
+        self.assertRaises(InterpKernelException,m.getDXYZ)
+        m.setSpaceDimension(3)
+        self.assertEqual(9,len(m.__str__().split("\n")))
+        self.assertEqual(4,len(m.__repr__().split("\n")))
+        self.assertEqual((0,0,0),m.getNodeStruct())
+        self.assertEqual((0.,0.,0.),m.getOrigin())
+        self.assertEqual((0.,0.,0.),m.getDXYZ())
+        self.assertRaises(InterpKernelException,m.setNodeStruct,[3,4])
+        m.setNodeStruct([3,4,2])
+        self.assertEqual((3,4,2),m.getNodeStruct())
+        m.setOrigin(DataArrayDouble([1.5,2.5,3.5]))
+        self.assertEqual((1.5,2.5,3.5),m.getOrigin())
+        m.setDXYZ((0.5,1.,0.25))
+        self.assertEqual((0.5,1.,0.25),m.getDXYZ())
+        for it in DataArrayDouble([(1.5,2.5,3.5)]):
+            m2=MEDCouplingIMesh("",3,DataArrayInt([3,4,2]),it,DataArrayDouble((0.5,1.,0.25)))
+            pass
+        self.assertEqual(3,m.getSpaceDimension())
+        self.assertEqual((3,4,2),m2.getNodeStruct())
+        self.assertEqual((1.5,2.5,3.5),m2.getOrigin())
+        self.assertEqual((0.5,1.,0.25),m2.getDXYZ())
+        self.assertEqual(24,m2.getNumberOfNodes())
+        self.assertEqual(6,m2.getNumberOfCells())
+        self.assertTrue(m.isEqual(m2,1e-12)) ; self.assertTrue(m.isEqualWithoutConsideringStr(m2,1e-12))
+        m2.setAxisUnit("m")
+        self.assertTrue(not m.isEqual(m2,1e-12)) ; self.assertTrue(m.isEqualWithoutConsideringStr(m2,1e-12))
+        m.setAxisUnit("m")
+        self.assertTrue(m.isEqual(m2,1e-12)) ; self.assertTrue(m.isEqualWithoutConsideringStr(m2,1e-12))
+        m.setName("mesh")
+        self.assertTrue(not m.isEqual(m2,1e-12)) ; self.assertTrue(m.isEqualWithoutConsideringStr(m2,1e-12))
+        m2.setName("mesh")
+        self.assertTrue(m.isEqual(m2,1e-12)) ; self.assertTrue(m.isEqualWithoutConsideringStr(m2,1e-12))
+        m2.setTime(1.1,0,3)
+        self.assertTrue(not m.isEqual(m2,1e-12))
+        m.setTime(1.1,0,3)
+        self.assertTrue(m.isEqual(m2,1e-12))
+        m.setTimeUnit("ms")
+        self.assertTrue(not m.isEqual(m2,1e-12)) ; self.assertTrue(m.isEqualWithoutConsideringStr(m2,1e-12))
+        m2.setTimeUnit("ms")
+        self.assertTrue(m.isEqual(m2,1e-12)) ; self.assertTrue(m.isEqualWithoutConsideringStr(m2,1e-12))
+        #
+        m2.setNodeStruct([3,2,4])
+        self.assertTrue(not m.isEqual(m2,1e-12))
+        m.setNodeStruct([3,2,4])
+        self.assertTrue(m.isEqual(m2,1e-12))
+        m.setOrigin(DataArrayDouble([1.5,3.5,2.5]))
+        self.assertTrue(not m.isEqual(m2,1e-12))
+        m2.setOrigin([1.5,3.5,2.5])
+        self.assertTrue(m.isEqual(m2,1e-12))
+        m.setDXYZ((0.5,0.25,1.))
+        self.assertTrue(not m.isEqual(m2,1e-12))
+        m2.setDXYZ(DataArrayDouble((0.5,0.25,1.)))
+        self.assertTrue(m.isEqual(m2,1e-12))
+        m2bis=m2.deepCpy()
+        self.assertTrue(m2bis.isEqual(m2,1e-12))
+        #
+        self.assertEqual(3,m.getMeshDimension())
+        self.assertAlmostEqual(0.125,m.getMeasureOfAnyCell(),16);
+        mu=MEDCoupling1SGTUMesh(m.buildUnstructured())
+        mu.checkCoherency2()
+        cooExp=DataArrayDouble([(1.5,3.5,2.5),(2,3.5,2.5),(2.5,3.5,2.5),(1.5,3.75,2.5),(2,3.75,2.5),(2.5,3.75,2.5),(1.5,3.5,3.5),(2,3.5,3.5),(2.5,3.5,3.5),(1.5,3.75,3.5),(2,3.75,3.5),(2.5,3.75,3.5),(1.5,3.5,4.5),(2,3.5,4.5),(2.5,3.5,4.5),(1.5,3.75,4.5),(2,3.75,4.5),(2.5,3.75,4.5),(1.5,3.5,5.5),(2,3.5,5.5),(2.5,3.5,5.5),(1.5,3.75,5.5),(2,3.75,5.5),(2.5,3.75,5.5)]) ; cooExp.setInfoOnComponents(["X [m]","Y [m]","Z [m]"])
+        self.assertTrue(isinstance(mu,MEDCoupling1SGTUMesh))
+        self.assertEqual(NORM_HEXA8,mu.getCellModelEnum())
+        self.assertTrue(mu.getCoords().isEqual(cooExp,1e-12))
+        self.assertTrue(mu.getNodalConnectivity().isEqual(DataArrayInt([1,0,3,4,7,6,9,10,2,1,4,5,8,7,10,11,7,6,9,10,13,12,15,16,8,7,10,11,14,13,16,17,13,12,15,16,19,18,21,22,14,13,16,17,20,19,22,23])))
+        bary=m.getBarycenterAndOwner()
+        baryExp=DataArrayDouble([(1.75,3.625,3),(2.25,3.625,3),(1.75,3.625,4),(2.25,3.625,4),(1.75,3.625,5),(2.25,3.625,5)]) ; baryExp.setInfoOnComponents(["X [m]","Y [m]","Z [m]"])
+        self.assertTrue(bary.isEqual(baryExp,1e-12))
+        #
+        c=m.convertToCartesian()
+        c.checkCoherency()
+        self.assertEqual([1.1,0,3],c.getTime())
+        self.assertEqual("ms",c.getTimeUnit())
+        self.assertEqual(3,c.getMeshDimension())
+        self.assertEqual(3,c.getSpaceDimension())
+        arrX=DataArrayDouble([1.5,2.,2.5]) ; arrX.setInfoOnComponents(["X [m]"])
+        self.assertTrue(c.getCoordsAt(0).isEqual(arrX,1e-12))
+        arrY=DataArrayDouble([3.5,3.75]) ; arrY.setInfoOnComponents(["Y [m]"])
+        self.assertTrue(c.getCoordsAt(1).isEqual(arrY,1e-12))
+        arrZ=DataArrayDouble([2.5,3.5,4.5,5.5]) ; arrZ.setInfoOnComponents(["Z [m]"])
+        self.assertTrue(c.getCoordsAt(2).isEqual(arrZ,1e-12))
+        self.assertTrue(c.buildUnstructured().isEqual(m.buildUnstructured(),1e-12))
+        #
+        a,b=m.getCellsContainingPoints(baryExp,1e-12)
+        self.assertTrue(a.isEqual(DataArrayInt([0,1,2,3,4,5])))
+        self.assertTrue(b.isEqual(DataArrayInt([0,1,2,3,4,5,6])))
+        for a,b in enumerate(baryExp):
+            self.assertEqual(a,m.getCellContainingPoint(b,1e-12))
+            pass
+        #
+        m.translate([1.,2.,4.])
+        self.assertEqual((3,2,4),m.getNodeStruct())
+        self.assertEqual((2.5,5.5,6.5),m.getOrigin())
+        self.assertEqual((0.5,0.25,1.),m.getDXYZ())
+        m.scale([0.,1.,3.],2.)
+        self.assertAlmostEqual(1.,m.getMeasureOfAnyCell(),16);
+        self.assertEqual((3,2,4),m.getNodeStruct())
+        self.assertEqual((5.,10.,10.),m.getOrigin())
+        self.assertEqual((1.,0.5,2.),m.getDXYZ())
+        #
+        f=m.getMeasureField(False)
+        f2=MEDCouplingFieldDouble(ON_CELLS) ; f2.setTime(1.1,0,3) ; f2.setMesh(m) ; arr=DataArrayDouble(6) ; arr[:]=1. ; f2.setArray(arr) ; f2.setTimeUnit("ms")
+        f2.setName("MeasureOfMesh_mesh")
+        self.assertTrue(f.isEqual(f2,1e-12,1e-12))
+        #
+        m3=m.buildStructuredSubPart([(1,2),(0,1),(1,3)])
+        self.assertEqual((2,2,3),m3.getNodeStruct())
+        self.assertEqual((6.,10.,12.),m3.getOrigin())
+        self.assertEqual((1.,0.5,2.),m3.getDXYZ())
+        # now playing with 3D surf
+        m4=MEDCouplingIMesh("",3,DataArrayInt([3,1,4]),DataArrayDouble([1.5,2.5,3.5]),DataArrayDouble((0.5,1.,0.25))) ; m4.setAxisUnit("km")
+        self.assertEqual(3,m4.getSpaceDimension())
+        self.assertEqual(2,m4.getMeshDimension())
+        self.assertEqual(12,m4.getNumberOfNodes())
+        self.assertEqual(6,m4.getNumberOfCells())
+        mu=MEDCoupling1SGTUMesh(m4.buildUnstructured())
+        mu.checkCoherency2()
+        self.assertTrue(isinstance(mu,MEDCoupling1SGTUMesh))
+        self.assertEqual(NORM_QUAD4,mu.getCellModelEnum())
+        coordsExp=DataArrayDouble([(1.5,2.5,3.5),(2,2.5,3.5),(2.5,2.5,3.5),(1.5,2.5,3.75),(2,2.5,3.75),(2.5,2.5,3.75),(1.5,2.5,4),(2,2.5,4),(2.5,2.5,4),(1.5,2.5,4.25),(2,2.5,4.25),(2.5,2.5,4.25)]) ; coordsExp.setInfoOnComponents(["X [km]","Y [km]","Z [km]"])
+        self.assertTrue(mu.getCoords().isEqual(coordsExp,1e-12))
+        self.assertTrue(mu.getNodalConnectivity().isEqual(DataArrayInt([1,0,3,4,2,1,4,5,4,3,6,7,5,4,7,8,7,6,9,10,8,7,10,11])))
+        pass
     
     def setUp(self):
         pass
     
     def setUp(self):
         pass
index 62158e784f3fb24866d7c06aa3f018865e3beba2..3efdfc62fb8839024bbb315b68658f6aec0fcfba 100644 (file)
@@ -28,6 +28,7 @@
 #include "MEDCouplingUMesh.hxx"
 #include "MEDCouplingExtrudedMesh.hxx"
 #include "MEDCouplingCMesh.hxx"
 #include "MEDCouplingUMesh.hxx"
 #include "MEDCouplingExtrudedMesh.hxx"
 #include "MEDCouplingCMesh.hxx"
+#include "MEDCouplingIMesh.hxx"
 #include "MEDCouplingCurveLinearMesh.hxx"
 #include "MEDCoupling1GTUMesh.hxx"
 #include "MEDCouplingField.hxx"
 #include "MEDCouplingCurveLinearMesh.hxx"
 #include "MEDCoupling1GTUMesh.hxx"
 #include "MEDCouplingField.hxx"
@@ -301,6 +302,8 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::MEDCouplingCMesh::New;
 %newobject ParaMEDMEM::MEDCouplingCMesh::clone;
 %newobject ParaMEDMEM::MEDCouplingCMesh::getCoordsAt;
 %newobject ParaMEDMEM::MEDCouplingCMesh::New;
 %newobject ParaMEDMEM::MEDCouplingCMesh::clone;
 %newobject ParaMEDMEM::MEDCouplingCMesh::getCoordsAt;
+%newobject ParaMEDMEM::MEDCouplingIMesh::New;
+%newobject ParaMEDMEM::MEDCouplingIMesh::convertToCartesian;
 %newobject ParaMEDMEM::MEDCouplingCurveLinearMesh::New;
 %newobject ParaMEDMEM::MEDCouplingCurveLinearMesh::clone;
 %newobject ParaMEDMEM::MEDCouplingCurveLinearMesh::getCoords;
 %newobject ParaMEDMEM::MEDCouplingCurveLinearMesh::New;
 %newobject ParaMEDMEM::MEDCouplingCurveLinearMesh::clone;
 %newobject ParaMEDMEM::MEDCouplingCurveLinearMesh::getCoords;
@@ -2856,19 +2859,19 @@ namespace ParaMEDMEM
   class MEDCouplingCMesh : public ParaMEDMEM::MEDCouplingStructuredMesh
   {
   public:
   class MEDCouplingCMesh : public ParaMEDMEM::MEDCouplingStructuredMesh
   {
   public:
-    static MEDCouplingCMesh *New();
-    static MEDCouplingCMesh *New(const std::string& meshName);
+    static MEDCouplingCMesh *New() throw(INTERP_KERNEL::Exception);
+    static MEDCouplingCMesh *New(const std::string& meshName) throw(INTERP_KERNEL::Exception);
     MEDCouplingCMesh *clone(bool recDeepCpy) const;
     void setCoords(const DataArrayDouble *coordsX,
                    const DataArrayDouble *coordsY=0,
                    const DataArrayDouble *coordsZ=0) throw(INTERP_KERNEL::Exception);
     void setCoordsAt(int i, const DataArrayDouble *arr) throw(INTERP_KERNEL::Exception);
     %extend {
     MEDCouplingCMesh *clone(bool recDeepCpy) const;
     void setCoords(const DataArrayDouble *coordsX,
                    const DataArrayDouble *coordsY=0,
                    const DataArrayDouble *coordsZ=0) throw(INTERP_KERNEL::Exception);
     void setCoordsAt(int i, const DataArrayDouble *arr) throw(INTERP_KERNEL::Exception);
     %extend {
-      MEDCouplingCMesh()
+      MEDCouplingCMesh() throw(INTERP_KERNEL::Exception)
       {
         return MEDCouplingCMesh::New();
       }
       {
         return MEDCouplingCMesh::New();
       }
-      MEDCouplingCMesh(const std::string& meshName)
+      MEDCouplingCMesh(const std::string& meshName) throw(INTERP_KERNEL::Exception)
       {
         return MEDCouplingCMesh::New(meshName);
       }
       {
         return MEDCouplingCMesh::New(meshName);
       }
@@ -2899,16 +2902,16 @@ namespace ParaMEDMEM
   class MEDCouplingCurveLinearMesh : public ParaMEDMEM::MEDCouplingStructuredMesh
   {
   public:
   class MEDCouplingCurveLinearMesh : public ParaMEDMEM::MEDCouplingStructuredMesh
   {
   public:
-    static MEDCouplingCurveLinearMesh *New();
-    static MEDCouplingCurveLinearMesh *New(const std::string& meshName);
+    static MEDCouplingCurveLinearMesh *New() throw(INTERP_KERNEL::Exception);
+    static MEDCouplingCurveLinearMesh *New(const std::string& meshName) throw(INTERP_KERNEL::Exception);
     MEDCouplingCurveLinearMesh *clone(bool recDeepCpy) const;
     void setCoords(const DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
     %extend {
     MEDCouplingCurveLinearMesh *clone(bool recDeepCpy) const;
     void setCoords(const DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
     %extend {
-      MEDCouplingCurveLinearMesh()
+      MEDCouplingCurveLinearMesh() throw(INTERP_KERNEL::Exception)
       {
         return MEDCouplingCurveLinearMesh::New();
       }
       {
         return MEDCouplingCurveLinearMesh::New();
       }
-      MEDCouplingCurveLinearMesh(const std::string& meshName)
+      MEDCouplingCurveLinearMesh(const std::string& meshName) throw(INTERP_KERNEL::Exception)
       {
         return MEDCouplingCurveLinearMesh::New(meshName);
       }
       {
         return MEDCouplingCurveLinearMesh::New(meshName);
       }
@@ -2940,6 +2943,99 @@ namespace ParaMEDMEM
   };
 
   //== MEDCouplingCurveLinearMesh End
   };
 
   //== MEDCouplingCurveLinearMesh End
+
+  //== MEDCouplingIMesh
+
+  class MEDCouplingIMesh : public ParaMEDMEM::MEDCouplingStructuredMesh
+  {
+  public:
+    static MEDCouplingIMesh *New() throw(INTERP_KERNEL::Exception);
+    //
+    void setSpaceDimension(int spaceDim) throw(INTERP_KERNEL::Exception);
+    std::vector<int> getNodeStruct() const throw(INTERP_KERNEL::Exception);
+    std::vector<double> getOrigin() const throw(INTERP_KERNEL::Exception);
+    std::vector<double> getDXYZ() const throw(INTERP_KERNEL::Exception);
+    void setAxisUnit(const std::string& unitName) throw(INTERP_KERNEL::Exception);
+    std::string getAxisUnit() const throw(INTERP_KERNEL::Exception);
+    double getMeasureOfAnyCell() const throw(INTERP_KERNEL::Exception);
+    MEDCouplingCMesh *convertToCartesian() const throw(INTERP_KERNEL::Exception);
+    %extend
+    {
+      MEDCouplingIMesh()
+      {
+        return MEDCouplingIMesh::New();
+      }
+      static MEDCouplingIMesh *New(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) throw(INTERP_KERNEL::Exception)
+      {
+        static const char msg0[]="MEDCouplingIMesh::New : error on 'origin' parameter !";
+        static const char msg1[]="MEDCouplingIMesh::New : error on 'dxyz' parameter !";
+        const int *nodeStrctPtr(0);
+        const double *originPtr(0),*dxyzPtr(0);
+        int sw,sz,val0;
+        std::vector<int> bb0;
+        nodeStrctPtr=convertObjToPossibleCpp1_Safe(nodeStrct,sw,sz,val0,bb0);
+        //
+        double val,val2;
+        std::vector<double> bb,bb2;
+        int sz1,sz2;
+        originPtr=convertObjToPossibleCpp5_SingleCompo(origin,sw,val,bb,msg0,false,sz1);
+        dxyzPtr=convertObjToPossibleCpp5_SingleCompo(dxyz,sw,val2,bb2,msg1,false,sz2);
+        //
+        return MEDCouplingIMesh::New(meshName,spaceDim,nodeStrctPtr,nodeStrctPtr+sz,originPtr,originPtr+sz1,dxyzPtr,dxyzPtr+sz2);
+      }
+
+      MEDCouplingIMesh(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) throw(INTERP_KERNEL::Exception)
+      {
+        return ParaMEDMEM_MEDCouplingIMesh_New__SWIG_1(meshName,spaceDim,nodeStrct,origin,dxyz);
+      }
+
+      void setNodeStruct(PyObject *nodeStrct) throw(INTERP_KERNEL::Exception)
+      {
+        int sw,sz,val0;
+        std::vector<int> bb0;
+        const int *nodeStrctPtr(convertObjToPossibleCpp1_Safe(nodeStrct,sw,sz,val0,bb0));
+        self->setNodeStruct(nodeStrctPtr,nodeStrctPtr+sz);
+      }
+
+      void setOrigin(PyObject *origin) throw(INTERP_KERNEL::Exception)
+      {
+        static const char msg[]="MEDCouplingIMesh::setOrigin : invalid input 'origin' parameter ! integer, float, list/tuple of float, DataArrayDouble or DataArrayDoubleTuple supported !";
+        double val;
+        DataArrayDouble *a;
+        DataArrayDoubleTuple *aa;
+        std::vector<double> bb;
+        int sw,nbTuples;
+        const double *originPtr(convertObjToPossibleCpp5_SingleCompo(origin,sw,val,bb,msg,false,nbTuples));
+        self->setOrigin(originPtr,originPtr+nbTuples);
+      }
+      
+      void setDXYZ(PyObject *dxyz) throw(INTERP_KERNEL::Exception)
+      {
+        static const char msg[]="MEDCouplingIMesh::setDXYZ : invalid input 'dxyz' parameter ! integer, float, list/tuple of float, DataArrayDouble or DataArrayDoubleTuple supported !";
+        double val;
+        DataArrayDouble *a;
+        DataArrayDoubleTuple *aa;
+        std::vector<double> bb;
+        int sw,nbTuples;
+        const double *originPtr(convertObjToPossibleCpp5_SingleCompo(dxyz,sw,val,bb,msg,false,nbTuples));
+        self->setDXYZ(originPtr,originPtr+nbTuples);
+      }
+
+      std::string __str__() const throw(INTERP_KERNEL::Exception)
+      {
+        return self->simpleRepr();
+      }
+      std::string __repr__() const throw(INTERP_KERNEL::Exception)
+      {
+        std::ostringstream oss;
+        self->reprQuickOverview(oss);
+        return oss.str();
+      }
+    }
+  };
+
+  //== MEDCouplingIMesh End
+
 }
 
 namespace ParaMEDMEM
 }
 
 namespace ParaMEDMEM
index 7d583d4c8599038e25bab3262e4e12f06be9a464..e7e283efcee79bd9a44f42bccdc34b104c4098d9 100644 (file)
@@ -242,6 +242,7 @@ namespace ParaMEDMEM
     static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step) throw(INTERP_KERNEL::Exception);
     static std::string GetVarNameFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception);
     static std::string GetUnitFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception);
     static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step) throw(INTERP_KERNEL::Exception);
     static std::string GetVarNameFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception);
     static std::string GetUnitFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception);
+    static std::string BuildInfoFromVarAndUnit(const std::string& var, const std::string& unit) throw(INTERP_KERNEL::Exception);
     void updateTime() const;
     %extend
     {
     void updateTime() const;
     %extend
     {
index b2e7702c1baea0d7b5b96829f887a6a811bbaf8c..f0382c2cda99b332ce87ee14b0a34554a92da26d 100644 (file)
@@ -40,6 +40,8 @@ static PyObject *convertMesh(ParaMEDMEM::MEDCouplingMesh *mesh, int owner) throw
     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingCMesh,owner);
   if(dynamic_cast<ParaMEDMEM::MEDCouplingCurveLinearMesh *>(mesh))
     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingCurveLinearMesh,owner);
     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingCMesh,owner);
   if(dynamic_cast<ParaMEDMEM::MEDCouplingCurveLinearMesh *>(mesh))
     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingCurveLinearMesh,owner);
+  if(dynamic_cast<ParaMEDMEM::MEDCouplingIMesh *>(mesh))
+    ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingIMesh,owner);
   if(!ret)
     throw INTERP_KERNEL::Exception("Not recognized type of mesh on downcast !");
   return ret;
   if(!ret)
     throw INTERP_KERNEL::Exception("Not recognized type of mesh on downcast !");
   return ret;