Salome HOME
Small modif
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingMemArray.hxx
index 991673bf98053076db96c1c61eaffb4a25b794ea..aea13c23df3e652f97ecae4291da51ec35758c9f 100644 (file)
@@ -146,8 +146,9 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT std::string getVarOnComponent(int i) const;
     MEDCOUPLING_EXPORT std::string getUnitOnComponent(int i) const;
     MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const std::string& info);
-    MEDCOUPLING_EXPORT int getNumberOfComponents() const { return (int)_info_on_compo.size(); }
+    MEDCOUPLING_EXPORT std::size_t getNumberOfComponents() const { return _info_on_compo.size(); }
     MEDCOUPLING_EXPORT void setPartOfValuesBase3(const DataArray *aBase, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
+    MEDCOUPLING_EXPORT virtual void *getVoidStarPointer() = 0;
     MEDCOUPLING_EXPORT virtual DataArray *deepCopy() const = 0;
     MEDCOUPLING_EXPORT virtual DataArray *buildNewEmptyInstance() const = 0;
     MEDCOUPLING_EXPORT virtual bool isAllocated() const = 0;
@@ -156,8 +157,8 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT virtual int getNumberOfTuples() const = 0;
     MEDCOUPLING_EXPORT virtual std::size_t getNbOfElems() const = 0;
     MEDCOUPLING_EXPORT virtual std::size_t getNbOfElemAllocated() const = 0;
-    MEDCOUPLING_EXPORT virtual void alloc(int nbOfTuple, int nbOfCompo=1) = 0;
-    MEDCOUPLING_EXPORT virtual void reAlloc(int newNbOfTuple) = 0;
+    MEDCOUPLING_EXPORT virtual void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1) = 0;
+    MEDCOUPLING_EXPORT virtual void reAlloc(std::size_t newNbOfTuple) = 0;
     MEDCOUPLING_EXPORT virtual void renumberInPlace(const int *old2New) = 0;
     MEDCOUPLING_EXPORT virtual void renumberInPlaceR(const int *new2Old) = 0;
     MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) = 0;
@@ -168,6 +169,9 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT virtual DataArray *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const = 0;
     MEDCOUPLING_EXPORT virtual DataArray *selectByTupleIdSafeSlice(int bg, int end2, int step) const = 0;
     MEDCOUPLING_EXPORT virtual void rearrange(int newNbOfCompo) = 0;
+    MEDCOUPLING_EXPORT virtual void circularPermutation(int nbOfShift=1) = 0;
+    MEDCOUPLING_EXPORT virtual void circularPermutationPerTuple(int nbOfShift=1) = 0;
+    MEDCOUPLING_EXPORT virtual void reversePerTuple() = 0;
     MEDCOUPLING_EXPORT void checkNbOfTuples(int nbOfTuples, const std::string& msg) const;
     MEDCOUPLING_EXPORT void checkNbOfComps(int nbOfCompo, const std::string& msg) const;
     MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const;
@@ -196,6 +200,7 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT static void CheckValueInRange(int ref, int value, const std::string& msg);
     MEDCOUPLING_EXPORT static void CheckValueInRangeEx(int value, int start, int end, const std::string& msg);
     MEDCOUPLING_EXPORT static void CheckClosingParInRange(int ref, int value, const std::string& msg);
+    MEDCOUPLING_EXPORT static int EffectiveCircPerm(int nbOfShift, int nbOfTuples);
   protected:
     std::string _name;
     std::vector<std::string> _info_on_compo;
@@ -210,15 +215,19 @@ namespace MEDCoupling
   class DataArrayTemplate : public DataArray
   {
   public:
+    MEDCOUPLING_EXPORT static MCAuto< typename Traits<T>::ArrayTypeCh > NewFromStdVector(const typename std::vector<T>& v);
+    MEDCOUPLING_EXPORT std::vector< MCAuto< typename Traits<T>::ArrayTypeCh > > explodeComponents() const;
+    //
     std::size_t getHeapMemorySizeWithoutChildren() const;
     //
     MEDCOUPLING_EXPORT int getNumberOfTuples() const { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); }
     MEDCOUPLING_EXPORT std::size_t getNbOfElems() const { return _mem.getNbOfElem(); }
     bool empty() const;
+    MEDCOUPLING_EXPORT void *getVoidStarPointer() { return getPointer(); }
     MEDCOUPLING_EXPORT const T *getConstPointer() const { return _mem.getConstPointer(); }
     MEDCOUPLING_EXPORT const T *begin() const { return getConstPointer(); }
     MEDCOUPLING_EXPORT const T *end() const { return getConstPointer()+getNbOfElems(); }
-    void alloc(int nbOfTuple, int nbOfCompo=1);
+    void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1);
     void useArray(const T *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
     void useExternalArrayWithRWAccess(const T *array, int nbOfTuple, int nbOfCompo);
     T getIJSafe(int tupleId, int compoId) const;
@@ -243,7 +252,7 @@ namespace MEDCoupling
     void deepCopyFrom(const DataArrayTemplate<T>& other);
     void reverse();
     void fillWithValue(T val);
-    void reAlloc(int newNbOfTuple);
+    void reAlloc(std::size_t newNbOfTuple);
     void renumberInPlace(const int *old2New);
     void renumberInPlaceR(const int *new2Old);
     void sort(bool asc=true);
@@ -252,6 +261,9 @@ namespace MEDCoupling
     typename Traits<T>::ArrayType *renumberAndReduce(const int *old2New, int newNbOfTuple) const;
     typename Traits<T>::ArrayType *changeNbOfComponents(int newNbOfComp, T dftValue) const;
     typename Traits<T>::ArrayType *subArray(int tupleIdBg, int tupleIdEnd=-1) const;
+    void circularPermutation(int nbOfShift=1);
+    void circularPermutationPerTuple(int nbOfShift=1);
+    void reversePerTuple();
     void setPartOfValues1(const typename Traits<T>::ArrayType *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
     void setPartOfValuesSimple1(T a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp);
     void setPartOfValues2(const typename Traits<T>::ArrayType *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true);
@@ -356,6 +368,10 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT DataArrayDouble *fromCylToCart() const;
     MEDCOUPLING_EXPORT DataArrayDouble *fromSpherToCart() const;
     MEDCOUPLING_EXPORT DataArrayDouble *cartesianize(MEDCouplingAxisType atOfThis) const;
+    MEDCOUPLING_EXPORT DataArrayDouble *fromCartToPolar() const;
+    MEDCOUPLING_EXPORT DataArrayDouble *fromCartToCyl() const;
+    MEDCOUPLING_EXPORT DataArrayDouble *fromCartToSpher() const;
+    MEDCOUPLING_EXPORT DataArrayDouble *fromCartToCylGiven(const DataArrayDouble *coords, const double center[3], const double vect[3]) const;
     MEDCOUPLING_EXPORT DataArrayDouble *doublyContractedProduct() const;
     MEDCOUPLING_EXPORT DataArrayDouble *determinant() const;
     MEDCOUPLING_EXPORT DataArrayDouble *eigenValues() const;
@@ -483,6 +499,7 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT void switchOnTupleEqualTo(int val, std::vector<bool>& vec) const;
     MEDCOUPLING_EXPORT void switchOnTupleNotEqualTo(int val, std::vector<bool>& vec) const;
     MEDCOUPLING_EXPORT DataArrayInt *buildPermutationArr(const DataArrayInt& other) const;
+    MEDCOUPLING_EXPORT DataArrayInt *indicesOfSubPart(const DataArrayInt& partOfThis) const;
     MEDCOUPLING_EXPORT DataArrayInt *sumPerTuple() const;
     MEDCOUPLING_EXPORT void checkMonotonic(bool increasing) const;
     MEDCOUPLING_EXPORT bool isMonotonic(bool increasing) const;
@@ -827,10 +844,24 @@ namespace MEDCoupling
   };
 }
 
-#include "MEDCouplingMemArray.txx"
-
 namespace MEDCoupling
 {
+  template<class T>
+  template<class InputIterator>
+  void MemArray<T>::insertAtTheEnd(InputIterator first, InputIterator last)
+  {
+    T *pointer=_pointer.getPointer();
+    while(first!=last)
+      {
+        if(_nb_of_elem>=_nb_of_elem_alloc)
+          {
+            reserve(_nb_of_elem_alloc>0?2*_nb_of_elem_alloc:1);
+            pointer=_pointer.getPointer();
+          }
+        pointer[_nb_of_elem++]=*first++;
+      }
+  }
+  
   template<class InputIterator>
   void DataArrayDouble::insertAtTheEnd(InputIterator first, InputIterator last)
   {