+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Array.hxx
+// Module : MED
+
#ifndef __MEDARRAY_H__
#define __MEDARRAY_H__
/*!
A template class to generate an array of any particular type (int, long,
- float, double) for our purpose in the MED++ library.
+ float, double) for our purpose in the MED++ library./n/n
+
+ Arrays can be stored in MED_FULL_INTERLACE mode (ie : x1,y1,z1,x2,y2,z2...) or
+ in MED_NO_INTERLACE mode ( x1,x2,..xn, y1, y2 ..,yn,z1,...,zn)./n The alternate
+ representation mode is calculate ONLY when it is usefull. We assure coherency
+ for minor data modifications (element, line or column) if you use set methods.
+ But, if you get a pointer and modify the array, no automatical coherency is possible.
+ You can use calculateOther to force a recalculation and insure the coherency./n
+ No recalculation is done, when the entire array is modified./n
+ Theses arrays are "Med like" arrays; lower bound equals 1. (first element is element 1,
+ first coordinate is coordinate 1). /n
+
+ Available constructors are :/n
+
+ - default constructor (not very usefull)/n
+ - constructor asking for array dimensions and mode (does memory allocation for you)/n
+ - constructor asking for array dimensions, mode and values (doesn't do memory allocation
+ but copies pointers only.)/n
+ - a copy constructor which copies only pointers./n
+ (be aware of coherency)
+ - a copy constructor which copies data (deepcopy)./n
+ - assignement operator is also available and only copies pointers (and not data)./n/n
+
+ Attribute "pointers" aren't standard pointers but class PointerOf objects in order to simplify
+ memory management./n
+
+ A simple test program (testUArray) allows to test this class.
*/
-template <class T> class MEDARRAY
-// Class Template MEDARRAY
-// template to generate an array of any
-// particular type (int, long, float, double)
-// for our purpose in the MED++ library
+template <class T> class MEDARRAY
{
private :
- med_int _ldValues; // leading dimension of value (example : space dimension with coordinates)
- med_int _lengthValues; // length of values (example : number of nodes with coordinates)
- medModeSwitch _mode; // data access mode:
- // MED_FULL_INTERLACE (default mode)
- // or MED_NO_INTERLACE
- PointerOf <T> _valuesDefault; // in _mode representation
- PointerOf <T> _valuesOther; // in other _mode representation
+
+ /*! leading dimension of value (example : space dimension for coordinates) */
+ med_int _ldValues;
+ /*! length of values (example : number of nodes for coordinates) */
+ med_int _lengthValues;
+ /*! data access mode. possible values are :\n
+ - MED_FULL_INTERLACE (default mode) \n
+ - MED_NO_INTERLACE */
+ medModeSwitch _mode;
+ /*! Pointer to representation in mode MED_FULL_INTERLACE */
+ PointerOf <T> _valuesFull;
+ /*! Pointer to representation in mode MED_NO_INTERLACE */
+ PointerOf <T> _valuesNo;
+ /*! Pointer to representation in mode _mode */
+ PointerOf <T> _valuesDefault;
+ /*! Pointer to representation in the other mode (!=_mode) */
+ PointerOf <T> _valuesOther;
public :
- MEDARRAY(): _ldValues(0), _lengthValues(0), _mode(MED_FULL_INTERLACE),
- _valuesDefault(), _valuesOther()
- {
- };
- ~MEDARRAY()
- {
- };
-
-
- // the following constructor are for the generation
- // with the default or not _mode
+ inline MEDARRAY();
+ inline ~MEDARRAY();
+
+ MEDARRAY (const med_int ld_values, const med_int length_values,
+ const medModeSwitch mode=MED_FULL_INTERLACE);
+ MEDARRAY (T* values, const med_int ld_values,
+ const med_int length_values, const medModeSwitch mode=MED_FULL_INTERLACE);
+ MEDARRAY (MEDARRAY const &m);
+ MEDARRAY (MEDARRAY const &m, bool copyOther);
+ MEDARRAY & operator = (const MEDARRAY & m);
+
+ inline med_int getLeadingValue() const;
+ inline med_int getLengthValue() const;
+
+ const T * get (const medModeSwitch mode) ;
+ const T * getRow (const med_int i) ;
+ const T * getColumn (const med_int j) ;
+ const T getIJ (const med_int i, const med_int j) const;
+// T * const get (const medModeSwitch mode) const;
+// T * const getRow (const med_int i) const;
+// T * const getColumn (const med_int j) const;
+// T const getIJ (const med_int i, const med_int j) const;
+
+ inline medModeSwitch getMode() const;
+
+ void set (const medModeSwitch mode,const T* value);
+ void setI (const med_int i, const T* value);
+ void setJ (const med_int j, const T* value);
+ void setIJ (const med_int i, const med_int j, const T value);
+
+ void calculateOther();
+};
- MEDARRAY(const med_int ld_values, const med_int length_values,
- const medModeSwitch mode=MED_FULL_INTERLACE) ;
+//-------------------------------------------------//
+// //
+// IMPLEMENTED CODE //
+// //
+//-------------------------------------------------//
- MEDARRAY( T*values, const med_int ld_values,
- const med_int length_values, const medModeSwitch mode=MED_FULL_INTERLACE) ;
- MEDARRAY(MEDARRAY const &m );
+template <class T> inline MEDARRAY<T>::MEDARRAY():
+ _ldValues(0), _lengthValues(0), _mode(MED_FULL_INTERLACE),
+ _valuesFull(), _valuesNo(),
+ _valuesDefault(), _valuesOther()
+{
+};
- inline med_int getLeadingValue() const; // as Space Dimension with coordinates
- inline med_int getLengthValue() const; // as Number of Nodes with coordinates
-
- T * const get (const medModeSwitch mode) ;
- T * const getI (const medModeSwitch mode, const med_int i) ;
- T const getIJ (const med_int i, const med_int j) const;
+// ------------------
- // need by write, to get default mode !
- inline medModeSwitch getMode() const ;
-
- void set (medModeSwitch mode, T* value);
- void setI (medModeSwitch mode, med_int i, T* value);
- void setIJ (med_int i, med_int j, T value);
-
-private:
- void calculateOther() ;
- void allocateOther();
- void updateDefault();
+template <class T> inline MEDARRAY<T>::~MEDARRAY()
+{
};
+// ------------------
-// implemented code
+ /*! This constructor does allocation and does not set values : \n.
+ It allocates a "T" array of length_values*ld_values length.\n
+ 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./n
+ The desallocation of T array is not your responsability. \n\n
+ Throws MEDEXCEPTION if T array length is < 1*/
template <class T> MEDARRAY<T>::MEDARRAY(const med_int ld_values,
const med_int length_values,
const medModeSwitch mode):
+
_ldValues(ld_values),
_lengthValues(length_values),
_mode(mode),
- _valuesOther(),
- _valuesDefault(length_values*ld_values)
+ _valuesFull(), _valuesNo(),
+ _valuesDefault(),_valuesOther()
{
- BEGIN_OF("constructor MEDARRAY<T>::MEDARRAY(const med_int, const med_int, const medModeSwitch(= MED_FULL_INTERLACE))");
+ BEGIN_OF("constructor MEDARRAY<T>::MEDARRAY(const med_int, const med_int, const medModeSwitch)");
- // if could not allocate
+ // 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 med_int, const med_int, const medModeSwitch) : dimension < 1 !"));
+ throw MEDEXCEPTION(LOCALIZED("MEDARRAY<T>::MEDARRAY(const med_int, const med_int, const medModeSwitch) : dimension < 1 !"));
+ }
+
+ if ( _mode == MED_FULL_INTERLACE)
+ {
+ _valuesFull.set(length_values*ld_values);
+ _valuesDefault.set((T*) _valuesFull);
+ }
+ else
+ {
+ ASSERT (_mode == MED_NO_INTERLACE);
+ _valuesNo.set(length_values*ld_values);
+ _valuesDefault.set((T*)_valuesNo);
}
+ ASSERT( (T*)_valuesDefault != NULL);
SCRUTE((T*)_valuesDefault);
SCRUTE((T*)_valuesOther);
- SCRUTE(_ldValues);
- SCRUTE(_lengthValues);
- SCRUTE(_mode);
+ SCRUTE((T*)_valuesNo);
+ SCRUTE((T*)_valuesFull);
- END_OF("constructor MEDARRAY<T>::MEDARRAY(const med_int, const med_int, const medModeSwitch (= MED_FULL_INTERLACE))");
+ END_OF("constructor MEDARRAY<T>::MEDARRAY(const med_int, const med_int, const medModeSwitch ()");
}
+// ------------------
+
+ /*! This constructor duplicate T*values.\n
+
+ Throws MEDEXCEPTION if the lenght of T is < 1*/
template <class T> MEDARRAY<T>::MEDARRAY( T*values,
const med_int ld_values,
const med_int length_values,
- const medModeSwitch mode):
+ const medModeSwitch mode):
_ldValues(ld_values),
_lengthValues(length_values),
_mode(mode),
- _valuesOther()
+ _valuesFull(),_valuesNo(),
+ _valuesDefault(),_valuesOther()
{
- _valuesDefault.set(values);
-}
+ BEGIN_OF("constructor MEDARRAY<T>::MEDARRAY(T* values, const med_int, const med_int, const medModeSwitch)");
-template <class T> MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & m ):
- _ldValues(m._ldValues),
- _lengthValues(m._lengthValues),
- _mode(m._mode),
- _valuesDefault((int)m._ldValues*m._lengthValues)
-{
- if ( m._ldValues*m._lengthValues >= 0 )
+ // if ld_values < 1 or length_values < 1, we could not allocate
+ // throws an exception
+
+ if ( (ld_values<1) | (length_values<1) )
{
- memcpy((T*)_valuesDefault,(const T* const)m._valuesDefault,m._ldValues*m._lengthValues*sizeof(T));
+ throw MEDEXCEPTION(LOCALIZED("MEDARRAY<T>::MEDARRAY(T* values, const med_int, const medModeSwitch) : dimension < 1 !"));
}
- if ((const T* const)(m._valuesOther) != NULL)
+ if ( _mode == MED_FULL_INTERLACE)
{
- _valuesOther.set(m._ldValues*m._lengthValues);
- memcpy((T*)_valuesOther,(const T* const)m._valuesOther,m._ldValues*m._lengthValues*sizeof(T));
+ _valuesFull.set(_ldValues*length_values,values);
+ _valuesDefault.set((T*)_valuesFull);
}
else
{
- _valuesOther.set(0);
+ ASSERT (_mode == MED_NO_INTERLACE);
+ _valuesNo.set(_ldValues*length_values,values);
+ _valuesDefault.set((T*)_valuesNo);
}
-}
-template <class T> inline med_int MEDARRAY<T>::getLeadingValue() const
-{
- return _ldValues ;
-};
+ ASSERT( (T*)_valuesDefault != NULL);
+ SCRUTE((T*)_valuesDefault);
+ SCRUTE((T*)_valuesOther);
+ SCRUTE((T*)_valuesNo);
+ SCRUTE((T*)_valuesFull);
-template <class T> inline med_int MEDARRAY<T>::getLengthValue() const
-{
- return _lengthValues ;
-};
+ END_OF("constructor MEDARRAY<T>::MEDARRAY(T* values, const med_int, const med_int, const medModeSwitch)");
+}
-template <class T> T* const MEDARRAY<T>::get(const medModeSwitch mode)
+// ------------------
+
+ /*! This constructor allocates a new medarray and does a copy of pointers/n
+ It DOES NOT copy the memory . The two objects will share the same data./n
+ (for copying data, use constructor MEDARRAY(MEDARRAY<T> const & m,bool copyOther). */
+template <class T> MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & m ):
+ _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)
{
- if ((T*)_valuesDefault != NULL)
- if (mode == _mode)
- {
- return _valuesDefault;
- }
- else
- {
- calculateOther() ;
- return _valuesOther ;
- }
- throw MEDEXCEPTION("MEDARRAY::get(mode) : No values defined !");
+ BEGIN_OF("constructor MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & m)");
+ ASSERT( (T*)_valuesDefault != NULL);
+ SCRUTE((T*)_valuesDefault);
+ SCRUTE((T*)_valuesOther);
+ SCRUTE((T*)_valuesNo);
+ SCRUTE((T*)_valuesFull);
+ END_OF("constructor MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & m)");
}
-template <class T> T* const MEDARRAY<T>::getI(const medModeSwitch mode,const med_int i)
+ /*! This constructor allocates a new array and does a copy of values
+ included in the m arrays./n
+ If the boolean is setted to true, both representations (in full mode
+ and no interlace mode) will be copied./n
+ Otherwise, only _valuesDefault will be copied./n
+ Desallocation of the arrays is not your reponsability./n/n
+ Throws MEDEXCEPTION if _valuesOther is null and copyOther equals true*/
+template <class T> MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & p,bool copyOther ):
+ _ldValues(p._ldValues),
+ _lengthValues(p._lengthValues),
+ _mode(p._mode),
+ _valuesDefault(),
+ _valuesNo(),
+ _valuesFull(),
+ _valuesOther()
{
- // 1<=i<=_lengthValues and return an array of _ldValues length
- // if MED_FULL_INTERLACE
- // 1<=i<=_ldValues and return an array of _lengthValues length
- // if MED_NO_INTERLACE
-
- if (i<=0)
- throw MEDEXCEPTION("MEDARRAY::getI(mode,i) : argument i must be > 0");
+ BEGIN_OF("Constructeur deepCopy MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & m,bool copyOther");
- if (( T* )_valuesDefault != NULL)
- {
- // if mode = MED_FULL_INTERLACE :
- int first = _ldValues ;
- int second = _lengthValues;
+ // PG : Non, s'il n'y a rien, on test et on ne copie rien, c'est tout !
- // else :
- if (mode == MED_NO_INTERLACE)
+// 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_FULL_INTERLACE)
{
- first = _lengthValues ;
- second = _ldValues ;
+ _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);
+ }
}
-
- if (i>second)
- throw MEDEXCEPTION("MEDARRAY::getI(mode,i) : argument i must be <= second");
-
- if (mode == _mode)
- return _valuesDefault + (i-1)*first ;
- else
+ else
{
- calculateOther() ;
- return _valuesOther + (i-1)*first ;
+ ASSERT (_mode == 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);
+ }
}
+}
+
+// ------------------
+
+// /*! This operator does a copy of pointers/n
+// It DOES NOT copy of the memory.
+// The two objects will share data./n */
+
+template <class T> MEDARRAY<T> & MEDARRAY<T>::MEDARRAY::operator = (const MEDARRAY & m)
+{
+
+ BEGIN_OF("Operator = MEDARRAY<T>");
+
+ _ldValues=m._ldValues;
+ _lengthValues=m._lengthValues;
+ _mode=m._mode;
+
+ SCRUTE(_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_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 (_mode == 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);
}
- throw MEDEXCEPTION("MEDARRAY::getI(mode,i) : No values defined !");
+
+ SCRUTE((T*)_valuesDefault);
+ SCRUTE((T*)_valuesOther);
+ SCRUTE((T*)_valuesNo);
+ SCRUTE((T*)_valuesFull);
+
+ END_OF("Operator = MEDARRAY<T>");
+ return *this;
}
+// ------------------
-template <class T> T const MEDARRAY<T>::getIJ(const med_int i,const med_int j) const
+ /*! returns _ldValues. (for example, space dimension for coordinates array)*/
+template <class T> inline med_int MEDARRAY<T>::getLeadingValue() const
{
- // 1<=i<=_lengthValues and 1<j<_ldValues
+ return _ldValues;
+};
- 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");
+ /*! returns _ldValues. (for example, number of nodes for coordinates array)*/
+template <class T> inline med_int MEDARRAY<T>::getLengthValue() const
+{
+ return _lengthValues;
+};
+
+// ------------------
- if ( (const T* const)_valuesDefault != NULL)
+ /*! 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 */
+template <class T> const T* MEDARRAY<T>::get(const medModeSwitch mode)
+{
+ BEGIN_OF("MEDARRAY<T>::get(const medModeSwitch mode)");
+ if ((T*)_valuesDefault == NULL)
{
- switch (_mode)
- {
- case MED_FULL_INTERLACE :
- {
- return _valuesDefault[(i-1)*_ldValues+j-1];
- }
- case MED_NO_INTERLACE :
+ 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)
{
- return _valuesDefault[(j-1)*_lengthValues+i-1];
+ calculateOther();
}
- }
- }
- else
- throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : No value in array !");
+ //PN : pour enlever les warning compilateurs
+ //return (const T*)_valuesDefault;
+ return (T*) _valuesOther;
+ }
+ END_OF("MEDARRAY<T>::get(const medModeSwitch mode)");
}
-template <class T> inline medModeSwitch MEDARRAY<T>::getMode() const
-{
- return _mode ;
-}
+// ------------------
-template <class T> void MEDARRAY<T>::set(medModeSwitch mode, T* value)
+ /*! returns a pointer to ith element of the array.
+ (ith line in a MED_FULL_INTERLACE representation )/n
+ Be aware : if _mode is MED_NO_INTERLACE, the entire
+ array will be recalculate in MED_FULL_INTERLACE representation./n*/
+
+template <class T> const T* MEDARRAY<T>::getRow(const med_int i)
{
- BEGIN_OF("MEDARRAY<T>::set(mode,i,value)");
+ BEGIN_OF("MEDARRAY<T>::getRow(const med_int i)");
- SCRUTE(_ldValues);
- SCRUTE(_lengthValues);
- SCRUTE((T*)_valuesDefault);
- SCRUTE((T*)_valuesOther);
- SCRUTE(_mode);
- SCRUTE(mode);
- SCRUTE(value);
-
- if ((T*)_valuesDefault != NULL)
- {
- if (mode == _mode)
- {
- _valuesDefault = value ;
- if ((T*)_valuesOther != NULL) calculateOther() ;
- }
- else
- {
- allocateOther() ;
- _valuesOther = value ;
- updateDefault() ;
- }
- }
- else
- {
- throw MEDEXCEPTION("MEDARRAY::set(mode,value) : No values defined !");
- }
+ 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");
+ }
- END_OF("MEDARRAY<T>::set(mode,i,value)");
+ if ((T*)_valuesFull == NULL)
+ {
+ ASSERT(((T*) _valuesDefault)==((T*) _valuesNo));
+ calculateOther();
+ }
+ ASSERT((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;
+
+ END_OF("MEDARRAY<T>::getRow(const med_int i )");
+ return ptr;
}
+// ------------------
+
+ /*! this method is similar to getRow method./n
+ It returns a pointer to jth line of the array in a MED_NO-INTERLACE representation
+ (for example, 2nd coordinates)./n
+ Be aware : if _mode is MED_FULL_INTERLACE, the entire
+ array will be recalculate in MED_NO_INTERLACE representation./n*/
-template <class T> void MEDARRAY<T>::setI(medModeSwitch mode, med_int i, T* value)
+template <class T> const T* MEDARRAY<T>::getColumn(const med_int j)
{
- BEGIN_OF("MEDARRAY<T>::setI(mode,i,value)");
+ BEGIN_OF("MEDARRAY<T>::getColumn(const med_int j)");
+ 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");
+ }
- SCRUTE(i);
- SCRUTE(_ldValues);
- SCRUTE(_lengthValues);
- SCRUTE((T*)_valuesDefault);
- SCRUTE((T*)_valuesOther);
- SCRUTE(_mode);
- SCRUTE(mode);
+ if ((T*)_valuesNo == NULL)
+ {
+ ASSERT(((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;
- // 1<=i<=_lengthValues and return an array of _ldValues length
- // if MED_FULL_INTERLACE
- // 1<=i<=_ldValues and return an array of _lengthValues length
- // if MED_NO_INTERLACE
+ return ptr;
+}
- if (i<=0)
+// ------------------
+
+ /*! returns Jth value of Ith element .\n
+ don't forget first element is element 1 (and not element 0). */
+template <class T> const T MEDARRAY<T>::getIJ(const med_int i,const med_int j) const
+{
+ BEGIN_OF("MEDARRAY<T>::getIJ(const med_int i, const med_int j)");
+ if (i<1)
+ {
+ throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument i must be >= 1");
+ }
+ if (i>_lengthValues)
{
- throw MEDEXCEPTION("MEDARRAY::setI(mode,i,value) : argument i must be > 0");
+ throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument i must be <= _lengthValues");
}
- if ((T*)_valuesDefault != NULL)
+ if (j<1)
{
- int first = _ldValues;
- int second = _lengthValues;
+ 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 (mode == MED_NO_INTERLACE)
- {
- first = _lengthValues;
- second = _ldValues;
- }
- SCRUTE(second);
+ if ( (const T*)_valuesDefault == NULL)
+ {
+ throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : No value in array !");
+ }
- if ( i > second)
- {
- SCRUTE(i);
- SCRUTE(second);
- throw MEDEXCEPTION("MEDARRAY::setI(mode,i,value) : argument i must be <= second");
- }
- if (mode == _mode)
+ if (_mode == MED_FULL_INTERLACE)
+ {
+ return _valuesDefault[(i-1)*_ldValues+j-1];
+ }
+ else
+ {
+ return _valuesDefault[(j-1)*_lengthValues+i-1];
+ }
+ END_OF("MEDARRAY<T>::getIJ(const med_int i, const med_int j)");
+}
+
+// ------------------
+
+ /*! returns the default mode (_mode)/n
+ (internal use : needed by write method) */
+template <class T> inline medModeSwitch MEDARRAY<T>::getMode() const
+{
+ BEGIN_OF("MEDARRAY<T>::getMode()");
+ END_OF("MEDARRAY<T>::getMode()");
+ return _mode;
+}
+
+// ------------------
+
+ /*! sets T pointer of _valuesDefault (cf class PointerOf) on value.\n
+ no copy of value is done. \n
+ the other representation mode is not recalculate.
+ the corresponding pointers are setted to null */
+// template <class T> void MEDARRAY<T>::set(const medModeSwitch mode, const T* value)
+// {
+
+// BEGIN_OF("MEDARRAY<T>::set(mode,value)");
+
+// _mode = mode;
+// if ( _mode == MED_FULL_INTERLACE)
+// {
+// _valuesFull.set(value);
+// _valuesDefault.set((T*)_valuesFull);
+// _valuesNo.set(0);
+// }
+// else
+// {
+// ASSERT (_mode == MED_NO_INTERLACE);
+// _valuesNo.set(value);
+// _valuesDefault.set((T*)_valuesNo);
+// _valuesFull.set(0);
+// }
+// _valuesOther.set(0);
+// END_OF("MEDARRAY<T>::set(mode,i,value)");
+// }
+
+// set with duplication because we don't know were value come and
+// MEDARRAY must have properties on it !!!!
+template <class T> void MEDARRAY<T>::set(const medModeSwitch mode, const T* value)
+{
+ BEGIN_OF("MEDARRAY<T>::set(mode,value)");
+
+ _mode = mode;
+ if ( _mode == MED_FULL_INTERLACE)
{
- for (int k =0;k<first;k++)
- {
- (_valuesDefault + (i-1)*first)[k] = value[k];
- }
- if ((T*)_valuesOther != NULL)
- for (int k =0;k<first;k++)
- {
- _valuesOther[k*second+i-1] = value[k];
- }
+ _valuesFull.set(_ldValues*_lengthValues,value);
+ _valuesDefault.set((T*)_valuesFull);
+ _valuesNo.set(0);
}
- else
+ else
{
- allocateOther() ;
- // return _valuesOther + (i-1)*first = &value ;
- for (int k =0;k<second;k++)
- {
- _valuesOther[(i-1)*first+k-1] = value[k];
- _valuesDefault[k*second+i-1] = value[k];
- }
+ ASSERT (_mode == MED_NO_INTERLACE);
+ _valuesNo.set(_ldValues*_lengthValues,value);
+ _valuesDefault.set((T*)_valuesNo);
+ _valuesFull.set(0);
}
+ _valuesOther.set(0);
+
+ END_OF("MEDARRAY<T>::set(mode,i,value)");
+}
+
+
+
+// ------------------
+
+ /*! Sets ith element to T* values\n
+ if they both exist, both _valuesFull and _valuesNo arrays will be updated./n
+ Throws exception if i < 1 or i > _lengthValues */
+template <class T> void MEDARRAY<T>::setI(const med_int i, const T* value)
+{
+ BEGIN_OF("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");
}
- else
+ if ( i > _lengthValues)
+ {
+ throw MEDEXCEPTION("MEDARRAY::setI(i,value) : argument i must be <= _lenghtValues");
+ }
+
+ if ((T*)_valuesFull != NULL)
{
- throw MEDEXCEPTION("MEDARRAY::setI(mode,i,value) : No values defined !");
+ for (int k = 0;k<_ldValues;k++)
+ {
+ _valuesFull[k+_ldValues*(i-1)] = value[k];
+ }
}
- SCRUTE((T*) _valuesDefault);
- SCRUTE((T*) _valuesOther);
+ if ((T*)_valuesNo != NULL)
+ {
+ for (int k = 0;k<_ldValues;k++)
+ {
+ _valuesNo[k*_lengthValues +(i-1)] = value[k];
+ }
+ }
- END_OF("MEDARRAY::setI(mode,i,value)");
+ END_OF("MEDARRAY::setI(i,value)");
}
+// ------------------
-template <class T> void MEDARRAY<T>::setIJ(med_int i, med_int j, T value)
+ /*! Sets ith element to T* values\n
+ if they both exist, both _valuesFull and _valuesNo arrays will be updated./n
+ Throws exception if i < 1 or i > _lengthValues */
+template <class T> void MEDARRAY<T>::setJ(const med_int j, const T* value)
+{
+ BEGIN_OF("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("MEDARRAY::setJ(j,value)");
+}
+
+// ------------------
+
+ /*! Sets value of Jth coordinate of Ith element to T value./n
+ Maintains coherency./n
+ Throws exception if we don't have
+ 1<=i<=_lengthValues and 1<=j<=_ldValues */
+template <class T> void MEDARRAY<T>::setIJ(const med_int i, const med_int j, const T value)
{
// 1<=i<=_lengthValues and 1<=j<=_ldValues
- if (i<1)
+ if (i<1)
throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument i must be >= 1");
- if (i>_lengthValues)
+ if (i>_lengthValues)
throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument i must be <= _lengthValues");
- if (j<1)
+ if (j<1)
throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument j must be >= 1");
- if (j>_ldValues)
+ if (j>_ldValues)
throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument j must be <= _ldValues");
- if ((T*)_valuesDefault != NULL)
- {
- switch (_mode)
- {
- case MED_FULL_INTERLACE :
- {
- _valuesDefault[(i-1)*_ldValues+j-1] = value;
- break;
- }
- case MED_NO_INTERLACE :
- {
- _valuesDefault[(j-1)*_lengthValues+i-1] = value;
- break;
- }
- }
- }
- else
+ if ((T*)_valuesDefault == NULL)
{
throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : No value in array !");
- }
-}
+ }
-template <class T> void MEDARRAY<T>::calculateOther()
-{
- BEGIN_OF("MEDARRAY<T>::calculateOther()") ;
- SCRUTE((T*)_valuesDefault);
- SCRUTE((T*)_valuesOther);
- if ((T*)_valuesDefault != NULL)
+ if ((T*)_valuesFull != NULL)
{
- //we allocate _valuesOther if needed
- if ((T*)_valuesOther == NULL)
- {
- _valuesOther.set(_ldValues*_lengthValues);
- }
-
- // we set _valuesOther
- int first = _ldValues ;
- int second = _lengthValues;
- if (_mode == MED_NO_INTERLACE)
- {
- first = _lengthValues ;
- second = _ldValues;
- }
- for (int i=0; i<first;i++)
- for (int j=0; j<second; j++)
- _valuesOther[i*second+j] = _valuesDefault[j*first+i];
+ _valuesFull[j-1+_ldValues*(i-1)] = value;
}
- else
+ if ((T*)_valuesNo != NULL)
{
- throw MEDEXCEPTION("MEDARRAY::calculateOther() : No values defined !");
+ _valuesNo[(j-1)*_lengthValues+i-1] = value;
}
- END_OF("MEDARRAY<T>::calculateOther()") ;
}
-template <class T> void MEDARRAY<T>::allocateOther()
+ /*! Calculates the other mode of representation : MED_FULL_INTERLACE
+ if __mode = MED_NO_INTERLACE and vice versa./n
+ Throws exception if no value are setted */
+template <class T> void MEDARRAY<T>::calculateOther()
{
- if ((T*)_valuesDefault != NULL)
+ BEGIN_OF("MEDARRAY<T>::calculateOther()");
+ if ((T*)_valuesDefault == NULL)
{
- if ((T*)_valuesOther == NULL)
- {
- // we set _valuesOther
- _valuesOther.set(_ldValues*_lengthValues);
- }
+ throw MEDEXCEPTION("MEDARRAY::calculateOther() : No values defined !");
}
- else
- throw MEDEXCEPTION("MEDARRAY::allocateOther() : No values defined !");
-}
-template <class T> void MEDARRAY<T>::updateDefault()
-{
- BEGIN_OF("MEDARRAY<T>::updateDefault()");
-
- if ((T*)_valuesDefault != NULL)
+ if ((T*)_valuesOther == NULL)
{
- if ((T*)_valuesOther != NULL)
- {
- // we update _valuesDefault with _valuesOther
- // if mode = MED_FULL_INTERLACE :
- int first = _ldValues ;
- int second = _lengthValues;
- // else :
- if (_mode == MED_NO_INTERLACE)
- {
- first = _lengthValues ;
- second = _ldValues;
- }
- for (int i=0; i<first;i++)
- for (int j=0; j<second; j++)
- _valuesDefault[j*first+i] = _valuesOther[i*second+j];
- }
- else
- {
- throw MEDEXCEPTION("MEDARRAY<T>::updateDefault() : No valuesOther defined !");
- }
+ _valuesOther.set(_ldValues*_lengthValues);
+ }
+ if (_mode == MED_NO_INTERLACE)
+ {
+ _valuesFull.set((T*)_valuesOther);
}
else
{
- throw MEDEXCEPTION("MEDARRAY<T>::updateDefault() : No values defined !");
+ ASSERT( _mode==MED_FULL_INTERLACE);
+ _valuesNo.set((T*)_valuesOther);
}
- END_OF("MEDARRAY<T>::updateDefault()");
+ for (int i=0; i<_lengthValues;i++)
+ {
+ for (int j=0; j<_ldValues; j++)
+ {
+ if (_mode == MED_NO_INTERLACE)
+ {
+ _valuesFull[i*_ldValues+j] = _valuesNo[j*_lengthValues+i];
+ }
+ else
+ {
+ _valuesNo[j*_lengthValues+i]=_valuesFull[i*_ldValues+j];
+ }
+ }
+ }
+ END_OF("MEDARRAY<T>::calculateOther()");
}
# endif /* # ifndef __MEDARRAY_H__ */
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_CellModel.cxx
+// Module : MED
+
using namespace std;
/*
File MEDMEM_CellModel.cxx
_numberOfVertexes=2;
_numberOfNodes=2;
// constituent are POINT1 and we have no need to define _constituents vector
-// vector<medGeometryElement> vector_type(2,MED_POINT1) ;
-// vector<medGeometryElement> __constituents_type[]={vector_type};
-// vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+1) ;
-// _constituentsType = _constituents_type ;
- //_constituentsType[2][1]={{MED_POINT1,MED_POINT1}} ;
_numberOfConstituentsDimension=1 ;
_numberOfConstituents=new int[1] ;
_numberOfConstituents[0]=2 ;
_numberOfVertexes=2;
_numberOfNodes=3;
// constituent are POINT1 and we have no need to define _constituents vector
-// vector<medGeometryElement> vector_type(3,MED_POINT1) ;
-// vector<medGeometryElement> __constituents_type[]={vector_type};
-// vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+1) ;
-// _constituentsType = _constituents_type ;
_numberOfConstituentsDimension=1 ;
_numberOfConstituents=new int[1] ;
_numberOfConstituents[0]=3 ;
tmpConstituentsType1[0] = MED_SEG2 ;
tmpConstituentsType1[1] = MED_SEG2 ;
tmpConstituentsType1[2] = MED_SEG2 ;
- medGeometryElement * tmpConstituentsType2 = new medGeometryElement[3] ;
- tmpConstituentsType2[0] = MED_POINT1 ;
- tmpConstituentsType2[1] = MED_POINT1 ;
- tmpConstituentsType2[2] = MED_POINT1 ;
- _constituentsType = new medGeometryElement*[2] ;
+// medGeometryElement * tmpConstituentsType2 = new medGeometryElement[3] ;
+// tmpConstituentsType2[0] = MED_POINT1 ;
+// tmpConstituentsType2[1] = MED_POINT1 ;
+// tmpConstituentsType2[2] = MED_POINT1 ;
+// _constituentsType = new medGeometryElement*[2] ;
+ _constituentsType = new medGeometryElement*[1] ;
_constituentsType[0]=tmpConstituentsType1 ;
- _constituentsType[1]=tmpConstituentsType2 ;
+// _constituentsType[1]=tmpConstituentsType2 ;
// Well, point are defined, but could not be acces because we have
// only 1 numberOfConstituentsDimension !
_dimension=2;
_numberOfVertexes=3;
_numberOfNodes=6;
-// int _edge1[]={1,2,4} ;
-// int _edge2[]={2,3,5} ;
-// int _edge3[]={3,1,6} ;
-// vector<int> edge1(_edge1,_edge1+3) ;
-// vector<int> edge2(_edge2,_edge2+3) ;
-// vector<int> edge3(_edge3,_edge3+3) ;
-// vector<int> _vector_edge[]={edge1,edge2,edge3};
-// vector< vector<int> > vector_edge(_vector_edge,_vector_edge+3) ;
-// vector< vector<int> > __constituents__[]={vector_edge};
-// vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+1) ;
-// _constituents = _constituents_ ;
_numberOfConstituentsDimension=1 ;
_numberOfConstituents=new int[1] ;
_numberOfConstituents[0]=3 ;
tmpConstituents1[2]=_edge3 ;
_constituents = new int**[1] ;
_constituents[0]=tmpConstituents1 ;
-// vector<medGeometryElement> vector_edge_type(3,MED_SEG3) ;
-// vector<medGeometryElement> vector_type(6,MED_POINT1) ;
-// vector<medGeometryElement> __constituents_type[]={vector_edge_type,vector_type};
-// vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
-// _constituentsType = _constituents_type ;
- //_constituentsType={{MED_SEG3,MED_SEG3,MED_SEG3},{MED_POINT1,MED_POINT1,MED_POINT1,MED_POINT1,MED_POINT1,MED_POINT1}} ;
medGeometryElement * tmpConstituentsType1 = new medGeometryElement[3] ;
tmpConstituentsType1[0] = MED_SEG3 ;
tmpConstituentsType1[1] = MED_SEG3 ;
tmpConstituentsType1[2] = MED_SEG3 ;
- medGeometryElement * tmpConstituentsType2 = new medGeometryElement[6] ;
- tmpConstituentsType2[0] = MED_POINT1 ;
- tmpConstituentsType2[1] = MED_POINT1 ;
- tmpConstituentsType2[2] = MED_POINT1 ;
- tmpConstituentsType2[3] = MED_POINT1 ;
- tmpConstituentsType2[4] = MED_POINT1 ;
- tmpConstituentsType2[5] = MED_POINT1 ;
- _constituentsType = new medGeometryElement*[2] ;
+// medGeometryElement * tmpConstituentsType2 = new medGeometryElement[6] ;
+// tmpConstituentsType2[0] = MED_POINT1 ;
+// tmpConstituentsType2[1] = MED_POINT1 ;
+// tmpConstituentsType2[2] = MED_POINT1 ;
+// tmpConstituentsType2[3] = MED_POINT1 ;
+// tmpConstituentsType2[4] = MED_POINT1 ;
+// tmpConstituentsType2[5] = MED_POINT1 ;
+// _constituentsType = new medGeometryElement*[2] ;
+ _constituentsType = new medGeometryElement*[1] ;
_constituentsType[0]=tmpConstituentsType1 ;
- _constituentsType[1]=tmpConstituentsType2 ;
+// _constituentsType[1]=tmpConstituentsType2 ;
// Well, point are defined, but could not be acces because we have
// only 1 numberOfConstituentsDimension !
_dimension=2;
_numberOfVertexes=4;
_numberOfNodes=4;
-// int _edge1[]={1,2} ;
-// int _edge2[]={2,3} ;
-// int _edge3[]={3,4} ;
-// int _edge4[]={4,1} ;
-// vector<int> edge1(_edge1,_edge1+2) ;
-// vector<int> edge2(_edge2,_edge2+2) ;
-// vector<int> edge3(_edge3,_edge3+2) ;
-// vector<int> edge4(_edge4,_edge4+2) ;
-// vector<int> _vector_edge[]={edge1,edge2,edge3,edge4};
-// vector< vector<int> > vector_edge(_vector_edge,_vector_edge+4) ;
-// vector< vector<int> > __constituents__[]={vector_edge};
-// vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+1) ;
-// _constituents = _constituents_ ;
- //_constituents={{{1,2},{2,3},{3,4},{4,1}}} ;
_numberOfConstituentsDimension=1 ;
_numberOfConstituents=new int[1] ;
_numberOfConstituents[0]=4 ;
tmpConstituents1[3]=_edge4 ;
_constituents = new int**[1] ;
_constituents[0]=tmpConstituents1 ;
-// vector<medGeometryElement> vector_edge_type(4,MED_SEG2) ;
-// vector<medGeometryElement> vector_type(4,MED_POINT1) ;
-// vector<medGeometryElement> __constituents_type[]={vector_edge_type,vector_type};
-// vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
-// _constituentsType = _constituents_type ;
- //_constituentsType={{MED_SEG2,MED_SEG2,MED_SEG2,MED_SEG2},{MED_POINT1,MED_POINT1,MED_POINT1,MED_POINT1}} ;
medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ;
tmpConstituentsType1[0] = MED_SEG2 ;
tmpConstituentsType1[1] = MED_SEG2 ;
tmpConstituentsType1[2] = MED_SEG2 ;
tmpConstituentsType1[3] = MED_SEG2 ;
- medGeometryElement * tmpConstituentsType2 = new medGeometryElement[4] ;
- tmpConstituentsType2[0] = MED_POINT1 ;
- tmpConstituentsType2[1] = MED_POINT1 ;
- tmpConstituentsType2[2] = MED_POINT1 ;
- tmpConstituentsType2[3] = MED_POINT1 ;
- _constituentsType = new medGeometryElement*[2] ;
+// medGeometryElement * tmpConstituentsType2 = new medGeometryElement[4] ;
+// tmpConstituentsType2[0] = MED_POINT1 ;
+// tmpConstituentsType2[1] = MED_POINT1 ;
+// tmpConstituentsType2[2] = MED_POINT1 ;
+// tmpConstituentsType2[3] = MED_POINT1 ;
+// _constituentsType = new medGeometryElement*[2] ;
+ _constituentsType = new medGeometryElement*[1] ;
_constituentsType[0]=tmpConstituentsType1 ;
- _constituentsType[1]=tmpConstituentsType2 ;
+// _constituentsType[1]=tmpConstituentsType2 ;
// Well, point are defined, but could not be acces because we have
// only 1 numberOfConstituentsDimension !
_dimension=2;
_numberOfVertexes=4;
_numberOfNodes=8;
-// int _edge1[]={1,2,5} ;
-// int _edge2[]={2,3,6} ;
-// int _edge3[]={3,4,7} ;
-// int _edge4[]={4,1,8} ;
-// vector<int> edge1(_edge1,_edge1+3) ;
-// vector<int> edge2(_edge2,_edge2+3) ;
-// vector<int> edge3(_edge3,_edge3+3) ;
-// vector<int> edge4(_edge4,_edge4+3) ;
-// vector<int> _vector_edge[]={edge1,edge2,edge3,edge4};
-// vector< vector<int> > vector_edge(_vector_edge,_vector_edge+4) ;
-// vector< vector<int> > __constituents__[]={vector_edge};
-// vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+1) ;
-// _constituents = _constituents_ ;
- //_constituents={{{1,2,5},{2,3,6},{3,4,7},{4,1,8}}} ;
_numberOfConstituentsDimension=1 ;
_numberOfConstituents=new int[1] ;
_numberOfConstituents[0]=4 ;
tmpConstituents1[3]=_edge4 ;
_constituents = new int**[1] ;
_constituents[0]=tmpConstituents1 ;
-// vector<medGeometryElement> vector_edge_type(4,MED_SEG3) ;
-// vector<medGeometryElement> vector_type(8,MED_POINT1) ;
-// vector<medGeometryElement> __constituents_type[]={vector_edge_type,vector_type};
-// vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
-// _constituentsType = _constituents_type ;
- //_constituentsType={{MED_SEG3,MED_SEG3,MED_SEG3,MED_SEG3},{MED_POINT1,MED_POINT1,MED_POINT1,MED_POINT1,MED_POINT1,MED_POINT1,MED_POINT1,MED_POINT1} ;
medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ;
tmpConstituentsType1[0] = MED_SEG3 ;
tmpConstituentsType1[1] = MED_SEG3 ;
tmpConstituentsType1[2] = MED_SEG3 ;
tmpConstituentsType1[3] = MED_SEG3 ;
- medGeometryElement * tmpConstituentsType2 = new medGeometryElement[4] ;
- tmpConstituentsType2[0] = MED_POINT1 ;
- tmpConstituentsType2[1] = MED_POINT1 ;
- tmpConstituentsType2[2] = MED_POINT1 ;
- tmpConstituentsType2[3] = MED_POINT1 ;
- tmpConstituentsType2[4] = MED_POINT1 ;
- tmpConstituentsType2[5] = MED_POINT1 ;
- tmpConstituentsType2[6] = MED_POINT1 ;
- tmpConstituentsType2[7] = MED_POINT1 ;
- _constituentsType = new medGeometryElement*[2] ;
+// medGeometryElement * tmpConstituentsType2 = new medGeometryElement[8] ;
+// tmpConstituentsType2[0] = MED_POINT1 ;
+// tmpConstituentsType2[1] = MED_POINT1 ;
+// tmpConstituentsType2[2] = MED_POINT1 ;
+// tmpConstituentsType2[3] = MED_POINT1 ;
+// tmpConstituentsType2[4] = MED_POINT1 ;
+// tmpConstituentsType2[5] = MED_POINT1 ;
+// tmpConstituentsType2[6] = MED_POINT1 ;
+// tmpConstituentsType2[7] = MED_POINT1 ;
+// _constituentsType = new medGeometryElement*[2] ;
+ _constituentsType = new medGeometryElement*[1] ;
_constituentsType[0]=tmpConstituentsType1 ;
- _constituentsType[1]=tmpConstituentsType2 ;
+// _constituentsType[1]=tmpConstituentsType2 ;
// Well, point are defined, but could not be acces because we have
// only 1 numberOfConstituentsDimension !
_dimension=3;
_numberOfVertexes=4;
_numberOfNodes=4;
-// int _edge1[]={1,2} ;
-// int _edge2[]={2,3} ;
-// int _edge3[]={3,1} ;
-// int _edge4[]={1,4} ;
-// int _edge5[]={2,4} ;
-// int _edge6[]={3,4} ;
-// vector<int> edge1(_edge1,_edge1+2) ;
-// vector<int> edge2(_edge2,_edge2+2) ;
-// vector<int> edge3(_edge3,_edge3+2) ;
-// vector<int> edge4(_edge4,_edge4+2) ;
-// vector<int> edge5(_edge5,_edge5+2) ;
-// vector<int> edge6(_edge6,_edge6+2) ;
-// vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6};
-// vector< vector<int> > vector_edge(_vector_edge,_vector_edge+6) ;
-// int _face1[]={1,2,3} ;
-// int _face2[]={1,4,2} ;
-// int _face3[]={2,4,3} ;
-// int _face4[]={3,4,1} ;
-// vector<int> face1(_face1,_face1+3) ;
-// vector<int> face2(_face2,_face2+3) ;
-// vector<int> face3(_face3,_face3+3) ;
-// vector<int> face4(_face4,_face4+3) ;
-// vector<int> _vector_face[] = {face1,face2,face3,face4} ;
-// vector< vector<int> > vector_face(_vector_face,_vector_face+4) ;
-// vector< vector<int> > __constituents__[]={vector_face,vector_edge};
-// vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
-// _constituents = _constituents_ ;
- //_constituents={{{1,2,3},{1,4,2},{2,4,3},{3,4,1}},{{1,2},{2,3},{3,1},{1,4},{2,4},{3,4}}} ;
_numberOfConstituentsDimension=2 ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=4 ;
_constituents = new int**[2] ;
_constituents[0]=tmpConstituents1 ;
_constituents[1]=tmpConstituents2 ;
-// vector<medGeometryElement> vector_edge_type(6,MED_SEG2) ;
-// vector<medGeometryElement> vector_face_type(4,MED_TRIA3) ;
-// vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
-// vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
-// _constituentsType = _constituents_type ;
- //_constituentsType={{MED_TRIA3,MED_TRIA3,MED_TRIA3,MED_TRIA3}{MED_SEG2,MED_SEG2,MED_SEG2,MED_SEG2,MED_SEG2,MED_SEG2}} ;
medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ;
tmpConstituentsType1[0] = MED_TRIA3 ;
tmpConstituentsType1[1] = MED_TRIA3 ;
_dimension=3;
_numberOfVertexes=4;
_numberOfNodes=10;
-// int _edge1[]={1,2,5} ;
-// int _edge2[]={2,3,6} ;
-// int _edge3[]={3,1,7} ;
-// int _edge4[]={1,4,8} ;
-// int _edge5[]={2,4,9} ;
-// int _edge6[]={3,4,10} ;
-// vector<int> edge1(_edge1,_edge1+3) ;
-// vector<int> edge2(_edge2,_edge2+3) ;
-// vector<int> edge3(_edge3,_edge3+3) ;
-// vector<int> edge4(_edge4,_edge4+3) ;
-// vector<int> edge5(_edge5,_edge5+3) ;
-// vector<int> edge6(_edge6,_edge6+3) ;
-// vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6};
-// vector< vector<int> > vector_edge(_vector_edge,_vector_edge+6) ;
-// int _face1[]={1,2,3,5,6,7} ;
-// int _face2[]={1,4,2,8,9,5} ;
-// int _face3[]={2,4,3,9,10,6} ;
-// int _face4[]={3,4,1,10,8,7} ;
-// vector<int> face1(_face1,_face1+6) ;
-// vector<int> face2(_face2,_face2+6) ;
-// vector<int> face3(_face3,_face3+6) ;
-// vector<int> face4(_face4,_face4+6) ;
-// vector<int> _vector_face[] = {face1,face2,face3,face4} ;
-// vector< vector<int> > vector_face(_vector_face,_vector_face+4) ;
-// vector< vector<int> > __constituents__[]={vector_face,vector_edge};
-// vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
-// _constituents = _constituents_ ;
- //_constituents={{{1,2,3,5,6,7},{1,4,2,8,9,5},{2,4,3,9,10,6},{3,4,1,10,8,7}},{{1,2,5},{2,3,6},{3,1,7},{1,4,8},{2,4,9},{3,4,10}}} ;
_numberOfConstituentsDimension=2 ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=4 ;
_constituents = new int**[2] ;
_constituents[0]=tmpConstituents1 ;
_constituents[1]=tmpConstituents2 ;
-// vector<medGeometryElement> vector_edge_type(6,MED_SEG3) ;
-// vector<medGeometryElement> vector_face_type(4,MED_TRIA6) ;
-// vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
-// vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
-// _constituentsType = _constituents_type ;
- //_constituentsType={{MED_TRIA6,MED_TRIA6,MED_TRIA6,MED_TRIA6}{MED_SEG3,MED_SEG3,MED_SEG3,MED_SEG3,MED_SEG3,MED_SEG3}} ;
medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ;
tmpConstituentsType1[0] = MED_TRIA6 ;
tmpConstituentsType1[1] = MED_TRIA6 ;
_dimension=3;
_numberOfVertexes=8;
_numberOfNodes=8;
-// int _edge1[]={1,2} ;
-// int _edge2[]={2,3} ;
-// int _edge3[]={3,4} ;
-// int _edge4[]={4,1} ;
-// int _edge5[]={5,6} ;
-// int _edge6[]={6,7} ;
-// int _edge7[]={7,8} ;
-// int _edge8[]={8,5} ;
-// int _edge9[]={1,5} ;
-// int _edge10[]={2,6} ;
-// int _edge11[]={3,7} ;
-// int _edge12[]={4,8} ;
-// vector<int> edge1(_edge1,_edge1+2) ;
-// vector<int> edge2(_edge2,_edge2+2) ;
-// vector<int> edge3(_edge3,_edge3+2) ;
-// vector<int> edge4(_edge4,_edge4+2) ;
-// vector<int> edge5(_edge5,_edge5+2) ;
-// vector<int> edge6(_edge6,_edge6+2) ;
-// vector<int> edge7(_edge7,_edge7+2) ;
-// vector<int> edge8(_edge8,_edge8+2) ;
-// vector<int> edge9(_edge9,_edge9+2) ;
-// vector<int> edge10(_edge10,_edge10+2) ;
-// vector<int> edge11(_edge11,_edge11+2) ;
-// vector<int> edge12(_edge12,_edge12+2) ;
-// vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9,edge10,edge11,edge12};
-// vector< vector<int> > vector_edge(_vector_edge,_vector_edge+12) ;
_numberOfConstituentsDimension=2 ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=6 ;
int* _edge12=new int[2];
_edge12[0]=4;
_edge12[1]=8;
-// int _face1[]={1,2,3,4} ;
-// int _face2[]={5,8,7,6} ;
-// int _face3[]={1,5,6,2} ;
-// int _face4[]={2,6,7,3} ;
-// int _face5[]={3,7,8,4} ;
-// int _face6[]={4,8,5,1} ;
-// vector<int> face1(_face1,_face1+4) ;
-// vector<int> face2(_face2,_face2+4) ;
-// vector<int> face3(_face3,_face3+4) ;
-// vector<int> face4(_face4,_face4+4) ;
-// vector<int> face5(_face5,_face5+4) ;
-// vector<int> face6(_face6,_face6+4) ;
-// vector<int> _vector_face[] = {face1,face2,face3,face4,face5,face6} ;
-// vector< vector<int> > vector_face(_vector_face,_vector_face+6) ;
-// vector< vector<int> > __constituents__[]={vector_face,vector_edge};
-// vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
-// _constituents = _constituents_ ;
int* _face1=new int[4];
_face1[0]=1;
_face1[1]=2;
_constituents = new int**[2] ;
_constituents[0]=tmpConstituents1 ;
_constituents[1]=tmpConstituents2 ;
-// vector<medGeometryElement> vector_edge_type(12,MED_SEG2) ;
-// vector<medGeometryElement> vector_face_type(6,MED_QUAD4) ;
-// vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
-// vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2);
-// _constituentsType = _constituents_type ;
medGeometryElement * tmpConstituentsType1 = new medGeometryElement[6] ;
tmpConstituentsType1[0] = MED_QUAD4 ;
tmpConstituentsType1[1] = MED_QUAD4 ;
_dimension=3;
_numberOfVertexes=8;
_numberOfNodes=20;
-
-// int _edge1[]={1,2,9} ;
-// int _edge2[]={2,3,10} ;
-// int _edge3[]={3,4,11} ;
-// int _edge4[]={4,1,12} ;
-// int _edge5[]={5,6,13} ;
-// int _edge6[]={6,7,14};
-// int _edge7[]={7,8,15} ;
-// int _edge8[]={8,5,16} ;
-// int _edge9[]={1,5,17} ;
-// int _edge10[]={2,6,18} ;
-// int _edge11[]={3,7,19} ;
-// int _edge12[]={4,8,20} ;
-
-// vector<int> edge1(_edge1,_edge1+3) ;
-// vector<int> edge2(_edge2,_edge2+3) ;
-// vector<int> edge3(_edge3,_edge3+3) ;
-// vector<int> edge4(_edge4,_edge4+3) ;
-// vector<int> edge5(_edge5,_edge5+3) ;
-// vector<int> edge6(_edge6,_edge6+3) ;
-// vector<int> edge7(_edge7,_edge7+3) ;
-// vector<int> edge8(_edge8,_edge8+3) ;
-// vector<int> edge9(_edge9,_edge9+3) ;
-// vector<int> edge10(_edge10,_edge10+3) ;
-// vector<int> edge11(_edge11,_edge11+3) ;
-// vector<int> edge12(_edge12,_edge12+3) ;
-// vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9,edge10, edge11,edge12};
-// vector< vector<int> > vector_edge(_vector_edge,_vector_edge+12) ;
-
-// int _face1[]={1,2,3,4,9,10,11,12} ;
-// int _face2[]={5,8,7,6,16,15,14,13} ;
-// int _face3[]={1,5,6,2,17,13,18,9} ;
-// int _face4[]={2,6,7,3,18,14,19,10} ;
-// int _face5[]={3,7,8,4,19,15,20,11} ;
-// int _face6[]={4,8,5,1,20,16,17,12} ;
-// vector<int> face1(_face1,_face1+8);
-// vector<int> face2(_face2,_face2+8);
-// vector<int> face3(_face3,_face3+8);
-// vector<int> face4(_face4,_face4+8);
-// vector<int> face5(_face5,_face5+8);
-// vector<int> face6(_face6,_face6+8);
-// vector<int> _vector_face[]= {face1,face2,face3,face4,face5,face6} ;
-// vector< vector<int> > vector_face(_vector_face,_vector_face+6);
-
-// vector< vector<int> > __constituents__[]={vector_face,vector_edge};
-// vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
-// _constituents = _constituents_ ;
_numberOfConstituentsDimension=2 ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=6 ;
int* _edge1=new int[3];
_edge1[0]=1;
_edge1[1]=2;
- _edge1[1]=9;
+ _edge1[2]=9;
int* _edge2=new int[3];
_edge2[0]=2;
_edge2[1]=3;
- _edge2[1]=10;
+ _edge2[2]=10;
int* _edge3=new int[3];
_edge3[0]=3;
_edge3[1]=4;
_constituents = new int**[2] ;
_constituents[0]=tmpConstituents1 ;
_constituents[1]=tmpConstituents2 ;
-// vector<medGeometryElement> vector_edge_type(12,MED_SEG3) ;
-// vector<medGeometryElement> vector_face_type(6,MED_QUAD8) ;
-// vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
-// vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
-// _constituentsType = _constituents_type ;
medGeometryElement * tmpConstituentsType1 = new medGeometryElement[6] ;
tmpConstituentsType1[0] = MED_QUAD8 ;
tmpConstituentsType1[1] = MED_QUAD8 ;
_numberOfVertexes=6;
_numberOfNodes=6;
-// int _edge1[]= {1,2} ;
-// int _edge2[]= {2,3} ;
-// int _edge3[]= {3,1} ;
-// int _edge4[]= {4,5} ;
-// int _edge5[]= {5,6} ;
-// int _edge6[]= {6,4} ;
-// int _edge7[]= {1,4} ;
-// int _edge8[]= {2,5} ;
-// int _edge9[]= {3,6} ;
-
-// vector<int> edge1(_edge1,_edge1+2) ;
-// vector<int> edge2(_edge2,_edge2+2) ;
-// vector<int> edge3(_edge3,_edge3+2) ;
-// vector<int> edge4(_edge4,_edge4+2) ;
-// vector<int> edge5(_edge5,_edge5+2) ;
-// vector<int> edge6(_edge6,_edge6+2) ;
-// vector<int> edge7(_edge7,_edge7+2) ;
-// vector<int> edge8(_edge8,_edge8+2) ;
-// vector<int> edge9(_edge9,_edge9+2) ;
-// vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9};
-// vector< vector<int> > vector_edge(_vector_edge,_vector_edge+9) ;
-
-// int _face1[]={1,2,3};
-// int _face2[]={4,6,5};
-// int _face3[]={1,4,5,2};
-// int _face4[]={2,5,6,3};
-// int _face5[]={3,6,4,1};
-// vector<int> face1(_face1,_face1+3);
-// vector<int> face2(_face2,_face2+3);
-// vector<int> face3(_face3,_face3+4);
-// vector<int> face4(_face4,_face4+4);
-// vector<int> face5(_face5,_face5+4);
-// vector<int> _vector_face[]= {face1,face2,face3,face4,face5} ;
-// vector< vector<int> > vector_face(_vector_face,_vector_face+5);
-
-// vector< vector<int> > __constituents__[]={vector_face,vector_edge};
-// vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
-// _constituents = _constituents_ ;
_numberOfConstituentsDimension=2 ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=5 ;
_constituents = new int**[2] ;
_constituents[0]=tmpConstituents1 ;
_constituents[1]=tmpConstituents2 ;
-// vector<medGeometryElement> vector_edge_type(9,MED_SEG2) ;
-// vector<medGeometryElement> vector_face_type(5,MED_QUAD4) ;
-// vector_face_type[0]=MED_TRIA3 ;
-// vector_face_type[1]=MED_TRIA3 ;
-// vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
-// vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
-// _constituentsType = _constituents_type ;
medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ;
tmpConstituentsType1[0] = MED_TRIA3 ;
tmpConstituentsType1[1] = MED_TRIA3 ;
_dimension=3;
_numberOfVertexes=6;
_numberOfNodes=15;
-// int _edge1[]={1,2,7} ;
-// int _edge2[]={2,3,8} ;
-// int _edge3[]={3,1,9} ;
-// int _edge4[]={4,5,10} ;
-// int _edge5[]={5,6,11} ;
-// int _edge6[]={6,4,12} ;
-// int _edge7[]={1,4,13} ;
-// int _edge8[]={2,5,14} ;
-// int _edge9[]={3,6,15} ;
-
-// vector<int> edge1(_edge1,_edge1+3) ;
-// vector<int> edge2(_edge2,_edge2+3) ;
-// vector<int> edge3(_edge3,_edge3+3) ;
-// vector<int> edge4(_edge4,_edge4+3) ;
-// vector<int> edge5(_edge5,_edge5+3) ;
-// vector<int> edge6(_edge6,_edge6+3) ;
-// vector<int> edge7(_edge7,_edge7+3) ;
-// vector<int> edge8(_edge8,_edge8+3) ;
-// vector<int> edge9(_edge9,_edge9+3) ;
-// vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9};
-// vector< vector<int> > vector_edge(_vector_edge,_vector_edge+9) ;
-
-// int _face1[]={1,2,3,7,8,9};
-// int _face2[]={4,6,5,12,11,10};
-// int _face3[]={1,4,5,2,13,10,14,7};
-// int _face4[]={2,5,6,3,14,11,15,8};
-// int _face5[]={3,6,4,1,15,12,13,9};
-// vector<int> face1(_face1,_face1+6);
-// vector<int> face2(_face2,_face2+6);
-// vector<int> face3(_face3,_face3+8);
-// vector<int> face4(_face4,_face4+8);
-// vector<int> face5(_face5,_face5+8);
-// vector<int> _vector_face[]= {face1,face2,face3,face4,face5} ;
-// vector< vector<int> > vector_face(_vector_face,_vector_face+5);
-
-// vector< vector<int> > __constituents__[]={vector_face,vector_edge};
-// vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
-// _constituents = _constituents_ ;
_numberOfConstituentsDimension=2 ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=5 ;
_constituents = new (int**)[2] ;
_constituents[0]=tmpConstituents1 ;
_constituents[1]=tmpConstituents2 ;
-// vector<medGeometryElement> vector_edge_type(9,MED_SEG3) ;
-// vector<medGeometryElement> vector_face_type(5,MED_QUAD8) ;
-// vector_face_type[0]=MED_TRIA6 ;
-// vector_face_type[1]=MED_TRIA6 ;
-// vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
-// vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
-// _constituentsType = _constituents_type ;
medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ;
tmpConstituentsType1[0] = MED_TRIA6 ;
tmpConstituentsType1[1] = MED_TRIA6 ;
_dimension=3;
_numberOfVertexes=5;
_numberOfNodes=5;
-// int _edge1[]={1,2} ;
-// int _edge2[]={2,3} ;
-// int _edge3[]={3,4} ;
-// int _edge4[]={4,1} ;
-// int _edge5[]={1,5} ;
-// int _edge6[]={2,5} ;
-// int _edge7[]={3,5} ;
-// int _edge8[]={4,5} ;
-
-// vector<int> edge1(_edge1,_edge1+2) ;
-// vector<int> edge2(_edge2,_edge2+2) ;
-// vector<int> edge3(_edge3,_edge3+2) ;
-// vector<int> edge4(_edge4,_edge4+2) ;
-// vector<int> edge5(_edge5,_edge5+2) ;
-// vector<int> edge6(_edge6,_edge6+2) ;
-// vector<int> edge7(_edge7,_edge7+2) ;
-// vector<int> edge8(_edge8,_edge8+2) ;
-// vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8};
-// vector< vector<int> > vector_edge(_vector_edge,_vector_edge+8) ;
-
-// int _face1[]={1,2,3,4} ;
-// int _face2[]={1,5,2} ;
-// int _face3[]={2,5,3} ;
-// int _face4[]={3,5,4} ;
-// int _face5[]={4,5,1} ;
-// vector<int> face1(_face1,_face1+4);
-// vector<int> face2(_face2,_face2+3);
-// vector<int> face3(_face3,_face3+3);
-// vector<int> face4(_face4,_face4+3);
-// vector<int> face5(_face5,_face5+3);
-// vector<int> _vector_face[]= {face1,face2,face3,face4,face5} ;
-// vector< vector<int> > vector_face(_vector_face,_vector_face+5);
-
-// vector< vector<int> > __constituents__[]={vector_face,vector_edge};
-// vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
-// _constituents = _constituents_ ;
_numberOfConstituentsDimension=2 ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=5 ;
_constituents = new int**[2] ;
_constituents[0]=tmpConstituents1 ;
_constituents[1]=tmpConstituents2 ;
-// vector<medGeometryElement> vector_edge_type(8,MED_SEG2) ;
-// vector<medGeometryElement> vector_face_type(5,MED_TRIA3) ;
-// vector_face_type[0]=MED_QUAD4 ;
-// vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
-// vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
-// _constituentsType = _constituents_type ;
medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ;
tmpConstituentsType1[0] = MED_QUAD4 ;
tmpConstituentsType1[1] = MED_TRIA3 ;
_dimension=3;
_numberOfVertexes=5;
_numberOfNodes=13;
-// int _edge1[]={1,2,6} ;
-// int _edge2[]={2,3,7} ;
-// int _edge3[]={3,4,8} ;
-// int _edge4[]={4,1,9} ;
-// int _edge5[]={1,5,10} ;
-// int _edge6[]={2,5,11} ;
-// int _edge7[]={3,5,12} ;
-// int _edge8[]={4,5,13} ;
-
-// vector<int> edge1(_edge1,_edge1+3) ;
-// vector<int> edge2(_edge2,_edge2+3) ;
-// vector<int> edge3(_edge3,_edge3+3) ;
-// vector<int> edge4(_edge4,_edge4+3) ;
-// vector<int> edge5(_edge5,_edge5+3) ;
-// vector<int> edge6(_edge6,_edge6+3) ;
-// vector<int> edge7(_edge7,_edge7+3) ;
-// vector<int> edge8(_edge8,_edge8+3) ;
-
-
-// vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8};
-// vector< vector<int> > vector_edge(_vector_edge,_vector_edge+8) ;
-
-// int _face1[]={1,2,3,4,6,7,8,9} ;
-// int _face2[]={1,5,2,10,11,6} ;
-// int _face3[]={2,5,3,11,12,7} ;
-// int _face4[]={3,5,4,12,13,8} ;
-// int _face5[]={4,5,1,13,10,9} ;
-// vector<int> face1(_face1,_face1+8);
-// vector<int> face2(_face2,_face2+6);
-// vector<int> face3(_face3,_face3+6);
-// vector<int> face4(_face4,_face4+6);
-// vector<int> face5(_face5,_face5+6);
-// vector<int> _vector_face[]= {face1,face2,face3,face4,face5} ;
-// vector< vector<int> > vector_face(_vector_face,_vector_face+5);
-
-
-// vector< vector<int> > __constituents__[]={vector_face,vector_edge};
-// vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
-// _constituents = _constituents_ ;
_numberOfConstituentsDimension=2 ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=5 ;
_constituents = new int**[2] ;
_constituents[0]=tmpConstituents1 ;
_constituents[1]=tmpConstituents2 ;
-// vector<medGeometryElement> vector_edge_type(8,MED_SEG3) ;
-// vector<medGeometryElement> vector_face_type(5,MED_TRIA6) ;
-// vector_face_type[0]=MED_QUAD8 ;
-// vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
-// vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
-
-// _constituentsType = _constituents_type ;
medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ;
tmpConstituentsType1[0] = MED_QUAD8 ;
tmpConstituentsType1[1] = MED_TRIA6 ;
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Connectivity.hxx
+// Module : MED
+
#ifndef CONNECTIVITY_HXX
#define CONNECTIVITY_HXX
class FAMILY;
/*!
- this class deals with all type of connectivity
- this a recursive class in order to store
-
+ This class deals with all type of connectivity ./n
+ it a recursive class.
*/
-class CONNECTIVITY // recursive class
+/* ------------------------------------------- */
+class CONNECTIVITY
+/* ------------------------------------------- */
{
- /*
- Class Attributs
- */
+ /* ---------------------- */
+ /* Class Attributs */
+ /* ---------------------- */
protected:
/*! contains MED_CELL MED_FACE or MED_EDGE */
- medEntityMesh _entity ;
+ medEntityMesh _entity;
/*! contains MED_NODAL or MED_DESCEND */
- medConnectivity _typeConnectivity ;
+ medConnectivity _typeConnectivity;
/*! count of differents cells types
used by the mesh */
- med_int _numberOfTypes ;
+ med_int _numberOfTypes;
/*! array of all med_geometric_type used by MESH. */
- medGeometryElement* _geometricTypes ;
+ medGeometryElement* _geometricTypes;
/*! map indexed by med_geometric_type
which contains the different
'CellModel' used by MESH. */
- CELLMODEL * _type ;
+ CELLMODEL * _type;
/*! contains the dimension of the entity */
- med_int _entityDimension ;
+ med_int _entityDimension;
/*! needed by calculateReverseNodalConnectivity */
- med_int _numberOfNodes ;
+ med_int _numberOfNodes;
/*! array of size _numberOfTypes+1 which
gives for each cell type the first
( 0 <= i < _numberOfTypes ).
Note that _count[_numberOfTypes] returns
total cells count + 1 */
- med_int * _count ;
-
- /*! pointer on an array which stores the nodal connectivity */
- MEDSKYLINEARRAY* _nodal ;
- /*! pointer on an array which stores the descending connectivity */
- MEDSKYLINEARRAY* _descending ;
- /*! pointer on an array which stores the resverse nodal connectivity */
- MEDSKYLINEARRAY* _reverseNodalConnectivity ;
- /*! pointer on an array which stores the reverse descending connectivity */
- MEDSKYLINEARRAY* _reverseDescendingConnectivity ;
+ med_int * _count;
+
+ /*! pointer to an array which stores the nodal connectivity */
+ MEDSKYLINEARRAY* _nodal;
+ /*! pointer to an array which stores
+ the descending connectivity */
+ MEDSKYLINEARRAY* _descending;
+ /*! pointer to an array which stores
+ the reverse nodal connectivity */
+ MEDSKYLINEARRAY* _reverseNodalConnectivity;
+ /*! pointer to an array which stores
+ the reverse descending connectivity */
+ MEDSKYLINEARRAY* _reverseDescendingConnectivity;
/*! if face or edge, list of 2 cells or
2 faces it belongs to.
If 2nd number equals 0, we have a
boundary entity. We could use
MEDSKYLINEARRAY, but we suppose we have
always only 2 (or 1) entities. */
- MEDSKYLINEARRAY* _neighbourhood ;
+ MEDSKYLINEARRAY* _neighbourhood;
/*! connectivity of sub cell if
descendant connectivity is calculated */
- CONNECTIVITY * _constituent ;
+ CONNECTIVITY * _constituent;
- /*
- Class Methods
- */
+ /* -------------------- */
+ /* Class Methods */
+ /* -------------------- */
private:
- /*! does nothing if already exists, else
+ /*! private method :/n
+ does nothing if already exists, else
evaluates _nodal from _descending */
- void calculateNodalConnectivity() ;
- /*! does nothing if already exists, else
+ void calculateNodalConnectivity();
+ /*! private method :/n
+ does nothing if already exists, else
evaluates from _nodal */
- void calculateReverseNodalConnectivity() ;
- /*! does nothing if already exists, else
+ void calculateReverseNodalConnectivity();
+ /*! private method :/n
+ does nothing if already exists, else
evaluates _descending from _nodal */
- void calculateDescendingConnectivity() ;
- /*! does nothing if already exists, else
+ void calculateDescendingConnectivity();
+ /*! private method :/n
+ does nothing if already exists, else
evaluates from _descending */
- // void calculateReverseDescendingConnectivity(CONNECTIVITY *myConnectivity) ;
+ // void calculateReverseDescendingConnectivity(CONNECTIVITY *myConnectivity);
- med_int* getReverseNodalConnectivity () ;
- med_int* getReverseNodalConnectivityIndex () ;
- med_int* getReverseDescendingConnectivity () ;
- med_int* getReverseDescendingConnectivityIndex () ;
+ const med_int* getReverseNodalConnectivity ();
+ const med_int* getReverseNodalConnectivityIndex ();
+ const med_int* getReverseDescendingConnectivity ();
+ const med_int* getReverseDescendingConnectivityIndex ();
- /*! does nothing if already exists, else
+ /*! private method :/n
+ does nothing if already exists, else
evaluates _neighbourhood from _descending */
- void calculateNeighbourhood(CONNECTIVITY &myConnectivity) ;
+ void calculateNeighbourhood(CONNECTIVITY &myConnectivity);
public:
friend class MED_MESH_RDONLY_DRIVER;
friend class MED_MESH_WRONLY_DRIVER;
- CONNECTIVITY(medEntityMesh Entity=MED_CELL);
- CONNECTIVITY(int numberOfTypes, medEntityMesh Entity=MED_CELL);
- CONNECTIVITY(CONNECTIVITY & m);
- ~CONNECTIVITY();
+ // in order to fill CONNECTIVITY of MESH
+ friend class GRID;
- inline bool existConnectivity (medConnectivity connectivityType, medEntityMesh Entity) const ;
- void calculateConnectivity (medConnectivity connectivityType, medEntityMesh Entity) ;
- void updateFamily(vector<FAMILY*> myFamilies) ;
+ CONNECTIVITY (medEntityMesh Entity=MED_CELL);
+ CONNECTIVITY (int numberOfTypes, medEntityMesh Entity=MED_CELL);
+ CONNECTIVITY (const CONNECTIVITY & m);
+ ~CONNECTIVITY ();
- inline medEntityMesh getEntity () const;
- inline med_int getNumberOfTypes (medEntityMesh Entity) const;
- inline medGeometryElement * getGeometricTypes (medEntityMesh Entity) const;
- medGeometryElement getElementType(medEntityMesh Entity,int Number) const ;
- inline int * getGlobalNumberingIndex (medEntityMesh Entity) const ;
+ void setConstituent (CONNECTIVITY * Constituent)
+ throw (MEDEXCEPTION);
- med_int * getConnectivity (medConnectivity ConnectivityType, medEntityMesh Entity,
- medGeometryElement Type) ;
- med_int * getConnectivityIndex (medConnectivity ConnectivityType,medEntityMesh Entity) ;
-
- CELLMODEL & getType (medGeometryElement Type) const;
- CELLMODEL * getCellsTypes (medEntityMesh Entity) const;
-
- med_int getNumberOfNodesInType (medGeometryElement Type) const;
- med_int getNumberOfSubCellInType (medGeometryElement Type) const;
- med_int getNumberOf (medEntityMesh Entity, medGeometryElement Type) const;
- med_int* getValue (medConnectivity TypeConnectivity, medGeometryElement Type) ;
- med_int* getValueIndex (medConnectivity TypeConnectivity) ;
+ void setGeometricTypes (const medGeometryElement * Types,
+ const medEntityMesh Entity)
+ throw (MEDEXCEPTION);
+
+ void setCount (const int * Count, const medEntityMesh Entity)
+ throw (MEDEXCEPTION);
+
+ void setNodal (const int * Connectivity,
+ const medEntityMesh Entity,
+ const medGeometryElement Type)
+ throw (MEDEXCEPTION);
+
+ inline bool existConnectivity (medConnectivity connectivityType, medEntityMesh Entity) const;
+
+ void calculateConnectivity (medConnectivity connectivityType, medEntityMesh Entity);
- inline med_int* getReverseConnectivity (medConnectivity ConnectivityType, medEntityMesh Entity=MED_CELL) ;
- inline med_int* getReverseConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity=MED_CELL) ;
+ void updateFamily (vector<FAMILY*> myFamilies);
- med_int* getNeighbourhood() const;
+ inline medEntityMesh getEntity () const;
+ inline med_int getNumberOfTypes (medEntityMesh Entity) const;
+ inline const medGeometryElement * getGeometricTypes (medEntityMesh Entity) const
+ throw (MEDEXCEPTION);
+ medGeometryElement getElementType (medEntityMesh Entity,
+ int Number) const;
+ inline const int * getGlobalNumberingIndex (medEntityMesh Entity) const
+ throw (MEDEXCEPTION);
-} ;
+ const med_int * getConnectivity (medConnectivity ConnectivityType,
+ medEntityMesh Entity,
+ medGeometryElement Type);
+ const med_int * getConnectivityIndex (medConnectivity ConnectivityType,
+ medEntityMesh Entity);
+
+ const CELLMODEL & getType (medGeometryElement Type) const;
+ const CELLMODEL * getCellsTypes (medEntityMesh Entity) const
+ throw (MEDEXCEPTION);
+
+ med_int getNumberOfNodesInType (medGeometryElement Type) const;
+ med_int getNumberOfSubCellInType (medGeometryElement Type) const;
+ med_int getNumberOf (medEntityMesh Entity,
+ medGeometryElement Type) const;
+ const med_int* getValue (medConnectivity TypeConnectivity,
+ medGeometryElement Type);
+ const med_int* getValueIndex (medConnectivity TypeConnectivity);
+
+ inline const med_int* getReverseConnectivity (medConnectivity ConnectivityType,
+ medEntityMesh Entity=MED_CELL)
+ throw (MEDEXCEPTION);
+ inline const med_int* getReverseConnectivityIndex (medConnectivity ConnectivityType,
+ medEntityMesh Entity=MED_CELL)
+ throw (MEDEXCEPTION);
+
+ const med_int* getNeighbourhood() const;
+
+};
/*----------------------*/
/* Methodes Inline */
/*----------------------*/
/*! Returns the medEntityMesh */
+//--------------------------------------------------//
inline medEntityMesh CONNECTIVITY::getEntity() const
+//--------------------------------------------------//
{
- return _entity;
+ return _entity;
}
-/*! Returns the number of different <medGeometryElement> types existing in the specified entity.
-
+/*! Returns the number of different <medGeometryElement> types
+ existing in the specified entity. /n
Note : Not implemented for MED_ALL_ENTITIES. */
+//-----------------------------------------------------------------------//
inline med_int CONNECTIVITY::getNumberOfTypes(medEntityMesh Entity) const
+//-----------------------------------------------------------------------//
{
MESSAGE("CONNECTIVITY::getNumberOfTypes : Entity = "<<Entity<<", _entity = "<<_entity);
if (_entity==Entity)
- return _numberOfTypes;
+ return _numberOfTypes;
else if (_constituent!=NULL)
- return _constituent->getNumberOfTypes(Entity) ;
+ return _constituent->getNumberOfTypes(Entity);
else
- return 0 ; // because it is the right information (no need exception !
- //throw MEDEXCEPTION("Entity not defined !") ;
+ return 0; // because it is the right information (no exception needed)!
}
-/*! Returns an array of all <med geometry elements> types existing in the mesh for the given medEntityMesh.
-
- Note : Not implemented for MED_ALL_ENTITIES. */
-inline medGeometryElement* CONNECTIVITY::getGeometricTypes(medEntityMesh Entity) const
+/*! Returns an array of all <med geometry elements> types existing in the mesh
+ for the given medEntityMesh./n
+ Note : Not implemented for MED_ALL_ENTITIES. /n
+ Throws an exception if Entity is unknown */
+//------------------------------------------------------------------------------------------//
+inline const medGeometryElement* CONNECTIVITY::getGeometricTypes(medEntityMesh Entity) const
+ throw (MEDEXCEPTION)
+//------------------------------------------------------------------------------------------//
{
if (_entity==Entity)
- return _geometricTypes;
+ return _geometricTypes;
else if (_constituent!=NULL)
- return _constituent->getGeometricTypes(Entity) ;
+ return _constituent->getGeometricTypes(Entity);
else
- throw MEDEXCEPTION("Entity not defined !") ;
+ throw MEDEXCEPTION("Entity not defined !");
}
/*! A DOCUMENTER */
-inline int * CONNECTIVITY::getGlobalNumberingIndex(medEntityMesh Entity) const
+//----------------------------------------------------------------------------------//
+inline const int * CONNECTIVITY::getGlobalNumberingIndex(medEntityMesh Entity) const
+ throw (MEDEXCEPTION)
+//----------------------------------------------------------------------------------//
{
if (_entity==Entity)
- return _count;
+ return _count;
else if (_constituent!=NULL)
- return _constituent->getGlobalNumberingIndex(Entity) ;
+ return _constituent->getGlobalNumberingIndex(Entity);
else
- throw MEDEXCEPTION("Entity not defined !") ;
+ throw MEDEXCEPTION("Entity not defined !");
}
/*! Returns true if a connectivity exists on elements of type "Entity" */
-inline bool CONNECTIVITY::existConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity) const
+//-----------------------------------------------------------------------------//
+inline bool CONNECTIVITY::existConnectivity( medConnectivity ConnectivityType,
+ medEntityMesh Entity) const
+//-----------------------------------------------------------------------------//
{
if (_entity==Entity) {
MESSAGE("existConnectivity : _entity==Entity="<<Entity);
if ((ConnectivityType==MED_NODAL)&(_nodal!=(MEDSKYLINEARRAY*)NULL))
- return true ;
+ return true;
if ((ConnectivityType==MED_DESCENDING)&(_descending!=(MEDSKYLINEARRAY*)NULL))
- return true ;
+ return true;
} else if (_constituent!=NULL)
- return _constituent->existConnectivity(ConnectivityType,Entity) ;
- return false ;
+ return _constituent->existConnectivity(ConnectivityType,Entity);
+ return false;
}
/*!
-Return an array which contain CELLMODEL foreach element type present in connectivity for given medEntityMesh (similar as getGeometricTypes)
-
+Returns an array containing CELLMODEL foreach element type present
+in connectivity for given medEntityMesh (similar as getGeometricTypes)./n
Throw an execption if the given entity is not defined or if the array is not defined.
*/
-inline CELLMODEL * CONNECTIVITY::getCellsTypes(medEntityMesh Entity) const
+//-----------------------------------------------------------------------------//
+inline const CELLMODEL * CONNECTIVITY::getCellsTypes(medEntityMesh Entity) const
+ throw (MEDEXCEPTION)
+//-----------------------------------------------------------------------------//
{
if (Entity == _entity)
if (_type!=NULL)
- return _type ;
+ return _type;
else
- throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) : CELLMODEL array is not defined !");
+ throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) :
+ CELLMODEL array is not defined !");
else
if (_constituent != NULL)
- return _constituent->getCellsTypes(Entity) ;
+ return _constituent->getCellsTypes(Entity);
else
throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) : Not found Entity !");
}
-inline med_int* CONNECTIVITY::getReverseConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity)
+/*! A DOCUMENTER */
+//------------------------------------------------------------------------------------------//
+inline const med_int* CONNECTIVITY::getReverseConnectivity( medConnectivity ConnectivityType,
+ medEntityMesh Entity)
+ throw (MEDEXCEPTION)
+//------------------------------------------------------------------------------------------//
{
if(_entity==Entity)
if (ConnectivityType==MED_NODAL)
- return getReverseNodalConnectivity() ;
+ return getReverseNodalConnectivity();
else if (ConnectivityType==MED_DESCENDING)
- return getReverseDescendingConnectivity() ;
+ return getReverseDescendingConnectivity();
else
throw MEDEXCEPTION("MESH::getReverseConnectivity : connectivity mode not supported !");
// other entity :
if (NULL==_constituent)
- calculateDescendingConnectivity() ;
- return _constituent->getReverseConnectivity(ConnectivityType,Entity) ;
+ calculateDescendingConnectivity();
+ return _constituent->getReverseConnectivity(ConnectivityType,Entity);
}
-inline med_int* CONNECTIVITY::getReverseConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity)
+/*! A DOCUMENTER */
+//-----------------------------------------------------------------------------------------------//
+inline const med_int* CONNECTIVITY::getReverseConnectivityIndex(medConnectivity ConnectivityType,
+ medEntityMesh Entity)
+ throw (MEDEXCEPTION)
+//-----------------------------------------------------------------------------------------------//
{
if(_entity==Entity)
if (ConnectivityType==MED_NODAL)
- return getReverseNodalConnectivityIndex() ;
+ return getReverseNodalConnectivityIndex();
else if (ConnectivityType==MED_DESCENDING)
- return getReverseDescendingConnectivityIndex() ;
+ return getReverseDescendingConnectivityIndex();
else
throw MEDEXCEPTION("MESH::getReverseConnectivityIndex : connectivity mode not supported !");
// other entity :
if (NULL==_constituent)
- calculateDescendingConnectivity() ;
- return _constituent->getReverseConnectivityIndex(ConnectivityType,Entity) ;
+ calculateDescendingConnectivity();
+ return _constituent->getReverseConnectivityIndex(ConnectivityType,Entity);
}
#endif /* CONNECTIVITY_HXX */
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Exception.cxx
+// Module : MED
+
using namespace std;
/*
File MedException.cxx
}
+/*!
+ \internal
+ Function used to duplicate char *
+*/
const char* duplicate( const char *const str ) ;
-
const char* duplicate( const char *const str )
{
ASSERT(str!=NULL) ;
return new_str ;
}
+/*!
+ \internal Default Constructor (Should not be used)
+*/
+// ------------------------------------------------------ //
MEDEXCEPTION::MEDEXCEPTION( void ): exception() , _text(0)
+// ------------------------------------------------------ //
{
MESSAGE( "You must user the standard builder : MEDEXCEPTION::MEDEXCEPTION( const char *text )" ) ;
INTERRUPTION(1) ;
}
+/*!
+ \internal
+ Function used to elaborate the text of the MEDEXCEPTION
+*/
+// --------------------------------------------------------------------------------------- //
const char *makeText( const char *text, const char *fileName, const unsigned int lineNumber )
+// --------------------------------------------------------------------------------------- //
{
char *newText = 0 ;
const size_t l0 = strlen(prefix) ;
if ( fileName )
- {
+ {
const size_t l2 = strlen(fileName) ;
ASSERT(lineNumber>=1) ;
sprintf( newText , "%s in %s [%u] : %s" , prefix, fileName, lineNumber, text ) ;
ASSERT(newText[l4-1] == '\0' );
- }
+ }
else
- {
+ {
newText = new char [ l0+l1+3+1 ] ;
sprintf( newText , "%s : %s" , prefix, text ) ;
- }
+ }
ASSERT(newText) ;
return newText ;
}
-
-MEDEXCEPTION::MEDEXCEPTION( const char *text, const char *fileName, const unsigned int lineNumber ) : exception(), _text( makeText( text , fileName , lineNumber ) )
+/*!
+ Constructor : \n
+ It will create the text of the MEDEXCEPTION from the different parameters.
+ It will take the form : \n
+ MEDEXCEPTION, fileName, lineNumber and text of the exception
+*/
+// ------------------------------------------------------------------------------------------------ //
+MEDEXCEPTION::MEDEXCEPTION( const char *text, const char *fileName, const unsigned int lineNumber ) :
+ exception(), _text( makeText( text , fileName , lineNumber ) )
+// ------------------------------------------------------------------------------------------------ //
{
MESSAGE(_text);
}
+/*!
+ Destructor : \n
+ If necessary desallocates Memory
+*/
+// ------------------------------------//
MEDEXCEPTION::~MEDEXCEPTION() throw ()
+// ------------------------------------//
{
if ( _text )
{
}
-
+/*!
+ Copy Constructor : \n
+ Should not be used very often
+*/
+// ----------------------------------------------------------------------- //
MEDEXCEPTION::MEDEXCEPTION( const MEDEXCEPTION &ex ): _text(duplicate(ex._text))
+// ----------------------------------------------------------------------- //
{
;
}
-
-
+/*!
+ Operator << : put the message to the given stream.
+*/
+// ------------------------------------------------------- //
ostream & operator<<( ostream &os , const MEDEXCEPTION &ex )
+// ------------------------------------------------------- //
{
os << ex._text ;
return os ;
}
-
-
+/*!
+ Return a char * which contain the message.
+*/
+// ------------------------------------------------- //
const char* MEDEXCEPTION::what( void ) const throw ()
+// ------------------------------------------------- //
{
return _text ;
}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Family.cxx
+// Module : MED
+
using namespace std;
/*
File MEDMEM_Family.cxx
FAMILY::FAMILY(MESH* Mesh, int Identifier, string Name, int NumberOfAttribute,
int *AttributeIdentifier, int *AttributeValue, string AttributeDescription,
- int NumberOfGroup, string GroupName
+ int NumberOfGroup, string GroupName,
+ int * MEDArrayNodeFamily,
+ int ** MEDArrayCellFamily,
+ int ** MEDArrayFaceFamily,
+ int ** MEDArrayEdgeFamily
): SUPPORT(Mesh,Name),
_identifier(Identifier),
_numberOfAttribute(NumberOfAttribute),
- _attributeIdentifier(AttributeIdentifier),
- _attributeValue(AttributeValue),
_numberOfGroup(NumberOfGroup)
{
MESSAGE("FAMILY(int Identifier, string Name, int NumberOfAttribute,int *AttributeIdentifier,int *AttributeValue,string AttributeDescription,int NumberOfGroup,string GroupName, int ** Number) : "<<Identifier);
+ _isOnAllElts = false ;
+ // replace them by pointerOf ?
+ _attributeIdentifier = new int[_numberOfAttribute] ;
+ memcpy(_attributeIdentifier,AttributeIdentifier,_numberOfAttribute*sizeof(int));
+ _attributeValue = new int[_numberOfAttribute] ;
+ memcpy(_attributeValue,AttributeValue,_numberOfAttribute*sizeof(int));
+
_attributeDescription=new string[_numberOfAttribute];
for (int i=0;i<NumberOfAttribute;i++) {
_attributeDescription[i].assign(AttributeDescription,i*MED_TAILLE_DESC,MED_TAILLE_DESC);
// the list <tmp_NodesList> of node numbers <i+1> belonging to the family <_identifier>
int NumberOfNodes = _mesh->getNumberOfNodes();
int NumberOfNodesInFamily = 0 ;
- int * NodeFamilyNumber = _mesh->getMEDArrayNodeFamily() ; // EF : TEMPORAIRE !!
+ //int * NodeFamilyNumber = _mesh->getMEDArrayNodeFamily() ; // EF : TEMPORAIRE !!
int * tmp_NodesList = new int[NumberOfNodes] ; // Un peu brutal...., oui mais ce n'est qu'un tableau de travail !
for (int i=0; i<NumberOfNodes; i++)
- if ( _identifier == NodeFamilyNumber[i] ) {
+ if ( _identifier == MEDArrayNodeFamily[i] ) {
tmp_NodesList[NumberOfNodesInFamily]=i+1 ;
NumberOfNodesInFamily++;
}
-
+ //SCRUTE(NumberOfNodesInFamily);
+
// If we found nodes set the family attributes adequatly
if (NumberOfNodesInFamily>0) {
Find = true ;
_entity = MED_NODE ;
- _numberOfGeometricType = 1 ;
- _geometricType = new medGeometryElement[1] ;
- _geometricType[0]=MED_NONE ;
+// _numberOfGeometricType = 1 ;
+// _geometricType = new medGeometryElement[1] ;
+// _geometricType[0]=MED_NONE ;
// family on all NODE
- if (NumberOfNodesInFamily==NumberOfNodes)
+ if (NumberOfNodesInFamily==NumberOfNodes) {
_isOnAllElts = true ;
- else {
+ update();
+ } else {
+ _numberOfGeometricType = 1 ;
+ if (_geometricType!=NULL) delete[] _geometricType ;
+ _geometricType = new medGeometryElement[1] ;
+ _geometricType[0]=MED_NONE ;
_isOnAllElts= false ;
- _numberOfEntities = new int[1] ;
- _numberOfEntities[0]=NumberOfNodesInFamily ;
- _totalNumberOfEntities=NumberOfNodesInFamily;
+ if (_numberOfElements!=NULL) delete[] _numberOfElements ;
+ _numberOfElements = new int[1] ;
+ _numberOfElements[0]=NumberOfNodesInFamily ;
+ _totalNumberOfElements=NumberOfNodesInFamily;
- _number=new MEDSKYLINEARRAY(1,NumberOfNodesInFamily) ;
- int * NumberIndex = _number->getIndex();
- int * NumberValue = _number->getValue();
+// _number=new MEDSKYLINEARRAY(1,NumberOfNodesInFamily) ;
+// int * NumberIndex = _number->getIndex();
+// int * NumberValue = _number->getValue();
+ int * NumberIndex = new int[2];
+ int * NumberValue = new int[NumberOfNodesInFamily];
+
NumberIndex[0]=1; //set the MEDSKYLINEARRAY Index table
NumberIndex[1]=1+NumberOfNodesInFamily; //set the MEDSKYLINEARRAY Index table
for(int i=0; i<NumberOfNodesInFamily; i++) // OH LA LA...
NumberValue[i]=tmp_NodesList[i] ; // RESIZE de tmp_NodesList serait plus efficace !!!!!!!!
// PG : pas de problème, si ca marche. Il faudra déplacer le delete !
+ if(_number!=NULL) delete _number ;
+ _number=new MEDSKYLINEARRAY(1,NumberOfNodesInFamily,NumberIndex,NumberValue) ;
+ delete[] NumberIndex ;
+ delete[] NumberValue ;
}
}
delete[] tmp_NodesList ;
// ?? Scan every cell family number <NodeFamilyNumber[i]> in order to create
// ?? the list <tmp_NodesList> of node numbers <i+1> belonging to the family <_identifier>
if (!Find) {
-
- // Get cell types information from <_mesh>
- int numberOfCellTypes = _mesh->getNumberOfTypes(MED_CELL) ;
- medGeometryElement * cellTypes = _mesh->getTypes(MED_CELL) ;
-
- int * numberOfCellsInFamily = new int[numberOfCellTypes] ;
- int numberOfCellTypesInFamily = 0 ;
-
- medGeometryElement * tmp_CellsTypes = new medGeometryElement[numberOfCellTypes];
- int ** tmp_CellsLists = new int*[numberOfCellTypes] ;
- int * GeometricTypeNumber = new int[numberOfCellTypes] ;
- int ** CellFamilyNumber = _mesh->getMEDArrayCellFamily(); // EF: TEMPORAIRE
- int * GlobalNumberingIndex = _mesh->getGlobalNumberingIndex(MED_CELL);
-
- // we search for all cell in this family
- for (int cellTypeNumber=0; cellTypeNumber < numberOfCellTypes; cellTypeNumber++) {
-
- int NumberOfCells = _mesh->getNumberOfElements(MED_CELL,cellTypes[cellTypeNumber]) ;
- int NumberOfCellsInThisFamily = 0 ;
- int * CellsOfThisFamilyNumber = CellFamilyNumber[cellTypeNumber];
- int * tmp_CellsList = new int[NumberOfCells];
-
- for (int i=0; i<NumberOfCells; i++)
- if (_identifier == CellsOfThisFamilyNumber[i]) {
- tmp_CellsList[NumberOfCellsInThisFamily]=i+GlobalNumberingIndex[cellTypeNumber] ;
- NumberOfCellsInThisFamily++;
- }
-
- if (NumberOfCellsInThisFamily>0) {// we have found some cells
- numberOfCellsInFamily[numberOfCellTypesInFamily]=NumberOfCellsInThisFamily;
- int * CellsList=new int[NumberOfCellsInThisFamily] ;
-
- for (int i=0;i<NumberOfCellsInThisFamily;i++)
- CellsList[i]=tmp_CellsList[i] ; // RESIZE de tmp_NodesList serait plus efficace !!!!!!!!
-
- tmp_CellsLists[numberOfCellTypesInFamily]=CellsList ;
- tmp_CellsTypes[numberOfCellTypesInFamily]=cellTypes[cellTypeNumber];
- GeometricTypeNumber[numberOfCellTypesInFamily]=cellTypeNumber+1;
- numberOfCellTypesInFamily++;
- }
-
- delete[] tmp_CellsList ;
- }
-
- // we define all attribut in SUPPORT :
- if (numberOfCellTypesInFamily>0) { // we have found cells
- Find = true ;
- _entity = MED_CELL ;
- _numberOfGeometricType = numberOfCellTypesInFamily ;
- _geometricType = new medGeometryElement[numberOfCellTypesInFamily] ;
- _geometricTypeNumber = new int[numberOfCellTypesInFamily] ;
- _isOnAllElts = false ;
- _numberOfEntities = new int[numberOfCellTypesInFamily] ;
- _totalNumberOfEntities=0;
- for (int i=0; i<numberOfCellTypesInFamily; i++) {
- _geometricType[i]=tmp_CellsTypes[i] ;
- _geometricTypeNumber[i]=GeometricTypeNumber[i];
- _numberOfEntities[i]=numberOfCellsInFamily[i] ;
- _totalNumberOfEntities+=numberOfCellsInFamily[i] ;
- }
- delete[] numberOfCellsInFamily;
- delete[] tmp_CellsTypes;
- delete[] GeometricTypeNumber;
-
- // family on all CELL ?
- if (_totalNumberOfEntities==Mesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)) {
- _isOnAllElts = true ;
- delete[] _numberOfEntities ;
- _numberOfEntities=(int*)NULL;
- } else {
- _number=new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities);
- int *NumberValue=_number->getValue();
- int *NumberIndex=_number->getIndex();
- NumberIndex[0]=1;
- for (int i=0; i<_numberOfGeometricType; i++) {
- NumberIndex[i+1]=NumberIndex[i]+_numberOfEntities[i];
- for (int j=NumberIndex[i]; j<NumberIndex[i+1]; j++)
- NumberValue[j-1]=tmp_CellsLists[i][j-NumberIndex[i]];
- delete[] tmp_CellsLists[i];
- }
- delete[] tmp_CellsLists;
- }
- }
+ Find = build(MED_CELL,MEDArrayCellFamily) ;
}
// on face ?
- if (!Find)
+ if (!Find) {
if ((_mesh->existConnectivity(MED_NODAL,MED_FACE))|(_mesh->existConnectivity(MED_DESCENDING,MED_FACE))) {
- int NumberOfFacesType = _mesh->getNumberOfTypes(MED_FACE) ;
- medGeometryElement * FacesType = _mesh->getTypes(MED_FACE) ;
- int * NumberOfFacesInFamily = new int[NumberOfFacesType] ;
- int NumberOfFacesTypeInFamily = 0 ;
- medGeometryElement * tmp_FacesTypes = new medGeometryElement[NumberOfFacesType];
- int ** tmp_FacesLists = new int*[NumberOfFacesType] ;
- int * GeometricTypeNumber = new int[NumberOfFacesType] ;
- int ** FaceFamilyNumber = _mesh->getMEDArrayFaceFamily();
- int * GlobalNumberingIndex = _mesh->getGlobalNumberingIndex(MED_FACE);
- // we search all face in this family
- for (int FaceTypeNumber=0; FaceTypeNumber<NumberOfFacesType; FaceTypeNumber++) {
- int NumberOfThisFaces = _mesh->getNumberOfElements(MED_FACE,FacesType[FaceTypeNumber]) ;
- int NumberOfFacesInThisFamily = 0 ;
- int * FaceOfThisFamilyNumber = FaceFamilyNumber[FaceTypeNumber];
- int * tmp_FacesList = new int[NumberOfThisFaces];
- for (int i=0; i<NumberOfThisFaces; i++)
- if (_identifier == FaceOfThisFamilyNumber[i]) {
- tmp_FacesList[NumberOfFacesInThisFamily]=i+GlobalNumberingIndex[FaceTypeNumber] ;
- NumberOfFacesInThisFamily++;
-
- SCRUTE(i);
- SCRUTE(NumberOfFacesInThisFamily);
-
- }
- if (NumberOfFacesInThisFamily>0) {// we have found some faces
- NumberOfFacesInFamily[NumberOfFacesTypeInFamily]=NumberOfFacesInThisFamily;
- int * FacesList=new int[NumberOfFacesInThisFamily] ;
- for (int i=0;i<NumberOfFacesInThisFamily;i++)
- FacesList[i]=tmp_FacesList[i] ;
- tmp_FacesLists[NumberOfFacesTypeInFamily]=FacesList ;
- tmp_FacesTypes[NumberOfFacesTypeInFamily]=FacesType[FaceTypeNumber];
- GeometricTypeNumber[NumberOfFacesTypeInFamily]=FaceTypeNumber+1;
- NumberOfFacesTypeInFamily++;
- }
- delete[] tmp_FacesList ;
- }
- // we define all attribut in SUPPORT :
- if (NumberOfFacesTypeInFamily>0) { // we have found faces
- Find = true ;
- _entity = MED_FACE ;
- _numberOfGeometricType = NumberOfFacesTypeInFamily ;
- _geometricType = new medGeometryElement[NumberOfFacesTypeInFamily] ;
- _geometricTypeNumber = new int[NumberOfFacesTypeInFamily] ;
- _isOnAllElts = false ;
- _numberOfEntities = new int[NumberOfFacesTypeInFamily] ;
- _totalNumberOfEntities=0;
- for (int i=0; i<NumberOfFacesTypeInFamily; i++) {
- _geometricType[i]=tmp_FacesTypes[i] ;
- _geometricTypeNumber[i]=GeometricTypeNumber[i];
- _numberOfEntities[i]=NumberOfFacesInFamily[i] ;
- _totalNumberOfEntities+=NumberOfFacesInFamily[i] ;
- }
- delete[] NumberOfFacesInFamily;
- delete[] tmp_FacesTypes;
- delete[] GeometricTypeNumber;
-
- // family on all FACE ?
-
- // we suppose family is never on all face !!!!!!!!!
- // in all case, family is only on boundary and connectivity is partial
-
-// if (_totalNumberOfEntities==Mesh->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS)) {
-// _isOnAllElts = true ;
-// delete[] _numberOfEntities ;
-// _numberOfEntities=(int*)NULL;
-// } else {
- _number=new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities);
- int *NumberValue=_number->getValue();
- int *NumberIndex=_number->getIndex();
- NumberIndex[0]=1;
- for (int i=0; i<_numberOfGeometricType; i++) {
- NumberIndex[i+1]=NumberIndex[i]+_numberOfEntities[i];
- for (int j=NumberIndex[i]; j<NumberIndex[i+1]; j++)
- NumberValue[j-1]=tmp_FacesLists[i][j-NumberIndex[i]];
- delete[] tmp_FacesLists[i];
- }
- delete[] tmp_FacesLists;
-// }
- }
+ Find = build(MED_FACE,MEDArrayFaceFamily) ;
}
+ }
// on edge ?
- if (!Find)
+ if (!Find) {
if ((_mesh->existConnectivity(MED_NODAL,MED_EDGE))|(_mesh->existConnectivity(MED_DESCENDING,MED_EDGE))) {
- int NumberOfEdgesType = _mesh->getNumberOfTypes(MED_EDGE) ;
- medGeometryElement * EdgesType = _mesh->getTypes(MED_EDGE) ;
- int * NumberOfEdgesInFamily = new int[NumberOfEdgesType] ;
- int NumberOfEdgesTypeInFamily = 0 ;
- medGeometryElement * tmp_EdgesTypes = new medGeometryElement[NumberOfEdgesType];
- int ** tmp_EdgesLists = new int*[NumberOfEdgesType] ;
- int * GeometricTypeNumber = new int[NumberOfEdgesType] ;
- int ** EdgeFamilyNumber = _mesh->getMEDArrayEdgeFamily();
- int * GlobalNumberingIndex = _mesh->getGlobalNumberingIndex(MED_EDGE);
- // we search all edge in this family
- for (int EdgeTypeNumber=0; EdgeTypeNumber<NumberOfEdgesType; EdgeTypeNumber++) {
- int NumberOfThisEdges = _mesh->getNumberOfElements(MED_EDGE,EdgesType[EdgeTypeNumber]) ;
- int NumberOfEdgesInThisFamily = 0 ;
- int * EdgeOfThisFamilyNumber = EdgeFamilyNumber[EdgeTypeNumber];
- int * tmp_EdgesList = new int[NumberOfThisEdges];
- for (int i=0; i<NumberOfThisEdges; i++)
- if (_identifier == EdgeOfThisFamilyNumber[i]) {
- tmp_EdgesList[NumberOfEdgesInThisFamily]=i+GlobalNumberingIndex[EdgeTypeNumber] ;
- NumberOfEdgesInThisFamily++;
- }
- if (NumberOfEdgesInThisFamily>0) {// we have found some edges
- NumberOfEdgesInFamily[NumberOfEdgesTypeInFamily]=NumberOfEdgesInThisFamily;
- int * EdgesList=new int[NumberOfEdgesInThisFamily] ;
- for (int i=0;i<NumberOfEdgesInThisFamily;i++)
- EdgesList[i]=tmp_EdgesList[i] ;
- tmp_EdgesLists[NumberOfEdgesTypeInFamily]=EdgesList ;
- tmp_EdgesTypes[NumberOfEdgesTypeInFamily]=EdgesType[EdgeTypeNumber];
- GeometricTypeNumber[NumberOfEdgesTypeInFamily]=EdgeTypeNumber+1;
- NumberOfEdgesTypeInFamily++;
- }
- delete[] tmp_EdgesList ;
- }
- // we define all attribut in SUPPORT :
- if (NumberOfEdgesTypeInFamily>0) { // we have found edges
- Find = true ;
- _entity = MED_EDGE ;
- _numberOfGeometricType = NumberOfEdgesTypeInFamily ;
- _geometricType = new medGeometryElement[NumberOfEdgesTypeInFamily] ;
- _geometricTypeNumber = new int[NumberOfEdgesTypeInFamily] ;
- _isOnAllElts = false ;
- _numberOfEntities = new int[NumberOfEdgesTypeInFamily] ;
- _totalNumberOfEntities=0;
- for (int i=0; i<NumberOfEdgesTypeInFamily; i++) {
- _geometricType[i]=tmp_EdgesTypes[i] ;
- _geometricTypeNumber[i]=GeometricTypeNumber[i];
- _numberOfEntities[i]=NumberOfEdgesInFamily[i] ;
- _totalNumberOfEntities+=NumberOfEdgesInFamily[i] ;
- }
- delete[] NumberOfEdgesInFamily;
- delete[] tmp_EdgesTypes;
- delete[] GeometricTypeNumber;
-
- // family on all EDGE ?
-
- // we suppose family is never on all edge !!!!!!!!!
- // in all case, family is only on boundary and connectivity is partial
-
-// if (_totalNumberOfEntities==Mesh->getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS)) {
-// _isOnAllElts = true ;
-// delete[] _numberOfEntities ;
-// _numberOfEntities=(int*)NULL;
-// } else {
- _number=new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities);
- int *NumberValue=_number->getValue();
- int *NumberIndex=_number->getIndex();
- NumberIndex[0]=1;
- for (int i=0; i<_numberOfGeometricType; i++) {
- NumberIndex[i+1]=NumberIndex[i]+_numberOfEntities[i];
- for (int j=NumberIndex[i]; j<NumberIndex[i+1]; j++)
- NumberValue[j-1]=tmp_EdgesLists[i][j-NumberIndex[i]];
- delete[] tmp_EdgesLists[i];
- }
- delete[] tmp_EdgesLists;
-// }
- }
+ Find = build(MED_EDGE,MEDArrayEdgeFamily) ;
}
+ }
// That's all !
// if not find : no entity in familly !!!
_numberOfGeometricType = 0 ;
_isOnAllElts = false ;
MESSAGE ("FAMILY() : No entity found !") ;
- } else { // set gauss point number to be equal one !
- _numberOfGaussPoint = new int[_numberOfGeometricType] ;
- for (int i=0; i<_numberOfGeometricType; i++)
- _numberOfGaussPoint[i]=1 ;
- }
+ }
+ // already done by support !!!!
+// else { // set gauss point number to be equal one !
+// _numberOfGaussPoint = new int[_numberOfGeometricType] ;
+// for (int i=0; i<_numberOfGeometricType; i++)
+// _numberOfGaussPoint[i]=1 ;
+// }
+};
+
+FAMILY::FAMILY(const FAMILY & m):SUPPORT(m)
+{
+ MESSAGE("FAMILY::FAMILY(FAMILY & m)");
+ _identifier = m._identifier;
+ _numberOfAttribute = m._numberOfAttribute;
+ if (m._attributeIdentifier != NULL)
+ {
+ _attributeIdentifier = new int[m._numberOfAttribute];
+ memcpy(_attributeIdentifier,m._attributeIdentifier,m._numberOfAttribute*sizeof(int));
+ }
+ else
+ _attributeIdentifier = (int *) NULL;
+ if (m._attributeValue != NULL)
+ {
+ _attributeValue = new int[m._numberOfAttribute];
+ memcpy(_attributeValue,m._attributeValue,m._numberOfAttribute*sizeof(int));
+ }
+ else
+ _attributeValue = (int *) NULL;
+ if (m._attributeDescription != NULL)
+ {
+ _attributeDescription = new string[m._numberOfAttribute];
+ for (int i=0;i<m._numberOfAttribute;i++)
+ _attributeDescription[i] = m._attributeDescription[i];
+ }
+ else
+ _attributeDescription = (string *) NULL;
+ _numberOfGroup = m._numberOfGroup;
+ if (m._groupName != NULL)
+ {
+ _groupName = new string[m._numberOfGroup];
+ for (int i=0;i<m._numberOfGroup;i++)
+ _groupName[i]=m._groupName[i];
+ }
+ else
+ _groupName = (string *) NULL;
+};
+
+FAMILY::FAMILY(const SUPPORT & s):SUPPORT(s)
+{
+ MESSAGE("FAMILY::FAMILY(const SUPPORT & s)");
+
+ _identifier = 0;
+ _numberOfAttribute = 0;
+ _attributeIdentifier = (int*) NULL;
+ _attributeValue = (int*) NULL;
+ _attributeDescription = (string*) NULL;
+ _numberOfGroup = 0;
+ _groupName= (string*) NULL;
};
FAMILY::FAMILY(FAMILY & m):SUPPORT(m)
_groupName = fam._groupName;
return *this;
};
+
+ostream & operator<<(ostream &os, FAMILY &myFamily)
+{
+ // how do cast without duplicate ?
+ os << (SUPPORT) myFamily;
+
+ os << " - Identifier : "<<myFamily.getIdentifier()<<endl;
+ int numberofattributes = myFamily.getNumberOfAttributes();
+ os << " - Attributes ("<<numberofattributes<<") :"<<endl;
+ for (int j=1;j<numberofattributes+1;j++)
+ os << " * "<<myFamily.getAttributeIdentifier(j)<<" : "<<myFamily.getAttributeValue(j)<<", "<<myFamily.getAttributeDescription(j).c_str()<<endl;
+ int numberofgroups = myFamily.getNumberOfGroups();
+ os << " - Groups ("<<numberofgroups<<") :"<<endl;
+ for (int j=1;j<numberofgroups+1;j++)
+ os << " * "<<myFamily.getGroupName(j).c_str()<<endl ;
+
+ return os;
+};
+
+bool FAMILY::build(medEntityMesh Entity,int **FamilyNumber /* from MED file */)
+{
+ MESSAGE("FAMILY::build(medEntityMesh Entity,int **FamilyNumber /* from MED file */)");
+ bool Find = false ;
+ // Get types information from <_mesh>
+ int numberOfTypes = _mesh->getNumberOfTypes(Entity) ;
+ const medGeometryElement * types = _mesh->getTypes(Entity) ;
+
+ int * numberOfElementsInFamily = new int[numberOfTypes] ;
+ int numberOfElementTypesInFamily = 0 ;
+
+ medGeometryElement * tmp_Types = new medGeometryElement[numberOfTypes];
+ int ** tmp_ElementsLists = new int*[numberOfTypes] ;
+ // int * GeometricTypeNumber = new int[numberOfTypes] ;
+ const int * GlobalNumberingIndex = _mesh->getGlobalNumberingIndex(Entity);
+
+ // we search for all elements in this family
+ for (int TypeNumber=0; TypeNumber < numberOfTypes; TypeNumber++) {
+
+ int NumberOfElements = _mesh->getNumberOfElements(Entity,types[TypeNumber]) ;
+ int NumberOfElementsInThisFamily = 0 ;
+ int * ElementsOfThisFamilyNumber = FamilyNumber[TypeNumber];
+ int * tmp_ElementsList = new int[NumberOfElements];
+
+ for (int i=0; i<NumberOfElements; i++)
+ if (_identifier == ElementsOfThisFamilyNumber[i]) {
+ tmp_ElementsList[NumberOfElementsInThisFamily]=i+GlobalNumberingIndex[TypeNumber] ;
+ NumberOfElementsInThisFamily++;
+ }
+
+ if (NumberOfElementsInThisFamily>0) {// we have found some elements
+ numberOfElementsInFamily[numberOfElementTypesInFamily]=NumberOfElementsInThisFamily;
+
+ //int * ElementsList = tmp_ElementsList.resize(NumberOfElementsInThisFamily);
+ int * ElementsList = new int[NumberOfElementsInThisFamily] ;
+ memcpy(ElementsList,tmp_ElementsList,sizeof(int)*NumberOfElementsInThisFamily); // RESIZE de tmp_NodesList serait plus efficace !!!!!!!!
+
+ tmp_ElementsLists[numberOfElementTypesInFamily]=ElementsList ;
+ tmp_Types[numberOfElementTypesInFamily]=types[TypeNumber];
+ // GeometricTypeNumber[numberOfElementTypesInFamily]=TypeNumber+1;
+ numberOfElementTypesInFamily++;
+ // delete [] ElementsList;
+ }
+ delete[] tmp_ElementsList;
+ }
+
+ // we define all attribut in SUPPORT :
+ if (numberOfElementTypesInFamily>0) { // we have found elements
+ Find = true ;
+ _entity = Entity ;
+ _numberOfGeometricType = numberOfElementTypesInFamily ;
+ if (_geometricType!=NULL) delete[] _geometricType ;
+ _geometricType = new medGeometryElement[numberOfElementTypesInFamily] ;
+ _isOnAllElts = false ;
+ if (_numberOfElements!=NULL) delete[] _numberOfElements ;
+ _numberOfElements = new int[numberOfElementTypesInFamily] ;
+ _totalNumberOfElements=0;
+
+ //_numberOfGaussPoint = new int[numberOfElementTypesInFamily] ;
+
+ //int * numberIndex = new int[numberOfElementTypesInFamily+1];
+ //numberIndex[0]=1;
+ for (int i=0; i<numberOfElementTypesInFamily; i++) {
+ _geometricType[i]=tmp_Types[i] ;
+ //numberIndex[i+1]=numberIndex[i]+numberOfElementsInFamily[i];
+ _numberOfElements[i]=numberOfElementsInFamily[i]; // plutot un resize !!
+ _totalNumberOfElements+=_numberOfElements[i];
+ //_numberOfGaussPoint[i]=1;
+ }
+ // delete[] numberOfElementsInFamily;
+ // delete[] tmp_Types;
+ // delete[] GeometricTypeNumber;
+
+ // family on all ELEMENT ?
+ if (_totalNumberOfElements == _mesh->getNumberOfElements(Entity,MED_ALL_ELEMENTS)) {
+ _isOnAllElts = true ;
+ // all others attributs are rights !
+ for (int i=0; i<_numberOfGeometricType; i++)
+ delete[] tmp_ElementsLists[i];
+ } else {
+ int *NumberValue = new int[_totalNumberOfElements];
+ int *NumberIndex = new int[_numberOfGeometricType+1];
+ NumberIndex[0]=1;
+ for (int i=0; i<_numberOfGeometricType; i++) {
+ NumberIndex[i+1]=NumberIndex[i]+_numberOfElements[i];
+ for (int j=NumberIndex[i]; j<NumberIndex[i+1]; j++)
+ NumberValue[j-1]=tmp_ElementsLists[i][j-NumberIndex[i]];
+ delete[] tmp_ElementsLists[i];
+ }
+ if(_number!=NULL) delete _number ;
+ _number = new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,NumberIndex,NumberValue);
+ delete[] NumberIndex ;
+ delete[] NumberValue ;
+ }
+ }
+ delete[] tmp_Types;
+ delete[] numberOfElementsInFamily;
+
+ delete[] tmp_ElementsLists;
+
+ return Find ;
+}
+
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Field.cxx
+// Module : MED
+
using namespace std;
#include "MEDMEM_Field.hxx"
// FIELD_ : Constructors
// ---------------------------------
FIELD_::FIELD_():
+ _isRead(false),
_name(""), _description(""), _support((SUPPORT *)NULL),
- _numberOfComponents(0), _componentsTypes((int *)NULL),
+ _numberOfComponents(0), _numberOfValues(0),_componentsTypes((int *)NULL),
_componentsNames((string *)NULL),
_componentsDescriptions((string *)NULL),
_componentsUnits((UNIT*)NULL),
}
FIELD_::FIELD_(const SUPPORT * Support, const int NumberOfComponents):
+ _isRead(false),
_name(""), _description(""), _support(Support),
_numberOfComponents(NumberOfComponents),
_iterationNumber(-1),_time(0.0),_orderNumber(-1)
{
MESSAGE("FIELD_(const SUPPORT * Support, const int NumberOfComponents)");
+ _numberOfValues = Support->getNumberOfElements(MED_ALL_ELEMENTS);
_componentsTypes = new int[NumberOfComponents] ;
_componentsNames = new string[NumberOfComponents];
_componentsDescriptions = new string[NumberOfComponents];
FIELD_::FIELD_(const FIELD_ &m)
{
+ _isRead = m._isRead ;
_name = m._name;
_description = m._description;
_support = m._support;
_numberOfComponents = m._numberOfComponents;
+ _numberOfValues = m._numberOfValues;
if (m._componentsTypes != NULL)
{
_time = m._time;
_orderNumber = m._orderNumber;
_valueType = m._valueType;
+ //_drivers = m._drivers ; // PG : Well, same driver, what about m destructor !
+
}
FIELD_::~FIELD_()
delete[] _componentsUnits ;
if ( _MEDComponentsUnits !=NULL)
delete[] _MEDComponentsUnits ;
+
+ // delete driver
+// vector<GENDRIVER *>::const_iterator it ;
+// SCRUTE(_drivers.size());
+// int i=0;
+// for (it=_drivers.begin();it!=_drivers.end();it++) {
+// i++;
+// SCRUTE(i);
+// delete (*it) ;
+
+
+ MESSAGE("In this object FIELD_ there is(are) " << _drivers.size() << " driver(s)");
+
+ for (int index=0; index < _drivers.size(); index++ )
+ {
+ SCRUTE(_drivers[index]);
+ if ( _drivers[index] != NULL) delete _drivers[index];
+ }
}
// void FIELD_::setIterationNumber (int IterationNumber) {};
// void FIELD_::setOrderNumber (int OrderNumber) {};
// void FIELD_::setFieldName (string& fieldName) {};
-void FIELD_::rmDriver (int index) {};
-int FIELD_::addDriver (driverTypes driverType,
- const string & fileName,
- const string & driverFieldName) {} ;
-int FIELD_::addDriver (GENDRIVER & driver) {};
-void FIELD_::write (const GENDRIVER &) {};
-void FIELD_::read (const GENDRIVER &) {};
+void FIELD_::rmDriver (int index) {};
+int FIELD_::addDriver (driverTypes driverType,
+ const string & fileName,
+ const string & driverFieldName) {};
+int FIELD_::addDriver (GENDRIVER & driver) {};
+void FIELD_::write (const GENDRIVER &) {};
+void FIELD_::read (const GENDRIVER &) {};
+void FIELD_::write (int index, const string & driverName) {};
+void FIELD_::read (int index) {};
// void FIELD_::setValueType(med_type_champ ValueType) {};
// med_type_champ FIELD_::getValueType() {};
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_GenDriver.cxx
+// Module : MED
+
using namespace std;
#include "MEDMEM_GenDriver.hxx"
#include "MEDMEM_STRING.hxx"
_status(MED_CLOSED),
_driverType(NO_DRIVER) {}
-GENDRIVER::GENDRIVER(const GENDRIVER & genDriver):_id(MED_INVALID), _fileName(genDriver._fileName),
- _accessMode(genDriver._accessMode),
- _status(genDriver._status),_driverType(NO_DRIVER) {}
+GENDRIVER::GENDRIVER(const GENDRIVER & genDriver):
+ //_id(MED_INVALID),
+ _id(genDriver._id),
+ _fileName(genDriver._fileName),
+ _accessMode(genDriver._accessMode),
+ _status(genDriver._status),
+ _driverType(genDriver._driverType)
+{}
+
GENDRIVER::~GENDRIVER() {}
const char * LOC = "bool GENDRIVER::operator ==(const GENDRIVER &genDriver) const : ";
- BEGIN_OF(LOC);
+ MESSAGE(LOC);
return ( _id == genDriver._id ) &&
( _driverType == genDriver._driverType );
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_MedMedDriver.cxx
+// Module : MED
+
using namespace std;
# include <string>
# include "MEDMEM_DriversDef.hxx"
# include "MEDMEM_Mesh.hxx"
+# include "MEDMEM_Grid.hxx"
# include "MEDMEM_Field.hxx"
// EN ATTENDANT L'utilisation de MedFieldDriver.hxx ds Field.hxx
# include "MEDMEM_MedFieldDriver.hxx"
MED_MED_DRIVER::MED_MED_DRIVER(const string & fileName, MED * const ptrMed):
GENDRIVER(fileName,MED_EN::MED_RDWR), _ptrMed(ptrMed), _medIdt(MED_INVALID)
{
- _ptrMed->addDriver(*this); // OU RECUPERER L'ID.
+ _ptrMed->addDriver(*this); // The specific MED driver id is set within the addDriver method.
}
MED_MED_DRIVER::MED_MED_DRIVER(const string & fileName,
}
//REM : As t'on besoin du champ _status : _medIdt <-> _status ? Oui
+MED_MED_DRIVER::MED_MED_DRIVER(const MED_MED_DRIVER & driver):
+ GENDRIVER(driver),
+ _ptrMed(driver._ptrMed),
+ _medIdt(MED_INVALID)
+{
+}
+
+MED_MED_DRIVER::~MED_MED_DRIVER()
+{
+ MESSAGE("MED_MED_DRIVER::~MED_MED_DRIVER() has been destroyed");
+}
+
+// GENDRIVER * MED_MED_DRIVER::copy(void) const
+// {
+// return new MED_MED_DRIVER(*this) ;
+// }
+void MED_MED_DRIVER::read()
+{
+}
+void MED_MED_DRIVER::readFileStruct()
+{
+}
+void MED_MED_DRIVER::write() const
+{
+}
+GENDRIVER * MED_MED_DRIVER::copy(void) const
+{
+}
+void MED_MED_DRIVER::writeFrom() const
+{
+}
+
-void MED_MED_DRIVER::open() {
+
+void MED_MED_DRIVER::open()
+ throw (MEDEXCEPTION)
+{
const char * LOC ="MED_MED_DRIVER::open() : ";
BEGIN_OF(LOC);
// REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE
- if ( _medIdt != MED_INVALID )
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "_medIdt is already in use, please close the file |"
- << _fileName << "| before calling open()"
- )
- );
+// if ( _medIdt != MED_INVALID )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+// << "_medIdt is already in use, please close the file |"
+// << _fileName << "| before calling open()"
+// )
+// );
- if ( _status != MED_CLOSED )
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "_status is closed, please close the file |"
- << _fileName << "| before calling open()"
- )
- );
+// if ( _status != MED_CLOSED )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+// << "_status is closed, please close the file |"
+// << _fileName << "| before calling open()"
+// )
+// );
if ( _fileName == "" )
throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
)
);
+ MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
_medIdt = MEDouvrir( (const_cast <char *> (_fileName.c_str())), (MED_FR::med_mode_acces) _accessMode);
+ MESSAGE(LOC<<" _medIdt = "<<_medIdt);
- if (_medIdt > 0) _status=MED_OPENED;
+ if (_medIdt > 0)
+ _status=MED_OPENED;
else {
_status = MED_CLOSED;
_medIdt = MED_INVALID;
)
);
}
-
+
END_OF(LOC);
}
-void MED_MED_DRIVER::close() {
+void MED_MED_DRIVER::close()
+{
MED_FR::med_int err = 0;
const char * LOC = "MED_MED_DRIVER::close() : ";
- if ( _status == MED_CLOSED)
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
- << _fileName << "| is already closed"
- )
- );
+// if ( _status == MED_CLOSED)
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
+// << _fileName << "| is already closed"
+// )
+// );
- if ( _medIdt == MED_INVALID )
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_medIdt invalid, but the file |"
- << _fileName << "| seems to be openned !"
- )
- );
+// if ( _medIdt == MED_INVALID )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_medIdt invalid, but the file |"
+// << _fileName << "| seems to be openned !"
+// )
+// );
+
+ if ( _medIdt != MED_INVALID )
+ err=MEDfermer(_medIdt);
- err=MEDfermer(_medIdt);
+// if (err != MED_VALID)
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
+// << _fileName << "| couldn't be closed"
+// )
+// );
_status = MED_CLOSED;
_medIdt = MED_INVALID;
-
- if (err != MED_VALID)
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
- << _fileName << "| couldn't be closed"
- )
- );
-
+
END_OF(LOC);
}
+// ------------- Read Only Part --------------
+
+MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER():MED_MED_DRIVER()
+{
+}
+
+MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed):
+ MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_RDONLY)
+{
+ MESSAGE("MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed) Constructeur read only");
+}
+
+MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const MED_MED_RDONLY_DRIVER & driver):
+ MED_MED_DRIVER(driver)
+{
+}
+
+MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER()
+{
+ MESSAGE("MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER() has been destroyed");
+}
-void MED_MED_DRIVER::readFileStruct( void )
+GENDRIVER * MED_MED_RDONLY_DRIVER::copy(void) const
+{
+ return new MED_MED_RDONLY_DRIVER(*this) ;
+}
+
+void MED_MED_RDONLY_DRIVER::readFileStruct( void )
+ throw (MEDEXCEPTION)
{
const char * LOC = "MED_MED_DRIVER::readFileStruct() : ";
int err,i,j;
MESH_ENTITIES::const_iterator currentEntity;
for (i=1;i<=numberOfMeshes;i++) {
+
+ // find out if the mesh is a Grid
+
+ int isAGrid = false;
+ MED_FR::med_grid_type type;
+
+ err = MEDgridInfo (_medIdt, i, &isAGrid, &type);
+ if (err != MED_VALID)
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "error in MEDgridInfo()") );
+
err = MEDmaaInfo(_medIdt, i ,meshName, &meshDim) ;
if (err != MED_VALID)
throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": can't get information about the mesh n°"
);
MESSAGE(LOC<<": Mesh n°"<<i<<" nammed "<<meshName);
- ptrMesh = new MESH();
- MED_MESH_RDWR_DRIVER * _ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
- _ptrDriver->setId ( getId() );
- _ptrDriver->setMeshName ( meshName );
- ptrMesh->addDriver(*_ptrDriver);
- _ptrMed->_meshes[meshName] = ptrMesh;
+ if (isAGrid)
+ ptrMesh = new GRID((MED_EN::med_grid_type) type);
+ else
+ ptrMesh = new MESH();
+
+ //MED_MESH_RDWR_DRIVER * _ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
+ MED_EN::med_mode_acces myMode = getAccessMode();
+ MED_MESH_DRIVER * ptrDriver ;
+ switch (myMode) {
+ case MED_EN::MED_LECT:
+ ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
+ break ;
+ case MED_EN::MED_REMP:
+ ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
+ break ;
+ case MED_EN::MED_ECRI: // should never append !!
+ ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
+ break;
+ default:
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
+ }
+ ptrDriver->setId ( getId() );
+ ptrDriver->setMeshName ( meshName );
+ ptrMesh->addDriver(*ptrDriver);
+ delete ptrDriver ;
+
+ if (isAGrid)
+ _ptrMed->_meshes[meshName] = (MESH *) ptrMesh;
+ else
+ _ptrMed->_meshes[meshName] = ptrMesh;
+
+ ptrMesh->setName(meshName);
+
+ SCRUTE(ptrMesh);
+
+ MESSAGE(LOC<<"is" << (isAGrid ? "" : " NOT") << " a GRID and its name is "<<ptrMesh->getName());
+
// we create all global support (for each entity type :
for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
string supportName="SupportOnAll_" ;
supportName+=entNames[(MED_FR::med_entite_maillage)(*currentEntity).first] ;
- (_ptrMed->_support)[meshName][(MED_FR::med_entite_maillage)(*currentEntity).first]=new SUPPORT(ptrMesh,supportName,(MED_EN::medEntityMesh) (*currentEntity).first) ;
+ //(_ptrMed->_support)[meshName][(MED_FR::med_entite_maillage)(*currentEntity).first]=new SUPPORT(ptrMesh,supportName,(MED_EN::medEntityMesh) (*currentEntity).first) ;
+ SUPPORT* mySupport = new SUPPORT() ;
+ mySupport->setName(supportName);
+ mySupport->setMesh(ptrMesh);
+ mySupport->setEntity((MED_EN::medEntityMesh) (*currentEntity).first);
+ mySupport->setAll(true);
+ (_ptrMed->_support)[meshName][(MED_FR::med_entite_maillage)(*currentEntity).first] = mySupport ;
}
}
}
((FIELD<MED_FR::med_int>*) ptrField)->setNumberOfComponents(numberOfComponents);
((FIELD<MED_FR::med_int>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
MESSAGE("#### SET NAME in FIELD : "<<fieldName);
- ptrDriver = new MED_FIELD_RDWR_DRIVER<MED_FR::med_int> (_fileName, (FIELD<MED_FR::med_int> *) ptrField);
+
+ MED_EN::med_mode_acces myMode = getAccessMode();
+ switch (myMode) {
+ case MED_EN::MED_LECT:
+ ptrDriver = new MED_FIELD_RDONLY_DRIVER<MED_FR::med_int>(_fileName, (FIELD<MED_FR::med_int> *)ptrField);
+ break ;
+ case MED_EN::MED_REMP:
+ ptrDriver = new MED_FIELD_RDWR_DRIVER<MED_FR::med_int>(_fileName, (FIELD<MED_FR::med_int> *)ptrField);
+ break ;
+ case MED_EN::MED_ECRI: // should never append !!
+ ptrDriver = new MED_FIELD_RDONLY_DRIVER<MED_FR::med_int>(_fileName, (FIELD<MED_FR::med_int> *)ptrField);
+ break;
+ default:
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
+ }
break;
}
case MED_FR::MED_REEL64 : {
((FIELD<MED_FR::med_float>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
MESSAGE("#### SET NAME in FIELD : "<<fieldName);
- ptrDriver = new MED_FIELD_RDWR_DRIVER<MED_FR::med_float>(_fileName, (FIELD<MED_FR::med_float> *) ptrField);
+ MED_EN::med_mode_acces myMode = getAccessMode();
+ switch (myMode) {
+ case MED_EN::MED_LECT:
+ ptrDriver = new MED_FIELD_RDONLY_DRIVER<MED_FR::med_float>(_fileName, (FIELD<MED_FR::med_float> *)ptrField);
+ break ;
+ case MED_EN::MED_REMP:
+ ptrDriver = new MED_FIELD_RDWR_DRIVER<MED_FR::med_float>(_fileName, (FIELD<MED_FR::med_float> *)ptrField);
+ break ;
+ case MED_EN::MED_ECRI: // should never append !!
+ ptrDriver = new MED_FIELD_RDONLY_DRIVER<MED_FR::med_float>(_fileName, (FIELD<MED_FR::med_float> *)ptrField);
+ break;
+ default:
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
+ }
break;
}
default : {
MESSAGE("###### ptrDriver->setFieldName : #"<<fieldName<<"#");
ptrDriver->setFieldName(fieldName);
ptrField->addDriver(*ptrDriver);
-
+ // driver is duplicated : remove it
+ delete ptrDriver;
+
DT_IT_ dtIt;
dtIt.dt = timeStepNumber;
dtIt.it = orderNumber;
// This method ask the drivers of all MESH/FIELD objects created from this MED driver
// to read themselves
-void MED_MED_DRIVER::read( void ) {
-
+void MED_MED_RDONLY_DRIVER::read( void )
+ throw (MEDEXCEPTION) // from objects method read !
+{
const char * LOC = "MED_MED_DRIVER::read() : ";
BEGIN_OF(LOC);
+
const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
map<MESH_NAME_,MESH*>::const_iterator currentMesh;
for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ )
(*currentMesh).second->read(*this);
+ //(*currentMesh).second->read(); // default reader, from readFileStruct
+ // PROVISOIRE
+ _ptrMed->updateSupport() ;
+
for ( currentField =_meshName.begin(); currentField != _meshName.end(); currentField++ )
(*currentField).first->read(*this);
+ //(*currentField).first->read(); // default reader, from readFileStruct
END_OF(LOC);
}
+void MED_MED_RDONLY_DRIVER::write(void) const
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("MED_MED_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
+}
+
+void MED_MED_RDONLY_DRIVER::writeFrom(void) const
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("MED_MED_RDONLY_DRIVER::writeFrom : Can't write with a RDONLY driver !");
+}
+
+// ------------- Write Only Part --------------
+
+MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER():MED_MED_DRIVER()
+{
+}
+
+MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed):
+ MED_MED_DRIVER(fileName,ptrMed)
+{}
+
+MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const MED_MED_WRONLY_DRIVER & driver):
+ MED_MED_DRIVER(driver)
+{}
+
+MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER()
+{
+ MESSAGE("MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER() has been destroyed");
+}
+
+GENDRIVER * MED_MED_WRONLY_DRIVER::copy(void) const
+{
+ return new MED_MED_WRONLY_DRIVER(*this) ;
+}
+
+void MED_MED_WRONLY_DRIVER::read(void)
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("MED_MED_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
+}
+
+void MED_MED_WRONLY_DRIVER::readFileStruct(void)
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("MED_MED_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
+}
+
// This method ask the drivers of all MESH/FIELD objects created from this MED driver
// to write themselves
-void MED_MED_DRIVER::writeFrom( void) const {
-
+void MED_MED_WRONLY_DRIVER::writeFrom( void) const
+ throw (MEDEXCEPTION) //from object method write !
+{
const char * LOC = "MED_MED_DRIVER::writeFrom() : ";
BEGIN_OF(LOC);
for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
try {
(*currentMesh).second->write(*this);
- // A CREER pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id
+ // On utilise pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id
}
catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
continue;
-}
+ }
}
for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
}
-void MED_MED_DRIVER::write(void ) const {
-
+void MED_MED_WRONLY_DRIVER::write(void ) const
+ throw (MEDEXCEPTION) // from object method write !
+{
const char * LOC = "MED_MED_DRIVER::write() : ";
int current;
map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
- current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName);
+ //current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName);
+ current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName,(*currentMesh).second->getName());
+ // put right _id in Mesh driver (same as this._id)
(*currentMesh).second->_drivers[current]->setId( getId() );
+ //(*currentMesh).second->write(current) ;
}
- // for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
- // current = (*currentField).first->addDriver(MED_DRIVER,_fileName);
- // (*currentField).first->_drivers[current]->setId( getId() );
- // }
+ for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
+ //current = (*currentField).first->addDriver(MED_DRIVER,_fileName);
+ current = (*currentField).first->addDriver(MED_DRIVER,_fileName,(*currentField).first->getName());
+ // put right _id in Field driver (same as this._id)
+ (*currentField).first->_drivers[current]->setId( getId() );
+ //(*currentField).first->write(current) ;
+ }
- // *this.writeFrom();
+ // that's work, but it is more efficenty to write directly when we had driver, no ?
+ writeFrom();
END_OF(LOC);
}
-MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed):
- MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_RDONLY)
-{
- MESSAGE("MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed) Constructeur read only");
-}
-
-void MED_MED_RDONLY_DRIVER::open() {
- BEGIN_OF("MED_MED_RDONLY_DRIVER::open()");
- MED_MED_DRIVER::open();
- END_OF("MED_MED_RDONLY_DRIVER::open()");
-}
-
-void MED_MED_RDONLY_DRIVER::close() {
- BEGIN_OF("MED_MED_RDONLY_DRIVER::close()");
- MED_MED_DRIVER::close();
- END_OF("MED_MED_RDONLY_DRIVER::clode()");
-}
-
-void MED_MED_RDONLY_DRIVER::read(void) {
- BEGIN_OF("MED_MED_RDONLY_DRIVER::read(void)");
- MED_MED_DRIVER::read();
- END_OF("MED_MED_RDONLY_DRIVER::read(void)");
-}
-
-void MED_MED_RDONLY_DRIVER::readFileStruct(void) {
- BEGIN_OF("MED_MED_RDONLY_DRIVER::readFileStruct(void)");
- MED_MED_DRIVER::readFileStruct();
- END_OF("MED_MED_RDONLY_DRIVER::readFileStruct(void)");
-}
+// ------------- Read Write Part --------------
-MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed):
- MED_MED_DRIVER(fileName,ptrMed)
+MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER()
{}
-void MED_MED_WRONLY_DRIVER::open() {
- BEGIN_OF("MED_MED_WRONLY_DRIVER::open()");
- MED_MED_DRIVER::open();
- END_OF("MED_MED_WRONLY_DRIVER::open()");
-}
-
-void MED_MED_WRONLY_DRIVER::close() {
- BEGIN_OF("MED_MED_WRONLY_DRIVER::close()");
- MED_MED_DRIVER::close();
- END_OF("MED_MED_WRONLY_DRIVER::clode()");
-}
-
-void MED_MED_WRONLY_DRIVER::write(void) const {
- BEGIN_OF("MED_MED_WRONLY_DRIVER::write(void) const");
- MED_MED_DRIVER::write();
- END_OF("MED_MED_WRONLY_DRIVER::write(void) const");
-}
-
-void MED_MED_WRONLY_DRIVER::writeFrom(void) const {
- BEGIN_OF("MED_MED_WRONLY_DRIVER::writeFrom(void) const");
- MED_MED_DRIVER::writeFrom();
- END_OF("MED_MED_WRONLY_DRIVER::writeFrom(void) const");
-}
-
MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER(const string & fileName, MED * const ptrMed):
MED_MED_DRIVER(fileName,ptrMed)
{}
-void MED_MED_RDWR_DRIVER::open() {
- BEGIN_OF("MED_MED_RDWR_DRIVER::open()");
- MED_MED_DRIVER::open();
- END_OF("MED_MED_RDWR_DRIVER::open()");
+MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER(const MED_MED_RDWR_DRIVER & driver):
+ MED_MED_DRIVER(driver)
+{}
+
+MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER() {
+ MESSAGE("MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER() has been destroyed");
}
-void MED_MED_RDWR_DRIVER::close() {
- BEGIN_OF("MED_MED_RDWR_DRIVER::close()");
- MED_MED_DRIVER::close();
- END_OF("MED_MED_RDWR_DRIVER::close()");
+GENDRIVER * MED_MED_RDWR_DRIVER::copy(void) const
+{
+ return new MED_MED_RDWR_DRIVER(*this) ;
}
-void MED_MED_RDWR_DRIVER::read(void) {
+void MED_MED_RDWR_DRIVER::read(void)
+ throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::read()
+{
BEGIN_OF("MED_MED_RDWR_DRIVER::read(void)");
MED_MED_RDONLY_DRIVER::read();
END_OF("MED_MED_RDWR_DRIVER::read(void)");
}
-void MED_MED_RDWR_DRIVER::readFileStruct(void) {
+void MED_MED_RDWR_DRIVER::readFileStruct(void)
+ throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::readFileStruct()
+{
BEGIN_OF("MED_MED_RDWR_DRIVER::readFileStruct(void)");
MED_MED_RDONLY_DRIVER::readFileStruct();
END_OF("MED_MED_RDWR_DRIVER::readFileStruct(void)");
}
-void MED_MED_RDWR_DRIVER::write(void) const {
+void MED_MED_RDWR_DRIVER::write(void) const
+ throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::write()
+{
BEGIN_OF("MED_MED_RDWR_DRIVER::write(void) const");
MED_MED_WRONLY_DRIVER::write();
END_OF("MED_MED_RDWR_DRIVER::write(void) const");
}
-void MED_MED_RDWR_DRIVER::writeFrom(void) const {
+void MED_MED_RDWR_DRIVER::writeFrom(void) const
+ throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::writeFrom();
+{
BEGIN_OF("MED_MED_RDWR_DRIVER::writeFrom(void) const");
MED_MED_WRONLY_DRIVER::writeFrom();
END_OF("MED_MED_RDWR_DRIVER::writeFrom(void) const");
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Mesh.cxx
+// Module : MED
+
using namespace std;
/*
File Mesh.cxx
#include <list>
#include <map>
+#include "MEDMEM_DriversDef.hxx"
#include "MEDMEM_Field.hxx"
#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Support.hxx"
#include "MEDMEM_Family.hxx"
#include "MEDMEM_Group.hxx"
+#include "MEDMEM_Coordinate.hxx"
#include "MEDMEM_Connectivity.hxx"
#include "MEDMEM_CellModel.hxx"
+#include "MEDMEM_Grid.hxx"
//update Families with content list
//int family_count(int family_number, int count, int * entities_number, int * entities_list) ;
// MESH::INSTANCE_DE<MED_MESH_RDONLY_DRIVER> MESH::inst_med_rdonly ;
//const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med_rdonly , &MESH::inst_med_rdwr } ;
+// Add a similar line for your personnal driver (step 3)
MESH::INSTANCE_DE<MED_MESH_RDWR_DRIVER> MESH::inst_med ;
-const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med } ;
+MESH::INSTANCE_DE<GIBI_MESH_RDWR_DRIVER> MESH::inst_gibi ;
+// Add your own driver in the driver list (step 4)
+// Note the list must be coherent with the driver type list defined in MEDMEM_DRIVER.hxx.
+const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med, &MESH::inst_gibi } ;
/*! Add a MESH driver of type (MED_DRIVER, ....) associated with file <fileName>. The meshname used in the file
is <driverName>. addDriver returns an int handler. */
BEGIN_OF(LOC);
// A faire : Vérifier que le driver est de type MESH.
- _drivers.push_back(&driver);
+ GENDRIVER * newDriver = driver.copy() ;
+
+ _drivers.push_back(newDriver);
return _drivers.size()-1;
-
+
END_OF(LOC);
}
void MESH::init() {
+ const char * LOC = "MESH::init(): ";
+
+ BEGIN_OF(LOC);
+
string _name = "NOT DEFINED"; // A POSITIONNER EN FCT DES IOS ?
- _numberOfMEDNodeFamily = MED_INVALID;
- _MEDArrayNodeFamily = (int * ) NULL; // SOLUTION TEMPORAIRE
- _numberOfMEDCellFamily = (int * ) NULL;
- _numberOfMEDFaceFamily = (int * ) NULL;
- _numberOfMEDEdgeFamily = (int * ) NULL;
- _MEDArrayCellFamily = (int **) NULL; // SOLUTION TEMPORAIRE
- _MEDArrayFaceFamily = (int **) NULL; // SOLUTION TEMPORAIRE
- _MEDArrayEdgeFamily = (int **) NULL; // SOLUTION TEMPORAIRE
-
COORDINATE * _coordinate = (COORDINATE *) NULL;
CONNECTIVITY * _connectivity = (CONNECTIVITY *) NULL;
_numberOfFacesGroups = 0;
_numberOfEdgesGroups = 0;
+ _isAGrid = false;
};
/*! Create an empty MESH. */
-MESH::MESH() {
+MESH::MESH():_coordinate(NULL),_connectivity(NULL) {
init();
};
-MESH::MESH(const MESH &m)
+MESH::MESH(MESH &m)
{
- // VERIFIER QUE TS LES OPERATEURS DE RECOPIE DES ATTRIBUTS
- // SONT CORRECTS.
- *this = m;
+ _name=m._name;
+ _isAGrid = m._isAGrid;
+
+ if (m._coordinate != NULL)
+ _coordinate = new COORDINATE(* m._coordinate);
+ else
+ _coordinate = (COORDINATE *) NULL;
+
+ if (m._connectivity != NULL)
+ _connectivity = new CONNECTIVITY(* m._connectivity);
+ else
+ _connectivity = (CONNECTIVITY *) NULL;
+
+ _spaceDimension = m._spaceDimension;
+ _meshDimension = m._meshDimension;
+ _numberOfNodes = m._numberOfNodes;
+
+ _numberOfNodesFamilies = m._numberOfNodesFamilies;
+ _familyNode = m._familyNode;
+ for (int i=0; i<m._numberOfNodesFamilies; i++)
+ {
+ _familyNode[i] = new FAMILY(* m._familyNode[i]);
+ _familyNode[i]->setMesh(this);
+ }
+
+ _numberOfCellsFamilies = m._numberOfCellsFamilies;
+ _familyCell = m._familyCell;
+ for (int i=0; i<m._numberOfCellsFamilies; i++)
+ {
+ _familyCell[i] = new FAMILY(* m._familyCell[i]);
+ _familyCell[i]->setMesh(this);
+ }
+
+ _numberOfFacesFamilies = m._numberOfFacesFamilies;
+ _familyFace = m._familyFace;
+ for (int i=0; i<m._numberOfFacesFamilies; i++)
+ {
+ _familyFace[i] = new FAMILY(* m._familyFace[i]);
+ _familyFace[i]->setMesh(this);
+ }
+
+ _numberOfEdgesFamilies = m._numberOfEdgesFamilies;
+ _familyEdge = m._familyEdge;
+ for (int i=0; i<m._numberOfEdgesFamilies; i++)
+ {
+ _familyEdge[i] = new FAMILY(* m._familyEdge[i]);
+ _familyEdge[i]->setMesh(this);
+ }
+
+ _numberOfNodesGroups = m._numberOfNodesGroups;
+ _groupNode = m._groupNode;
+ for (int i=0; i<m._numberOfNodesGroups; i++)
+ {
+ _groupNode[i] = new GROUP(* m._groupNode[i]);
+ _groupNode[i]->setMesh(this);
+ }
+
+ _numberOfCellsGroups = m._numberOfCellsGroups;
+ _groupCell = m._groupCell;
+ for (int i=0; i<m._numberOfCellsGroups; i++)
+ {
+ _groupCell[i] = new GROUP(* m._groupCell[i]);
+ _groupCell[i]->setMesh(this);
+ }
+
+ _numberOfFacesGroups = m._numberOfFacesGroups;
+ _groupFace = m._groupFace;
+ for (int i=0; i<m._numberOfFacesGroups; i++)
+ {
+ _groupFace[i] = new GROUP(* m._groupFace[i]);
+ _groupFace[i]->setMesh(this);
+ }
+
+ _numberOfEdgesGroups = m._numberOfEdgesGroups;
+ _groupEdge = m._groupEdge;
+ for (int i=0; i<m._numberOfEdgesGroups; i++)
+ {
+ _groupEdge[i] = new GROUP(* m._groupEdge[i]);
+ _groupEdge[i]->setMesh(this);
+ }
+
+ //_drivers = m._drivers; //Recopie des drivers?
}
MESH::~MESH() {
- if ( _MEDArrayNodeFamily != (int * ) NULL) delete [] _MEDArrayNodeFamily; // SOLUTION TEMPORAIRE
- if ( _numberOfMEDCellFamily != (int * ) NULL) delete [] _numberOfMEDCellFamily;
- if ( _numberOfMEDFaceFamily != (int * ) NULL) delete [] _numberOfMEDFaceFamily;
- if ( _numberOfMEDEdgeFamily != (int * ) NULL) delete [] _numberOfMEDEdgeFamily;
- // IL FAUT FAIRE UNE BOUCLE DE DESALLOCATION
- if ( _MEDArrayCellFamily != (int **) NULL) delete [] _MEDArrayCellFamily; // SOLUTION TEMPORAIRE
- if ( _MEDArrayFaceFamily != (int **) NULL) delete [] _MEDArrayFaceFamily; // SOLUTION TEMPORAIRE
- if ( _MEDArrayEdgeFamily != (int **) NULL) delete [] _MEDArrayEdgeFamily; // SOLUTION TEMPORAIRE
-
- if (_coordinate != NULL) delete _coordinate ;
- if (_connectivity != NULL) delete _connectivity ;
+ MESSAGE("MESH::~MESH() : Destroying the Mesh");
+ if (_coordinate != ((COORDINATE *) NULL)) delete _coordinate ;
+ if (_connectivity != ((CONNECTIVITY *) NULL)) delete _connectivity ;
int size ;
size = _familyNode.size() ;
for (int i=0;i<size;i++)
- delete _familyNode[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _familyNode[i] ;
size = _familyCell.size() ;
for (int i=0;i<size;i++)
- delete _familyCell[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _familyCell[i] ;
size = _familyFace.size() ;
for (int i=0;i<size;i++)
- delete _familyFace[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _familyFace[i] ;
size = _familyEdge.size() ;
for (int i=0;i<size;i++)
- delete _familyEdge[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _familyEdge[i] ;
size = _groupNode.size() ;
for (int i=0;i<size;i++)
- delete _groupNode[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _groupNode[i] ;
size = _groupCell.size() ;
for (int i=0;i<size;i++)
- delete _groupCell[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _groupCell[i] ;
size = _groupFace.size() ;
for (int i=0;i<size;i++)
- delete _groupFace[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _groupFace[i] ;
size = _groupEdge.size() ;
for (int i=0;i<size;i++)
- delete _groupEdge[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _groupEdge[i] ;
+
+ MESSAGE("In this object MESH there is(are) " << _drivers.size() << " driver(s)");
+
+ for (int index=0; index < _drivers.size(); index++ )
+ {
+ SCRUTE(_drivers[index]);
+ if ( _drivers[index] != NULL) delete _drivers[index];
+ }
}
init();
- current = addDriver(driverType,fileName,driverName);
- switch(_drivers[current]->getAccessMode() ) {
- case MED_RDONLY : {
- MESSAGE("MESH::MESH(driverTypes driverType, .....) : driverType must have a MED_RDWR accessMode");
- rmDriver(current);
- break;}
- default : {
- }
- }
+ MED_MESH_RDONLY_DRIVER myDriver(fileName,this) ;
+ myDriver.setMeshName(driverName);
+ current = addDriver(myDriver);
+// current = addDriver(driverType,fileName,driverName);
+// switch(_drivers[current]->getAccessMode() ) {
+// case MED_WRONLY : {
+// MESSAGE("MESH::MESH(driverTypes driverType, .....) : driverType must not be a MED_WRONLY accessMode");
+// rmDriver(current);
+// break;}
+// default : {
+// }
+// }
_drivers[current]->open();
_drivers[current]->read();
_drivers[current]->close();
+
+ if (_isAGrid)
+ ((GRID *) this)->fillMeshAfterRead();
+
END_OF(LOC);
};
ostream & operator<<(ostream &os, MESH &myMesh)
{
-// int space_dimension = myMesh.get_space_dimension();
-// os << "Space dimension "<< space_dimension << endl ;
-// int nodes_count = myMesh.get_nodes_count() ;
-// os << "Nodes count : "<< nodes_count << endl ;
-// double * coord = myMesh.get_coordinates();
-// os << "Coordinates :" << endl ;
-// string * coordinate_name = myMesh.get_coordinates_name() ;
-// string * coordinate_unit = myMesh.get_coordinates_unit() ;
-
-// for(int i=0;i<space_dimension;i++) {
-// os << " - name "<< i << " : "<< coordinate_name[i] << endl;
-// os << " - unit "<< i << " : "<< coordinate_unit[i] << endl ;
-// }
-
-// for(int j=0;j<nodes_count;j++) {
-// for(int i=0;i<space_dimension;i++)
-// os << " coord["<< i <<","<< j << "] : "<< coord[j+i*nodes_count] <<" ," ;
-// os << endl;
-// }
-
-// int cells_types_count = myMesh.get_cells_types_count() ;
-// os << "cells_types_count : " << cells_types_count << endl ;
-// for(int i=1;i<cells_types_count;i++) {
-// os << "cell type : " << myMesh.get_cells_type(i) << endl ;
-// os << " - cells count : " << myMesh.get_cells_count(i) << endl ;
-// int *conectivity = myMesh.get_nodal_connectivity(i) ;
-// int nodes_cells_count = myMesh.get_cells_type(i).get_nodes_count() ;
-// for(int j=0;j<myMesh.get_cells_count(i);j++) {
-// os << " " ;
-// for(int k=0;k<nodes_cells_count;k++)
-// os <<conectivity[j*nodes_cells_count+k] << " " ;
-// os << endl ;
-// }
-// }
-
-// int nodes_families_count = myMesh.get_nodes_families_count() ;
-// os << "nodes_families_count : " << nodes_families_count << endl ;
-// vector<FamilyNode*> nodes_Families = myMesh.get_nodes_Families() ;
-// for(int i=0;i<nodes_families_count;i++)
-// os << " - Famile "<<i<<" : "<< (FamilyNode &) (*nodes_Families[i]) << endl ;
-// os << endl ;
-
-// int cells_families_count = myMesh.get_cells_families_count() ;
-// os << "cells_families_count : " << cells_families_count << endl ;
-// vector<FamilyCell*> cells_Families = myMesh.get_cells_Families() ;
-// for(int i=0;i<cells_families_count;i++)
-// os << " - Famile "<<i<<" : "<< (*cells_Families[i]) << endl ;
-// os << endl ;
-
- return os ;
+ int spacedimension = myMesh.getSpaceDimension();
+ int meshdimension = myMesh.getMeshDimension();
+ int numberofnodes = myMesh.getNumberOfNodes();
+
+ os << "Space Dimension : " << spacedimension << endl << endl;
+
+ os << "Mesh Dimension : " << meshdimension << endl << endl;
+
+ const double * coordinates = myMesh.getCoordinates(MED_FULL_INTERLACE);
+ os << "SHOW NODES COORDINATES : " << endl;
+
+ os << "Name :" << endl;
+ const string * coordinatesnames = myMesh.getCoordinatesNames();
+ for(int i=0; i<spacedimension ; i++)
+ {
+ os << " - " << coordinatesnames[i] << endl;
+ }
+ os << "Unit :" << endl;
+ const string * coordinatesunits = myMesh.getCoordinatesUnits();
+ for(int i=0; i<spacedimension ; i++)
+ {
+ os << " - " << coordinatesunits[i] << endl;
+ }
+ for(int i=0; i<numberofnodes ; i++)
+ {
+ os << "Nodes " << i+1 << " : ";
+ for (int j=0; j<spacedimension ; j++)
+ os << coordinates[i*spacedimension+j] << " ";
+ os << endl;
+ }
+
+ const CONNECTIVITY * myConnectivity = myMesh.getConnectivityptr();
+ if (!myConnectivity->existConnectivity(MED_NODAL,MED_CELL) && myConnectivity->existConnectivity(MED_DESCENDING,MED_CELL))
+ {
+ os << endl << "SHOW CONNECTIVITY (DESCENDING) :" << endl;
+ int numberofelements;
+ const int * connectivity;
+ const int * connectivity_index;
+ myMesh.calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL);
+ try {
+ numberofelements = myMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS);
+ connectivity = myMesh.getConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS);
+ connectivity_index = myMesh.getConnectivityIndex(MED_DESCENDING,MED_CELL);
+ }
+ catch (MEDEXCEPTION m) {
+ os << m.what() << endl;
+ exit (-1);
+ }
+ for (int j=0;j<numberofelements;j++) {
+ os << "Element "<<j+1<<" : ";
+ for (int k=connectivity_index[j];k<connectivity_index[j+1];k++)
+ os << connectivity[k-1]<<" ";
+ os << endl;
+ }
+ }
+ else
+ {
+ int numberoftypes = myMesh.getNumberOfTypes(MED_CELL);
+ const medGeometryElement * types = myMesh.getTypes(MED_CELL);
+ os << endl << "SHOW CONNECTIVITY (NODAL) :" << endl;
+ for (int i=0; i<numberoftypes; i++) {
+ os << "For type " << types[i] << " : " << endl;
+ int numberofelements = myMesh.getNumberOfElements(MED_CELL,types[i]);
+ const int * connectivity = myMesh.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,types[i]);
+ int numberofnodespercell = types[i]%100;
+ for (int j=0;j<numberofelements;j++){
+ os << "Element "<< j+1 <<" : ";
+ for (int k=0;k<numberofnodespercell;k++)
+ os << connectivity[j*numberofnodespercell+k]<<" ";
+ os << endl;
+ }
+ }
+ }
+
+
+ medEntityMesh entity;
+ os << endl << "SHOW FAMILIES :" << endl << endl;
+ for (int k=1; k<=4; k++)
+ {
+ if (k==1) entity = MED_NODE;
+ if (k==2) entity = MED_CELL;
+ if (k==3) entity = MED_FACE;
+ if (k==4) entity = MED_EDGE;
+ int numberoffamilies = myMesh.getNumberOfFamilies(entity);
+ using namespace MED_FR;
+ os << "NumberOfFamilies on "<< entNames[(MED_FR::med_entite_maillage) entity] <<" : "<<numberoffamilies<<endl;
+ using namespace MED_EN;
+ for (int i=1; i<numberoffamilies+1;i++)
+ {
+ os << * myMesh.getFamily(entity,i) << endl;
+ }
+ }
+
+ os << endl << "SHOW GROUPS :" << endl << endl;
+ for (int k=1; k<=4; k++)
+ {
+ if (k==1) entity = MED_NODE;
+ if (k==2) entity = MED_CELL;
+ if (k==3) entity = MED_FACE;
+ if (k==4) entity = MED_EDGE;
+ int numberofgroups = myMesh.getNumberOfGroups(entity);
+ using namespace MED_FR;
+ os << "NumberOfGroups on "<< entNames[(MED_FR::med_entite_maillage) entity] <<" : "<<numberofgroups<<endl;
+ using namespace MED_EN;
+ for (int i=1; i<numberofgroups+1;i++)
+ {
+ os << * myMesh.getGroup(entity,i) << endl;
+ }
+ }
+
+ return os;
}
/*!
Return -1 if not found.
*/
-int MESH::getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity)
+int MESH::getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity) const
{
const char* LOC="MESH::getElementNumber " ;
BEGIN_OF(LOC) ;
else
numberOfValue = myType.getNumberOfNodes() ; // nodes
- int * myReverseConnectivityValue = getReverseConnectivity(ConnectivityType,Entity) ;
- int * myReverseConnectivityIndex = getReverseConnectivityIndex(ConnectivityType,Entity) ;
+ const int * myReverseConnectivityValue = getReverseConnectivity(ConnectivityType,Entity) ;
+ const int * myReverseConnectivityIndex = getReverseConnectivityIndex(ConnectivityType,Entity) ;
// First node or face/edge
int indexBegin = myReverseConnectivityIndex[connectivity[0]-1] ;
For instance, we could get only face in 3D and edge in 2D.
*/
-SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION)
+SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity)
+ throw (MEDEXCEPTION)
{
const char * LOC = "MESH::getBoundaryElements : " ;
BEGIN_OF(LOC) ;
mySupport->setAll(false);
- int * myConnectivityValue = getReverseConnectivity(MED_DESCENDING) ;
- int * myConnectivityIndex = getReverseConnectivityIndex(MED_DESCENDING) ;
+ const int * myConnectivityValue = getReverseConnectivity(MED_DESCENDING) ;
+ const int * myConnectivityIndex = getReverseConnectivityIndex(MED_DESCENDING) ;
int numberOf = getNumberOfElements(Entity,MED_ALL_ELEMENTS) ;
list<int> myElementsList ;
int size = 0 ;
- SCRUTE(numberOf) ;
for (int i=0 ; i<numberOf; i++)
if (myConnectivityValue[myConnectivityIndex[i]] == 0) {
- SCRUTE(i+1) ;
myElementsList.push_back(i+1) ;
size++ ;
}
- SCRUTE(size) ;
// Well, we must know how many geometric type we have found
int * myListArray = new int[size] ;
int id = 0 ;
list<int>::iterator myElementsListIt ;
for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
myListArray[id]=(*myElementsListIt) ;
- SCRUTE(id);
- SCRUTE(myListArray[id]);
id ++ ;
}
medGeometryElement* geometricType ;
int * numberOfGaussPoint ;
int * geometricTypeNumber ;
- int * numberOfEntities ;
- MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ;
+ int * numberOfElements ;
+ //MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ;
int * mySkyLineArrayIndex ;
int numberOfType = getNumberOfTypes(Entity) ;
if (numberOfType == 1) { // wonderfull : it's easy !
numberOfGeometricType = 1 ;
geometricType = new medGeometryElement[1] ;
- medGeometryElement * allType = getTypes(Entity);
+ const medGeometryElement * allType = getTypes(Entity);
geometricType[0] = allType[0] ;
numberOfGaussPoint = new int[1] ;
numberOfGaussPoint[0] = 1 ;
geometricTypeNumber = new int[1] ; // not use, but initialized to nothing
geometricTypeNumber[0] = 0 ;
- numberOfEntities = new int[1] ;
- numberOfEntities[0] = size ;
+ numberOfElements = new int[1] ;
+ numberOfElements[0] = size ;
mySkyLineArrayIndex = new int[2] ;
mySkyLineArrayIndex[0]=1 ;
mySkyLineArrayIndex[1]=1+size ;
}
numberOfGeometricType = theType.size() ;
geometricType = new medGeometryElement[numberOfGeometricType] ;
- medGeometryElement * allType = getTypes(Entity);
+ const medGeometryElement * allType = getTypes(Entity);
numberOfGaussPoint = new int[numberOfGeometricType] ;
geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing
- numberOfEntities = new int[numberOfGeometricType] ;
+ numberOfElements = new int[numberOfGeometricType] ;
mySkyLineArrayIndex = new int[numberOfGeometricType+1] ;
int index = 0 ;
mySkyLineArrayIndex[0]=1 ;
geometricType[index] = (*theTypeIt).first ;
numberOfGaussPoint[index] = 1 ;
geometricTypeNumber[index] = 0 ;
- numberOfEntities[index] = (*theTypeIt).second ;
- mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfEntities[index] ;
+ numberOfElements[index] = (*theTypeIt).second ;
+ mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfElements[index] ;
index++ ;
}
}
- mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
+ //mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
+ MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
mySupport->setNumberOfGeometricType(numberOfGeometricType) ;
mySupport->setGeometricType(geometricType) ;
mySupport->setNumberOfGaussPoint(numberOfGaussPoint) ;
+ mySupport->setNumberOfElements(numberOfElements) ;
+ mySupport->setTotalNumberOfElements(size) ;
// mySupport->setGeometricTypeNumber(geometricTypeNumber) ;
- mySupport->setNumberOfEntities(numberOfEntities) ;
- mySupport->setTotalNumberOfEntities(size) ;
mySupport->setNumber(mySkyLineArray) ;
+ delete[] numberOfElements;
+ delete[] geometricTypeNumber;
+ delete[] numberOfGaussPoint;
+ delete[] geometricType;
+ delete[] mySkyLineArrayIndex;
+ delete[] myListArray;
+// delete mySkyLineArray;
+
END_OF(LOC) ;
return mySupport ;
}
-FIELD<double>* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION)
+FIELD<double>* MESH::getVolume(const SUPPORT * Support) const throw (MEDEXCEPTION)
{
+ const char * LOC = "MESH::getVolume(SUPPORT*) : ";
+ BEGIN_OF(LOC);
+
// Support must be on 3D elements
- MESSAGE("MESH::getVolume(SUPPORT*)");
// Make sure that the MESH class is the same as the MESH class attribut
// in the class Support
MESH* myMesh = Support->getMesh();
if (this != myMesh)
- throw MEDEXCEPTION("MESH::getVolume(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !"));
int dim_space = getSpaceDimension();
medEntityMesh support_entity = Support->getEntity();
bool onAll = Support->isOnAllElements();
int nb_type, length_values;
- medGeometryElement* types;
+ const medGeometryElement* types;
int nb_entity_type;
// !!!! WARNING : use of nodal global numbering in the mesh !!!!
- int* global_connectivity;
+ const int* global_connectivity;
- if (onAll)
- {
- nb_type = myMesh->getNumberOfTypes(support_entity);
- length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
- types = getTypes(support_entity);
- }
- else
+// if (onAll)
+// {
+// nb_type = myMesh->getNumberOfTypes(support_entity);
+// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+// types = getTypes(support_entity);
+// }
+// else
{
nb_type = Support->getNumberOfTypes();
length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
}
int index;
- FIELD<double>* Volume;
-
- Volume = new FIELD<double>::FIELD(Support,1);
+ FIELD<double>* Volume = new FIELD<double>::FIELD(Support,1);
// double *volume = new double [length_values];
Volume->setName("VOLUME");
Volume->setDescription("cells volume");
Volume->setOrderNumber(0);
Volume->setTime(0.0);
- double *volume = Volume->getValue(MED_FULL_INTERLACE);
+ //const double *volume = Volume->getValue(MED_FULL_INTERLACE);
+ MEDARRAY<double> *volume = Volume->getvalue();
- index = 0;
+ index = 1;
const double * coord = getCoordinates(MED_FULL_INTERLACE);
for (int i=0;i<nb_type;i++)
}
else
{
- nb_entity_type = Support->getNumberOfElements(type);
-
- int * supp_number = Support->getNumber(type);
- int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
- int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
- global_connectivity = new int[(type%100)*nb_entity_type];
-
- for (int k_type = 0; k_type<nb_entity_type; k_type++) {
- for (int j_ent = 0; j_ent<(type%100); j_ent++) {
- global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
- }
- }
+ // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all"));
+
+ nb_entity_type = Support->getNumberOfElements(type);
+
+ const int * supp_number = Support->getNumber(type);
+ const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+ global_connectivity = global_connectivity_tmp ;
}
switch (type)
(x2-x1)*((y3-y1)*(z4-z1) - (z3-z1)*(y4-y1)) +
(x4-x1)*((y3-y1)*(z2-z1) - (z3-z1)*(y2-y1)))/6.0;
- volume[index] = xvolume ;
+ //volume[index] = xvolume ;
+ volume->setIJ(index,1,xvolume) ;
index++;
}
break;
(x5-x1)*((y4-y1)*(z3-z1) - (z4-z1)*(y3-y1)))
)/6.0;
- volume[index] = xvolume ;
+ //volume[index] = xvolume ;
+ volume->setIJ(index,1,xvolume) ;
index = index++;
}
break;
xvolume = -2.0*(2.0*(A + B + D + E + G + H) + C + F + P)/9.0;
- volume[index] = xvolume ;
+ //volume[index] = xvolume ;
+ volume->setIJ(index,1,xvolume) ;
index++;
}
break;
V + W) + 2.0*(I + R + U + X + Y + Z) +
AA)/27.0;
- volume[index] = xvolume ;
+ //volume[index] = xvolume ;
+ volume->setIJ(index,1,xvolume) ;
index++;
}
break;
}
default :
- throw MEDEXCEPTION("MESH::getVolume(SUPPORT*) Bad Support to get Volumes on it !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Volumes on it !"));
break;
}
}
return Volume;
}
-FIELD<double>* MESH::getArea(const SUPPORT * Support) throw (MEDEXCEPTION)
+FIELD<double>* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION)
{
+ const char * LOC = "MESH::getArea(SUPPORT*) : ";
+ BEGIN_OF(LOC);
+
// Support must be on 2D elements
- MESSAGE("MESH::getArea(SUPPORT*)");
// Make sure that the MESH class is the same as the MESH class attribut
// in the class Support
MESH* myMesh = Support->getMesh();
if (this != myMesh)
- throw MEDEXCEPTION("MESH::getArea(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !"));
int dim_space = getSpaceDimension();
medEntityMesh support_entity = Support->getEntity();
bool onAll = Support->isOnAllElements();
int nb_type, length_values;
- medGeometryElement* types;
+ const medGeometryElement* types;
int nb_entity_type;
// !!!! WARNING : use of nodal global numbering in the mesh !!!!
- int* global_connectivity;
+ const int* global_connectivity;
- if (onAll)
- {
- nb_type = myMesh->getNumberOfTypes(support_entity);
- length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
- types = getTypes(support_entity);
- }
- else
+// if (onAll)
+// {
+// nb_type = myMesh->getNumberOfTypes(support_entity);
+// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+// types = getTypes(support_entity);
+// }
+// else
{
nb_type = Support->getNumberOfTypes();
length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
}
else
{
- nb_entity_type = Support->getNumberOfElements(type);
-
- int * supp_number = Support->getNumber(type);
- int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
- int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
- global_connectivity = new int[(type%100)*nb_entity_type];
+ // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all !"));
+
+ nb_entity_type = Support->getNumberOfElements(type);
+
+ const int * supp_number = Support->getNumber(type);
+ const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+
+ global_connectivity = global_connectivity_tmp ;
- for (int k_type = 0; k_type<nb_entity_type; k_type++) {
- for (int j_ent = 0; j_ent<(type%100); j_ent++) {
- global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
- }
- }
}
switch (type)
break;
}
default :
- throw MEDEXCEPTION("MESH::getArea(SUPPORT*) Bad Support to get Areas on it !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Areas on it !"));
break;
}
}
Area->setValue(MED_FULL_INTERLACE,area);
-
+ delete[] area;
return Area;
}
-FIELD<double>* MESH::getLength(const SUPPORT * Support) throw (MEDEXCEPTION)
+FIELD<double>* MESH::getLength(const SUPPORT * Support) const throw (MEDEXCEPTION)
{
+ const char * LOC = "MESH::getLength(SUPPORT*) : ";
+ BEGIN_OF(LOC);
+
// Support must be on 1D elements
- MESSAGE("MESH::getLength(SUPPORT*)");
// Make sure that the MESH class is the same as the MESH class attribut
// in the class Support
MESH* myMesh = Support->getMesh();
if (this != myMesh)
- throw MEDEXCEPTION("MESH::getLength(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !"));
int dim_space = getSpaceDimension();
medEntityMesh support_entity = Support->getEntity();
bool onAll = Support->isOnAllElements();
int nb_type, length_values;
- medGeometryElement* types;
+ const medGeometryElement* types;
int nb_entity_type;
// !!!! WARNING : use of nodal global numbering in the mesh !!!!
- int* global_connectivity;
+ const int* global_connectivity;
- if (onAll)
- {
- nb_type = myMesh->getNumberOfTypes(support_entity);
- length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
- types = getTypes(support_entity);
- }
- else
+// if (onAll)
+// {
+// nb_type = myMesh->getNumberOfTypes(support_entity);
+// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+// types = getTypes(support_entity);
+// }
+// else
{
nb_type = Support->getNumberOfTypes();
length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
// double *length = new double [length_values];
Length->setValueType(MED_REEL64);
- double *length = Length->getValue(MED_FULL_INTERLACE);
+ //const double *length = Length->getValue(MED_FULL_INTERLACE);
+ MEDARRAY<double> * length = Length->getvalue();
const double * coord = getCoordinates(MED_FULL_INTERLACE);
- index = 0;
+ index = 1;
for (int i=0;i<nb_type;i++)
{
}
else
{
- nb_entity_type = Support->getNumberOfElements(type);
+ //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all !"));
- int * supp_number = Support->getNumber(type);
- int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
- int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
- global_connectivity = new int[(type%100)*nb_entity_type];
+ nb_entity_type = Support->getNumberOfElements(type);
- for (int k_type = 0; k_type<nb_entity_type; k_type++) {
- for (int j_ent = 0; j_ent<(type%100); j_ent++) {
- global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
- }
- }
+ const int * supp_number = Support->getNumber(type);
+ const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ int* global_connectivity_tmp = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+ global_connectivity = global_connectivity_tmp ;
}
switch (type)
xlength = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2) +
(z1 - z2)*(z1 - z2));
- length[index] = xlength ;
+ length->setIJ(index,1,xlength) ;
index++;
}
break;
}
default :
- throw MEDEXCEPTION("MESH::getLength(SUPPORT*) Bad Support to get Lengths on it !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Lengths on it !"));
break;
}
}
return Length;
}
-FIELD<double>* MESH::getNormal(const SUPPORT * Support) throw (MEDEXCEPTION)
+FIELD<double>* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTION)
{
+ const char * LOC = "MESH::getNormal(SUPPORT*) : ";
+ BEGIN_OF(LOC);
+
// Support must be on 2D or 1D elements
- MESSAGE("MESH::getNormal(SUPPORT*)");
// Make sure that the MESH class is the same as the MESH class attribut
// in the class Support
MESH* myMesh = Support->getMesh();
if (this != myMesh)
- throw MEDEXCEPTION("MESH::getNormal(SUPPORT*) no compatibility between *this and SUPPORT::_mesh : pointeur problem !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh : pointeur problem !"));
int dim_space = getSpaceDimension();
medEntityMesh support_entity = Support->getEntity();
bool onAll = Support->isOnAllElements();
int nb_type, length_values;
- medGeometryElement* types;
+ const medGeometryElement* types;
int nb_entity_type;
// !!!! WARNING : use of nodal global numbering in the mesh !!!!
- int* global_connectivity;
+ const int* global_connectivity;
- if (onAll)
- {
- nb_type = myMesh->getNumberOfTypes(support_entity);
- length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
- types = getTypes(support_entity);
- }
- else
+// if (onAll)
+// {
+// nb_type = myMesh->getNumberOfTypes(support_entity);
+// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+// types = getTypes(support_entity);
+// }
+// else
{
nb_type = Support->getNumberOfTypes();
length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
FIELD<double>* Normal = new FIELD<double>::FIELD(Support,dim_space);
Normal->setName("NORMAL");
Normal->setDescription("cells or faces normal");
- for (int k=0;k<dim_space;k++) {
- int kp1 = k + 1;
- Normal->setComponentName(kp1,"normal");
- Normal->setComponentDescription(kp1,"desc-comp");
- Normal->setMEDComponentUnit(kp1,"unit");
+ for (int k=1;k<=dim_space;k++) {
+ Normal->setComponentName(k,"normal");
+ Normal->setComponentDescription(k,"desc-comp");
+ Normal->setMEDComponentUnit(k,"unit");
}
Normal->setValueType(MED_REEL64);
- Normal->setIterationNumber(0);
- Normal->setOrderNumber(0);
+ Normal->setIterationNumber(MED_NOPDT);
+ Normal->setOrderNumber(MED_NONOR);
Normal->setTime(0.0);
double * normal = new double [dim_space*length_values];
(type==MED_QUAD4) || (type==MED_QUAD8)) &&
(dim_space != 3)) || (((type==MED_SEG2) || (type==MED_SEG3)) &&
(dim_space != 2)) )
- throw MEDEXCEPTION("MESH::getNormal(SUPPORT*) no compatibility between *this and SUPPORT::_mesh : dimension problem !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh : dimension problem !"));
double xnormal1, xnormal2, xnormal3 ;
}
else
{
- nb_entity_type = Support->getNumberOfElements(type);
+ // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all for instance !"));
+ nb_entity_type = Support->getNumberOfElements(type);
+
+ const int * supp_number = Support->getNumber(type);
+ const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+
+ global_connectivity = global_connectivity_tmp ;
- int * supp_number = Support->getNumber(type);
- int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
- int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
- global_connectivity = new int[(type%100)*nb_entity_type];
-
- for (int k_type = 0; k_type<nb_entity_type; k_type++) {
- for (int j_ent = 0; j_ent<(type%100); j_ent++) {
- global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
- }
- }
}
switch (type)
break;
}
default :
- throw MEDEXCEPTION("MESH::getNormal(SUPPORT*) Bad Support to get Normals on it !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Normals on it !"));
break;
}
}
Normal->setValue(MED_FULL_INTERLACE,normal);
+ delete[] normal ;
+
+ END_OF(LOC);
return Normal;
}
-FIELD<double>* MESH::getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION)
+FIELD<double>* MESH::getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION)
{
- MESSAGE("MESH::getBarycenter(SUPPORT*)");
+ const char * LOC = "MESH::getBarycenter(SUPPORT*) : ";
+ BEGIN_OF(LOC);
// Make sure that the MESH class is the same as the MESH class attribut
// in the class Support
MESH* myMesh = Support->getMesh();
if (this != myMesh)
- throw MEDEXCEPTION("MESH::getBarycenter(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !"));
int dim_space = getSpaceDimension();
medEntityMesh support_entity = Support->getEntity();
bool onAll = Support->isOnAllElements();
int nb_type, length_values;
- medGeometryElement* types;
+ const medGeometryElement* types;
int nb_entity_type;
// !!!! WARNING : use of nodal global numbering in the mesh !!!!
- int* global_connectivity;
+ const int* global_connectivity;
- if (onAll)
- {
- nb_type = myMesh->getNumberOfTypes(support_entity);
- length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
- types = getTypes(support_entity);
- }
- else
+// if (onAll)
+// {
+// nb_type = myMesh->getNumberOfTypes(support_entity);
+// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+// types = getTypes(support_entity);
+// }
+// else
{
nb_type = Support->getNumberOfTypes();
length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
}
else
{
- nb_entity_type = Support->getNumberOfElements(type);
-
- int * supp_number = Support->getNumber(type);
- int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
- int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
- global_connectivity = new int[(type%100)*nb_entity_type];
-
- for (int k_type = 0; k_type<nb_entity_type; k_type++) {
- for (int j_ent = 0; j_ent<(type%100); j_ent++) {
- global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
- }
- }
+ // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all !"));
+ nb_entity_type = Support->getNumberOfElements(type);
+
+ const int * supp_number = Support->getNumber(type);
+ const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+ global_connectivity = global_connectivity_tmp;
}
switch (type)
break;
}
default :
- throw MEDEXCEPTION("MESH::getBarycenter(SUPPORT*) Bad Support to get a barycenter on it (in fact unknown type) !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get a barycenter on it (in fact unknown type) !"));
break;
}
}
Barycenter->setValue(MED_FULL_INTERLACE,barycenter);
+ delete[] barycenter ;
+
+ END_OF(LOC);
+
return Barycenter;
}
+
+//=======================================================================
+//function : checkGridFillCoords
+//purpose : if this->_isAGrid, assure that _coordinate is filled
+//=======================================================================
+
+inline void MESH::checkGridFillCoords() const
+{
+ if (_isAGrid)
+ ((GRID *) this)->fillCoordinates();
+}
+
+//=======================================================================
+//function : checkGridFillConnectivity
+//purpose : if this->_isAGrid, assure that _connectivity is filled
+//=======================================================================
+
+inline void MESH::checkGridFillConnectivity() const
+{
+ if (_isAGrid)
+ ((GRID *) this)->fillConnectivity();
+}
+
+
+void MESH::read(int index)
+{
+ const char * LOC = "MESH::read(int index=0) : ";
+ BEGIN_OF(LOC);
+
+ if (_drivers[index]) {
+ _drivers[index]->open();
+ _drivers[index]->read();
+ _drivers[index]->close();
+ }
+ else
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
+ )
+ );
+ if (_isAGrid)
+ ((GRID *) this)->fillMeshAfterRead();
+
+ END_OF(LOC);
+}
+//=======================================================================
+//function : getSkin
+//purpose :
+//=======================================================================
+
+SUPPORT * MESH::getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION)
+{
+ const char * LOC = "MESH::getSkin : " ;
+ BEGIN_OF(LOC) ;
+ // some test :
+ if (this != Support3D->getMesh())
+ throw MEDEXCEPTION(STRING(LOC) << "no compatibility between *this and SUPPORT::_mesh !");
+ if (_meshDimension != 3 || Support3D->getEntity() != MED_CELL)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Defined on 3D cells only"));
+
+ // well, all rigth !
+ SUPPORT * mySupport = new SUPPORT(this,"Skin",MED_FACE);
+ mySupport->setAll(false);
+
+ list<int> myElementsList ;
+ int i,j, size = 0 ;
+
+ calculateConnectivity(MED_FULL_INTERLACE, MED_DESCENDING, MED_CELL);
+ if (Support3D->isOnAllElements())
+ {
+ int * myConnectivityValue = const_cast <int*> (getReverseConnectivity(MED_DESCENDING)) ;
+ int nbFaces = getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS);
+ for (i=0, j=1 ; j<=nbFaces; ++j, i += 2)
+ {
+ int cellNb1 = myConnectivityValue [i];
+ int cellNb2 = myConnectivityValue [i+1];
+ //MESSAGE( " FACE # " << j << " -- Cells: " << cellNb1 << ", " << cellNb2 );
+ if ((cellNb1 == 0 || cellNb2 == 0) && (cellNb1 + cellNb2 > 0))
+ {
+ myElementsList.push_back( j ) ;
+ size++ ;
+ }
+ }
+ }
+ else
+ {
+ map<int,int> FaceNbEncounterNb;
+
+ int * myConnectivityValue = const_cast <int *>
+ (getConnectivity(MED_FULL_INTERLACE, MED_DESCENDING,
+ MED_CELL, MED_ALL_ELEMENTS));
+ int * myConnectivityIndex = const_cast <int *> (getConnectivityIndex(MED_DESCENDING, MED_CELL));
+ int * myCellNbs = const_cast <int *> (Support3D->getnumber()->getValue());
+ int nbCells = Support3D->getnumber()->getLength();
+ for (i=0; i<nbCells; ++i)
+ {
+ int cellNb = myCellNbs [ i ];
+ int faceFirst = myConnectivityIndex[ cellNb-1 ];
+ int faceLast = myConnectivityIndex[ cellNb ];
+ for (j = faceFirst; j < faceLast; ++j)
+ {
+ int faceNb = abs( myConnectivityValue [ j-1 ] );
+ //MESSAGE( "Cell # " << i << " -- Face: " << faceNb);
+ if (FaceNbEncounterNb.find( faceNb ) == FaceNbEncounterNb.end())
+ FaceNbEncounterNb[ faceNb ] = 1;
+ else
+ FaceNbEncounterNb[ faceNb ] ++;
+ }
+ }
+ map<int,int>::iterator FaceNbEncounterNbItr;
+ for (FaceNbEncounterNbItr = FaceNbEncounterNb.begin();
+ FaceNbEncounterNbItr != FaceNbEncounterNb.end();
+ FaceNbEncounterNbItr ++)
+ if ((*FaceNbEncounterNbItr).second == 1)
+ {
+ myElementsList.push_back( (*FaceNbEncounterNbItr).first) ;
+ size++ ;
+ }
+ }
+ // Well, we must know how many geometric type we have found
+ int * myListArray = new int[size] ;
+ int id = 0 ;
+ list<int>::iterator myElementsListIt ;
+ for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
+ myListArray[id]=(*myElementsListIt) ;
+ id ++ ;
+ }
+
+ int numberOfGeometricType ;
+ medGeometryElement* geometricType ;
+ int * numberOfGaussPoint ;
+ int * geometricTypeNumber ;
+ int * numberOfEntities ;
+ // MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ;
+ int * mySkyLineArrayIndex ;
+
+ int numberOfType = getNumberOfTypes(MED_FACE) ;
+ if (numberOfType == 1) { // wonderfull : it's easy !
+ numberOfGeometricType = 1 ;
+ geometricType = new medGeometryElement[1] ;
+ const medGeometryElement * allType = getTypes(MED_FACE);
+ geometricType[0] = allType[0] ;
+ numberOfGaussPoint = new int[1] ;
+ numberOfGaussPoint[0] = 1 ;
+ geometricTypeNumber = new int[1] ; // not use, but initialized to nothing
+ geometricTypeNumber[0] = 0 ;
+ numberOfEntities = new int[1] ;
+ numberOfEntities[0] = size ;
+ mySkyLineArrayIndex = new int[2] ;
+ mySkyLineArrayIndex[0]=1 ;
+ mySkyLineArrayIndex[1]=1+size ;
+ }
+ else {// hemmm
+ map<medGeometryElement,int> theType ;
+ for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
+ medGeometryElement myType = getElementType(MED_FACE,*myElementsListIt) ;
+ if (theType.find(myType) != theType.end() )
+ theType[myType]+=1 ;
+ else
+ theType[myType]=1 ;
+ }
+ numberOfGeometricType = theType.size() ;
+ geometricType = new medGeometryElement[numberOfGeometricType] ;
+ const medGeometryElement * allType = getTypes(MED_FACE);
+ numberOfGaussPoint = new int[numberOfGeometricType] ;
+ geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing
+ numberOfEntities = new int[numberOfGeometricType] ;
+ mySkyLineArrayIndex = new int[numberOfGeometricType+1] ;
+ int index = 0 ;
+ mySkyLineArrayIndex[0]=1 ;
+ map<medGeometryElement,int>::iterator theTypeIt ;
+ for (theTypeIt=theType.begin();theTypeIt!=theType.end();theTypeIt++) {
+ geometricType[index] = (*theTypeIt).first ;
+ numberOfGaussPoint[index] = 1 ;
+ geometricTypeNumber[index] = 0 ;
+ numberOfEntities[index] = (*theTypeIt).second ;
+ mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfEntities[index] ;
+ index++ ;
+ }
+ }
+ // mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
+ MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
+
+ mySupport->setNumberOfGeometricType(numberOfGeometricType) ;
+ mySupport->setGeometricType(geometricType) ;
+ mySupport->setNumberOfGaussPoint(numberOfGaussPoint) ;
+ // mySupport->setGeometricTypeNumber(geometricTypeNumber) ;
+ mySupport->setNumberOfElements(numberOfEntities) ;
+ mySupport->setTotalNumberOfElements(size) ;
+ mySupport->setNumber(mySkyLineArray) ;
+
+ delete[] numberOfEntities;
+ delete[] geometricTypeNumber;
+ delete[] numberOfGaussPoint;
+ delete[] geometricType;
+ delete[] mySkyLineArrayIndex;
+ delete[] myListArray;
+// delete mySkyLineArray;
+
+ END_OF(LOC) ;
+ return mySupport ;
+
+}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Mesh.hxx
+// Module : MED
+
#ifndef MESH_HXX
#define MESH_HXX
#include "MEDMEM_Coordinate.hxx"
#include "MEDMEM_Connectivity.hxx"
+// Add your own driver header (step 2)
#include "MEDMEM_MedMeshDriver.hxx"
#include "MEDMEM_MedMedDriver.hxx"
+#include "MEDMEM_GibiMeshDriver.hxx"
class CELLMODEL;
-class FAMILY;
-class GROUP;
-class SUPPORT;
+class FAMILY;
+class GROUP;
+class SUPPORT;
template <class T> class FIELD;
using namespace MED_EN;
-/*! This class contains all the informations related with a MESH :
+/*! This class contains all the informations related with a MESH :
- COORDINATES
- CONNECTIVITIES
- FAMILIES OF NODES
- FAMILIES OF CELLS
- FAMILIES OF FACES
- FAMILIES OF EDGES
-
+
NOTE: A Family is only on one type of entity (MED_CELL, MED_FACE, MED_EDGE, MED_NODE).
You can't have a family on MED_CELL and MED_FACE
-
+
*/
class MESH
// ------- Drivers Management Part
protected:
-
+
//-----------------------//
- class INSTANCE
+ class INSTANCE
//-----------------------//
{
public:
virtual GENDRIVER * run(const string & fileName, MESH * ptrMesh) const = 0 ;
} ;
-
+
//-------------------------------------------------------//
- template <class T> class INSTANCE_DE : public INSTANCE
+ template <class T> class INSTANCE_DE : public INSTANCE
//-------------------------------------------------------//
{
public :
- GENDRIVER * run(const string & fileName, MESH * ptrMesh) const
+ GENDRIVER * run(const string & fileName, MESH * ptrMesh) const
{ return new T(fileName,ptrMesh) ; }
} ;
-
- static INSTANCE_DE<MED_MESH_RDWR_DRIVER> inst_med ;
+
+ // Add a similar line for your personnal driver (step 3)
+ static INSTANCE_DE<MED_MESH_RDWR_DRIVER> inst_med ;
+ static INSTANCE_DE<GIBI_MESH_RDWR_DRIVER> inst_gibi ;
//static INSTANCE_DE<VTK_DRIVER> inst_vtk ;
static const INSTANCE * const instances[] ;
string _name; // A POSITIONNER EN FCT DES IOS ?
- int _numberOfMEDNodeFamily ; // INUTILE
- int * _MEDArrayNodeFamily ; // SOLUTION TEMPORAIRE
- int * _numberOfMEDCellFamily ; // INUTILE
- int * _numberOfMEDFaceFamily ; // INUTILE
- int * _numberOfMEDEdgeFamily ; // INUTILE
- int ** _MEDArrayCellFamily ; // SOLUTION TEMPORAIRE
- int ** _MEDArrayFaceFamily ; // SOLUTION TEMPORAIRE
- int ** _MEDArrayEdgeFamily ; // SOLUTION TEMPORAIRE
-
COORDINATE * _coordinate;
CONNECTIVITY * _connectivity;
int _numberOfNodes ;
int _numberOfNodesFamilies; //INUTILE ? -> _familyNode.size()
- vector<FAMILY*> _familyNode ; // array of size _numberOfNodesFamilies;
+ vector<FAMILY*> _familyNode ; // array of size _numberOfNodesFamilies;
int _numberOfCellsFamilies;
- vector<FAMILY*> _familyCell ; // array of size _numberOfCellsFamilies;
+ vector<FAMILY*> _familyCell ; // array of size _numberOfCellsFamilies;
int _numberOfFacesFamilies;
- vector<FAMILY*> _familyFace ; // array of size _numberOfFacesFamilies;
+ vector<FAMILY*> _familyFace ; // array of size _numberOfFacesFamilies;
int _numberOfEdgesFamilies;
vector<FAMILY*> _familyEdge ; // array of size _numberOfEdgesFamilies;
int _numberOfNodesGroups; //INUTILE ?
- vector<GROUP*> _groupNode; // array of size _numberOfNodesGroups;
+ vector<GROUP*> _groupNode; // array of size _numberOfNodesGroups;
int _numberOfCellsGroups; //INUTILE ?
- vector<GROUP*> _groupCell; // array of size _numberOfCellsGroups;
+ vector<GROUP*> _groupCell; // array of size _numberOfCellsGroups;
int _numberOfFacesGroups; //INUTILE ?
- vector<GROUP*> _groupFace; // array of size _numberOfFacesGroups;
+ vector<GROUP*> _groupFace; // array of size _numberOfFacesGroups;
int _numberOfEdgesGroups; //INUTILE ?
- vector<GROUP*> _groupEdge; // array of size _numberOfEdgesGroups;
+ vector<GROUP*> _groupEdge; // array of size _numberOfEdgesGroups;
// list of all Group
vector<GENDRIVER *> _drivers; // Storage of the drivers currently in use
-
+
+ bool _isAGrid; // am I a GRID or not
+
//-----------------------//
// Methods
//-----------------------//
+ inline void checkGridFillCoords() const;
+ inline void checkGridFillConnectivity() const;
+ // if this->_isAGrid, assure that _coordinate and _connectivity are filled
+
public :
+ // Add your personnal driver line (step 2)
friend class MED_MESH_RDONLY_DRIVER;
friend class MED_MESH_WRONLY_DRIVER;
friend class MED_MED_DRIVER;
+ friend class MED_MED_RDONLY_DRIVER;
+ friend class MED_MED_WRONLY_DRIVER;
+ friend class MED_MED_RDWR_DRIVER;
+
+ friend class GIBI_MESH_RDONLY_DRIVER;
+ friend class GIBI_MESH_WRONLY_DRIVER;
+ friend class GIBI_MESH_RDWR_DRIVER;
+
void init();
MESH();
- MESH(const MESH &m);
+ MESH(MESH &m);
MESH & operator=(const MESH &m);
- MESH( driverTypes driverType, const string & fileName="",
- const string & meshName="");
+ MESH( driverTypes driverType, const string & fileName="",
+ const string & meshName="");
~MESH();
friend ostream & operator<<(ostream &os, MESH &my) ;
- int addDriver(driverTypes driverType,
- const string & fileName ="Default File Name.med",
- const string & driverName="Default Mesh Name");
- int addDriver(MED_MESH_DRIVER & driver);
+ int addDriver(driverTypes driverType,
+ const string & fileName ="Default File Name.med",
+ const string & driverName="Default Mesh Name");
+ int addDriver(GENDRIVER & driver);
void rmDriver(int index=0);
- inline void read(int index=0);
+ void read(int index=0);
inline void read(const MED_MED_DRIVER & genDriver);
inline void write(int index=0, const string & driverName = "");
inline void write(const MED_MED_DRIVER & genDriver);
- inline int * getMEDArrayNodeFamily() ;
- inline int ** getMEDArrayCellFamily() ;
- inline int ** getMEDArrayFaceFamily() ;
- inline int ** getMEDArrayEdgeFamily() ;
-
// void calculateReverseConnectivity();
// void createFaces(); //Faces creation => full constituent informations
// void buildConstituent() ; // calculate descendent connectivity + face-cell connectivity
inline void setName(string name);
inline string getName() const;
- inline int getSpaceDimension();
- inline int getMeshDimension();
-
- inline int getNumberOfNodes();
- inline COORDINATE * getCoordinateptr();
- inline string getCoordinatesSystem();
- inline const double * getCoordinates(medModeSwitch Mode);
- inline const double getCoordinate(int Number,int Axis);
- inline string * getCoordinatesNames();
- inline string * getCoordinatesUnits();
+ inline int getSpaceDimension() const ;
+ inline int getMeshDimension() const ;
+ inline bool getIsAGrid();
+
+ inline int getNumberOfNodes() const ;
+ inline const COORDINATE * getCoordinateptr() const ;
+ inline string getCoordinatesSystem() const ;
+ inline const double * getCoordinates(medModeSwitch Mode) const ;
+ inline const double getCoordinate(int Number,int Axis) const ;
+ inline const string * getCoordinatesNames() const ;
+ inline const string * getCoordinatesUnits() const ;
// inline int * getNodesNumbers();
- inline int getNumberOfTypes(medEntityMesh Entity);
- inline medGeometryElement * getTypes(medEntityMesh Entity);
- inline CELLMODEL * getCellsTypes(medEntityMesh Entity);
- inline int * getGlobalNumberingIndex(medEntityMesh Entity);
- inline int getNumberOfElements(medEntityMesh Entity,medGeometryElement Type);
- inline bool existConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity);
- inline medGeometryElement getElementType(medEntityMesh Entity,int Number) ;
- inline void calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity);
- inline int * getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity, medGeometryElement Type);
- inline int * getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity);
- int getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity) ;
- inline int * getReverseConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity=MED_CELL);
- inline int * getReverseConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity=MED_CELL);
-
- inline int getNumberOfFamilies(medEntityMesh Entity);
- inline vector<FAMILY*> getFamilies(medEntityMesh Entity);
- inline FAMILY* getFamily(medEntityMesh Entity,int i);
- inline int getNumberOfGroups(medEntityMesh Entity);
- inline vector<GROUP*> getGroups(medEntityMesh Entity);
- inline GROUP* getGroup(medEntityMesh Entity,int i);
- inline CONNECTIVITY* getConnectivityptr();
+ inline int getNumberOfTypes(medEntityMesh Entity) const ;
+ inline const medGeometryElement * getTypes(medEntityMesh Entity) const ;
+ inline const CELLMODEL * getCellsTypes(medEntityMesh Entity) const ;
+ inline const int * getGlobalNumberingIndex(medEntityMesh Entity) const ;
+ inline int getNumberOfElements(medEntityMesh Entity,medGeometryElement Type) const ;
+ inline bool existConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity) const ;
+ inline medGeometryElement getElementType(medEntityMesh Entity,int Number) const ;
+ inline void calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity) ;
+ inline const int * getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity, medGeometryElement Type) const ;
+ inline const int * getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity) const ;
+ int getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity) const ;
+ inline const int * getReverseConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity=MED_CELL) const ;
+ inline const int * getReverseConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity=MED_CELL) const ;
+
+ inline int getNumberOfFamilies(medEntityMesh Entity) const ;
+ inline const vector<FAMILY*> getFamilies(medEntityMesh Entity) const ;
+ inline const FAMILY* getFamily(medEntityMesh Entity,int i) const ;
+ inline int getNumberOfGroups(medEntityMesh Entity) const ;
+ inline const vector<GROUP*> getGroups(medEntityMesh Entity) const ;
+ inline const GROUP* getGroup(medEntityMesh Entity,int i) const ;
+ inline const CONNECTIVITY* getConnectivityptr() const ;
SUPPORT * getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION) ;
+ //SUPPORT * getBoundaryElements(medEntityMesh Entity) const throw (MEDEXCEPTION) ; // problème avec le maillage dans le support : le pointeur n'est pas const, mais sa valeur oui. A voir !!! PG
+
+ SUPPORT * getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION) ;
// Node DonneBarycentre(const Cell &m) const;
- FIELD<double>* getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 3D elements
- FIELD<double>* getArea(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 2D elements
- FIELD<double>* getLength(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 1D elements
- FIELD<double>* getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 2D elements
- FIELD<double>* getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION) ;
- // FIELD<int>* getNeighbourhood(SUPPORT * Support) throw (MEDEXCEPTION) ; // Il faut preciser !
+ FIELD<double>* getVolume(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 3D elements
+ FIELD<double>* getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 2D elements
+ FIELD<double>* getLength(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 1D elements
+ FIELD<double>* getNormal(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 2D elements
+ FIELD<double>* getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION) ;
+ // FIELD<int>* getNeighbourhood(SUPPORT * Support) const throw (MEDEXCEPTION) ; // Il faut preciser !
};
// ---------------------------------------
// Methodes Inline
// ---------------------------------------
-inline CONNECTIVITY* MESH::getConnectivityptr() {return _connectivity;}
-
-inline void MESH::read(int index/*=0*/)
-{
- const char * LOC = "MESH::read(int index=0) : ";
- BEGIN_OF(LOC);
-
- if (_drivers[index]) {
- _drivers[index]->open();
- _drivers[index]->read();
- _drivers[index]->close();
- }
- else
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "The index given is invalid, index must be between 0 and |"
- << _drivers.size()
- )
- );
- END_OF(LOC);
-}
+inline const CONNECTIVITY* MESH::getConnectivityptr() const
+{
+ return _connectivity;
+}
+
+// inline void MESH::read(int index/*=0*/)
+// {
+// const char * LOC = "MESH::read(int index=0) : ";
+// BEGIN_OF(LOC);
+
+// if (_drivers[index]) {
+// _drivers[index]->open();
+// _drivers[index]->read();
+// _drivers[index]->close();
+// }
+// else
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+// << "The index given is invalid, index must be between 0 and |"
+// << _drivers.size()
+// )
+// );
+// END_OF(LOC);
+// }
/*! Write all the content of the MESH using driver referenced by the handler <index>*/
-inline void MESH::write(int index/*=0*/, const string & driverName/* = ""*/)
-{
+inline void MESH::write(int index/*=0*/, const string & driverName/* = ""*/)
+{
const char * LOC = "MESH::write(int index=0, const string & driverName = \"\") : ";
BEGIN_OF(LOC);
if ( _drivers[index] ) {
- _drivers[index]->open();
- if (driverName != "") _drivers[index]->setMeshName(driverName);
- _drivers[index]->write();
- _drivers[index]->close();
+ _drivers[index]->open();
+ if (driverName != "") _drivers[index]->setMeshName(driverName);
+ _drivers[index]->write();
+ _drivers[index]->close();
}
else
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "The index given is invalid, index must be between 0 and |"
- << _drivers.size()
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
)
- );
+ );
END_OF(LOC);
-}
+}
-// This method is MED specific : don't use it
-// must be private.
-inline void MESH::write(const MED_MED_DRIVER & genDriver)
-{
+// This method is MED specific : don't use it
+// must be private.
+inline void MESH::write(const MED_MED_DRIVER & genDriver)
+{
const char * LOC = "MESH::write(const MED_MED_DRIVER & genDriver): ";
BEGIN_OF(LOC);
for (int index=0; index < _drivers.size(); index++ )
- if ( *_drivers[index] == genDriver ) {
- _drivers[index]->open();
- _drivers[index]->write();
+ if ( *_drivers[index] == genDriver ) {
+ _drivers[index]->open();
+ _drivers[index]->write();
_drivers[index]->close();
// ? FINALEMENT PAS BESOIN DE L'EXCEPTION ?
}
-
+
END_OF(LOC);
-
-}
+
+}
+
+// This method is MED specific : don't use it
+// must be private.
+inline void MESH::read(const MED_MED_DRIVER & genDriver)
+{
+ const char * LOC = "MESH::read(const MED_MED_DRIVER & genDriver): ";
+ BEGIN_OF(LOC);
+
+ for (int index=0; index < _drivers.size(); index++ )
+ if ( *_drivers[index] == genDriver ) {
+ _drivers[index]->open();
+ _drivers[index]->read();
+ _drivers[index]->close();
+ // ? FINALEMENT PAS BESOIN DE L'EXCEPTION ?
+ }
+
+ END_OF(LOC);
+
+}
// This method is MED specific : don't use it
// must be private.
}
/*! Set the MESH name */
-inline void MESH::setName(string name)
+inline void MESH::setName(string name)
{
_name=name ; //NOM interne à la classe
}
/*! Get the MESH name */
-inline string MESH::getName() const
+inline string MESH::getName() const
{
return _name ;
}
/*! Get the dimension of the space */
-inline int MESH::getSpaceDimension()
+inline int MESH::getSpaceDimension() const
{
return _spaceDimension;
}
/*! Get the dimension of the MESH */
-inline int MESH::getMeshDimension()
+inline int MESH::getMeshDimension() const
{
return _meshDimension;
}
/*! Get the number of nodes used in the MESH */
-inline int MESH::getNumberOfNodes()
+inline int MESH::getNumberOfNodes() const
{
return _numberOfNodes;
}
/*! Get the COORDINATES object. Use it only if you need COORDINATES informations not provided by the MESH class.*/
-inline COORDINATE * MESH::getCoordinateptr()
+inline const COORDINATE * MESH::getCoordinateptr() const
{
+ checkGridFillCoords();
return _coordinate;
}
/*! Get the system in which coordinates are given (CARTESIAN,CYLINDRICAL,SPHERICAL) __??MED_CART??__. */
-inline string MESH::getCoordinatesSystem()
+inline string MESH::getCoordinatesSystem() const
{
return _coordinate->getCoordinatesSystem();
}
/*! Get the whole coordinates array in a given interlacing mode. The interlacing mode are :
- MED_NO_INTERLACE : X1 X2 Y1 Y2 Z1 Z2
- - MED_FULL_INTERLACE : X1 Y1 Z1 X2 Y2 Z2
+ - MED_FULL_INTERLACE : X1 Y1 Z1 X2 Y2 Z2
*/
-inline const double * MESH::getCoordinates(medModeSwitch Mode)
+inline const double * MESH::getCoordinates(medModeSwitch Mode) const
{
+ checkGridFillCoords();
return _coordinate->getCoordinates(Mode);
}
/*! Get the coordinate n° number on axis n°axis*/
-inline const double MESH::getCoordinate(int number, int axis)
+inline const double MESH::getCoordinate(int number, int axis) const
{
+ checkGridFillCoords();
return _coordinate->getCoordinate(number,axis);
}
/*! Get the coordinate names array ("x ","y ","z ")
of size n*MED_TAILLE_PNOM
*/
-inline string * MESH::getCoordinatesNames()
+inline const string * MESH::getCoordinatesNames() const
{
return _coordinate->getCoordinatesNames();
}
/*! Get the coordinate unit names array ("cm ","cm ","cm ")
of size n*MED_TAILLE_PNOM
*/
-inline string * MESH::getCoordinatesUnits()
+inline const string * MESH::getCoordinatesUnits() const
{
return _coordinate->getCoordinatesUnits();
}
-// int * MESH::getNodesNumbers() {
+// int * MESH::getNodesNumbers() const
+// {
// return nodesNumbers;
// }
/*! Get the number of different geometric types for a given entity type.
- For exemple getNumberOfTypes(MED_CELL) would return 3 is the MESH
- have some MED_TETRA4, MED_PYRA5 and MED_HEXA6 in it.
+ For exemple getNumberOfTypes(MED_CELL) would return 3 is the MESH
+ have some MED_TETRA4, MED_PYRA5 and MED_HEXA6 in it.
medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_NODE, MED_ALL_ENTITIES
If there is no connectivity, return an exception.
*/
-inline int MESH::getNumberOfTypes(medEntityMesh entity)
+inline int MESH::getNumberOfTypes(medEntityMesh entity) const
{
MESSAGE("MESH::getNumberOfTypes(medEntityMesh entity) : "<<entity);
if (entity == MED_NODE)
return 1 ;
+ checkGridFillConnectivity();
if (_connectivity != NULL)
return _connectivity->getNumberOfTypes(entity) ;
throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !"));
}
-/*!
+/*!
Get the list of geometric types used by a given entity.
medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_ALL_ENTITIES
- REM : Don't use MED_NODE
+ REM : Don't use MED_NODE
If entity is not defined, return an exception.
*/
-inline medGeometryElement * MESH::getTypes(medEntityMesh entity)
+inline const medGeometryElement * MESH::getTypes(medEntityMesh entity) const
{
if (entity == MED_NODE)
throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : No medGeometryElement with MED_NODE entity !"));
// return un tableau de taille 1 contenant MED_NONE, comme les supports pour etre coherent avec getNumberOfTypes ???? PG
+ checkGridFillConnectivity();
if (_connectivity != NULL)
return _connectivity->getGeometricTypes(entity) ;
throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : Connectivity not defined !"));
}
-/*!
+/*!
Get the whole list of CELLMODEL used by cells of given type (medEntityMesh).
REMARK : Don't use MED_NODE as medEntityMesh
*/
-inline CELLMODEL * MESH::getCellsTypes(medEntityMesh Entity)
+inline const CELLMODEL * MESH::getCellsTypes(medEntityMesh Entity) const
{
+ checkGridFillConnectivity();
if (_connectivity != NULL)
- return _connectivity->getCellsTypes(Entity) ;
+ return _connectivity->getCellsTypes(Entity) ;
throw MEDEXCEPTION(LOCALIZED("MESH::getCellsTypes( medEntityMesh ) : Connectivity not defined !"));
}
-/*! Return an array of size NumbreOfTypes+1 which contains, for each
- geometric type of the given entity, the first global element number
+/*! Return an array of size NumbreOfTypes+1 which contains, for each
+ geometric type of the given entity, the first global element number
of this type.
- For exemple, if we have a mesh with 5 triangles and 4 quadrangle :
+ For exemple, if we have a mesh with 5 triangles and 4 quadrangle :
- size of GlobalNumberingIndex is 3
- GlobalNumberingIndex[0]=1 (the first type)
- GlobalNumberingIndex[1]=6 (the second type)
- GlobalNumberingIndex[2]=10
*/
-inline int * MESH::getGlobalNumberingIndex(medEntityMesh entity)
+inline const int * MESH::getGlobalNumberingIndex(medEntityMesh entity) const
{
+ checkGridFillConnectivity();
if (_connectivity != NULL)
- return _connectivity->getGlobalNumberingIndex(entity);
+ return _connectivity->getGlobalNumberingIndex(entity);
throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !"));
}
/*!
Example :
- getNumberOfElements(MED_NODE,MED_NONE) : number of node
- getNumberOfElements(MED_NODE,MED_TRIA3) : return 0 (not defined)
- - getNumberOfElements(MED_FACE,MED_TRIA3) : return number of triangles
+ - getNumberOfElements(MED_FACE,MED_TRIA3) : return number of triangles
elements defined in face entity (0 if not defined)
- - getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) : return total number
+ - getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) : return total number
of elements defined in cell entity
*/
-inline int MESH::getNumberOfElements(medEntityMesh entity, medGeometryElement Type)
+inline int MESH::getNumberOfElements(medEntityMesh entity, medGeometryElement Type) const
{
const char * LOC = "MESH::getNumberOfElements(medEntityMesh,medGeometryElement) : " ;
if (entity==MED_NODE)
return _numberOfNodes ;
else
return 0 ;
- //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"wrong medGeometryElement with MED_NODE"));
- else
- if (_connectivity != (CONNECTIVITY*)NULL)
- return _connectivity->getNumberOf(entity,Type) ;
- else
- return 0 ;
+ //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"wrong medGeometryElement with MED_NODE"));
+ else
+ {
+ checkGridFillConnectivity();
+ if (_connectivity != (CONNECTIVITY*)NULL)
+ return _connectivity->getNumberOf(entity,Type) ;
+ else
+ return 0 ;
//throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"connectivity not defined !"));
+ }
}
/*!
Return true if the wanted connectivity exist, else return false
(to use before a getSomething method).
*/
-inline bool MESH::existConnectivity(medConnectivity connectivityType, medEntityMesh entity)
+inline bool MESH::existConnectivity(medConnectivity connectivityType, medEntityMesh entity) const
{
+ checkGridFillConnectivity();
if (_connectivity==(CONNECTIVITY*)NULL)
throw MEDEXCEPTION("MESH::existConnectivity(medConnectivity,medEntityMesh) : no connectivity defined !");
return _connectivity->existConnectivity(connectivityType,entity) ;
Throw an exception if Entity is not defined or Number are wrong (too big).
*/
-inline medGeometryElement MESH::getElementType(medEntityMesh Entity,int Number)
+inline medGeometryElement MESH::getElementType(medEntityMesh Entity,int Number) const
{
+ checkGridFillConnectivity();
if (_connectivity==(CONNECTIVITY*)NULL)
throw MEDEXCEPTION("MESH::getElementType(medEntityMesh,int) : no connectivity defined !");
return _connectivity->getElementType(Entity,Number) ;
}
/*!
- Calculate the ask connectivity. Return an exception if this could not be
+ Calculate the ask connectivity. Return an exception if this could not be
done. Do nothing if connectivity already exist.
*/
inline void MESH::calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity)
{
+ checkGridFillConnectivity();
if (Mode==MED_FULL_INTERLACE)
_connectivity->calculateConnectivity(ConnectivityType,entity) ;
else
throw MEDEXCEPTION(LOCALIZED("MESH::calculateConnectivity : only for MED_FULL_INTERLACE mode"));
}
/*!
- Return the required connectivity in the right mode for the given
+ Return the required connectivity in the right mode for the given
geometric type of the given entity.
- To get connectivity for all geometric type, use Mode=MED_FULL_INTERLACE
- and Type=MED_ALL_ELEMENTS.
+ To get connectivity for all geometric type, use Mode=MED_FULL_INTERLACE
+ and Type=MED_ALL_ELEMENTS.
You must also get the corresponding index array.
*/
-inline int * MESH::getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity, medGeometryElement Type)
+inline const int * MESH::getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity, medGeometryElement Type) const
{
+ checkGridFillConnectivity();
if (Mode==MED_FULL_INTERLACE)
return _connectivity->getConnectivity(ConnectivityType,entity,Type) ;
throw MEDEXCEPTION(LOCALIZED("MESH::getConnectivity : only for MED_FULL_INTERLACE mode"));
}
/*!
- Return the required index array for a connectivity received in
+ Return the required index array for a connectivity received in
MED_FULL_ENTERLACE mode and MED_ALL_ELEMENTS type.
This array allow to find connectivity of each elements.
Example : Connectivity of i^{th} elements (1<=i<=NumberOfElement) begin
- at index ConnectivityIndex[i-1] and end at index ConnectivityIndex[i]-1
- in Connectivity array (Connectivity[ConnectivityIndex[i-1]-1] is the
+ at index ConnectivityIndex[i-1] and end at index ConnectivityIndex[i]-1
+ in Connectivity array (Connectivity[ConnectivityIndex[i-1]-1] is the
first value)
*/
-inline int * MESH::getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh entity)
+inline const int * MESH::getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh entity) const
{
+ checkGridFillConnectivity();
return _connectivity->getConnectivityIndex(ConnectivityType, entity) ;
}
/*!
You must get ReverseConnectivityIndex array to use it.
*/
-inline int * MESH::getReverseConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/)
+inline const int * MESH::getReverseConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/) const
{
+ checkGridFillConnectivity();
if (NULL==_connectivity)
throw MEDEXCEPTION("MESH::getReverseConnectivity : no connectivity defined in MESH !");
-
+
return _connectivity->getReverseConnectivity(ConnectivityType,Entity) ;
}
/*!
This array allow to find reverse connectivity of each elements.
- Example : Reverse connectivity of i^{th} elements (1<=i<=NumberOfElement)
- begin at index ReverseConnectivityIndex[i-1] and end at index
- ReverseConnectivityIndex[i]-1
+ Example : Reverse connectivity of i^{th} elements (1<=i<=NumberOfElement)
+ begin at index ReverseConnectivityIndex[i-1] and end at index
+ ReverseConnectivityIndex[i]-1
in ReverseConnectivity array (
- ReverseConnectivity[ReverseConnectivityIndex[i-1]-1]
+ ReverseConnectivity[ReverseConnectivityIndex[i-1]-1]
is the first value)
*/
-inline int * MESH::getReverseConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/)
+inline const int * MESH::getReverseConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/) const
{
+ checkGridFillConnectivity();
if (NULL==_connectivity)
throw MEDEXCEPTION("MESH::getReverseConnectivityIndex : no connectivity defined in MESH !");
-
+
return _connectivity->getReverseConnectivityIndex(ConnectivityType,Entity) ;
}
-inline int MESH::getNumberOfFamilies (medEntityMesh entity)
+inline int MESH::getNumberOfFamilies (medEntityMesh entity) const
{
switch (entity) {
- case MED_NODE :
+ case MED_NODE :
return _numberOfNodesFamilies ;
- case MED_CELL :
+ case MED_CELL :
return _numberOfCellsFamilies ;
case MED_FACE :
return _numberOfFacesFamilies ;
throw MEDEXCEPTION("MESH::getNumberOfFamilies : Unknown entity");
}
}
-inline int MESH::getNumberOfGroups (medEntityMesh entity)
+inline int MESH::getNumberOfGroups (medEntityMesh entity) const
{
switch (entity) {
- case MED_NODE :
+ case MED_NODE :
return _numberOfNodesGroups ;
- case MED_CELL :
+ case MED_CELL :
return _numberOfCellsGroups ;
case MED_FACE :
return _numberOfFacesGroups ;
throw MEDEXCEPTION("MESH::getNumberOfGroups : Unknown entity");
}
}
-vector<FAMILY*> MESH::getFamilies(medEntityMesh entity) {
+const vector<FAMILY*> MESH::getFamilies(medEntityMesh entity) const
+{
switch (entity) {
- case MED_NODE :
+ case MED_NODE :
return _familyNode ;
- case MED_CELL :
+ case MED_CELL :
return _familyCell ;
case MED_FACE :
return _familyFace ;
}
}
-vector<GROUP*> MESH::getGroups(medEntityMesh entity) {
+const vector<GROUP*> MESH::getGroups(medEntityMesh entity) const
+{
switch (entity) {
- case MED_NODE :
+ case MED_NODE :
return _groupNode ;
- case MED_CELL :
+ case MED_CELL :
return _groupCell ;
case MED_FACE :
return _groupFace ;
}
}
-FAMILY* MESH::getFamily(medEntityMesh entity, int i) {
- if (i<=0)
+const FAMILY* MESH::getFamily(medEntityMesh entity, int i) const
+{
+ if (i<=0)
throw MEDEXCEPTION("MESH::getFamily(i) : argument i must be > 0");
int NumberOfFamilies = 0 ;
vector<FAMILY*> Family ;
default :
throw MEDEXCEPTION("MESH::getFamilies : Unknown entity");
}
- if (i>NumberOfFamilies)
+ if (i>NumberOfFamilies)
throw MEDEXCEPTION("MESH::getFamily(entity,i) : argument i must be <= _numberOfFamilies");
- return Family[i-1];
+ return Family[i-1];
}
-GROUP* MESH::getGroup(medEntityMesh entity, int i) {
+const GROUP* MESH::getGroup(medEntityMesh entity, int i) const
+{
const char * LOC = "MESH::getGroup(medEntityMesh entity, int i) : " ;
- if (i<=0)
+ if (i<=0)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"argument i must be > 0"));
int NumberOfGroups = 0 ;
vector<GROUP*> Group ;
default :
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Unknown entity"));
}
- if (i>NumberOfGroups)
+ if (i>NumberOfGroups)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"argument i="<<i<<" must be <= _numberOfGroups="<<NumberOfGroups));
- return Group[i-1];
+ return Group[i-1];
}
// return ;
// }
-//inline void MESH::write(const string & driverName) {
+//inline void MESH::write(const string & driverName) {
// write(0,driverName);
//}
-
-// this method are temporary, perhaps we remove it if we put information in an other place
-inline int * MESH::getMEDArrayNodeFamily() {
- return _MEDArrayNodeFamily ;
-}
-inline int ** MESH::getMEDArrayCellFamily() {
- return _MEDArrayCellFamily ;
-}
-inline int ** MESH::getMEDArrayFaceFamily() {
- return _MEDArrayFaceFamily ;
-}
-inline int ** MESH::getMEDArrayEdgeFamily() {
- return _MEDArrayEdgeFamily ;
+inline bool MESH::getIsAGrid()
+{
+ return _isAGrid;
}
#endif /* MESH_HXX */
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_SkyLineArray.hxx
+// Module : MED
+
# ifndef __MEDSKYLINEARRAY_H__
# define __MEDSKYLINEARRAY_H__
private :
med_int _count ;
med_int _length ;
- PointerOf <med_int> _index ; // array of size _count+1 : _index[0]=1 and
+ PointerOf <med_int> _index ; // array of size _count+1 : _index[0]=1 and
// _index[_count]=length+1
PointerOf <med_int> _value ; // array of size _length
MEDSKYLINEARRAY();
~MEDSKYLINEARRAY();
MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray );
- MEDSKYLINEARRAY( const med_int count , const med_int length );
-
- void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ;
+ MEDSKYLINEARRAY( const med_int count, const med_int length );
+ MEDSKYLINEARRAY( const med_int count, const med_int length,
+ const med_int* index, const med_int* value );
+
+ //void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ;
inline med_int getNumberOf() const;
inline med_int getLength() const;
- inline med_int* getIndex() ;
- inline med_int* getValue() ;
+ inline const med_int* getIndex() const;
+ inline const med_int* getValue() const;
inline med_int getNumberOfI(int i) const throw (MEDEXCEPTION) ;
- inline med_int* getI(int i) throw (MEDEXCEPTION) ;
+ inline const med_int* getI(int i) const throw (MEDEXCEPTION) ;
inline med_int getIJ(int i, int j) const throw (MEDEXCEPTION) ;
-
+ inline med_int getIndexValue(int i) const throw (MEDEXCEPTION) ;
+
+ inline void setIndex(const med_int* index) ;
+ inline void setI(const med_int i, const med_int* values) throw (MEDEXCEPTION) ;
+ inline void setIJ(med_int i, med_int j, med_int value) throw (MEDEXCEPTION) ;
+ inline void setIndexValue(med_int i, med_int value) throw (MEDEXCEPTION) ;
+
} ;
// ---------------------------------------
{
return _length ;
};
-inline med_int* MEDSKYLINEARRAY::getIndex()
-{
- return (med_int*)_index ;
+inline const med_int* MEDSKYLINEARRAY::getIndex() const
+{
+ return (const med_int*)_index ;
} ;
-inline med_int* MEDSKYLINEARRAY::getValue()
-{
- return (med_int*)_value ;
+inline const med_int* MEDSKYLINEARRAY::getValue() const
+{
+ return (const med_int*)_value ;
} ;
inline med_int MEDSKYLINEARRAY::getNumberOfI(int i) const throw (MEDEXCEPTION)
{
throw MEDEXCEPTION("MEDSKYLINEARRAY::getNumberOfI : argument is out of range");
return _index[i]-_index[i-1] ;
} ;
-inline med_int* MEDSKYLINEARRAY::getI(int i) throw (MEDEXCEPTION)
-{
+inline const med_int* MEDSKYLINEARRAY::getI(int i) const throw (MEDEXCEPTION)
+{
if (i<1)
throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument must be >= 1");
if (i>_count)
throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument is out of range");
- return _value+_index[i-1]-1 ;
+ return _value+_index[i-1]-1 ;
}
inline med_int MEDSKYLINEARRAY::getIJ(int i, int j) const throw (MEDEXCEPTION)
-{
+{
if (i<1)
throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : first argument must be >= 1");
if (j<1)
return _value[_index[i-1]+j-2] ;
}
+inline med_int MEDSKYLINEARRAY::getIndexValue(int i) const throw (MEDEXCEPTION)
+{
+ if (i<1)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::getIndexValue : argument must be >= 1");
+ if (i>_index[_count])
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::getIndexValue : argument is out of range") ;
+ return _value[i-1] ;
+}
+
+inline void MEDSKYLINEARRAY::setIndex(const med_int* index)
+{
+ memcpy((med_int*)_index,index,(_count+1)*sizeof(med_int));
+}
+
+
+inline void MEDSKYLINEARRAY::setIJ(med_int i, med_int j, med_int value) throw (MEDEXCEPTION)
+{
+ if (i<1)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : first argument must be >= 1");
+ if (j<1)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : second argument must be >= 1");
+ if (i>_count)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : first argument is out of range") ;
+ if (j>_index[i])
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : second argument is out of range") ;
+
+ _value[_index[i-1]+j-2]=value ;
+
+}
+
+inline void MEDSKYLINEARRAY::setI(const med_int i, const med_int * values) throw (MEDEXCEPTION)
+{
+ if (i<1)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setI : index must be >= 1");
+;
+ if (i>_count)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setI : index is out of range") ;
+
+ memcpy(_value+_index[i-1]-1,values,(_index[i]-_index[i-1])*sizeof(med_int)) ;
+}
+
+inline void MEDSKYLINEARRAY::setIndexValue(med_int i, med_int value) throw (MEDEXCEPTION)
+{
+ if (i<1)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setIndexValue : argument must be >= 1");
+ if (i>_index[_count])
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setIndexValue : argument is out of range") ;
+ _value[i-1]=value ;
+}
# endif
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Support.hxx
+// Module : MED
+
/*
- File Support.hxx
- $Header$
+ File Support.hxx
+ $Header$
*/
#ifndef SUPPORT_HXX
#include <string>
#include "utilities.h"
+#include "MEDMEM_STRING.hxx"
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_define.hxx"
#include "MEDMEM_SkyLineArray.hxx"
-#include "MEDMEM_Mesh.hxx"
+//#include "MEDMEM_Mesh.hxx"
using namespace MED_EN;
class MESH ;
-class SUPPORT
+/*!
+
+ This class describe a support of elements on an entity of the mesh.
+
+ It contains the list of meshes elements for an entity (MED_NODE,
+ MED_CELL, MED_FACE or MED_EDGE).
+
+*/
+
+class SUPPORT
{
protected:
- /*! name of the support */
+ /*!
+ \if developper
+ Support name.
+ \endif
+ */
string _name;
- /*! description of the support (optionnal) */
+
+ /*!
+ \if developper
+ Description of the support (optional).
+ \endif
+ */
string _description;
- /*! reference to the mesh on which the support is defined */
+
+ /*!
+ \if developper
+ Reference to the mesh on which the support is defined.
+ \endif
+ */
MESH * _mesh;
- /*! type of entity on which the support is defined
- (only one for each support) */
+
+ /*!
+ \if developper
+ Type of entity on which the support is defined
+ (only one for each support).
+ \endif
+ */
medEntityMesh _entity ;
- /*! number of geometric type defined in the support */
+
+ /*!
+ \if developper
+ Number of geometric type defined in the support.
+ \endif
+ */
int _numberOfGeometricType;
- /*! array of all geometric type defined in the support */
+
+ /*!
+ \if developper
+ Array of all geometric type defined in the support.
+ \endif
+ */
medGeometryElement * _geometricType;
- /*! array of size _numberOfGeometricType which contains
- for each type the number of gauss point
- (not yet implemented) */
- int * _numberOfGaussPoint ;
- /*! array of size _numberOfGeometricType
- which contains number of geometric
- entity type in Mesh
- (to get corresponding CellModel)*/
- int * _geometricTypeNumber;
- /*! If true, we consider all entities of type _entity */
- bool _isOnAllElts;
- /*! array of size _numberOfGeometricType wich contains
- for each geometric type, count of entities.
- (if _isOnAllElts is true, we could get same
- information from _mesh) */
- int * _numberOfEntities;
- /*! sum of each _numberOfEntities component (if
- _isOnAllElts is true, we could get same
- information from _mesh) */
- int _totalNumberOfEntities;
+
+ /*!
+ \if developper
+ Array of size _numberOfGeometricType which contains
+ for each type the number of gauss point
+ (not yet implemented).
+ \endif
+ */
+ int * _numberOfGaussPoint ;
+
+ /*
+ \if developper
+ Array of size _numberOfGeometricType
+ which contains number of geometric
+ entity type in Mesh
+ (to get corresponding CellModel).
+ \endif
+ */
+ //int * _geometricTypeNumber;
+
+ /*!
+ \if developper
+ If true, we consider all entities of type _entity.
+ \endif
+ */
+ bool _isOnAllElts;
+
+ /*!
+ \if developper
+ Index array of size _numberOfGeometricType wich contains
+ for each geometric type, the number of elements of this type.
+ \endif
+ */
+ int * _numberOfElements;
+
+ /*!
+ \if developper
+ Sum of each _numberOfElements component.
+ \endif
+ */
+ int _totalNumberOfElements;
// the two following arrays are defined only if _isOnAllElts is false :
- /* array of size _numberOfType+1 wich contains for
- each geometric type, index in _number._value
- (if _all is true, we must ask _mesh to get
- information). _typeIndex[i+1]-_typeIndex[i]
- represents count of entities of ith geometric
- type. _typeIndex[_numberOfType] contains total
- entities count. If _numberOf[i]=0,
- _typeIndex[i+1]=_typeIndex[i]
- defined only if _isOnAllElts is false*/
- // int * _typeIndex;
- /*! array of size _index[_numberOfType] wich contain number of
- entities of each geometric type. We use global numbering.
- defined only if _isOnAllElts is false*/
- MEDSKYLINEARRAY * _number;
+ /*
+ \if developper
+ array of size _numberOfType+1 wich contains for
+ each geometric type, index in _number._value
+ (if _all is true, we must ask _mesh to get
+ information). _typeIndex[i+1]-_typeIndex[i]
+ represents count of entities of ith geometric
+ type. _typeIndex[_numberOfType] contains total
+ entities count. If _numberOf[i]=0,
+ _typeIndex[i+1]=_typeIndex[i]
+ defined only if _isOnAllElts is false
+ \endif
+ */
+ // int * _typeIndex;
+
+ /*!
+ \if developper
+ Array of size _index[_numberOfType]-1 wich contain number of
+ entities of each geometric type. We use global numbering.\n
+ Defined only if _isOnAllElts is false.
+ \endif
+ */
+ MEDSKYLINEARRAY * _number;
public:
- SUPPORT();
- SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL);
- SUPPORT(SUPPORT & m);
+ SUPPORT();
+ SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL);
+ SUPPORT(const SUPPORT & m);
~SUPPORT();
friend ostream & operator<<(ostream &os,const SUPPORT &my);
-
+
// function to set all value when SUPPORT was created by MedMedDriver without all MESH information !!! Change with new API !
void update();
-
+
inline void setName(string Name);
- inline void setDescription(string Description);
- inline void setMesh(MESH *Mesh);
- inline void setAll(bool All);
- inline void setEntity(medEntityMesh Entity);
- inline void setNumberOfGeometricType(int NumberOfGeometricType);
- inline void setGeometricType(medGeometryElement *GeometricType);
- inline void setNumberOfGaussPoint(int *NumberOfGaussPoint);
- // inline void setGeometricTypeNumber(int *GeometricTypeNumber);
- inline void setNumberOfEntities(int *NumberOfEntities);
- inline void setTotalNumberOfEntities(int TotalNumberOfEntities);
- inline void setNumber(MEDSKYLINEARRAY * Number);
-
- inline string getName() const;
- inline string getDescription() const;
- inline MESH * getMesh() const;
+ inline void setDescription(string Description);
+ inline void setMesh(MESH *Mesh);
+ inline void setAll(bool All);
+ inline void setEntity(medEntityMesh Entity);
+ inline void setNumberOfGeometricType(int NumberOfGeometricType);
+ inline void setGeometricType(const medGeometryElement *GeometricType);
+ inline void setNumberOfGaussPoint(const int *NumberOfGaussPoint);
+ // inline void setGeometricTypeNumber(int *GeometricTypeNumber);
+ inline void setNumberOfElements(const int *NumberOfElements);
+ inline void setTotalNumberOfElements(int TotalNumberOfElements);
+ inline void setNumber(MEDSKYLINEARRAY * Number);
+ inline void setNumber(const int * index, const int* value);
+
+ inline string getName() const;
+ inline string getDescription() const;
+ inline MESH * getMesh() const;
inline medEntityMesh getEntity() const;
- inline bool isOnAllElements() const;
+ inline bool isOnAllElements() const;
inline int getNumberOfTypes() const;
- inline medGeometryElement* getTypes() const ;
- inline int * getNumberOfGaussPoint() const throw (MEDEXCEPTION);
- inline int getNumberOfGaussPoint(medGeometryElement geomElement) const throw (MEDEXCEPTION);
- //inline int * getGeometricTypeNumber() const;
- // inline int getNumberOfTotalEntity() const;
+ inline const medGeometryElement* getTypes() const ;
+ inline const int * getNumberOfGaussPoint() const throw (MEDEXCEPTION);
+ inline int getNumberOfGaussPoint(medGeometryElement geomElement) const throw (MEDEXCEPTION);
+ //inline int * getGeometricTypeNumber() const;
+ //inline int getTotalNumberOfElement() const;
inline int getNumberOfElements(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION);
- inline int * getNumber(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
- inline int * getNumberIndex() const throw (MEDEXCEPTION);
+ inline const int * getNumber(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
+ inline const int * getNumberIndex() const throw (MEDEXCEPTION);
void blending(SUPPORT * mySupport);
- /*
- This function allows the user to set a support not on all entities Entity,
- it should be used after an initialisation with the constructor
- SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL) and
- after the call to the function setAll(false).
- It allocates and initialises all the attributs of the class SUPPORT.
- */
-
void setpartial(string Description, int NumberOfGeometricType,
int TotalNumberOfEntity, medGeometryElement *GeometricType,
int *NumberOfEntity, int *NumberValue);
+
+ void getBoundaryElements() throw (MEDEXCEPTION);
};
// _____________________
// Methodes Inline
// _____________________
-/*! If isOnAllElements is false, returns number of elements in the
- support else returns number of nodes.
+/*!
+ If isOnAllElements is false, returns number of elements in the
+ support else returns number of nodes.
- Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements
- in entity of support.
+ Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements
+ in entity of support.
- Note : If SUPPORT is defined on MED_NODE, use MED_NONE
- medGeometryElement type. */
+ Note : If SUPPORT is defined on MED_NODE, use MED_NONE
+ medGeometryElement type.
+*/
//-----------------------------------------------------------------------------
inline int SUPPORT::getNumberOfElements(medGeometryElement GeometricType) const
-throw (MEDEXCEPTION)
+ throw (MEDEXCEPTION)
//-----------------------------------------------------------------------------
{
- if (_isOnAllElts){
- return _mesh->getNumberOfElements(_entity,GeometricType);
- } else {
- if (GeometricType==MED_ALL_ELEMENTS)
- return _totalNumberOfEntities;
- for (int i=0;i<_numberOfGeometricType;i++)
- if (_geometricType[i]==GeometricType)
- return _numberOfEntities[i] ;
- throw MEDEXCEPTION("Support::getNumberOfElements : Type not found !") ;
- }
+ if (GeometricType==MED_ALL_ELEMENTS)
+ return _totalNumberOfElements;
+ for (int i=0;i<_numberOfGeometricType;i++)
+ if (_geometricType[i]==GeometricType)
+ return _numberOfElements[i];
+ throw MEDEXCEPTION("Support::getNumberOfElements : Geometric type not found !") ;
}
-// inline int SUPPORT::getNumberOf(medGeometryElement GeometricType) const
-// throw (MEDEXCEPTION)
-// {
-// if (GeometricType==MED_ALL_ELEMENTS)
-// return _totalNumberOfEntities ;
-// for (int i=0;i<_numberOfGeometricType;i++)
-// if (_geometricType[i]==GeometricType)
-// return _numberOfEntities[i] ;
-// throw MEDEXCEPTION("Support::getNumberOf: GeometricType not found !");
-// }
-
-// inline int SUPPORT::getNumberOfTotalEntity() const
-// {
-// return _totalNumberOfEntities ;
-// }
//---------------------------------------------------------------------
-inline MEDSKYLINEARRAY * SUPPORT::getnumber() const
- throw (MEDEXCEPTION)
+inline MEDSKYLINEARRAY * SUPPORT::getnumber() const
+ throw (MEDEXCEPTION)
//---------------------------------------------------------------------
{
- if (_number==NULL)
+ if (_number==NULL)
throw MEDEXCEPTION("Support::getnumber : Not defined !") ;
return _number ;
}
-/*! If isOnAllElements is false, returns an array which contains
- all number of given medGeometryElement.
+/*!
+ If isOnAllElements is false, returns an array which contains
+ all number of given medGeometryElement.
- Numbering is global, ie numbers are bounded by 1 and
- MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and
- MESH::getNumberOfElement(entity,geomElement).
+ Numbering is global, ie numbers are bounded by 1 and
+ MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and
+ MESH::getNumberOfElement(entity,geomElement).
- Note : If SUPPORT is defined on MED_NODE, use MED_NONE
- medGeometryElement type. */
+ Note : If SUPPORT is defined on MED_NODE, use MED_NONE
+ medGeometryElement type.
+*/
//---------------------------------------------------------------------
-inline int * SUPPORT::getNumber(medGeometryElement GeometricType) const
- throw (MEDEXCEPTION)
+inline const int * SUPPORT::getNumber(medGeometryElement GeometricType) const
+ throw (MEDEXCEPTION)
//---------------------------------------------------------------------
{
const char * LOC = "Support::getNumber : " ;
- if (_isOnAllElts)
+ if (_isOnAllElts)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined, support is on all entity !")) ;
if (GeometricType==MED_ALL_ELEMENTS)
- return _number->getValue() ;
+ return _number->getValue() ;
for (int i=0;i<_numberOfGeometricType;i++)
if (_geometricType[i]==GeometricType)
return _number->getI(i+1) ;
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"GeometricType not found !")) ;
}
-/*! If isOnAllElements is false, returns index of element number.
- Use it with getNumber(MED_ALL_ELEMENTS).
+/*!
+ If isOnAllElements is false, returns index of element number.
+ Use it with getNumber(MED_ALL_ELEMENTS).
- Note : See getConnectivityIndex for details. */
+ Note : See getConnectivityIndex for details.
+*/
//-------------------------------------------
-inline int * SUPPORT::getNumberIndex() const
+inline const int * SUPPORT::getNumberIndex() const
//-------------------------------------------
-throw (MEDEXCEPTION)
+ throw (MEDEXCEPTION)
{
- if (_isOnAllElts)
- throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ;
- return _number->getIndex() ;
+ if (_isOnAllElts)
+ throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ;
+ return _number->getIndex() ;
}
/*! A DOCUMENTER */
//-------------------------------------------------
-inline int * SUPPORT::getNumberOfGaussPoint() const
-throw (MEDEXCEPTION)
+inline const int * SUPPORT::getNumberOfGaussPoint() const
+ throw (MEDEXCEPTION)
//-------------------------------------------------
{
if (_numberOfGaussPoint!=NULL)
throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
}
-/*! Returns number of Gauss points for this medGeometryElement.
+/*!
+ Returns number of Gauss points for this medGeometryElement.
- Note :
- - Not defined if SUPPORT is on MED_NODE.
- - Not defined for MED_ALL_ELEMENTS medGeometryElement type. */
+ Note :
+ - Not defined if SUPPORT is on MED_NODE.
+ - Not defined for MED_ALL_ELEMENTS medGeometryElement type.
+*/
//-----------------------------------------------------------------------------
-inline int SUPPORT::getNumberOfGaussPoint(medGeometryElement geomElement) const
-throw (MEDEXCEPTION)
+inline int SUPPORT::getNumberOfGaussPoint(medGeometryElement geomElement) const
+ throw (MEDEXCEPTION)
//-----------------------------------------------------------------------------
{
if (_numberOfGaussPoint!=NULL) {
} else
throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
}
-// inline int SUPPORT::getNumberLength() const
-// throw (MEDEXCEPTION)
+// inline int SUPPORT::getNumberLength() const
+// throw (MEDEXCEPTION)
// {
-// if (_isOnAllElts)
+// if (_isOnAllElts)
// throw MEDEXCEPTION("Support::getNumberLength : Not defined, support is on all entity !") ;
// return _number->getLength() ;
// }
-/*! set the attribute _name to Name */
+/*! set the attribute _name to Name */
//--------------------------------------
inline void SUPPORT::setName(string Name)
//--------------------------------------
-{
- _name=Name;
+{
+ _name=Name;
}
/*! set the attribute _description to Description */
//--------------------------------------------------
inline void SUPPORT::setDescription(string Description)
//--------------------------------------------------
-{
- _description=Description;
+{
+ _description=Description;
}
-/*! set the reference _mesh to Mesh */
+/*! set the reference _mesh to Mesh */
//--------------------------------------
inline void SUPPORT::setMesh(MESH *Mesh)
//--------------------------------------
-{
- _mesh=Mesh;
+{
+ _mesh=Mesh;
}
/*! set the attribute _isOnAllElts to All */
//------------------------------------------
inline void SUPPORT::setAll(bool All)
//------------------------------------------
-{
- _isOnAllElts=All;
+{
+ _isOnAllElts=All;
}
/*! set the attribute _entity to Entity */
//------------------------------------------
inline void SUPPORT::setEntity(medEntityMesh Entity)
-{
- _entity=Entity;
- if ( Entity == MED_NODE) {
- _numberOfGeometricType=1 ;
- _geometricType=new medGeometryElement[1] ; // delete previous ???
- _geometricType[0]=MED_NONE ;
- }
+{
+ _entity=Entity;
+// if ( Entity == MED_NODE) {
+// _numberOfGeometricType=1 ;
+// if (_geometricType == (medGeometryElement *) NULL)
+// _geometricType=new medGeometryElement[1] ;
+// else
+// {
+// // delete previous ???
+// delete [] _geometricType;
+// _geometricType=new medGeometryElement[1] ;
+// }
+// _geometricType[0]=MED_NONE ;
+// }
}
/*! set the attribute _numberOfGeometricType to NumberOfGeometricType */
//---------------------------------------------------------------------
inline void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType)
//---------------------------------------------------------------------
-{
- _numberOfGeometricType=NumberOfGeometricType;
+{
+ _numberOfGeometricType=NumberOfGeometricType;
+ if (_geometricType!=NULL) {
+ delete[] _geometricType ;
+ _geometricType = NULL ;
+ }
+ if (_numberOfElements!=NULL) {
+ delete[] _numberOfElements ;
+ _numberOfElements = NULL ;
+ }
+ if (_numberOfGaussPoint!=NULL) {
+ delete[] _numberOfGaussPoint ;
+ _numberOfGaussPoint = NULL ;
+ }
}
-/*! set the attribute _geometricType to geometricType */
+/*! set the attribute _geometricType to geometricType */
//---------------------------------------------------------------------
-inline void SUPPORT::setGeometricType(medGeometryElement *GeometricType)
+inline void SUPPORT::setGeometricType(const medGeometryElement *GeometricType)
//---------------------------------------------------------------------
-{
- _geometricType=GeometricType;
+{
+ if (NULL == _geometricType)
+ _geometricType=new medGeometryElement[_numberOfGeometricType];
+ for (int i=0;i<_numberOfGeometricType;i++)
+ _geometricType[i] = GeometricType[i];
+ // _geometricType=GeometricType;
}
-/*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */
+/*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */
//-----------------------------------------------------------------
-inline void SUPPORT::setNumberOfGaussPoint(int *NumberOfGaussPoint)
+inline void SUPPORT::setNumberOfGaussPoint(const int *NumberOfGaussPoint)
//-----------------------------------------------------------------
{
- _numberOfGaussPoint = NumberOfGaussPoint ;
+ if (NULL == _numberOfGaussPoint)
+ _numberOfGaussPoint=new int[_numberOfGeometricType];
+ for (int i=0;i<_numberOfGeometricType;i++)
+ _numberOfGaussPoint[i] = NumberOfGaussPoint[i];
+ // _numberOfGaussPoint = NumberOfGaussPoint ;
}
-/*! set the attribute _geometricTypeNumber to GeometricTypeNumber */
+/*! set the attribute _geometricTypeNumber to GeometricTypeNumber */
//-------------------------------------------------------------------
//inline void SUPPORT::setGeometricTypeNumber(int *GeometricTypeNumber)
//-------------------------------------------------------------------
-//{
-// _geometricTypeNumber=GeometricTypeNumber;
+//{
+// _geometricTypeNumber=GeometricTypeNumber;
//}
-/*! set the attribute _numberOfEntities to NumberOfEntities */
+/*!
+ Set the attribute _numberOfElements to NumberOfElements and
+ calculate the total number of elements.
+*/
//----------------------------------------------------------
-inline void SUPPORT::setNumberOfEntities(int *NumberOfEntities)
+inline void SUPPORT::setNumberOfElements(const int *NumberOfElements)
//----------------------------------------------------------
-{
- _numberOfEntities=NumberOfEntities;
+{
+ if (NULL == _numberOfElements)
+ _numberOfElements=new int[_numberOfGeometricType];
+ memcpy(_numberOfElements,NumberOfElements,sizeof(int)*_numberOfGeometricType);
+ _totalNumberOfElements = 0 ;
+ for (int i=0;i<_numberOfGeometricType;i++)
+ _totalNumberOfElements+=_numberOfElements[i];
}
-/*! set the attribute _totalNumberOfEntities to TotalNumberOfEntities */
+/*! set the attribute _totalNumberOfElements to TotalNumberOfElements */
//--------------------------------------------------------------------
-inline void SUPPORT::setTotalNumberOfEntities(int TotalNumberOfEntities)
+inline void SUPPORT::setTotalNumberOfElements(int TotalNumberOfElements)
//--------------------------------------------------------------------
-{
- _totalNumberOfEntities=TotalNumberOfEntities;
+{
+ _totalNumberOfElements=TotalNumberOfElements;
}
-/*! set the attribute _number to Number */
+/*! set the attribute _number to Number */
//---------------------------------------------------
inline void SUPPORT::setNumber(MEDSKYLINEARRAY * Number)
//---------------------------------------------------
-{
- _number=Number;
+{
+ if (_number != NULL) delete _number ;
+ _number=Number;
+}
+
+/*! set the attribute _number with index and value arrays */
+//---------------------------------------------------
+inline void SUPPORT::setNumber(const int * index, const int* value)
+//---------------------------------------------------
+{
+ if (_number != NULL) delete _number ;
+ _number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value);
}
/*! returns the name of the support. */
//------------------------------------
-inline string SUPPORT::getName() const
+inline string SUPPORT::getName() const
//------------------------------------
-{
- return _name;
+{
+ return _name;
}
/*! returns the description of the support. */
//--------------------------------------------
-inline string SUPPORT::getDescription() const
+inline string SUPPORT::getDescription() const
//--------------------------------------------
-{
- return _description;
+{
+ return _description;
}
-/*! returns a refernce to the mesh */
+/*! returns a reference to the mesh */
//------------------------------------
-inline MESH * SUPPORT::getMesh() const
+inline MESH * SUPPORT::getMesh() const
//------------------------------------
-{
- return _mesh;
+{
+ return _mesh;
}
-/*! Returns true if all elements of this entity are
- concerned, false otherwise.
- If true, you must use mesh reference (getMesh) to get more information.*/
+/*!
+ Returns true if all elements of this entity are
+ concerned, false otherwise.
+ If true, you must use mesh reference (getMesh) to get more information.
+*/
//------------------------------------------
-inline bool SUPPORT::isOnAllElements() const
+inline bool SUPPORT::isOnAllElements() const
//------------------------------------------
-{
- return _isOnAllElts;
+{
+ return _isOnAllElts;
}
-/*! Returns number of geometric Types
- defines in the support */
+/*!
+ Returns number of geometric Types
+ defines in the support
+*/
//------------------------------------------
-inline int SUPPORT::getNumberOfTypes() const
+inline int SUPPORT::getNumberOfTypes() const
//------------------------------------------
-{
- if ((_isOnAllElts)&(_entity != MED_NODE))
- return _mesh->getNumberOfTypes(_entity) ;
- else
- return _numberOfGeometricType ;
+{
+ // if ((_isOnAllElts)&(_entity != MED_NODE))
+ // return _mesh->getNumberOfTypes(_entity) ;
+ // else
+ return _numberOfGeometricType ;
}
-/*! Returns the medEntityMesh's type used by the support.
- Note : A support deals only with one entity's type
- (for example : MED_FACE or MED_NODE)*/
+/*!
+ Returns the medEntityMesh's type used by the support.
+ Note : A support deals only with one entity's type
+ (for example : MED_FACE or MED_NODE)
+*/
//---------------------------------------------
-inline medEntityMesh SUPPORT::getEntity() const
+inline medEntityMesh SUPPORT::getEntity() const
//---------------------------------------------
-{
- return _entity;
+{
+ return _entity;
}
-/*! If isOnAllElements is false, returns an array of <medGeometryElement>
- types used by the support.
+/*!
+ If isOnAllElements is false, returns an array of <medGeometryElement>
+ types used by the support.
- <medEntityMesh> is given by getEntity. */
+ <medEntityMesh> is given by getEntity.
+*/
//---------------------------------------------------
-inline medGeometryElement * SUPPORT::getTypes() const
+inline const medGeometryElement * SUPPORT::getTypes() const
//---------------------------------------------------
{
- if ((_isOnAllElts)&(_entity != MED_NODE))
- return _mesh->getTypes(_entity) ;
- else
- return _geometricType;
+ // if ((_isOnAllElts)&(_entity != MED_NODE))
+ // return _mesh->getTypes(_entity) ;
+ // else
+ return _geometricType;
}
//---------------------------------------------------
// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined (is on all elements) !"));
// if (_geometricTypeNumber==NULL)
// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined !"));
-// return _geometricTypeNumber;
+// return _geometricTypeNumber;
// }
-
+
#endif /* SUPPORT_HXX */
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Unit.hxx
+// Module : MED
+
/*
File Unit.hxx
$Header$
-#==============================================================================
-# File : Makefile.in
-# Author : Patrick GOLDBRONN (CEA/DEN/DM2S/SFME/LGLS)
-# CVS : $Header$
-#==============================================================================
+# MED MEDMEM : MED files in memory
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : Makefile.in
+# Author : Patrick GOLDBRONN (CEA/DEN/DM2S/SFME/LGLS)
+# Module : MED
-# source path
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
-VPATH=.:$(srcdir)
+VPATH=.:$(srcdir):$(srcdir)/tests
MACHINE=PCLINUX
MEDMEM_Med.hxx \
MEDMEM_MedMedDriver.hxx \
MEDMEM_MedMeshDriver.hxx \
+MEDMEM_GibiMeshDriver.hxx \
MEDMEM_ModulusArray.hxx \
MEDMEM_SkyLineArray.hxx \
MEDMEM_VtkMedDriver.hxx \
MEDMEM_Mesh.hxx \
+MEDMEM_Meshing.hxx \
MEDMEM_STRING.hxx \
MEDMEM_Support.hxx \
-MEDMEM_Unit.hxx
+MEDMEM_Unit.hxx \
+MEDMEM_Grid.hxx
# Libraries targets
MEDMEM_Exception.cxx \
MEDMEM_MedMedDriver.cxx \
MEDMEM_MedMeshDriver.cxx \
+MEDMEM_GibiMeshDriver.cxx \
MEDMEM_SkyLineArray.cxx \
MEDMEM_Mesh.cxx \
+MEDMEM_Meshing.cxx \
MEDMEM_Support.cxx \
MEDMEM_Unit.cxx \
-
-#VtkMedDriver.cxx \
+MEDMEM_VtkMedDriver.cxx \
+MEDMEM_Grid.cxx
# Executables targets
-BIN = duplicateMED med_test duplicateMEDMESH
+BIN = med2vtk duplicateMED med_test duplicateMEDMESH
BIN_SRC =
BIN_SERVER_IDL =
BIN_CLIENT_IDL =
-TEST_PROGS = test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray test_MEDMEM_CellModel test_copie_field_ test_copie_fieldT test_copie_coordinate test_copie_medarray test_copie_connectivity test_copie_support test_copie_family test_copie_group test_affect_medarray
-#TEST_PROGS = test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray test_MEDMEM_CellModel testUCoordinate testUUnit testUGeoNameMeshEntities testUMedException testUModulusArray testUSkyLineArray testUArray testUCellModel readEntete readCoordinate test_copie_field_ test_copie_fieldT test_copie_coordinate test_copie_medarray test_copie_connectivity test_copie_support test_copie_family test_copie_group test_affect_medarray
+TEST_PROGS = test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray test_MEDMEM_CellModel testUPointerOf testUCoordinate testUUnit testUGeoNameMeshEntities testUMedException testUModulusArray testUSkyLineArray testUArray testUCellModel readEntete readCoordinate test_copie_field_ test_copie_fieldT test_copie_coordinate test_copie_medarray test_copie_connectivity test_copie_support test_copie_family test_copie_group test_copie_mesh test_affect_medarray test_MEDMEM_Meshing
# testUCellModel -> a revoir car l'API a changee (plus de vector)
LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lSalomeLoggerServer -L${KERNEL_ROOT_DIR}/lib/salome
# build create_mesh :
-bin: create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_mesh_c3h8q4_wrong create_mesh_c2q4s2_wrong
+bin: create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_mesh_c3h8q4_wrong create_mesh_c2q4s2_wrong create_grid
-create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4: %: %.c
+create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_grid: %: %.c
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(MED2_LIBS) $(HDF5_LIBS) $(LDFLAGS) $<
@CONCLUDE@
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : duplicateMEDMESH.cxx
+// Module : MED
+
using namespace std;
#include<string>
#include<deque>
string filenameOUT = argv[2] ;
MED * myMed = new MED() ;
- MED_MED_DRIVER myMedDriver(filenameIN,myMed) ;
+ MED_MED_RDONLY_DRIVER myMedDriver(filenameIN,myMed) ;
// we read all meshes in filenameIN
try {
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : med_test.cxx
+// Module : MED
+
using namespace std;
#include<string>
double infty = 1.e20;
-void affiche_support(SUPPORT * mySupport)
+void affiche_support(const SUPPORT * mySupport)
{
cout << " - Name : "<<mySupport->getName().c_str()<<endl ;
cout << " - Description : "<<mySupport->getDescription().c_str()<<endl ;
if (!(mySupport->isOnAllElements())) {
int NumberOfTypes = mySupport->getNumberOfTypes() ;
cout<<" - NumberOfTypes : "<<NumberOfTypes<<endl;
- medGeometryElement * Types = mySupport->getTypes() ;
+ const medGeometryElement * Types = mySupport->getTypes() ;
for (int j=0;j<NumberOfTypes;j++) {
cout << " * Type "<<Types[j]<<" : " ;
int NumberOfElements = mySupport->getNumberOfElements(Types[j]) ;
- int * Number = mySupport->getNumber(Types[j]) ;
+ const int * Number = mySupport->getNumber(Types[j]) ;
for (int k=0; k<NumberOfElements;k++)
cout << Number[k] << " ";
cout << endl ;
int NumberOfFamilies = myMesh->getNumberOfFamilies(Entity) ;
cout << "NumberOfFamilies : "<<NumberOfFamilies<<endl;
for (int i=1; i<NumberOfFamilies+1;i++) {
- FAMILY* myFamily = myMesh->getFamily(Entity,i);
+ const FAMILY* myFamily = myMesh->getFamily(Entity,i);
affiche_support(myFamily);
cout << " - Identifier : "<<myFamily->getIdentifier()<<endl ;
int NumberOfAttributes = myFamily->getNumberOfAttributes() ;
int NumberOfGroups = myMesh->getNumberOfGroups(Entity) ;
cout << "NumberOfGroups : "<<NumberOfGroups<<endl;
for (int i=1; i<NumberOfGroups+1;i++) {
- GROUP* myGroup = myMesh->getGroup(Entity,i);
+ const GROUP* myGroup = myMesh->getGroup(Entity,i);
affiche_support(myGroup);
int NumberOfFamillies = myGroup->getNumberOfFamilies() ;
cout << " - Families ("<<NumberOfFamillies<<") :"<<endl;
cout << "Show Nodes Coordinates : " << endl ;
cout << "Name :" << endl ;
- string * CoordinatesNames = myMesh->getCoordinatesNames() ;
+ const string * CoordinatesNames = myMesh->getCoordinatesNames() ;
for(int i=0; i<SpaceDimension ; i++) {
cout << " - " << CoordinatesNames[i] << endl ;
}
cout << "Unit :" << endl ;
- string * CoordinatesUnits = myMesh->getCoordinatesUnits() ;
+ const string * CoordinatesUnits = myMesh->getCoordinatesUnits() ;
for(int i=0; i<SpaceDimension ; i++) {
cout << " - " << CoordinatesUnits[i] << endl ;
}
}
int NumberOfTypes = myMesh->getNumberOfTypes(MED_CELL) ;
- medGeometryElement * Types = myMesh->getTypes(MED_CELL) ;
+ const medGeometryElement * Types = myMesh->getTypes(MED_CELL) ;
cout << "Show Connectivity (Nodal) :" << endl ;
for (int i=0; i<NumberOfTypes; i++) {
cout << "For type " << Types[i] << " : " << endl ;
int NumberOfElements = myMesh->getNumberOfElements(MED_CELL,Types[i]);
- int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,Types[i]);
+ const int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,Types[i]);
int NomberOfNodesPerCell = Types[i]%100 ;
for (int j=0;j<NumberOfElements;j++){
cout << "Element "<< j+1 <<" : " ;
affiche_groupe(myMesh,MED_EDGE);
cout << "Show Reverse Nodal Connectivity :" << endl ;
- int * ReverseNodalConnectivity = myMesh->getReverseConnectivity(MED_NODAL) ;
- int * ReverseNodalConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_NODAL) ;
+ const int * ReverseNodalConnectivity = myMesh->getReverseConnectivity(MED_NODAL) ;
+ const int * ReverseNodalConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_NODAL) ;
for (int i=0; i<NumberOfNodes; i++) {
cout << "Node "<<i+1<<" : " ;
for (int j=ReverseNodalConnectivityIndex[i];j<ReverseNodalConnectivityIndex[i+1];j++)
cout << "Show Connectivity (Descending) :" << endl ;
int NumberOfElements ;
- int * connectivity ;
- int * connectivity_index ;
+ const int * connectivity ;
+ const int * connectivity_index ;
myMesh->calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL);
try {
NumberOfElements = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS);
}
cout << "Show Reverse Descending Connectivity :" << endl ;
- int * ReverseDescendingConnectivity = myMesh->getReverseConnectivity(MED_DESCENDING) ;
- int * ReverseDescendingConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_DESCENDING) ;
+ const int * ReverseDescendingConnectivity = myMesh->getReverseConnectivity(MED_DESCENDING) ;
+ const int * ReverseDescendingConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_DESCENDING) ;
int NumberOfConstituents = 0;
string constituent ;
}
if (MeshDimension==1) {
- MESSAGE("ERROR : MeshDimension = 1 !");
- MESSAGE("We could not see Reverse Descending Connectivity.") ;
+ INFOS("ERROR : MeshDimension = 1 !");
+ INFOS("We could not see Reverse Descending Connectivity.") ;
} else {
NumberOfConstituents = myMesh->getNumberOfElements (constituentEntity,MED_ALL_ELEMENTS);
for (int i=0; i<NumberOfConstituents; i++) {
}
}
cout << "Show "<<constituent<<" Connectivity (Nodal) :" << endl ;
- int * face_connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,constituentEntity,MED_ALL_ELEMENTS);
- int * face_connectivity_index = myMesh->getConnectivityIndex(MED_NODAL,constituentEntity);
+ const int * face_connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,constituentEntity,MED_ALL_ELEMENTS);
+ const int * face_connectivity_index = myMesh->getConnectivityIndex(MED_NODAL,constituentEntity);
for (int i=0; i<NumberOfConstituents; i++) {
cout << constituent <<i+1<<" : " ;
for (int j=face_connectivity_index[i];j<face_connectivity_index[i+1];j++)
SUPPORT * support1 = (SUPPORT*) NULL;
- FIELD<double>* normal = new FIELD<double>::FIELD();
- FIELD<double>* length = new FIELD<double>::FIELD();
- normal = NULL;
- length = NULL;
+ //FIELD<double>* normal = new FIELD<double>::FIELD();
+ //FIELD<double>* length = new FIELD<double>::FIELD();
+ //normal = NULL;
+ //length = NULL;
string support_name = "Support on all " ;
support_name+=constituent;
support1 = new SUPPORT(myMesh,support_name,constituentEntity);
cout << "Getting the normal of each face of this support !" << endl ;
- normal = myMesh->getNormal(support1);
+ FIELD<double>* normal = myMesh->getNormal(support1);
double normal_square, norm ;
double maxnorm=-infty;
}
cout << "Max Norm " << maxnorm << " Min Norm " << minnorm << endl;
+ delete normal ;
if (SpaceDimension == 2)
{
cout << "Getting the length of each edge !" << endl ;
- length = myMesh->getLength(support1);
+ FIELD<double>* length = myMesh->getLength(support1);
double length_value,maxlength,minlength;
maxlength = -infty;
minlength = dmin(minlength,length_value);
}
cout << "Max Length " << maxlength << " Min Length " << minlength << endl;
+
+ delete length ;
}
+ delete support1 ;
+
cout << "Building of the Support on all space-dimensionned cells of the mesh :"<< endl ;
SUPPORT * support = new SUPPORT(myMesh);
cout << "Getting the barycenter of each element of this support !" << endl ;
- FIELD<double>* barycenter = new FIELD<double>::FIELD();
+ //FIELD<double>* barycenter = new FIELD<double>::FIELD();
- barycenter = myMesh->getBarycenter(support);
+ FIELD<double>* barycenter = myMesh->getBarycenter(support);
NumberOfElements = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS);
for (int i = 1; i<=NumberOfElements;i++)
cout << "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) << endl;
}
- FIELD<double>* volume = new FIELD<double>::FIELD();
- FIELD<double>* area = new FIELD<double>::FIELD();
- volume = NULL;
- area = NULL;
+ delete barycenter ;
+
+ //FIELD<double>* volume = new FIELD<double>::FIELD();
+ //FIELD<double>* area = new FIELD<double>::FIELD();
+ //volume = NULL;
+ //area = NULL;
if (SpaceDimension == 3)
{
cout << "Getting the Volume of each element of this support which is a 3D one !" << endl;
- volume = myMesh->getVolume(support);
+ FIELD<double>* volume = myMesh->getVolume(support);
double maxvol,minvol,voltot;
maxvol = -infty;
cout << "Max Volume " << maxvol << " Min Volume " << minvol << endl;
cout << "Support Volume " << voltot << endl;
+
+ delete volume ;
}
else if (SpaceDimension == 2)
{
cout << "Getting the Area of each element of this support which is a 2D one !" << endl;
- area = myMesh->getArea(support);
+ FIELD<double>* area = myMesh->getArea(support);
// cout << "nb of comp "<< area->getNumberOfComponents() << " length " << area->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS) << endl;
cout << "Max Area " << maxarea << " Min Area " << minarea << endl;
cout << "Support Area " << areatot << endl;
+
+ delete area ;
}
- if (barycenter != NULL) delete barycenter;
- if (volume != NULL ) delete volume;
- if (area != NULL ) delete area;
+ delete support ;
+
+ //if (barycenter != NULL) delete barycenter;
+ //if (volume != NULL ) delete volume;
+ //if (area != NULL ) delete area;
if (argc < 4) return 0;
// cout << value[j]<< " ";
// cout<<endl;
// }
+ MEDARRAY<double> * myvalue = myField->getvalue();
+ const double * value ;
for (int i=1; i<NumberOf+1; i++) {
- double * value = myField->getValueI(MED_FULL_INTERLACE,i) ;
+ value = myvalue->getRow(i) ;
for (int j=0; j<NumberOfComponents; j++)
cout << value[j]<< " ";
cout<<endl;
}
+ cout<<endl;
+
+ delete myField;
+ delete mySupport;
+ delete myMesh ;
return 0;
}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_MEDMEM_Array.cxx
+// Module : MED
+
using namespace std;
#include "utilities.h"
#include "MEDMEM_Array.hxx"
int NumberOfNodes = 4 ;
MEDARRAY<int> * myArray = new MEDARRAY<int>(SpaceDimension,NumberOfNodes,MED_FULL_INTERLACE) ;
- int * value = myArray->get(MED_FULL_INTERLACE) ;
- for (int i=0; i<SpaceDimension*NumberOfNodes; i++)
- value[i]=i ;
+ //const int * value = myArray->get(MED_FULL_INTERLACE) ;
+ for (int i=1; i<=NumberOfNodes; i++)
+ for (int j=1; j<=SpaceDimension; j++)
+ myArray->setIJ(i,j,i) ;
int numberof ;
MESSAGE("Show all 1 :");
numberof = myArray->getLeadingValue() ;
for (int i=1; i<=myArray->getLengthValue() ; i++) {
- int * node = myArray->getI(MED_FULL_INTERLACE,i) ;
+ //int * node = myArray->getI(MED_FULL_INTERLACE,i) ;
+ const int * node = myArray->getRow(i) ;
cout << " - " ;
for (int j=0;j<numberof;j++)
cout << node[j] << " " ;
MESSAGE("Show all 2 :");
numberof = myArray->getLengthValue() ;
for (int i=1; i<=myArray->getLeadingValue() ; i++) {
- int * node = myArray->getI(MED_NO_INTERLACE,i) ;
+ //int * node = myArray->getJ(MED_NO_INTERLACE,i) ;
+ const int * node = myArray->getColumn(i) ;
cout << " - " ;
for (int j=0;j<numberof;j++)
cout << node[j] << " " ;
MESSAGE("Show all 0 :");
numberof = myArray->getLeadingValue() ;
int length = myArray->getLengthValue() ;
- int * NoInterlaceArray = myArray->get(MED_NO_INTERLACE) ;
+ const int * NoInterlaceArray = myArray->get(MED_NO_INTERLACE) ;
for (int i=0; i<length ; i++) {
cout << " - " ;
for (int j=0;j<numberof;j++)
cout << NoInterlaceArray[j*length+i] << " " ;
cout << endl ;
}
+
+ delete myArray ;
+
return 0 ;
}
-
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_MEDMEM_CellModel.cxx
+// Module : MED
+
using namespace std;
#include "utilities.h"
#include "MEDMEM_CellModel.hxx"