Salome HOME
Updated copyright comment
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingMemArrayFloat.cxx
index a06401848c202cfa4e71ef972d86e0c8190aa4a8..4b7132cd533b16099e6f346297432d4b22fa1c92 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2024  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -24,7 +24,9 @@ using namespace MEDCoupling;
 
 template class MEDCoupling::MemArray<float>;
 template class MEDCoupling::DataArrayTemplate<float>;
+template class MEDCoupling::DataArrayTemplateClassic<float>;
 template class MEDCoupling::DataArrayTemplateFP<float>;
+template class MEDCoupling::DataArrayIterator<float>;
 
 DataArrayFloat *DataArrayFloat::New()
 {
@@ -36,28 +38,10 @@ DataArrayFloat *DataArrayFloat::deepCopy() const
   return new DataArrayFloat(*this);
 }
 
-void DataArrayFloat::reprStream(std::ostream& stream) const
-{
-  stream << "Name of float array : \"" << _name << "\"\n";
-  reprWithoutNameStream(stream);
-}
-
-void DataArrayFloat::reprZipStream(std::ostream& stream) const
-{
-  stream << "Name of float array : \"" << _name << "\"\n";
-  reprZipWithoutNameStream(stream);
-}
-
-void DataArrayFloat::reprZipWithoutNameStream(std::ostream& stream) const
-{
-  DataArray::reprWithoutNameStream(stream);
-  stream.precision(7);
-  _mem.repr(getNumberOfComponents(),stream);
-}
-
 void DataArrayFloat::reprCppStream(const std::string& varName, std::ostream& stream) const
 {
-  int nbTuples(getNumberOfTuples()),nbComp(getNumberOfComponents());
+  mcIdType nbTuples(getNumberOfTuples());
+  std::size_t nbComp(getNumberOfComponents());
   const float *data(begin());
   stream.precision(7);
   stream << "DataArrayFloat *" << varName << "=DataArrayFloat::New();" << std::endl;
@@ -79,10 +63,10 @@ void DataArrayFloat::reprQuickOverview(std::ostream& stream) const
   stream << "DataArrayFloat C++ instance at " << this << ". ";
   if(isAllocated())
     {
-      int nbOfCompo=(int)_info_on_compo.size();
+      std::size_t nbOfCompo=_info_on_compo.size();
       if(nbOfCompo>=1)
         {
-          int nbOfTuples=getNumberOfTuples();
+          mcIdType nbOfTuples=getNumberOfTuples();
           stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl;
           reprQuickOverviewData(stream,MAX_NB_OF_BYTE_IN_REPR);
         }
@@ -96,18 +80,18 @@ void DataArrayFloat::reprQuickOverview(std::ostream& stream) const
 void DataArrayFloat::reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const
 {
   const float *data(begin());
-  int nbOfTuples(getNumberOfTuples());
-  int nbOfCompo=(int)_info_on_compo.size();
+  mcIdType nbOfTuples(getNumberOfTuples());
+  std::size_t nbOfCompo=_info_on_compo.size();
   std::ostringstream oss2; oss2 << "[";
   oss2.precision(7);
   std::string oss2Str(oss2.str());
   bool isFinished=true;
-  for(int i=0;i<nbOfTuples && isFinished;i++)
+  for(mcIdType i=0;i<nbOfTuples && isFinished;i++)
     {
       if(nbOfCompo>1)
         {
           oss2 << "(";
-          for(int j=0;j<nbOfCompo;j++,data++)
+          for(std::size_t j=0;j<nbOfCompo;j++,data++)
             {
               oss2 << *data;
               if(j!=nbOfCompo-1) oss2 << ", ";
@@ -129,26 +113,6 @@ void DataArrayFloat::reprQuickOverviewData(std::ostream& stream, std::size_t max
   stream << "]";
 }
 
-std::string DataArrayFloat::reprNotTooLong() const
-{
-  std::ostringstream ret;
-  reprNotTooLongStream(ret);
-  return ret.str();
-}
-
-void DataArrayFloat::reprNotTooLongStream(std::ostream& stream) const
-{
-  stream << "Name of float array : \"" << _name << "\"\n";
-  reprNotTooLongWithoutNameStream(stream);
-}
-
-void DataArrayFloat::reprNotTooLongWithoutNameStream(std::ostream& stream) const
-{
-  DataArray::reprWithoutNameStream(stream);
-  stream.precision(7);
-  _mem.reprNotTooLong(getNumberOfComponents(),stream);
-}
-
 bool DataArrayFloat::isEqualIfNotWhy(const DataArrayFloat& other, float prec, std::string& reason) const
 {
   if(!areInfoEqualsIfNotWhy(other,reason))
@@ -167,3 +131,41 @@ bool DataArrayFloat::isEqualWithoutConsideringStr(const DataArrayFloat& other, f
   std::string tmp;
   return _mem.isEqual(other._mem,prec,tmp);
 }
+
+DataArrayFloatIterator *DataArrayFloat::iterator()
+{
+  return new DataArrayFloatIterator(this);
+}
+
+DataArrayFloatIterator::DataArrayFloatIterator(DataArrayFloat *da):DataArrayIterator<float>(da)
+{
+}
+
+DataArrayFloatTuple::DataArrayFloatTuple(float *pt, std::size_t nbOfComp):DataArrayTuple<float>(pt,nbOfComp)
+{
+}
+
+std::string DataArrayFloatTuple::repr() const
+{
+  std::ostringstream oss; oss.precision(7); oss << "(";
+  for(std::size_t i=0;i<_nb_of_compo-1;i++)
+    oss << _pt[i] << ", ";
+  oss << _pt[_nb_of_compo-1] << ")";
+  return oss.str();
+}
+
+float DataArrayFloatTuple::floatValue() const
+{
+  return this->zeValue();
+}
+
+/*!
+ * This method returns a newly allocated instance the caller should dealed with by a MEDCoupling::DataArrayFloat::decrRef.
+ * This method performs \b no copy of data. The content is only referenced using MEDCoupling::DataArrayFloat::useArray with ownership set to \b false.
+ * This method throws an INTERP_KERNEL::Exception is it is impossible to match sizes of \b this that is too say \b nbOfCompo=this->_nb_of_elem and \bnbOfTuples==1 or
+ * \b nbOfCompo=1 and \bnbOfTuples==this->_nb_of_elem.
+ */
+DataArrayFloat *DataArrayFloatTuple::buildDAFloat(std::size_t nbOfTuples, std::size_t nbOfCompo) const
+{
+  return this->buildDA(nbOfTuples,nbOfCompo);
+}