From e399635972a2ba008a8ea73cc170e304783cae32 Mon Sep 17 00:00:00 2001 From: nri Date: Thu, 10 Jul 2003 17:30:50 +0000 Subject: [PATCH] NRI : Merge from V1_2. --- src/MEDMEM/MEDMEM_Connectivity.cxx | 825 +++++++++++------- src/MEDMEM/MEDMEM_Coordinate.hxx | 109 ++- src/MEDMEM/MEDMEM_DriversDef.cxx | 33 +- src/MEDMEM/MEDMEM_Family.hxx | 146 +++- src/MEDMEM/MEDMEM_Field.hxx | 1062 +++++++++++++++++------ src/MEDMEM/MEDMEM_Group.hxx | 60 +- src/MEDMEM/MEDMEM_Med.hxx | 100 ++- src/MEDMEM/MEDMEM_MedMeshDriver.hxx | 279 ++++-- src/MEDMEM/MEDMEM_STRING.hxx | 114 ++- src/MEDMEM/MEDMEM_SkyLineArray.cxx | 60 +- src/MEDMEM/MEDMEM_Support.cxx | 428 ++++++--- src/MEDMEM/MEDMEM_Unit.cxx | 26 + src/MEDMEM/MEDMEM_VtkMedDriver.cxx | 388 ++++++--- src/MEDMEM/test_MEDMEM_SkyLineArray.cxx | 48 +- 14 files changed, 2619 insertions(+), 1059 deletions(-) diff --git a/src/MEDMEM/MEDMEM_Connectivity.cxx b/src/MEDMEM/MEDMEM_Connectivity.cxx index 8c8b87225..ca443761f 100644 --- a/src/MEDMEM/MEDMEM_Connectivity.cxx +++ b/src/MEDMEM/MEDMEM_Connectivity.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_Connectivity.cxx +// Module : MED + using namespace std; #include "MEDMEM_Connectivity.hxx" #include "MEDMEM_Family.hxx" @@ -8,118 +34,251 @@ using namespace std; #include "MEDMEM_STRING.hxx" -//------------------------------------------------------// -CONNECTIVITY::CONNECTIVITY(medEntityMesh Entity/*=MED_CELL*/): -//------------------------------------------------------// - _entity(Entity), - _typeConnectivity(MED_NODAL), - _numberOfTypes(0), - _geometricTypes((medGeometryElement*)NULL), - _type((CELLMODEL*)NULL), - _entityDimension(0), - _count((int*)NULL), - _nodal((MEDSKYLINEARRAY*)NULL), - _descending((MEDSKYLINEARRAY*)NULL), - _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL), - _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL), - _neighbourhood((MEDSKYLINEARRAY*)NULL), - _constituent((CONNECTIVITY*)NULL) +/*! + Default Constructor. /n + Default for Entity is MED_CELL and type of Connectivity is MED_NODAL */ +//--------------------------------------------------------------// +CONNECTIVITY::CONNECTIVITY(medEntityMesh Entity /* =MED_CELL */) : +//--------------------------------------------------------------// + _entity(Entity), + _typeConnectivity(MED_NODAL), + _numberOfTypes(0), + _geometricTypes((medGeometryElement*)NULL), + _type((CELLMODEL*)NULL), + _entityDimension(0), + _count((int*)NULL), + _nodal((MEDSKYLINEARRAY*)NULL), + _descending((MEDSKYLINEARRAY*)NULL), + _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL), + _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL), + _neighbourhood((MEDSKYLINEARRAY*)NULL), + _constituent((CONNECTIVITY*)NULL) { - MESSAGE("CONNECTIVITY(medEntityMesh Entity=MED_CELL)") ; + MESSAGE("CONNECTIVITY(medEntityMesh Entity=MED_CELL)"); } -//-------------------------------------------------------------------------// -CONNECTIVITY::CONNECTIVITY(int numberOfTypes,medEntityMesh Entity/*=MED_CELL*/): -//-------------------------------------------------------------------------// - _entity(Entity), - _typeConnectivity(MED_NODAL), - _numberOfTypes(numberOfTypes), - _entityDimension(0), - _nodal((MEDSKYLINEARRAY*)NULL), - _descending((MEDSKYLINEARRAY*)NULL), - _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL), - _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL), - _neighbourhood((MEDSKYLINEARRAY*)NULL), - _constituent((CONNECTIVITY*)NULL) +/*! + Constructor. /n + Default for Entity is MED_CELL */ +//------------------------------------------------------------------------------// +CONNECTIVITY::CONNECTIVITY(int numberOfTypes,medEntityMesh Entity /* =MED_CELL */): +//------------------------------------------------------------------------------// + _entity(Entity), + _typeConnectivity(MED_NODAL), + _numberOfTypes(numberOfTypes), + _entityDimension(0), + _nodal((MEDSKYLINEARRAY*)NULL), + _descending((MEDSKYLINEARRAY*)NULL), + _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL), + _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL), + _neighbourhood((MEDSKYLINEARRAY*)NULL), + _constituent((CONNECTIVITY*)NULL) { - MESSAGE("CONNECTIVITY(int numberOfTypes,medEntityMesh Entity=MED_CELL)") ; + MESSAGE("CONNECTIVITY(int numberOfTypes,medEntityMesh Entity=MED_CELL)"); _geometricTypes = new medGeometryElement[numberOfTypes]; _type = new CELLMODEL[numberOfTypes]; - _count = new int[numberOfTypes]; + _count = new int[numberOfTypes+1]; } -//-------------------------------------------------------------------------// -CONNECTIVITY::CONNECTIVITY(CONNECTIVITY & m) -//-------------------------------------------------------------------------// +/*! + Copy Constructor. +*/ +//------------------------------------------------------// +CONNECTIVITY::CONNECTIVITY (const CONNECTIVITY & m): +//----------------------------------------------------// + _entity (m._entity), + _typeConnectivity (m._typeConnectivity), + _numberOfTypes (m._numberOfTypes), + _entityDimension (m._entityDimension), + _numberOfNodes (m._numberOfNodes) { - _entity = m._entity; - _typeConnectivity = m._typeConnectivity; - _numberOfTypes = m._numberOfTypes; - if (m._geometricTypes != NULL) - { - _geometricTypes = new medGeometryElement[m._numberOfTypes]; - memcpy(_geometricTypes,m._geometricTypes,m._numberOfTypes*sizeof(medGeometryElement)); - } - else + if (m._geometricTypes != NULL) + { + _geometricTypes = new medGeometryElement[_numberOfTypes]; + memcpy(_geometricTypes,m._geometricTypes,_numberOfTypes*sizeof(medGeometryElement)); + } + else _geometricTypes = (medGeometryElement *) NULL; - if (m._type != NULL) - _type = new CELLMODEL(* m._type); - else + + if (m._type != NULL) + { + _type = new CELLMODEL[_numberOfTypes]; + for (int i=0;i<_numberOfTypes;i++) + _type[i] = CELLMODEL(m._type[i]); + } + else _type = (CELLMODEL *) NULL; - _entityDimension = m._entityDimension; - _numberOfNodes = m._numberOfNodes; - if (m._count != NULL) - { - _count = new med_int[m._numberOfTypes+1]; - memcpy(_count,m._count,(m._numberOfTypes+1)*sizeof(med_int)); - } - else + + if (m._count != NULL) + { + _count = new med_int[_numberOfTypes+1]; + memcpy(_count,m._count,(_numberOfTypes+1)*sizeof(med_int)); + } + else _count = (med_int *) NULL; - if (m._nodal != NULL) + + if (m._nodal != NULL) _nodal = new MEDSKYLINEARRAY(* m._nodal); - else + else _nodal = (MEDSKYLINEARRAY *) NULL; - if (m._descending != NULL) + + if (m._descending != NULL) _descending = new MEDSKYLINEARRAY(* m._descending); - else + else _descending = (MEDSKYLINEARRAY *) NULL; - if (m._reverseNodalConnectivity != NULL) + + if (m._reverseNodalConnectivity != NULL) _reverseNodalConnectivity = new MEDSKYLINEARRAY(* m._reverseNodalConnectivity); - else + else _reverseNodalConnectivity = (MEDSKYLINEARRAY *) NULL; - if (m._reverseDescendingConnectivity != NULL) + + if (m._reverseDescendingConnectivity != NULL) _reverseDescendingConnectivity = new MEDSKYLINEARRAY(* m._reverseDescendingConnectivity); - else + else _reverseDescendingConnectivity = (MEDSKYLINEARRAY *) NULL; - if (m._neighbourhood != NULL) + + if (m._neighbourhood != NULL) _neighbourhood = new MEDSKYLINEARRAY(* m._neighbourhood); - else + else _neighbourhood = (MEDSKYLINEARRAY *) NULL; - if (m._constituent != NULL) + + if (m._constituent != NULL) _constituent = new CONNECTIVITY(* m._constituent); - else + else _constituent = (CONNECTIVITY *) NULL; } +/*! + Destructor./n + desallocates existing pointers */ //----------------------------// CONNECTIVITY::~CONNECTIVITY() //----------------------------// { - MESSAGE("Destructeur de CONNECTIVITY()") ; - if ( _geometricTypes != NULL ) - delete [] _geometricTypes ; - if ( _count != NULL ) - delete[] _count ; - if ( _nodal != NULL ) - delete _nodal ; - if ( _descending != NULL ) - delete _descending ; - if ( _reverseNodalConnectivity != NULL ) - delete _reverseNodalConnectivity ; - if ( _reverseDescendingConnectivity != NULL ) - delete _reverseDescendingConnectivity ; - if ( _constituent != NULL ) - delete _constituent ; + MESSAGE("Destructeur de CONNECTIVITY()"); + + if (_geometricTypes != NULL) + delete [] _geometricTypes; + if (_type != NULL) + delete [] _type; + if (_count != NULL) + delete[] _count; + if (_nodal != NULL) + delete _nodal; + if (_descending != NULL) + delete _descending; + if (_reverseNodalConnectivity != NULL) + delete _reverseNodalConnectivity; + if (_reverseDescendingConnectivity != NULL) + delete _reverseDescendingConnectivity; + if (_constituent != NULL) + delete _constituent; +} + +/*! + set _constituent to Constituent + be aware desallocation of _constituent is done by CONNECTIVITY:~CONNECTIVITY + throws an exception if Constituent = MED_CELL + A DOCUMENTER + */ +//----------------------------------------------------------// +void CONNECTIVITY::setConstituent(CONNECTIVITY * Constituent) + throw (MEDEXCEPTION) +//----------------------------------------------------------// +{ + medEntityMesh Entity = Constituent->getEntity(); + if (Entity == MED_CELL) + throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setConstituent : could not set constituent on MED_CELL !")); + + if ((Entity == MED_EDGE)&(_entityDimension == 3)) + { + if (_constituent == NULL) + throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setConstituent : Entity not found !")); + _constituent->setConstituent(Constituent); + } + else + _constituent = Constituent; +} + +/*! Duplicated Types array in CONNECTIVITY object. */ +//--------------------------------------------------------------------// +void CONNECTIVITY::setGeometricTypes(const medGeometryElement * Types, + const medEntityMesh Entity) + throw (MEDEXCEPTION) +//--------------------------------------------------------------------// +{ + if (Entity == _entity) + for (int i=0; i<_numberOfTypes; i++) + { + _geometricTypes[i] = Types[i]; + _type[i] = CELLMODEL(_geometricTypes[i]); + } + else + { + if (_constituent == NULL) + throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setGeometricTypes : Entity not found !")); + _constituent->setGeometricTypes(Types,Entity); + } +} + +/*! A DOCUMENTER */ +//--------------------------------------------------------------------// +void CONNECTIVITY::setCount(const int * Count, const medEntityMesh Entity) + throw (MEDEXCEPTION) +//--------------------------------------------------------------------// +{ + if (Entity == _entity) + { + int * index = new int[Count[_numberOfTypes]]; + index[0]=1; + _count[0]=1; + for (int i=0; i<_numberOfTypes; i++) { + _count[i+1] = Count[i+1]; + int NumberOfNodesPerElement = _type[i].getNumberOfNodes() ; + for (int j=_count[i]; j<_count[i+1]; j++) + index[j] = index[j-1]+NumberOfNodesPerElement; + } + // allocate _nodal + if (_nodal != NULL) delete _nodal; + _nodal = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,index[_count[_numberOfTypes]-1]-1); + _nodal->setIndex(index); + delete[] index; + } + else + { + if (_constituent == NULL) + throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setCount : Entity not found !")); + _constituent->setCount(Count,Entity); + } +} + +//--------------------------------------------------------------------// +void CONNECTIVITY::setNodal(const int * Connectivity, + const medEntityMesh Entity, + const medGeometryElement Type) + throw (MEDEXCEPTION) +//--------------------------------------------------------------------// +{ + if (_entity == Entity) + { + // find geometric type + bool find = false; + for (int i=0; i<_numberOfTypes; i++) + if (_geometricTypes[i] == Type) { + find = true; + int NumberOfNodePerElements = _type[i].getNumberOfNodes() ; + //_nodal->setI(i+1,Connectivity); + for( int j=_count[i];j<_count[i+1]; j++) + _nodal->setI(j,Connectivity+(j-_count[i])*NumberOfNodePerElements); + } + if (!find) + throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setNodal : geometric type not found")); + } else + { + if (_constituent == NULL) + throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setNodal : Entity not found !")); + _constituent->setNodal(Connectivity,Entity,Type); + } } /*! A DOCUMENTER */ @@ -135,15 +294,15 @@ void CONNECTIVITY::calculateConnectivity(medConnectivity ConnectivityType, medEn if (Entity==_entity) if (ConnectivityType==MED_NODAL) - calculateNodalConnectivity() ; + calculateNodalConnectivity(); else if (Entity==MED_CELL) - calculateDescendingConnectivity() ; + calculateDescendingConnectivity(); else throw MEDEXCEPTION("CONNECTIVITY::calculateConnectivity : Could not build DESCENDING !"); if (Entity!=_entity) { - calculateDescendingConnectivity() ; - _constituent->calculateConnectivity(ConnectivityType,Entity) ; + calculateDescendingConnectivity(); + _constituent->calculateConnectivity(ConnectivityType,Entity); } } @@ -162,19 +321,19 @@ void CONNECTIVITY::updateFamily(vector myFamilies) int numberOfFamilies = myFamilies.size(); if (numberOfFamilies == 0 ) { - MESSAGE(LOC<<"No family") ; - return ; + MESSAGE(LOC<<"No family"); + return; } // does we do an update ? if ((_constituent != NULL)&(_descending != NULL)) { - MESSAGE(LOC<<"Constituent is already defined") ; - return ; + MESSAGE(LOC<<"Constituent is already defined"); + return; } if ((_constituent != NULL)&(_descending == NULL)) { if (myFamilies[0]->getEntity() != _constituent->getEntity()) { - MESSAGE(LOC<<"Family and constituent entity are different. We do nothing") ; - return ; + MESSAGE(LOC<<"Family and constituent entity are different. We do nothing"); + return; } for(int i=0; i myFamilies) } // well we could go ! - CONNECTIVITY * oldConstituent = _constituent ; - _constituent = (CONNECTIVITY *)NULL ; + CONNECTIVITY * oldConstituent = _constituent; + +// for(int i=0; i_nodal == NULL) { MESSAGE(LOC<<"We have no nodal connectivity of sub cell"); - throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have no nodal connectivity of sub cell")) ; + throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have no nodal connectivity of sub cell")); } - int oldNumberOfFace = oldConstituent->_nodal->getNumberOf() ; - int * oldConstituentValue = oldConstituent->_nodal->getValue() ; - int * oldConstituentIndex = oldConstituent->_nodal->getIndex() ; + int oldNumberOfFace = oldConstituent->_nodal->getNumberOf(); + const int * oldConstituentValue = oldConstituent->_nodal->getValue(); + const int * oldConstituentIndex = oldConstituent->_nodal->getIndex(); - SCRUTE(oldNumberOfFace); + calculateDescendingConnectivity(); - calculateDescendingConnectivity() ; - - // if (oldConstituent->_nodal != NULL) { - int newNumberOfFace = _constituent->_nodal->getNumberOf() ; - int * newConstituentValue = _constituent->_nodal->getValue() ; - int * newConstituentIndex = _constituent->_nodal->getIndex() ; + int newNumberOfFace = _constituent->_nodal->getNumberOf(); + const int * newConstituentValue = _constituent->_nodal->getValue(); + const int * newConstituentIndex = _constituent->_nodal->getIndex(); - SCRUTE(newNumberOfFace); - - int * newReverseDescendingIndex = + const int * newReverseDescendingIndex = _reverseDescendingConnectivity->getIndex(); - int * newReverseDescendingValue = - _reverseDescendingConnectivity->getValue(); - int * newDescendingIndex = _descending->getIndex(); - int * newDescendingValue = _descending->getValue(); + const int * newDescendingIndex = _descending->getIndex(); + const int * newDescendingValue = _descending->getValue(); // loop on all family, // for all constituent in family, we get it's old connectivity @@ -236,49 +394,48 @@ void CONNECTIVITY::updateFamily(vector myFamilies) int index1 = 0; int indexm1 = 0; - _constituent->calculateReverseNodalConnectivity() ; + _constituent->calculateReverseNodalConnectivity(); for (int iOldFace=0;iOldFacegetReverseNodalConnectivity() ; - int * reverseFaceNodalIndex = _constituent->getReverseNodalConnectivityIndex() ; + const int * reverseFaceNodal = _constituent->getReverseNodalConnectivity(); + const int * reverseFaceNodalIndex = _constituent->getReverseNodalConnectivityIndex(); // set an array wich contains faces numbers arround first node - int BeginIndexFaceArrayFirstNode=reverseFaceNodalIndex[NodesLists[0]-1] ; - int EndIndexFaceArrayFirstNode=reverseFaceNodalIndex[NodesLists[0]] ; + int BeginIndexFaceArrayFirstNode=reverseFaceNodalIndex[NodesLists[0]-1]; + int EndIndexFaceArrayFirstNode=reverseFaceNodalIndex[NodesLists[0]]; int NumberOfFacesInList=EndIndexFaceArrayFirstNode-BeginIndexFaceArrayFirstNode; - int * FacesList = new int[NumberOfFacesInList] ; - for (int l=BeginIndexFaceArrayFirstNode; l myFamilies) } } NumberOfFacesInList = NewNumberOfFacesInList; - delete [] FacesList ; + delete [] FacesList; FacesList = NewFacesList; } - if (!NumberOfFacesInList==0) { if (NumberOfFacesInList>1) @@ -300,27 +456,22 @@ void CONNECTIVITY::updateFamily(vector myFamilies) MEDMODULUSARRAY modulusArrayOld(face_size_itOld,NodesLists); - SCRUTE(NumberOfFacesInList); - SCRUTE(FacesList); - SCRUTE(newConstituentIndex); - int face_it_beginNew = newConstituentIndex[FacesList[0]-1]; int face_it_endNew = newConstituentIndex[FacesList[0]]; face_size_itNew = face_it_endNew - face_it_beginNew; - int * newNodesLists = newConstituentValue+newConstituentIndex[FacesList[0]-1]-1 ; - MEDMODULUSARRAY modulusArrayNew(face_size_itOld,newNodesLists); + const int * newNodesLists = newConstituentValue+newConstituentIndex[FacesList[0]-1]-1; + MEDMODULUSARRAY modulusArrayNew(face_size_itNew,newNodesLists); int retCompareNewOld = modulusArrayNew.compare(modulusArrayOld); + //SCRUTE(retCompareNewOld); + // Real new face found if(retCompareNewOld == 1) { - renumberingFromOldToNew[iOldFace] = FacesList[0] ; - - MESSAGE("Renumbering index " << iOldFace << " val "<< FacesList[0]); - + renumberingFromOldToNew[iOldFace] = FacesList[0]; index = 1; index1++; } @@ -330,9 +481,6 @@ void CONNECTIVITY::updateFamily(vector myFamilies) if(retCompareNewOld == -1) { renumberingFromOldToNew[iOldFace] = FacesList[0]; - - MESSAGE("Renumbering index " << iOldFace << " val "<< FacesList[0]); - index = 1; indexm1++; @@ -347,43 +495,44 @@ void CONNECTIVITY::updateFamily(vector myFamilies) throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This face/edge should not be a (d-1) cell because it has "<getIJ(FacesList[0],1); + int cell2 = _reverseDescendingConnectivity->getIJ(FacesList[0],2); // PROVISOIRE : en attendant que le SKYLINEARRAY de ReverseDescending soit correct (sans le zero) // if (cell2 == 0) // throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This is a boundary face/edge, it should not be renumbered and it is wrongly oriented.")); if (cell2 != 0) { // we are not on border !!!! - newReverseDescendingValue[face_it_begin-1] = cell2; + _reverseDescendingConnectivity->setIJ(FacesList[0],1,cell2); // Updating _constituent->_nodal because of reversity - int * oldArray = oldConstituentValue+face_it_beginOld-1; - int * newArray = newConstituentValue+face_it_beginNew-1; - for(int iarray=0;iarray_nodal->setIJ(FacesList[0],iarray,oldArray[iarray-1]); + } // Updating _reverseDescendingConnectivity - newReverseDescendingValue[face_it_begin] = cell1; + _reverseDescendingConnectivity->setIJ(FacesList[0],2,cell1); // Updating _descending for cell1 and cell2 - for(int iface=newDescendingIndex[cell1-1];ifacegetIndexValue(iface)==FacesList[0]) + _descending->setIndexValue(iface,-FacesList[0]); + else if (_descending->getIndexValue(iface)==-FacesList[0]) + _descending->setIndexValue(iface,FacesList[0]); + // else nothing to do for(int iface=newDescendingIndex[cell2-1];ifacegetIndexValue(iface)==FacesList[0]) + _descending->setIndexValue(iface,-FacesList[0]); + else if (_descending->getIndexValue(iface)==-FacesList[0]) + _descending->setIndexValue(iface,FacesList[0]); + // else nothing to do + } else {// else we are on border and we do nothing !!!!!!!! INFOS("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING"); - INFOS(LOC<<" Boudary FACE "< myFamilies) throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have a Face connectivity problem")); } } + delete[] FacesList; } MESSAGE(LOC<<"The Renumbering is finished and the status is"); - SCRUTE(index1); - SCRUTE(indexm1); // Updating the Family for(int i=0; igetnumber()->getLength(); - int * value_skyline = myFamily->getnumber()->getValue(); + MEDSKYLINEARRAY * number = myFamily->getnumber(); + int numberOfLines_skyline = number->getNumberOf(); + const int * index_skyline = number->getIndex(); - for (int i=0;isetIndexValue(j,renumberingFromOldToNew[number->getIndexValue(j)-1]); + } } MESSAGE(LOC<<"updating the family (END) : " << *myFamily); } + + delete oldConstituent ; + delete [] renumberingFromOldToNew; } + END_OF(LOC); - return ; + return; } //------------------------------------------------------------------------------------------------------------------// -med_int * CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type) +const med_int * CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type) //------------------------------------------------------------------------------------------------------------------// { - const char * LOC = "CONNECTIVITY::getConnectivity" ; + const char * LOC = "CONNECTIVITY::getConnectivity"; BEGIN_OF(LOC); - MEDSKYLINEARRAY * Connectivity ; + MEDSKYLINEARRAY * Connectivity; if (Entity==_entity) { if (ConnectivityType==MED_NODAL) @@ -437,26 +591,27 @@ med_int * CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType, medEnt } else { - calculateDescendingConnectivity() ; + calculateDescendingConnectivity(); Connectivity=_descending; } if (Connectivity!=NULL) if (Type==MED_ALL_ELEMENTS) - return Connectivity->getValue() ; + return Connectivity->getValue(); else { for (med_int i=0; i<_numberOfTypes; i++) if (_geometricTypes[i]==Type) - return Connectivity->getI(_count[i]) ; - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Type not found !")) ; + //return Connectivity->getI(i+1); + return Connectivity->getI(_count[i]); + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Type not found !")); } else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")) ; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")); } else if (_constituent != NULL) return _constituent->getConnectivity(ConnectivityType,Entity,Type); - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")) ; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")); } /*! Give morse index array to use with @@ -468,13 +623,13 @@ med_int * CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType, medEnt - In C mode : Connectivity[ConnectivityIndex[i]-1+j-1] - In fortran mode : Connectivity[ConnectivityIndex[i]+j] */ //-----------------------------------------------------------------------------------------------// -med_int * CONNECTIVITY::getConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity) +const med_int * CONNECTIVITY::getConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity) //------------------------------------------------------------------------------------------------// { - const char * LOC = "CONNECTIVITY::getConnectivityIndex" ; + const char * LOC = "CONNECTIVITY::getConnectivityIndex"; BEGIN_OF(LOC); - MEDSKYLINEARRAY * Connectivity ; + MEDSKYLINEARRAY * Connectivity; if (Entity==_entity) { if (ConnectivityType==MED_NODAL) @@ -483,31 +638,31 @@ med_int * CONNECTIVITY::getConnectivityIndex(medConnectivity ConnectivityType, m Connectivity=_descending; if (Connectivity!=NULL) - return Connectivity->getIndex() ; + return Connectivity->getIndex(); else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")) ; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")); } else if (_constituent != NULL) return _constituent->getConnectivityIndex(ConnectivityType,Entity); - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")) ; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")); } /*! A DOCUMENTER */ //--------------------------------------------------------------// -CELLMODEL & CONNECTIVITY::getType(medGeometryElement Type) const +const CELLMODEL & CONNECTIVITY::getType(medGeometryElement Type) const //--------------------------------------------------------------// { - const char * LOC = "CONNECTIVITY::getType" ; + const char * LOC = "CONNECTIVITY::getType"; BEGIN_OF(LOC); if ((Type==MED_ALL_ELEMENTS) || (Type==MED_NONE)) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE !")) ; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE !")); for (med_int i=0; i<_numberOfTypes; i++) if (_geometricTypes[i]==Type) - return _type[i] ; - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !")) ; + return _type[i]; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !")); } /*! Returns the number of elements of type . @@ -516,15 +671,15 @@ CELLMODEL & CONNECTIVITY::getType(medGeometryElement Type) const med_int CONNECTIVITY::getNumberOfNodesInType(medGeometryElement Type) const //------------------------------------------------------------------------// { - const char * LOC = "CONNECTIVITY::getNumberOfNodesInType" ; + const char * LOC = "CONNECTIVITY::getNumberOfNodesInType"; BEGIN_OF(LOC); if ((Type==MED_ALL_ELEMENTS) || (Type==MED_NONE)) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!")) ; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!")); for (med_int i=0; i<_numberOfTypes; i++) if (_geometricTypes[i]==Type) - return _type[i].getNumberOfNodes() ; - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !")) ; + return _type[i].getNumberOfNodes(); + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !")); } /*! Returns the number of geometric sub cells of type. @@ -534,11 +689,11 @@ med_int CONNECTIVITY::getNumberOfSubCellInType(medGeometryElement Type) const //------------------------------------------------------------------------// { if ((Type==MED_ALL_ELEMENTS) || (Type==MED_NONE)) - throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!") ; + throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!"); for (med_int i=0; i<_numberOfTypes; i++) if (_geometricTypes[i]==Type) - return _type[i].getNumberOfConstituents(1) ; - throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement not found !") ; + return _type[i].getNumberOfConstituents(1); + throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement not found !"); } /*! Returns the number of elements of type . @@ -551,14 +706,14 @@ med_int CONNECTIVITY::getNumberOfSubCellInType(medGeometryElement Type) const med_int CONNECTIVITY::getNumberOf(medEntityMesh Entity, medGeometryElement Type) const //-----------------------------------------------------------------------------------// { - const char * LOC = "CONNECTIVITY::getNumberOf" ; + const char * LOC = "CONNECTIVITY::getNumberOf"; BEGIN_OF(LOC); MESSAGE(LOC<<" Entity = "<< Entity << ", _entity = "<<_entity); if (Entity==_entity) { if (Type==MED_NONE) - return 0 ; // not defined ! + return 0; // not defined ! //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_NONE")); if (Type==MED_ALL_ELEMENTS) return _count[_numberOfTypes]-1; @@ -570,13 +725,13 @@ med_int CONNECTIVITY::getNumberOf(medEntityMesh Entity, medGeometryElement Type) if (_constituent != NULL) return _constituent->getNumberOf(Entity,Type); - return 0 ; // valid if they are nothing else ! - //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")) ; + return 0; // valid if they are nothing else ! + //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")); } /*! A DOCUMENTER */ //--------------------------------------------------------------// -med_int* CONNECTIVITY::getValue(medConnectivity TypeConnectivity, +const med_int* CONNECTIVITY::getValue(medConnectivity TypeConnectivity, medGeometryElement Type) //--------------------------------------------------------------// { @@ -603,7 +758,7 @@ med_int* CONNECTIVITY::getValue(medConnectivity TypeConnectivity, /*! A DOCUMENTER */ //---------------------------------------------------------------------// -med_int* CONNECTIVITY:: getValueIndex(medConnectivity TypeConnectivity) +const med_int* CONNECTIVITY:: getValueIndex(medConnectivity TypeConnectivity) //---------------------------------------------------------------------// { if (TypeConnectivity == MED_NODAL) @@ -620,7 +775,7 @@ med_int* CONNECTIVITY:: getValueIndex(medConnectivity TypeConnectivity) /*! Not yet implemented */ //----------------------------------------------// -med_int* CONNECTIVITY:: getNeighbourhood() const +const med_int* CONNECTIVITY:: getNeighbourhood() const //----------------------------------------------// { throw MEDEXCEPTION("CONNECTIVITY::getNeighbourhood : Not implemented"); @@ -629,7 +784,7 @@ med_int* CONNECTIVITY:: getNeighbourhood() const /*! Returns an array which contains, for each node, all cells arround it. */ //-------------------------------------------------// -med_int* CONNECTIVITY::getReverseNodalConnectivity() +const med_int* CONNECTIVITY::getReverseNodalConnectivity() //-------------------------------------------------// { calculateReverseNodalConnectivity(); @@ -639,7 +794,7 @@ med_int* CONNECTIVITY::getReverseNodalConnectivity() /*! Give index array to use with getReverseConnectivity(MED_NODAL). It is unusefull with MED_DESCENDING mode, because we have allways two cells. */ //-------------------------------------------------------// -med_int* CONNECTIVITY::getReverseNodalConnectivityIndex() +const med_int* CONNECTIVITY::getReverseNodalConnectivityIndex() //-------------------------------------------------------// { calculateReverseNodalConnectivity(); @@ -650,7 +805,7 @@ med_int* CONNECTIVITY::getReverseNodalConnectivityIndex() the 2 cells of each side. First is cell which face normal is outgoing. arround it. */ //------------------------------------------------------// -med_int* CONNECTIVITY::getReverseDescendingConnectivity() +const med_int* CONNECTIVITY::getReverseDescendingConnectivity() //------------------------------------------------------// { // it is in _constituent connectivity only if we are in MED_CELL @@ -666,7 +821,7 @@ med_int* CONNECTIVITY::getReverseDescendingConnectivity() /*! calculate the reverse descending Connectivity and returns the index ( A DOCUMENTER MIEUX)*/ //-----------------------------------------------------------// -med_int* CONNECTIVITY::getReverseDescendingConnectivityIndex() +const med_int* CONNECTIVITY::getReverseDescendingConnectivityIndex() //-----------------------------------------------------------// { // it is in _constituent connectivity only if we are in MED_CELL @@ -697,14 +852,12 @@ void CONNECTIVITY::calculateNodalConnectivity() void CONNECTIVITY::calculateReverseNodalConnectivity() //---------------------------------------------------// { - const char * LOC = "CONNECTIVITY::calculateReverseNodalConnectivity : " ; - BEGIN_OF(LOC) ; + const char * LOC = "CONNECTIVITY::calculateReverseNodalConnectivity : "; + BEGIN_OF(LOC); if (_nodal==NULL) - calculateNodalConnectivity() ; + calculateNodalConnectivity(); - MESSAGE(LOC<<"Number of nodes = "<<_numberOfNodes); - if(_reverseNodalConnectivity==NULL) { med_int node_number = 0; @@ -720,9 +873,9 @@ void CONNECTIVITY::calculateReverseNodalConnectivity() // treat all cells of a particular type for (med_int k = _count[j]; k < _count[j+1]; k++) // treat all nodes of the cell type - for (med_int local_node_number = 1 ; local_node_number < node_number+1; local_node_number++) + for (med_int local_node_number = 1; local_node_number < node_number+1; local_node_number++) { - med_int global_node = _nodal->getIJ(k,local_node_number) ; + med_int global_node = _nodal->getIJ(k,local_node_number); reverse_connectivity[global_node].push_back(k); } } @@ -734,24 +887,28 @@ void CONNECTIVITY::calculateReverseNodalConnectivity() for (med_int i = 1; i < _numberOfNodes+1; i++) size_reverse_nodal_connectivity += reverse_connectivity[i].size(); - MEDSKYLINEARRAY * ReverseConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity) ; - // reverse_nodal_connectivity_index = new (med_int)[_numberOfNodes+1]; - // reverse_nodal_connectivity = new (med_int)[size_reverse_nodal_connectivity]; - med_int * reverse_nodal_connectivity = ReverseConnectivity->getValue() ; - med_int * reverse_nodal_connectivity_index = ReverseConnectivity->getIndex() ; + //MEDSKYLINEARRAY * ReverseConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity); + med_int * reverse_nodal_connectivity_index = new (med_int)[_numberOfNodes+1]; + med_int * reverse_nodal_connectivity = new (med_int)[size_reverse_nodal_connectivity]; + //const med_int * reverse_nodal_connectivity = ReverseConnectivity->getValue(); + //const med_int * reverse_nodal_connectivity_index = ReverseConnectivity->getIndex(); reverse_nodal_connectivity_index[0] = 1; for (med_int i = 1; i < _numberOfNodes+1; i++) { med_int size = reverse_connectivity[i].size(); - reverse_nodal_connectivity_index[i] = reverse_nodal_connectivity_index[i-1] + size ; + reverse_nodal_connectivity_index[i] = reverse_nodal_connectivity_index[i-1] + size; for (med_int j = 0; j < size; j++) reverse_nodal_connectivity[reverse_nodal_connectivity_index[i-1]-1+j]= reverse_connectivity[i][j]; } - _reverseNodalConnectivity = ReverseConnectivity ; - - } + //_reverseNodalConnectivity = ReverseConnectivity; + _reverseNodalConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity, + reverse_nodal_connectivity_index, + reverse_nodal_connectivity); + delete[] reverse_nodal_connectivity_index; + delete[] reverse_nodal_connectivity; + } } /*! If not yet done, calculate the Descending Connectivity */ @@ -775,49 +932,51 @@ void CONNECTIVITY::calculateDescendingConnectivity() MESSAGE(LOC<<": No descending connectivity defined, but constituent exist !"); if (_entityDimension == 3) - _constituent = new CONNECTIVITY(MED_FACE) ; + _constituent = new CONNECTIVITY(MED_FACE); else if (_entityDimension == 2) - _constituent = new CONNECTIVITY(MED_EDGE) ; + _constituent = new CONNECTIVITY(MED_EDGE); else { MESSAGE(LOC<<"We are in 1D"); return; } - _constituent->_typeConnectivity = MED_DESCENDING ; - _constituent->_numberOfNodes = _numberOfNodes ; + _constituent->_typeConnectivity = MED_NODAL; + _constituent->_numberOfNodes = _numberOfNodes; // foreach cells, we built array of constituent - int DescendingSize = 0 ; + int DescendingSize = 0; for(int i=0; i<_numberOfTypes; i++) - DescendingSize+=(_count[i+1]-_count[i])*_type[i].getNumberOfConstituents(1) ; - _descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,DescendingSize) ; - int * descend_connectivity = _descending->getValue() ; + DescendingSize+=(_count[i+1]-_count[i])*_type[i].getNumberOfConstituents(1); + //_descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,DescendingSize); + //const int * descend_connectivity = _descending->getValue(); + int * descend_connectivity = new int[DescendingSize]; for (int i=0; igetIndex() ; + //const int * descend_connectivity_index = _descending->getIndex(); + int * descend_connectivity_index = new int[_count[_numberOfTypes]]; descend_connectivity_index[0]=1; medGeometryElement* ConstituentsTypes = new medGeometryElement[2]; - ConstituentsTypes[0]=MED_NONE ; - ConstituentsTypes[1]=MED_NONE ; + ConstituentsTypes[0]=MED_NONE; + ConstituentsTypes[1]=MED_NONE; int * NumberOfConstituentsForeachType = new int[2]; NumberOfConstituentsForeachType[0]=0; NumberOfConstituentsForeachType[1]=0; for(int i=0; i<_numberOfTypes; i++) { // initialize descend_connectivity_index array : - int NumberOfConstituents = _type[i].getNumberOfConstituents(1) ; + int NumberOfConstituents = _type[i].getNumberOfConstituents(1); for (int j=_count[i];j<_count[i+1];j++){ - descend_connectivity_index[j]=descend_connectivity_index[j-1]+NumberOfConstituents ; + descend_connectivity_index[j]=descend_connectivity_index[j-1]+NumberOfConstituents; // compute number of constituent of all cell for each type for(int k=1;k_nodal = new MEDSKYLINEARRAY(TotalNumberOfConstituents,TotalNumberOfNodes) ; + int TotalNumberOfConstituents = NumberOfConstituentsForeachType[0]+NumberOfConstituentsForeachType[1]; + int TotalNumberOfNodes = NumberOfConstituentsForeachType[0]*(ConstituentsTypes[0]%100)+NumberOfConstituentsForeachType[1]*(ConstituentsTypes[1]%100); + + //_constituent->_nodal = new MEDSKYLINEARRAY(TotalNumberOfConstituents,TotalNumberOfNodes); // we use _constituent->_nodal - int * ConstituentNodalConnectivity = _constituent->_nodal->getValue(); - int * ConstituentNodalConnectivityIndex = _constituent->_nodal->getIndex(); + //const int * ConstituentNodalConnectivity = _constituent->_nodal->getValue(); + //const int * ConstituentNodalConnectivityIndex = _constituent->_nodal->getIndex(); + int * ConstituentNodalConnectivity = new int[TotalNumberOfNodes]; + int * ConstituentNodalConnectivityIndex = new int[TotalNumberOfConstituents+1]; ConstituentNodalConnectivityIndex[0]=1; _constituent->_entityDimension=ConstituentsTypes[0]/100; if (ConstituentsTypes[1]==MED_NONE) - _constituent->_numberOfTypes = 1 ; + _constituent->_numberOfTypes = 1; else - _constituent->_numberOfTypes = 2 ; - _constituent->_geometricTypes = new medGeometryElement[_constituent->_numberOfTypes] ; - _constituent->_type = new CELLMODEL[_constituent->_numberOfTypes] ; - _constituent->_count = new med_int[_constituent->_numberOfTypes+1] ; + _constituent->_numberOfTypes = 2; + _constituent->_geometricTypes = new medGeometryElement[_constituent->_numberOfTypes]; + _constituent->_type = new CELLMODEL[_constituent->_numberOfTypes]; + _constituent->_count = new med_int[_constituent->_numberOfTypes+1]; _constituent->_count[0]=1; - int* tmp_NumberOfConstituentsForeachType = new med_int[_constituent->_numberOfTypes+1] ; + int* tmp_NumberOfConstituentsForeachType = new med_int[_constituent->_numberOfTypes+1]; tmp_NumberOfConstituentsForeachType[0]=0; // to count constituent of each type for (int i=0; i<_constituent->_numberOfTypes;i++) { - _constituent->_geometricTypes[i]=ConstituentsTypes[i] ; - _constituent->_count[i+1]=_constituent->_count[i]+NumberOfConstituentsForeachType[i] ; + _constituent->_geometricTypes[i]=ConstituentsTypes[i]; + _constituent->_count[i+1]=_constituent->_count[i]+NumberOfConstituentsForeachType[i]; CELLMODEL Type(ConstituentsTypes[i]); _constituent->_type[i]=Type; - tmp_NumberOfConstituentsForeachType[i+1]=NumberOfConstituentsForeachType[i] ; + tmp_NumberOfConstituentsForeachType[i+1]=NumberOfConstituentsForeachType[i]; for (int j=tmp_NumberOfConstituentsForeachType[i]; jgetIndex(); - int * ReverseNodalConnectivityValue = _reverseNodalConnectivity->getValue(); + calculateReverseNodalConnectivity(); + const int * ReverseNodalConnectivityIndex = _reverseNodalConnectivity->getIndex(); + const int * ReverseNodalConnectivityValue = _reverseNodalConnectivity->getValue(); // array to keep reverse descending connectivity int * ReverseDescendingConnectivityValue = new int[TotalNumberOfConstituents*2]; - int TotalNumberOfSubCell = 0 ; + int TotalNumberOfSubCell = 0; for (int i=0; i<_numberOfTypes; i++) { // loop on all cell type - CELLMODEL Type = _type[i] ; - int NumberOfNodesPerCell = Type.getNumberOfNodes() ; + CELLMODEL Type = _type[i]; + int NumberOfNodesPerCell = Type.getNumberOfNodes(); int NumberOfConstituentPerCell = Type.getNumberOfConstituents(1); for (int j=_count[i]; j<_count[i+1]; j++) // we loop on all cell of this type - for (int k=1 ; k<=NumberOfConstituentPerCell; k++) { // we loop on all sub cell of it + for (int k=1; k<=NumberOfConstituentPerCell; k++) { // we loop on all sub cell of it if (descend_connectivity[descend_connectivity_index[j-1]+k-2]==0) { // it is a new sub cell ! // TotalNumberOfSubCell++; @@ -887,10 +1049,10 @@ void CONNECTIVITY::calculateDescendingConnectivity() //we have maximum two types descend_connectivity[descend_connectivity_index[j-1]+k-2]=TotalNumberOfSubCell; - ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2]=j ; - int NumberOfNodesPerConstituent = Type.getConstituentType(1,k)%100 ; + ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2]=j; + int NumberOfNodesPerConstituent = Type.getConstituentType(1,k)%100; - int * NodesLists = new int[NumberOfNodesPerConstituent] ; + int * NodesLists = new int[NumberOfNodesPerConstituent]; for (int l=0; lgetIJ(j,Type.getNodeConstituent(1,k,l+1)); ConstituentNodalConnectivity[ConstituentNodalConnectivityIndex[TotalNumberOfSubCell-1]-1+l]=NodesLists[l]; @@ -898,26 +1060,26 @@ void CONNECTIVITY::calculateDescendingConnectivity() // we use reverse_nodal_connectivity to find the other element which contain this sub cell // all elements which contains first node of sub cell : - int ReverseNodalConnectivityIndex_0 = ReverseNodalConnectivityIndex[NodesLists[0]-1] ; - int ReverseNodalConnectivityIndex_1 = ReverseNodalConnectivityIndex[NodesLists[0]] ; - int NumberOfCellsInList = ReverseNodalConnectivityIndex_1-ReverseNodalConnectivityIndex_0 ; + int ReverseNodalConnectivityIndex_0 = ReverseNodalConnectivityIndex[NodesLists[0]-1]; + int ReverseNodalConnectivityIndex_1 = ReverseNodalConnectivityIndex[NodesLists[0]]; + int NumberOfCellsInList = ReverseNodalConnectivityIndex_1-ReverseNodalConnectivityIndex_0; if (NumberOfCellsInList > 0) { // we could have no element ! - int * CellsList = new int[NumberOfCellsInList] ; + int * CellsList = new int[NumberOfCellsInList]; for (int l=ReverseNodalConnectivityIndex_0; l 0) { // We have found some elements ! - int CellNumber = CellsList[0] ; - delete [] CellsList ; + int CellNumber = CellsList[0]; + //delete [] CellsList; if (NumberOfCellsInList>1) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one other Cell ("<getIJ(CellNumber,Type2.getNodeConstituent(1,l,m)) == NodesLists[n-1]) - counter++ ; + counter++; } if (counter==Type.getConstituentType(1,k)%100) { descend_connectivity[descend_connectivity_index[CellNumber-1]+l-2]=-1*TotalNumberOfSubCell; // because, see it in other side ! - find2 = true ; + find2 = true; } if (find2) - break ; + break; } if (!find2) - INFOS(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!") ; // exception ? + INFOS(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!"); // exception ? } } else { - ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0 ; + ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0; } + delete[] CellsList; } - delete[] NodesLists ; + + delete[] NodesLists; } } } // we adjust _constituent - int NumberOfConstituent=0 ; - int SizeOfConstituentNodal=0 ; + int NumberOfConstituent=0; + int SizeOfConstituentNodal=0; for (int i=0;i<_constituent->_numberOfTypes; i++) { NumberOfConstituent += tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1; SizeOfConstituentNodal += (tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1)*_constituent->_type[i].getNumberOfNodes(); } // we built new _nodal attribute in _constituent - MEDSKYLINEARRAY *ConstituentNodal = new MEDSKYLINEARRAY(NumberOfConstituent,SizeOfConstituentNodal); - int *ConstituentNodalValue = ConstituentNodal->getValue(); - int *ConstituentNodalIndex = ConstituentNodal->getIndex(); + //MEDSKYLINEARRAY *ConstituentNodal = new MEDSKYLINEARRAY(NumberOfConstituent,SizeOfConstituentNodal); + //const int *ConstituentNodalValue = ConstituentNodal->getValue(); + //const int *ConstituentNodalIndex = ConstituentNodal->getIndex(); + int *ConstituentNodalValue = new int[SizeOfConstituentNodal]; + int *ConstituentNodalIndex = new int[NumberOfConstituent+1]; ConstituentNodalIndex[0]=1; // we build _reverseDescendingConnectivity - _reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,2*NumberOfConstituent) ; - int *reverseDescendingConnectivityValue = _reverseDescendingConnectivity->getValue(); - int *reverseDescendingConnectivityIndex = _reverseDescendingConnectivity->getIndex(); + //_reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,2*NumberOfConstituent); + //const int *reverseDescendingConnectivityValue = _reverseDescendingConnectivity->getValue(); + //const int *reverseDescendingConnectivityIndex = _reverseDescendingConnectivity->getIndex(); + int *reverseDescendingConnectivityValue = new int[2*NumberOfConstituent]; + int *reverseDescendingConnectivityIndex = new int[NumberOfConstituent+1]; reverseDescendingConnectivityIndex[0]=1; // first constituent type @@ -1007,9 +1175,9 @@ void CONNECTIVITY::calculateDescendingConnectivity() } // second type if any if (_constituent->_numberOfTypes==2) { - int offset = _constituent->_count[1]-tmp_NumberOfConstituentsForeachType[0]-1 ; + int offset = _constituent->_count[1]-tmp_NumberOfConstituentsForeachType[0]-1; int offset1=offset*_constituent->_type[0].getNumberOfNodes(); - int offset2=offset*2 ; + int offset2=offset*2; int NumberOfNodesPerConstituent = _constituent->_type[1].getNumberOfNodes(); for(int j=tmp_NumberOfConstituentsForeachType[0]; j_count[2]=NumberOfConstituent+1 ; + _constituent->_count[2]=NumberOfConstituent+1; // we correct _descending to adjust face number for(int j=0;jtmp_NumberOfConstituentsForeachType[0]) descend_connectivity[j]-=offset; } + + delete[] ConstituentNodalConnectivityIndex; + delete[] ConstituentNodalConnectivity; + + _descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1, + DescendingSize, + descend_connectivity_index, + descend_connectivity); + delete[] descend_connectivity_index; + delete[] descend_connectivity; + _reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent, + 2*NumberOfConstituent, + reverseDescendingConnectivityIndex, + reverseDescendingConnectivityValue); + delete[] reverseDescendingConnectivityIndex; + delete[] reverseDescendingConnectivityValue; + _constituent->_count[1]=tmp_NumberOfConstituentsForeachType[0]+1; - delete _constituent->_nodal ; - _constituent->_nodal = ConstituentNodal ; + delete[] tmp_NumberOfConstituentsForeachType; + + //delete _constituent->_nodal; + _constituent->_nodal = new MEDSKYLINEARRAY(NumberOfConstituent, + SizeOfConstituentNodal, + ConstituentNodalIndex, + ConstituentNodalValue); - delete[] ReverseDescendingConnectivityValue ; + delete[] ConstituentNodalIndex; + delete[] ConstituentNodalValue; + + delete[] ReverseDescendingConnectivityValue; } END_OF(LOC); } @@ -1047,7 +1240,7 @@ void CONNECTIVITY::calculateDescendingConnectivity() // if (myConnectivity->getEntity()!=MED_CELL) // throw MEDEXCEPTION("CONNECTIVITY::calculateReverseDescending // Connectivity : we need MED_CELL connectivity !"); -// return ; +// return; // } /*! Not implemented yet */ @@ -1056,7 +1249,7 @@ void CONNECTIVITY::calculateNeighbourhood(CONNECTIVITY &myConnectivity) //--------------------------------------------------------------------// { // Mesh dimension ! - return ; + return; } @@ -1064,7 +1257,7 @@ void CONNECTIVITY::calculateNeighbourhood(CONNECTIVITY &myConnectivity) Give, for one element number of a specified entity the geometric type Of this element. - Example : medGeometryElement myType = myConnectivity.getElementType(MED_CELL,35) ; + Example : medGeometryElement myType = myConnectivity.getElementType(MED_CELL,35); */ //--------------------------------------------------------------------// medGeometryElement CONNECTIVITY::getElementType(medEntityMesh Entity,int Number) const @@ -1073,11 +1266,11 @@ medGeometryElement CONNECTIVITY::getElementType(medEntityMesh Entity,int Number) if (_entity==Entity) { for(int i=1; i<=_numberOfTypes;i++) if (Number<_count[i]) - return _geometricTypes[i-1] ; + return _geometricTypes[i-1]; } else if (_constituent!=NULL) - return _constituent->getElementType(Entity,Number) ; + return _constituent->getElementType(Entity,Number); else - throw MEDEXCEPTION(LOCALIZED("getElementType : Entity not defined !")) ; - throw MEDEXCEPTION(LOCALIZED("getElementType : Wrong Number !")) ; + throw MEDEXCEPTION(LOCALIZED("getElementType : Entity not defined !")); + throw MEDEXCEPTION(LOCALIZED("getElementType : Wrong Number !")); } diff --git a/src/MEDMEM/MEDMEM_Coordinate.hxx b/src/MEDMEM/MEDMEM_Coordinate.hxx index e65517fc8..4bb0ee8b3 100644 --- a/src/MEDMEM/MEDMEM_Coordinate.hxx +++ b/src/MEDMEM/MEDMEM_Coordinate.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_Coordinate.hxx +// Module : MED + /* File Coordinate.hxx $Header$ @@ -11,38 +37,45 @@ #include "MEDMEM_PointerOf.hxx" #include "MEDMEM_Exception.hxx" #include "MEDMEM_define.hxx" -//using namespace MED_EN; #include "MEDMEM_Array.hxx" -class COORDINATE { +/*! + This class contains coordinates of the nodes ./n + It could also store useful optional information about nodes + as node numbers and about axes as names or units. /n + spaceDimension and numberOfNodes can be found in _coordinate object. +*/ + +class COORDINATE +{ protected: /*! contains "CARTESIAN", "CYLINDRICAL" or "SPHERICAL"*/ - string _coordinateSystem; + string _coordinateSystem; + - // all in _coordinate object !!! - // int _spaceDimension; - // int _numberOfNodes; + /*! _coordinate is a MEDARRAY object : \n + - spaceDimension /n + - numberOfNodes /n + - default storage mode /n + - Up to 4 "PointerOf" to an array of size spaceDimension*NumberOfNodes/n - /*! array of size spaceDimension*NumberOfNodes */ - //PointerOf< MEDARRAY > _coordinate; - //bool _allocateCoordinate; - MEDARRAY* _coordinate; + Storing the object (not a pointer to this object) is more convenient for memory + management. + */ + MEDARRAY _coordinate; - /*! array of size spaceDimension */ - PointerOf _coordinateName; - //string * _coordinateName; + /*! PointerOf to an array of size spaceDimension storing axes names*/ + PointerOf _coordinateName; - /*! array of size spaceDimension */ - PointerOf _coordinateUnit; - //string * _coordinateUnit; + /*! PointerOf to an array of size spaceDimension storing units */ + PointerOf _coordinateUnit; - /*! array of size NumberOfNodes : optionnal nodes numbers */ - PointerOf _nodeNumber; - //int * _nodeNumber; + /*! PointerOf to an array of size NumberOfNodes : optional nodes numbers */ + PointerOf _nodeNumber; public : @@ -52,28 +85,34 @@ public : COORDINATE(); - COORDINATE(medModeSwitch Mode,int SpaceDimension, int NumberOfNodes); + COORDINATE(int SpaceDimension, int NumberOfNodes, medModeSwitch Mode); COORDINATE(const COORDINATE & m); ~COORDINATE(); void setCoordinates(MEDARRAY *Coordinate); - void setCoordinatesNames(string * CoordinateName); - void setCoordinatesUnits(string * CoordinateUnit); - void setCoordinatesSystem(string CoordinateSystem); - void setNodesNumbers(int * NodeNumber); - - int* getNodesNumbers() const; - int* getNodesNumbers() ; + void setCoordinates(const medModeSwitch Mode, const double *Coordinate); + void setCoordinatesNames(const string * CoordinateName); + void setCoordinateName(const string CoordinateName, const int i); + void setCoordinatesUnits(const string * CoordinateUnit); + void setCoordinateUnit(const string CoordinateUnit, const int i); + void setCoordinatesSystem(const string CoordinateSystem); + void setNodesNumbers(const int * NodeNumber); + + int getSpaceDimension() const; + int getNumberOfNodes() const; + + const int* getNodesNumbers() const; + //const int* getNodesNumbers() ; string getCoordinatesSystem() const; + const double * getCoordinates(medModeSwitch Mode); - double getCoordinate(int Number,int Axis); - // return coordinate of node number Number, on axis Axis (1: X, 2: Y, 3: Z) - const double * getCoordinateAxis(int Axis); - // return all nodes coordinates from axis Axis - string * getCoordinatesNames(); - string getCoordinateName(int Axis); - string * getCoordinatesUnits(); - string getCoordinateUnit(int Axis); + double getCoordinate(int Number,int Axis); + const double * getCoordinateAxis(int Axis); + + const string * getCoordinatesNames() const; + string getCoordinateName(int Axis) const; + const string * getCoordinatesUnits() const; + string getCoordinateUnit(int Axis) const; }; #endif /* COORDINATE_HXX */ diff --git a/src/MEDMEM/MEDMEM_DriversDef.cxx b/src/MEDMEM/MEDMEM_DriversDef.cxx index aaeb69ba5..9ca1920f2 100644 --- a/src/MEDMEM/MEDMEM_DriversDef.cxx +++ b/src/MEDMEM/MEDMEM_DriversDef.cxx @@ -1,11 +1,38 @@ +// 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_DriversDef.cxx +// Module : MED + using namespace std; #include "MEDMEM_DriversDef.hxx" -namespace MED_FR { +namespace MED_FR +{ // Returns the (string) name of the geometry of // an element given by a med_geometrie_element value -GEO_NAME::GEO_NAME () : map() +GEO_NAME::GEO_NAME() : map() { map &table = (map&)*this ; table[(int)0 ] = "MED_NONE" ; @@ -38,7 +65,7 @@ string & GEO_NAME::operator[]( const med_geometrie_element &c ) const // Returns the (string) name of the type of // an entity given by a med_entite_maillage value -ENT_NAME:: ENT_NAME () : map() +ENT_NAME::ENT_NAME() : map() { map &table = (map&)*this ; table[(int)MED_MAILLE ] = "MED_MAILLE"; diff --git a/src/MEDMEM/MEDMEM_Family.hxx b/src/MEDMEM/MEDMEM_Family.hxx index 58fdf5e90..02a40a729 100644 --- a/src/MEDMEM/MEDMEM_Family.hxx +++ b/src/MEDMEM/MEDMEM_Family.hxx @@ -1,42 +1,126 @@ +// 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.hxx +// Module : MED + #ifndef FAMILY_HXX #define FAMILY_HXX #include #include "MEDMEM_Support.hxx" +/*! + + This class describe a family of elements on an entity./n + It inherits from support. /n + It contains a list of elements (by SUPPORT class inheritance) + and a description of some attributs./n + + All families on one entity represent a mesh partition for this entity. + +*/ + class FAMILY : public SUPPORT { protected : - /*! Identifier of the family in the mesh - Note : There is precisely one for each family. */ + /*! + \if developper + Identifier of the family in the mesh + Note : There is precisely one for each family. + \endif + */ int _identifier ; - /*! Number of attribute of the family */ + /*! + \if developper + Number of attribute of the family ./n + Note that attributes are numbered from 1 to N. + \endif + */ int _numberOfAttribute ; - /*! Array of all attributes' identifiers. - There is one for each attribute. */ + /*! + \if developper + Array of all attributes' identifiers. + There is one for each attribute. + \endif + */ int * _attributeIdentifier ; - /*! Array of all attributes' values. - There is one for each attribute. */ + /*! + \if developper + Array of all attributes' values. + There is one for each attribute. + \endif + */ int * _attributeValue ; - /*! Array of all attributes' descriptions. - There is one for each attribute. */ + /*! + \if developper + Array of all attributes' descriptions. + There is one for each attribute. + \endif + */ string * _attributeDescription ; - - /*! Number of the group the family belongs to */ + /*! + \if developper + Number of the group the family belongs to. + \endif + */ int _numberOfGroup ; - /*! Name of the group the family belongs to */ + /*! + \if developper + Name of the group the family belongs to. + \endif + */ string * _groupName ; public: + /*! Constructor. */ FAMILY(); + /*! + \if developper + Constructor to use with med driver. + */ + FAMILY( MESH* Mesh, int Identifier, string Name, + int NumberOfAttribute, int *AttributeIdentifier, + int *AttributeValue, string AttributeDescription, + int NumberOfGroup, string GroupName, + int * MEDArrayNodeFamily, + int ** MEDArrayCellFamily, + int ** MEDArrayFaceFamily, + int ** MEDArrayEdgeFamily + ) ; - // constructor to use with med driver - FAMILY(MESH* Mesh, int Identifier, string Name, int NumberOfAttribute,int *AttributeIdentifier,int *AttributeValue,string AttributeDescription,int NumberOfGroup,string GroupName) ; + /*! Copy Constructor. */ + FAMILY(const FAMILY & m); - FAMILY(FAMILY & m); + /*! Constructor with SUPPORT entry. */ + FAMILY(const SUPPORT & s); + /*! Destructor. */ ~FAMILY(); FAMILY & operator=(const FAMILY &fam); + friend ostream & operator<<(ostream &os, FAMILY &my) ; + + bool build(medEntityMesh Entity,int **FamilyNumber); inline void setIdentifier (int Identifier); inline void setNumberOfAttributes (int NumberOfAttribute); @@ -63,7 +147,7 @@ public: // inline methods : -/* Set the attribute _identifier to Identifier. */ +/*! Sets the attribute _identifier to Identifier. */ //---------------------------------------------- inline void FAMILY::setIdentifier(int Identifier) //---------------------------------------------- @@ -71,7 +155,7 @@ inline void FAMILY::setIdentifier(int Identifier) _identifier = Identifier; } -/* Set the attribute _numberOfAttribute to NumberOfAttribute. */ +/*! Sets the attribute _numberOfAttribute to NumberOfAttribute. */ //-------------------------------------------------------------- inline void FAMILY::setNumberOfAttributes(int NumberOfAttribute) //-------------------------------------------------------------- @@ -79,7 +163,7 @@ inline void FAMILY::setNumberOfAttributes(int NumberOfAttribute) _numberOfAttribute = NumberOfAttribute; } -/* Set the attribute _attributeIdentifier to AttributeIdentifier. */ +/*! Sets the attribute _attributeIdentifier to AttributeIdentifier. */ //--------------------------------------------------------------------- inline void FAMILY::setAttributesIdentifiers(int * AttributeIdentifier) //--------------------------------------------------------------------- @@ -87,7 +171,7 @@ inline void FAMILY::setAttributesIdentifiers(int * AttributeIdentifier) _attributeIdentifier = AttributeIdentifier ; } -/* Set the attribute _attributeValue to AttributeValue. */ +/*! Sets the attribute _attributeValue to AttributeValue. */ //----------------------------------------------------------- inline void FAMILY::setAttributesValues(int * AttributeValue) //----------------------------------------------------------- @@ -95,7 +179,7 @@ inline void FAMILY::setAttributesValues(int * AttributeValue) _attributeValue = AttributeValue ; } -/* Set the attribute _identifier to Identifier. */ +/*! Sets the attribute _attributeDescription to AttributeDescription. */ //-------------------------------------------------------------------------- inline void FAMILY::setAttributesDescriptions(string * AttributeDescription) //-------------------------------------------------------------------------- @@ -103,7 +187,7 @@ inline void FAMILY::setAttributesDescriptions(string * AttributeDescription) _attributeDescription = AttributeDescription ; } -/* Set the attribute _identifier to Identifier. */ +/*! Sets the attribute _numberOfGroup to NumberOfGroups. */ //------------------------------------------------------- inline void FAMILY::setNumberOfGroups(int NumberOfGroups) //------------------------------------------------------- @@ -111,43 +195,55 @@ inline void FAMILY::setNumberOfGroups(int NumberOfGroups) _numberOfGroup = NumberOfGroups ; } -/* Set the attribute _identifier to Identifier. */ +/*! Sets the attribute _groupName to GroupName. */ //---------------------------------------------------- inline void FAMILY::setGroupsNames(string * GroupName) //---------------------------------------------------- { _groupName = GroupName ; } +/*! Returns the attribute _identifier./n + Note that there is one identifier precisely for each family. */ //-------------------------------------- inline int FAMILY::getIdentifier() const //-------------------------------------- { return _identifier ; } + +/*! Returns the number of attributes of the family. */ //---------------------------------------------- inline int FAMILY::getNumberOfAttributes() const //---------------------------------------------- { return _numberOfAttribute ; } +/*! Returns a pointer to attributes identifiers . + (There are _numberOfAttribute attributes) */ //--------------------------------------------------- inline int * FAMILY::getAttributesIdentifiers() const //--------------------------------------------------- { return _attributeIdentifier ; } +/*! Returns identifer of the Ith attribute of the family./n + Note that they are numbered from 1 to N */ //---------------------------------------------------- inline int FAMILY::getAttributeIdentifier(int i) const //---------------------------------------------------- { return _attributeIdentifier[i-1] ; } +/*! Returns a pointer to attributes values. + (There are _numberOfAttribute attributes)*/ //---------------------------------------------- inline int * FAMILY::getAttributesValues() const //---------------------------------------------- { return _attributeValue ; } +/*! Returns value of the Ith attribute of the family./n + Note that they are numbered from 1 to N */ //----------------------------------------------- inline int FAMILY::getAttributeValue(int i) const //----------------------------------------------- @@ -160,24 +256,30 @@ inline string * FAMILY::getAttributesDescriptions() const { return _attributeDescription ; } +/*! Returns description of the Ith attribute of the family/n + Note that they are numbered from 1 to N */ //-------------------------------------------------------- inline string FAMILY::getAttributeDescription(int i) const //-------------------------------------------------------- { return _attributeDescription[i-1] ; } +/*! Returns the number of groups the family belongs to.*/ //------------------------------------------ inline int FAMILY::getNumberOfGroups() const //------------------------------------------ { return _numberOfGroup; } +/*! Returns a pointer to the names of the groups the family belongs to */ //-------------------------------------------- inline string * FAMILY::getGroupsNames() const //-------------------------------------------- { return _groupName ; } +/*! Returns the name of the Ith group the family belongs to./n + Note that they are numbered from 1 to N*/ //--------------------------------------------- inline string FAMILY::getGroupName(int i) const //--------------------------------------------- diff --git a/src/MEDMEM/MEDMEM_Field.hxx b/src/MEDMEM/MEDMEM_Field.hxx index 42d404b58..419c10a4d 100644 --- a/src/MEDMEM/MEDMEM_Field.hxx +++ b/src/MEDMEM/MEDMEM_Field.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_Field.hxx +// Module : MED + /* File Field.hxx $Header$ @@ -22,100 +48,183 @@ using namespace MED_EN; -//class GENDRIVER; +/*! + + This class contains all the informations related with a template class FIELD : + - Components descriptions + - Time step description + - Location of the values (a SUPPORT class) + +*/ + class FIELD_ // GENERIC POINTER TO a template class FIELD { - protected: - string _name ; - string _description ; + bool _isRead ; + + /*! + \if developper + Field name. + \endif + */ + string _name ; + /*! + \if developper + Field description. + \endif + */ + string _description ; + /*! + \if developper + Pointer to the support the field deals with. + \endif + */ const SUPPORT * _support ; - int _numberOfComponents ; - int * _componentsTypes ; // array of size _numberOfComponents - // (constant, scalar, vector, tensor) - // we could use an array of integer to store - // numbers of values - // 1 for scalar, - // space dimension for vector, - // space dimension square for tensor. - // so numbers of values per entities are - // sum of _componentsTypes array - // Do not use yet! All type are scalar ! - string * _componentsNames; // array of size _numberOfComponents - string * _componentsDescriptions; // array of size _numberOfComponents - UNIT * _componentsUnits; // array of size _numberOfComponents - string * _MEDComponentsUnits; // array of size _numberOfComponents : - // get unit from med file - - int _iterationNumber ; - double _time; - int _orderNumber ; - - /*MED_EN::*/med_type_champ _valueType ; + + /*! + \if developper + Number of field's components. + \endif + */ + int _numberOfComponents ; + /*! + \if developper + Number of field's values. + \endif + */ + int _numberOfValues ; + + /*! + \if developper + Array of size _numberOfComponents. /n + (constant, scalar, vector, tensor)/n + We could use an array of integer to store + numbers of values: /n + - 1 for scalar,/n + - space dimension for vector,/n + - space dimension square for tensor./n + So numbers of values per entities would be + sum of _componentsTypes array. + + Not implemented yet! All type are scalar ! + \endif + */ + int * _componentsTypes ; + /*! + \if developper + Array of size _numberOfComponents + storing components names if any. + \endif + */ + string * _componentsNames; + /*! + \if developper + Array of size _numberOfComponents + storing components descriptions if any. + \endif + */ + string * _componentsDescriptions; + /*! + \if developper + Array of size _numberOfComponents + storing components units if any. + \endif + */ + UNIT * _componentsUnits; + /*! + \if developper + Array of size _numberOfComponents + storing components units if any. + \endif + */ + string * _MEDComponentsUnits; + int _iterationNumber ; + double _time; + int _orderNumber ; + + med_type_champ _valueType ; + + vector _drivers; // Storage of the drivers currently in use public: - + + friend class MED_MED_RDONLY_DRIVER; + friend class MED_MED_WRONLY_DRIVER; + friend class MED_MED_RDWR_DRIVER; + + /*! + Constructor. + */ FIELD_ (); + /*! + Constructor. + */ FIELD_(const SUPPORT * Support, const int NumberOfComponents); + /*! + Copy constructor. + */ FIELD_(const FIELD_ &m); + /*! + Destructor. + */ ~FIELD_(); // virtual void setIterationNumber (int IterationNumber); -// virtual void setOrderNumber (int OrderNumber); -// virtual void setFieldName (string& fieldName); +// virtual void setOrderNumber (int OrderNumber); +// virtual void setFieldName (string& fieldName); virtual void rmDriver(int index); - virtual int addDriver(driverTypes driverType, - const string & fileName, - const string & driverFieldName) ; + virtual int addDriver(driverTypes driverType, + const string & fileName="Default File Name.med", + const string & driverFieldName="Default Field Nam") ; virtual int addDriver( GENDRIVER & driver); - virtual void write(const GENDRIVER &); virtual void read (const GENDRIVER &); - - // virtual void getValueType (MED_FR::med_type_champ ValueType) ; - // virtual void setValueType (/*MED_EN::*/med_type_champ ValueType) ; - // virtual med_type_champ getValueType () ; + virtual void read(int index=0); + virtual void write(const GENDRIVER &); + virtual void write(int index=0, const string & driverName=""); inline void setName(string Name); inline string getName() const; inline void setDescription(string Description); - inline string getDescription()const; + inline string getDescription() const; inline const SUPPORT * getSupport() const; - inline void setSupport(SUPPORT * support); + inline void setSupport(SUPPORT * support); inline void setNumberOfComponents(int NumberOfComponents); inline int getNumberOfComponents() const; + inline void setNumberOfValues(int NumberOfValues); + inline int getNumberOfValues() const; // inline void setComponentType(int *ComponentType); // inline int * getComponentType() const; // inline int getComponentTypeI(int i) const; inline void setComponentsNames(string * ComponentsNames); - inline void setComponentName(int i, string ComponentName); - inline string * getComponentsNames() const; + inline void setComponentName(int i, string ComponentName); + inline const string * getComponentsNames() const; inline string getComponentName(int i) const; inline void setComponentsDescriptions(string *ComponentsDescriptions); inline void setComponentDescription(int i, string ComponentDescription); - inline string * getComponentsDescriptions() const; + inline const string * getComponentsDescriptions() const; inline string getComponentDescription(int i) const; // provisoire : en attendant de regler le probleme des unites ! inline void setComponentsUnits(UNIT * ComponentsUnits); - inline UNIT * getComponentsUnits() const; - inline UNIT * getComponentUnit(int i) const; + inline const UNIT * getComponentsUnits() const; + inline const UNIT * getComponentUnit(int i) const; inline void setMEDComponentsUnits(string * MEDComponentsUnits); inline void setMEDComponentUnit(int i, string MEDComponentUnit); - inline string * getMEDComponentsUnits() const; + inline const string * getMEDComponentsUnits() const; inline string getMEDComponentUnit(int i) const; inline void setIterationNumber(int IterationNumber); inline int getIterationNumber() const; inline void setTime(double Time); inline double getTime() const; - inline void setOrderNumber(int OrderNumber); + inline void setOrderNumber(int OrderNumber); inline int getOrderNumber() const; - inline void setValueType (/*MED_EN::*/med_type_champ ValueType) ; - inline /*MED_EN::*/med_type_champ getValueType () ; + inline void setValueType (med_type_champ ValueType) ; + inline med_type_champ getValueType () const; }; @@ -126,143 +235,298 @@ public: // ----------------- // Methodes Inline // ----------------- - +/*! + Set FIELD name. +*/ inline void FIELD_::setName(string Name) { _name=Name; } -inline string FIELD_::getName() const +/*! + Get FIELD name. +*/ +inline string FIELD_::getName() const { return _name; } +/*! + Set FIELD description. +*/ inline void FIELD_::setDescription(string Description) { _description=Description; } -inline string FIELD_::getDescription() const +/*! + Get FIELD description. +*/ +inline string FIELD_::getDescription() const { return _description; } +/*! + Set FIELD number of components. +*/ inline void FIELD_::setNumberOfComponents(int NumberOfComponents) { _numberOfComponents=NumberOfComponents; -} -inline int FIELD_::getNumberOfComponents() const -{ - return _numberOfComponents ; -} -// inline void FIELD_::setComponentType(int *ComponentType) -// { -// _componentsTypes=ComponentType ; +} +/*! + Get FIELD number of components. +*/ +inline int FIELD_::getNumberOfComponents() const +{ + return _numberOfComponents ; +} +/*! + Set FIELD number of values. + + It must be the same than in the associated SUPPORT object. +*/ +inline void FIELD_::setNumberOfValues(int NumberOfValues) +{ + _numberOfValues=NumberOfValues; +} +/*! + Get FIELD number of value. +*/ +inline int FIELD_::getNumberOfValues() const +{ + return _numberOfValues ; +} + +// inline void FIELD_::setComponentType(int *ComponentType) +// { +// _componentsTypes=ComponentType ; // } -// inline int * FIELD_::getComponentType() const -// { -// return _componentsTypes ; +// inline int * FIELD_::getComponentType() const +// { +// return _componentsTypes ; // } -// inline int FIELD_::getComponentTypeI(int i) const -// { -// return _componentsTypes[i-1] ; +// inline int FIELD_::getComponentTypeI(int i) const +// { +// return _componentsTypes[i-1] ; // } -inline void FIELD_::setComponentsNames(string * ComponentsNames) -{ - _componentsNames=ComponentsNames ; + +/*! + Set FIELD components names. + + Duplicate the ComponentsNames string array to put components names in + FIELD. ComponentsNames size must be equal to number of components. +*/ +inline void FIELD_::setComponentsNames(string * ComponentsNames) +{ + if (NULL == _componentsNames) + _componentsNames = new string[_numberOfComponents] ; + for (int i=0; i<_numberOfComponents; i++) + _componentsNames[i]=ComponentsNames[i] ; } -inline void FIELD_::setComponentName(int i, string ComponentName) -{ - _componentsNames[i-1]=ComponentName ; +/*! + Set FIELD i^th component name. + + i must be >=1 and <= number of components. +*/ +inline void FIELD_::setComponentName(int i, string ComponentName) +{ + _componentsNames[i-1]=ComponentName ; } -inline string * FIELD_::getComponentsNames() const -{ - return _componentsNames ; +/*! + Get a reference to the string array which contain the components names. + + This Array size is equal to number of components +*/ +inline const string * FIELD_::getComponentsNames() const +{ + return _componentsNames ; } -inline string FIELD_::getComponentName(int i) const -{ - return _componentsNames[i-1] ; +/*! + Get the name of the i^th component. +*/ +inline string FIELD_::getComponentName(int i) const +{ + return _componentsNames[i-1] ; } -inline void FIELD_::setComponentsDescriptions(string *ComponentsDescriptions) -{ - _componentsDescriptions=ComponentsDescriptions ; +/*! + Set FIELD components descriptions. + + Duplicate the ComponentsDescriptions string array to put components + descriptions in FIELD. + ComponentsDescriptions size must be equal to number of components. +*/ +inline void FIELD_::setComponentsDescriptions(string *ComponentsDescriptions) +{ + if (NULL == _componentsDescriptions) + _componentsDescriptions = new string[_numberOfComponents] ; + for (int i=0; i<_numberOfComponents; i++) + _componentsDescriptions[i]=ComponentsDescriptions[i] ; } +/*! + Set FIELD i^th component description. + + i must be >=1 and <= number of components. +*/ inline void FIELD_::setComponentDescription(int i,string ComponentDescription) -{ - _componentsDescriptions[i-1]=ComponentDescription ; +{ + _componentsDescriptions[i-1]=ComponentDescription ; } -inline string * FIELD_::getComponentsDescriptions() const -{ - return _componentsDescriptions ; +/*! + Get a reference to the string array which contain the components descriptions. + + This Array size is equal to number of components +*/ +inline const string * FIELD_::getComponentsDescriptions() const +{ + return _componentsDescriptions ; } +/*! + Get the description of the i^th component. +*/ inline string FIELD_::getComponentDescription(int i) const -{ - return _componentsDescriptions[i-1]; -} -inline void FIELD_::setComponentsUnits(UNIT * ComponentsUnits) -{ - _componentsUnits=ComponentsUnits ; -} -inline UNIT * FIELD_::getComponentsUnits() const -{ - return _componentsUnits ; -} -inline UNIT * FIELD_::getComponentUnit(int i) const -{ - return &_componentsUnits[i-1] ; -} -inline void FIELD_::setMEDComponentsUnits(string * MEDComponentsUnits) -{ - _MEDComponentsUnits=MEDComponentsUnits ; -} -inline void FIELD_::setMEDComponentUnit(int i, string MEDComponentUnit) -{ - _MEDComponentsUnits[i-1]=MEDComponentUnit ; -} -inline string * FIELD_::getMEDComponentsUnits() const -{ - return _MEDComponentsUnits ; -} -inline string FIELD_::getMEDComponentUnit(int i) const -{ - return _MEDComponentsUnits[i-1] ; -} -inline void FIELD_::setIterationNumber(int IterationNumber) -{ - _iterationNumber=IterationNumber; -} -inline int FIELD_::getIterationNumber() const -{ - return _iterationNumber ; -} -inline void FIELD_::setTime(double Time) -{ - _time=Time ; -} -inline double FIELD_::getTime() const -{ - return _time ; -} -inline void FIELD_::setOrderNumber(int OrderNumber) -{ - _orderNumber=OrderNumber ; -} -inline int FIELD_::getOrderNumber() const -{ +{ + return _componentsDescriptions[i-1]; +} + +/*! + \todo + Set FIELD components UNIT. + + Duplicate the ComponentsUnits UNIT array to put components + units in FIELD. + ComponentsUnits size must be equal to number of components. +*/ +inline void FIELD_::setComponentsUnits(UNIT * ComponentsUnits) +{ + if (NULL == _componentsUnits) + _componentsUnits = new UNIT[_numberOfComponents] ; + for (int i=0; i<_numberOfComponents; i++) + _componentsUnits[i]=ComponentsUnits[i] ; +} +/*! + Get a reference to the UNIT array which contain the components units. + + This Array size is equal to number of components +*/ +inline const UNIT * FIELD_::getComponentsUnits() const +{ + return _componentsUnits ; +} +/*! + Get the UNIT of the i^th component. +*/ +inline const UNIT * FIELD_::getComponentUnit(int i) const +{ + return &_componentsUnits[i-1] ; +} +/*! + Set FIELD components unit. + + Duplicate the MEDComponentsUnits string array to put components + units in FIELD. + MEDComponentsUnits size must be equal to number of components. + +*/ +inline void FIELD_::setMEDComponentsUnits(string * MEDComponentsUnits) +{ + if (NULL == _MEDComponentsUnits) + _MEDComponentsUnits = new string[_numberOfComponents] ; + for (int i=0; i<_numberOfComponents; i++) + _MEDComponentsUnits[i]=MEDComponentsUnits[i] ; +} +/*! + Set FIELD i^th component unit. + + i must be >=1 and <= number of components. +*/ +inline void FIELD_::setMEDComponentUnit(int i, string MEDComponentUnit) +{ + _MEDComponentsUnits[i-1]=MEDComponentUnit ; +} +/*! + Get a reference to the string array which contain the components units. + + This Array size is equal to number of components +*/ +inline const string * FIELD_::getMEDComponentsUnits() const +{ + return _MEDComponentsUnits ; +} +/*! + Get the string for unit of the i^th component. +*/ +inline string FIELD_::getMEDComponentUnit(int i) const +{ + return _MEDComponentsUnits[i-1] ; +} +/*! + Set the iteration number where FIELD has been calculated. +*/ +inline void FIELD_::setIterationNumber(int IterationNumber) +{ + _iterationNumber=IterationNumber; +} +/*! + Get the iteration number where FIELD has been calculated. +*/ +inline int FIELD_::getIterationNumber() const +{ + return _iterationNumber ; +} +/*! + Set the time (in second) where FIELD has been calculated. +*/ +inline void FIELD_::setTime(double Time) +{ + _time=Time ; +} +/*! + Get the time (in second) where FIELD has been calculated. +*/ +inline double FIELD_::getTime() const +{ + return _time ; +} +/*! + Set the order number where FIELD has been calculated. + + It corresponds to internal iteration during one time step. +*/ +inline void FIELD_::setOrderNumber(int OrderNumber) +{ + _orderNumber=OrderNumber ; +} +/*! + Get the order number where FIELD has been calculated. +*/ +inline int FIELD_::getOrderNumber() const +{ return _orderNumber ; } +/*! + Get a reference to the SUPPORT object associated to FIELD. +*/ inline const SUPPORT * FIELD_::getSupport() const { return _support ; } +/*! + Set the reference to the SUPPORT object associated to FIELD. + Reference is not duplicate, so it must not be deleted. +*/ inline void FIELD_::setSupport(SUPPORT * support) { _support = support ; } - -inline /*MED_EN::*/med_type_champ FIELD_::getValueType () +/*! + Get the FIELD med value type (MED_INT32 or MED_REEL64). +*/ +inline med_type_champ FIELD_::getValueType () const { return _valueType ; } - -inline void FIELD_::setValueType (/*MED_EN::*/med_type_champ ValueType) +/*! + Set the FIELD med value type (MED_INT32 or MED_REEL64). +*/ +inline void FIELD_::setValueType (med_type_champ ValueType) { _valueType = ValueType ; } @@ -271,6 +535,13 @@ inline void FIELD_::setValueType (/*MED_EN::*/med_type_champ ValueType) // END OF CLASS FIELD_ // ///////////////////////// +/*! + + This template class contains informations related with a FIELD : + - Values of the field + +*/ + template class FIELD : public FIELD_ { @@ -278,31 +549,29 @@ template class FIELD : public FIELD_ protected: //-----------------------// - class INSTANCE + class INSTANCE //-----------------------// { public: virtual GENDRIVER * run(const string & fileName, FIELD * ptrFIELD) const = 0 ; } ; - + //-------------------------------------------------------// - template class INSTANCE_DE : public INSTANCE + template class INSTANCE_DE : public INSTANCE //-------------------------------------------------------// { public : - GENDRIVER * run(const string & fileName, FIELD * ptrFIELD) const - { - return new T2(fileName,ptrFIELD); + GENDRIVER * run(const string & fileName, FIELD * ptrFIELD) const + { + return new T2(fileName,ptrFIELD); } } ; - + // static INSTANCE_DE inst_med_rdonly ; static INSTANCE_DE > inst_med ; static const INSTANCE * const instances[] ; // ------ End of Drivers Management Part - - vector _drivers; // Storage of the drivers currently in use // array of value of type T MEDARRAY *_value ; @@ -317,15 +586,15 @@ public: FIELD(const SUPPORT * Support, const int NumberOfComponents); // Ajout NB Constructeur FIELD avec allocation de memoire de tous ses attribut FIELD(const SUPPORT * Support, driverTypes driverType, const string & fileName="", const string & fieldName=""); - ~FIELD(); + ~FIELD(); friend class MED_FIELD_RDONLY_DRIVER; friend class MED_FIELD_WRONLY_DRIVER; - friend class MED_FIELD_RDWR_DRIVER ; + //friend class MED_FIELD_RDWR_DRIVER ; void init (); void rmDriver(int index=0); - int addDriver(driverTypes driverType, + int addDriver(driverTypes driverType, const string & fileName="Default File Name.med", const string & driverFieldName="Default Field Name") ; int addDriver(GENDRIVER & driver); @@ -334,118 +603,201 @@ public: void allocValue(const int NumberOfComponents, const int LengthValue); void deallocValue(); - - inline void read(int index=0); - inline void read(const GENDRIVER & genDriver); + + inline void read(int index=0); + inline void read(const GENDRIVER & genDriver); inline void write(int index=0, const string & driverName = ""); inline void write(const GENDRIVER &); inline void setValue(MEDARRAY *Value); - inline T* getValue(medModeSwitch Mode) const; - inline T* getValueI(medModeSwitch Mode,int i) const; + inline MEDARRAY* getvalue() const; + inline const T* getValue(medModeSwitch Mode) const; + inline const T* getValueI(medModeSwitch Mode,int i) const; inline T getValueIJ(int i,int j) const; inline void setValue(medModeSwitch mode, T* value); inline void setValueI(medModeSwitch mode, int i, T* value); inline void setValueIJ(int i, int j, T value); + + /*! + This fonction feeds the FIELD private attributs _value with the + volume of each cells belonging to the argument Support. The field has to be + initialised via the constructor FIELD(const SUPPORT * , const int ) + with Support as SUPPORT argument, 1 has the number of components, and Support + has be a SUPPORT on 3D cells. This initialisation could be done by the empty + constructor followed by a setSupport and setNumberOfComponents call but it has + be followed by a setValueType(MED_REEL64) call. + */ + void getVolume() const throw (MEDEXCEPTION) ; + /*! + This fonction feeds the FIELD private attributs _value with the + area of each cells (or faces) belonging to the attribut _support. The field + has to be initialised via the constructor FIELD(const SUPPORT * , + const int ) with 1 has the number of components, and _support has be a + SUPPORT on 2D cells or 3D faces. This initialisation could be done by the + empty constructor followed by a setSupport and setNumberOfComponents call but + it has be followed by a setValueType(MED_REEL64) call. + */ + void getArea() const throw (MEDEXCEPTION) ; + /*! + This fonction feeds the FIELD private attributs _value with the + length of each segments belonging to the attribut _support. The field has + to be initialised via the constructor FIELD(const SUPPORT * , + const int ) with 1 has the number of components, and _support has be a + SUPPORT on 3D edges or 2D faces. This initialisation could be done by the + empty constructor followed by a setSupport and setNumberOfComponents call but + it has be followed by a setValueType(MED_REEL64) call. + */ + void getLength() const throw (MEDEXCEPTION) ; + /*! + This fonction feeds the FIELD private attributs _value with the + normal vector of each faces belonging to the attribut _support. The field + has to be initialised via the constructor FIELD(const SUPPORT * , + const int ) with the space dimension has the number of components, and + _support has be a SUPPORT on 3D or 2D faces. This initialisation could be done + by the empty constructor followed by a setSupport and setNumberOfComponents + call but it has be followed by a setValueType(MED_REEL64) call. + */ + void getNormal() const throw (MEDEXCEPTION) ; + /*! + This fonction feeds the FIELD private attributs _value with the + barycenter of each faces or cells or edges belonging to the attribut _support. + The field has to be initialised via the constructor + FIELD(const SUPPORT * ,const int ) with the space dimension has the + number of components, and _support has be a SUPPORT on 3D cells or 2D faces. + This initialisation could be done by the empty constructor followed by a + setSupport and setNumberOfComponents call but it has be followed by a + setValueType(MED_REEL64) call. + */ + void getBarycenter() const throw (MEDEXCEPTION) ; }; // -------------------- -// Implemented Methods +// Implemented Methods // -------------------- -template FIELD::FIELD(): +/*! + Constructor. +*/ +template FIELD::FIELD(): _value((MEDARRAY*)NULL) { MESSAGE("Constructeur FIELD sans parametre"); } +/*! + Constructor. +*/ template FIELD::FIELD(const SUPPORT * Support, const int NumberOfComponents): FIELD_(Support, NumberOfComponents) { BEGIN_OF("FIELD::FIELD(const SUPPORT * Support, const int NumberOfComponents)"); - - int length = 0 ; + try { - length = Support->getNumberOfElements(MED_ALL_ELEMENTS); + _numberOfValues = Support->getNumberOfElements(MED_ALL_ELEMENTS); } catch (MEDEXCEPTION &ex) { MESSAGE("No value defined ! ("<*)NULL ; } - MESSAGE("FIELD : constructeur : "<::MEDARRAY(NumberOfComponents,length); - else + MESSAGE("FIELD : constructeur : "<< _numberOfValues <<" et "<< NumberOfComponents); + if (0<_numberOfValues) { + _value = new MEDARRAY::MEDARRAY(_numberOfComponents,_numberOfValues); + _isRead = true ; + } else _value = (MEDARRAY*)NULL ; END_OF("FIELD::FIELD(const SUPPORT * Support, const int NumberOfComponents)"); } +/*! + \if developper + \endif +*/ template void FIELD::init () { } +/*! + Copy constructor. +*/ template FIELD::FIELD(const FIELD & m): FIELD_((FIELD_) m) { if (m._value != NULL) { - _value = new MEDARRAY::MEDARRAY(* m._value); + // copie only default ! + _value = new MEDARRAY::MEDARRAY(* m._value,false); } else _value = (MEDARRAY *) NULL; - _drivers = m._drivers; + //_drivers = m._drivers; } -template FIELD & FIELD::FIELD::operator=(const FIELD &m) +/*! + +*/ +template FIELD & FIELD::operator=(const FIELD &m) { } +/*! + Constructor. +*/ template FIELD::FIELD(const SUPPORT * Support, - driverTypes driverType, - const string & fileName/*=""*/, + driverTypes driverType, + const string & fileName/*=""*/, const string & fieldDriverName/*=""*/) { - const char * LOC = "template FIELD::FIELD(const SUPPORT * Support, driverTypes driverType, const string & fileName="", const string & fieldName="") : "; - + const char * LOC = "template FIELD::FIELD(const SUPPORT * Support, driverTypes driverType, const string & fileName=\"\", const string & fieldName=\"\") : "; + int current; - + BEGIN_OF(LOC); - + init(); _support = Support; _value = (MEDARRAY*)NULL; - current = addDriver(driverType,fileName,fieldDriverName); - switch(_drivers[current]->getAccessMode() ) { - case MED_RDONLY : { - MESSAGE("MESH::MESH(driverTypes driverType, .....) : driverType must have a MED_RDWR accessMode"); - rmDriver(current); - break;} - default : { - } - } - _drivers[current]->open(); + MED_FIELD_RDONLY_DRIVER myDriver(fileName,this); + myDriver.setFieldName(fieldDriverName); + current = addDriver(myDriver); +// current = addDriver(driverType,fileName,fieldDriverName); +// switch(_drivers[current]->getAccessMode() ) { +// case MED_WRONLY : { +// MESSAGE("FIELD::FIELD(driverTypes driverType, .....) : driverType must have a MED_RDONLY or MED_RDWR accessMode"); +// rmDriver(current); +// break;} +// default : { +// } +// } + _drivers[current]->open(); _drivers[current]->read(); _drivers[current]->close(); - END_OF(LOC); + END_OF(LOC); } -template FIELD::~FIELD() -{ +/*! + Destructor. +*/ +template FIELD::~FIELD() +{ BEGIN_OF(" Destructeur FIELD::~FIELD()"); if (_value) delete _value; END_OF(" Destructeur FIELD::~FIELD()"); } +/*! + +*/ template void FIELD::allocValue(const int NumberOfComponents) { - BEGIN_OF("void FIELD::allocValue(const int NumberOfComponents)"); + const char* LOC = "FIELD::allocValue(const int NumberOfComponents)" ; + BEGIN_OF(LOC); _numberOfComponents = NumberOfComponents ; if (_componentsTypes == NULL) @@ -463,10 +815,12 @@ template void FIELD::allocValue(const int NumberOfComponents) } try { - int length = _support->getNumberOfElements(MED_ALL_ELEMENTS); - MESSAGE("FIELD : constructeur : "<::MEDARRAY(NumberOfComponents,length); + _numberOfValues = _support->getNumberOfElements(MED_ALL_ELEMENTS); + MESSAGE(LOC <<" : "<<_numberOfValues <<" et "<< NumberOfComponents); + + _value = new MEDARRAY::MEDARRAY(_numberOfComponents,_numberOfValues); + + _isRead = true ; } catch (MEDEXCEPTION &ex) { MESSAGE("No value defined, problem with NumberOfComponents (and may be _support) size of MEDARRAY::_value !"); @@ -477,6 +831,9 @@ template void FIELD::allocValue(const int NumberOfComponents) END_OF("void FIELD::allocValue(const int NumberOfComponents)"); } +/*! + +*/ template void FIELD::allocValue(const int NumberOfComponents, const int LengthValue) { BEGIN_OF("void FIELD::allocValue(const int NumberOfComponents,const int LengthValue)"); @@ -497,18 +854,24 @@ template void FIELD::allocValue(const int NumberOfComponents, const } MESSAGE("FIELD : constructeur : "<::MEDARRAY(NumberOfComponents,LengthValue); + _numberOfValues = LengthValue ; + _value = new MEDARRAY::MEDARRAY(_numberOfComponents,_numberOfValues); + _isRead = true ; SCRUTE(_value); END_OF("void FIELD::allocValue(const int NumberOfComponents,const int LengthValue)"); } +/*! + +*/ template void FIELD::deallocValue() { BEGIN_OF("void FIELD::deallocValue()"); - - delete _value; + _numberOfValues = 0 ; + _numberOfComponents = 0 ; + if (_value != NULL) + delete _value; END_OF("void FIELD::deallocValue()"); } @@ -522,21 +885,25 @@ template FIELD::INSTANCE_DE > FI template const FIELD::INSTANCE * const FIELD::instances[] = { &FIELD::inst_med } ; -template int FIELD::addDriver(driverTypes driverType, +/*! + Create the specified driver and return its index reference to path to + read or write methods. +*/ +template int FIELD::addDriver(driverTypes driverType, const string & fileName/*="Default File Name.med"*/, const string & driverName/*="Default Field Name"*/) { const char * LOC = "FIELD::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Field Name\") : "; - + GENDRIVER * driver; int current; BEGIN_OF(LOC); - + driver = instances[driverType]->run(fileName, this) ; _drivers.push_back(driver); current = _drivers.size()-1; - + _drivers[current]->setFieldName(driverName); return current; @@ -545,138 +912,321 @@ template int FIELD::addDriver(driverTypes driverType, } +/*! + Duplicate the given driver and return its index reference to path to + read or write methods. +*/ template inline int FIELD::addDriver (GENDRIVER & driver ) { const char * LOC = "FIELD::addDriver(GENDRIVER &) : "; BEGIN_OF(LOC); - - _drivers.push_back(&driver); + + // duplicate driver to delete it with destructor ! + GENDRIVER * newDriver = driver.copy() ; + + _drivers.push_back(newDriver); return _drivers.size() -1 ; END_OF(LOC); }; +/*! + Remove the driver referenced by its index. +*/ template void FIELD::rmDriver (int index/*=0*/) { const char * LOC = "FIELD::rmDriver (int index=0): "; BEGIN_OF(LOC); - + if ( _drivers[index] ) { - //_drivers.erase(&_drivers[index]); + //_drivers.erase(&_drivers[index]); // why not ???? MESSAGE ("detruire"); } 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); } - -template inline void FIELD::read(int index/*=0*/) -{ + +/*! + Read FIELD in the file specified in the driver given by its index. +*/ +template inline void FIELD::read(int index/*=0*/) +{ const char * LOC = "FIELD::read(int index=0) : "; BEGIN_OF(LOC); if ( _drivers[index] ) { - _drivers[index]->open(); + _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() + throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) + << "The index given is invalid, index must be between 0 and |" + << _drivers.size() ) - ); + ); END_OF(LOC); } -template inline void FIELD::write(int index/*=0*/, const string & driverName /*= ""*/) -{ +/*! + Write FIELD in the file specified in the driver given by its index. +*/ +template inline void FIELD::write(int index/*=0*/, const string & driverName /*= ""*/) +{ const char * LOC = "FIELD::write(int index=0, const string & driverName = \"\") : "; BEGIN_OF(LOC); if( _drivers[index] ) { - _drivers[index]->open(); - if (driverName != "") _drivers[index]->setFieldName(driverName); + _drivers[index]->open(); + if (driverName != "") _drivers[index]->setFieldName(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); } -template inline void FIELD::write(const GENDRIVER & genDriver) -{ +/*! + \internal + Write FIELD with the driver which is equal to the given driver. + + Use by MED object. +*/ +template inline void FIELD::write(const GENDRIVER & genDriver) +{ const char * LOC = " FIELD::write(const 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(); } - + END_OF(LOC); - -} -template inline void FIELD::read(const GENDRIVER & genDriver) -{ +} + +/*! + \internal + Read FIELD with the driver which is equal to the given driver. + + Use by MED object. +*/ +template inline void FIELD::read(const GENDRIVER & genDriver) +{ const char * LOC = " FIELD::read(const GENDRIVER &) : "; BEGIN_OF(LOC); for (int index=0; index < _drivers.size(); index++ ) - if ( *_drivers[index] == genDriver ) { - _drivers[index]->open(); - _drivers[index]->read(); + if ( *_drivers[index] == genDriver ) { + _drivers[index]->open(); + _drivers[index]->read(); _drivers[index]->close(); } - + END_OF(LOC); - -} -template inline void FIELD::setValue(MEDARRAY *Value) -{ - _value=Value ; } -template inline T* FIELD::getValue(medModeSwitch Mode) const -{ - return _value->get(Mode) ; + +/*! + \if developper + Destroy the MEDARRAY in FIELD and put the new one without copy. + \endif +*/ +template inline void FIELD::setValue(MEDARRAY *Value) +{ + if (NULL != _value) delete _value ; + _value=Value ; +} + +/*! + \if developper + Return a reference to the MEDARRAY in FIELD. + \endif +*/ +template inline MEDARRAY* FIELD::getvalue() const +{ + return _value ; +} + +/*! + Return a reference to values array to read them. +*/ +template inline const T* FIELD::getValue(medModeSwitch Mode) const +{ + return _value->get(Mode) ; } -template inline T* FIELD::getValueI(medModeSwitch Mode,int i) const + +/*! + Return a reference to i^{th} row or column - component - (depend on Mode value) + of FIELD values array. +*/ +template inline const T* FIELD::getValueI(medModeSwitch Mode,int i) const { - return _value->getI(Mode,i) ; + if ( Mode == MED_FULL_INTERLACE ) + { + return _value->getRow(i) ; + } + ASSERT ( Mode == MED_NO_INTERLACE); + return _value->getColumn(i); } -template inline T FIELD::getValueIJ(int i,int j) const + +/*! + Return the value of i^{th} element and j^{th} component. +*/ +template inline T FIELD::getValueIJ(int i,int j) const { - return _value->getIJ(i,j) ; + return _value->getIJ(i,j) ; } +/*! + Copy new values array in FIELD according to the given mode. + + Array must have right size. If not results are unpredicable. +*/ template inline void FIELD::setValue(medModeSwitch mode, T* value) { _value->set(mode,value); } +/*! + Update values array in FIELD with the given ones according to specified mode. +*/ template inline void FIELD::setValueI(medModeSwitch mode, int i, T* value) { - _value->setI(mode,i,value); + // PROVISOIRE : + if (MED_FULL_INTERLACE == mode) + _value->setI(i,value); + else if (MED_NO_INTERLACE == mode) + _value->setJ(i,value); + else + throw MEDEXCEPTION(LOCALIZED("FIELD::setValueI : bad medModeSwitch")) ; } +/*! + Set the value of i^{th} element and j^{th} component with the given one. +*/ template inline void FIELD::setValueIJ(int i, int j, T value) { _value->setIJ(i,j,value); } +/* + METHODS +*/ + +/*! + Fill values array with volume values. +*/ +template void FIELD::getVolume() const throw (MEDEXCEPTION) +{ + const char * LOC = "FIELD::getVolume() const : "; + BEGIN_OF(LOC); + + // The field has to be initilised by a non empty support and a + // number of components = 1 and its value type has to be set to MED_REEL64 + // (ie a FIELD) + + if ((_support == (SUPPORT *) NULL) || (_numberOfComponents != 1) || (_valueType != MED_REEL64)) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to 1 and a value type set to MED_REEL64")); + + END_OF(LOC); +} + +/*! + Fill values array with area values. +*/ +template void FIELD::getArea() const throw (MEDEXCEPTION) +{ + const char * LOC = "FIELD::getArea() const : "; + BEGIN_OF(LOC); + + // The field has to be initilised by a non empty support and a + // number of components = 1 and its value type has to be set to MED_REEL64 + // (ie a FIELD) + + if ((_support == (SUPPORT *) NULL) || (_numberOfComponents != 1) || (_valueType != MED_REEL64)) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to 1 and a value type set to MED_REEL64")); + + END_OF(LOC); +} + +/*! + Fill values array with length values. +*/ +template void FIELD::getLength() const throw (MEDEXCEPTION) +{ + const char * LOC = "FIELD::getLength() const : "; + BEGIN_OF(LOC); + + // The field has to be initilised by a non empty support and a + // number of components = 1 and its value type has to be set to MED_REEL64 + // (ie a FIELD) + + if ((_support == (SUPPORT *) NULL) || (_numberOfComponents != 1) || (_valueType != MED_REEL64)) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to 1 and a value type set to MED_REEL64")); + + END_OF(LOC); +} + +/*! + Fill values array with normal values. +*/ +template void FIELD::getNormal() const throw (MEDEXCEPTION) +{ + const char * LOC = "FIELD::getNormal() const : "; + BEGIN_OF(LOC); + + // The field has to be initilised by a non empty support and a + // number of components = 1 and its value type has to be set to MED_REEL64 + // (ie a FIELD) + + if (_support == (SUPPORT *) NULL) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to the space dimension and a value type set to MED_REEL64")); + + int dim_space = _support->getMesh()->getSpaceDimension(); + + if ((_numberOfComponents != dim_space) || (_valueType != MED_REEL64)) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to the space dimension and a value type set to MED_REEL64")); + + END_OF(LOC); +} + +/*! + Fill values array with barycenter values. +*/ +template void FIELD::getBarycenter() const throw (MEDEXCEPTION) +{ + const char * LOC = "FIELD::getBarycenter() const : "; + BEGIN_OF(LOC); + + // The field has to be initilised by a non empty support and a number of + //components = space dimension and its value type has to be set to MED_REEL64 + // (ie a FIELD) + + if (_support == (SUPPORT *) NULL) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to the space dimension and a value type set to MED_REEL64")); + + int dim_space = _support->getMesh()->getSpaceDimension(); + + if ((_numberOfComponents != dim_space) || (_valueType != MED_REEL64)) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to the space dimension and a value type set to MED_REEL64")); + + END_OF(LOC); +} + #endif /* FIELD_HXX */ diff --git a/src/MEDMEM/MEDMEM_Group.hxx b/src/MEDMEM/MEDMEM_Group.hxx index 6d8479c44..c19dcdbba 100644 --- a/src/MEDMEM/MEDMEM_Group.hxx +++ b/src/MEDMEM/MEDMEM_Group.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_Group.hxx +// Module : MED + /* File Group.hxx $Header$ @@ -13,21 +39,46 @@ class FAMILY; +/*! + + This class describe a group of elements on an entity./n + It inherits from SUPPORT./n + It is a blending of some FAMILY class./n/n + +*/ + class GROUP : public SUPPORT { protected : - /*! Number of families in the group */ + /*! + \if developper + Number of families in the group. + */ int _numberOfFamilies ; - /*! Vector of families in the group */ + /*! + \if developper + Vector of families in the group. + Note that Families are numbered from 1 to N. + */ vector _family ; public: + /*! Constructor. */ GROUP(); + /*! Constructor. */ GROUP(const string & name, const list & family) throw (MEDEXCEPTION) ; - GROUP(GROUP & m); + /*! Copy Constructor. */ + GROUP(const GROUP & m); + /*! Destructor. */ ~GROUP(); + + /*! Copy operator. */ + // PN ATTention il n y a pas de copie du vecteur Family ???? GROUP & operator=(const GROUP &group); - + + /*! Operator << */ + friend ostream & operator<<(ostream &os, GROUP &my) ; + inline void setNumberOfFamilies(int numberOfFamilies); inline void setFamilies(vector Family); @@ -35,7 +86,6 @@ public: inline vector getFamilies() const ; inline FAMILY * getFamily(int i) const ; -// void init(const list & family); }; // inline method : diff --git a/src/MEDMEM/MEDMEM_Med.hxx b/src/MEDMEM/MEDMEM_Med.hxx index e121452b5..7a5efb5cd 100644 --- a/src/MEDMEM/MEDMEM_Med.hxx +++ b/src/MEDMEM/MEDMEM_Med.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_Med.hxx +// Module : MED + # ifndef MED_HXX # define MED_HXX @@ -9,7 +35,11 @@ // LOCAL # include "MEDMEM_define.hxx" + +// Add your own driver header (step 2) # include "MEDMEM_MedMedDriver.hxx" +# include "MEDMEM_VtkMedDriver.hxx" + # include "MEDMEM_Exception.hxx" //using namespace MED_EN; @@ -38,21 +68,32 @@ typedef map MAP_DT_IT_; // - IN THE SECOND CASE THE USER BEGINS HIS WORK WITH A MESH OR A FIELD, // ?? GET A MED POINTER THEN CAN ADD MESHes OR FIELDs ?? // + +/*! + + This class is use to group together some MESH, SUPPORT and FIELD + objects. + +*/ + class MED { - friend class MED_MED_DRIVER; + // Add your personnal driver line (step 2) friend class MED_MED_RDONLY_DRIVER; + friend class MED_MED_WRONLY_DRIVER; + friend class MED_MED_RDWR_DRIVER; private: map _meshes; // We can't have two MESHes with the same meshName. - // The string key is a meshName. + // The string key is a meshName. - map _fields; // We can't have two FIELDs with the same fieldName. + map _fields; // We can't have two FIELD_s with the same fieldName. - map _meshName; // Get the meshName associated with a FIELD * - // in order to get the MESH* from _meshes + map _meshName; // Get the meshName associated with a FIELD_ * + // in order to get the MESH* from _meshes + // POURQUOI MED_FR::med_entite_maillage ? devrait être MED_EN ! map < MESH_NAME_, map > _support ; // For each MESH, we list support for each entity on all elements. @@ -67,9 +108,9 @@ public: // INUTILE : void addMesh (const string & meshName ); // Read the mesh found in the file <_fileName>. <_fileName> must be set. // INUTILE : void addField (const string & fieldName ); // Pensez au cas ou on ajoute un Field/Mesh avec un driver déjà existant. - void addField (const FIELD_ * const ptrField ) throw (MEDEXCEPTION) ; // Add an existing FIELD object to the FIELD list, the meshName is given by the FIELD object. - void addMesh (const MESH * ptrMesh ) throw (MEDEXCEPTION) ; // Add an existing MESH object to the MESH list, the meshName is given by the MESH object. - + void addField ( FIELD_ * const ptrField ) throw (MED_EXCEPTION) ; + void addMesh ( MESH * const ptrMesh ) throw (MED_EXCEPTION) ; + // ------ Drivers Management Part protected: @@ -80,40 +121,47 @@ protected: template class INSTANCE_DE : public INSTANCE { public : - GENDRIVER * run(const string & fileName, MED * const ptrMed) const { return new T(fileName,ptrMed) ; } + GENDRIVER * run(const string & fileName, MED * const ptrMed) const + { + MESSAGE("GENDRIVER * run") ; + return new T(fileName,ptrMed) ; + } } ; - static INSTANCE_DE inst_med ; - //static INSTANCE_DE inst_vtk ; + // Add your new driver instance here (step 3) + static INSTANCE_DE inst_med ; + static INSTANCE_DE inst_vtk ; static const INSTANCE * const instances[] ; public: int addDriver (driverTypes driverType, const string & fileName); int addDriver (GENDRIVER & driver); - void rmDriver (int index=0); - void readFileStruct(int index=0); - // void read (int index=0); - void writeFrom (int index=0); - void write (int index=0); + void rmDriver (int index=0) throw (MEDEXCEPTION) ; + + void readFileStruct(int index=0) throw (MEDEXCEPTION) ; + void read (int index=0) throw (MEDEXCEPTION) ; + void writeFrom (int index=0) throw (MEDEXCEPTION) ; + void write (int index=0) throw (MEDEXCEPTION) ; // ------ End Of Drivers Management Part int getNumberOfMeshes ( void ) const; int getNumberOfFields ( void ) const; - void getMeshNames ( string * meshNames ) const; - deque getMeshNames () const; - MESH * getMesh ( const string & meshName ) const; - MESH * getMesh ( const FIELD_ * field ) const; - void getFieldNames ( string * fieldNames ) const; - deque getFieldNames () const; + void getMeshNames ( string * meshNames ) const throw (MEDEXCEPTION) ; + deque getMeshNames () const; + MESH * getMesh ( const string & meshName ) const throw (MEDEXCEPTION) ; + MESH * getMesh ( const FIELD_ * const field ) const throw (MEDEXCEPTION) ; + void getFieldNames ( string * fieldNames ) const throw (MEDEXCEPTION) ; + deque getFieldNames () const; // A FAIRE DES ROUTINES QUI DONNENT LES PDT ET ITE - deque getFieldIteration (const string & fieldName) const ; + deque getFieldIteration (const string & fieldName) const throw (MEDEXCEPTION) ; FIELD_ * getField ( const string & fieldName, - const int dt, const int it) const; + const int dt, const int it) const throw (MEDEXCEPTION) ; + + const map & getSupports(const string & meshName) const throw (MEDEXCEPTION) ; - const map & getSupports(const string & meshName) const; - SUPPORT * getSupport (const string & meshName,MED_FR::med_entite_maillage entity) const ; + SUPPORT * getSupport (const string & meshName,MED_FR::med_entite_maillage entity) const throw (MEDEXCEPTION) ; void updateSupport () ; diff --git a/src/MEDMEM/MEDMEM_MedMeshDriver.hxx b/src/MEDMEM/MEDMEM_MedMeshDriver.hxx index 4a04f61aa..cae5ab857 100644 --- a/src/MEDMEM/MEDMEM_MedMeshDriver.hxx +++ b/src/MEDMEM/MEDMEM_MedMeshDriver.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_MedMeshDriver.hxx +// Module : MED + #ifndef MED_MESH_DRIVER_HXX #define MED_MESH_DRIVER_HXX @@ -15,6 +41,14 @@ class FAMILY; class GROUP; class CONNECTIVITY; +/*! + + Driver Med for MESH. + + Generic part : implement open and close methods. + +*/ + class MED_MESH_DRIVER : public GENDRIVER { protected: @@ -30,136 +64,199 @@ public : static const MED_FR::med_geometrie_element all_cell_type[MED_NBR_GEOMETRIE_MAILLE]; static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE]; - - MED_MESH_DRIVER():GENDRIVER(), - _ptrMesh(( MESH *)MED_NULL),_medIdt(MED_INVALID), - _meshName(""),_meshNum(MED_INVALID) - { - } - MED_MESH_DRIVER(const string & fileName, MESH * ptrMesh, med_mode_acces accessMode): - GENDRIVER(fileName,accessMode), - _ptrMesh(ptrMesh),_medIdt(MED_INVALID), - _meshName(""),_meshNum(MED_INVALID) - { - } - - void open() { - BEGIN_OF("MED_MESH_DRIVER::open()"); - _medIdt = MED_FR::MEDouvrir( (const_cast (_fileName.c_str())),(MED_FR::med_mode_acces) _accessMode); - MESSAGE("MED_MESH_DRIVER::open() _medIdt : "<< _medIdt ); - if (_medIdt > 0) _status=MED_OPENED; else { - MESSAGE(" MED_MESH__DRIVER::open() : MEDouvrir : _medIdt= " << _medIdt ); - _status = MED_INVALID; - } - END_OF("MED_MESH_DRIVER::open()"); - } - - void close() { - const char * LOC = "MED_MESH_DRIVER::close() " ; - BEGIN_OF(LOC); - med_int err = 0; - if ( _status == MED_OPENED) { - err=MED_FR::MEDfermer(_medIdt); - H5close(); // If we call H5close() all the files are closed. - if (err != 0) - throw MEDEXCEPTION( LOCALIZED(STRING(LOC) - <<" Error when closing file !" - ) - ); - MESSAGE(LOC <<": _medIdt= " << _medIdt ); - MESSAGE(LOC<<": MEDfermer : err = " << err ); - _status = MED_CLOSED; - _medIdt = MED_INVALID; - } - END_OF(LOC); - } + + /*! + Constructor. + */ + MED_MESH_DRIVER() ; + /*! + Constructor. + */ + MED_MESH_DRIVER(const string & fileName, + MESH * ptrMesh, + med_mode_acces accessMode) ; + /*! + Copy constructor. + */ + MED_MESH_DRIVER(const MED_MESH_DRIVER & driver) ; + + /*! + Destructor. + */ + virtual ~MED_MESH_DRIVER() ; + + void open() throw (MEDEXCEPTION); + void close() throw (MEDEXCEPTION); virtual void write( void ) const = 0 ; virtual void read ( void ) = 0 ; - + + /*! + Set the name of the MESH asked in file. + + It could be different than the name of the MESH object. + */ void setMeshName(const string & meshName) ; + /*! + Get the name of the MESH asked in file. + */ string getMeshName() const ; +private: + virtual GENDRIVER * copy ( void ) const = 0 ; + }; +/*! + + Driver Med for MESH : Read only. + + Implement read method. + +*/ + class MED_MESH_RDONLY_DRIVER : public virtual MED_MESH_DRIVER { public : - MED_MESH_RDONLY_DRIVER():MED_MESH_DRIVER() {}; - - MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh): - MED_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY) { - MESSAGE("MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); - } - - ~MED_MESH_RDONLY_DRIVER() { - MESSAGE("MED_MESH_RDONLY_DRIVER::~MED_MESH_RDONLY_DRIVER() has been destroyed"); - } + /*! + Constructor. + */ + MED_MESH_RDONLY_DRIVER() ; + /*! + Constructor. + */ + MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ; + /*! + Copy constructor. + */ + MED_MESH_RDONLY_DRIVER(const MED_MESH_RDONLY_DRIVER & driver) ; + + /*! + Destructor. + */ + virtual ~MED_MESH_RDONLY_DRIVER() ; // CREER UNE METHODE POUR LIRE LA LISTE DES MAILLAGES ..... + + /*! + Return a MEDEXCEPTION : it is the read-only driver. + */ + void write( void ) const throw (MEDEXCEPTION); + /*! + Read MESH in the specified file. + */ + void read ( void ) throw (MEDEXCEPTION); + +private: int getCOORDINATE(); int getCONNECTIVITY(); int getFAMILY(); - void write( void ) const ; - void read ( void ) ; - -private: int getNodalConnectivity(CONNECTIVITY * Connectivity) ; int getDescendingConnectivity(CONNECTIVITY * Connectivity) ; - int getNodesFamiliesNumber() ; + int getNodesFamiliesNumber(int * MEDArrayNodeFamily) ; int getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity) ; void updateFamily() ; void buildAllGroups(vector & Groups, vector & Families) ; - + void getGRID (); + + GENDRIVER * copy ( void ) const ; + }; +/*! + + Driver Med for MESH : Write only. + + Implement write method. + +*/ + class MED_MESH_WRONLY_DRIVER : public virtual MED_MESH_DRIVER { public : - MED_MESH_WRONLY_DRIVER():MED_MESH_DRIVER() {} - - MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh): - MED_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY) - { - MESSAGE("MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); - }; - - ~MED_MESH_WRONLY_DRIVER() { - MESSAGE("MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed"); - } - - void write( void ) const ; - void read ( void ) ; - - int writeCoordinates () const; - int writeConnectivities (medEntityMesh entity) const; - int writeFamilyNumbers () const; + /*! + Constructor. + */ + MED_MESH_WRONLY_DRIVER() ; + /*! + Constructor. + */ + MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) ; + /*! + Copy constructor. + */ + MED_MESH_WRONLY_DRIVER(const MED_MESH_WRONLY_DRIVER & driver) ; + + /*! + Destructor. + */ + virtual ~MED_MESH_WRONLY_DRIVER() ; + + /*! + Write MESH in the specified file. + */ + void write( void ) const throw (MEDEXCEPTION); + /*! + Return a MEDEXCEPTION : it is the write-only driver. + */ + void read ( void ) throw (MEDEXCEPTION); + +private: + int writeCoordinates () const; + int writeConnectivities (medEntityMesh entity) const; + int writeFamilyNumbers () const; int writeFamilies (vector & families) const; + int writeGRID() const; + + GENDRIVER * copy ( void ) const ; }; +/*! + + Driver Med for MESH : Read write. + - Use read method from MED_MESH_RDONLY_DRIVER + - Use write method from MED_MESH_WRONLY_DRIVER + +*/ + class MED_MESH_RDWR_DRIVER : public MED_MESH_RDONLY_DRIVER, public MED_MESH_WRONLY_DRIVER { public : - MED_MESH_RDWR_DRIVER():MED_MESH_DRIVER() {} + /*! + Constructor. + */ + MED_MESH_RDWR_DRIVER() ; + /*! + Constructor. + */ + MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ; + /*! + Copy constructor. + */ + MED_MESH_RDWR_DRIVER(const MED_MESH_RDWR_DRIVER & driver) ; - MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh): - MED_MESH_DRIVER(fileName,ptrMesh,MED_RDWR) - { - MESSAGE("MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); - }; + /*! + Destructor. + */ + ~MED_MESH_RDWR_DRIVER() ; - ~MED_MESH_RDWR_DRIVER() { - MESSAGE("MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed"); - } - - void write(void) const ; - void read (void) ; -}; + /*! + Write MESH in the specified file. + */ + void write(void) const throw (MEDEXCEPTION); + /*! + Read MESH in the specified file. + */ + void read (void) throw (MEDEXCEPTION); +private: + GENDRIVER * copy(void) const ; + +}; #endif /* MED_MESH_DRIVER_HXX */ diff --git a/src/MEDMEM/MEDMEM_STRING.hxx b/src/MEDMEM/MEDMEM_STRING.hxx index e53df0db6..be06dc2ab 100644 --- a/src/MEDMEM/MEDMEM_STRING.hxx +++ b/src/MEDMEM/MEDMEM_STRING.hxx @@ -1,53 +1,95 @@ -# ifndef STRING_HXX -# define STRING_HXX +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_STRING.hxx +// Module : MED + +# ifndef MEDMEM_STRING_HXX +# define MEDMEM_STRING_HXX + +using namespace std; # include -//# include # include -using namespace std; +/*! + A class to generate string from any type: + here is a simple use case + STRING msgErr; + msgErr << "This Object cannot be instanciated by now ! Try "<< 11 << "times just to see what happens "; + throw SALOME_EXCEPTION (LOCALIZED(msgErr)) ; + */ class STRING : public string { private : - // ostringstream _s ; ostrstream _s ; public : - operator const char * () const { - return const_cast (this->c_str()) ; - } - - ~STRING() - { - _s.freeze(false); - } + STRING::STRING() :string(), _s() + { + } + + STRING::~STRING() + { + _s.freeze(false); + } + + STRING::operator const char * () const + { + return const_cast (this->c_str()) ; + } + + template STRING::STRING( const T &valeur ) : string(), _s() + { + _s.freeze(false); + + _s << valeur ; + _s << ends; + + this->string::operator =( _s.str()); // freeze is true by now + } + + template STRING & STRING::operator<<( const T &valeur ) + { - STRING() :string() , _s() - { - } - - template STRING( const T &valeur ) : string() , _s() - { - _s.freeze(false); - _s << valeur ; - this->string::operator =( _s.str()); // freeze is true by now - } - - template STRING &operator<<( const T &valeur ) - { - _s.freeze(false); - _s << valeur ; - this->string::operator = ( _s.str()) ; // freeze is true by now - return *this ; - } -} ; + if ( _s.pcount() ) + { + _s.seekp(-1, ios::cur); // Back up before NULL + _s.rdbuf()->freeze(0); // Unfreeze it + } + + _s << valeur ; + _s << ends; -// Exemple d'utilisation avec les exceptions SALOME -// STRING msgErr; -// msgErr << "ESSAI::ESSAI() : This Object cannot be instanciated by now ! Try "<< 11 << "times just to see what happens "; -// throw SALOME_EXCEPTION (LOCALIZED(msgErr)) ; + this->string::operator = ( _s.str() ) ; // freeze is true by now + _s.freeze( false ) ; + return *this ; + + + } +} ; # endif diff --git a/src/MEDMEM/MEDMEM_SkyLineArray.cxx b/src/MEDMEM/MEDMEM_SkyLineArray.cxx index 160427402..f2b2a54b0 100644 --- a/src/MEDMEM/MEDMEM_SkyLineArray.cxx +++ b/src/MEDMEM/MEDMEM_SkyLineArray.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_SkyLineArray.cxx +// Module : MED + using namespace std; #include "MEDMEM_SkyLineArray.hxx" #include "utilities.h" @@ -26,22 +52,32 @@ MEDSKYLINEARRAY::~MEDSKYLINEARRAY() //if (_value != NULL) delete [] _value; } -MEDSKYLINEARRAY::MEDSKYLINEARRAY(const med_int count , const med_int length ) : - _count(count), _length(length), - _index(_count+1),_value(_length) +MEDSKYLINEARRAY::MEDSKYLINEARRAY(const med_int count, const med_int length): + _count(count), _length(length), + _index(_count+1),_value(_length) { MESSAGE("Constructeur MEDSKYLINEARRAY(count="< #include -#include "utilities.h" -#include "MEDMEM_define.hxx" +//#include "utilities.h" +//#include "MEDMEM_define.hxx" #include "MEDMEM_DriversDef.hxx" #include "MEDMEM_Support.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" +//#include "MEDMEM_Family.hxx" +//#include "MEDMEM_Group.hxx" #include "MEDMEM_Mesh.hxx" using namespace MED_EN; /* This class is a generic class for family and group */ + +/*! + Constructor. +*/ //-------------------------------------------------------------------------- SUPPORT::SUPPORT(): _name(""), _description(""), _mesh((MESH*)NULL), _entity(MED_CELL), _numberOfGeometricType(0), _geometricType((medGeometryElement*)NULL), _numberOfGaussPoint((int*)NULL), - _geometricTypeNumber((int*)NULL), _isOnAllElts(false), - _numberOfEntities((int*)NULL), _totalNumberOfEntities(0), + //_geometricTypeNumber((int*)NULL), + _isOnAllElts(false), + _numberOfElements((int*)NULL), + _totalNumberOfElements(0), _number((MEDSKYLINEARRAY*)NULL) //-------------------------------------------------------------------------- { - MESSAGE("Constructeur SUPPORT sans parametre"); + MESSAGE("SUPPORT::SUPPORT()"); }; +/*! + Constructor. +*/ //-------------------------------------------------------------------------- SUPPORT::SUPPORT(MESH* Mesh, string Name/*=""*/, medEntityMesh Entity/*=MED_CELL*/): _name(Name), _description(""), _mesh(Mesh), _entity(Entity), _numberOfGeometricType(0), _geometricType((medGeometryElement*)NULL), _numberOfGaussPoint((int*)NULL), - _geometricTypeNumber((int*)NULL), - _isOnAllElts(true), _numberOfEntities((int*)NULL), - _totalNumberOfEntities(0), + //_geometricTypeNumber((int*)NULL), + _isOnAllElts(true), + _numberOfElements((int*)NULL), + _totalNumberOfElements(0), _number((MEDSKYLINEARRAY*)NULL) //-------------------------------------------------------------------------- { - MESSAGE("Constructeur SUPPORT avec parametres MESH* Mesh,string name,medEntityMesh Entity"); - if ( Entity == MED_NODE) { - _numberOfGeometricType=1 ; - _geometricType=new medGeometryElement[1] ; - _geometricType[0]=MED_NONE ; - } + MESSAGE("SUPPORT::SUPPORT(MESH*Mesh,string Name,medEntityMesh Entity)"); + update() ; }; +/*! + Copy constructor. +*/ //-------------------------------------------------------------------------- -SUPPORT::SUPPORT(SUPPORT & m) +SUPPORT::SUPPORT(const SUPPORT & m) //-------------------------------------------------------------------------- { const char * LOC = "SUPPORT::SUPPORT(SUPPORT & m) : " ; @@ -77,22 +112,22 @@ SUPPORT::SUPPORT(SUPPORT & m) } else _numberOfGaussPoint = (int *) NULL; - if (m._geometricTypeNumber != NULL) - { - _geometricTypeNumber = new int[m._numberOfGeometricType]; - memcpy(_geometricTypeNumber,m._geometricTypeNumber,m._numberOfGeometricType*sizeof(int)); - } - else - _geometricTypeNumber = (int *) NULL; +// if (m._geometricTypeNumber != NULL) +// { +// _geometricTypeNumber = new int[m._numberOfGeometricType]; +// memcpy(_geometricTypeNumber,m._geometricTypeNumber,m._numberOfGeometricType*sizeof(int)); +// } +// else +// _geometricTypeNumber = (int *) NULL; _isOnAllElts = m._isOnAllElts; - if (m._numberOfEntities != NULL) + if (m._numberOfElements != NULL) { - _numberOfEntities = new int[m._numberOfGeometricType]; - memcpy(_numberOfEntities,m._numberOfEntities,m._numberOfGeometricType*sizeof(int)); + _numberOfElements = new int[_numberOfGeometricType]; + memcpy(_numberOfElements,m._numberOfElements,_numberOfGeometricType*sizeof(int)); } else - _numberOfEntities = (int *) NULL; - _totalNumberOfEntities = m._totalNumberOfEntities; + _numberOfElements = (int *) NULL; + _totalNumberOfElements = m._totalNumberOfElements; if (m._isOnAllElts == false) _number = new MEDSKYLINEARRAY(* m._number); else @@ -101,28 +136,35 @@ SUPPORT::SUPPORT(SUPPORT & m) END_OF(LOC) ; }; + +/*! + Destructor. +*/ //----------------- SUPPORT::~SUPPORT() //----------------- { - MESSAGE("Destructeur ~SUPPORT()"); - if (_geometricType!=NULL) - delete[] _geometricType ; - if (_numberOfGaussPoint!=NULL) - delete[] _numberOfGaussPoint ; - if (_geometricTypeNumber!=NULL) - delete[] _geometricTypeNumber ; - if (_numberOfEntities!=NULL) - delete[] _numberOfEntities ; - if (_number!=NULL) - delete _number ; + MESSAGE("Destructeur ~SUPPORT()"); + if (_geometricType != (medGeometryElement *) NULL) + delete [] _geometricType ; + if (_numberOfGaussPoint != (int *) NULL) + delete [] _numberOfGaussPoint ; + // if (_geometricTypeNumber!=NULL) + // delete[] _geometricTypeNumber ; + if (_numberOfElements != (int *) NULL) + delete[] _numberOfElements ; + if (_number != (MEDSKYLINEARRAY *) NULL) + delete _number ; } +/*! + operator <<. +*/ //-------------------------------------------------- ostream & operator<<(ostream &os, const SUPPORT &my) //-------------------------------------------------- { - os << "Name : "<getI(j+1) ; - for (int k=0; kgetI(j+1); + for (int k=0; kgetNumberOfTypes(_entity) ; - MESSAGE( "NumberOfTypes : "<< NumberOfTypes ); - _numberOfGaussPoint = new int[NumberOfTypes] ; - for (int i=0;igetNumberOfNodes(); + _totalNumberOfElements=_numberOfElements[0]; + _numberOfGaussPoint = new int[1] ; + _numberOfGaussPoint[0]=1; + } else { // we duplicate information from _mesh + _numberOfGeometricType=_mesh->getNumberOfTypes(_entity); + if (_geometricType == (medGeometryElement *) NULL) + _geometricType = new medGeometryElement[_numberOfGeometricType] ; + memcpy(_geometricType,_mesh->getTypes(_entity),_numberOfGeometricType*sizeof(medGeometryElement)); + if (_numberOfElements == (int *) NULL) + _numberOfElements = new int[_numberOfGeometricType] ; + if (_numberOfGaussPoint == (int *) NULL) + _numberOfGaussPoint = new int[_numberOfGeometricType] ; + _totalNumberOfElements=0; + for (int i=0;i<_numberOfGeometricType;i++) { + _numberOfElements[i]=_mesh->getNumberOfElements(_entity,_geometricType[i]) ; + _totalNumberOfElements+=_numberOfElements[i]; _numberOfGaussPoint[i]=1 ; + } } - if (_entity == MED_NODE) - _totalNumberOfEntities = _mesh->getNumberOfNodes(); - + } END_OF(LOC); }; -/*! A DOCUMENTER */ +/*! + Blend the given SUPPORT into it. +*/ //------------------- void SUPPORT::blending(SUPPORT * mySupport) //------------------- @@ -211,17 +276,17 @@ void SUPPORT::blending(SUPPORT * mySupport) } } // set new value : - int * numberOfEntities=_numberOfEntities ; - _numberOfEntities = new int[it] ; - _totalNumberOfEntities = 0 ; - // int totalSize = 0 ; + int * numberOfElements=_numberOfElements ; + _numberOfElements = new int[it] ; + _totalNumberOfElements = 0 ; + //int totalSize = 0 ; int ** tmp_array = new (int*)[it]; for (int i=0;igetNumber(myType[i]) ; + const int * number1 = getNumber(myType[i]) ; + const int * number2 = mySupport->getNumber(myType[i]) ; SCRUTE(number1); SCRUTE(number2); - int numberOfElements1 = numberOfEntities[i] ; + int numberOfElements1 = numberOfElements[i] ; int numberOfElements2 = mySupport->getNumberOfElements(myType[i]) ; SCRUTE(numberOfElements1); @@ -253,9 +318,9 @@ void SUPPORT::blending(SUPPORT * mySupport) } //create the array ! - int newNumberOfEntities = elementList.size() ; - _numberOfEntities[i] = newNumberOfEntities ; - int * tmp_arrayNew = new int[newNumberOfEntities]; + int newNumberOfElements = elementList.size() ; + _numberOfElements[i] = newNumberOfElements ; + int * tmp_arrayNew = new int[newNumberOfElements]; set::iterator its ; for(its=elementList.begin();its!=elementList.end(); its++) { @@ -265,7 +330,7 @@ void SUPPORT::blending(SUPPORT * mySupport) delete[] tmp_array[i] ; tmp_array[i] = tmp_arrayNew ; - _totalNumberOfEntities-=(numberOfElementsInType-newNumberOfEntities) ; + _totalNumberOfElements-=(numberOfElementsInType-newNumberOfElements) ; } else throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"ERROR")) ; @@ -278,32 +343,39 @@ void SUPPORT::blending(SUPPORT * mySupport) _geometricType = new medGeometryElement[it] ; int * numberOfGaussPoint=_numberOfGaussPoint ; _numberOfGaussPoint= new int[it] ; - int * geometricTypeNumber=_geometricTypeNumber ; - _geometricTypeNumber = new int[it] ; +// int * geometricTypeNumber=_geometricTypeNumber ; +// _geometricTypeNumber = new int[it] ; - MEDSKYLINEARRAY* numberNew = new MEDSKYLINEARRAY(it,_totalNumberOfEntities); - int * numberIndex = numberNew->getIndex() ; +// MEDSKYLINEARRAY* numberNew = new MEDSKYLINEARRAY(it,_totalNumberOfElements); +// int * numberIndex = numberNew->getIndex() ; + int size = _mesh->getNumberOfElements(_entity,MED_ALL_ELEMENTS); + if (_totalNumberOfElements == size) _isOnAllElts = true; + + int * numberValue = new int[_totalNumberOfElements] ; + int * numberIndex = new int[it+1] ; numberIndex[0]=1; for (int i=0;igetI(i+1),tmp_array[i],sizeof(int)*_numberOfEntities[i]) ; + memcpy(numberValue+numberIndex[i]-1,tmp_array[i],sizeof(int)*_numberOfElements[i]) ; delete[] tmp_array[i] ; - numberIndex[i+1]=numberIndex[i]+_numberOfEntities[i] ; + numberIndex[i+1]=numberIndex[i]+_numberOfElements[i] ; _geometricType[i]=myType[i] ; _numberOfGaussPoint[i]=1 ; - _geometricTypeNumber[i]=0 ; - } - delete _number ; - _number = numberNew ; + if ( _number != (MEDSKYLINEARRAY *) NULL) delete _number ; + //_number = numberNew ; + _number = new MEDSKYLINEARRAY(it,_totalNumberOfElements,numberIndex,numberValue); + delete[] numberIndex; + + delete[] numberValue; delete[] myType ; delete[] tmp_array ; delete[] geometricType ; delete[] numberOfGaussPoint ; - delete[] geometricTypeNumber ; - delete[] numberOfEntities ; +// delete[] geometricTypeNumber ; + delete[] numberOfElements ; END_OF(LOC); }; @@ -313,52 +385,184 @@ void SUPPORT::blending(SUPPORT * mySupport) 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.; - useful for the Python API. + It allocates and initialises all the attributs of the class SUPPORT. */ //------------------- void SUPPORT::setpartial(string Description, int NumberOfGeometricType, - int TotalNumberOfEntity, + int TotalNumberOfElements, medGeometryElement *GeometricType, - int *NumberOfEntity, int *NumberValue) + int *NumberOfElements, int *NumberValue) //------------------- { const char * LOC = "SUPPORT::setpartial(string , int , int , medGeometryElement * , int * , int *) : " ; BEGIN_OF(LOC) ; + _isOnAllElts = false ; + _description=Description; _numberOfGeometricType=NumberOfGeometricType; - _totalNumberOfEntities=TotalNumberOfEntity; - + if (_geometricType!=NULL) delete[] _geometricType ; _geometricType = new medGeometryElement[NumberOfGeometricType]; - _geometricType = GeometricType; + if (_numberOfElements!=NULL) delete[] _numberOfElements ; + _numberOfElements = new int[NumberOfGeometricType]; + _totalNumberOfElements = TotalNumberOfElements; + if (_numberOfGaussPoint!=NULL) delete[] _numberOfGaussPoint ; + _numberOfGaussPoint = new int[NumberOfGeometricType]; + int * index = new int[_numberOfGeometricType+1]; + index[0]=1; + for (int i=0;i<_numberOfGeometricType;i++) { + _geometricType[i] = GeometricType[i] ; + _numberOfElements[i] = NumberOfElements[i] ; + _numberOfGaussPoint[i] = 1 ; + index[i+1] = index[i]+NumberOfElements[i] ; + } + + if (_number!=NULL) delete _number ; + _number = new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,NumberValue); - // attributes initialised at 0 because not really useful but it has to be - // allocated !! WARNING !! + delete[] index ; - _geometricTypeNumber = new int[NumberOfGeometricType] ; - for (int i=0;igetSpaceDimension(); + + if (spaceDimension == 3) + if (_entity != MED_FACE) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 3D mesh for entity "<<_entity<<" !")); + if (spaceDimension == 2) + if (_entity != MED_EDGE) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 2D mesh for entity "<<_entity<<" !")); + + setAll(false); + + const int * myConnectivityValue = _mesh->getReverseConnectivity(MED_DESCENDING) ; + const int * myConnectivityIndex = _mesh->getReverseConnectivityIndex(MED_DESCENDING) ; + int numberOf = _mesh->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 ++ ; + } - for (int i=0;i<_numberOfGeometricType;i++) - index[i+1] = index[i]+_numberOfEntities[i] ; + int numberOfGeometricType ; + medGeometryElement* geometricType ; + int * numberOfGaussPoint ; + int * geometricTypeNumber ; + int * numberOfElements ; + //MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ; + int * mySkyLineArrayIndex ; + + int numberOfType = _mesh->getNumberOfTypes(_entity) ; + if (numberOfType == 1) { // wonderfull : it's easy ! + numberOfGeometricType = 1 ; + geometricType = new medGeometryElement[1] ; + const medGeometryElement * allType = _mesh->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 ; + numberOfElements = new int[1] ; + numberOfElements[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 = _mesh->getElementType(_entity,*myElementsListIt) ; + if (theType.find(myType) != theType.end() ) + theType[myType]+=1 ; + else + theType[myType]=1 ; + } + numberOfGeometricType = theType.size() ; + geometricType = new medGeometryElement[numberOfGeometricType] ; + const medGeometryElement * allType = _mesh->getTypes(_entity); + numberOfGaussPoint = new int[numberOfGeometricType] ; + geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing + numberOfElements = 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 ; + numberOfElements[index] = (*theTypeIt).second ; + mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfElements[index] ; + index++ ; + } + } + //mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ; + MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ; - number->setMEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities,index,NumberValue); + setNumberOfGeometricType(numberOfGeometricType) ; + // setGeometricType(geometricType) ; + // setNumberOfGaussPoint(numberOfGaussPoint) ; + for (int i=0;isetIndex(mySkyLineArrayIndex); + + for (int i=0;isetIndexValue(i+1,myListArray[i]); + } + + delete[] numberOfElements; + delete[] geometricTypeNumber; + delete[] numberOfGaussPoint; + delete[] geometricType; + delete[] mySkyLineArrayIndex; + delete[] myListArray; + delete mySkyLineArray; + + END_OF(LOC) ; +} diff --git a/src/MEDMEM/MEDMEM_Unit.cxx b/src/MEDMEM/MEDMEM_Unit.cxx index 8648722bb..7cd49a7e4 100644 --- a/src/MEDMEM/MEDMEM_Unit.cxx +++ b/src/MEDMEM/MEDMEM_Unit.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_Unit.cxx +// Module : MED + using namespace std; /* File MEDMEM_Unit.cxx diff --git a/src/MEDMEM/MEDMEM_VtkMedDriver.cxx b/src/MEDMEM/MEDMEM_VtkMedDriver.cxx index d3e758c3d..70df3ee59 100644 --- a/src/MEDMEM/MEDMEM_VtkMedDriver.cxx +++ b/src/MEDMEM/MEDMEM_VtkMedDriver.cxx @@ -1,199 +1,255 @@ +// 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_VtkMedDriver.cxx +// Module : MED + using namespace std; #include "MEDMEM_VtkMedDriver.hxx" +#include + +#include "MEDMEM_define.hxx" #include "MEDMEM_Med.hxx" +#include "MEDMEM_Field.hxx" +#include "MEDMEM_Support.hxx" +#include "MEDMEM_Mesh.hxx" +#include "MEDMEM_CellModel.hxx" VTK_MED_DRIVER::VTK_MED_DRIVER(): GENDRIVER(), - _ptrMed((MED * const)MED_NULL), - _vtkFile(MED_INVALID) + _ptrMed((MED * const)MED_NULL) { + _vtkFile = new ofstream(); // What about _id in Gendriver ? // _driverType ??? } VTK_MED_DRIVER::VTK_MED_DRIVER(const string & fileName, MED * const ptrMed): - GENDRIVER(fileName,MED_EN::MED_RDWR), _ptrMed(ptrMed), _vtkFile(MED_INVALID) + GENDRIVER(fileName,MED_EN::MED_RDWR), _ptrMed(ptrMed) { + _ptrMed->addDriver(*this); // OU RECUPERER L'ID. + _vtkFile = new ofstream(); // What about _id in Gendriver ? // _driverType ??? } -//REM : As t'on besoin du champ _status : _vtkFile <-> _status ? Oui +VTK_MED_DRIVER::VTK_MED_DRIVER(const VTK_MED_DRIVER & driver): + GENDRIVER(driver), + _ptrMed(driver._ptrMed) +{ + _ptrMed->addDriver(*this); // OU RECUPERER L'ID. + _vtkFile = new ofstream(); + // What about _id in Gendriver ? + // _driverType ??? +} +VTK_MED_DRIVER::~VTK_MED_DRIVER() +{ + close(); + delete _vtkFile ; +} -void VTK_MED_DRIVER::open() { +GENDRIVER * VTK_MED_DRIVER::copy() const +{ + return new VTK_MED_DRIVER(*this) ; +} + +//REM : As t'on besoin du champ _status : _vtkFile <-> _status ? Oui + +void VTK_MED_DRIVER::openConst() const { const char * LOC ="VTK_MED_DRIVER::open() : "; BEGIN_OF(LOC); - // REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE -// if ( _vtkFile != MED_INVALID ) -// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) -// << "_vtkFile is already in use, please close the file |" -// << _fileName << "| before calling open()" -// ) -// ); - - if ( _status != MED_CLOSED ) - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "_status is not closed, please close the file |" - << _fileName << "| before calling open()" - ) - ); - if ( _fileName == "" ) throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_fileName is |\"\"|, please set a correct fileName before calling open()" ) ); - _vtkFile.open(filename.c_str()) ; // ? if error ???? - _status = MED_OPENED ; - -// if (_vtkFile > 0) _status=MED_OPENED; -// else { -// _status = MED_CLOSED; -// _vtkFile = MED_INVALID; -// throw MED_EXCEPTION (LOCALIZED( STRING(LOC) -// << "Can't open |" << _fileName -// << "|, _vtkFile : " << _vtkFile -// ) -// ); -// } - + + if (!(*_vtkFile).is_open()) + (*_vtkFile).open(_fileName.c_str()) ; +// if (*_vtkFile) +// _status = MED_OPENED ; +// else + if (!(*_vtkFile)) + throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not open file " + << _fileName) + ); END_OF(LOC); } +void VTK_MED_DRIVER::open() { + openConst() ; +} -void VTK_MED_DRIVER::close() { +void VTK_MED_DRIVER::closeConst() const { - const char * LOC = "MED_MED_DRIVER::close() : "; + const char * LOC = "VTK_MED_DRIVER::close() : "; BEGIN_OF(LOC); - if ( _status == MED_CLOSED) - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |" - << _fileName << "| is already closed" - ) - ); - - // if ( _vtkFile == MED_INVALID ) -// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_vtkFile invalid, but the file |" -// << _fileName << "| seems to be openned !" -// ) -// ); - vtkFile_.close(); - - _status = MED_CLOSED; - // _vtkFile = MED_INVALID; - -// if (err != MED_VALID) -// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |" -// << _fileName << "| couldn't be closed" -// ) -// ); + (*_vtkFile).close(); +// if (*_vtkFile) +// _status = MED_CLOSED ; +// else + if (!(*_vtkFile)) + throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not close file " + << _fileName) + ); END_OF(LOC); } +void VTK_MED_DRIVER::close() { + closeConst() ; +} -void VTK_MED_DRIVER::write() { - const char * LOC = "MED_MED_DRIVER::write() : "; +void VTK_MED_DRIVER::write() const { + + const char * LOC = "VTK_MED_DRIVER::write() : "; BEGIN_OF(LOC); + // Well we must open vtk file first, because there are + // no other driver than MED for VTK that do it ! + openConst() ; + // could we put more than one Mesh ????? - _vtkFile << "# vtk DataFile Version 2.0" << endl - << "maillage SALOLME" << endl ; - // only ASCII for the moment (binary came latest :-) - _vtkFile << "ASCII" << endl ; - - int NumberOfMeshes = _ptrMED->getNumberOfMeshes() ; - string * MeshName = new string[NumberOfMeshes] ; - _ptrMED->getMeshNames(MeshName) ; + (*_vtkFile) << "# vtk DataFile Version 2.0" << endl + << "maillage from MedMemory" << endl ; + // only ASCII for the moment (binary came later :-) + (*_vtkFile) << "ASCII" << endl ; + + int NumberOfMeshes = _ptrMed->getNumberOfMeshes() ; + deque MeshNames = _ptrMed->getMeshNames() ; + deque::const_iterator currentMesh ; // In fact, we must take care of all supports // We restrict Field on all nodes or cells + + int NumberOfFields = _ptrMed->getNumberOfFields() ; + deque FieldNames = _ptrMed->getFieldNames() ; + deque::const_iterator currentField ; + + // for ( currentMesh=MeshName.begin();currentMesh != MeshName.end(); currentMesh++) { for (int i=0; igetMesh(MeshName[i]) ; + MESH * myMesh = _ptrMed->getMesh(MeshNames[i]) ; writeMesh(myMesh) ; // get all field which values are on this mesh => revoir api de Med !!! - _vtkFile << "NODE" << endl ; // first : field on node + // fields is on all node ! + (*_vtkFile) << "POINT_DATA " << myMesh->getNumberOfNodes() << endl ; for (int j=0; jgetField() ; - if (myField->getSupport()->getEntity()!=MED_NODE) - if (myField->getSupport()->isOnAllElements()) - writeField(myField) ; - + deque timeStep = _ptrMed->getFieldIteration(FieldNames[j]) ; + deque::const_iterator currentTimeStep ; + for ( currentTimeStep=timeStep.begin(); currentTimeStep!=timeStep.end(); currentTimeStep++) { + int dt = (*currentTimeStep).dt ; + int it = (*currentTimeStep).it ; + FIELD_ * myField = _ptrMed->getField(FieldNames[j],dt,it) ; + if( MeshNames[i] == myField->getSupport()->getMesh()->getName() ) { + // rigth in all case : better compare pointeur ? + if (MED_NODE == myField->getSupport()->getEntity()) + if (myField->getSupport()->isOnAllElements()) { + ostringstream name ; + name << myField->getName() << "_" << dt << "_" << it ; + writeField(myField,name.str()) ; + } else + INFOS("Could not write field "<getName()<<" which is not on all nodes !"); + } + } } - _vtkFile << "CELL" << endl ; + + (*_vtkFile) << "CELL_DATA " << myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) << endl ; // second : field on cell for (int j=0; jgetField() ; - if (myField->getSupport()->getEntity()!=MED_CELL) - if (myField->getSupport()->isOnAllElements()) - writeField(myField) ; - + deque timeStep = _ptrMed->getFieldIteration(FieldNames[j]) ; + deque::const_iterator currentTimeStep ; + for ( currentTimeStep=timeStep.begin(); currentTimeStep!=timeStep.end(); currentTimeStep++) { + int dt ; + int it ; + FIELD_ * myField = _ptrMed->getField(FieldNames[j],dt,it) ; + if( MeshNames[i] == myField->getSupport()->getMesh()->getName() ) { + // rigth in all case : better compare pointeur ? + if (MED_CELL == myField->getSupport()->getEntity()) + if (myField->getSupport()->isOnAllElements()) { + ostringstream name ; + name << myField->getName() << "_" << dt << "_" << it ; + writeField(myField,name.str()) ; + } else + INFOS("Could not write field "<getName()<<" which is not on all cells !"); + } + } } } + // Well we must close vtk file first, because there are + // no other driver than MED for VTK that do it ! + closeConst() ; + END_OF(LOC); } -void VTK_MED_DRIVER::writeMesh(MESH * myMesh) { +void VTK_MED_DRIVER::writeMesh(MESH * myMesh) const { - const char * LOC = "MED_MED_DRIVER::writeMesh() : "; + const char * LOC = "VTK_MED_DRIVER::writeMesh() : "; BEGIN_OF(LOC); - _vtkFile << "DATASET UNSTRUCTURED_GRID" << endl ; + (*_vtkFile) << "DATASET UNSTRUCTURED_GRID" << endl ; // put points (all point are in 3D, so if we are in 1D or 2D, we complete by zero ! int SpaceDimension = myMesh->getSpaceDimension() ; int NumberOfNodes = myMesh->getNumberOfNodes() ; - _vtkFile << "POINTS " << NumberOfNodes << " float" << endl ; - double *coordinate = myMesh->getCoordinates(MED_FULL_ENTERLACE) ; - if (SpaceDimension<3) { // 1D or 2D - coordinate_z = new double[NumberOfNodes] ; - // we put zero : - for (int i=0;igetCoordinates(MED_FULL_INTERLACE) ; + for (int i=0;igetNumberOfTypes(MED_CELL) ; - int * cells_count = myMesh->get_cells_count() ; - int cells_sum = cells_count[cells_types_count] ; - CellModel * cells_type = myMesh->get_cells_type() ; - int connectivity_sum = 0 ; + // int * cells_count = myMesh->get_cells_count() ; + // int cells_sum = cells_count[cells_types_count] ; + int cells_sum = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) ; + const CELLMODEL * cells_type = myMesh->getCellsTypes(MED_CELL) ; + // int connectivity_sum = 0 ; - int * connectivity = myMesh->getConnectivity(MED_FULL_ENTERLACE,MED_CELL,MED_ALL_ELEMENTS) ; - int * connectivityIndex = myMesh->getConnectivityIndex(MED_CELL) ; + const int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_ALL_ELEMENTS) ; + const int * connectivityIndex = myMesh->getConnectivityIndex(MED_NODAL,MED_CELL) ; - for (int i=0;igetNumberOfElements(MED_CELL,cells_type[i].getType()) ; + const int * connectivityArray = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,cells_type[i].getType()); + for (int j=0;jget_nodal_connectivity(i+1))[j*nodes_cell+filter[k]] - 1 << " " ; - _vtkFile << endl ; + (*_vtkFile) << connectivityArray[j*nodes_cell+filter[k]] - 1 << " " ; + (*_vtkFile) << endl ; } + if (filter != NULL) + delete[] filter ; } - _vtkFile << endl ; + (*_vtkFile) << endl ; // we put cells type - _vtkFile << "CELL_TYPES " << cells_sum << endl ; + (*_vtkFile) << "CELL_TYPES " << cells_sum << endl ; for (int i=0;igetNumberOfElements(MED_CELL,cells_type[i].getType()) ; + for (int j=0;jgetSupport()->getNumberOfElements(MED_ALL_ELEMENTS) ; + int NomberOfComponents = myField->getNumberOfComponents() ; + + med_type_champ type = myField->getValueType() ; + SCRUTE(name); + SCRUTE(type); + switch (type) + { + case MED_INT32 : { + MESSAGE("MED_INT32"); + if (NomberOfComponents==3) { + (*_vtkFile) << "VECTORS " << name << " int" << endl ; + } else if (NomberOfComponents<=4) { + (*_vtkFile) << "SCALARS " << name << " int " << NomberOfComponents << endl ; + (*_vtkFile) << "LOOKUP_TABLE default" << endl ; + } else { + INFOS("Could not write field "<getName()<<" there are more than 4 components !"); + return ; + } + + //const int * value = ((FIELD*)myField)->getValue(MED_NO_INTERLACE) ; + const int * value = ((FIELD*)myField)->getValue(MED_NO_INTERLACE) ; + for (int i=0; igetName()<<" there are more than 4 components !"); + return ; + } + const double * value = ((FIELD*)myField)->getValue(MED_NO_INTERLACE) ; + for (int i=0; igetIndex() ; + int * index = new int[NumberOfCell+1] ; index[0]=1; index[1]=4; index[2]=8; index[3]=11; - int * value = myArray->getValue() ; + int * value = new int[Size] ; value[0]=1; // first value[1]=2; value[2]=5; @@ -26,9 +51,11 @@ int main (int argc, char ** argv) { value[9]=6; // value[]=; // forth + MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size,index,value) ; + cout << "Show all 1 :" << endl ; for (int i=1; igetI(i) ; + const int * cell = myArray->getI(i) ; int numberof = myArray->getNumberOfI(i) ; cout << " - " ; for (int j=0;jgetI(i) ; - int numberof = myArray2->getNumberOfI(i) ; + const int * index2 = myArray2->getIndex() ; + for (int i=1; i<=NumberOfCell ; i++) { cout << " - " ; - for (int j=0;jgetIndexValue(j) << " " ; cout << endl ; } + delete myArray2 ; + delete[] index ; + delete[] value ; + return 0 ; } -- 2.39.2