Salome HOME
Merge branch 'agy/codeutils'
[tools/medcoupling.git] / src / MEDCoupling_Swig / MEDCouplingCommon.i
index 189db27d9eaf9f234f066df14b4b09e1ab8bd789..bfbf966dbebe43072a7e2fcc993c0a0214af01e8 100644 (file)
@@ -360,6 +360,7 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::MEDCouplingAMRAttribute::deepCpy;
 %newobject ParaMEDMEM::MEDCouplingAMRAttribute::deepCpyWithoutGodFather;
 %newobject ParaMEDMEM::MEDCouplingAMRAttribute::getFieldOn;
+%newobject ParaMEDMEM::MEDCouplingAMRAttribute::projectTo;
 %newobject ParaMEDMEM::MEDCouplingAMRAttribute::buildCellFieldOnRecurseWithoutOverlapWithoutGhost;
 %newobject ParaMEDMEM::MEDCouplingAMRAttribute::buildCellFieldOnWithGhost;
 %newobject ParaMEDMEM::MEDCouplingAMRAttribute::buildCellFieldOnWithoutGhost;
@@ -427,14 +428,16 @@ namespace INTERP_KERNEL
   public:
     BoxSplittingOptions();
     void init() throw(INTERP_KERNEL::Exception);
-    double getEffeciency() const throw(INTERP_KERNEL::Exception);
-    void setEffeciency(double effeciency) throw(INTERP_KERNEL::Exception);
-    double getEffeciencySnd() const throw(INTERP_KERNEL::Exception);
-    void setEffeciencySnd(double effeciencySnd) throw(INTERP_KERNEL::Exception);
-    int getMinCellDirection() const throw(INTERP_KERNEL::Exception);
-    void setMinCellDirection(int minCellDirection) throw(INTERP_KERNEL::Exception);
-    int getMaxCells() const throw(INTERP_KERNEL::Exception);
-    void setMaxCells(int maxCells) throw(INTERP_KERNEL::Exception);
+    double getEfficiencyGoal() const throw(INTERP_KERNEL::Exception);
+    void setEfficiencyGoal(double efficiency) throw(INTERP_KERNEL::Exception);
+    double getEfficiencyThreshold() const throw(INTERP_KERNEL::Exception);
+    void setEfficiencyThreshold(double efficiencyThreshold) throw(INTERP_KERNEL::Exception);
+    int getMinimumPatchLength() const throw(INTERP_KERNEL::Exception);
+    void setMinimumPatchLength(int minPatchLength) throw(INTERP_KERNEL::Exception);
+    int getMaximumPatchLength() const throw(INTERP_KERNEL::Exception);
+    void setMaximumPatchLength(int maxPatchLength) throw(INTERP_KERNEL::Exception);
+    int getMaximumNbOfCellsInPatch() const throw(INTERP_KERNEL::Exception);
+    void setMaximumNbOfCellsInPatch(int maxNbCellsInPatch) throw(INTERP_KERNEL::Exception);
     void copyOptions(const BoxSplittingOptions & other) throw(INTERP_KERNEL::Exception);
     std::string printOptions() const throw(INTERP_KERNEL::Exception);
     %extend
@@ -545,7 +548,9 @@ namespace ParaMEDMEM
     virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const throw(INTERP_KERNEL::Exception);
     virtual std::string simpleRepr() const throw(INTERP_KERNEL::Exception);
     virtual std::string advancedRepr() const throw(INTERP_KERNEL::Exception);
-    void writeVTK(const std::string& fileName, bool isBinary=true) const throw(INTERP_KERNEL::Exception);
+    std::string writeVTK(const std::string& fileName, bool isBinary=true) const throw(INTERP_KERNEL::Exception);
+    virtual std::string getVTKFileExtension() const;
+    std::string getVTKFileNameOf(const std::string& fileName) const;
     // tools
     virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
     virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const throw(INTERP_KERNEL::Exception);
@@ -2865,6 +2870,7 @@ namespace ParaMEDMEM
     int getNodeIdFromPos(int i, int j, int k) const throw(INTERP_KERNEL::Exception);
     int getNumberOfCellsOfSubLevelMesh() const throw(INTERP_KERNEL::Exception);
     int getSpaceDimensionOnNodeStruct() const throw(INTERP_KERNEL::Exception);
+    double computeSquareness() const throw(INTERP_KERNEL::Exception);
     virtual std::vector<int> getNodeGridStructure() const throw(INTERP_KERNEL::Exception);
     std::vector<int> getCellGridStructure() const throw(INTERP_KERNEL::Exception);
     MEDCoupling1SGTUMesh *build1SGTUnstructured() const throw(INTERP_KERNEL::Exception);
@@ -2946,6 +2952,13 @@ namespace ParaMEDMEM
         return MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(st,fieldOfDbl,inp);
       }
 
+      static void AssignPartOfFieldOfDoubleUsing(const std::vector<int>& st, DataArrayDouble *fieldOfDbl, PyObject *partCompactFormat, const DataArrayDouble *other) throw(INTERP_KERNEL::Exception)
+      {
+        std::vector< std::pair<int,int> > inp;
+        convertPyToVectorPairInt(partCompactFormat,inp);
+        MEDCouplingStructuredMesh::AssignPartOfFieldOfDoubleUsing(st,fieldOfDbl,inp,other);
+      }
+
       static int DeduceNumberOfGivenRangeInCompactFrmt(PyObject *part) throw(INTERP_KERNEL::Exception)
       {
         std::vector< std::pair<int,int> > inp;
@@ -3007,6 +3020,14 @@ namespace ParaMEDMEM
         return retPy;
       }
 
+      static bool AreRangesIntersect(PyObject *r1, PyObject *r2)
+      {
+        std::vector< std::pair<int,int> > r1Cpp,r2Cpp;
+        convertPyToVectorPairInt(r1,r1Cpp);
+        convertPyToVectorPairInt(r2,r2Cpp);
+        return MEDCouplingStructuredMesh::AreRangesIntersect(r1Cpp,r2Cpp);
+      }
+
       static PyObject *IsPartStructured(PyObject *li, PyObject *st) throw(INTERP_KERNEL::Exception)
       {
         int szArr,sw,iTypppArr;
@@ -3519,7 +3540,7 @@ namespace ParaMEDMEM
     void copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
     std::string simpleRepr() const throw(INTERP_KERNEL::Exception);
     std::string advancedRepr() const throw(INTERP_KERNEL::Exception);
-    void writeVTK(const std::string& fileName, bool isBinary=true) const throw(INTERP_KERNEL::Exception);
+    std::string  writeVTK(const std::string& fileName, bool isBinary=true) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
     MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const;
     MEDCouplingFieldDouble *deepCpy() const;
@@ -4590,11 +4611,11 @@ namespace ParaMEDMEM
         return MEDCouplingFieldDouble::MergeFields(tmp);
       }
 
-      static void WriteVTK(const char *fileName, PyObject *li, bool isBinary=true) throw(INTERP_KERNEL::Exception)
+      static std::string WriteVTK(const char *fileName, PyObject *li, bool isBinary=true) throw(INTERP_KERNEL::Exception)
       {
         std::vector<const MEDCouplingFieldDouble *> tmp;
         convertFromPyObjVectorOfObj<const ParaMEDMEM::MEDCouplingFieldDouble *>(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp);
-        MEDCouplingFieldDouble::WriteVTK(fileName,tmp,isBinary);
+        return MEDCouplingFieldDouble::WriteVTK(fileName,tmp,isBinary);
       }
     }
   };
@@ -4918,7 +4939,6 @@ namespace ParaMEDMEM
   class MEDCouplingCartesianAMRMeshGen : public RefCountObject, public TimeLabel
   {
   public:
-    virtual MEDCouplingCartesianAMRMeshGen *deepCpy(MEDCouplingCartesianAMRMeshGen *father) const throw(INTERP_KERNEL::Exception);
     int getAbsoluteLevel() const throw(INTERP_KERNEL::Exception);
     int getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const throw(INTERP_KERNEL::Exception);
     std::vector<int> getPositionRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const throw(INTERP_KERNEL::Exception);
@@ -4977,6 +4997,12 @@ namespace ParaMEDMEM
         return ret;
       }
 
+      // agy : don't know why typemap fails here ??? let it in the extend section
+      PyObject *deepCpy(MEDCouplingCartesianAMRMeshGen *father) const throw(INTERP_KERNEL::Exception)
+      {
+        return convertCartesianAMRMesh(self->deepCpy(father), SWIG_POINTER_OWN | 0 );
+      }
+
       MEDCouplingCartesianAMRPatch *getPatchAtPosition(const std::vector<int>& pos) const throw(INTERP_KERNEL::Exception)
       {
         const MEDCouplingCartesianAMRPatch *ret(self->getPatchAtPosition(pos));
@@ -4995,6 +5021,16 @@ namespace ParaMEDMEM
         return ret2;
       }
 
+      virtual PyObject *positionRelativeToGodFather() const throw(INTERP_KERNEL::Exception)
+      {
+        std::vector<int> out1;
+        std::vector< std::pair<int,int> > out0(self->positionRelativeToGodFather(out1));
+        PyObject *ret(PyTuple_New(2));
+        PyTuple_SetItem(ret,0,convertFromVectorPairInt(out0));
+        PyTuple_SetItem(ret,1,convertIntArrToPyList2(out1));
+        return ret;
+      }
+
       virtual PyObject *retrieveGridsAt(int absoluteLev) const throw(INTERP_KERNEL::Exception)
       {
         std::vector<MEDCouplingCartesianAMRPatchGen *> ps(self->retrieveGridsAt(absoluteLev));
@@ -5164,6 +5200,7 @@ namespace ParaMEDMEM
     MEDCouplingFieldDouble *buildCellFieldOnWithGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDouble *buildCellFieldOnWithoutGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const throw(INTERP_KERNEL::Exception);
     bool changeGodFather(MEDCouplingCartesianAMRMesh *gf) throw(INTERP_KERNEL::Exception);
+    MEDCouplingAMRAttribute *projectTo(MEDCouplingCartesianAMRMesh *targetGF) const throw(INTERP_KERNEL::Exception);
     %extend
     {
       static MEDCouplingAMRAttribute *New(MEDCouplingCartesianAMRMesh *gf, PyObject *fieldNames, int ghostLev) throw(INTERP_KERNEL::Exception)