From: nri Date: Thu, 10 Jul 2003 17:44:00 +0000 (+0000) Subject: NRI : Merge from V1_2. X-Git-Tag: V1_2_1~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=acef48ebcfef0977499f761d1bcda7d8a68849f2;p=modules%2Fmed.git NRI : Merge from V1_2. --- diff --git a/src/MEDMEM/MEDMEM_Array.hxx b/src/MEDMEM/MEDMEM_Array.hxx index ac7eec814..6d74be7db 100644 --- a/src/MEDMEM/MEDMEM_Array.hxx +++ b/src/MEDMEM/MEDMEM_Array.hxx @@ -1,3 +1,29 @@ +// 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__ @@ -10,452 +36,712 @@ using namespace MED_EN; /*! 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 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 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 _valuesDefault; // in _mode representation - PointerOf _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 _valuesFull; + /*! Pointer to representation in mode MED_NO_INTERLACE */ + PointerOf _valuesNo; + /*! Pointer to representation in mode _mode */ + PointerOf _valuesDefault; + /*! Pointer to representation in the other mode (!=_mode) */ + PointerOf _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 inline MEDARRAY::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 inline MEDARRAY::~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 MEDARRAY::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::MEDARRAY(const med_int, const med_int, const medModeSwitch(= MED_FULL_INTERLACE))"); + BEGIN_OF("constructor MEDARRAY::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::MEDARRAY(const med_int, const med_int, const medModeSwitch) : dimension < 1 !")); + throw MEDEXCEPTION(LOCALIZED("MEDARRAY::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::MEDARRAY(const med_int, const med_int, const medModeSwitch (= MED_FULL_INTERLACE))"); + END_OF("constructor MEDARRAY::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 MEDARRAY::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::MEDARRAY(T* values, const med_int, const med_int, const medModeSwitch)"); -template MEDARRAY::MEDARRAY(MEDARRAY 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::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 inline med_int MEDARRAY::getLeadingValue() const -{ - return _ldValues ; -}; + ASSERT( (T*)_valuesDefault != NULL); + SCRUTE((T*)_valuesDefault); + SCRUTE((T*)_valuesOther); + SCRUTE((T*)_valuesNo); + SCRUTE((T*)_valuesFull); -template inline med_int MEDARRAY::getLengthValue() const -{ - return _lengthValues ; -}; + END_OF("constructor MEDARRAY::MEDARRAY(T* values, const med_int, const med_int, const medModeSwitch)"); +} -template T* const MEDARRAY::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 const & m,bool copyOther). */ +template MEDARRAY::MEDARRAY(MEDARRAY 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::MEDARRAY(MEDARRAY const & m)"); + ASSERT( (T*)_valuesDefault != NULL); + SCRUTE((T*)_valuesDefault); + SCRUTE((T*)_valuesOther); + SCRUTE((T*)_valuesNo); + SCRUTE((T*)_valuesFull); + END_OF("constructor MEDARRAY::MEDARRAY(MEDARRAY const & m)"); } -template T* const MEDARRAY::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 MEDARRAY::MEDARRAY(MEDARRAY 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::MEDARRAY(MEDARRAY 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 MEDARRAY & MEDARRAY::MEDARRAY::operator = (const MEDARRAY & m) +{ + + BEGIN_OF("Operator = MEDARRAY"); + + _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"); + return *this; } +// ------------------ -template T const MEDARRAY::getIJ(const med_int i,const med_int j) const + /*! returns _ldValues. (for example, space dimension for coordinates array)*/ +template inline med_int MEDARRAY::getLeadingValue() const { - // 1<=i<=_lengthValues and 1= 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 inline med_int MEDARRAY::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 const T* MEDARRAY::get(const medModeSwitch mode) +{ + BEGIN_OF("MEDARRAY::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::get(const medModeSwitch mode)"); } -template inline medModeSwitch MEDARRAY::getMode() const -{ - return _mode ; -} +// ------------------ -template void MEDARRAY::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 const T* MEDARRAY::getRow(const med_int i) { - BEGIN_OF("MEDARRAY::set(mode,i,value)"); + BEGIN_OF("MEDARRAY::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::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::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 void MEDARRAY::setI(medModeSwitch mode, med_int i, T* value) +template const T* MEDARRAY::getColumn(const med_int j) { - BEGIN_OF("MEDARRAY::setI(mode,i,value)"); + BEGIN_OF("MEDARRAY::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 const T MEDARRAY::getIJ(const med_int i,const med_int j) const +{ + BEGIN_OF("MEDARRAY::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::getIJ(const med_int i, const med_int j)"); +} + +// ------------------ + + /*! returns the default mode (_mode)/n + (internal use : needed by write method) */ +template inline medModeSwitch MEDARRAY::getMode() const +{ + BEGIN_OF("MEDARRAY::getMode()"); + END_OF("MEDARRAY::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 void MEDARRAY::set(const medModeSwitch mode, const T* value) +// { + +// BEGIN_OF("MEDARRAY::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::set(mode,i,value)"); +// } + +// set with duplication because we don't know were value come and +// MEDARRAY must have properties on it !!!! +template void MEDARRAY::set(const medModeSwitch mode, const T* value) +{ + BEGIN_OF("MEDARRAY::set(mode,value)"); + + _mode = mode; + if ( _mode == MED_FULL_INTERLACE) { - for (int k =0;k::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 void MEDARRAY::setI(const med_int i, const T* value) +{ + BEGIN_OF("MEDARRAY::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 void MEDARRAY::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 void MEDARRAY::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 void MEDARRAY::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 void MEDARRAY::calculateOther() -{ - BEGIN_OF("MEDARRAY::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::calculateOther()") ; } -template void MEDARRAY::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 void MEDARRAY::calculateOther() { - if ((T*)_valuesDefault != NULL) + BEGIN_OF("MEDARRAY::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 void MEDARRAY::updateDefault() -{ - BEGIN_OF("MEDARRAY::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::updateDefault() : No valuesOther defined !"); - } + _valuesOther.set(_ldValues*_lengthValues); + } + if (_mode == MED_NO_INTERLACE) + { + _valuesFull.set((T*)_valuesOther); } else { - throw MEDEXCEPTION("MEDARRAY::updateDefault() : No values defined !"); + ASSERT( _mode==MED_FULL_INTERLACE); + _valuesNo.set((T*)_valuesOther); } - END_OF("MEDARRAY::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::calculateOther()"); } # endif /* # ifndef __MEDARRAY_H__ */ diff --git a/src/MEDMEM/MEDMEM_CellModel.cxx b/src/MEDMEM/MEDMEM_CellModel.cxx index d4c66f958..9ea2b3aec 100644 --- a/src/MEDMEM/MEDMEM_CellModel.cxx +++ b/src/MEDMEM/MEDMEM_CellModel.cxx @@ -1,3 +1,29 @@ +// 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 @@ -39,11 +65,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfVertexes=2; _numberOfNodes=2; // constituent are POINT1 and we have no need to define _constituents vector -// vector vector_type(2,MED_POINT1) ; -// vector __constituents_type[]={vector_type}; -// vector< vector > _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 ; @@ -73,10 +94,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfVertexes=2; _numberOfNodes=3; // constituent are POINT1 and we have no need to define _constituents vector -// vector vector_type(3,MED_POINT1) ; -// vector __constituents_type[]={vector_type}; -// vector< vector > _constituents_type(__constituents_type,__constituents_type+1) ; -// _constituentsType = _constituents_type ; _numberOfConstituentsDimension=1 ; _numberOfConstituents=new int[1] ; _numberOfConstituents[0]=3 ; @@ -139,13 +156,14 @@ CELLMODEL::CELLMODEL(medGeometryElement t) 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 ! @@ -157,17 +175,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _dimension=2; _numberOfVertexes=3; _numberOfNodes=6; -// int _edge1[]={1,2,4} ; -// int _edge2[]={2,3,5} ; -// int _edge3[]={3,1,6} ; -// vector edge1(_edge1,_edge1+3) ; -// vector edge2(_edge2,_edge2+3) ; -// vector edge3(_edge3,_edge3+3) ; -// vector _vector_edge[]={edge1,edge2,edge3}; -// vector< vector > vector_edge(_vector_edge,_vector_edge+3) ; -// vector< vector > __constituents__[]={vector_edge}; -// vector< vector< vector > > _constituents_(__constituents__,__constituents__+1) ; -// _constituents = _constituents_ ; _numberOfConstituentsDimension=1 ; _numberOfConstituents=new int[1] ; _numberOfConstituents[0]=3 ; @@ -195,26 +202,21 @@ CELLMODEL::CELLMODEL(medGeometryElement t) tmpConstituents1[2]=_edge3 ; _constituents = new int**[1] ; _constituents[0]=tmpConstituents1 ; -// vector vector_edge_type(3,MED_SEG3) ; -// vector vector_type(6,MED_POINT1) ; -// vector __constituents_type[]={vector_edge_type,vector_type}; -// vector< vector > _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 ! @@ -226,20 +228,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _dimension=2; _numberOfVertexes=4; _numberOfNodes=4; -// int _edge1[]={1,2} ; -// int _edge2[]={2,3} ; -// int _edge3[]={3,4} ; -// int _edge4[]={4,1} ; -// vector edge1(_edge1,_edge1+2) ; -// vector edge2(_edge2,_edge2+2) ; -// vector edge3(_edge3,_edge3+2) ; -// vector edge4(_edge4,_edge4+2) ; -// vector _vector_edge[]={edge1,edge2,edge3,edge4}; -// vector< vector > vector_edge(_vector_edge,_vector_edge+4) ; -// vector< vector > __constituents__[]={vector_edge}; -// vector< vector< vector > > _constituents_(__constituents__,__constituents__+1) ; -// _constituents = _constituents_ ; - //_constituents={{{1,2},{2,3},{3,4},{4,1}}} ; _numberOfConstituentsDimension=1 ; _numberOfConstituents=new int[1] ; _numberOfConstituents[0]=4 ; @@ -269,25 +257,20 @@ CELLMODEL::CELLMODEL(medGeometryElement t) tmpConstituents1[3]=_edge4 ; _constituents = new int**[1] ; _constituents[0]=tmpConstituents1 ; -// vector vector_edge_type(4,MED_SEG2) ; -// vector vector_type(4,MED_POINT1) ; -// vector __constituents_type[]={vector_edge_type,vector_type}; -// vector< vector > _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 ! @@ -299,20 +282,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _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 edge1(_edge1,_edge1+3) ; -// vector edge2(_edge2,_edge2+3) ; -// vector edge3(_edge3,_edge3+3) ; -// vector edge4(_edge4,_edge4+3) ; -// vector _vector_edge[]={edge1,edge2,edge3,edge4}; -// vector< vector > vector_edge(_vector_edge,_vector_edge+4) ; -// vector< vector > __constituents__[]={vector_edge}; -// vector< vector< vector > > _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 ; @@ -346,29 +315,24 @@ CELLMODEL::CELLMODEL(medGeometryElement t) tmpConstituents1[3]=_edge4 ; _constituents = new int**[1] ; _constituents[0]=tmpConstituents1 ; -// vector vector_edge_type(4,MED_SEG3) ; -// vector vector_type(8,MED_POINT1) ; -// vector __constituents_type[]={vector_edge_type,vector_type}; -// vector< vector > _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 ! @@ -380,34 +344,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _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 edge1(_edge1,_edge1+2) ; -// vector edge2(_edge2,_edge2+2) ; -// vector edge3(_edge3,_edge3+2) ; -// vector edge4(_edge4,_edge4+2) ; -// vector edge5(_edge5,_edge5+2) ; -// vector edge6(_edge6,_edge6+2) ; -// vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6}; -// vector< vector > 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 face1(_face1,_face1+3) ; -// vector face2(_face2,_face2+3) ; -// vector face3(_face3,_face3+3) ; -// vector face4(_face4,_face4+3) ; -// vector _vector_face[] = {face1,face2,face3,face4} ; -// vector< vector > vector_face(_vector_face,_vector_face+4) ; -// vector< vector > __constituents__[]={vector_face,vector_edge}; -// vector< vector< vector > > _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 ; @@ -475,12 +411,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _constituents = new int**[2] ; _constituents[0]=tmpConstituents1 ; _constituents[1]=tmpConstituents2 ; -// vector vector_edge_type(6,MED_SEG2) ; -// vector vector_face_type(4,MED_TRIA3) ; -// vector __constituents_type[]={vector_face_type,vector_edge_type}; -// vector< vector > _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 ; @@ -504,34 +434,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _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 edge1(_edge1,_edge1+3) ; -// vector edge2(_edge2,_edge2+3) ; -// vector edge3(_edge3,_edge3+3) ; -// vector edge4(_edge4,_edge4+3) ; -// vector edge5(_edge5,_edge5+3) ; -// vector edge6(_edge6,_edge6+3) ; -// vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6}; -// vector< vector > 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 face1(_face1,_face1+6) ; -// vector face2(_face2,_face2+6) ; -// vector face3(_face3,_face3+6) ; -// vector face4(_face4,_face4+6) ; -// vector _vector_face[] = {face1,face2,face3,face4} ; -// vector< vector > vector_face(_vector_face,_vector_face+4) ; -// vector< vector > __constituents__[]={vector_face,vector_edge}; -// vector< vector< vector > > _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 ; @@ -617,12 +519,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _constituents = new int**[2] ; _constituents[0]=tmpConstituents1 ; _constituents[1]=tmpConstituents2 ; -// vector vector_edge_type(6,MED_SEG3) ; -// vector vector_face_type(4,MED_TRIA6) ; -// vector __constituents_type[]={vector_face_type,vector_edge_type}; -// vector< vector > _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 ; @@ -646,32 +542,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _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 edge1(_edge1,_edge1+2) ; -// vector edge2(_edge2,_edge2+2) ; -// vector edge3(_edge3,_edge3+2) ; -// vector edge4(_edge4,_edge4+2) ; -// vector edge5(_edge5,_edge5+2) ; -// vector edge6(_edge6,_edge6+2) ; -// vector edge7(_edge7,_edge7+2) ; -// vector edge8(_edge8,_edge8+2) ; -// vector edge9(_edge9,_edge9+2) ; -// vector edge10(_edge10,_edge10+2) ; -// vector edge11(_edge11,_edge11+2) ; -// vector edge12(_edge12,_edge12+2) ; -// vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9,edge10,edge11,edge12}; -// vector< vector > vector_edge(_vector_edge,_vector_edge+12) ; _numberOfConstituentsDimension=2 ; _numberOfConstituents=new int[2] ; _numberOfConstituents[0]=6 ; @@ -734,23 +604,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) 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 face1(_face1,_face1+4) ; -// vector face2(_face2,_face2+4) ; -// vector face3(_face3,_face3+4) ; -// vector face4(_face4,_face4+4) ; -// vector face5(_face5,_face5+4) ; -// vector face6(_face6,_face6+4) ; -// vector _vector_face[] = {face1,face2,face3,face4,face5,face6} ; -// vector< vector > vector_face(_vector_face,_vector_face+6) ; -// vector< vector > __constituents__[]={vector_face,vector_edge}; -// vector< vector< vector > > _constituents_(__constituents__,__constituents__+2) ; -// _constituents = _constituents_ ; int* _face1=new int[4]; _face1[0]=1; _face1[1]=2; @@ -804,11 +657,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _constituents = new int**[2] ; _constituents[0]=tmpConstituents1 ; _constituents[1]=tmpConstituents2 ; -// vector vector_edge_type(12,MED_SEG2) ; -// vector vector_face_type(6,MED_QUAD4) ; -// vector __constituents_type[]={vector_face_type,vector_edge_type}; -// vector< vector > _constituents_type(__constituents_type,__constituents_type+2); -// _constituentsType = _constituents_type ; medGeometryElement * tmpConstituentsType1 = new medGeometryElement[6] ; tmpConstituentsType1[0] = MED_QUAD4 ; tmpConstituentsType1[1] = MED_QUAD4 ; @@ -840,53 +688,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _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 edge1(_edge1,_edge1+3) ; -// vector edge2(_edge2,_edge2+3) ; -// vector edge3(_edge3,_edge3+3) ; -// vector edge4(_edge4,_edge4+3) ; -// vector edge5(_edge5,_edge5+3) ; -// vector edge6(_edge6,_edge6+3) ; -// vector edge7(_edge7,_edge7+3) ; -// vector edge8(_edge8,_edge8+3) ; -// vector edge9(_edge9,_edge9+3) ; -// vector edge10(_edge10,_edge10+3) ; -// vector edge11(_edge11,_edge11+3) ; -// vector edge12(_edge12,_edge12+3) ; -// vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9,edge10, edge11,edge12}; -// vector< vector > 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 face1(_face1,_face1+8); -// vector face2(_face2,_face2+8); -// vector face3(_face3,_face3+8); -// vector face4(_face4,_face4+8); -// vector face5(_face5,_face5+8); -// vector face6(_face6,_face6+8); -// vector _vector_face[]= {face1,face2,face3,face4,face5,face6} ; -// vector< vector > vector_face(_vector_face,_vector_face+6); - -// vector< vector > __constituents__[]={vector_face,vector_edge}; -// vector< vector< vector > > _constituents_(__constituents__,__constituents__+2) ; -// _constituents = _constituents_ ; _numberOfConstituentsDimension=2 ; _numberOfConstituents=new int[2] ; _numberOfConstituents[0]=6 ; @@ -916,11 +717,11 @@ CELLMODEL::CELLMODEL(medGeometryElement t) 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; @@ -1038,11 +839,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _constituents = new int**[2] ; _constituents[0]=tmpConstituents1 ; _constituents[1]=tmpConstituents2 ; -// vector vector_edge_type(12,MED_SEG3) ; -// vector vector_face_type(6,MED_QUAD8) ; -// vector __constituents_type[]={vector_face_type,vector_edge_type}; -// vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; -// _constituentsType = _constituents_type ; medGeometryElement * tmpConstituentsType1 = new medGeometryElement[6] ; tmpConstituentsType1[0] = MED_QUAD8 ; tmpConstituentsType1[1] = MED_QUAD8 ; @@ -1075,44 +871,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _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 edge1(_edge1,_edge1+2) ; -// vector edge2(_edge2,_edge2+2) ; -// vector edge3(_edge3,_edge3+2) ; -// vector edge4(_edge4,_edge4+2) ; -// vector edge5(_edge5,_edge5+2) ; -// vector edge6(_edge6,_edge6+2) ; -// vector edge7(_edge7,_edge7+2) ; -// vector edge8(_edge8,_edge8+2) ; -// vector edge9(_edge9,_edge9+2) ; -// vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9}; -// vector< vector > 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 face1(_face1,_face1+3); -// vector face2(_face2,_face2+3); -// vector face3(_face3,_face3+4); -// vector face4(_face4,_face4+4); -// vector face5(_face5,_face5+4); -// vector _vector_face[]= {face1,face2,face3,face4,face5} ; -// vector< vector > vector_face(_vector_face,_vector_face+5); - -// vector< vector > __constituents__[]={vector_face,vector_edge}; -// vector< vector< vector > > _constituents_(__constituents__,__constituents__+2) ; -// _constituents = _constituents_ ; _numberOfConstituentsDimension=2 ; _numberOfConstituents=new int[2] ; _numberOfConstituents[0]=5 ; @@ -1204,13 +962,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _constituents = new int**[2] ; _constituents[0]=tmpConstituents1 ; _constituents[1]=tmpConstituents2 ; -// vector vector_edge_type(9,MED_SEG2) ; -// vector vector_face_type(5,MED_QUAD4) ; -// vector_face_type[0]=MED_TRIA3 ; -// vector_face_type[1]=MED_TRIA3 ; -// vector __constituents_type[]={vector_face_type,vector_edge_type}; -// vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; -// _constituentsType = _constituents_type ; medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ; tmpConstituentsType1[0] = MED_TRIA3 ; tmpConstituentsType1[1] = MED_TRIA3 ; @@ -1238,44 +989,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _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 edge1(_edge1,_edge1+3) ; -// vector edge2(_edge2,_edge2+3) ; -// vector edge3(_edge3,_edge3+3) ; -// vector edge4(_edge4,_edge4+3) ; -// vector edge5(_edge5,_edge5+3) ; -// vector edge6(_edge6,_edge6+3) ; -// vector edge7(_edge7,_edge7+3) ; -// vector edge8(_edge8,_edge8+3) ; -// vector edge9(_edge9,_edge9+3) ; -// vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9}; -// vector< vector > 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 face1(_face1,_face1+6); -// vector face2(_face2,_face2+6); -// vector face3(_face3,_face3+8); -// vector face4(_face4,_face4+8); -// vector face5(_face5,_face5+8); -// vector _vector_face[]= {face1,face2,face3,face4,face5} ; -// vector< vector > vector_face(_vector_face,_vector_face+5); - -// vector< vector > __constituents__[]={vector_face,vector_edge}; -// vector< vector< vector > > _constituents_(__constituents__,__constituents__+2) ; -// _constituents = _constituents_ ; _numberOfConstituentsDimension=2 ; _numberOfConstituents=new int[2] ; _numberOfConstituents[0]=5 ; @@ -1394,13 +1107,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _constituents = new (int**)[2] ; _constituents[0]=tmpConstituents1 ; _constituents[1]=tmpConstituents2 ; -// vector vector_edge_type(9,MED_SEG3) ; -// vector vector_face_type(5,MED_QUAD8) ; -// vector_face_type[0]=MED_TRIA6 ; -// vector_face_type[1]=MED_TRIA6 ; -// vector __constituents_type[]={vector_face_type,vector_edge_type}; -// vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; -// _constituentsType = _constituents_type ; medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ; tmpConstituentsType1[0] = MED_TRIA6 ; tmpConstituentsType1[1] = MED_TRIA6 ; @@ -1428,42 +1134,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _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 edge1(_edge1,_edge1+2) ; -// vector edge2(_edge2,_edge2+2) ; -// vector edge3(_edge3,_edge3+2) ; -// vector edge4(_edge4,_edge4+2) ; -// vector edge5(_edge5,_edge5+2) ; -// vector edge6(_edge6,_edge6+2) ; -// vector edge7(_edge7,_edge7+2) ; -// vector edge8(_edge8,_edge8+2) ; -// vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8}; -// vector< vector > 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 face1(_face1,_face1+4); -// vector face2(_face2,_face2+3); -// vector face3(_face3,_face3+3); -// vector face4(_face4,_face4+3); -// vector face5(_face5,_face5+3); -// vector _vector_face[]= {face1,face2,face3,face4,face5} ; -// vector< vector > vector_face(_vector_face,_vector_face+5); - -// vector< vector > __constituents__[]={vector_face,vector_edge}; -// vector< vector< vector > > _constituents_(__constituents__,__constituents__+2) ; -// _constituents = _constituents_ ; _numberOfConstituentsDimension=2 ; _numberOfConstituents=new int[2] ; _numberOfConstituents[0]=5 ; @@ -1548,12 +1218,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _constituents = new int**[2] ; _constituents[0]=tmpConstituents1 ; _constituents[1]=tmpConstituents2 ; -// vector vector_edge_type(8,MED_SEG2) ; -// vector vector_face_type(5,MED_TRIA3) ; -// vector_face_type[0]=MED_QUAD4 ; -// vector __constituents_type[]={vector_face_type,vector_edge_type}; -// vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; -// _constituentsType = _constituents_type ; medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ; tmpConstituentsType1[0] = MED_QUAD4 ; tmpConstituentsType1[1] = MED_TRIA3 ; @@ -1580,45 +1244,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _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 edge1(_edge1,_edge1+3) ; -// vector edge2(_edge2,_edge2+3) ; -// vector edge3(_edge3,_edge3+3) ; -// vector edge4(_edge4,_edge4+3) ; -// vector edge5(_edge5,_edge5+3) ; -// vector edge6(_edge6,_edge6+3) ; -// vector edge7(_edge7,_edge7+3) ; -// vector edge8(_edge8,_edge8+3) ; - - -// vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8}; -// vector< vector > 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 face1(_face1,_face1+8); -// vector face2(_face2,_face2+6); -// vector face3(_face3,_face3+6); -// vector face4(_face4,_face4+6); -// vector face5(_face5,_face5+6); -// vector _vector_face[]= {face1,face2,face3,face4,face5} ; -// vector< vector > vector_face(_vector_face,_vector_face+5); - - -// vector< vector > __constituents__[]={vector_face,vector_edge}; -// vector< vector< vector > > _constituents_(__constituents__,__constituents__+2) ; -// _constituents = _constituents_ ; _numberOfConstituentsDimension=2 ; _numberOfConstituents=new int[2] ; _numberOfConstituents[0]=5 ; @@ -1727,13 +1352,6 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _constituents = new int**[2] ; _constituents[0]=tmpConstituents1 ; _constituents[1]=tmpConstituents2 ; -// vector vector_edge_type(8,MED_SEG3) ; -// vector vector_face_type(5,MED_TRIA6) ; -// vector_face_type[0]=MED_QUAD8 ; -// vector __constituents_type[]={vector_face_type,vector_edge_type}; -// vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; - -// _constituentsType = _constituents_type ; medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ; tmpConstituentsType1[0] = MED_QUAD8 ; tmpConstituentsType1[1] = MED_TRIA6 ; diff --git a/src/MEDMEM/MEDMEM_Connectivity.hxx b/src/MEDMEM/MEDMEM_Connectivity.hxx index 904670e26..9986a2350 100644 --- a/src/MEDMEM/MEDMEM_Connectivity.hxx +++ b/src/MEDMEM/MEDMEM_Connectivity.hxx @@ -1,3 +1,29 @@ +// 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 @@ -14,37 +40,38 @@ class CELLMODEL; 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 @@ -55,205 +82,272 @@ protected: ( 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 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 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 types existing in the specified entity. - +/*! Returns the number of different 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 = "< 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 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="<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 */ diff --git a/src/MEDMEM/MEDMEM_Exception.cxx b/src/MEDMEM/MEDMEM_Exception.cxx index 7f37110a4..915f4fc75 100644 --- a/src/MEDMEM/MEDMEM_Exception.cxx +++ b/src/MEDMEM/MEDMEM_Exception.cxx @@ -1,3 +1,29 @@ +// 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 @@ -17,8 +43,11 @@ extern "C" } +/*! + \internal + Function used to duplicate char * +*/ const char* duplicate( const char *const str ) ; - const char* duplicate( const char *const str ) { ASSERT(str!=NULL) ; @@ -30,14 +59,25 @@ const char* duplicate( const char *const str ) 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 ; @@ -48,7 +88,7 @@ const char *makeText( const char *text, const char *fileName, const unsigned int const size_t l0 = strlen(prefix) ; if ( fileName ) - { + { const size_t l2 = strlen(fileName) ; ASSERT(lineNumber>=1) ; @@ -59,24 +99,38 @@ const char *makeText( const char *text, const char *fileName, const unsigned int 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 ) { @@ -88,22 +142,33 @@ MEDEXCEPTION::~MEDEXCEPTION() throw () } - +/*! + 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 ; } diff --git a/src/MEDMEM/MEDMEM_Family.cxx b/src/MEDMEM/MEDMEM_Family.cxx index 22ff834e5..a8f0a02e8 100644 --- a/src/MEDMEM/MEDMEM_Family.cxx +++ b/src/MEDMEM/MEDMEM_Family.cxx @@ -1,3 +1,29 @@ +// 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 @@ -16,16 +42,25 @@ FAMILY::FAMILY():_identifier(0), _numberOfAttribute(0), 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) : "< of node numbers 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; i0) { 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 in order to create // ?? the list of node numbers 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; i0) {// we have found some cells - numberOfCellsInFamily[numberOfCellTypesInFamily]=NumberOfCellsInThisFamily; - int * CellsList=new int[NumberOfCellsInThisFamily] ; - - for (int i=0;i0) { // 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; igetNumberOfElements(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]; jexistConnectivity(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; FaceTypeNumbergetNumberOfElements(MED_FACE,FacesType[FaceTypeNumber]) ; - int NumberOfFacesInThisFamily = 0 ; - int * FaceOfThisFamilyNumber = FaceFamilyNumber[FaceTypeNumber]; - int * tmp_FacesList = new int[NumberOfThisFaces]; - for (int i=0; i0) {// we have found some faces - NumberOfFacesInFamily[NumberOfFacesTypeInFamily]=NumberOfFacesInThisFamily; - int * FacesList=new int[NumberOfFacesInThisFamily] ; - for (int i=0;i0) { // 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; igetNumberOfElements(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]; jexistConnectivity(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; EdgeTypeNumbergetNumberOfElements(MED_EDGE,EdgesType[EdgeTypeNumber]) ; - int NumberOfEdgesInThisFamily = 0 ; - int * EdgeOfThisFamilyNumber = EdgeFamilyNumber[EdgeTypeNumber]; - int * tmp_EdgesList = new int[NumberOfThisEdges]; - for (int i=0; i0) {// we have found some edges - NumberOfEdgesInFamily[NumberOfEdgesTypeInFamily]=NumberOfEdgesInThisFamily; - int * EdgesList=new int[NumberOfEdgesInThisFamily] ; - for (int i=0;i0) { // 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; igetNumberOfElements(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 + 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; i0) {// 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; igetNumberOfElements(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]; jgetNumberOfElements(MED_ALL_ELEMENTS); _componentsTypes = new int[NumberOfComponents] ; _componentsNames = new string[NumberOfComponents]; _componentsDescriptions = new string[NumberOfComponents]; @@ -35,10 +64,12 @@ FIELD_::FIELD_(const SUPPORT * Support, const int 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) { @@ -70,6 +101,8 @@ FIELD_::FIELD_(const FIELD_ &m) _time = m._time; _orderNumber = m._orderNumber; _valueType = m._valueType; + //_drivers = m._drivers ; // PG : Well, same driver, what about m destructor ! + } FIELD_::~FIELD_() @@ -85,19 +118,39 @@ FIELD_::~FIELD_() delete[] _componentsUnits ; if ( _MEDComponentsUnits !=NULL) delete[] _MEDComponentsUnits ; + + // delete driver +// vector::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() {}; diff --git a/src/MEDMEM/MEDMEM_GenDriver.cxx b/src/MEDMEM/MEDMEM_GenDriver.cxx index 7e9d4d3fb..fe62e3980 100644 --- a/src/MEDMEM/MEDMEM_GenDriver.cxx +++ b/src/MEDMEM/MEDMEM_GenDriver.cxx @@ -1,3 +1,29 @@ +// 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" @@ -16,9 +42,15 @@ GENDRIVER::GENDRIVER(const string & fileName, _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() {} @@ -131,7 +163,7 @@ bool GENDRIVER::operator ==(const GENDRIVER &genDriver) const { const char * LOC = "bool GENDRIVER::operator ==(const GENDRIVER &genDriver) const : "; - BEGIN_OF(LOC); + MESSAGE(LOC); return ( _id == genDriver._id ) && ( _driverType == genDriver._driverType ); diff --git a/src/MEDMEM/MEDMEM_MedMedDriver.cxx b/src/MEDMEM/MEDMEM_MedMedDriver.cxx index af4394bdb..6b7d09332 100644 --- a/src/MEDMEM/MEDMEM_MedMedDriver.cxx +++ b/src/MEDMEM/MEDMEM_MedMedDriver.cxx @@ -1,3 +1,29 @@ +// 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 @@ -6,6 +32,7 @@ using namespace std; # 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" @@ -22,7 +49,7 @@ MED_MED_DRIVER::MED_MED_DRIVER(): GENDRIVER(), 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, @@ -33,26 +60,61 @@ 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) @@ -60,9 +122,12 @@ void MED_MED_DRIVER::open() { ) ); + MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode); _medIdt = MEDouvrir( (const_cast (_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; @@ -72,45 +137,74 @@ void MED_MED_DRIVER::open() { ) ); } - + 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; @@ -137,6 +231,16 @@ void MED_MED_DRIVER::readFileStruct( void ) 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°" @@ -145,17 +249,54 @@ void MED_MED_DRIVER::readFileStruct( void ) ); MESSAGE(LOC<<": Mesh n°"<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 "<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 ; } } } @@ -316,7 +457,21 @@ void MED_MED_DRIVER::readFileStruct( void ) ((FIELD*) ptrField)->setNumberOfComponents(numberOfComponents); ((FIELD*) ptrField)->setName(fieldName) ; //provisoire, pour debug MESSAGE("#### SET NAME in FIELD : "< (_fileName, (FIELD *) ptrField); + + MED_EN::med_mode_acces myMode = getAccessMode(); + switch (myMode) { + case MED_EN::MED_LECT: + ptrDriver = new MED_FIELD_RDONLY_DRIVER(_fileName, (FIELD *)ptrField); + break ; + case MED_EN::MED_REMP: + ptrDriver = new MED_FIELD_RDWR_DRIVER(_fileName, (FIELD *)ptrField); + break ; + case MED_EN::MED_ECRI: // should never append !! + ptrDriver = new MED_FIELD_RDONLY_DRIVER(_fileName, (FIELD *)ptrField); + break; + default: + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !")); + } break; } case MED_FR::MED_REEL64 : { @@ -327,7 +482,20 @@ void MED_MED_DRIVER::readFileStruct( void ) ((FIELD*) ptrField)->setName(fieldName) ; //provisoire, pour debug MESSAGE("#### SET NAME in FIELD : "<(_fileName, (FIELD *) ptrField); + MED_EN::med_mode_acces myMode = getAccessMode(); + switch (myMode) { + case MED_EN::MED_LECT: + ptrDriver = new MED_FIELD_RDONLY_DRIVER(_fileName, (FIELD *)ptrField); + break ; + case MED_EN::MED_REMP: + ptrDriver = new MED_FIELD_RDWR_DRIVER(_fileName, (FIELD *)ptrField); + break ; + case MED_EN::MED_ECRI: // should never append !! + ptrDriver = new MED_FIELD_RDONLY_DRIVER(_fileName, (FIELD *)ptrField); + break; + default: + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !")); + } break; } default : { @@ -356,7 +524,9 @@ void MED_MED_DRIVER::readFileStruct( void ) MESSAGE("###### ptrDriver->setFieldName : #"<setFieldName(fieldName); ptrField->addDriver(*ptrDriver); - + // driver is duplicated : remove it + delete ptrDriver; + DT_IT_ dtIt; dtIt.dt = timeStepNumber; dtIt.it = orderNumber; @@ -383,11 +553,13 @@ void MED_MED_DRIVER::readFileStruct( void ) // 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 & _meshes = const_cast& > (_ptrMed->_meshes); map::const_iterator currentMesh; @@ -396,17 +568,71 @@ void MED_MED_DRIVER::read( void ) { 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); @@ -420,11 +646,11 @@ void MED_MED_DRIVER::writeFrom( void) const { 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++ ) { @@ -440,8 +666,9 @@ void MED_MED_DRIVER::writeFrom( void) const { } -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; @@ -456,114 +683,77 @@ void MED_MED_DRIVER::write(void ) const { map::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"); diff --git a/src/MEDMEM/MEDMEM_Mesh.cxx b/src/MEDMEM/MEDMEM_Mesh.cxx index e1d079547..94e9a0533 100644 --- a/src/MEDMEM/MEDMEM_Mesh.cxx +++ b/src/MEDMEM/MEDMEM_Mesh.cxx @@ -1,3 +1,29 @@ +// 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 @@ -9,13 +35,17 @@ using namespace std; #include #include +#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) ; @@ -25,8 +55,12 @@ using namespace std; // MESH::INSTANCE_DE 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 MESH::inst_med ; -const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med } ; +MESH::INSTANCE_DE 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 . The meshname used in the file is . addDriver returns an int handler. */ @@ -57,9 +91,11 @@ int MESH::addDriver(MED_MESH_DRIVER & driver) { 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); } @@ -89,17 +125,12 @@ void MESH::rmDriver (int index/*=0*/) { 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; @@ -117,58 +148,146 @@ void MESH::init() { _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; isetMesh(this); + } + + _numberOfCellsFamilies = m._numberOfCellsFamilies; + _familyCell = m._familyCell; + for (int i=0; isetMesh(this); + } + + _numberOfFacesFamilies = m._numberOfFacesFamilies; + _familyFace = m._familyFace; + for (int i=0; isetMesh(this); + } + + _numberOfEdgesFamilies = m._numberOfEdgesFamilies; + _familyEdge = m._familyEdge; + for (int i=0; isetMesh(this); + } + + _numberOfNodesGroups = m._numberOfNodesGroups; + _groupNode = m._groupNode; + for (int i=0; isetMesh(this); + } + + _numberOfCellsGroups = m._numberOfCellsGroups; + _groupCell = m._groupCell; + for (int i=0; isetMesh(this); + } + + _numberOfFacesGroups = m._numberOfFacesGroups; + _groupFace = m._groupFace; + for (int i=0; isetMesh(this); + } + + _numberOfEdgesGroups = m._numberOfEdgesGroups; + _groupEdge = m._groupEdge; + for (int i=0; isetMesh(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;igetAccessMode() ) { - 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); }; @@ -247,56 +373,117 @@ MESH::MESH(driverTypes driverType, const string & fileName/*=""*/, const string 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 nodes_Families = myMesh.get_nodes_Families() ; -// for(int i=0;i cells_Families = myMesh.get_cells_Families() ; -// for(int i=0;iexistConnectivity(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;jsetAll(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 myElementsList ; int size = 0 ; - SCRUTE(numberOf) ; for (int i=0 ; i::iterator myElementsListIt ; for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) { myListArray[id]=(*myElementsListIt) ; - SCRUTE(id); - SCRUTE(myListArray[id]); id ++ ; } @@ -415,22 +598,22 @@ SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION) 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 ; @@ -446,10 +629,10 @@ SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION) } 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 ; @@ -458,53 +641,64 @@ SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION) 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* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) +FIELD* 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); @@ -512,9 +706,7 @@ FIELD* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) } int index; - FIELD* Volume; - - Volume = new FIELD::FIELD(Support,1); + FIELD* Volume = new FIELD::FIELD(Support,1); // double *volume = new double [length_values]; Volume->setName("VOLUME"); Volume->setDescription("cells volume"); @@ -533,9 +725,10 @@ FIELD* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) Volume->setOrderNumber(0); Volume->setTime(0.0); - double *volume = Volume->getValue(MED_FULL_INTERLACE); + //const double *volume = Volume->getValue(MED_FULL_INTERLACE); + MEDARRAY *volume = Volume->getvalue(); - index = 0; + index = 1; const double * coord = getCoordinates(MED_FULL_INTERLACE); for (int i=0;i* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) } 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_typegetNumberOfElements(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* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) (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; @@ -639,7 +836,8 @@ FIELD* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) (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; @@ -710,7 +908,8 @@ FIELD* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) 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; @@ -876,13 +1075,14 @@ FIELD* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) 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; } } @@ -890,34 +1090,36 @@ FIELD* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) return Volume; } -FIELD* MESH::getArea(const SUPPORT * Support) throw (MEDEXCEPTION) +FIELD* 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); @@ -964,18 +1166,23 @@ FIELD* MESH::getArea(const SUPPORT * Support) throw (MEDEXCEPTION) } 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* MESH::getArea(const SUPPORT * Support) throw (MEDEXCEPTION) 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* MESH::getLength(const SUPPORT * Support) throw (MEDEXCEPTION) +FIELD* 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); @@ -1130,10 +1339,11 @@ FIELD* MESH::getLength(const SUPPORT * Support) throw (MEDEXCEPTION) // 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 * length = Length->getvalue(); const double * coord = getCoordinates(MED_FULL_INTERLACE); - index = 0; + index = 1; for (int i=0;i* MESH::getLength(const SUPPORT * Support) throw (MEDEXCEPTION) } 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_typegetNumber(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* MESH::getLength(const SUPPORT * Support) throw (MEDEXCEPTION) 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; } } @@ -1198,34 +1411,36 @@ FIELD* MESH::getLength(const SUPPORT * Support) throw (MEDEXCEPTION) return Length; } -FIELD* MESH::getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) +FIELD* 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); @@ -1237,17 +1452,16 @@ FIELD* MESH::getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) FIELD* Normal = new FIELD::FIELD(Support,dim_space); Normal->setName("NORMAL"); Normal->setDescription("cells or faces normal"); - for (int k=0;ksetComponentName(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]; @@ -1268,7 +1482,7 @@ FIELD* MESH::getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) (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 ; @@ -1279,18 +1493,22 @@ FIELD* MESH::getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) } 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_typegetNumber(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* MESH::getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) 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* MESH::getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION) +FIELD* 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); @@ -1499,18 +1721,20 @@ FIELD* MESH::getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION) } 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_typegetNumberOfElements(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* MESH::getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION) 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 myElementsList ; + int i,j, size = 0 ; + + calculateConnectivity(MED_FULL_INTERLACE, MED_DESCENDING, MED_CELL); + if (Support3D->isOnAllElements()) + { + int * myConnectivityValue = const_cast (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 FaceNbEncounterNb; + + int * myConnectivityValue = const_cast + (getConnectivity(MED_FULL_INTERLACE, MED_DESCENDING, + MED_CELL, MED_ALL_ELEMENTS)); + int * myConnectivityIndex = const_cast (getConnectivityIndex(MED_DESCENDING, MED_CELL)); + int * myCellNbs = const_cast (Support3D->getnumber()->getValue()); + int nbCells = Support3D->getnumber()->getLength(); + for (i=0; i::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::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 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::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 ; + +} diff --git a/src/MEDMEM/MEDMEM_Mesh.hxx b/src/MEDMEM/MEDMEM_Mesh.hxx index 75acb39f7..3791a074b 100644 --- a/src/MEDMEM/MEDMEM_Mesh.hxx +++ b/src/MEDMEM/MEDMEM_Mesh.hxx @@ -1,3 +1,29 @@ +// 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 @@ -13,13 +39,15 @@ #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 FIELD; @@ -29,17 +57,17 @@ template 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 @@ -50,25 +78,27 @@ public : // ------- Drivers Management Part protected: - + //-----------------------// - class INSTANCE + class INSTANCE //-----------------------// { public: virtual GENDRIVER * run(const string & fileName, MESH * ptrMesh) const = 0 ; } ; - + //-------------------------------------------------------// - template class INSTANCE_DE : public INSTANCE + template 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 inst_med ; + + // Add a similar line for your personnal driver (step 3) + static INSTANCE_DE inst_med ; + static INSTANCE_DE inst_gibi ; //static INSTANCE_DE inst_vtk ; static const INSTANCE * const instances[] ; @@ -83,15 +113,6 @@ protected : 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; @@ -100,61 +121,71 @@ protected : int _numberOfNodes ; int _numberOfNodesFamilies; //INUTILE ? -> _familyNode.size() - vector _familyNode ; // array of size _numberOfNodesFamilies; + vector _familyNode ; // array of size _numberOfNodesFamilies; int _numberOfCellsFamilies; - vector _familyCell ; // array of size _numberOfCellsFamilies; + vector _familyCell ; // array of size _numberOfCellsFamilies; int _numberOfFacesFamilies; - vector _familyFace ; // array of size _numberOfFacesFamilies; + vector _familyFace ; // array of size _numberOfFacesFamilies; int _numberOfEdgesFamilies; vector _familyEdge ; // array of size _numberOfEdgesFamilies; int _numberOfNodesGroups; //INUTILE ? - vector _groupNode; // array of size _numberOfNodesGroups; + vector _groupNode; // array of size _numberOfNodesGroups; int _numberOfCellsGroups; //INUTILE ? - vector _groupCell; // array of size _numberOfCellsGroups; + vector _groupCell; // array of size _numberOfCellsGroups; int _numberOfFacesGroups; //INUTILE ? - vector _groupFace; // array of size _numberOfFacesGroups; + vector _groupFace; // array of size _numberOfFacesGroups; int _numberOfEdgesGroups; //INUTILE ? - vector _groupEdge; // array of size _numberOfEdgesGroups; + vector _groupEdge; // array of size _numberOfEdgesGroups; // list of all Group vector _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 @@ -163,114 +194,140 @@ public : 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 getFamilies(medEntityMesh Entity); - inline FAMILY* getFamily(medEntityMesh Entity,int i); - inline int getNumberOfGroups(medEntityMesh Entity); - inline vector 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 getFamilies(medEntityMesh Entity) const ; + inline const FAMILY* getFamily(medEntityMesh Entity,int i) const ; + inline int getNumberOfGroups(medEntityMesh Entity) const ; + inline const vector 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* getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 3D elements - FIELD* getArea(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 2D elements - FIELD* getLength(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 1D elements - FIELD* getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 2D elements - FIELD* getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION) ; - // FIELD* getNeighbourhood(SUPPORT * Support) throw (MEDEXCEPTION) ; // Il faut preciser ! + FIELD* getVolume(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 3D elements + FIELD* getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 2D elements + FIELD* getLength(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 1D elements + FIELD* getNormal(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 2D elements + FIELD* getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION) ; + // FIELD* 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 */ -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. @@ -292,66 +349,69 @@ inline void MESH::read(const MED_MED_DRIVER & genDriver) } /*! 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(); } @@ -359,18 +419,19 @@ inline string * MESH::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 @@ -378,61 +439,65 @@ inline string * MESH::getCoordinatesUnits() 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) : "<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 !")); } /*! @@ -441,12 +506,12 @@ inline int * MESH::getGlobalNumberingIndex(medEntityMesh entity) 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) @@ -454,20 +519,24 @@ inline int MESH::getNumberOfElements(medEntityMesh entity, medGeometryElement Ty 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) ; @@ -477,51 +546,55 @@ inline bool MESH::existConnectivity(medConnectivity connectivityType, medEntityM 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) ; } /*! @@ -531,11 +604,12 @@ inline int * MESH::getConnectivityIndex(medConnectivity ConnectivityType,medEnti 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) ; } /*! @@ -543,28 +617,29 @@ inline int * MESH::getReverseConnectivity(medConnectivity ConnectivityType,medEn 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 ; @@ -574,12 +649,12 @@ inline int MESH::getNumberOfFamilies (medEntityMesh entity) 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 ; @@ -589,11 +664,12 @@ inline int MESH::getNumberOfGroups (medEntityMesh entity) throw MEDEXCEPTION("MESH::getNumberOfGroups : Unknown entity"); } } -vector MESH::getFamilies(medEntityMesh entity) { +const vector 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 ; @@ -604,11 +680,12 @@ vector MESH::getFamilies(medEntityMesh entity) { } } -vector MESH::getGroups(medEntityMesh entity) { +const vector 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 ; @@ -619,8 +696,9 @@ vector MESH::getGroups(medEntityMesh entity) { } } -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 ; @@ -648,14 +726,15 @@ FAMILY* MESH::getFamily(medEntityMesh entity, int i) { 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 ; @@ -683,9 +762,9 @@ GROUP* MESH::getGroup(medEntityMesh entity, int i) { default : throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Unknown entity")); } - if (i>NumberOfGroups) + if (i>NumberOfGroups) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"argument i="< _index ; // array of size _count+1 : _index[0]=1 and + PointerOf _index ; // array of size _count+1 : _index[0]=1 and // _index[_count]=length+1 PointerOf _value ; // array of size _length @@ -21,18 +47,26 @@ public : 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) ; + } ; // --------------------------------------- @@ -46,13 +80,13 @@ inline med_int MEDSKYLINEARRAY::getLength() const { 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) { @@ -62,16 +96,16 @@ 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) @@ -83,5 +117,54 @@ inline med_int MEDSKYLINEARRAY::getIJ(int i, int j) const throw (MEDEXCEPTION) 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 diff --git a/src/MEDMEM/MEDMEM_Support.hxx b/src/MEDMEM/MEDMEM_Support.hxx index c90a01ce2..ce3b2ebbb 100644 --- a/src/MEDMEM/MEDMEM_Support.hxx +++ b/src/MEDMEM/MEDMEM_Support.hxx @@ -1,6 +1,32 @@ +// 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 @@ -10,221 +36,272 @@ #include #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) @@ -233,14 +310,16 @@ throw (MEDEXCEPTION) 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) { @@ -251,183 +330,236 @@ throw (MEDEXCEPTION) } 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 - types used by the support. +/*! + If isOnAllElements is false, returns an array of + types used by the support. - is given by getEntity. */ + 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; } //--------------------------------------------------- @@ -439,8 +571,8 @@ inline medGeometryElement * SUPPORT::getTypes() const // 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 */ diff --git a/src/MEDMEM/MEDMEM_Unit.hxx b/src/MEDMEM/MEDMEM_Unit.hxx index 81a24f860..62f885760 100644 --- a/src/MEDMEM/MEDMEM_Unit.hxx +++ b/src/MEDMEM/MEDMEM_Unit.hxx @@ -1,3 +1,29 @@ +// 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$ diff --git a/src/MEDMEM/Makefile.in b/src/MEDMEM/Makefile.in index 3e7bf88f4..f1000048e 100644 --- a/src/MEDMEM/Makefile.in +++ b/src/MEDMEM/Makefile.in @@ -1,14 +1,34 @@ -#============================================================================== -# 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 @@ -35,13 +55,16 @@ MEDMEM_MedFieldDriver.hxx \ 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 @@ -60,22 +83,23 @@ MEDMEM_Med.cxx \ 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) @@ -84,9 +108,9 @@ CXXFLAGS+=-ftemplate-depth-42 -I${KERNEL_ROOT_DIR}/include/salome 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@ diff --git a/src/MEDMEM/duplicateMEDMESH.cxx b/src/MEDMEM/duplicateMEDMESH.cxx index e30383ce5..c2615b099 100644 --- a/src/MEDMEM/duplicateMEDMESH.cxx +++ b/src/MEDMEM/duplicateMEDMESH.cxx @@ -1,3 +1,29 @@ +// 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 #include @@ -20,7 +46,7 @@ int main (int argc, char ** argv) { 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 { diff --git a/src/MEDMEM/med_test.cxx b/src/MEDMEM/med_test.cxx index 9fbf88a8a..5090890bc 100644 --- a/src/MEDMEM/med_test.cxx +++ b/src/MEDMEM/med_test.cxx @@ -1,3 +1,29 @@ +// 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 @@ -22,7 +48,7 @@ double dmin(double x, double y) { return (x>y)?y:x;} double infty = 1.e20; -void affiche_support(SUPPORT * mySupport) +void affiche_support(const SUPPORT * mySupport) { cout << " - Name : "<getName().c_str()<getDescription().c_str()<isOnAllElements())) { int NumberOfTypes = mySupport->getNumberOfTypes() ; cout<<" - NumberOfTypes : "<getTypes() ; + const medGeometryElement * Types = mySupport->getTypes() ; for (int j=0;jgetNumberOfElements(Types[j]) ; - int * Number = mySupport->getNumber(Types[j]) ; + const int * Number = mySupport->getNumber(Types[j]) ; for (int k=0; kgetNumberOfFamilies(Entity) ; cout << "NumberOfFamilies : "<getFamily(Entity,i); + const FAMILY* myFamily = myMesh->getFamily(Entity,i); affiche_support(myFamily); cout << " - Identifier : "<getIdentifier()<getNumberOfAttributes() ; @@ -69,7 +95,7 @@ void affiche_groupe(MESH *myMesh,medEntityMesh Entity) int NumberOfGroups = myMesh->getNumberOfGroups(Entity) ; cout << "NumberOfGroups : "<getGroup(Entity,i); + const GROUP* myGroup = myMesh->getGroup(Entity,i); affiche_support(myGroup); int NumberOfFamillies = myGroup->getNumberOfFamilies() ; cout << " - Families ("<getCoordinatesNames() ; + const string * CoordinatesNames = myMesh->getCoordinatesNames() ; for(int i=0; igetCoordinatesUnits() ; + const string * CoordinatesUnits = myMesh->getCoordinatesUnits() ; for(int i=0; igetNumberOfTypes(MED_CELL) ; - medGeometryElement * Types = myMesh->getTypes(MED_CELL) ; + const medGeometryElement * Types = myMesh->getTypes(MED_CELL) ; cout << "Show Connectivity (Nodal) :" << endl ; for (int i=0; igetNumberOfElements(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;jgetReverseConnectivity(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; icalculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL); try { NumberOfElements = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); @@ -194,8 +220,8 @@ int main (int argc, char ** argv) { } 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 ; @@ -212,8 +238,8 @@ int main (int argc, char ** argv) { } 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; igetConnectivity(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* normal = new FIELD::FIELD(); - FIELD* length = new FIELD::FIELD(); - normal = NULL; - length = NULL; + //FIELD* normal = new FIELD::FIELD(); + //FIELD* length = new FIELD::FIELD(); + //normal = NULL; + //length = NULL; string support_name = "Support on all " ; support_name+=constituent; support1 = new SUPPORT(myMesh,support_name,constituentEntity); @@ -249,7 +275,7 @@ int main (int argc, char ** argv) { cout << "Getting the normal of each face of this support !" << endl ; - normal = myMesh->getNormal(support1); + FIELD* normal = myMesh->getNormal(support1); double normal_square, norm ; double maxnorm=-infty; @@ -270,12 +296,13 @@ int main (int argc, char ** argv) { } 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* length = myMesh->getLength(support1); double length_value,maxlength,minlength; maxlength = -infty; @@ -288,16 +315,20 @@ int main (int argc, char ** argv) { 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* barycenter = new FIELD::FIELD(); + //FIELD* barycenter = new FIELD::FIELD(); - barycenter = myMesh->getBarycenter(support); + FIELD* barycenter = myMesh->getBarycenter(support); NumberOfElements = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); for (int i = 1; i<=NumberOfElements;i++) @@ -309,16 +340,18 @@ int main (int argc, char ** argv) { cout << "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) << endl; } - FIELD* volume = new FIELD::FIELD(); - FIELD* area = new FIELD::FIELD(); - volume = NULL; - area = NULL; + delete barycenter ; + + //FIELD* volume = new FIELD::FIELD(); + //FIELD* area = new FIELD::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* volume = myMesh->getVolume(support); double maxvol,minvol,voltot; maxvol = -infty; @@ -334,12 +367,14 @@ int main (int argc, char ** argv) { 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* area = myMesh->getArea(support); // cout << "nb of comp "<< area->getNumberOfComponents() << " length " << area->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS) << endl; @@ -357,11 +392,15 @@ int main (int argc, char ** argv) { 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; @@ -421,13 +460,20 @@ int main (int argc, char ** argv) { // cout << value[j]<< " "; // cout< * myvalue = myField->getvalue(); + const double * value ; for (int i=1; igetValueI(MED_FULL_INTERLACE,i) ; + value = myvalue->getRow(i) ; for (int j=0; j * myArray = new MEDARRAY(SpaceDimension,NumberOfNodes,MED_FULL_INTERLACE) ; - int * value = myArray->get(MED_FULL_INTERLACE) ; - for (int i=0; iget(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;jgetLengthValue() ; 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;jgetLeadingValue() ; int length = myArray->getLengthValue() ; - int * NoInterlaceArray = myArray->get(MED_NO_INTERLACE) ; + const int * NoInterlaceArray = myArray->get(MED_NO_INTERLACE) ; for (int i=0; i