]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
*** empty log message ***
authorageay <ageay>
Wed, 21 Jul 2010 14:13:35 +0000 (14:13 +0000)
committerageay <ageay>
Wed, 21 Jul 2010 14:13:35 +0000 (14:13 +0000)
src/MEDCoupling_Swig/MEDCouplingTypemaps.i
src/MEDCoupling_Swig/libMEDCoupling_Swig.i

index becacdfe96ba64bbc7014976caf57a822d29eea6..117cc6102655f75e3297b5e34e17d2349b6c5be2 100644 (file)
@@ -22,6 +22,8 @@ static PyObject* convertMesh(ParaMEDMEM::MEDCouplingMesh* mesh, int owner)
   PyObject *ret;
   if(dynamic_cast<ParaMEDMEM::MEDCouplingUMesh *>(mesh))
     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,owner);
+  if(dynamic_cast<ParaMEDMEM::MEDCouplingExtrudedMesh *>(mesh))
+    ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingExtrudedMesh,owner);
   return ret;
 }
 
@@ -33,41 +35,13 @@ static PyObject *convertIntArrToPyList(const int *ptr, int size)
   return ret;
 }
 
-static int *convertPyToNewIntArr(PyObject *pyLi, int size)
+static int *convertPyToNewIntArr2(PyObject *pyLi, int *size)
 {
   if(PyList_Check(pyLi))
     {
-      int *tmp=new int[size];
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyList_GetItem(pyLi,i);
-          if(PyInt_Check(o))
-            {
-              int val=(int)PyInt_AS_LONG(o);
-              tmp[i]=val;
-            }
-          else
-            {
-              PyErr_SetString(PyExc_TypeError,"list must contain integers only");
-              return NULL;
-            }
-        }
-      return tmp;
-    }
-  else
-    {
-      PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr : not a list");
-      return 0;
-    }
-}
-
-static int *convertPyToNewIntArr2(PyObject *pyLi)
-{
-  if(PyList_Check(pyLi))
-    {
-      int size=PyList_Size(pyLi);
-      int *tmp=new int[size];
-      for(int i=0;i<size;i++)
+      *size=PyList_Size(pyLi);
+      int *tmp=new int[*size];
+      for(int i=0;i<*size;i++)
         {
           PyObject *o=PyList_GetItem(pyLi,i);
           if(PyInt_Check(o))
index 876dff59a883abdd8fbbc0ad01432ea60a2242f6..12cc18dbfd3ec017b4056e8f7f05c52136f6289f 100644 (file)
@@ -21,6 +21,8 @@
 
 #define MEDCOUPLING_EXPORT
 
+%include std_vector.i
+
 %{
 #include "MEDCouplingMemArray.hxx"
 #include "MEDCouplingUMesh.hxx"
@@ -33,11 +35,18 @@ using namespace ParaMEDMEM;
 using namespace INTERP_KERNEL;
 %}
 
+%template(ivec) std::vector<int>;
+
 %typemap(out) ParaMEDMEM::MEDCouplingMesh*
 {
   $result=convertMesh($1,$owner);
 }
 
+%typemap(out) ParaMEDMEM::MEDCouplingPointSet*
+{
+  $result=convertMesh($1,$owner);
+}
+
 %newobject ParaMEDMEM::DataArrayDouble::New;
 %newobject ParaMEDMEM::DataArrayInt::New;
 %newobject ParaMEDMEM::DataArrayDouble::convertToIntArr;
@@ -53,9 +62,11 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::MEDCouplingFieldDouble::clone;
 %newobject ParaMEDMEM::MEDCouplingMesh::mergeMyselfWith;
 %newobject ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic;
-%newobject ParaMEDMEM::MEDCouplingUMesh::buildPartOfMySelf;
 %newobject ParaMEDMEM::MEDCouplingPointSet::zipCoordsTraducer;
-%newobject ParaMEDMEM::MEDCouplingUMesh::getMeasureField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer;
+%newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity;
+%newobject ParaMEDMEM::MEDCouplingPointSet::buildBoundaryMesh;
+%newobject ParaMEDMEM::MEDCouplingMesh::getMeasureField;
 %newobject ParaMEDMEM::MEDCouplingUMesh::buildExtrudedMeshFromThis;
 %newobject ParaMEDMEM::MEDCouplingUMesh::mergeUMeshes;
 %newobject ParaMEDMEM::MEDCouplingExtrudedMesh::New;
@@ -84,7 +95,37 @@ namespace ParaMEDMEM
 {
 
   %extend MEDCouplingPointSet
-    {
+  {
+      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 convertIntArrToPyList(&nodes[0],nodes.size());
+      }
       void rotate(PyObject *center, PyObject *vector, double alpha)
       {
         double *c=convertPyToNewDblArr2(center);
@@ -97,6 +138,35 @@ namespace ParaMEDMEM
         delete [] c;
         delete [] v;
       }
+      void translate(PyObject *vector)
+      {
+        double *v=convertPyToNewDblArr2(vector);
+        self->translate(v);
+        delete [] v;
+      }
+      void scale(PyObject *point, double factor)
+      {
+        double *p=convertPyToNewDblArr2(point);
+        self->scale(p,factor);
+        delete [] p;
+      }
+      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;
+        double *p=convertPyToNewDblArr2(pt);
+        double *v=convertPyToNewDblArr2(vec);
+        self->findNodesOnPlane(p,v,eps,nodes);
+        delete [] v;
+        delete [] p;
+        return convertIntArrToPyList(&nodes[0],nodes.size());
+      }
     }
 
   class MEDCouplingUMesh : public ParaMEDMEM::MEDCouplingPointSet
@@ -118,20 +188,16 @@ namespace ParaMEDMEM
     INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
     int getNumberOfNodesInCell(int cellId) const;
     bool isStructured() const;
-    int getNumberOfCells() const;
-    int getNumberOfNodes() const;
-    int getSpaceDimension() const;
-    int getMeshDimension() const;
     int getMeshLength() const;
     //tools
-    void zipCoords();
-    DataArrayInt *zipCoordsTraducer();
+    DataArrayInt *zipConnectivityTraducer(int compType);
     void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const;
-    MEDCouplingUMesh *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const;
+    MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const;
     %extend {
       void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, PyObject *li)
       {
-        int *tmp=convertPyToNewIntArr(li,size);
+        int sz;
+        int *tmp=convertPyToNewIntArr2(li,&sz);
         self->insertNextCell(type,size,tmp);
         delete [] tmp;
       }
@@ -153,8 +219,15 @@ namespace ParaMEDMEM
         PyList_SetItem(res,1,SWIG_From_bool(ret1));
         return res;
       }
+      void renumberCells(PyObject *li, bool check)
+      {
+        int size;
+        int *tmp=convertPyToNewIntArr2(li,&size);
+        self->renumberCells(tmp,tmp+size,check);
+        delete [] tmp;
+      }
     }
-    MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
+    void convertToPolyTypes(const std::vector<int>& cellIdsToConvert);
     MEDCouplingUMesh *buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy);
     static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2);
   };
@@ -185,7 +258,8 @@ namespace ParaMEDMEM
  {
    void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple)
    {
-     int *tmp=convertPyToNewIntArr2(li);
+     int size;
+     int *tmp=convertPyToNewIntArr2(li,&size);
      self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple);
    }