Back to index

salome-med  6.5.0
Public Member Functions | Private Attributes
MEDMEM::MEDARRAY< T > Class Template Reference

#include <MEDMEM_Array.hxx>

Inheritance diagram for MEDMEM::MEDARRAY< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 MEDARRAY ()
 ~MEDARRAY ()
 MEDARRAY (const int ld_values, const int length_values, const MED_EN::medModeSwitch mode=MED_EN::MED_FULL_INTERLACE)
 This constructor does allocation and does not set values :
.
 MEDARRAY (T *values, const int ld_values, const int length_values, const MED_EN::medModeSwitch mode=MED_EN::MED_FULL_INTERLACE, bool shallowCopy=false, bool ownershipOfValues=false)
 This constructor duplicate T*values.
 MEDARRAY (MEDARRAY const &m)
 This constructor allocates a new medarray and does a copy of pointers
It DOES NOT copy the memory .
 MEDARRAY (MEDARRAY const &m, bool copyOther)
 This constructor allocates a new array and does a copy of values included in the m arrays.
MEDARRAYoperator= (const MEDARRAY &m)
 This operator makes a deep copy of the arrays.
MEDARRAYshallowCopy (const MEDARRAY &m)
 Idem operator= but performs only shallow copy (just copy of pointers) of arrays contains in _valuesFull and _valuesNo
WARNING the MEDARRAY returned HAS THE OWNERSHIP OF THE ARRAY !!!!
int getLeadingValue () const
 returns _ldValues.
int getLengthValue () const
 returns _ldValues.
const T * get (const MED_EN::medModeSwitch mode)
 returns a pointer to _valuesDefault or _valuesOther, depending on mode value : if mode is the same as _mode, _valuesDefault is returned.
const T * getRow (const int i)
 returns a pointer to ith element of the array.
const T * getColumn (const int j)
 this method is similar to getRow method.
const T getIJ (const int i, const int j) const
 returns Jth value of Ith element .
MED_EN::medModeSwitch getMode () const
 returns the default mode (_mode)
(internal use : needed by write method)
void set (const MED_EN::medModeSwitch mode, const T *value)
 sets T pointer of _valuesDefault (cf class PointerOf) on value.
void setI (const int i, const T *value)
 Sets ith element to T* values
if they both exist, both _valuesFull and _valuesNo arrays will be updated.
void setJ (const int j, const T *value)
 Sets ith element to T* values
if they both exist, both _valuesFull and _valuesNo arrays will be updated.
void setIJ (const int i, const int j, const T value)
 Sets value of Jth coordinate of Ith element to T value.
void calculateOther ()
 Calculates the other mode of representation : MED_FULL_INTERLACE if __mode = MED_NO_INTERLACE and vice versa.
bool isOtherCalculated () const
void clearOtherMode ()
 This function clears the other mode of representation if it exists It is usefull for people who needs for optimisation reasons to work directly on the inside array without using set-functions.

Private Attributes

int _ldValues
 leading dimension of value (example : space dimension for coordinates)
int _lengthValues
 length of values (example : number of nodes for coordinates)
MED_EN::medModeSwitch _mode
 data access mode.
PointerOf< T > _valuesFull
 Pointer to representation in mode MED_FULL_INTERLACE.
PointerOf< T > _valuesNo
 Pointer to representation in mode MED_NO_INTERLACE.
PointerOf< T > _valuesDefault
 Pointer to representation in mode _mode.
PointerOf< T > _valuesOther
 Pointer to representation in the other mode (!=_mode)

Detailed Description

template<class T>
class MEDMEM::MEDARRAY< T >

Definition at line 63 of file MEDMEM_Array.hxx.


Constructor & Destructor Documentation

template<class T >
MEDMEM::MEDARRAY< T >::MEDARRAY ( ) [inline]
template<class T >
MEDMEM::MEDARRAY< T >::~MEDARRAY ( ) [inline]

Definition at line 139 of file MEDMEM_Array.hxx.

{
}
template<class T >
MEDMEM::MEDARRAY< T >::MEDARRAY ( const int  ld_values,
const int  length_values,
const MED_EN::medModeSwitch  mode = MED_EN::MED_FULL_INTERLACE 
)

This constructor does allocation and does not set values :
.

It allocates a "T" array of length_values*ld_values length.
You don't have to know the T values when calling this construtor but you have to call "set" method to initialize them later. You also can get the pointer to the memory zone (with "get" method), and work with it.
The desallocation of T array is not your responsability.

Throws MEDEXCEPTION if T array length is < 1

Definition at line 154 of file MEDMEM_Array.hxx.

                                                                        :

                                                _ldValues(ld_values),
                                                _lengthValues(length_values),
                                                _mode(mode),
                                                _valuesFull(), _valuesNo(),
                                                _valuesDefault(),_valuesOther()
{
  //  BEGIN_OF_MED("constructor MEDARRAY<T>::MEDARRAY(const int, const int, const medModeSwitch)");

  // if ld_values < 1 or length_values < 1
  // throws an exception
  // Pointers are setted to NULL

  if ((ld_values<1)|(length_values<1))
  {
        throw MEDEXCEPTION(LOCALIZED("MEDARRAY<T>::MEDARRAY(const int, const int, const medModeSwitch) : dimension < 1 !"));
  }

  if ( _mode == MED_EN::MED_FULL_INTERLACE)
  {
        _valuesFull.set(length_values*ld_values);
        _valuesDefault.set((T*) _valuesFull);
  }
  else
  {
        ASSERT_MED (_mode == MED_EN::MED_NO_INTERLACE);
        _valuesNo.set(length_values*ld_values);
        _valuesDefault.set((T*)_valuesNo);
  }

  ASSERT_MED( (T*)_valuesDefault != NULL);
//   SCRUTE_MED((T*)_valuesDefault);
//   SCRUTE_MED((T*)_valuesOther);
//   SCRUTE_MED((T*)_valuesNo);
//   SCRUTE_MED((T*)_valuesFull);

  //  END_OF_MED("constructor MEDARRAY<T>::MEDARRAY(const int, const int, const medModeSwitch ()");
}
template<class T>
MEDMEM::MEDARRAY< T >::MEDARRAY ( T *  values,
const int  ld_values,
const int  length_values,
const MED_EN::medModeSwitch  mode = MED_EN::MED_FULL_INTERLACE,
bool  shallowCopy = false,
bool  ownershipOfValues = false 
)

This constructor duplicate T*values.


                                Throws MEDEXCEPTION if  the lenght of T is < 1 

Definition at line 201 of file MEDMEM_Array.hxx.

                                                                 :
                                                _ldValues(ld_values),
                                                _lengthValues(length_values),
                                                _mode(mode),
                                                _valuesFull(),_valuesNo(),
                                                _valuesDefault(),_valuesOther()
{
  //  BEGIN_OF_MED("constructor MEDARRAY<T>::MEDARRAY(T* values, const int, const int, const medModeSwitch)");

  // if ld_values < 1 or length_values < 1, we could not allocate
  // throws an exception

  if ( (ld_values<1) | (length_values<1) )
  {
           throw MEDEXCEPTION(LOCALIZED("MEDARRAY<T>::MEDARRAY(T* values, const int, const medModeSwitch) : dimension < 1 !"));
  }
  if ( _mode == MED_EN::MED_FULL_INTERLACE)
  {
        if(shallowCopy)
          {
            if(ownershipOfValues)
              {
                _valuesFull.setShallowAndOwnership((const T*)values);
            }
            else
              {
                _valuesFull.set((const T*)values);
              }
          }
        else
          {
            _valuesFull.set(_ldValues*length_values,values);
          }
        _valuesDefault.set((T*)_valuesFull);
  }
  else
  {
        ASSERT_MED (_mode == MED_EN::MED_NO_INTERLACE);
        if(shallowCopy)
        {
          if(ownershipOfValues)
            {
              _valuesNo.setShallowAndOwnership((const T*)values);
            }
          else
            {
              _valuesNo.set((const T*)values);
            }
        }
        else
          _valuesNo.set(_ldValues*length_values,values);
        _valuesDefault.set((T*)_valuesNo);
  }
  ASSERT_MED( (T*)_valuesDefault != NULL);
//   SCRUTE_MED((T*)_valuesDefault);
//   SCRUTE_MED((T*)_valuesOther);
//   SCRUTE_MED((T*)_valuesNo);
//   SCRUTE_MED((T*)_valuesFull);

  //  END_OF_MED("constructor MEDARRAY<T>::MEDARRAY(T* values, const int, const int, const medModeSwitch)");
}
template<class T>
MEDMEM::MEDARRAY< T >::MEDARRAY ( MEDARRAY< T > const &  m)

This constructor allocates a new medarray and does a copy of pointers
It DOES NOT copy the memory .

The two objects will share the same data.
(for copying data, use constructor MEDARRAY(MEDARRAY<T> const & m,bool copyOther).

Definition at line 273 of file MEDMEM_Array.hxx.

                                                              :
                                        _ldValues(m._ldValues),
                                        _lengthValues(m._lengthValues),
                                        _mode(m._mode),
                                        _valuesFull((const T*)m._valuesFull),
                                        _valuesNo((const T*)m._valuesNo),
                                        _valuesDefault((const T*)m._valuesDefault),
                                        _valuesOther((const T*)m._valuesOther)
{
  //  BEGIN_OF_MED("constructor MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & m)");
  ASSERT_MED( (T*)_valuesDefault != NULL);
//   SCRUTE_MED((T*)_valuesDefault);
//   SCRUTE_MED((T*)_valuesOther);
//   SCRUTE_MED((T*)_valuesNo);
//   SCRUTE_MED((T*)_valuesFull);
  //  END_OF_MED("constructor MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & m)");
}
template<class T>
MEDMEM::MEDARRAY< T >::MEDARRAY ( MEDARRAY< T > const &  m,
bool  copyOther 
)

This constructor allocates a new array and does a copy of values included in the m arrays.


If the boolean is setted to true, both representations (in full mode and no interlace mode) will be copied.
Otherwise, only _valuesDefault will be copied.
Desallocation of the arrays is not your reponsability.

Throws MEDEXCEPTION if _valuesOther is null and copyOther equals true

Definition at line 298 of file MEDMEM_Array.hxx.

                                                                             :
                                        _ldValues(p._ldValues),
                                        _lengthValues(p._lengthValues),
                                        _mode(p._mode),
                                        _valuesFull(),
                                        _valuesNo(),
                                        _valuesDefault(),
                                        _valuesOther()
{
  //  BEGIN_OF_MED("Constructeur deepCopy MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & m,bool copyOther");

  // PG : Non, s'il n'y a rien, on test et on ne copie rien, c'est tout !

//    if ( copyOther==true && ((const T*)p._valuesOther==NULL))
//      {
//        throw MEDEXCEPTION("MEDARRAY MEDARRAY const &m,bool copyOther : No Other values defined and bool = true !");
//      }

  if ( _mode == MED_EN::MED_FULL_INTERLACE)
    {
      _valuesFull.set(p._ldValues*p._lengthValues,(const T*)p._valuesFull);
      _valuesDefault.set((T*)_valuesFull);
      if (copyOther)
        if ((const T*)p._valuesNo != NULL)
          {
            _valuesNo.set(p._ldValues*p._lengthValues,(const T*)p._valuesNo);
            _valuesOther.set((T*)_valuesNo);
          }
    }
  else
    {
      ASSERT_MED (_mode == MED_EN::MED_NO_INTERLACE);
      _valuesNo.set(p._ldValues*p._lengthValues,(const T*)p._valuesNo);
      _valuesDefault.set((T*)_valuesNo);
      if (copyOther)
        if ((const T*)p._valuesFull != NULL)
          {
            _valuesFull.set(p._ldValues*p._lengthValues,(const T*)p._valuesFull);
            _valuesOther.set((T*)_valuesFull);
          }
    }
}

Member Function Documentation

template<class T >
void MEDMEM::MEDARRAY< T >::calculateOther ( )

Calculates the other mode of representation : MED_FULL_INTERLACE if __mode = MED_NO_INTERLACE and vice versa.


Throws exception if no value are setted

Definition at line 760 of file MEDMEM_Array.hxx.

{
  //  BEGIN_OF_MED("MEDARRAY<T>::calculateOther()");
  if ((T*)_valuesDefault == NULL)
  {
        throw MEDEXCEPTION("MEDARRAY::calculateOther() : No values defined !");
  }

  if ((T*)_valuesOther == NULL)
  {
        _valuesOther.set(_ldValues*_lengthValues);
  }
  if (_mode == MED_EN::MED_NO_INTERLACE)
  {
        _valuesFull.set((T*)_valuesOther);
  }
  else
  {
        ASSERT_MED( _mode==MED_EN::MED_FULL_INTERLACE);
        _valuesNo.set((T*)_valuesOther);
  }

  for (int i=0; i<_lengthValues;i++)
  {
        for (int j=0; j<_ldValues; j++)
        {
                if (_mode == MED_EN::MED_NO_INTERLACE)
                {
                        _valuesFull[i*_ldValues+j] = _valuesNo[j*_lengthValues+i];
                }
                else
                {
                        _valuesNo[j*_lengthValues+i]=_valuesFull[i*_ldValues+j];
                }
        }
  }
  //  END_OF_MED("MEDARRAY<T>::calculateOther()");
}
template<class T >
void MEDMEM::MEDARRAY< T >::clearOtherMode ( )

This function clears the other mode of representation if it exists It is usefull for people who needs for optimisation reasons to work directly on the inside array without using set-functions.

Definition at line 631 of file MEDMEM_Array.hxx.

{
    if(isOtherCalculated())
    {
        if ( _mode == MED_EN::MED_FULL_INTERLACE)
            _valuesNo.set(0);
        else
            _valuesFull.set(0);
        _valuesOther.set(0);
    }
}
template<class T >
const T * MEDMEM::MEDARRAY< T >::get ( const MED_EN::medModeSwitch  mode)

returns a pointer to _valuesDefault or _valuesOther, depending on mode value : if mode is the same as _mode, _valuesDefault is returned.

else, if _valuesOther is calculated (if necessary) and then returned. The pointer can be used to set values

Definition at line 430 of file MEDMEM_Array.hxx.

{
  //  BEGIN_OF_MED("MEDARRAY<T>::get(const medModeSwitch mode)");
  if ((T*)_valuesDefault == NULL)
  {
        throw MEDEXCEPTION("MEDARRAY::get(mode) : No values defined !");
  }
  if (mode == _mode)
  {
        //PN : pour enlever les warning compilateurs
        //return (const T*)_valuesDefault;
        return  (T*) _valuesDefault;
  }
  else
  {
        if ((T*)_valuesOther == NULL)
        {
                calculateOther();
        }
        //PN : pour enlever les warning compilateurs
        //return (const T*)_valuesDefault;
        return  (T*) _valuesOther;
  }
}

Here is the caller graph for this function:

template<class T >
const T * MEDMEM::MEDARRAY< T >::getColumn ( const int  j)

this method is similar to getRow method.


It returns a pointer to jth line of the array in a MED_NO-INTERLACE representation (for example, 2nd coordinates).
Be aware : if _mode is MED_FULL_INTERLACE, the entire array will be recalculate in MED_NO_INTERLACE representation.

Definition at line 497 of file MEDMEM_Array.hxx.

{
  if ((T*)_valuesDefault == NULL)
  {
        throw MEDEXCEPTION("MEDARRAY::getColumn(j) : No values defined !");
  }
  if (j<1)
  {
        throw MEDEXCEPTION("MEDARRAY::getColumn(j) : argument j must be >= 1");
  }
  if (j>_ldValues)
  {
        throw MEDEXCEPTION("MEDARRAY::getColumn(j) : argument j must be <= _ldValues");
  }

  if ((T*)_valuesNo == NULL)
  {
        ASSERT_MED(((T*) _valuesDefault)==((T*) _valuesFull));
        calculateOther();
  }
  //PN pour enlever les warning compilateur
  //const T* ptr = (const T*)_valuesNo + (j-1)*_lengthValues;
  const T* ptr = ( T*)_valuesNo + (j-1)*_lengthValues;

  return ptr;
}

Here is the caller graph for this function:

template<class T >
const T MEDMEM::MEDARRAY< T >::getIJ ( const int  i,
const int  j 
) const

returns Jth value of Ith element .


don't forget first element is element 1 (and not element 0).

Definition at line 528 of file MEDMEM_Array.hxx.

{

  if (i<1)
  {
        throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument i must be >= 1");
  }
  if (i>_lengthValues)
  {
        throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument i must be <= _lengthValues");
  }
  if (j<1)
  {
        throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument j must be >= 1");
  }
  if (j>_ldValues)
  {
        throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument j must be <= _ldValues");
  }

  if ( (const T*)_valuesDefault ==  NULL)
  {
        throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : No value in array !");
  }

  if (_mode == MED_EN::MED_FULL_INTERLACE)
  {
        return _valuesDefault[(i-1)*_ldValues+j-1];
  }
  else
  {
        return _valuesDefault[(j-1)*_lengthValues+i-1];
  }

}

Here is the caller graph for this function:

template<class T >
int MEDMEM::MEDARRAY< T >::getLeadingValue ( ) const [inline]

returns _ldValues.

(for example, space dimension for coordinates array)

Definition at line 411 of file MEDMEM_Array.hxx.

{
  return _ldValues;
}

Here is the caller graph for this function:

template<class T >
int MEDMEM::MEDARRAY< T >::getLengthValue ( ) const [inline]

returns _ldValues.

(for example, number of nodes for coordinates array)

Definition at line 419 of file MEDMEM_Array.hxx.

{
  return _lengthValues;
}

Here is the caller graph for this function:

template<class T >
MED_EN::medModeSwitch MEDMEM::MEDARRAY< T >::getMode ( ) const [inline]

returns the default mode (_mode)
(internal use : needed by write method)

Definition at line 568 of file MEDMEM_Array.hxx.

{
  return _mode;
}
template<class T >
const T * MEDMEM::MEDARRAY< T >::getRow ( const int  i)

returns a pointer to ith element of the array.

(ith line in a MED_FULL_INTERLACE representation )
Be aware : if _mode is MED_NO_INTERLACE, the entire array will be recalculate in MED_FULL_INTERLACE representation.

Definition at line 462 of file MEDMEM_Array.hxx.

{
  if ((T*)_valuesDefault == NULL)
  {
        throw MEDEXCEPTION("MEDARRAY::getRow(i) : No values defined !");
  }
  if (i<1)
  {
        throw MEDEXCEPTION("MEDARRAY::getRow(i) : argument i must be >= 1");
  }
  if (i>_lengthValues)
  {
        throw MEDEXCEPTION("MEDARRAY::getRow(i) : argument i must be <= _lengthValues");
  }

  if ((T*)_valuesFull == NULL)
  {
        calculateOther();
  }
  ASSERT_MED((T*)_valuesFull != NULL);

  // PN pour enlever les warning compilateurs
  //const T* ptr = (const T*)_valuesFull + (i-1)*_ldValues;
  const T* ptr =  (T*) _valuesFull + (i-1)*_ldValues;

  return ptr;
}

Here is the caller graph for this function:

template<class T>
bool MEDMEM::MEDARRAY< T >::isOtherCalculated ( ) const [inline]

Definition at line 119 of file MEDMEM_Array.hxx.

{return (const T*)_valuesOther != NULL;}
template<class T >
MEDARRAY< T > & MEDMEM::MEDARRAY< T >::operator= ( const MEDARRAY< T > &  m)

This operator makes a deep copy of the arrays.


Definition at line 345 of file MEDMEM_Array.hxx.

{

  //  BEGIN_OF_MED("Operator = MEDARRAY<T>");

  _ldValues=m._ldValues;
  _lengthValues=m._lengthValues;
  _mode=m._mode;

  //  SCRUTE_MED(_mode);

  if ((const T*) m._valuesFull !=NULL)
    _valuesFull.set(_ldValues*_lengthValues,(const T*) m._valuesFull);

  if ((const T*) m._valuesNo !=NULL)
    _valuesNo.set(_ldValues*_lengthValues,(const T*) m._valuesNo);

  if (_mode == MED_EN::MED_FULL_INTERLACE) {
    //PN : pour enlever les warning compilateur
    //_valuesDefault.set((const T*) _valuesFull);
    //_valuesOther.set((const T*) _valuesNo);
    _valuesDefault.set((T*) _valuesFull);
    _valuesOther.set((T*) _valuesNo);
  } else {
    ASSERT_MED (_mode == MED_EN::MED_NO_INTERLACE);
    //PN : pour enlever les warning compilateur
    //_valuesDefault.set((const T*) _valuesNo);
    //_valuesOther.set((const T*) _valuesFull);
    _valuesDefault.set((T*) _valuesNo);
    _valuesOther.set((T*) _valuesFull);
  }

//   SCRUTE_MED((T*)_valuesDefault);
//   SCRUTE_MED((T*)_valuesOther);
//   SCRUTE_MED((T*)_valuesNo);
//   SCRUTE_MED((T*)_valuesFull);

  //  END_OF_MED("Operator = MEDARRAY<T>");
  return *this;
}
template<class T>
void MEDMEM::MEDARRAY< T >::set ( const MED_EN::medModeSwitch  mode,
const T *  value 
)

sets T pointer of _valuesDefault (cf class PointerOf) on value.


no copy of value is done.
the other representation mode is not recalculate. the corresponding pointers are setted to null

Definition at line 604 of file MEDMEM_Array.hxx.

{
  //  BEGIN_OF_MED("MEDARRAY<T>::set(mode,value)");

  _mode = mode;
  if ( _mode == MED_EN::MED_FULL_INTERLACE)
    {
      _valuesFull.set(_ldValues*_lengthValues,value);
      _valuesDefault.set((T*)_valuesFull);
      _valuesNo.set(0);
    }
  else
    {
      ASSERT_MED (_mode == MED_EN::MED_NO_INTERLACE);
      _valuesNo.set(_ldValues*_lengthValues,value);
      _valuesDefault.set((T*)_valuesNo);
      _valuesFull.set(0);
    }
  _valuesOther.set(0);

  //  END_OF_MED("MEDARRAY<T>::set(mode,i,value)");
}

Here is the caller graph for this function:

template<class T>
void MEDMEM::MEDARRAY< T >::setI ( const int  i,
const T *  value 
)

Sets ith element to T* values
if they both exist, both _valuesFull and _valuesNo arrays will be updated.


Throws exception if i < 1 or i > _lengthValues

Definition at line 649 of file MEDMEM_Array.hxx.

{
  //  BEGIN_OF_MED("MEDARRAY<T>::setI(i,value)");

  if ((T*)_valuesDefault == NULL)
  {
        throw MEDEXCEPTION("MEDARRAY::setI(i,value) : No values defined !");
  }
  if (i<=0)
  {
      throw MEDEXCEPTION("MEDARRAY::setI(i,value) : argument i must be > 0");
  }
  if ( i > _lengthValues)
  {
     throw MEDEXCEPTION("MEDARRAY::setI(i,value) : argument i must be <= _lenghtValues");
  }

  if ((T*)_valuesFull != NULL)
  {
   for (int k = 0;k<_ldValues;k++)
   {
                _valuesFull[k+_ldValues*(i-1)] = value[k];
   }
  }

  if ((T*)_valuesNo != NULL)
  {
   for (int k = 0;k<_ldValues;k++)
   {
                _valuesNo[k*_lengthValues +(i-1)] = value[k];
   }
  }

  //  END_OF_MED("MEDARRAY::setI(i,value)");
}

Here is the caller graph for this function:

template<class T>
void MEDMEM::MEDARRAY< T >::setIJ ( const int  i,
const int  j,
const T  value 
)

Sets value of Jth coordinate of Ith element to T value.


Maintains coherency.
Throws exception if we don't have 1<=i<=_lengthValues and 1<=j<=_ldValues

Definition at line 728 of file MEDMEM_Array.hxx.

{
  // 1<=i<=_lengthValues and 1<=j<=_ldValues

  if (i<1)
    throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument i must be >= 1");
  if (i>_lengthValues)
    throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument i must be <= _lengthValues");

  if (j<1)
    throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument j must be >= 1");
  if (j>_ldValues)
    throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument j must be <= _ldValues");

  if ((T*)_valuesDefault == NULL)
  {
    throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : No value in array !");
  }

  if ((T*)_valuesFull != NULL)
  {
        _valuesFull[j-1+_ldValues*(i-1)] = value;
  }
  if ((T*)_valuesNo != NULL)
  {
        _valuesNo[(j-1)*_lengthValues+i-1] = value;
  }
}

Here is the caller graph for this function:

template<class T>
void MEDMEM::MEDARRAY< T >::setJ ( const int  j,
const T *  value 
)

Sets ith element to T* values
if they both exist, both _valuesFull and _valuesNo arrays will be updated.


Throws exception if i < 1 or i > _lengthValues

Definition at line 689 of file MEDMEM_Array.hxx.

{
  //  BEGIN_OF_MED("MEDARRAY::setJ(j,value)");
  if (( T*)_valuesDefault == NULL)
  {
        throw MEDEXCEPTION("MEDARRAY::setJ(j) : No values defined !");
  }
  if (j<1)
  {
        throw MEDEXCEPTION("MEDARRAY::setJ(j) : argument j must be >= 1");
  }
  if (j>_ldValues)
  {
        throw MEDEXCEPTION("MEDARRAY::setJ(j) : argument j must be <= _ldValues");
  }
  if ((T*)_valuesFull != NULL)
  {
   for (int k = 0;k<_lengthValues;k++)
   {
                _valuesFull[k*_ldValues+(j-1)] = value[k];
   }
  }

  if ((T*)_valuesNo != NULL)
  {
   for (int k = 0;k<_lengthValues;k++)
   {
                _valuesNo[k+_lengthValues*(j-1)] = value[k];
   }
  }
  //  END_OF_MED("MEDARRAY::setJ(j,value)");
}

Here is the caller graph for this function:

template<class T >
MEDARRAY< T > & MEDMEM::MEDARRAY< T >::shallowCopy ( const MEDARRAY< T > &  m)

Idem operator= but performs only shallow copy (just copy of pointers) of arrays contains in _valuesFull and _valuesNo
WARNING the MEDARRAY returned HAS THE OWNERSHIP OF THE ARRAY !!!!

Definition at line 389 of file MEDMEM_Array.hxx.

{
  _ldValues=m._ldValues;
  _lengthValues=m._lengthValues;
  _mode=m._mode;
  if ((const T*) m._valuesFull !=NULL)
    _valuesFull.setShallowAndOwnership((const T*) m._valuesFull);
  if ((const T*) m._valuesNo !=NULL)
    _valuesNo.setShallowAndOwnership((const T*) m._valuesNo);
  if (_mode == MED_EN::MED_FULL_INTERLACE) {
    _valuesDefault.set((T*) _valuesFull);
    _valuesOther.set((T*) _valuesNo);
  } else {
    _valuesDefault.set((T*) _valuesNo);
    _valuesOther.set((T*) _valuesFull);
  }
  return *this;
}

Here is the caller graph for this function:


Member Data Documentation

template<class T>
int MEDMEM::MEDARRAY< T >::_ldValues [private]

leading dimension of value (example : space dimension for coordinates)

Definition at line 68 of file MEDMEM_Array.hxx.

template<class T>
int MEDMEM::MEDARRAY< T >::_lengthValues [private]

length of values (example : number of nodes for coordinates)

Definition at line 70 of file MEDMEM_Array.hxx.

template<class T>
MED_EN::medModeSwitch MEDMEM::MEDARRAY< T >::_mode [private]

data access mode.

possible values are :

  • MED_FULL_INTERLACE (default mode)
  • MED_NO_INTERLACE

Definition at line 74 of file MEDMEM_Array.hxx.

template<class T>
PointerOf<T> MEDMEM::MEDARRAY< T >::_valuesDefault [private]

Pointer to representation in mode _mode.

Definition at line 80 of file MEDMEM_Array.hxx.

template<class T>
PointerOf<T> MEDMEM::MEDARRAY< T >::_valuesFull [private]

Pointer to representation in mode MED_FULL_INTERLACE.

Definition at line 76 of file MEDMEM_Array.hxx.

template<class T>
PointerOf<T> MEDMEM::MEDARRAY< T >::_valuesNo [private]

Pointer to representation in mode MED_NO_INTERLACE.

Definition at line 78 of file MEDMEM_Array.hxx.

template<class T>
PointerOf<T> MEDMEM::MEDARRAY< T >::_valuesOther [private]

Pointer to representation in the other mode (!=_mode)

Definition at line 82 of file MEDMEM_Array.hxx.


The documentation for this class was generated from the following file: