Salome HOME
DGTUMesh with no cells can be now converted into umesh
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingMemArray.cxx
index 8ccb92e540131fdcca2c70e82283e1ee8d3d361d..28806d19d08a755c9ca918e3c3d427940c22decf 100644 (file)
@@ -3061,6 +3061,15 @@ void DataArrayDouble::useExternalArrayWithRWAccess(const double *array, int nbOf
   declareAsNew();
 }
 
+void DataArrayDouble::aggregate(const DataArrayDouble *other)
+{
+  if(!other)
+    throw INTERP_KERNEL::Exception("DataArrayDouble::aggregate : null pointer !");
+  if(getNumberOfComponents()!=other->getNumberOfComponents())
+    throw INTERP_KERNEL::Exception("DataArrayDouble::aggregate : mismatch number of components !");
+  _mem.insertAtTheEnd(other->begin(),other->end());
+}
+
 /*!
  * Checks if 0.0 value is present in \a this array. If it is the case, an exception
  * is thrown.
@@ -6907,6 +6916,8 @@ bool DataArrayInt::isFittingWith(const std::vector<bool>& v) const
  * This method assumes that \a this has one component and is allocated. This method scans all tuples in \a this and for all tuple equal to \a val
  * put True to the corresponding entry in \a vec.
  * \a vec is expected to be with the same size than the number of tuples of \a this.
+ *
+ *  \sa DataArrayInt::switchOnTupleNotEqualTo.
  */
 void DataArrayInt::switchOnTupleEqualTo(int val, std::vector<bool>& vec) const
 {
@@ -6922,6 +6933,27 @@ void DataArrayInt::switchOnTupleEqualTo(int val, std::vector<bool>& vec) const
       vec[i]=true;
 }
 
+/*!
+ * This method assumes that \a this has one component and is allocated. This method scans all tuples in \a this and for all tuple different from \a val
+ * put True to the corresponding entry in \a vec.
+ * \a vec is expected to be with the same size than the number of tuples of \a this.
+ * 
+ *  \sa DataArrayInt::switchOnTupleEqualTo.
+ */
+void DataArrayInt::switchOnTupleNotEqualTo(int val, std::vector<bool>& vec) const
+{
+  checkAllocated();
+  if(getNumberOfComponents()!=1)
+    throw INTERP_KERNEL::Exception("DataArrayInt::switchOnTupleNotEqualTo : number of components of this should be equal to one !");
+  int nbOfTuples(getNumberOfTuples());
+  if(nbOfTuples!=(int)vec.size())
+    throw INTERP_KERNEL::Exception("DataArrayInt::switchOnTupleNotEqualTo : number of tuples of this should be equal to size of input vector of bool !");
+  const int *pt(begin());
+  for(int i=0;i<nbOfTuples;i++)
+    if(pt[i]!=val)
+      vec[i]=true;
+}
+
 /*!
  * Sorts values of the array.
  *  \param [in] asc - \a true means ascending order, \a false, descending.
@@ -7159,6 +7191,15 @@ void DataArrayInt::useExternalArrayWithRWAccess(const int *array, int nbOfTuple,
   declareAsNew();
 }
 
+void DataArrayInt::aggregate(const DataArrayInt *other)
+{
+  if(!other)
+    throw INTERP_KERNEL::Exception("DataArrayInt::aggregate : null pointer !");
+  if(getNumberOfComponents()!=other->getNumberOfComponents())
+    throw INTERP_KERNEL::Exception("DataArrayInt::aggregate : mismatch number of components !");
+  _mem.insertAtTheEnd(other->begin(),other->end());
+}
+
 /*!
  * Returns a new DataArrayInt holding the same values as \a this array but differently
  * arranged in memory. If \a this array holds 2 components of 3 values: