From: nri Date: Thu, 10 Jul 2003 14:48:40 +0000 (+0000) Subject: sources v1.2 X-Git-Tag: V1_2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bc10f4836149793fd59a112ee25e888be5648f11;p=modules%2Fmed.git sources v1.2 --- diff --git a/src/MED/MED_test1.py b/src/MED/MED_test1.py index 8ce0e3f66..d55dae38e 100755 --- a/src/MED/MED_test1.py +++ b/src/MED/MED_test1.py @@ -1,11 +1,30 @@ -#============================================================================== -# File : MED_test1.py -# Created : -# Author : -# Project : SALOME -# Copyright : EDF 2002 +# MED MED : implemetation of MED idl descriptions +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : MED_test1.py +# Author : +# Module : MED # $Header$ -#============================================================================== import salome diff --git a/src/MED/MED_test2.py b/src/MED/MED_test2.py index 1169d5c78..77caf1518 100755 --- a/src/MED/MED_test2.py +++ b/src/MED/MED_test2.py @@ -1,11 +1,30 @@ -#============================================================================== -# File : MED_test2.py -# Created : -# Author : -# Project : SALOME -# Copyright : EDF 2002 +# MED MED : implemetation of MED idl descriptions +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : MED_test2.py +# Author : +# Module : MED # $Header$ -#============================================================================== import salome import SALOME diff --git a/src/MED/Makefile.in b/src/MED/Makefile.in index 104720330..a50248dfe 100644 --- a/src/MED/Makefile.in +++ b/src/MED/Makefile.in @@ -1,13 +1,31 @@ -#============================================================================== -# File : Makefile.in -# Created : ven déc 7 13:33:08 CET 2001 -# Author : Paul RASCLE, EDF -# Project : SALOME -# Copyright : EDF 2001 +# MED MED : implemetation of MED idl descriptions +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Paul RASCLE, EDF +# Module : MED # $Header$ -#============================================================================== -# source path top_srcdir=@top_srcdir@ top_builddir=../../.. srcdir=@srcdir@ @@ -36,7 +54,7 @@ BIN_SRC = CPPFLAGS += $(OCC_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) CXXFLAGS += $(OCC_CXXFLAGS) -LDFLAGS+= $(OCC_LIBS) $(HDF5_LIBS) -lSalomeContainer -lSalomeHDFPersist -lSalomeDS -lSalomeNS -lRegistry -lOpUtil -lmedmem -lMEDImpl +LDFLAGS+= $(HDF5_LIBS) -lSalomeContainer -lTOOLSDS -lSalomeNS -lRegistry -lOpUtil -lmedmem -lMEDImpl -lSalomeHDFPersist MED.hh MEDSK.cc: MED.idl diff --git a/src/MED/Med_Gen_i.cxx b/src/MED/Med_Gen_i.cxx index 2906c2fee..89fd3c4af 100755 --- a/src/MED/Med_Gen_i.cxx +++ b/src/MED/Med_Gen_i.cxx @@ -1,13 +1,33 @@ -//============================================================================= -// File : Med_Gen_i.cxx -// Created : mer fév 20 15:47:57 CET 2002 -// Author : Paul RASCLE, EDF -// Project : SALOME -// Copyright : EDF 2001 -// $Header$ -//============================================================================= -using namespace std; +// MED MED : implemetation of MED idl descriptions +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : Med_Gen_i.cxx +// Author : Paul RASCLE, EDF +// Module : MED +// $Header$ +using namespace std; +using namespace std; #include "Med_Gen_i.hxx" #include "Mesh_i.hxx" @@ -38,6 +58,7 @@ using namespace std; #include #include +#include #include "SALOMEDS_Tool.hxx" // Initialisation des variables statiques @@ -256,7 +277,7 @@ throw (SALOME::SALOME_Exception) try { myMeshDriver.read(); -("apres read"); + MESSAGE("apres read"); myMeshDriver.close(); } catch (const exception & ex) @@ -455,17 +476,21 @@ Med_Gen_i::~Med_Gen_i() * CORBA: Save Mesh objects (called when a study is saved) */ //============================================================================= -SALOMEDS::TMPFile* Med_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent) { +SALOMEDS::TMPFile* Med_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile) { const char* LOC = "Med_Gen_i::Save"; BEGIN_OF(LOC); SALOMEDS::TMPFile_var aStreamFile; // Get a temporary directory to store a file - TCollection_AsciiString aTmpDir = SALOMEDS_Tool::GetTmpDir(); + TCollection_AsciiString aTmpDir = (isMultiFile)?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir(); // Create a list to store names of created files SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; TColStd_SequenceOfAsciiString aFileNames; + CORBA::String_var aSaveStudyName = strdup(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL())); + SALOMEDS::SObject_var aMedMeshFather = theComponent->GetStudy()->FindObject("MEDMESH"); if (!CORBA::is_nil(aMedMeshFather)) { SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedMeshFather); @@ -476,11 +501,11 @@ SALOMEDS::TMPFile* Med_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent) { CORBA::Object_var myIOR = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()); SALOME_MED::MESH_var myMesh = SALOME_MED::MESH::_narrow(myIOR); if (! CORBA::is_nil(myMesh)) { - TCollection_AsciiString aName; - aName = "MED_tmp_"; + TCollection_AsciiString aName(strdup(aSaveStudyName)); + aName += "_MEDMESH_"; aName += myMesh->getName(); aName += ".med"; -// MESSAGE("Save mesh with name "<addDriver(SALOME_MED::MED_DRIVER,(aTmpDir+aName).ToCString(),myMesh->getName()); myMesh->write(driverId,""); aFileNames.Append(aName); @@ -499,11 +524,19 @@ SALOMEDS::TMPFile* Med_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent) { CORBA::Object_var myIOR = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()); SALOME_MED::FIELD_var myField = SALOME_MED::FIELD::_narrow(myIOR); if (! CORBA::is_nil(myField)) { - TCollection_AsciiString aName; - aName = "MED_tmp_"; + ostringstream a,b; + a<< myField->getOrderNumber(); + b<< myField->getIterationNumber(); + + TCollection_AsciiString aName(strdup(aSaveStudyName)); + aName += "_MEDFIELD_"; aName += myField->getName(); + aName += "_ORDRE_"; + aName += strdup(a.str().c_str()); + aName += "_ITER_"; + aName += strdup(b.str().c_str()); aName += ".med"; -// MESSAGE("Save mesh with name "<addDriver(SALOME_MED::MED_DRIVER,(aTmpDir+aName).ToCString(),myField->getName()); myField->write(driverId,""); aFileNames.Append(aName); @@ -516,9 +549,93 @@ SALOMEDS::TMPFile* Med_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent) { aSeq->length(aFileNames.Length()); for(i = aFileNames.Length(); i > 0; i--) aSeq[i-1] = CORBA::string_dup(aFileNames.Value(i).ToCString()); // Conver a file to the byte stream - aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq); + aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile); // Remove the created file and tmp directory - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq, true); + if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true); + // Return the created byte stream + return aStreamFile._retn(); + + END_OF(LOC); +} + +SALOMEDS::TMPFile* Med_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile) { + const char* LOC = "Med_Gen_i::SaveASCII"; + BEGIN_OF(LOC); + + SALOMEDS::TMPFile_var aStreamFile; + // Get a temporary directory to store a file + TCollection_AsciiString aTmpDir = (isMultiFile)?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir(); + // Create a list to store names of created files + SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; + TColStd_SequenceOfAsciiString aFileNames; + + CORBA::String_var aSaveStudyName = strdup(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL())); + + SALOMEDS::SObject_var aMedMeshFather = theComponent->GetStudy()->FindObject("MEDMESH"); + if (!CORBA::is_nil(aMedMeshFather)) { + SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedMeshFather); + for(; anIter->More(); anIter->Next()) { + SALOMEDS::SObject_var aSO = anIter->Value(); + SALOMEDS::GenericAttribute_var anAttr; + if (aSO->FindAttribute(anAttr,"AttributeIOR")) { + CORBA::Object_var myIOR = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()); + SALOME_MED::MESH_var myMesh = SALOME_MED::MESH::_narrow(myIOR); + if (! CORBA::is_nil(myMesh)) { + TCollection_AsciiString aName(strdup(aSaveStudyName)); + aName += "_MEDMESH_"; + aName += myMesh->getName(); + aName += ".med"; + MESSAGE("Save mesh with name "<addDriver(SALOME_MED::MED_DRIVER,(aTmpDir+aName).ToCString(),myMesh->getName()); + myMesh->write(driverId,""); + HDFascii::ConvertFromHDFToASCII(strdup((aTmpDir+aName).ToCString()), true); + aFileNames.Append(aName); + } + } + } + } + + SALOMEDS::SObject_var aMedFieldFather = theComponent->GetStudy()->FindObject("MEDFIELD"); + if (!CORBA::is_nil(aMedFieldFather)) { + SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedFieldFather); + for(; anIter->More(); anIter->Next()) { + SALOMEDS::SObject_var aSO = anIter->Value(); + SALOMEDS::GenericAttribute_var anAttr; + if (aSO->FindAttribute(anAttr,"AttributeIOR")) { + CORBA::Object_var myIOR = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()); + SALOME_MED::FIELD_var myField = SALOME_MED::FIELD::_narrow(myIOR); + if (! CORBA::is_nil(myField)) { + ostringstream a,b; + a<< myField->getOrderNumber(); + b<< myField->getIterationNumber(); + + TCollection_AsciiString aName(strdup(aSaveStudyName)); + aName += "_MEDFIELD_"; + aName += myField->getName(); + aName += "_ORDRE_"; + aName += strdup(a.str().c_str()); + aName += "_ITER_"; + aName += strdup(b.str().c_str()); + aName += ".med"; + MESSAGE("Save mesh with name "<addDriver(SALOME_MED::MED_DRIVER,(aTmpDir+aName).ToCString(),myField->getName()); + myField->write(driverId,""); + HDFascii::ConvertFromHDFToASCII(strdup((aTmpDir+aName).ToCString()), true); + aFileNames.Append(aName); + } + } + } + } + + int i; + aSeq->length(aFileNames.Length()); + for(i = aFileNames.Length(); i > 0; i--) aSeq[i-1] = CORBA::string_dup(aFileNames.Value(i).ToCString()); + // Conver a file to the byte stream + aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile); + // Remove the created file and tmp directory + if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true); // Return the created byte stream return aStreamFile._retn(); @@ -531,28 +648,53 @@ SALOMEDS::TMPFile* Med_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent) { */ //============================================================================= -CORBA::Boolean Med_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream) { +CORBA::Boolean Med_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + bool isMultiFile) { const char* LOC = "Med_Gen_i::Load"; BEGIN_OF(LOC); // Get a temporary directory for a file - TCollection_AsciiString aTmpDir = SALOMEDS_Tool::GetTmpDir(); + TCollection_AsciiString aTmpDir = + (isMultiFile)?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir(); _saveFileName = CORBA::string_dup(aTmpDir.ToCString()); - SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.ToCString()); + SALOMEDS::ListOfFileNames_var aSeq = + SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.ToCString(), isMultiFile); return true; END_OF(LOC); } +CORBA::Boolean Med_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + bool isMultiFile) { + return Load(theComponent, theStream, theURL, isMultiFile); +} + //============================================================================= /*! * CORBA: */ //============================================================================= -void Med_Gen_i::Close(const char *IORSComponent) +void Med_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent) { MESSAGE("Med_Gen_i::Close"); + SALOMEDS::SObject_var aMedMeshFather = theComponent->GetStudy()->FindObject("MEDMESH"); + if (!CORBA::is_nil(aMedMeshFather)) { + SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedMeshFather); + for(; anIter->More(); anIter->Next()) { + SALOMEDS::SObject_var aSO = anIter->Value(); + SALOMEDS::GenericAttribute_var anAttr; + if (aSO->FindAttribute(anAttr,"AttributeIOR")) { + CORBA::Object_var myIOR = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()); + SALOME_MED::MESH_var myMesh = SALOME_MED::MESH::_narrow(myIOR); + // here must call method destroy of myMesh, but it not implented yet + } + } + } } //============================================================================= @@ -573,14 +715,18 @@ char* Med_Gen_i::ComponentDataType() */ //============================================================================= -char* Med_Gen_i::IORToLocalPersistentID(const char* IORString, - CORBA::Boolean& IsAFile) -{ +char* Med_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, + const char* IORString, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII) { const char * LOC = "Med_Gen_i::IORToLocalPersistentID" ; BEGIN_OF(LOC) ; - SCRUTE(IORString); - if (string(IORString).size()==0) return strdup(""); + + string aSaveStudyName(strdup(SALOMEDS_Tool::GetNameFromPath(theSObject->GetStudy()->URL()))); + + + if (string(IORString).size()==0) return strdup((aSaveStudyName+"_MED").c_str()); // Well, we know where put object (_saveFilename) and we know object (IORString) // cast object : CORBA::Object_var myIOR = _orb->string_to_object(IORString); @@ -590,7 +736,7 @@ char* Med_Gen_i::IORToLocalPersistentID(const char* IORString, if (! CORBA::is_nil(myMed)) { // nothing to save : Support will be saved inside the mesh - string str_MedName="Objet Med + /OBJ_MED/"; + string str_MedName=aSaveStudyName + "_MED Objet Med + /OBJ_MED/"; return strdup(str_MedName.c_str()) ; } @@ -598,20 +744,8 @@ char* Med_Gen_i::IORToLocalPersistentID(const char* IORString, SALOME_MED::MESH_var myMesh = SALOME_MED::MESH::_narrow(myIOR); if (! CORBA::is_nil(myMesh)) { - string str_MeshName; - try - { - long driverId = myMesh->addDriver(SALOME_MED::MED_DRIVER,_saveFileName.c_str(),myMesh->getName()) ; - myMesh->write(driverId,""); - str_MeshName=string("/ENS_MAA/")+string(myMesh->getName()); - } - catch(...) - { - MESSAGE("Unable to save the mesh"); - THROW_SALOME_CORBA_EXCEPTION("Unable to save Mesh in Med"\ - ,SALOME::INTERNAL_ERROR); - } - return strdup(str_MeshName.c_str()) ; + CORBA::String_var aName((aSaveStudyName+"_MEDMESH_"+ myMesh->getName() + ".med").c_str()); + return strdup(aName._retn()) ; } // SUPPORT @@ -632,34 +766,25 @@ char* Med_Gen_i::IORToLocalPersistentID(const char* IORString, THROW_SALOME_CORBA_EXCEPTION("Unable to save Field in Med"\ ,SALOME::INTERNAL_ERROR); } - return strdup(str_SupportName.c_str()); + return strdup((aSaveStudyName+"_MED"+str_SupportName).c_str()); } SALOME_MED::FIELD_var myField = SALOME_MED::FIELD::_narrow(myIOR); if (! CORBA::is_nil(myField)) { - string str_FieldName; - try - { - long driverId = myField->addDriver(SALOME_MED::MED_DRIVER,_saveFileName.c_str(),myField->getName()) ; - myField->write(driverId,""); - str_FieldName=string("/CHA/")+string(myField->getName()); - ostringstream a,b; - a<< myField->getOrderNumber(); - b<< myField->getIterationNumber(); - str_FieldName+=string("/ORDRE/")+a.str()+string("/ITER/")+b.str(); - } - catch(...) - { - MESSAGE("Unable to save the mesh"); - THROW_SALOME_CORBA_EXCEPTION("Unable to save Field in Med"\ - ,SALOME::INTERNAL_ERROR); - } - return strdup(str_FieldName.c_str()); + string str_FieldName; + ostringstream a,b; + a<< myField->getOrderNumber(); + b<< myField->getIterationNumber(); + CORBA::String_var aName((aSaveStudyName+"_MEDFIELD_"+ myField->getName() + + string("_ORDRE_")+a.str()+ + string("_ITER_")+b.str() + + ".med").c_str()); + return strdup(aName._retn()); } //THROW_SALOME_CORBA_EXCEPTION("Unable to save IOR",SALOME::BAD_PARAM); - return strdup(""); + return strdup((aSaveStudyName+"_MED").c_str()); END_OF(LOC) ; } @@ -670,53 +795,81 @@ char* Med_Gen_i::IORToLocalPersistentID(const char* IORString, */ //============================================================================= -char* Med_Gen_i::LocalPersistentIDToIOR(const char* aLocalPersistentID) +char* Med_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, + const char* aLocalPersistentID, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII) + throw(SALOME::SALOME_Exception) { const char * LOC = "Med_Gen_i::LocalPersistentIDToIOR" ; BEGIN_OF(LOC) ; - TCollection_AsciiString aTmpDir(CORBA::string_dup(_saveFileName.c_str())); - TCollection_AsciiString aFileName("MED_tmp_"); - aFileName += CORBA::string_dup(aLocalPersistentID); - aFileName += ".med"; - MESH * myMesh= new MESH() ; - myMesh->setName(aLocalPersistentID); - MED_MESH_RDONLY_DRIVER myMeshDriver((aTmpDir+aFileName).ToCString(),myMesh); - try - { - myMeshDriver.setMeshName(aLocalPersistentID); - myMeshDriver.open(); - } - catch (const exception & ex) - { - MESSAGE("Exception Interceptee : "); - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Unable to find this mesh in this file",SALOME::BAD_PARAM); - }; - try - { - myMeshDriver.read(); - MESSAGE("apres read"); - myMeshDriver.close(); + string aSaveStudyName(strdup(SALOMEDS_Tool::GetNameFromPath(theSObject->GetStudy()->URL()))); + int aStudyNameLen = strlen(aSaveStudyName.c_str()); + + if (strlen(aLocalPersistentID) <= aStudyNameLen) return strdup(""); + if (strcmp(aLocalPersistentID, "Objet Med + /OBJ_MED/") == 0) return strdup(""); // MED + + if (strncmp(&(aLocalPersistentID[aStudyNameLen]), "_MEDMESH_",9) == 0) {// MESH + MESH * myMesh= new MESH() ; + int aMeshNameLen = strlen(aLocalPersistentID) - 12 - aStudyNameLen; + char* aMeshName = new char[aMeshNameLen]; + strncpy(aMeshName, &(aLocalPersistentID[aStudyNameLen + 9]), aMeshNameLen-1); + aMeshName[aMeshNameLen-1] = 0; + myMesh->setName(aMeshName); + + char* aFileName; + if (isASCII) { + char* aResultPath = HDFascii::ConvertFromASCIIToHDF((aTmpDir + strdup(aLocalPersistentID)).ToCString()); + aFileName = new char[strlen(aResultPath) + 19]; + sprintf(aFileName, "%shdf_from_ascii.hdf", aResultPath); + delete(aResultPath); + } else aFileName = strdup((aTmpDir + strdup(aLocalPersistentID)).ToCString()); + MED_MESH_RDONLY_DRIVER myMeshDriver(aFileName,myMesh); + try + { + myMeshDriver.setMeshName(aMeshName); + myMeshDriver.open(); + } + catch (const exception & ex) + { + MESSAGE("Exception Interceptee : "); + SCRUTE(ex.what()); + THROW_SALOME_CORBA_EXCEPTION("Unable to find this mesh in this file",SALOME::BAD_PARAM); + }; + try + { + myMeshDriver.read(); + MESSAGE("apres read"); + myMeshDriver.close(); + } + catch (const exception & ex) + { + MESSAGE("Exception Interceptee : "); + SCRUTE(ex.what()); + THROW_SALOME_CORBA_EXCEPTION("Unable to read this mesh in this file",SALOME::BAD_PARAM); + } + MESH_i * meshi = new MESH_i(myMesh); + //SALOME_MED::MESH_var mesh = SALOME_MED::MESH::_narrow(meshi->_this()); + SALOME_MED::MESH_ptr mesh = meshi->_this(); + SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; + aSeq->length(1); + aSeq[0]=CORBA::string_dup(aLocalPersistentID); + if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true); + if (isASCII) { + SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames; + aFilesToRemove->length(1); + aFilesToRemove[0] = strdup(&(aFileName[strlen(SALOMEDS_Tool::GetDirFromPath(aFileName))])); + SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aFileName), aFilesToRemove, true); } - catch (const exception & ex) - { - MESSAGE("Exception Interceptee : "); - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Unable to read this mesh in this file",SALOME::BAD_PARAM); - }; - - MESH_i * meshi = new MESH_i(myMesh); - //SALOME_MED::MESH_var mesh = SALOME_MED::MESH::_narrow(meshi->_this()); - SALOME_MED::MESH_ptr mesh = meshi->_this(); - - SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - aSeq->length(1); - aSeq[0]=CORBA::string_dup(aFileName.ToCString()); - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq, true); + delete(aFileName); + return(CORBA::string_dup(_orb->object_to_string(mesh))); + } else if (strncmp(&(aLocalPersistentID[aStudyNameLen]), "_MEDFIELD_",14) == 0) { // FIELD + return(strdup("")); // not implemented yet + } - return(CORBA::string_dup(_orb->object_to_string(mesh))); + return strdup(""); END_OF(LOC) ; } @@ -773,6 +926,139 @@ SALOMEDS::SObject_ptr Med_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, return aResultSO._retn(); } +//============================================================================= +/*! + * returns true, if can copy the object + */ +//============================================================================= +CORBA::Boolean Med_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) { + // Try to retrieve known by MED component mesh by given IOR + SALOMEDS::GenericAttribute_var anAttr; + if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return false; + CORBA::Object_var anObj = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()); + SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(anObj); + // If the object is null one it can't be copied: return false + if (aMesh->_is_nil()) return false; + return true; +} + +//============================================================================= +/*! + * create copy of the object and put it to the stream + */ +//============================================================================= +SALOMEDS::TMPFile* Med_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) { + // Declare a sequence of the byte to store the copied object + SALOMEDS::TMPFile_var aStreamFile; + + // Try to get GEOM_Shape object by given SObject + SALOMEDS::GenericAttribute_var anAttr; + if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return new SALOMEDS::TMPFile(0); + CORBA::String_var anIOR = strdup(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()); + CORBA::Object_var anObj = _orb->string_to_object(anIOR); + SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(anObj); + if (aMesh->_is_nil()) return new SALOMEDS::TMPFile(0); + + // Get a temporary directory to store a temporary file + CORBA::String_var aTmpDir = SALOMEDS_Tool::GetTmpDir(); + // Create a list to store names of created files + SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; + aSeq->length(1); + aSeq[0] = strdup(aMesh->getName()); + char* aFullName = new char[strlen(aTmpDir)+strlen(aSeq[0])+1]; + strcpy(aFullName, aTmpDir); + strcpy(aFullName+strlen(aTmpDir), aSeq[0]); + long driverId = aMesh->addDriver(SALOME_MED::MED_DRIVER,strdup(aFullName) , aMesh->getName()); + aMesh->write(driverId,""); + delete(aFullName); + + aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aSeq.in(), false); + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeq.in(), true); + + // Assign an ID = 1 the the type SALOME_MED::MESH + theObjectID = 1; + + return aStreamFile._retn(); +} + +//============================================================================= +/*! + * returns true, if can copy the object + */ +//============================================================================= +CORBA::Boolean Med_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) { + // The MED component can paste only objects copied by MED component + // and with the object type = 1 (mesh) + if (strcmp(theComponentName, ComponentDataType()) != 0 || theObjectID != 1) return false; + return true; +} + +//============================================================================= +/*! + * returns true, if can copy the object + */ +//============================================================================= +SALOMEDS::SObject_ptr Med_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream, + CORBA::Long theObjectID, + SALOMEDS::SObject_ptr theObject) { + SALOMEDS::SObject_var aResultSO = SALOMEDS::SObject::_duplicate(theObject); + if (theStream.length() == 0) return aResultSO._retn(); + + SALOMEDS::Study_var aStudy = theObject->GetStudy(); + + CORBA::String_var aTmpDir = strdup(SALOMEDS_Tool::GetTmpDir()); + SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false); + CORBA::String_var aMeshName = strdup(aSeq[0]); + char* aFullName = new char[strlen(aTmpDir)+strlen(aMeshName)+1]; + strcpy(aFullName, aTmpDir); + strcpy(aFullName+strlen(aTmpDir), aMeshName); + + MESH * myMesh= new MESH() ; + myMesh->setName((char*)aMeshName); + MED_MESH_RDONLY_DRIVER myMeshDriver(aFullName, myMesh); + try { + myMeshDriver.setMeshName((char*)aMeshName); + myMeshDriver.open(); + } catch (const exception & ex) { + MESSAGE("Exception Interceptee : "); + SCRUTE(ex.what()); + delete(aFullName); + return aResultSO._retn(); + }; + try { + myMeshDriver.read(); + ("apres read"); + myMeshDriver.close(); + } catch (const exception & ex) { + MESSAGE("Exception Interceptee : "); + SCRUTE(ex.what()); + delete(aFullName); + return aResultSO._retn(); + }; + // set new mesh name, becouse now there are no possibility to operate meshes with the same names +// srand((unsigned int)time(NULL)); + int aRND = rand(); //Get a random number to present a name of a copied mesh + char aCopiedMeshName[20]; + sprintf(aCopiedMeshName,"MESH_COPY_%d",aRND); + myMesh->setName(aCopiedMeshName); + MESH_i * meshi = new MESH_i(myMesh); + SALOME_MED::MESH_ptr mesh = meshi->_this(); + // add the mesh object in study + meshi->addInStudy(aStudy,mesh); + // get the IOR attribute of just added mesh + CORBA::String_var anIORString = _orb->object_to_string(mesh); + aResultSO = aStudy->FindObjectIOR(anIORString); + + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeq.in(), true); + delete(aFullName); + return aResultSO._retn(); +} + + + + + + //============================================================================= /*! * C factory, accessible with dlsym, after dlopen diff --git a/src/MED/Med_Gen_i.hxx b/src/MED/Med_Gen_i.hxx index 976becfaf..e71790da0 100644 --- a/src/MED/Med_Gen_i.hxx +++ b/src/MED/Med_Gen_i.hxx @@ -1,11 +1,30 @@ -//============================================================================= -// File : Med_Gen_i.hxx -// Created : mer fév 20 15:47:52 CET 2002 -// Author : Paul RASCLE, EDF -// Project : SALOME -// Copyright : EDF 2001 -// $Header$ -//============================================================================= +// MED MED : implemetation of MED idl descriptions +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : Med_Gen_i.hxx +// Author : Paul RASCLE, EDF +// Module : MED +// $Header$ #ifndef _MED_GEN_I_HXX_ #define _MED_GEN_I_HXX_ @@ -64,13 +83,34 @@ public: // void Save(const char *IORSComponent, const char *aUrlOfFile); // void Load(const char *IORSComponent, const char *aUrlOfFile); - SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent); - CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream); - void Close(const char *IORSComponent); + SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile); + SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile); + + CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + bool isMultiFile); + CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + bool isMultiFile); + + void Close(SALOMEDS::SComponent_ptr theComponent); char* ComponentDataType(); - char* IORToLocalPersistentID(const char* IORString, CORBA::Boolean& IsAFile); - char* LocalPersistentIDToIOR(const char* aLocalPersistentID); + char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, + const char* IORString, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII); + char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, + const char* aLocalPersistentID, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII) + throw(SALOME::SALOME_Exception); bool CanPublishInStudy(CORBA::Object_ptr theIOR); @@ -78,6 +118,14 @@ public: SALOMEDS::SObject_ptr theSObject, CORBA::Object_ptr theObject, const char* theName) throw (SALOME::SALOME_Exception) ; + + CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject); + SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID); + CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID); + SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream, + CORBA::Long theObjectID, + SALOMEDS::SObject_ptr theObject); + private : static map _MedCorbaObj; static string _myFileName; diff --git a/src/MEDGUI/Makefile.in b/src/MEDGUI/Makefile.in index c3af1f19f..9713a68d7 100644 --- a/src/MEDGUI/Makefile.in +++ b/src/MEDGUI/Makefile.in @@ -1,13 +1,31 @@ -#============================================================================== -# File : Makefile.in -# Created : dim déc 9 18:35:11 CET 2001 -# Author : Paul RASCLE, EDF -# Project : SALOME -# Copyright : EDF 2001 +# MED MEDGUI : MED component GUI implemetation +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Paul RASCLE, EDF +# Module : MED # $Header$ -#============================================================================== -# source path top_srcdir=@top_srcdir@ top_builddir=../../.. srcdir=@srcdir@ diff --git a/src/MEDGUI/MedGUI.cxx b/src/MEDGUI/MedGUI.cxx index ff3690a61..e62b1a0e4 100644 --- a/src/MEDGUI/MedGUI.cxx +++ b/src/MEDGUI/MedGUI.cxx @@ -1,9 +1,30 @@ -//============================================================================= -// File : MedGUI.cxx -// Project : SALOME -// Copyright : EDF 2001 -//============================================================================= - +// MED MEDGUI : MED component GUI implemetation +// +// 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 : MedGUI.cxx +// Module : MED + +using namespace std; #include "MedGUI.h" // SALOME Includes @@ -184,7 +205,8 @@ bool MedGUI::OnGUIEvent (int theCommandID, QAD_Desktop* parent) SCRUTE(file); try { - medgen->readStructFile(file.latin1(),myStudyName); +// medgen->readStructFile(file.latin1(),myStudyName); + medgen->readStructFileWithFieldType(file.latin1(),myStudyName); if (myActiveStudy->getStudyDocument()->GetProperties()->IsLocked()) { QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(), QObject::tr("WRN_WARNING"), diff --git a/src/MEDGUI/MedGUI.h b/src/MEDGUI/MedGUI.h index 50ce9f4df..ead68fed1 100644 --- a/src/MEDGUI/MedGUI.h +++ b/src/MEDGUI/MedGUI.h @@ -1,8 +1,11 @@ -//============================================================================= -// File : MEDGUI.h -// Project : SALOME -// Copyright : EDF 2001 -//============================================================================= +// MED MEDGUI : MED component GUI implemetation +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : MEDGUI.h +// Module : MED #ifndef _MEDGUI_H_ #define _MEDGUI_H_ diff --git a/src/MEDGUI/MedGUI_icons.po b/src/MEDGUI/MedGUI_icons.po index e1121dcdf..60a4ae8fd 100644 --- a/src/MEDGUI/MedGUI_icons.po +++ b/src/MEDGUI/MedGUI_icons.po @@ -1,7 +1,29 @@ -# This is a Qt message file in .po format. Each msgid starts with -# a scope. This scope should *NOT* be translated - eg. translating -# from French to English, "Foo::Bar" would be translated to "Pub", -# not "Foo::Pub". +# MED MEDGUI : MED component GUI implemetation +# +# 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 : MedGUI_icons.po +# Module : MED + msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" diff --git a/src/MEDGUI/MedGUI_msg_en.po b/src/MEDGUI/MedGUI_msg_en.po index 429a86caa..614fb7495 100644 --- a/src/MEDGUI/MedGUI_msg_en.po +++ b/src/MEDGUI/MedGUI_msg_en.po @@ -1,7 +1,29 @@ -# This is a Qt message file in .po format. Each msgid starts with -# a scope. This scope should *NOT* be translated - eg. translating -# from French to English, "Foo::Bar" would be translated to "Pub", -# not "Foo::Pub". +# MED MEDGUI : MED component GUI implemetation +# +# 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 : MedGUI_msg_en.po +# Module : MED + msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" diff --git a/src/MEDGUI/MedGUI_msg_fr.po b/src/MEDGUI/MedGUI_msg_fr.po index ed84d64c4..16aa35c2d 100644 --- a/src/MEDGUI/MedGUI_msg_fr.po +++ b/src/MEDGUI/MedGUI_msg_fr.po @@ -1,7 +1,29 @@ -# This is a Qt message file in .po format. Each msgid starts with -# a scope. This scope should *NOT* be translated - eg. translating -# from French to English, "Foo::Bar" would be translated to "Pub", -# not "Foo::Pub". +# MED MEDGUI : MED component GUI implemetation +# +# 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 : MedGUI_msg_fr.po +# Module : MED + msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" diff --git a/src/MEDMEM/DataTest/Data/maill.0.med b/src/MEDMEM/DataTest/Data/maill.0.med new file mode 100644 index 000000000..e5a7b130d Binary files /dev/null and b/src/MEDMEM/DataTest/Data/maill.0.med differ diff --git a/src/MEDMEM/DataTest/Data/mesh.med b/src/MEDMEM/DataTest/Data/mesh.med new file mode 100755 index 000000000..5f7a25c55 Binary files /dev/null and b/src/MEDMEM/DataTest/Data/mesh.med differ diff --git a/src/MEDMEM/DataTest/Data/pointe.med b/src/MEDMEM/DataTest/Data/pointe.med new file mode 100644 index 000000000..430a74bd6 Binary files /dev/null and b/src/MEDMEM/DataTest/Data/pointe.med differ diff --git a/src/MEDMEM/DataTest/Data/zzzz121b.med b/src/MEDMEM/DataTest/Data/zzzz121b.med new file mode 100644 index 000000000..b28cebd2d Binary files /dev/null and b/src/MEDMEM/DataTest/Data/zzzz121b.med differ diff --git a/src/MEDMEM/DataTest/Maillages.txt b/src/MEDMEM/DataTest/Maillages.txt new file mode 100644 index 000000000..75d2c8dfe --- /dev/null +++ b/src/MEDMEM/DataTest/Maillages.txt @@ -0,0 +1,5 @@ +maill.0.med:MAILTRQU: +pointe.med:maa1: +mesh.med:Mesh 1: +zzzz121b.med:MUN: +zzzz121b.med:MZERO:2 diff --git a/src/MEDMEM/DataTest/README b/src/MEDMEM/DataTest/README new file mode 100644 index 000000000..d6ef4443a --- /dev/null +++ b/src/MEDMEM/DataTest/README @@ -0,0 +1,54 @@ + +mesh.med maillage du cube par SMESH +pointe.med fichier de test cree par Med Memoire +zzzz121b.med maillages Aster + champ : sert a Aster de fichier de test +maill.0.med petit fichier Aster (2D) + +Seuls les 2 premiers fichiers peuvent etre entierement lus par Med Memoire en version V08.2 : +Les 2 autres fichiers contiennent des points de Gauss qui ne seront pas gérés avant +la version V08.4 de Med Memoire. + + Utilisation des tests + --------------------- + +1) Tests Unitaires +__________________ + +Il faut récuperer les fichiers de reference +puis lancer tous.sh (apres avoir modifier les variables selon votre +environnement (SALOME,SALOME_LIB et SALOME_PATH) ) + + +Les resultats "grossiers" (OK ou NOK) sont dans le fichier cpterendu. +La "log" des résultats est dans le fichier result_test + + +2) Les deux tests readCoordinate et ReadEntete +______________________________________________ + +Ces deux tests, à terme devront permettre d'avoir un équivalent à mdump + + +A Constitution des fichiers de référence mdump +---------------------------------------------- + +Une liste des fichiers avec les noms de maillages associés se trouve +dans le fichier Maillages.txt sous la forme: + + nom de fichier:nom de maillage:numero du maillage + +creer la directory Ref +lancer constituedump.sh (apres avoir modifier les variables selon votre +environnement (SALOME,SALOME_LIB et SALOME_PATH) ) + +B Comparaison avec ces fichiers +------------------------------- + +Lancer testReadCoordinate.sh (apres avoir modifier les variables selon votre +environnement (SALOME,SALOME_LIB et SALOME_PATH) ) +Lancer testReadEntete.sh (apres avoir modifier les variables selon votre +environnement (SALOME,SALOME_LIB et SALOME_PATH) ) + +Les resultats sont dans le fichier PourMail + + diff --git a/src/MEDMEM/DataTest/Ref/RtestUCellModel b/src/MEDMEM/DataTest/Ref/RtestUCellModel new file mode 100644 index 000000000..4c7c3c4d1 --- /dev/null +++ b/src/MEDMEM/DataTest/Ref/RtestUCellModel @@ -0,0 +1,244 @@ +CELLMODEL Test +-------------- + +MED_POINT1 +__________________ +CellModel de Nom : MED_POINT1 +Nb de Vertexes : 1 +Nb de Noeuds : 1 +Dimension : 0 + + +MED_SEG2 +__________________ +CellModel de Nom : MED_SEG2 +Nb de Vertexes : 2 +Nb de Noeuds : 2 +Dimension : 1 + + +MED_SEG3 +__________________ +CellModel de Nom : MED_SEG3 +Nb de Vertexes : 2 +Nb de Noeuds : 3 +Dimension : 1 + + +MED_TRIA3 +__________________ +CellModel de Nom : MED_TRIA3 +Nb de Vertexes : 3 +Nb de Noeuds : 3 +Dimension : 2 +Nb d elements de dimension 1 : 3 +Types de ces elements +MED_SEG2 +Impression des coordonnées du 1er Element de ce type +1 2 + +Informations particulieres - dimension 1 +MED_SEG2 + +MED_QUAD4 +__________________ +CellModel de Nom : MED_QUAD4 +Nb de Vertexes : 4 +Nb de Noeuds : 4 +Dimension : 2 +Nb d elements de dimension 1 : 4 +Types de ces elements +MED_SEG2 +Impression des coordonnées du 1er Element de ce type +1 2 + +Informations particulieres - dimension 1 +MED_SEG2 + +MED_TRIA6 +__________________ +CellModel de Nom : MED_TRIA6 +Nb de Vertexes : 3 +Nb de Noeuds : 6 +Dimension : 2 +Nb d elements de dimension 1 : 3 +Types de ces elements +MED_SEG3 +Impression des coordonnées du 1er Element de ce type +1 2 4 + +Informations particulieres - dimension 1 +MED_SEG3 + +MED_QUAD8 +__________________ +CellModel de Nom : MED_QUAD8 +Nb de Vertexes : 4 +Nb de Noeuds : 8 +Dimension : 2 +Nb d elements de dimension 1 : 4 +Types de ces elements +MED_SEG3 +Impression des coordonnées du 1er Element de ce type +1 2 5 + +Informations particulieres - dimension 1 +MED_SEG3 + +MED_TETRA4 +__________________ +CellModel de Nom : MED_TETRA4 +Nb de Vertexes : 4 +Nb de Noeuds : 4 +Dimension : 3 +Nb d elements de dimension 1 : 6 +Types de ces elements +MED_SEG2 +Impression des coordonnées du 1er Element de ce type +1 2 +Nb d elements de dimension 2 : 4 +Types de ces elements +MED_TRIA3 +Impression des coordonnées du 1er Element de ce type +1 2 3 + +Informations particulieres - dimension 2 +MED_TRIA3 + +MED_PYRA5 +__________________ +CellModel de Nom : MED_PYRA5 +Nb de Vertexes : 5 +Nb de Noeuds : 5 +Dimension : 3 +Nb d elements de dimension 1 : 8 +Types de ces elements +MED_SEG2 +Impression des coordonnées du 1er Element de ce type +1 2 +Nb d elements de dimension 2 : 5 +Types de ces elements +MED_TRIA3 +MED_QUAD4 +Impression des coordonnées du 1er Element de ce type +1 2 3 4 + +Informations particulieres - dimension 2 + +MED_PENTA6 +__________________ +CellModel de Nom : MED_PENTA6 +Nb de Vertexes : 6 +Nb de Noeuds : 6 +Dimension : 3 +Nb d elements de dimension 1 : 9 +Types de ces elements +MED_SEG2 +Impression des coordonnées du 1er Element de ce type +1 2 +Nb d elements de dimension 2 : 5 +Types de ces elements +MED_TRIA3 +MED_QUAD4 +Impression des coordonnées du 1er Element de ce type +1 2 3 + +Informations particulieres - dimension 2 + +MED_HEXA8 +__________________ +CellModel de Nom : MED_HEXA8 +Nb de Vertexes : 8 +Nb de Noeuds : 8 +Dimension : 3 +Nb d elements de dimension 1 : 12 +Types de ces elements +MED_SEG2 +Impression des coordonnées du 1er Element de ce type +1 2 +Nb d elements de dimension 2 : 6 +Types de ces elements +MED_QUAD4 +Impression des coordonnées du 1er Element de ce type +1 2 3 4 + +Informations particulieres - dimension 2 + +MED_TETRA10 +__________________ +CellModel de Nom : MED_TETRA10 +Nb de Vertexes : 4 +Nb de Noeuds : 10 +Dimension : 3 +Nb d elements de dimension 1 : 6 +Types de ces elements +MED_SEG3 +Impression des coordonnées du 1er Element de ce type +1 2 5 +Nb d elements de dimension 2 : 4 +Types de ces elements +MED_TRIA6 +Impression des coordonnées du 1er Element de ce type +1 2 3 5 6 7 + +Informations particulieres - dimension 2 +MED_TRIA6 + +MED_PYRA13 +__________________ +CellModel de Nom : MED_PYRA13 +Nb de Vertexes : 5 +Nb de Noeuds : 13 +Dimension : 3 +Nb d elements de dimension 1 : 8 +Types de ces elements +MED_SEG3 +Impression des coordonnées du 1er Element de ce type +1 2 6 +Nb d elements de dimension 2 : 5 +Types de ces elements +MED_TRIA6 +MED_QUAD8 +Impression des coordonnées du 1er Element de ce type +1 2 3 4 6 7 8 9 + +Informations particulieres - dimension 2 + +MED_PENTA15 +__________________ +CellModel de Nom : MED_PENTA15 +Nb de Vertexes : 6 +Nb de Noeuds : 15 +Dimension : 3 +Nb d elements de dimension 1 : 9 +Types de ces elements +MED_SEG3 +Impression des coordonnées du 1er Element de ce type +1 2 7 +Nb d elements de dimension 2 : 5 +Types de ces elements +MED_TRIA6 +MED_QUAD8 +Impression des coordonnées du 1er Element de ce type +1 2 3 7 8 9 + +Informations particulieres - dimension 2 + +MED_HEXA20 +__________________ +CellModel de Nom : MED_HEXA20 +Nb de Vertexes : 8 +Nb de Noeuds : 20 +Dimension : 3 +Nb d elements de dimension 1 : 12 +Types de ces elements +MED_SEG3 +Impression des coordonnées du 1er Element de ce type +1 2 9 +Nb d elements de dimension 2 : 6 +Types de ces elements +MED_QUAD8 +Impression des coordonnées du 1er Element de ce type +1 2 3 4 9 10 11 12 + +Informations particulieres - dimension 2 diff --git a/src/MEDMEM/DataTest/Ref/RtestUGeoNameMeshEntities b/src/MEDMEM/DataTest/Ref/RtestUGeoNameMeshEntities new file mode 100644 index 000000000..a0ad7c1b1 --- /dev/null +++ b/src/MEDMEM/DataTest/Ref/RtestUGeoNameMeshEntities @@ -0,0 +1,53 @@ +GEO_NAME Test +------------- + +MED_NONE +MED_POINT1 +MED_SEG2 +MED_SEG3 +MED_TRIA3 +MED_QUAD4 +MED_TRIA6 +MED_QUAD8 +MED_TETRA4 +MED_PYRA5 +MED_PENTA6 +MED_HEXA8 +MED_TETRA10 +MED_PYRA13 +MED_PENTA15 +MED_HEXA20 + +MESH_ENTITIES Test +------------------ + +MED_MAILLE +MED_POINT1 +MED_SEG2 +MED_SEG3 +MED_TRIA3 +MED_TRIA6 +MED_QUAD4 +MED_QUAD8 +MED_TETRA4 +MED_TETRA10 +MED_HEXA8 +MED_HEXA20 +MED_PENTA6 +MED_PENTA15 +MED_PYRA5 +MED_PYRA13 + +MED_FACE +MED_TRIA3 +MED_TRIA6 +MED_QUAD4 +MED_QUAD8 + +MED_ARETE +MED_SEG2 +MED_SEG3 + +MED_NOEUD +MED_NONE + diff --git a/src/MEDMEM/DataTest/constituedump.sh b/src/MEDMEM/DataTest/constituedump.sh new file mode 100644 index 000000000..90faa0ae2 --- /dev/null +++ b/src/MEDMEM/DataTest/constituedump.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# +# 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 : constituedump.sh +# Module : MED + +cd Data +for i in `ls *.med` +do + echo "constitution de $i : 1er maillage" + mdump $i > ${i}.coor.dump << EOF +1 +1 +1 +EOF +cp ${i}.coor.dump ${i}.ent.dump +done + +for i in `echo zzzz121b.med` +do + echo "constitution de $i : 2nd maillage" + mdump $i > ${i}.2.coor.dump << EOF +1 +1 +2 +EOF +cp ${i}.2.coor.dump ${i}.2.ent.dump +done + +mv *.dump ../Ref +cd ../Ref + +for j in `ls *.ent.dump` +do +echo "Traitement de $j : " +vi ${j} << EOF +:/INFORMATIONS GENERALES +:-2 +:1,.d +:/Nombre de familles +:.,\$d +:wq +EOF +done + +for j in `ls *.coor.dump` +do +echo "Traitement de $j : " +vi ${j} << EOF +:/NOEUDS DU MAILLAGE +:-2 +:1,.d +:/Coordonnees des noeuds +: +2 +:.,\$d +:wq +EOF +done + + diff --git a/src/MEDMEM/DataTest/testreadCoordinate.sh b/src/MEDMEM/DataTest/testreadCoordinate.sh new file mode 100755 index 000000000..ecf163058 --- /dev/null +++ b/src/MEDMEM/DataTest/testreadCoordinate.sh @@ -0,0 +1,86 @@ +#!/bin/sh +# +# 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 : testreadCoordinate.sh +# Module : MED + +SALOME=${HOME}/V08 +SALOME_LIB=${SALOME}/Build/lib +SALOME_PATH=${SALOME}/Build/MED/src/MEDMEM +LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${SALOME_LIB} +RESULT=PourMail + +rm -rf ${RESULT} +echo " - Comparaison des Coordonnees : " >> ${RESULT} +echo -e " -------------------------------\n">> ${RESULT} + +npb=0; +num=1 +while [ true ] +do + ligne=`sed -n -e"$num,$num p" Maillages.txt` + num=`expr $num + 1 ` + if [ "$ligne" = "" ] + then + break + fi + if [ `echo $ligne | cut -c1 ` = "#" ] + then + echo "COMMENTAIRE" + continue + fi + fich=`echo $ligne | cut -f1 -d":"` + maill=`echo $ligne | cut -f2 -d":"` + nb=`echo $ligne | cut -f3 -d":"` + if [ "$nb" = "" ] + then + Result=Rmem/Rmem.${fich}.coor.dump + Compare=Ref/${fich}.coor.dump + else + Result=Rmem/Rmem.${fich}.${nb}.coor.dump + Compare=Ref/${fich}.${nb}.coor.dump + fi + ${SALOME_PATH}/readCoordinate Data/${fich} "${maill}" > $Result + + echo " Maillage " $maill "lu dans " $fich >> ${RESULT} + diff $Result $Compare >> /dev/null + rc=$? + if [ "$rc" != "0" ] + then + nb=`diff $Result $Compare| grep -v "Type de repere des coordonnees" | wc -l` + nb=`expr $nb + 0 ` + if [ "$nb" != "2" ] + then + echo " Difference entre les resultats des deux methodes de dumps : " >> ${RESULT} + echo " Fichiers compares : $Result et $Compare " >> ${RESULT} + diff $Result $Compare >> ${RESULT} + echo -e "\n">> ${RESULT} + npb=`expr $npb + 1 ` + else + echo " Pas de différence sur les coordonnees == test OK == " >> ${RESULT} + fi + else + echo " Pas de différence sur les coordonnees == test OK == " >> ${RESULT} + fi + echo -e "\n" >> ${RESULT} +done diff --git a/src/MEDMEM/DataTest/testreadEntete.sh b/src/MEDMEM/DataTest/testreadEntete.sh new file mode 100755 index 000000000..26101b85a --- /dev/null +++ b/src/MEDMEM/DataTest/testreadEntete.sh @@ -0,0 +1,85 @@ +#!/bin/sh +# +# 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 : testreadEntete.sh +# Module : MED + +SALOME=${HOME}/V08 +SALOME_LIB=${SALOME}/Build/lib +SALOME_PATH=${SALOME}/Build/MED/src/MEDMEM +LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${SALOME_LIB} +RESULT=PourMail + +echo " - Comparaison des Entetes : " >> ${RESULT} +echo -e " ------------------------\n">> ${RESULT} + +npb=0; +num=1 +while [ true ] +do + ligne=`sed -n -e"$num,$num p" Maillages.txt` + num=`expr $num + 1 ` + if [ "$ligne" = "" ] + then + break + fi + if [ `echo $ligne | cut -c1 ` = "#" ] + then + echo "COMMENTAIRE" + continue + fi + fich=`echo $ligne | cut -f1 -d":"` + maill=`echo $ligne | cut -f2 -d":"` + nb=`echo $ligne | cut -f3 -d":"` + if [ "$nb" = "" ] + then + Result=Rmem/Rmem.${fich}.ent.dump + Compare=Ref/${fich}.ent.dump + else + Result=Rmem/Rmem.${fich}.${nb}.ent.dump + Compare=Ref/${fich}.${nb}.ent.dump + fi + ${SALOME_PATH}/readEntete Data/${fich} "${maill}" > $Result + + echo " Maillage " $maill "lu dans " $fich >> ${RESULT} + diff $Result $Compare >> /dev/null + rc=$? + if [ "$rc" != "0" ] + then + nb=`diff $Result $Compare| grep -v "Type de repere des coordonnees" | wc -l` + nb=`expr $nb + 0 ` + # if [ "$nb" != "2" ] + # then + echo " Difference entre les resultats des deux methodes de dumps : " >> ${RESULT} + echo " Fichiers compares : $Result et $Compare " >> ${RESULT} + diff $Result $Compare >> ${RESULT} + echo -e "\n">> ${RESULT} + npb=`expr $npb + 1 ` + # else + # echo " Pas de différence sur les coordonnees == test OK == " >> ${RESULT} + # fi + else + echo " Pas de différence sur les informations generales == test OK == " >> ${RESULT} + fi + echo -e "\n" >> ${RESULT} +done diff --git a/src/MEDMEM/DataTest/tous.sh b/src/MEDMEM/DataTest/tous.sh new file mode 100755 index 000000000..52acaa46d --- /dev/null +++ b/src/MEDMEM/DataTest/tous.sh @@ -0,0 +1,54 @@ +# 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 : tous.sh +# Module : MED + +SALOME=${HOME}/V08 +SALOME_LIB=${SALOME}/Build/lib +SALOME_PATH=${SALOME}/Build/MED/src/MEDMEM +LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${SALOME_LIB} +RESULT=cptrendu +rm -rf ${RESULT} + +echo " Tests Unitaires " >> $RESULT +echo " --------------- " >> $RESULT +echo " " >> $RESULT + +for prog in testUGeoNameMeshEntities testUCellModel testUUnit testUCoordinate +#for prog in testUCoordinate +do + + echo "Passage du test : " ${prog} + echo "" >> result_test + echo "Passage du test : " ${prog} >> result_test + echo "Passage du test : " ${prog} + ${SALOME_PATH}/${prog} >> result_test + rc=$? + if [ "$rc" = "0" ] + then + echo "Test de " $prog " == Test OK" >> $RESULT + echo " " >> $RESULT + else + echo "Test de " $prog " NOK !!!!!!" >> $RESULT + fi +done +cat $RESULT diff --git a/src/MEDMEM/Doxyfile_med_devel.in b/src/MEDMEM/Doxyfile_med_devel.in new file mode 100644 index 000000000..68ce107e5 --- /dev/null +++ b/src/MEDMEM/Doxyfile_med_devel.in @@ -0,0 +1,172 @@ +# Doxyfile 0.1 + +#--------------------------------------------------------------------------- +# General configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = medmemoire +PROJECT_NUMBER = 1.0 +OUTPUT_DIRECTORY = doc_ref +OUTPUT_LANGUAGE = English +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ALWAYS_DETAILED_SEC = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = +INTERNAL_DOCS = NO +STRIP_CODE_COMMENTS = YES +CASE_SENSE_NAMES = YES +SHORT_NAMES = NO +HIDE_SCOPE_NAMES = NO +VERBATIM_HEADERS = YES +SHOW_INCLUDE_FILES = YES +JAVADOC_AUTOBRIEF = NO +INHERIT_DOCS = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 8 +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +ALIASES = +ENABLED_SECTIONS = developper +MAX_INITIALIZER_LINES = 30 +OPTIMIZE_OUTPUT_FOR_C = NO +SHOW_USED_FILES = YES +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_FORMAT = +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = @srcdir@ +FILE_PATTERNS = MEDMEM*.hxx \ + MEDMEM*.cxx +RECURSIVE = NO +EXCLUDE = CVS +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = YES +GENERATE_CHI = YES +BINARY_TOC = NO +TOC_EXPAND = YES +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = YES +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = YES +LATEX_OUTPUT = +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = +MAN_EXTENSION = +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::addtions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +PERL_PATH = +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HAVE_DOT = YES +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +TEMPLATE_RELATIONS = YES +HIDE_UNDOC_RELATIONS = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +GRAPHICAL_HIERARCHY = YES +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::addtions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO +CGI_NAME = +CGI_URL = +DOC_URL = +DOC_ABSPATH = +BIN_ABSPATH = +EXT_DOC_PATHS = diff --git a/src/MEDMEM/Doxyfile_med_user.in b/src/MEDMEM/Doxyfile_med_user.in new file mode 100644 index 000000000..0ac5081bc --- /dev/null +++ b/src/MEDMEM/Doxyfile_med_user.in @@ -0,0 +1,179 @@ +# Doxyfile 0.1 + +#--------------------------------------------------------------------------- +# General configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = MED +PROJECT_NUMBER = 1.0 +OUTPUT_DIRECTORY = doc_ref_user +OUTPUT_LANGUAGE = English +EXTRACT_ALL = NO +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +HIDE_UNDOC_MEMBERS = YES +HIDE_UNDOC_CLASSES = YES +BRIEF_MEMBER_DESC = NO +REPEAT_BRIEF = YES +ALWAYS_DETAILED_SEC = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = +INTERNAL_DOCS = NO +STRIP_CODE_COMMENTS = YES +CASE_SENSE_NAMES = YES +SHORT_NAMES = NO +HIDE_SCOPE_NAMES = NO +VERBATIM_HEADERS = NO +SHOW_INCLUDE_FILES = NO +JAVADOC_AUTOBRIEF = NO +INHERIT_DOCS = YES +INLINE_INFO = NO +SORT_MEMBER_DOCS = NO +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 8 +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +ALIASES = +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +OPTIMIZE_OUTPUT_FOR_C = NO +SHOW_USED_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = @srcdir@ +FILE_PATTERNS = MEDMEM*.hxx \ + MEDMEM*.cxx +RECURSIVE = NO +EXCLUDE = /export/home/pgoldb/SALOME_ROOT/MED/src/MEDMEM/MEDMEM_STRING.hxx \ + /export/home/pgoldb/SALOME_ROOT/MED/src/MEDMEM/MEDMEM_MedMeshDriver.cxx \ + /export/home/pgoldb/SALOME_ROOT/MED/src/MEDMEM/MEDMEM_Array.hxx \ + /export/home/pgoldb/SALOME_ROOT/MED/src/MEDMEM/MEDMEM_PointerOf.hxx \ + /export/home/pgoldb/SALOME_ROOT/MED/src/MEDMEM/MEDMEM_ModulusArray.hxx +EXCLUDE_PATTERNS = MEDMEM_DriversDef.* \ + MEDMEM_SkyLineArray.* \ + MEDMEM_Connectivity.* \ + MEDMEM_Coordinate.* +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = YES +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = YES +LATEX_OUTPUT = latex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::addtions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HAVE_DOT = YES +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +TEMPLATE_RELATIONS = YES +HIDE_UNDOC_RELATIONS = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +GRAPHICAL_HIERARCHY = YES +DOT_PATH = /export/home/LGLS/bin/ +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::addtions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO +CGI_NAME = search.cgi +CGI_URL = +DOC_URL = +DOC_ABSPATH = +BIN_ABSPATH = /usr/local/bin/ +EXT_DOC_PATHS = diff --git a/src/MEDMEM/MEDMEM_Array.hxx b/src/MEDMEM/MEDMEM_Array.hxx index 5156e1f85..ca8c4cb65 100644 --- a/src/MEDMEM/MEDMEM_Array.hxx +++ b/src/MEDMEM/MEDMEM_Array.hxx @@ -1,385 +1,747 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_Array.hxx +// Module : MED + #ifndef __MEDARRAY_H__ #define __MEDARRAY_H__ #include "MEDMEM_Exception.hxx" #include "MEDMEM_define.hxx" +#include "MEDMEM_PointerOf.hxx" #include "utilities.h" using namespace MED_EN; /*! A template class to generate an array of any particular type (int, long, - float, double) for our purpose in the MED++ library. + float, double) for our purpose in the MED++ library./n/n + + Arrays can be stored in MED_FULL_INTERLACE mode (ie : x1,y1,z1,x2,y2,z2...) or + in MED_NO_INTERLACE mode ( x1,x2,..xn, y1, y2 ..,yn,z1,...,zn)./n The alternate + representation mode is calculate ONLY when it is usefull. We assure coherency + for minor data modifications (element, line or column) if you use set methods. + But, if you get a pointer and modify the array, no automatical coherency is possible. + You can use calculateOther to force a recalculation and insure the coherency./n + No recalculation is done, when the entire array is modified./n + Theses arrays are "Med like" arrays; lower bound equals 1. (first element is element 1, + first coordinate is coordinate 1). /n + + Available constructors are :/n + + - default constructor (not very usefull)/n + - constructor asking for array dimensions and mode (does memory allocation for you)/n + - constructor asking for array dimensions, mode and values (doesn't do memory allocation + but copies pointers only.)/n + - a copy constructor which copies only pointers./n + (be aware of coherency) + - a copy constructor which copies data (deepcopy)./n + - assignement operator is also available and only copies pointers (and not data)./n/n + + Attribute "pointers" aren't standard pointers but class PointerOf objects in order to simplify + memory management./n + + A simple test program (testUArray) allows to test this class. */ -template class MEDARRAY -// Class Template MEDARRAY -// template to generate an array of any -// particular type (int, long, float, double) -// for our purpose in the MED++ library +template class MEDARRAY { private : - med_int _ld_values ; // leading dimension of value (example : space dimension with coordinates) - med_int _length_values ; // length of values (example : number of nodes with coordinates) - medModeSwitch _mode; // data access mode: - // MED_FULL_INTERLACE (default mode) - // or MED_NO_INTERLACE - T * _valuesDefault ; // in _mode representation - T * _valuesOther ; // in other _mode + + /*! leading dimension of value (example : space dimension for coordinates) */ + med_int _ldValues; + /*! length of values (example : number of nodes for coordinates) */ + med_int _lengthValues; + /*! data access mode. possible values are :\n + - MED_FULL_INTERLACE (default mode) \n + - MED_NO_INTERLACE */ + medModeSwitch _mode; + /*! Pointer to representation in mode MED_FULL_INTERLACE */ + PointerOf _valuesFull; + /*! Pointer to representation in mode MED_NO_INTERLACE */ + PointerOf _valuesNo; + /*! Pointer to representation in mode _mode */ + PointerOf _valuesDefault; + /*! Pointer to representation in the other mode (!=_mode) */ + PointerOf _valuesOther; public : - MEDARRAY():_ld_values(0),_length_values(0),_mode(MED_FULL_INTERLACE),_valuesDefault((T*)NULL),_valuesOther((T*)NULL) - { - }; - ~MEDARRAY() - { - if (_valuesDefault) - delete [] _valuesDefault ; - if (_valuesOther) - delete [] _valuesOther ; - }; - + inline MEDARRAY(); + inline ~MEDARRAY(); + + MEDARRAY (const med_int ld_values, const med_int length_values, + const medModeSwitch mode=MED_FULL_INTERLACE); + MEDARRAY (T* values, const med_int ld_values, + const med_int length_values, const medModeSwitch mode=MED_FULL_INTERLACE); + MEDARRAY (MEDARRAY const &m); + MEDARRAY (MEDARRAY const &m, bool copyOther); + MEDARRAY & operator = (const MEDARRAY & m); + + inline med_int getLeadingValue() const; + inline med_int getLengthValue() const; + + const T * get (const medModeSwitch mode) ; + const T * getRow (const med_int i) ; + const T * getColumn (const med_int j) ; + const T getIJ (const med_int i, const med_int j) const; +// T * const get (const medModeSwitch mode) const; +// T * const getRow (const med_int i) const; +// T * const getColumn (const med_int j) const; +// T const getIJ (const med_int i, const med_int j) const; + + inline medModeSwitch getMode() const; + + void set (const medModeSwitch mode,const T* value); + void setI (const med_int i, const T* value); + void setJ (const med_int j, const T* value); + void setIJ (const med_int i, const med_int j, const T value); + + void calculateOther(); +}; - // the following constructor are for the generation - // with the default or not _mode +//-------------------------------------------------// +// // +// IMPLEMENTED CODE // +// // +//-------------------------------------------------// - MEDARRAY(const med_int ld_values, const med_int length_values, - const medModeSwitch mode=MED_FULL_INTERLACE) ; - MEDARRAY( T*values, const med_int ld_values, - const med_int length_values, const medModeSwitch mode=MED_FULL_INTERLACE) ; +template inline MEDARRAY::MEDARRAY(): + _ldValues(0), _lengthValues(0), _mode(MED_FULL_INTERLACE), + _valuesFull(), _valuesNo(), + _valuesDefault(), _valuesOther() +{ +}; - inline med_int getLeadingValue() ; // as Space Dimension with coordinates - inline med_int getLengthValue() ; // as Number of Nodes with coordinates - - T * const get(medModeSwitch mode) ; - T* const getI(medModeSwitch mode,med_int i) ; - T getIJ(med_int i, med_int j) const ; +// ------------------ - // need by write, to get default mode ! - inline medModeSwitch getMode() const ; - - void set(medModeSwitch mode, T* value); - void setI(medModeSwitch mode, med_int i, T* value); - void setIJ(med_int i, med_int j, T value); - -private: - void calculateOther() ; - void allocateOther(); - void updateDefault(); +template inline MEDARRAY::~MEDARRAY() +{ }; +// ------------------ -// implemented code + /*! This constructor does allocation and does not set values : \n. + It allocates a "T" array of length_values*ld_values length.\n + You don't have to know the T values when calling this construtor + but you have to call "set" method to initialize them later. + You also can get the pointer to the memory zone (with "get" method), + and work with it./n + The desallocation of T array is not your responsability. \n\n + Throws MEDEXCEPTION if T array length is < 1*/ template MEDARRAY::MEDARRAY(const med_int ld_values, const med_int length_values, - const medModeSwitch mode = MED_FULL_INTERLACE): _ld_values(ld_values),_length_values(length_values),_mode(mode),_valuesOther((T*)NULL) -{ - BEGIN_OF("constructor MEDARRAY::MEDARRAY(const med_int , const med_int, const medModeSwitch (= MED_FULL_INTERLACE))"); - - // if could not allocate ? - if ((ld_values<1)|(length_values<1)) - throw MEDEXCEPTION( LOCALIZED("MEDARRAY::MEDARRAY(const med_int, const med_int, const medModeSwitch) : dimension < 1 !")); - _valuesDefault = new T[ld_values*length_values] ; + const medModeSwitch mode): - SCRUTE(_valuesDefault); + _ldValues(ld_values), + _lengthValues(length_values), + _mode(mode), + _valuesFull(), _valuesNo(), + _valuesDefault(),_valuesOther() +{ + BEGIN_OF("constructor MEDARRAY::MEDARRAY(const med_int, const med_int, const medModeSwitch)"); - SCRUTE(_valuesOther); + // if ld_values < 1 or length_values < 1 + // throws an exception + // Pointers are setted to NULL - SCRUTE(_ld_values); + if ((ld_values<1)|(length_values<1)) + { + throw MEDEXCEPTION(LOCALIZED("MEDARRAY::MEDARRAY(const med_int, const med_int, const medModeSwitch) : dimension < 1 !")); + } - SCRUTE(_length_values); + if ( _mode == MED_FULL_INTERLACE) + { + _valuesFull.set(length_values*ld_values); + _valuesDefault.set((T*) _valuesFull); + } + else + { + ASSERT (_mode == MED_NO_INTERLACE); + _valuesNo.set(length_values*ld_values); + _valuesDefault.set((T*)_valuesNo); + } - SCRUTE(_mode); + ASSERT( (T*)_valuesDefault != NULL); + SCRUTE((T*)_valuesDefault); + SCRUTE((T*)_valuesOther); + SCRUTE((T*)_valuesNo); + SCRUTE((T*)_valuesFull); - END_OF("constructor MEDARRAY::MEDARRAY(const med_int , const med_int, const medModeSwitch (= MED_FULL_INTERLACE))"); + END_OF("constructor MEDARRAY::MEDARRAY(const med_int, const med_int, const medModeSwitch ()"); } +// ------------------ + + /*! This constructor duplicate T*values.\n + + Throws MEDEXCEPTION if the lenght of T is < 1*/ template MEDARRAY::MEDARRAY( T*values, const med_int ld_values, const med_int length_values, - const medModeSwitch mode=MED_FULL_INTERLACE): _ld_values(ld_values),_length_values(length_values),_mode(mode),_valuesOther((T*)NULL) + const medModeSwitch mode): + _ldValues(ld_values), + _lengthValues(length_values), + _mode(mode), + _valuesFull(),_valuesNo(), + _valuesDefault(),_valuesOther() { - _valuesDefault = values; + BEGIN_OF("constructor MEDARRAY::MEDARRAY(T* values, const med_int, const med_int, const medModeSwitch)"); + + // if ld_values < 1 or length_values < 1, we could not allocate + // throws an exception + + if ( (ld_values<1) | (length_values<1) ) + { + throw MEDEXCEPTION(LOCALIZED("MEDARRAY::MEDARRAY(T* values, const med_int, const medModeSwitch) : dimension < 1 !")); + } + if ( _mode == MED_FULL_INTERLACE) + { + _valuesFull.set(_ldValues*length_values,values); + _valuesDefault.set((T*)_valuesFull); + } + else + { + ASSERT (_mode == MED_NO_INTERLACE); + _valuesNo.set(_ldValues*length_values,values); + _valuesDefault.set((T*)_valuesNo); + } + + ASSERT( (T*)_valuesDefault != NULL); + SCRUTE((T*)_valuesDefault); + SCRUTE((T*)_valuesOther); + SCRUTE((T*)_valuesNo); + SCRUTE((T*)_valuesFull); + + END_OF("constructor MEDARRAY::MEDARRAY(T* values, const med_int, const med_int, const medModeSwitch)"); } -template inline med_int MEDARRAY::getLeadingValue() { - return _ld_values ; -}; -template inline med_int MEDARRAY::getLengthValue() { - return _length_values ; -}; +// ------------------ + + /*! This constructor allocates a new medarray and does a copy of pointers/n + It DOES NOT copy the memory . The two objects will share the same data./n + (for copying data, use constructor MEDARRAY(MEDARRAY const & m,bool copyOther). */ +template MEDARRAY::MEDARRAY(MEDARRAY const & m ): + _ldValues(m._ldValues), + _lengthValues(m._lengthValues), + _mode(m._mode), + _valuesFull((const T*)m._valuesFull), + _valuesNo((const T*)m._valuesNo), + _valuesDefault((const T*)m._valuesDefault), + _valuesOther((const T*)m._valuesOther) +{ + BEGIN_OF("constructor MEDARRAY::MEDARRAY(MEDARRAY const & m)"); + ASSERT( (T*)_valuesDefault != NULL); + SCRUTE((T*)_valuesDefault); + SCRUTE((T*)_valuesOther); + SCRUTE((T*)_valuesNo); + SCRUTE((T*)_valuesFull); + END_OF("constructor MEDARRAY::MEDARRAY(MEDARRAY const & m)"); +} -template T* const MEDARRAY::get(medModeSwitch mode) + /*! This constructor allocates a new array and does a copy of values + included in the m arrays./n + If the boolean is setted to true, both representations (in full mode + and no interlace mode) will be copied./n + Otherwise, only _valuesDefault will be copied./n + Desallocation of the arrays is not your reponsability./n/n + Throws MEDEXCEPTION if _valuesOther is null and copyOther equals true*/ +template MEDARRAY::MEDARRAY(MEDARRAY const & p,bool copyOther ): + _ldValues(p._ldValues), + _lengthValues(p._lengthValues), + _mode(p._mode), + _valuesDefault(), + _valuesNo(), + _valuesFull(), + _valuesOther() { - if (_valuesDefault != NULL) - if (mode == _mode) { - return _valuesDefault; + BEGIN_OF("Constructeur deepCopy MEDARRAY::MEDARRAY(MEDARRAY const & m,bool copyOther"); + + // PG : Non, s'il n'y a rien, on test et on ne copie rien, c'est tout ! + +// if ( copyOther==true && ((const T*)p._valuesOther==NULL)) +// { +// throw MEDEXCEPTION("MEDARRAY MEDARRAY const &m,bool copyOther : No Other values defined and bool = true !"); +// } + + if ( _mode == MED_FULL_INTERLACE) + { + _valuesFull.set(p._ldValues*p._lengthValues,(const T*)p._valuesFull); + _valuesDefault.set((T*)_valuesFull); + if (copyOther) + if ((const T*)p._valuesNo != NULL) + { + _valuesNo.set(p._ldValues*p._lengthValues,(const T*)p._valuesNo); + _valuesOther.set((T*)_valuesNo); + } } - else { - calculateOther() ; - return _valuesOther ; + else + { + ASSERT (_mode == MED_NO_INTERLACE); + _valuesNo.set(p._ldValues*p._lengthValues,(const T*)p._valuesNo); + _valuesDefault.set((T*)_valuesNo); + if (copyOther) + if ((const T*)p._valuesFull != NULL) + { + _valuesFull.set(p._ldValues*p._lengthValues,(const T*)p._valuesFull); + _valuesOther.set((T*)_valuesFull); + } } - throw MEDEXCEPTION("MEDARRAY::get(mode) : No values defined !"); } -template T* const MEDARRAY::getI(medModeSwitch mode,med_int i) +// ------------------ + +// /*! This operator does a copy of pointers/n +// It DOES NOT copy of the memory. +// The two objects will share data./n */ + +template MEDARRAY & MEDARRAY::MEDARRAY::operator = (const MEDARRAY & m) { - // 1<=i<=_length_values and return an array of _ld_values length - // if MED_FULL_INTERLACE - // 1<=i<=_ld_values and return an array of _length_values length - // if MED_NO_INTERLACE - - if (_valuesDefault != NULL) { - // if mode = MED_FULL_INTERLACE : - int first = _ld_values ; - int second = _length_values; - // else : - if (mode == MED_NO_INTERLACE) { - first = _length_values ; - second = _ld_values ; - } - if (i<=0) - throw MEDEXCEPTION("MEDARRAY::getI(mode,i) : argument i must be > 0"); - if (i>second) - throw MEDEXCEPTION("MEDARRAY::getI(mode,i) : argument i must be <= second"); - if (mode == _mode) - return _valuesDefault + (i-1)*first ; - else { - calculateOther() ; - return _valuesOther + (i-1)*first ; - // return _valuesOther + (i-1)*second ; - } + + BEGIN_OF("Operator = MEDARRAY"); + + _ldValues=m._ldValues; + _lengthValues=m._lengthValues; + _mode=m._mode; + + SCRUTE(_mode); + + if ((const T*) m._valuesFull !=NULL) + _valuesFull.set(_ldValues*_lengthValues,(const T*) m._valuesFull); + + if ((const T*) m._valuesNo !=NULL) + _valuesNo.set(_ldValues*_lengthValues,(const T*) m._valuesNo); + + if (_mode == MED_FULL_INTERLACE) { + //PN : pour enlever les warning compilateur + //_valuesDefault.set((const T*) _valuesFull); + //_valuesOther.set((const T*) _valuesNo); + _valuesDefault.set((T*) _valuesFull); + _valuesOther.set((T*) _valuesNo); + } else { + ASSERT (_mode == MED_NO_INTERLACE); + //PN : pour enlever les warning compilateur + //_valuesDefault.set((const T*) _valuesNo); + //_valuesOther.set((const T*) _valuesFull); + _valuesDefault.set((T*) _valuesNo); + _valuesOther.set((T*) _valuesFull); } - throw MEDEXCEPTION("MEDARRAY::getI(mode,i) : No values defined !"); + + SCRUTE((T*)_valuesDefault); + SCRUTE((T*)_valuesOther); + SCRUTE((T*)_valuesNo); + SCRUTE((T*)_valuesFull); + + END_OF("Operator = MEDARRAY"); + return *this; } +// ------------------ -template T MEDARRAY::getIJ(med_int i, med_int j) const + /*! returns _ldValues. (for example, space dimension for coordinates array)*/ +template inline med_int MEDARRAY::getLeadingValue() const { - // 1<=i<=_length_values and 1= 1"); - if (i>_length_values) - throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument i must be <= _length_values"); - - if (j<1) - throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument j must be >= 1"); - if (j>_ld_values) - throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument j must be <= _ld_values"); - - if (_valuesDefault != NULL) { - switch (_mode) - { - case MED_FULL_INTERLACE : - { - return _valuesDefault[(i-1)*_ld_values+j-1]; - } - case MED_NO_INTERLACE : + return _ldValues; +}; + +// ------------------ + + /*! returns _ldValues. (for example, number of nodes for coordinates array)*/ +template inline med_int MEDARRAY::getLengthValue() const +{ + return _lengthValues; +}; + +// ------------------ + + /*! returns a pointer to _valuesDefault or _valuesOther, depending on + mode value : if mode is the same as _mode, _valuesDefault is returned. + else, if _valuesOther is calculated (if necessary) and then returned. + The pointer can be used to set values */ +template const T* MEDARRAY::get(const medModeSwitch mode) +{ + BEGIN_OF("MEDARRAY::get(const medModeSwitch mode)"); + if ((T*)_valuesDefault == NULL) + { + throw MEDEXCEPTION("MEDARRAY::get(mode) : No values defined !"); + } + if (mode == _mode) + { + //PN : pour enlever les warning compilateurs + //return (const T*)_valuesDefault; + return (T*) _valuesDefault; + } + else + { + if ((T*)_valuesOther == NULL) { - return _valuesDefault[(j-1)*_length_values+i-1]; + calculateOther(); } - } - } else - throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : No value in array !"); + //PN : pour enlever les warning compilateurs + //return (const T*)_valuesDefault; + return (T*) _valuesOther; + } + END_OF("MEDARRAY::get(const medModeSwitch mode)"); } -template inline medModeSwitch MEDARRAY::getMode() const +// ------------------ + + /*! returns a pointer to ith element of the array. + (ith line in a MED_FULL_INTERLACE representation )/n + Be aware : if _mode is MED_NO_INTERLACE, the entire + array will be recalculate in MED_FULL_INTERLACE representation./n*/ + +template const T* MEDARRAY::getRow(const med_int i) { - return _mode ; + + BEGIN_OF("MEDARRAY::getRow(const med_int i)"); + + if ((T*)_valuesDefault == NULL) + { + throw MEDEXCEPTION("MEDARRAY::getRow(i) : No values defined !"); + } + if (i<1) + { + throw MEDEXCEPTION("MEDARRAY::getRow(i) : argument i must be >= 1"); + } + if (i>_lengthValues) + { + throw MEDEXCEPTION("MEDARRAY::getRow(i) : argument i must be <= _lengthValues"); + } + + if ((T*)_valuesFull == NULL) + { + ASSERT(((T*) _valuesDefault)==((T*) _valuesNo)); + calculateOther(); + } + ASSERT((T*)_valuesFull != NULL); + + // PN pour enlever les warning compilateurs + //const T* ptr = (const T*)_valuesFull + (i-1)*_ldValues; + const T* ptr = (T*) _valuesFull + (i-1)*_ldValues; + + END_OF("MEDARRAY::getRow(const med_int i )"); + return ptr; +} +// ------------------ + + /*! this method is similar to getRow method./n + It returns a pointer to jth line of the array in a MED_NO-INTERLACE representation + (for example, 2nd coordinates)./n + Be aware : if _mode is MED_FULL_INTERLACE, the entire + array will be recalculate in MED_NO_INTERLACE representation./n*/ + +template const T* MEDARRAY::getColumn(const med_int j) +{ + BEGIN_OF("MEDARRAY::getColumn(const med_int j)"); + if ((T*)_valuesDefault == NULL) + { + throw MEDEXCEPTION("MEDARRAY::getColumn(j) : No values defined !"); + } + if (j<1) + { + throw MEDEXCEPTION("MEDARRAY::getColumn(j) : argument j must be >= 1"); + } + if (j>_ldValues) + { + throw MEDEXCEPTION("MEDARRAY::getColumn(j) : argument j must be <= _ldValues"); + } + + if ((T*)_valuesNo == NULL) + { + ASSERT(((T*) _valuesDefault)==((T*) _valuesFull)); + calculateOther(); + } + //PN pour enlever les warning compilateur + //const T* ptr = (const T*)_valuesNo + (j-1)*_lengthValues; + const T* ptr = ( T*)_valuesNo + (j-1)*_lengthValues; + + return ptr; } -template void MEDARRAY::set(medModeSwitch mode, T* value) +// ------------------ + + /*! returns Jth value of Ith element .\n + don't forget first element is element 1 (and not element 0). */ +template const T MEDARRAY::getIJ(const med_int i,const med_int j) const { + BEGIN_OF("MEDARRAY::getIJ(const med_int i, const med_int j)"); + if (i<1) + { + throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument i must be >= 1"); + } + if (i>_lengthValues) + { + throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument i must be <= _lengthValues"); + } + if (j<1) + { + throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument j must be >= 1"); + } + if (j>_ldValues) + { + throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument j must be <= _ldValues"); + } - BEGIN_OF("MEDARRAY::set(mode,i,value)"); + if ( (const T*)_valuesDefault == NULL) + { + throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : No value in array !"); + } - _mode = mode ; + if (_mode == MED_FULL_INTERLACE) + { + return _valuesDefault[(i-1)*_ldValues+j-1]; + } + else + { + return _valuesDefault[(j-1)*_lengthValues+i-1]; + } + END_OF("MEDARRAY::getIJ(const med_int i, const med_int j)"); +} - SCRUTE(_ld_values); - SCRUTE(_length_values); - SCRUTE(_valuesDefault); - SCRUTE(_valuesOther); - SCRUTE(_mode); - SCRUTE(mode); - SCRUTE(value); - - if (_valuesDefault != NULL) - if (mode == _mode) { - _valuesDefault = value ; - if (_valuesOther != NULL) calculateOther() ; - // if (_valuesOther != NULL) _valuesOther = value; +// ------------------ + + /*! returns the default mode (_mode)/n + (internal use : needed by write method) */ +template inline medModeSwitch MEDARRAY::getMode() const +{ + BEGIN_OF("MEDARRAY::getMode()"); + END_OF("MEDARRAY::getMode()"); + return _mode; +} + +// ------------------ + + /*! sets T pointer of _valuesDefault (cf class PointerOf) on value.\n + no copy of value is done. \n + the other representation mode is not recalculate. + the corresponding pointers are setted to null */ +// template void MEDARRAY::set(const medModeSwitch mode, const T* value) +// { + +// BEGIN_OF("MEDARRAY::set(mode,value)"); + +// _mode = mode; +// if ( _mode == MED_FULL_INTERLACE) +// { +// _valuesFull.set(value); +// _valuesDefault.set((T*)_valuesFull); +// _valuesNo.set(0); +// } +// else +// { +// ASSERT (_mode == MED_NO_INTERLACE); +// _valuesNo.set(value); +// _valuesDefault.set((T*)_valuesNo); +// _valuesFull.set(0); +// } +// _valuesOther.set(0); +// END_OF("MEDARRAY::set(mode,i,value)"); +// } + +// set with duplication because we don't know were value come and +// MEDARRAY must have properties on it !!!! +template void MEDARRAY::set(const medModeSwitch mode, const T* value) +{ + BEGIN_OF("MEDARRAY::set(mode,value)"); + + _mode = mode; + if ( _mode == MED_FULL_INTERLACE) + { + _valuesFull.set(_ldValues*_lengthValues,value); + _valuesDefault.set((T*)_valuesFull); + _valuesNo.set(0); } - else { - allocateOther() ; - _valuesOther = value ; - updateDefault() ; + else + { + ASSERT (_mode == MED_NO_INTERLACE); + _valuesNo.set(_ldValues*_lengthValues,value); + _valuesDefault.set((T*)_valuesNo); + _valuesFull.set(0); } - else throw MEDEXCEPTION("MEDARRAY::set(mode,value) : No values defined !"); + _valuesOther.set(0); END_OF("MEDARRAY::set(mode,i,value)"); } -template void MEDARRAY::setI(medModeSwitch mode, med_int i, T* value) + + +// ------------------ + + /*! Sets ith element to T* values\n + if they both exist, both _valuesFull and _valuesNo arrays will be updated./n + Throws exception if i < 1 or i > _lengthValues */ +template void MEDARRAY::setI(const med_int i, const T* value) { - BEGIN_OF("MEDARRAY::setI(mode,i,value)"); + BEGIN_OF("MEDARRAY::setI(i,value)"); - _mode = mode ; + if ((T*)_valuesDefault == NULL) + { + throw MEDEXCEPTION("MEDARRAY::setI(i,value) : No values defined !"); + } + if (i<=0) + { + throw MEDEXCEPTION("MEDARRAY::setI(i,value) : argument i must be > 0"); + } + if ( i > _lengthValues) + { + throw MEDEXCEPTION("MEDARRAY::setI(i,value) : argument i must be <= _lenghtValues"); + } - SCRUTE(i); - SCRUTE(_ld_values); - SCRUTE(_length_values); - SCRUTE(_valuesDefault); - SCRUTE(_valuesOther); - SCRUTE(_mode); - SCRUTE(mode); - - // 1<=i<=_length_values and return an array of _ld_values length - // if MED_FULL_INTERLACE - // 1<=i<=_ld_values and return an array of _length_values length - // if MED_NO_INTERLACE - - if (_valuesDefault != NULL) { - // if mode = MED_FULL_INTERLACE : - int first = _ld_values ; - int second = _length_values; - // else : - if (mode == MED_NO_INTERLACE) { - first = _length_values ; - second = _ld_values ; - } - SCRUTE(second); - if (i<=0) - throw MEDEXCEPTION("MEDARRAY::setI(mode,i,value) : argument i must be > 0"); - if (i>second) { - SCRUTE(i); - SCRUTE(second); - throw MEDEXCEPTION("MEDARRAY::setI(mode,i,value) : argument i must be <= second");} - if (mode == _mode) - { - // _valuesDefault + (i-1)*first = value ; - for (int k =0;k _lengthValues */ +template void MEDARRAY::setJ(const med_int j, const T* value) +{ + BEGIN_OF("MEDARRAY::setJ(j,value)"); + if (( T*)_valuesDefault == NULL) + { + throw MEDEXCEPTION("MEDARRAY::setJ(j) : No values defined !"); + } + if (j<1) + { + throw MEDEXCEPTION("MEDARRAY::setJ(j) : argument j must be >= 1"); + } + if (j>_ldValues) + { + throw MEDEXCEPTION("MEDARRAY::setJ(j) : argument j must be <= _ldValues"); + } + if ((T*)_valuesFull != NULL) + { + for (int k = 0;k<_lengthValues;k++) + { + _valuesFull[k*_ldValues+(j-1)] = value[k]; + } + } - END_OF("MEDARRAY::setI(mode,i,value)"); + if ((T*)_valuesNo != NULL) + { + for (int k = 0;k<_lengthValues;k++) + { + _valuesNo[k+_lengthValues*(j-1)] = value[k]; + } + } + END_OF("MEDARRAY::setJ(j,value)"); } -template void MEDARRAY::setIJ(med_int i, med_int j, T value) +// ------------------ + + /*! Sets value of Jth coordinate of Ith element to T value./n + Maintains coherency./n + Throws exception if we don't have + 1<=i<=_lengthValues and 1<=j<=_ldValues */ +template void MEDARRAY::setIJ(const med_int i, const med_int j, const T value) { - // 1<=i<=_length_values and 1= 1"); - if (i>_length_values) - throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument i must be <= _length_values"); + if (i>_lengthValues) + throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument i must be <= _lengthValues"); - if (j<1) + if (j<1) throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument j must be >= 1"); - if (j>_ld_values) - throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument j must be <= _ld_values"); + if (j>_ldValues) + throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument j must be <= _ldValues"); - if (_valuesDefault != NULL) { - switch (_mode) - { - case MED_FULL_INTERLACE : - { - _valuesDefault[(i-1)*_ld_values+j-1] = value; - break; - } - case MED_NO_INTERLACE : - { - _valuesDefault[(j-1)*_length_values+i-1] = value; - break; - } - } - } else + if ((T*)_valuesDefault == NULL) + { throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : No value in array !"); -} - -template void MEDARRAY::calculateOther() -{ - if (_valuesDefault != NULL) { - //we allocate _valuesOther if needed - if (_valuesOther == NULL) _valuesOther = new T[_ld_values*_length_values] ; - // we set _valuesOther - // if mode = MED_FULL_INTERLACE : - int first = _ld_values ; - int second = _length_values; - // else : - if (_mode == MED_NO_INTERLACE) { - first = _length_values ; - second = _ld_values; - } + } - for (int i=0; i void MEDARRAY::allocateOther() + /*! Calculates the other mode of representation : MED_FULL_INTERLACE + if __mode = MED_NO_INTERLACE and vice versa./n + Throws exception if no value are setted */ +template void MEDARRAY::calculateOther() { - if (_valuesDefault != NULL) { - if (_valuesOther == NULL) { - // we set _valuesOther - _valuesOther = new T[_ld_values*_length_values] ; - } + BEGIN_OF("MEDARRAY::calculateOther()"); + if ((T*)_valuesDefault == NULL) + { + throw MEDEXCEPTION("MEDARRAY::calculateOther() : No values defined !"); } - else - throw MEDEXCEPTION("MEDARRAY::allocateOther() : No values defined !"); -} -template void MEDARRAY::updateDefault() -{ - BEGIN_OF("MEDARRAY::updateDefault()"); - - if (_valuesDefault != NULL) { - if (_valuesOther != NULL) { - // we update _valuesDefault with _valuesOther - // if mode = MED_FULL_INTERLACE : - int first = _ld_values ; - int second = _length_values; - // else : - if (_mode == MED_NO_INTERLACE) { - first = _length_values ; - second = _ld_values; - } - for (int i=0; i::updateDefault() : No valuesOther defined !"); + if ((T*)_valuesOther == NULL) + { + _valuesOther.set(_ldValues*_lengthValues); + } + if (_mode == MED_NO_INTERLACE) + { + _valuesFull.set((T*)_valuesOther); } else - throw MEDEXCEPTION("MEDARRAY::updateDefault() : No values defined !"); + { + ASSERT( _mode==MED_FULL_INTERLACE); + _valuesNo.set((T*)_valuesOther); + } - END_OF("MEDARRAY::updateDefault()"); + for (int i=0; i<_lengthValues;i++) + { + for (int j=0; j<_ldValues; j++) + { + if (_mode == MED_NO_INTERLACE) + { + _valuesFull[i*_ldValues+j] = _valuesNo[j*_lengthValues+i]; + } + else + { + _valuesNo[j*_lengthValues+i]=_valuesFull[i*_ldValues+j]; + } + } + } + END_OF("MEDARRAY::calculateOther()"); } # endif /* # ifndef __MEDARRAY_H__ */ diff --git a/src/MEDMEM/MEDMEM_CellModel.cxx b/src/MEDMEM/MEDMEM_CellModel.cxx index 0f7f7b3a6..9ea2b3aec 100644 --- a/src/MEDMEM/MEDMEM_CellModel.cxx +++ b/src/MEDMEM/MEDMEM_CellModel.cxx @@ -1,3 +1,30 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_CellModel.cxx +// Module : MED + +using namespace std; /* File MEDMEM_CellModel.cxx $Header$ @@ -8,6 +35,17 @@ CELLMODEL::CELLMODEL(medGeometryElement t) { + // init first all to nothing + _dimension=0 ; + _numberOfNodes=0 ; + _numberOfVertexes=0 ; + _numberOfConstituentsDimension=0 ; + _numberOfConstituents=(int*)NULL ; + _numberOfNodeOfEachConstituent=(int**)NULL ; + _constituents=(int***)NULL ; + //_numberOfonstituentsType=(int*)NULL ; + _constituentsType=(medGeometryElement**)NULL ; + MESSAGE("CELLMODEL : constructeur pour le type " << t); switch (t) { @@ -27,10 +65,26 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfVertexes=2; _numberOfNodes=2; // constituent are POINT1 and we have no need to define _constituents vector - vector vector_type(2,MED_POINT1) ; - vector __constituents_type[]={vector_type}; - vector< vector > _constituents_type(__constituents_type,__constituents_type+1) ; - _constituentsType = _constituents_type ; + _numberOfConstituentsDimension=1 ; + _numberOfConstituents=new int[1] ; + _numberOfConstituents[0]=2 ; + _numberOfNodeOfEachConstituent=new (int*)[1] ; + _numberOfNodeOfEachConstituent[0]=new (int)[2] ; + _numberOfNodeOfEachConstituent[0][0]=1 ; + _numberOfNodeOfEachConstituent[0][1]=1 ; + + _constituents = new (int**)[1] ; + _constituents[0] = new (int*)[2] ; + _constituents[0][0] = new int[1] ; + _constituents[0][0][0] = 1 ; + _constituents[0][1] = new int[1] ; + _constituents[0][1][0] = 2 ; + + medGeometryElement * tmpConstituentsType1 = new medGeometryElement[2] ; + tmpConstituentsType1[0] = MED_POINT1 ; + tmpConstituentsType1[1] = MED_POINT1 ; + _constituentsType = new medGeometryElement*[1] ; + _constituentsType[0]=tmpConstituentsType1 ; break; } case MED_SEG3 : { @@ -40,10 +94,30 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfVertexes=2; _numberOfNodes=3; // constituent are POINT1 and we have no need to define _constituents vector - vector vector_type(3,MED_POINT1) ; - vector __constituents_type[]={vector_type}; - vector< vector > _constituents_type(__constituents_type,__constituents_type+1) ; - _constituentsType = _constituents_type ; + _numberOfConstituentsDimension=1 ; + _numberOfConstituents=new int[1] ; + _numberOfConstituents[0]=3 ; + _numberOfNodeOfEachConstituent=new (int*)[1] ; + _numberOfNodeOfEachConstituent[0]=new (int)[3] ; + _numberOfNodeOfEachConstituent[0][0]=1 ; + _numberOfNodeOfEachConstituent[0][1]=1 ; + _numberOfNodeOfEachConstituent[0][2]=1 ; + + _constituents = new (int**)[1] ; + _constituents[0] = new (int*)[3] ; + _constituents[0][0] = new int[1] ; + _constituents[0][0][0] = 1 ; + _constituents[0][1] = new int[1] ; + _constituents[0][1][0] = 2 ; + _constituents[0][2] = new int[1] ; + _constituents[0][2][0] = 3 ; + + medGeometryElement * tmpConstituentsType1 = new medGeometryElement[3] ; + tmpConstituentsType1[0] = MED_POINT1 ; + tmpConstituentsType1[1] = MED_POINT1 ; + tmpConstituentsType1[2] = MED_POINT1 ; + _constituentsType = new medGeometryElement*[1] ; + _constituentsType[0]=tmpConstituentsType1 ; break; } case MED_TRIA3 : { @@ -52,22 +126,47 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _dimension=2; _numberOfVertexes=3; _numberOfNodes=3; - int _edge1[]={1,2} ; - int _edge2[]={2,3} ; - int _edge3[]={3,1} ; - vector edge1(_edge1,_edge1+2) ; - vector edge2(_edge2,_edge2+2) ; - vector edge3(_edge3,_edge3+2) ; - vector _vector_edge[]={edge1,edge2,edge3}; - vector< vector > vector_edge(_vector_edge,_vector_edge+3) ; - vector< vector > __constituents__[]={vector_edge}; - vector< vector< vector > > _constituents_(__constituents__,__constituents__+1) ; - _constituents = _constituents_ ; - vector vector_edge_type(3,MED_SEG2) ; - vector vector_type(3,MED_POINT1) ; - vector __constituents_type[]={vector_edge_type,vector_type}; - vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; - _constituentsType = _constituents_type ; + + _numberOfConstituentsDimension=1 ; + _numberOfConstituents=new int[1] ; + _numberOfConstituents[0]=3 ; + _numberOfNodeOfEachConstituent=new (int*)[1] ; + _numberOfNodeOfEachConstituent[0]=new (int)[3] ; + _numberOfNodeOfEachConstituent[0][0]=2 ; + _numberOfNodeOfEachConstituent[0][1]=2 ; + _numberOfNodeOfEachConstituent[0][2]=2 ; + + int* _edge1=new int[2]; + _edge1[0]=1; + _edge1[1]=2; + int* _edge2=new int[2]; + _edge2[0]=2; + _edge2[1]=3; + int* _edge3=new int[2]; + _edge3[0]=3; + _edge3[1]=1; + int ** tmpConstituents1 = new (int*)[3]; + tmpConstituents1[0]=_edge1 ; + tmpConstituents1[1]=_edge2 ; + tmpConstituents1[2]=_edge3 ; + _constituents = new int**[1] ; + _constituents[0]=tmpConstituents1 ; + + medGeometryElement * tmpConstituentsType1 = new medGeometryElement[3] ; + tmpConstituentsType1[0] = MED_SEG2 ; + tmpConstituentsType1[1] = MED_SEG2 ; + tmpConstituentsType1[2] = MED_SEG2 ; +// medGeometryElement * tmpConstituentsType2 = new medGeometryElement[3] ; +// tmpConstituentsType2[0] = MED_POINT1 ; +// tmpConstituentsType2[1] = MED_POINT1 ; +// tmpConstituentsType2[2] = MED_POINT1 ; +// _constituentsType = new medGeometryElement*[2] ; + _constituentsType = new medGeometryElement*[1] ; + _constituentsType[0]=tmpConstituentsType1 ; +// _constituentsType[1]=tmpConstituentsType2 ; + // Well, point are defined, but could not be acces because we have + // only 1 numberOfConstituentsDimension ! + break; } case MED_TRIA6 : { @@ -76,22 +175,51 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _dimension=2; _numberOfVertexes=3; _numberOfNodes=6; - int _edge1[]={1,2,4} ; - int _edge2[]={2,3,5} ; - int _edge3[]={3,1,6} ; - vector edge1(_edge1,_edge1+3) ; - vector edge2(_edge2,_edge2+3) ; - vector edge3(_edge3,_edge3+3) ; - vector _vector_edge[]={edge1,edge2,edge3}; - vector< vector > vector_edge(_vector_edge,_vector_edge+3) ; - vector< vector > __constituents__[]={vector_edge}; - vector< vector< vector > > _constituents_(__constituents__,__constituents__+1) ; - _constituents = _constituents_ ; - vector vector_edge_type(3,MED_SEG3) ; - vector vector_type(6,MED_POINT1) ; - vector __constituents_type[]={vector_edge_type,vector_type}; - vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; - _constituentsType = _constituents_type ; + _numberOfConstituentsDimension=1 ; + _numberOfConstituents=new int[1] ; + _numberOfConstituents[0]=3 ; + _numberOfNodeOfEachConstituent=new (int*)[1] ; + _numberOfNodeOfEachConstituent[0]=new (int)[3] ; + _numberOfNodeOfEachConstituent[0][0]=3 ; + _numberOfNodeOfEachConstituent[0][1]=3 ; + _numberOfNodeOfEachConstituent[0][2]=3 ; + + int* _edge1=new int[3]; + _edge1[0]=1; + _edge1[1]=2; + _edge1[2]=4; + int* _edge2=new int[3]; + _edge2[0]=2; + _edge2[1]=3; + _edge2[2]=5; + int* _edge3=new int[3]; + _edge3[0]=3; + _edge3[1]=1; + _edge3[2]=6; + int ** tmpConstituents1 = new (int*)[3]; + tmpConstituents1[0]=_edge1 ; + tmpConstituents1[1]=_edge2 ; + tmpConstituents1[2]=_edge3 ; + _constituents = new int**[1] ; + _constituents[0]=tmpConstituents1 ; + medGeometryElement * tmpConstituentsType1 = new medGeometryElement[3] ; + tmpConstituentsType1[0] = MED_SEG3 ; + tmpConstituentsType1[1] = MED_SEG3 ; + tmpConstituentsType1[2] = MED_SEG3 ; +// medGeometryElement * tmpConstituentsType2 = new medGeometryElement[6] ; +// tmpConstituentsType2[0] = MED_POINT1 ; +// tmpConstituentsType2[1] = MED_POINT1 ; +// tmpConstituentsType2[2] = MED_POINT1 ; +// tmpConstituentsType2[3] = MED_POINT1 ; +// tmpConstituentsType2[4] = MED_POINT1 ; +// tmpConstituentsType2[5] = MED_POINT1 ; +// _constituentsType = new medGeometryElement*[2] ; + _constituentsType = new medGeometryElement*[1] ; + _constituentsType[0]=tmpConstituentsType1 ; +// _constituentsType[1]=tmpConstituentsType2 ; + // Well, point are defined, but could not be acces because we have + // only 1 numberOfConstituentsDimension ! + break; } case MED_QUAD4 : { @@ -100,24 +228,52 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _dimension=2; _numberOfVertexes=4; _numberOfNodes=4; - int _edge1[]={1,2} ; - int _edge2[]={2,3} ; - int _edge3[]={3,4} ; - int _edge4[]={4,1} ; - vector edge1(_edge1,_edge1+2) ; - vector edge2(_edge2,_edge2+2) ; - vector edge3(_edge3,_edge3+2) ; - vector edge4(_edge4,_edge4+2) ; - vector _vector_edge[]={edge1,edge2,edge3,edge4}; - vector< vector > vector_edge(_vector_edge,_vector_edge+4) ; - vector< vector > __constituents__[]={vector_edge}; - vector< vector< vector > > _constituents_(__constituents__,__constituents__+1) ; - _constituents = _constituents_ ; - vector vector_edge_type(4,MED_SEG2) ; - vector vector_type(4,MED_POINT1) ; - vector __constituents_type[]={vector_edge_type,vector_type}; - vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; - _constituentsType = _constituents_type ; + _numberOfConstituentsDimension=1 ; + _numberOfConstituents=new int[1] ; + _numberOfConstituents[0]=4 ; + _numberOfNodeOfEachConstituent=new (int*)[1] ; + _numberOfNodeOfEachConstituent[0]=new (int)[4] ; + _numberOfNodeOfEachConstituent[0][0]=2 ; + _numberOfNodeOfEachConstituent[0][1]=2 ; + _numberOfNodeOfEachConstituent[0][2]=2 ; + _numberOfNodeOfEachConstituent[0][3]=2 ; + + int* _edge1=new int[2]; + _edge1[0]=1; + _edge1[1]=2; + int* _edge2=new int[2]; + _edge2[0]=2; + _edge2[1]=3; + int* _edge3=new int[2]; + _edge3[0]=3; + _edge3[1]=4; + int* _edge4=new int[2]; + _edge4[0]=4; + _edge4[1]=1; + int ** tmpConstituents1 = new (int*)[4]; + tmpConstituents1[0]=_edge1 ; + tmpConstituents1[1]=_edge2 ; + tmpConstituents1[2]=_edge3 ; + tmpConstituents1[3]=_edge4 ; + _constituents = new int**[1] ; + _constituents[0]=tmpConstituents1 ; + medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ; + tmpConstituentsType1[0] = MED_SEG2 ; + tmpConstituentsType1[1] = MED_SEG2 ; + tmpConstituentsType1[2] = MED_SEG2 ; + tmpConstituentsType1[3] = MED_SEG2 ; +// medGeometryElement * tmpConstituentsType2 = new medGeometryElement[4] ; +// tmpConstituentsType2[0] = MED_POINT1 ; +// tmpConstituentsType2[1] = MED_POINT1 ; +// tmpConstituentsType2[2] = MED_POINT1 ; +// tmpConstituentsType2[3] = MED_POINT1 ; +// _constituentsType = new medGeometryElement*[2] ; + _constituentsType = new medGeometryElement*[1] ; + _constituentsType[0]=tmpConstituentsType1 ; +// _constituentsType[1]=tmpConstituentsType2 ; + // Well, point are defined, but could not be acces because we have + // only 1 numberOfConstituentsDimension ! + break; } case MED_QUAD8 : { @@ -126,24 +282,60 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _dimension=2; _numberOfVertexes=4; _numberOfNodes=8; - int _edge1[]={1,2,5} ; - int _edge2[]={2,3,6} ; - int _edge3[]={3,4,7} ; - int _edge4[]={4,1,8} ; - vector edge1(_edge1,_edge1+3) ; - vector edge2(_edge2,_edge2+3) ; - vector edge3(_edge3,_edge3+3) ; - vector edge4(_edge4,_edge4+3) ; - vector _vector_edge[]={edge1,edge2,edge3,edge4}; - vector< vector > vector_edge(_vector_edge,_vector_edge+4) ; - vector< vector > __constituents__[]={vector_edge}; - vector< vector< vector > > _constituents_(__constituents__,__constituents__+1) ; - _constituents = _constituents_ ; - vector vector_edge_type(4,MED_SEG3) ; - vector vector_type(8,MED_POINT1) ; - vector __constituents_type[]={vector_edge_type,vector_type}; - vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; - _constituentsType = _constituents_type ; + _numberOfConstituentsDimension=1 ; + _numberOfConstituents=new int[1] ; + _numberOfConstituents[0]=4 ; + _numberOfNodeOfEachConstituent=new (int*)[1] ; + _numberOfNodeOfEachConstituent[0]=new (int)[4] ; + _numberOfNodeOfEachConstituent[0][0]=3 ; + _numberOfNodeOfEachConstituent[0][1]=3 ; + _numberOfNodeOfEachConstituent[0][2]=3 ; + _numberOfNodeOfEachConstituent[0][3]=3 ; + + int* _edge1=new int[3]; + _edge1[0]=1; + _edge1[1]=2; + _edge1[2]=5; + int* _edge2=new int[3]; + _edge2[0]=2; + _edge2[1]=3; + _edge2[2]=6; + int* _edge3=new int[3]; + _edge3[0]=3; + _edge3[1]=4; + _edge3[2]=7; + int* _edge4=new int[3]; + _edge4[0]=4; + _edge4[1]=1; + _edge4[2]=8; + int ** tmpConstituents1 = new (int*)[4]; + tmpConstituents1[0]=_edge1 ; + tmpConstituents1[1]=_edge2 ; + tmpConstituents1[2]=_edge3 ; + tmpConstituents1[3]=_edge4 ; + _constituents = new int**[1] ; + _constituents[0]=tmpConstituents1 ; + medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ; + tmpConstituentsType1[0] = MED_SEG3 ; + tmpConstituentsType1[1] = MED_SEG3 ; + tmpConstituentsType1[2] = MED_SEG3 ; + tmpConstituentsType1[3] = MED_SEG3 ; +// medGeometryElement * tmpConstituentsType2 = new medGeometryElement[8] ; +// tmpConstituentsType2[0] = MED_POINT1 ; +// tmpConstituentsType2[1] = MED_POINT1 ; +// tmpConstituentsType2[2] = MED_POINT1 ; +// tmpConstituentsType2[3] = MED_POINT1 ; +// tmpConstituentsType2[4] = MED_POINT1 ; +// tmpConstituentsType2[5] = MED_POINT1 ; +// tmpConstituentsType2[6] = MED_POINT1 ; +// tmpConstituentsType2[7] = MED_POINT1 ; +// _constituentsType = new medGeometryElement*[2] ; + _constituentsType = new medGeometryElement*[1] ; + _constituentsType[0]=tmpConstituentsType1 ; +// _constituentsType[1]=tmpConstituentsType2 ; + // Well, point are defined, but could not be acces because we have + // only 1 numberOfConstituentsDimension ! + break; } case MED_TETRA4 : { @@ -152,38 +344,88 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _dimension=3; _numberOfVertexes=4; _numberOfNodes=4; - int _edge1[]={1,2} ; - int _edge2[]={2,3} ; - int _edge3[]={3,1} ; - int _edge4[]={1,4} ; - int _edge5[]={2,4} ; - int _edge6[]={3,4} ; - vector edge1(_edge1,_edge1+2) ; - vector edge2(_edge2,_edge2+2) ; - vector edge3(_edge3,_edge3+2) ; - vector edge4(_edge4,_edge4+2) ; - vector edge5(_edge5,_edge5+2) ; - vector edge6(_edge6,_edge6+2) ; - vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6}; - vector< vector > vector_edge(_vector_edge,_vector_edge+6) ; - int _face1[]={1,2,3} ; - int _face2[]={1,4,2} ; - int _face3[]={2,4,3} ; - int _face4[]={3,4,1} ; - vector face1(_face1,_face1+3) ; - vector face2(_face2,_face2+3) ; - vector face3(_face3,_face3+3) ; - vector face4(_face4,_face4+3) ; - vector _vector_face[] = {face1,face2,face3,face4} ; - vector< vector > vector_face(_vector_face,_vector_face+4) ; - vector< vector > __constituents__[]={vector_face,vector_edge}; - vector< vector< vector > > _constituents_(__constituents__,__constituents__+2) ; - _constituents = _constituents_ ; - vector vector_edge_type(6,MED_SEG2) ; - vector vector_face_type(4,MED_TRIA3) ; - vector __constituents_type[]={vector_face_type,vector_edge_type}; - vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; - _constituentsType = _constituents_type ; + _numberOfConstituentsDimension=2 ; + _numberOfConstituents=new int[2] ; + _numberOfConstituents[0]=4 ; + _numberOfConstituents[1]=6 ; + _numberOfNodeOfEachConstituent=new (int*)[2] ; + _numberOfNodeOfEachConstituent[0]=new (int)[4] ; + _numberOfNodeOfEachConstituent[0][0]=3 ; + _numberOfNodeOfEachConstituent[0][1]=3 ; + _numberOfNodeOfEachConstituent[0][2]=3 ; + _numberOfNodeOfEachConstituent[0][3]=3 ; + _numberOfNodeOfEachConstituent[1]=new (int)[6] ; + _numberOfNodeOfEachConstituent[1][0]=2 ; + _numberOfNodeOfEachConstituent[1][1]=2 ; + _numberOfNodeOfEachConstituent[1][2]=2 ; + _numberOfNodeOfEachConstituent[1][3]=2 ; + _numberOfNodeOfEachConstituent[1][4]=2 ; + _numberOfNodeOfEachConstituent[1][5]=2 ; + + int* _face1=new int[3]; + _face1[0]=1; + _face1[1]=2; + _face1[2]=3; + int* _face2=new int[3]; + _face2[0]=1; + _face2[1]=4; + _face2[2]=2; + int* _face3=new int[3]; + _face3[0]=2; + _face3[1]=4; + _face3[2]=3; + int* _face4=new int[3]; + _face4[0]=3; + _face4[1]=4; + _face4[2]=1; + int* _edge1=new int[2]; + _edge1[0]=1; + _edge1[1]=2; + int* _edge2=new int[2]; + _edge2[0]=2; + _edge2[1]=3; + int* _edge3=new int[2]; + _edge3[0]=3; + _edge3[1]=1; + int* _edge4=new int[2]; + _edge4[0]=1; + _edge4[1]=4; + int* _edge5=new int[2]; + _edge5[0]=2; + _edge5[1]=4; + int* _edge6=new int[2]; + _edge6[0]=3; + _edge6[1]=4; + int ** tmpConstituents1 = new (int*)[4]; + tmpConstituents1[0]=_face1 ; + tmpConstituents1[1]=_face2 ; + tmpConstituents1[2]=_face3 ; + tmpConstituents1[3]=_face4 ; + int ** tmpConstituents2 = new (int*)[6]; + tmpConstituents2[0]=_edge1 ; + tmpConstituents2[1]=_edge2 ; + tmpConstituents2[2]=_edge3 ; + tmpConstituents2[3]=_edge4 ; + tmpConstituents2[4]=_edge5 ; + tmpConstituents2[5]=_edge6 ; + _constituents = new int**[2] ; + _constituents[0]=tmpConstituents1 ; + _constituents[1]=tmpConstituents2 ; + medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ; + tmpConstituentsType1[0] = MED_TRIA3 ; + tmpConstituentsType1[1] = MED_TRIA3 ; + tmpConstituentsType1[2] = MED_TRIA3 ; + tmpConstituentsType1[3] = MED_TRIA3 ; + medGeometryElement * tmpConstituentsType2 = new medGeometryElement[6] ; + tmpConstituentsType2[0] = MED_SEG2 ; + tmpConstituentsType2[1] = MED_SEG2 ; + tmpConstituentsType2[2] = MED_SEG2 ; + tmpConstituentsType2[3] = MED_SEG2 ; + tmpConstituentsType2[4] = MED_SEG2 ; + tmpConstituentsType2[5] = MED_SEG2 ; + _constituentsType = new medGeometryElement*[2] ; + _constituentsType[0]=tmpConstituentsType1 ; + _constituentsType[1]=tmpConstituentsType2 ; break; } case MED_TETRA10 : { @@ -192,38 +434,106 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _dimension=3; _numberOfVertexes=4; _numberOfNodes=10; - int _edge1[]={1,2,5} ; - int _edge2[]={2,3,6} ; - int _edge3[]={3,1,7} ; - int _edge4[]={1,4,8} ; - int _edge5[]={2,4,9} ; - int _edge6[]={3,4,10} ; - vector edge1(_edge1,_edge1+3) ; - vector edge2(_edge2,_edge2+3) ; - vector edge3(_edge3,_edge3+3) ; - vector edge4(_edge4,_edge4+3) ; - vector edge5(_edge5,_edge5+3) ; - vector edge6(_edge6,_edge6+3) ; - vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6}; - vector< vector > vector_edge(_vector_edge,_vector_edge+6) ; - int _face1[]={1,2,3,5,6,7} ; - int _face2[]={1,4,2,8,9,5} ; - int _face3[]={2,4,3,9,10,6} ; - int _face4[]={3,4,1,10,8,7} ; - vector face1(_face1,_face1+6) ; - vector face2(_face2,_face2+6) ; - vector face3(_face3,_face3+6) ; - vector face4(_face4,_face4+6) ; - vector _vector_face[] = {face1,face2,face3,face4} ; - vector< vector > vector_face(_vector_face,_vector_face+4) ; - vector< vector > __constituents__[]={vector_face,vector_edge}; - vector< vector< vector > > _constituents_(__constituents__,__constituents__+2) ; - _constituents = _constituents_ ; - vector vector_edge_type(6,MED_SEG3) ; - vector vector_face_type(4,MED_TRIA6) ; - vector __constituents_type[]={vector_face_type,vector_edge_type}; - vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; - _constituentsType = _constituents_type ; + _numberOfConstituentsDimension=2 ; + _numberOfConstituents=new int[2] ; + _numberOfConstituents[0]=4 ; + _numberOfConstituents[1]=6 ; + _numberOfNodeOfEachConstituent=new (int*)[2] ; + _numberOfNodeOfEachConstituent[0]=new (int)[4] ; + _numberOfNodeOfEachConstituent[0][0]=6 ; + _numberOfNodeOfEachConstituent[0][1]=6 ; + _numberOfNodeOfEachConstituent[0][2]=6 ; + _numberOfNodeOfEachConstituent[0][3]=6 ; + _numberOfNodeOfEachConstituent[1]=new (int)[6] ; + _numberOfNodeOfEachConstituent[1][0]=3 ; + _numberOfNodeOfEachConstituent[1][1]=3 ; + _numberOfNodeOfEachConstituent[1][2]=3 ; + _numberOfNodeOfEachConstituent[1][3]=3 ; + _numberOfNodeOfEachConstituent[1][4]=3 ; + _numberOfNodeOfEachConstituent[1][5]=3 ; + + int* _face1=new int[6]; + _face1[0]=1; + _face1[1]=2; + _face1[2]=3; + _face1[3]=5; + _face1[4]=6; + _face1[5]=7; + int* _face2=new int[6]; + _face2[0]=1; + _face2[1]=4; + _face2[2]=2; + _face2[3]=8; + _face2[4]=9; + _face2[5]=5; + int* _face3=new int[6]; + _face3[0]=2; + _face3[1]=4; + _face3[2]=3; + _face3[3]=9; + _face3[4]=10; + _face3[5]=6; + int* _face4=new int[6]; + _face4[0]=3; + _face4[1]=4; + _face4[2]=1; + _face4[3]=10; + _face4[4]=8; + _face4[5]=7; + int* _edge1=new int[3]; + _edge1[0]=1; + _edge1[1]=2; + _edge1[2]=5; + int* _edge2=new int[3]; + _edge2[0]=2; + _edge2[1]=3; + _edge2[2]=6; + int* _edge3=new int[3]; + _edge3[0]=3; + _edge3[1]=1; + _edge3[2]=7; + int* _edge4=new int[3]; + _edge4[0]=1; + _edge4[1]=4; + _edge4[2]=8; + int* _edge5=new int[3]; + _edge5[0]=2; + _edge5[1]=4; + _edge5[2]=9; + int* _edge6=new int[3]; + _edge6[0]=3; + _edge6[1]=4; + _edge6[2]=10; + int ** tmpConstituents1 = new (int*)[4]; + tmpConstituents1[0]=_face1 ; + tmpConstituents1[1]=_face2 ; + tmpConstituents1[2]=_face3 ; + tmpConstituents1[3]=_face4 ; + int ** tmpConstituents2 = new (int*)[6]; + tmpConstituents2[0]=_edge1 ; + tmpConstituents2[1]=_edge2 ; + tmpConstituents2[2]=_edge3 ; + tmpConstituents2[3]=_edge4 ; + tmpConstituents2[4]=_edge5 ; + tmpConstituents2[5]=_edge6 ; + _constituents = new int**[2] ; + _constituents[0]=tmpConstituents1 ; + _constituents[1]=tmpConstituents2 ; + medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ; + tmpConstituentsType1[0] = MED_TRIA6 ; + tmpConstituentsType1[1] = MED_TRIA6 ; + tmpConstituentsType1[2] = MED_TRIA6 ; + tmpConstituentsType1[3] = MED_TRIA6 ; + medGeometryElement * tmpConstituentsType2 = new medGeometryElement[6] ; + tmpConstituentsType2[0] = MED_SEG3 ; + tmpConstituentsType2[1] = MED_SEG3 ; + tmpConstituentsType2[2] = MED_SEG3 ; + tmpConstituentsType2[3] = MED_SEG3 ; + tmpConstituentsType2[4] = MED_SEG3 ; + tmpConstituentsType2[5] = MED_SEG3 ; + _constituentsType = new medGeometryElement*[2] ; + _constituentsType[0]=tmpConstituentsType1 ; + _constituentsType[1]=tmpConstituentsType2 ; break; } case MED_HEXA8 : { @@ -232,54 +542,144 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _dimension=3; _numberOfVertexes=8; _numberOfNodes=8; - int _edge1[]={1,2} ; - int _edge2[]={2,3} ; - int _edge3[]={3,4} ; - int _edge4[]={4,1} ; - int _edge5[]={5,6} ; - int _edge6[]={6,7} ; - int _edge7[]={7,8} ; - int _edge8[]={8,5} ; - int _edge9[]={1,5} ; - int _edge10[]={2,6} ; - int _edge11[]={3,7} ; - int _edge12[]={4,8} ; - vector edge1(_edge1,_edge1+2) ; - vector edge2(_edge2,_edge2+2) ; - vector edge3(_edge3,_edge3+2) ; - vector edge4(_edge4,_edge4+2) ; - vector edge5(_edge5,_edge5+2) ; - vector edge6(_edge6,_edge6+2) ; - vector edge7(_edge7,_edge7+2) ; - vector edge8(_edge8,_edge8+2) ; - vector edge9(_edge9,_edge9+2) ; - vector edge10(_edge10,_edge10+2) ; - vector edge11(_edge11,_edge11+2) ; - vector edge12(_edge12,_edge12+2) ; - vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9,edge10,edge11,edge12}; - vector< vector > vector_edge(_vector_edge,_vector_edge+12) ; - int _face1[]={1,2,3,4} ; - int _face2[]={5,8,7,6} ; - int _face3[]={1,5,6,2} ; - int _face4[]={2,6,7,3} ; - int _face5[]={3,7,8,4} ; - int _face6[]={4,8,5,1} ; - vector face1(_face1,_face1+4) ; - vector face2(_face2,_face2+4) ; - vector face3(_face3,_face3+4) ; - vector face4(_face4,_face4+4) ; - vector face5(_face5,_face5+4) ; - vector face6(_face6,_face6+4) ; - vector _vector_face[] = {face1,face2,face3,face4,face5,face6} ; - vector< vector > vector_face(_vector_face,_vector_face+6) ; - vector< vector > __constituents__[]={vector_face,vector_edge}; - vector< vector< vector > > _constituents_(__constituents__,__constituents__+2) ; - _constituents = _constituents_ ; - vector vector_edge_type(12,MED_SEG2) ; - vector vector_face_type(6,MED_QUAD4) ; - vector __constituents_type[]={vector_face_type,vector_edge_type}; - vector< vector > _constituents_type(__constituents_type,__constituents_type+2); - _constituentsType = _constituents_type ; + _numberOfConstituentsDimension=2 ; + _numberOfConstituents=new int[2] ; + _numberOfConstituents[0]=6 ; + _numberOfConstituents[1]=12 ; + _numberOfNodeOfEachConstituent=new (int*)[2] ; + _numberOfNodeOfEachConstituent[0]=new (int)[6] ; + _numberOfNodeOfEachConstituent[0][0]=4 ; + _numberOfNodeOfEachConstituent[0][1]=4 ; + _numberOfNodeOfEachConstituent[0][2]=4 ; + _numberOfNodeOfEachConstituent[0][3]=4 ; + _numberOfNodeOfEachConstituent[0][4]=4 ; + _numberOfNodeOfEachConstituent[0][5]=4 ; + _numberOfNodeOfEachConstituent[1]=new (int)[12] ; + _numberOfNodeOfEachConstituent[1][0]=2 ; + _numberOfNodeOfEachConstituent[1][1]=2 ; + _numberOfNodeOfEachConstituent[1][2]=2 ; + _numberOfNodeOfEachConstituent[1][3]=2 ; + _numberOfNodeOfEachConstituent[1][4]=2 ; + _numberOfNodeOfEachConstituent[1][5]=2 ; + _numberOfNodeOfEachConstituent[1][6]=2 ; + _numberOfNodeOfEachConstituent[1][7]=2 ; + _numberOfNodeOfEachConstituent[1][8]=2 ; + _numberOfNodeOfEachConstituent[1][9]=2 ; + _numberOfNodeOfEachConstituent[1][10]=2 ; + _numberOfNodeOfEachConstituent[1][11]=2 ; + + int* _edge1=new int[2]; + _edge1[0]=1; + _edge1[1]=2; + int* _edge2=new int[2]; + _edge2[0]=2; + _edge2[1]=3; + int* _edge3=new int[2]; + _edge3[0]=3; + _edge3[1]=4; + int* _edge4=new int[2]; + _edge4[0]=4; + _edge4[1]=1; + int* _edge5=new int[2]; + _edge5[0]=5; + _edge5[1]=6; + int* _edge6=new int[2]; + _edge6[0]=6; + _edge6[1]=7; + int* _edge7=new int[2]; + _edge7[0]=7; + _edge7[1]=8; + int* _edge8=new int[2]; + _edge8[0]=8; + _edge8[1]=5; + int* _edge9=new int[2]; + _edge9[0]=1; + _edge9[1]=5; + int* _edge10=new int[2]; + _edge10[0]=2; + _edge10[1]=6; + int* _edge11=new int[2]; + _edge11[0]=3; + _edge11[1]=7; + int* _edge12=new int[2]; + _edge12[0]=4; + _edge12[1]=8; + int* _face1=new int[4]; + _face1[0]=1; + _face1[1]=2; + _face1[2]=3; + _face1[3]=4; + int* _face2=new int[4]; + _face2[0]=5; + _face2[1]=8; + _face2[2]=7; + _face2[3]=6; + int* _face3=new int[4]; + _face3[0]=1; + _face3[1]=5; + _face3[2]=6; + _face3[3]=2; + int* _face4=new int[4]; + _face4[0]=2; + _face4[1]=6; + _face4[2]=7; + _face4[3]=3; + int* _face5=new int[4]; + _face5[0]=3; + _face5[1]=7; + _face5[2]=8; + _face5[3]=4; + int* _face6=new int[4]; + _face6[0]=4; + _face6[1]=8; + _face6[2]=5; + _face6[3]=1; + int ** tmpConstituents1 = new (int*)[6]; + tmpConstituents1[0]=_face1 ; + tmpConstituents1[1]=_face2 ; + tmpConstituents1[2]=_face3 ; + tmpConstituents1[3]=_face4 ; + tmpConstituents1[4]=_face5 ; + tmpConstituents1[5]=_face6 ; + int ** tmpConstituents2 = new (int*)[12]; + tmpConstituents2[0]=_edge1 ; + tmpConstituents2[1]=_edge2 ; + tmpConstituents2[2]=_edge3 ; + tmpConstituents2[3]=_edge4 ; + tmpConstituents2[4]=_edge5 ; + tmpConstituents2[5]=_edge6 ; + tmpConstituents2[6]=_edge7 ; + tmpConstituents2[7]=_edge8 ; + tmpConstituents2[8]=_edge9 ; + tmpConstituents2[9]=_edge10; + tmpConstituents2[10]=_edge11; + tmpConstituents2[11]=_edge12; + _constituents = new int**[2] ; + _constituents[0]=tmpConstituents1 ; + _constituents[1]=tmpConstituents2 ; + medGeometryElement * tmpConstituentsType1 = new medGeometryElement[6] ; + tmpConstituentsType1[0] = MED_QUAD4 ; + tmpConstituentsType1[1] = MED_QUAD4 ; + tmpConstituentsType1[2] = MED_QUAD4 ; + tmpConstituentsType1[3] = MED_QUAD4 ; + tmpConstituentsType1[4] = MED_QUAD4 ; + tmpConstituentsType1[5] = MED_QUAD4 ; + medGeometryElement * tmpConstituentsType2 = new medGeometryElement[12] ; + tmpConstituentsType2[0] = MED_SEG2 ; + tmpConstituentsType2[1] = MED_SEG2 ; + tmpConstituentsType2[2] = MED_SEG2 ; + tmpConstituentsType2[3] = MED_SEG2 ; + tmpConstituentsType2[4] = MED_SEG2 ; + tmpConstituentsType2[5] = MED_SEG2 ; + tmpConstituentsType2[6] = MED_SEG2 ; + tmpConstituentsType2[7] = MED_SEG2 ; + tmpConstituentsType2[8] = MED_SEG2 ; + tmpConstituentsType2[9] = MED_SEG2 ; + tmpConstituentsType2[10] = MED_SEG2 ; + tmpConstituentsType2[11] = MED_SEG2 ; + _constituentsType = new medGeometryElement*[2] ; + _constituentsType[0]=tmpConstituentsType1 ; + _constituentsType[1]=tmpConstituentsType2 ; break; } case MED_HEXA20 : { @@ -288,58 +688,180 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _dimension=3; _numberOfVertexes=8; _numberOfNodes=20; + _numberOfConstituentsDimension=2 ; + _numberOfConstituents=new int[2] ; + _numberOfConstituents[0]=6 ; + _numberOfConstituents[1]=12 ; + _numberOfNodeOfEachConstituent=new (int*)[2] ; + _numberOfNodeOfEachConstituent[0]=new (int)[6] ; + _numberOfNodeOfEachConstituent[0][0]=8 ; + _numberOfNodeOfEachConstituent[0][1]=8 ; + _numberOfNodeOfEachConstituent[0][2]=8 ; + _numberOfNodeOfEachConstituent[0][3]=8 ; + _numberOfNodeOfEachConstituent[0][4]=8 ; + _numberOfNodeOfEachConstituent[0][5]=8 ; + _numberOfNodeOfEachConstituent[1]=new (int)[12] ; + _numberOfNodeOfEachConstituent[1][0]=3 ; + _numberOfNodeOfEachConstituent[1][1]=3 ; + _numberOfNodeOfEachConstituent[1][2]=3 ; + _numberOfNodeOfEachConstituent[1][3]=3 ; + _numberOfNodeOfEachConstituent[1][4]=3 ; + _numberOfNodeOfEachConstituent[1][5]=3 ; + _numberOfNodeOfEachConstituent[1][6]=3 ; + _numberOfNodeOfEachConstituent[1][7]=3 ; + _numberOfNodeOfEachConstituent[1][8]=3 ; + _numberOfNodeOfEachConstituent[1][9]=3 ; + _numberOfNodeOfEachConstituent[1][10]=3 ; + _numberOfNodeOfEachConstituent[1][11]=3 ; - int _edge1[]={1,2,9} ; - int _edge2[]={2,3,10} ; - int _edge3[]={3,4,11} ; - int _edge4[]={4,1,12} ; - int _edge5[]={5,6,13} ; - int _edge6[]={6,7,14}; - int _edge7[]={7,8,15} ; - int _edge8[]={8,5,16} ; - int _edge9[]={1,5,17} ; - int _edge10[]={2,6,18} ; - int _edge11[]={3,7,19} ; - int _edge12[]={4,8,20} ; - - vector edge1(_edge1,_edge1+3) ; - vector edge2(_edge2,_edge2+3) ; - vector edge3(_edge3,_edge3+3) ; - vector edge4(_edge4,_edge4+3) ; - vector edge5(_edge5,_edge5+3) ; - vector edge6(_edge6,_edge6+3) ; - vector edge7(_edge7,_edge7+3) ; - vector edge8(_edge8,_edge8+3) ; - vector edge9(_edge9,_edge9+3) ; - vector edge10(_edge10,_edge10+3) ; - vector edge11(_edge11,_edge11+3) ; - vector edge12(_edge12,_edge12+3) ; - vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9,edge10, edge11,edge12}; - vector< vector > vector_edge(_vector_edge,_vector_edge+12) ; - - int _face1[]={1,2,3,4,9,10,11,12} ; - int _face2[]={5,8,7,6,16,15,14,13} ; - int _face3[]={1,5,6,2,17,13,18,9} ; - int _face4[]={2,6,7,3,18,14,19,10} ; - int _face5[]={3,7,8,4,19,15,20,11} ; - int _face6[]={4,8,5,1,20,16,17,12} ; - vector face1(_face1,_face1+8); - vector face2(_face2,_face2+8); - vector face3(_face3,_face3+8); - vector face4(_face4,_face4+8); - vector face5(_face5,_face5+8); - vector face6(_face6,_face6+8); - vector _vector_face[]= {face1,face2,face3,face4,face5,face6} ; - vector< vector > vector_face(_vector_face,_vector_face+6); - - vector< vector > __constituents__[]={vector_face,vector_edge}; - vector< vector< vector > > _constituents_(__constituents__,__constituents__+2) ; - _constituents = _constituents_ ; - vector vector_edge_type(12,MED_SEG3) ; - vector vector_face_type(6,MED_QUAD8) ; - vector __constituents_type[]={vector_face_type,vector_edge_type}; - vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; - _constituentsType = _constituents_type ; + int* _edge1=new int[3]; + _edge1[0]=1; + _edge1[1]=2; + _edge1[2]=9; + int* _edge2=new int[3]; + _edge2[0]=2; + _edge2[1]=3; + _edge2[2]=10; + int* _edge3=new int[3]; + _edge3[0]=3; + _edge3[1]=4; + _edge3[2]=11; + int* _edge4=new int[3]; + _edge4[0]=4; + _edge4[1]=1; + _edge4[2]=12; + int* _edge5=new int[3]; + _edge5[0]=5; + _edge5[1]=6; + _edge5[2]=13; + int* _edge6=new int[3]; + _edge6[0]=6; + _edge6[1]=7; + _edge6[2]=14; + int* _edge7=new int[3]; + _edge7[0]=7; + _edge7[1]=8; + _edge7[2]=15; + int* _edge8=new int[3]; + _edge8[0]=8; + _edge8[1]=5; + _edge8[2]=16; + int* _edge9=new int[3]; + _edge9[0]=1; + _edge9[1]=5; + _edge9[2]=17; + int* _edge10=new int[3]; + _edge10[0]=2; + _edge10[1]=6; + _edge10[2]=18; + int* _edge11=new int[3]; + _edge11[0]=3; + _edge11[1]=7; + _edge11[2]=19; + int* _edge12=new int[3]; + _edge12[0]=4; + _edge12[1]=8; + _edge12[2]=20; + int* _face1=new int[8]; + _face1[0]=1; + _face1[1]=2; + _face1[2]=3; + _face1[3]=4; + _face1[4]=9; + _face1[5]=10; + _face1[6]=11; + _face1[7]=12; + int* _face2=new int[8]; + _face2[0]=5; + _face2[1]=8; + _face2[2]=7; + _face2[3]=6; + _face2[4]=16; + _face2[5]=15; + _face2[6]=14; + _face2[7]=13; + int* _face3=new int[8]; + _face3[0]=1; + _face3[1]=5; + _face3[2]=6; + _face3[3]=2; + _face3[4]=17; + _face3[5]=13; + _face3[6]=18; + _face3[7]=9; + int* _face4=new int[8]; + _face4[0]=2; + _face4[1]=6; + _face4[2]=7; + _face4[3]=3; + _face4[4]=18; + _face4[5]=14; + _face4[6]=19; + _face4[7]=10; + int* _face5=new int[8]; + _face5[0]=3; + _face5[1]=7; + _face5[2]=8; + _face5[3]=4; + _face5[4]=19; + _face5[5]=15; + _face5[6]=20; + _face5[7]=11; + int* _face6=new int[8]; + _face6[0]=4; + _face6[1]=8; + _face6[2]=5; + _face6[3]=1; + _face6[4]=20; + _face6[5]=16; + _face6[6]=17; + _face6[7]=12; + int ** tmpConstituents1 = new (int*)[6]; + tmpConstituents1[0]=_face1 ; + tmpConstituents1[1]=_face2 ; + tmpConstituents1[2]=_face3 ; + tmpConstituents1[3]=_face4 ; + tmpConstituents1[4]=_face5 ; + tmpConstituents1[5]=_face6 ; + int ** tmpConstituents2 = new (int*)[12]; + tmpConstituents2[0]=_edge1 ; + tmpConstituents2[1]=_edge2 ; + tmpConstituents2[2]=_edge3 ; + tmpConstituents2[3]=_edge4 ; + tmpConstituents2[4]=_edge5 ; + tmpConstituents2[5]=_edge6 ; + tmpConstituents2[6]=_edge7 ; + tmpConstituents2[7]=_edge8 ; + tmpConstituents2[8]=_edge9 ; + tmpConstituents2[9]=_edge10; + tmpConstituents2[10]=_edge11; + tmpConstituents2[11]=_edge12; + _constituents = new int**[2] ; + _constituents[0]=tmpConstituents1 ; + _constituents[1]=tmpConstituents2 ; + medGeometryElement * tmpConstituentsType1 = new medGeometryElement[6] ; + tmpConstituentsType1[0] = MED_QUAD8 ; + tmpConstituentsType1[1] = MED_QUAD8 ; + tmpConstituentsType1[2] = MED_QUAD8 ; + tmpConstituentsType1[3] = MED_QUAD8 ; + tmpConstituentsType1[4] = MED_QUAD8 ; + tmpConstituentsType1[5] = MED_QUAD8 ; + medGeometryElement * tmpConstituentsType2 = new medGeometryElement[12] ; + tmpConstituentsType2[0] = MED_SEG3 ; + tmpConstituentsType2[1] = MED_SEG3 ; + tmpConstituentsType2[2] = MED_SEG3 ; + tmpConstituentsType2[3] = MED_SEG3 ; + tmpConstituentsType2[4] = MED_SEG3 ; + tmpConstituentsType2[5] = MED_SEG3 ; + tmpConstituentsType2[6] = MED_SEG3 ; + tmpConstituentsType2[7] = MED_SEG3 ; + tmpConstituentsType2[8] = MED_SEG3 ; + tmpConstituentsType2[9] = MED_SEG3 ; + tmpConstituentsType2[10] = MED_SEG3 ; + tmpConstituentsType2[11] = MED_SEG3 ; + _constituentsType = new medGeometryElement*[2] ; + _constituentsType[0]=tmpConstituentsType1 ; + _constituentsType[1]=tmpConstituentsType2 ; break; } case MED_PENTA6 : { @@ -349,51 +871,116 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfVertexes=6; _numberOfNodes=6; - int _edge1[]= {1,2} ; - int _edge2[]= {2,3} ; - int _edge3[]= {3,1} ; - int _edge4[]= {4,5} ; - int _edge5[]= {5,6} ; - int _edge6[]= {6,4} ; - int _edge7[]= {1,4} ; - int _edge8[]= {2,5} ; - int _edge9[]= {3,6} ; - - vector edge1(_edge1,_edge1+2) ; - vector edge2(_edge2,_edge2+2) ; - vector edge3(_edge3,_edge3+2) ; - vector edge4(_edge4,_edge4+2) ; - vector edge5(_edge5,_edge5+2) ; - vector edge6(_edge6,_edge6+2) ; - vector edge7(_edge7,_edge7+2) ; - vector edge8(_edge8,_edge8+2) ; - vector edge9(_edge9,_edge9+2) ; - vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9}; - vector< vector > vector_edge(_vector_edge,_vector_edge+9) ; - - int _face1[]={1,2,3}; - int _face2[]={4,6,5}; - int _face3[]={1,4,5,2}; - int _face4[]={2,5,6,3}; - int _face5[]={3,6,4,1}; - vector face1(_face1,_face1+3); - vector face2(_face2,_face2+3); - vector face3(_face3,_face3+4); - vector face4(_face4,_face4+4); - vector face5(_face5,_face5+4); - vector _vector_face[]= {face1,face2,face3,face4,face5} ; - vector< vector > vector_face(_vector_face,_vector_face+5); - - vector< vector > __constituents__[]={vector_face,vector_edge}; - vector< vector< vector > > _constituents_(__constituents__,__constituents__+2) ; - _constituents = _constituents_ ; - vector vector_edge_type(9,MED_SEG2) ; - vector vector_face_type(5,MED_QUAD4) ; - vector_face_type[0]=MED_TRIA3 ; - vector_face_type[1]=MED_TRIA3 ; - vector __constituents_type[]={vector_face_type,vector_edge_type}; - vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; - _constituentsType = _constituents_type ; + _numberOfConstituentsDimension=2 ; + _numberOfConstituents=new int[2] ; + _numberOfConstituents[0]=5 ; + _numberOfConstituents[1]=9 ; + _numberOfNodeOfEachConstituent=new (int*)[2] ; + _numberOfNodeOfEachConstituent[0]=new (int)[5] ; + _numberOfNodeOfEachConstituent[0][0]=3 ; + _numberOfNodeOfEachConstituent[0][1]=3 ; + _numberOfNodeOfEachConstituent[0][2]=4 ; + _numberOfNodeOfEachConstituent[0][3]=4 ; + _numberOfNodeOfEachConstituent[0][4]=4 ; + _numberOfNodeOfEachConstituent[1]=new (int)[9] ; + _numberOfNodeOfEachConstituent[1][0]=2 ; + _numberOfNodeOfEachConstituent[1][1]=2 ; + _numberOfNodeOfEachConstituent[1][2]=2 ; + _numberOfNodeOfEachConstituent[1][3]=2 ; + _numberOfNodeOfEachConstituent[1][4]=2 ; + _numberOfNodeOfEachConstituent[1][5]=2 ; + _numberOfNodeOfEachConstituent[1][6]=2 ; + _numberOfNodeOfEachConstituent[1][7]=2 ; + _numberOfNodeOfEachConstituent[1][8]=2 ; + + int* _edge1=new int[2]; + _edge1[0]=1; + _edge1[1]=2; + int* _edge2=new int[2]; + _edge2[0]=2; + _edge2[1]=3; + int* _edge3=new int[2]; + _edge3[0]=3; + _edge3[1]=1; + int* _edge4=new int[2]; + _edge4[0]=4; + _edge4[1]=5; + int* _edge5=new int[2]; + _edge5[0]=5; + _edge5[1]=6; + int* _edge6=new int[2]; + _edge6[0]=6; + _edge6[1]=4; + int* _edge7=new int[2]; + _edge7[0]=1; + _edge7[1]=4; + int* _edge8=new int[2]; + _edge8[0]=2; + _edge8[1]=5; + int* _edge9=new int[2]; + _edge9[0]=3; + _edge9[1]=6; + int* _face1=new int[3]; + _face1[0]=1; + _face1[1]=2; + _face1[2]=3; + int* _face2=new int[3]; + _face2[0]=4; + _face2[1]=6; + _face2[2]=5; + int* _face3=new int[4]; + _face3[0]=1; + _face3[1]=4; + _face3[2]=5; + _face3[3]=2; + int* _face4=new int[4]; + _face4[0]=2; + _face4[1]=5; + _face4[2]=6; + _face4[3]=3; + int* _face5=new int[4]; + _face5[0]=3; + _face5[1]=6; + _face5[2]=4; + _face5[3]=1; + int ** tmpConstituents1 = new (int*)[5]; + tmpConstituents1[0]=_face1 ; + tmpConstituents1[1]=_face2 ; + tmpConstituents1[2]=_face3 ; + tmpConstituents1[3]=_face4 ; + tmpConstituents1[4]=_face5 ; + int ** tmpConstituents2 = new (int*)[9]; + tmpConstituents2[0]=_edge1 ; + tmpConstituents2[1]=_edge2 ; + tmpConstituents2[2]=_edge3 ; + tmpConstituents2[3]=_edge4 ; + tmpConstituents2[4]=_edge5 ; + tmpConstituents2[5]=_edge6 ; + tmpConstituents2[6]=_edge7 ; + tmpConstituents2[7]=_edge8 ; + tmpConstituents2[8]=_edge9 ; + _constituents = new int**[2] ; + _constituents[0]=tmpConstituents1 ; + _constituents[1]=tmpConstituents2 ; + medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ; + tmpConstituentsType1[0] = MED_TRIA3 ; + tmpConstituentsType1[1] = MED_TRIA3 ; + tmpConstituentsType1[2] = MED_QUAD4 ; + tmpConstituentsType1[3] = MED_QUAD4 ; + tmpConstituentsType1[4] = MED_QUAD4 ; + medGeometryElement * tmpConstituentsType2 = new medGeometryElement[9] ; + tmpConstituentsType2[0] = MED_SEG2 ; + tmpConstituentsType2[1] = MED_SEG2 ; + tmpConstituentsType2[2] = MED_SEG2 ; + tmpConstituentsType2[3] = MED_SEG2 ; + tmpConstituentsType2[4] = MED_SEG2 ; + tmpConstituentsType2[5] = MED_SEG2 ; + tmpConstituentsType2[6] = MED_SEG2 ; + tmpConstituentsType2[7] = MED_SEG2 ; + tmpConstituentsType2[8] = MED_SEG2 ; + _constituentsType = new medGeometryElement*[2] ; + _constituentsType[0]=tmpConstituentsType1 ; + _constituentsType[1]=tmpConstituentsType2 ; break; } case MED_PENTA15 : { @@ -402,52 +989,144 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _dimension=3; _numberOfVertexes=6; _numberOfNodes=15; - int _edge1[]={1,2,7} ; - int _edge2[]={2,3,8} ; - int _edge3[]={3,1,9} ; - int _edge4[]={4,5,10} ; - int _edge5[]={5,6,11} ; - int _edge6[]={6,4,12} ; - int _edge7[]={1,4,13} ; - int _edge8[]={2,5,14} ; - int _edge9[]={3,6,15} ; - - vector edge1(_edge1,_edge1+3) ; - vector edge2(_edge2,_edge2+3) ; - vector edge3(_edge3,_edge3+3) ; - vector edge4(_edge4,_edge4+3) ; - vector edge5(_edge5,_edge5+3) ; - vector edge6(_edge6,_edge6+3) ; - vector edge7(_edge7,_edge7+3) ; - vector edge8(_edge8,_edge8+3) ; - vector edge9(_edge9,_edge9+3) ; - vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9}; - vector< vector > vector_edge(_vector_edge,_vector_edge+9) ; - - int _face1[]={1,2,3,7,8,9}; - int _face2[]={4,6,5,12,11,10}; - int _face3[]={1,4,5,2,13,10,14,7}; - int _face4[]={2,5,6,3,14,11,15,8}; - int _face5[]={3,6,4,1,15,12,13,9}; - vector face1(_face1,_face1+6); - vector face2(_face2,_face2+6); - vector face3(_face3,_face3+8); - vector face4(_face4,_face4+8); - vector face5(_face5,_face5+8); - vector _vector_face[]= {face1,face2,face3,face4,face5} ; - vector< vector > vector_face(_vector_face,_vector_face+5); - - vector< vector > __constituents__[]={vector_face,vector_edge}; - vector< vector< vector > > _constituents_(__constituents__,__constituents__+2) ; - _constituents = _constituents_ ; - vector vector_edge_type(9,MED_SEG3) ; - vector vector_face_type(5,MED_QUAD8) ; - vector_face_type[0]=MED_TRIA6 ; - vector_face_type[1]=MED_TRIA6 ; - vector __constituents_type[]={vector_face_type,vector_edge_type}; - vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; - _constituentsType = _constituents_type ; - break; + _numberOfConstituentsDimension=2 ; + _numberOfConstituents=new int[2] ; + _numberOfConstituents[0]=5 ; + _numberOfConstituents[1]=9 ; + _numberOfNodeOfEachConstituent=new (int*)[2] ; + _numberOfNodeOfEachConstituent[0]=new (int)[5] ; + _numberOfNodeOfEachConstituent[0][0]=6 ; + _numberOfNodeOfEachConstituent[0][1]=6 ; + _numberOfNodeOfEachConstituent[0][2]=8 ; + _numberOfNodeOfEachConstituent[0][3]=8 ; + _numberOfNodeOfEachConstituent[0][4]=8 ; + _numberOfNodeOfEachConstituent[1]=new (int)[9] ; + _numberOfNodeOfEachConstituent[1][0]=3 ; + _numberOfNodeOfEachConstituent[1][1]=3 ; + _numberOfNodeOfEachConstituent[1][2]=3 ; + _numberOfNodeOfEachConstituent[1][3]=3 ; + _numberOfNodeOfEachConstituent[1][4]=3 ; + _numberOfNodeOfEachConstituent[1][5]=3 ; + _numberOfNodeOfEachConstituent[1][6]=3 ; + _numberOfNodeOfEachConstituent[1][7]=3 ; + _numberOfNodeOfEachConstituent[1][8]=3 ; + + int* _edge1=new int[3]; + _edge1[0]=1; + _edge1[1]=2; + _edge1[2]=7; + int* _edge2=new int[3]; + _edge2[0]=2; + _edge2[1]=3; + _edge2[2]=8; + int* _edge3=new int[3]; + _edge3[0]=3; + _edge3[1]=1; + _edge3[2]=9; + int* _edge4=new int[3]; + _edge4[0]=4; + _edge4[1]=5; + _edge4[2]=10; + int* _edge5=new int[3]; + _edge5[0]=5; + _edge5[1]=6; + _edge5[2]=11; + int* _edge6=new int[3]; + _edge6[0]=6; + _edge6[1]=4; + _edge6[2]=12; + int* _edge7=new int[3]; + _edge7[0]=1; + _edge7[1]=4; + _edge7[2]=13; + int* _edge8=new int[3]; + _edge8[0]=2; + _edge8[1]=5; + _edge8[2]=14; + int* _edge9=new int[3]; + _edge9[0]=3; + _edge9[1]=6; + _edge9[2]=15; + int* _face1=new int[6]; + _face1[0]=1; + _face1[1]=2; + _face1[2]=3; + _face1[3]=7; + _face1[4]=8; + _face1[5]=9; + int* _face2=new int[6]; + _face2[0]=4; + _face2[1]=5; + _face2[2]=6; + _face2[3]=12; + _face2[4]=11; + _face2[5]=10; + int* _face3=new int[8]; + _face3[0]=1; + _face3[1]=4; + _face3[2]=5; + _face3[3]=2; + _face3[4]=13; + _face3[5]=10; + _face3[6]=14; + _face3[7]=7; + int* _face4=new int[8]; + _face4[0]=2; + _face4[1]=5; + _face4[2]=6; + _face4[3]=3; + _face4[4]=14; + _face4[5]=11; + _face4[6]=15; + _face4[7]=8; + int* _face5=new int[8]; + _face5[0]=3; + _face5[1]=6; + _face5[2]=4; + _face5[3]=1; + _face5[4]=15; + _face5[5]=12; + _face5[6]=13; + _face5[7]=9; + int ** tmpConstituents1 = new (int*)[5]; + tmpConstituents1[0]=_face1 ; + tmpConstituents1[1]=_face2 ; + tmpConstituents1[2]=_face3 ; + tmpConstituents1[3]=_face4 ; + tmpConstituents1[4]=_face5 ; + int ** tmpConstituents2 = new (int*)[9]; + tmpConstituents2[0]=_edge1 ; + tmpConstituents2[1]=_edge2 ; + tmpConstituents2[2]=_edge3 ; + tmpConstituents2[3]=_edge4 ; + tmpConstituents2[4]=_edge5 ; + tmpConstituents2[5]=_edge6 ; + tmpConstituents2[6]=_edge7 ; + tmpConstituents2[7]=_edge8 ; + tmpConstituents2[8]=_edge9 ; + _constituents = new (int**)[2] ; + _constituents[0]=tmpConstituents1 ; + _constituents[1]=tmpConstituents2 ; + medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ; + tmpConstituentsType1[0] = MED_TRIA6 ; + tmpConstituentsType1[1] = MED_TRIA6 ; + tmpConstituentsType1[2] = MED_QUAD8 ; + tmpConstituentsType1[3] = MED_QUAD8 ; + tmpConstituentsType1[4] = MED_QUAD8 ; + medGeometryElement * tmpConstituentsType2 = new medGeometryElement[9] ; + tmpConstituentsType2[0] = MED_SEG3 ; + tmpConstituentsType2[1] = MED_SEG3 ; + tmpConstituentsType2[2] = MED_SEG3 ; + tmpConstituentsType2[3] = MED_SEG3 ; + tmpConstituentsType2[4] = MED_SEG3 ; + tmpConstituentsType2[5] = MED_SEG3 ; + tmpConstituentsType2[6] = MED_SEG3 ; + tmpConstituentsType2[7] = MED_SEG3 ; + tmpConstituentsType2[8] = MED_SEG3 ; + _constituentsType = new (medGeometryElement*)[2] ; + _constituentsType[0]=tmpConstituentsType1 ; + _constituentsType[1]=tmpConstituentsType2 ; + break ; } case MED_PYRA5 : { _name="MED_PYRA5" ; @@ -455,48 +1134,108 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _dimension=3; _numberOfVertexes=5; _numberOfNodes=5; - int _edge1[]={1,2} ; - int _edge2[]={2,3} ; - int _edge3[]={3,4} ; - int _edge4[]={4,1} ; - int _edge5[]={1,5} ; - int _edge6[]={2,5} ; - int _edge7[]={3,5} ; - int _edge8[]={4,5} ; - - vector edge1(_edge1,_edge1+2) ; - vector edge2(_edge2,_edge2+2) ; - vector edge3(_edge3,_edge3+2) ; - vector edge4(_edge4,_edge4+2) ; - vector edge5(_edge5,_edge5+2) ; - vector edge6(_edge6,_edge6+2) ; - vector edge7(_edge7,_edge7+2) ; - vector edge8(_edge8,_edge8+2) ; - vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8}; - vector< vector > vector_edge(_vector_edge,_vector_edge+8) ; - - int _face1[]={1,2,3,4} ; - int _face2[]={1,5,2} ; - int _face3[]={2,5,3} ; - int _face4[]={3,5,4} ; - int _face5[]={4,5,1} ; - vector face1(_face1,_face1+4); - vector face2(_face2,_face2+3); - vector face3(_face3,_face3+3); - vector face4(_face4,_face4+3); - vector face5(_face5,_face5+3); - vector _vector_face[]= {face1,face2,face3,face4,face5} ; - vector< vector > vector_face(_vector_face,_vector_face+5); - - vector< vector > __constituents__[]={vector_face,vector_edge}; - vector< vector< vector > > _constituents_(__constituents__,__constituents__+2) ; - _constituents = _constituents_ ; - vector vector_edge_type(8,MED_SEG2) ; - vector vector_face_type(5,MED_TRIA3) ; - vector_face_type[0]=MED_QUAD4 ; - vector __constituents_type[]={vector_face_type,vector_edge_type}; - vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; - _constituentsType = _constituents_type ; + _numberOfConstituentsDimension=2 ; + _numberOfConstituents=new int[2] ; + _numberOfConstituents[0]=5 ; + _numberOfConstituents[1]=8 ; + _numberOfNodeOfEachConstituent=new (int*)[2] ; + _numberOfNodeOfEachConstituent[0]=new (int)[5] ; + _numberOfNodeOfEachConstituent[0][0]=4 ; + _numberOfNodeOfEachConstituent[0][1]=3 ; + _numberOfNodeOfEachConstituent[0][2]=3 ; + _numberOfNodeOfEachConstituent[0][3]=3 ; + _numberOfNodeOfEachConstituent[0][4]=3 ; + _numberOfNodeOfEachConstituent[1]=new (int)[8] ; + _numberOfNodeOfEachConstituent[1][0]=2 ; + _numberOfNodeOfEachConstituent[1][1]=2 ; + _numberOfNodeOfEachConstituent[1][2]=2 ; + _numberOfNodeOfEachConstituent[1][3]=2 ; + _numberOfNodeOfEachConstituent[1][4]=2 ; + _numberOfNodeOfEachConstituent[1][5]=2 ; + _numberOfNodeOfEachConstituent[1][6]=2 ; + _numberOfNodeOfEachConstituent[1][7]=2 ; + + int* _edge1=new int[2]; + _edge1[0]=1; + _edge1[1]=2; + int* _edge2=new int[2]; + _edge2[0]=2; + _edge2[1]=3; + int* _edge3=new int[2]; + _edge3[0]=3; + _edge3[1]=4; + int* _edge4=new int[2]; + _edge4[0]=4; + _edge4[1]=1; + int* _edge5=new int[2]; + _edge5[0]=1; + _edge5[1]=5; + int* _edge6=new int[2]; + _edge6[0]=2; + _edge6[1]=5; + int* _edge7=new int[2]; + _edge7[0]=3; + _edge7[1]=5; + int* _edge8=new int[2]; + _edge8[0]=4; + _edge8[1]=5; + int* _face1=new int[4]; + _face1[0]=1; + _face1[1]=2; + _face1[2]=3; + _face1[3]=4; + int* _face2=new int[3]; + _face2[0]=1; + _face2[1]=5; + _face2[2]=2; + int* _face3=new int[3]; + _face3[0]=2; + _face3[1]=5; + _face3[2]=3; + int* _face4=new int[3]; + _face4[0]=3; + _face4[1]=5; + _face4[2]=4; + int* _face5=new int[3]; + _face5[0]=4; + _face5[1]=5; + _face5[2]=1; + int ** tmpConstituents1 = new (int*)[5]; + tmpConstituents1[0]=_face1 ; + tmpConstituents1[1]=_face2 ; + tmpConstituents1[2]=_face3 ; + tmpConstituents1[3]=_face4 ; + tmpConstituents1[4]=_face5 ; + int ** tmpConstituents2 = new (int*)[8]; + tmpConstituents2[0]=_edge1 ; + tmpConstituents2[1]=_edge2 ; + tmpConstituents2[2]=_edge3 ; + tmpConstituents2[3]=_edge4 ; + tmpConstituents2[4]=_edge5 ; + tmpConstituents2[5]=_edge6 ; + tmpConstituents2[6]=_edge7 ; + tmpConstituents2[7]=_edge8 ; + _constituents = new int**[2] ; + _constituents[0]=tmpConstituents1 ; + _constituents[1]=tmpConstituents2 ; + medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ; + tmpConstituentsType1[0] = MED_QUAD4 ; + tmpConstituentsType1[1] = MED_TRIA3 ; + tmpConstituentsType1[2] = MED_TRIA3 ; + tmpConstituentsType1[3] = MED_TRIA3 ; + tmpConstituentsType1[4] = MED_TRIA3 ; + medGeometryElement * tmpConstituentsType2 = new medGeometryElement[8] ; + tmpConstituentsType2[0] = MED_SEG2 ; + tmpConstituentsType2[1] = MED_SEG2 ; + tmpConstituentsType2[2] = MED_SEG2 ; + tmpConstituentsType2[3] = MED_SEG2 ; + tmpConstituentsType2[4] = MED_SEG2 ; + tmpConstituentsType2[5] = MED_SEG2 ; + tmpConstituentsType2[6] = MED_SEG2 ; + tmpConstituentsType2[7] = MED_SEG2 ; + _constituentsType = new medGeometryElement*[2] ; + _constituentsType[0]=tmpConstituentsType1 ; + _constituentsType[1]=tmpConstituentsType2 ; break; } case MED_PYRA13 : { @@ -505,52 +1244,132 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _dimension=3; _numberOfVertexes=5; _numberOfNodes=13; - int _edge1[]={1,2,6} ; - int _edge2[]={2,3,7} ; - int _edge3[]={3,4,8} ; - int _edge4[]={4,1,9} ; - int _edge5[]={1,5,10} ; - int _edge6[]={2,5,11} ; - int _edge7[]={3,5,12} ; - int _edge8[]={4,5,13} ; - - vector edge1(_edge1,_edge1+3) ; - vector edge2(_edge2,_edge2+3) ; - vector edge3(_edge3,_edge3+3) ; - vector edge4(_edge4,_edge4+3) ; - vector edge5(_edge5,_edge5+3) ; - vector edge6(_edge6,_edge6+3) ; - vector edge7(_edge7,_edge7+3) ; - vector edge8(_edge8,_edge8+3) ; - - - vector _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8}; - vector< vector > vector_edge(_vector_edge,_vector_edge+8) ; - - int _face1[]={1,2,3,4,6,7,8,9} ; - int _face2[]={1,5,2,10,11,6} ; - int _face3[]={2,5,3,11,12,7} ; - int _face4[]={3,5,4,12,13,8} ; - int _face5[]={4,5,1,13,10,9} ; - vector face1(_face1,_face1+8); - vector face2(_face2,_face2+6); - vector face3(_face3,_face3+6); - vector face4(_face4,_face4+6); - vector face5(_face5,_face5+6); - vector _vector_face[]= {face1,face2,face3,face4,face5} ; - vector< vector > vector_face(_vector_face,_vector_face+5); - - - vector< vector > __constituents__[]={vector_face,vector_edge}; - vector< vector< vector > > _constituents_(__constituents__,__constituents__+2) ; - _constituents = _constituents_ ; - vector vector_edge_type(8,MED_SEG3) ; - vector vector_face_type(5,MED_TRIA6) ; - vector_face_type[0]=MED_QUAD8 ; - vector __constituents_type[]={vector_face_type,vector_edge_type}; - vector< vector > _constituents_type(__constituents_type,__constituents_type+2) ; - - _constituentsType = _constituents_type ; + _numberOfConstituentsDimension=2 ; + _numberOfConstituents=new int[2] ; + _numberOfConstituents[0]=5 ; + _numberOfConstituents[1]=8 ; + _numberOfNodeOfEachConstituent=new (int*)[2] ; + _numberOfNodeOfEachConstituent[0]=new (int)[5] ; + _numberOfNodeOfEachConstituent[0][0]=8 ; + _numberOfNodeOfEachConstituent[0][1]=6 ; + _numberOfNodeOfEachConstituent[0][2]=6 ; + _numberOfNodeOfEachConstituent[0][3]=6 ; + _numberOfNodeOfEachConstituent[0][4]=6 ; + _numberOfNodeOfEachConstituent[1]=new (int)[8] ; + _numberOfNodeOfEachConstituent[1][0]=3 ; + _numberOfNodeOfEachConstituent[1][1]=3 ; + _numberOfNodeOfEachConstituent[1][2]=3 ; + _numberOfNodeOfEachConstituent[1][3]=3 ; + _numberOfNodeOfEachConstituent[1][4]=3 ; + _numberOfNodeOfEachConstituent[1][5]=3 ; + _numberOfNodeOfEachConstituent[1][6]=3 ; + _numberOfNodeOfEachConstituent[1][7]=3 ; + + int* _edge1=new int[3]; + _edge1[0]=1; + _edge1[1]=2; + _edge1[2]=6; + int* _edge2=new int[3]; + _edge2[0]=2; + _edge2[1]=3; + _edge2[2]=7; + int* _edge3=new int[3]; + _edge3[0]=3; + _edge3[1]=4; + _edge3[2]=8; + int* _edge4=new int[3]; + _edge4[0]=4; + _edge4[1]=1; + _edge4[2]=9; + int* _edge5=new int[3]; + _edge5[0]=1; + _edge5[1]=5; + _edge5[2]=10; + int* _edge6=new int[3]; + _edge6[0]=2; + _edge6[1]=5; + _edge6[2]=11; + int* _edge7=new int[3]; + _edge7[0]=3; + _edge7[1]=5; + _edge7[2]=12; + int* _edge8=new int[3]; + _edge8[0]=4; + _edge8[1]=5; + _edge8[2]=13; + int* _face1=new int[8]; + _face1[0]=1; + _face1[1]=2; + _face1[2]=3; + _face1[3]=4; + _face1[4]=6; + _face1[5]=7; + _face1[6]=8; + _face1[7]=9; + int* _face2=new int[6]; + _face2[0]=1; + _face2[1]=5; + _face2[2]=2; + _face2[3]=10; + _face2[4]=11; + _face2[5]=6; + int* _face3=new int[6]; + _face3[0]=2; + _face3[1]=5; + _face3[2]=3; + _face3[3]=11; + _face3[4]=12; + _face3[5]=7; + int* _face4=new int[6]; + _face4[0]=3; + _face4[1]=5; + _face4[2]=4; + _face4[3]=12; + _face4[4]=13; + _face4[5]=8; + int* _face5=new int[6]; + _face5[0]=4; + _face5[1]=5; + _face5[2]=1; + _face5[3]=13; + _face5[4]=10; + _face5[5]=9; + int ** tmpConstituents1 = new (int*)[5]; + tmpConstituents1[0]=_face1 ; + tmpConstituents1[1]=_face2 ; + tmpConstituents1[2]=_face3 ; + tmpConstituents1[3]=_face4 ; + tmpConstituents1[4]=_face5 ; + int ** tmpConstituents2 = new (int*)[8]; + tmpConstituents2[0]=_edge1 ; + tmpConstituents2[1]=_edge2 ; + tmpConstituents2[2]=_edge3 ; + tmpConstituents2[3]=_edge4 ; + tmpConstituents2[4]=_edge5 ; + tmpConstituents2[5]=_edge6 ; + tmpConstituents2[6]=_edge7 ; + tmpConstituents2[7]=_edge8 ; + _constituents = new int**[2] ; + _constituents[0]=tmpConstituents1 ; + _constituents[1]=tmpConstituents2 ; + medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ; + tmpConstituentsType1[0] = MED_QUAD8 ; + tmpConstituentsType1[1] = MED_TRIA6 ; + tmpConstituentsType1[2] = MED_TRIA6 ; + tmpConstituentsType1[3] = MED_TRIA6 ; + tmpConstituentsType1[4] = MED_TRIA6 ; + medGeometryElement * tmpConstituentsType2 = new medGeometryElement[8] ; + tmpConstituentsType2[0] = MED_SEG3 ; + tmpConstituentsType2[1] = MED_SEG3 ; + tmpConstituentsType2[2] = MED_SEG3 ; + tmpConstituentsType2[3] = MED_SEG3 ; + tmpConstituentsType2[4] = MED_SEG3 ; + tmpConstituentsType2[5] = MED_SEG3 ; + tmpConstituentsType2[6] = MED_SEG3 ; + tmpConstituentsType2[7] = MED_SEG3 ; + _constituentsType = new medGeometryElement*[2] ; + _constituentsType[0]=tmpConstituentsType1 ; + _constituentsType[1]=tmpConstituentsType2 ; break; } // default : @@ -567,13 +1386,20 @@ ostream & operator<<(ostream &os,const CELLMODEL &my) os << " - dimension : " << my._dimension << endl; os << " - number of nodes : " << my._numberOfNodes << endl ; os << " - number of vertexes : " << my._numberOfVertexes << endl ; - for(int i=0;i constituentsTypes ; - if (_constituentsType.size() > 0 ) { - vector constituentsType = _constituentsType[0] ; - vector::iterator itvec ; - for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++) - constituentsTypes.insert(*itvec); - } +// if (_constituentsType.size() > 0 ) { +// vector constituentsType = _constituentsType[0] ; +// vector::iterator itvec ; +// for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++) +// constituentsTypes.insert(*itvec); +// } return constituentsTypes.size() ; } // Return all types of constituents which dimension is (_dimension-1). -set CELLMODEL::getAllConstituentsType() const +set CELLMODEL::getAllConstituentsType() const { set constituentsTypes ; - if (_constituentsType.size() > 0 ) { - vector constituentsType = _constituentsType[0] ; - vector::iterator itvec ; - for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++) - constituentsTypes.insert(*itvec); - } +// if (_constituentsType.size() > 0 ) { +// vector constituentsType = _constituentsType[0] ; +// vector::iterator itvec ; +// for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++) +// constituentsTypes.insert(*itvec); +// } return constituentsTypes ; } // Return number of constituents foreach type (which dimension is _dimension-1). -map CELLMODEL::getNumberOfConstituentsForeachType() const +map CELLMODEL::getNumberOfConstituentsForeachType() const { map numberOfConstituentsForeachType ; - map::iterator itmap ; - if (_constituentsType.size() > 0 ) { - vector constituentsType = _constituentsType[0] ; - vector::iterator itvec ; - for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++) { - itmap = numberOfConstituentsForeachType.find(*itvec); - if (itmap==numberOfConstituentsForeachType.end()) // new element - numberOfConstituentsForeachType[*itvec]=1 ; - else - numberOfConstituentsForeachType[*itvec]++ ; +// map::iterator itmap ; +// if (_constituentsType.size() > 0 ) { +// vector constituentsType = _constituentsType[0] ; +// vector::iterator itvec ; +// for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++) { +// itmap = numberOfConstituentsForeachType.find(*itvec); +// if (itmap==numberOfConstituentsForeachType.end()) // new element +// numberOfConstituentsForeachType[*itvec]=1 ; +// else +// numberOfConstituentsForeachType[*itvec]++ ; +// } +// } + return numberOfConstituentsForeachType ; +} + +void CELLMODEL::init(const CELLMODEL &m) +{ + _name=m._name ; + _type= m._type ; + _dimension = m._dimension ; + _numberOfNodes = m._numberOfNodes ; + _numberOfVertexes = m._numberOfVertexes ; + + _numberOfConstituentsDimension = m._numberOfConstituentsDimension ; + + _numberOfConstituents = new int[_numberOfConstituentsDimension] ; + for(int i=0; i<_numberOfConstituentsDimension; i++) + _numberOfConstituents[i]=m._numberOfConstituents[i] ; + + _numberOfNodeOfEachConstituent = new (int*)[_numberOfConstituentsDimension] ; + for(int i=0; i<_numberOfConstituentsDimension; i++) { + int numberOf = _numberOfConstituents[i] ; + int * newArray = new int[numberOf] ; + int * oldArray = m._numberOfNodeOfEachConstituent[i] ; + for(int j=0; j #include #include #include +#include "utilities.h" #include "MEDMEM_define.hxx" +using namespace std ; using namespace MED_EN; -class CELLMODEL -{ +/*! + This class is an internal class and should not be used by the end-user. + This class describes all possible cell models and is used in order + to acces informations about geometric type of the cell : + Each object (if instancied), contains generic informations about + the cell model it describes as cell dimensions, number of nodes... +*/ -protected : +class CELLMODEL +{ - string _name ; - medGeometryElement _type ; - int _dimension ; // Cell _dimension (!= space _dimension) - int _numberOfNodes ; - int _numberOfVertexes ; - vector< vector< vector > > _constituents ; - // define local connectivity for each constituents - // composing it ( - // first vector : for each cell _dimension - // (first : dim-1, second if any : dim-2) - // second vector : for each constituents of this _dimension, - // third vector : list of local nodes - vector< vector > _constituentsType ; +private: + /*! private method : /n + used by constructor and operator= */ + void init(const CELLMODEL &m); + + /*! private method : /n */ + void clean(); + + + //protected: + /*! explicit name (as MED_POINT1) */ + string _name; + /*! type of cell (cf define.h) */ + medGeometryElement _type; + /*! Cell dimension (not space dimension) */ + int _dimension; + /*! number of nodes forming this type of a cell */ + int _numberOfNodes; + /*! number of vertexes forming this type of a cell */ + int _numberOfVertexes; + /*! 2 for a 3D Cell and 1 for a 2DCell */ + int _numberOfConstituentsDimension; + /*! Array of size numberOfConstituentsDimension */ + int* _numberOfConstituents ; + /*! Array of size _numberOfConstituentsDimension + x_numberOfConstituents[i] */ + int** _numberOfNodeOfEachConstituent ; + /*! defines nodal local connectivity for each + constituents of each dimension: + should be seen as a vector> \n + - first vector : for each cell dimension + (first : dim-1, second if any : dim-2)\n + - second vector : for each constituent of + this dimension\n + - third vector : list of local nodes */ + int*** _constituents ; + medGeometryElement** _constituentsType ; public : - CELLMODEL(){ - _type=MED_NONE ; - _dimension = 0 ; - _numberOfNodes = 0 ; - _numberOfVertexes = 0 ; - } - CELLMODEL(medGeometryElement t) ; - CELLMODEL(const CELLMODEL &m){ - _name= m._name ; - _type= m._type ; - _dimension = m._dimension ; - _numberOfNodes = m._numberOfNodes ; - _numberOfVertexes = m._numberOfVertexes ; - _constituents = m._constituents ; - _constituentsType = m._constituentsType ; - } - ~CELLMODEL() { - }; - - CELLMODEL & operator=(const CELLMODEL &m) { - _name=m._name ; - _type= m._type ; - _dimension = m._dimension ; - _numberOfNodes = m._numberOfNodes ; - _numberOfVertexes = m._numberOfVertexes ; - _constituents = m._constituents ; - _constituentsType = m._constituentsType ; - return *this ; - } + /*! Constructor. */ + inline CELLMODEL(); + /*! Constructor. */ + CELLMODEL(medGeometryElement t); + /*! Copy constructor. */ + inline CELLMODEL(const CELLMODEL &m); + /*! Destructor. */ + inline ~CELLMODEL(); + + /*! Operator = : duplicate CELLMODEL. */ + inline CELLMODEL & operator=(const CELLMODEL &m); + + /*! Operator << : print CELLMODEL to the given stream. */ friend ostream & operator<<(ostream &os,const CELLMODEL &my); - inline string getName() const ; + /*! returns _name attribute (ie: MED_PENTA15).\n + see med.h (in med/include) */ + inline string getName() const; + + /*! returns number of vertexes forming this type of cell */ inline int getNumberOfVertexes() const; - inline int getNumberOfNodes() const; - inline int getDimension() const; - inline medGeometryElement getType() const; - // Return all constituents which dimension is _dimension-dim. - vector< vector > getConstituents(int dim) const; + /*! returns number of nodes forming this type of cell */ + inline int getNumberOfNodes() const; - // Return number of constituents which dimension is _dimension-dim. - int getNumberOfConstituents(int dim) const; + /*! returns the dimension of this type of cell./n + it can be different from mesh dimension */ + inline int getDimension() const; - // Return local nodes numbers vector for num-th constituent which dimension is _dimension-dim. - vector getNodesConstituent(int dim,int num) const; + /*! returns the geometric type of the cell. \n + see med.h (in med/include) */ + inline medGeometryElement getType() const; - // Return local node number of nodes_index-th node for num-th constituent which dimension is _dimension-dim. - int getNodeConstituent(int dim,int num,int nodes_index); + /*! returns all constituents which dimension is _dimension-dim.*/ + int** getConstituents(int dim) const; - // Return types of each constituents which dimension is _dimension-dim. - vector getConstituentsType(int dim) const; + /*! returns number of constituents which dimension is _dimension-dim.*/ + int getNumberOfConstituents(int dim) const; - // Return type of num-th constituent which dimension is _dimension-dim. - medGeometryElement getConstituentType(int dim,int num) const; + /*! returns local nodes numbers vector for num-th constituent + which dimension is _dimension-dim.*/ + int* getNodesConstituent(int dim,int num) const; + /*! returns local node number of nodes_index-th node for + num-th constituent which dimension is _dimension-dim.*/ + int getNodeConstituent(int dim,int num,int nodes_index) const; - // Return number of constituents type (which dimension is _dimension-1). + /*! returns types of each constituents which dimension + is _dimension-dim.*/ + medGeometryElement* getConstituentsType(int dim) const; + + /*! returns type of num-th constituent which dimension + is _dimension-dim.*/ + medGeometryElement getConstituentType(int dim,int num) const; + + /*! returns number of constituents type + (which dimension is _dimension-1).*/ int getNumberOfConstituentsType() const; - // Return all types of constituents which dimension is (_dimension-1). - set getAllConstituentsType() const; + /*! returns all types of constituents which dimension + is (_dimension-1).*/ + set getAllConstituentsType() const; - // Return number of constituents foreach type (which dimension is _dimension-1). - map getNumberOfConstituentsForeachType() const; + /*! returns number of constituents foreach type (which dimension + is _dimension-1).*/ + map getNumberOfConstituentsForeachType() const; }; @@ -108,43 +167,70 @@ public : // Methodes Inline // ------------------------------------------ +inline CELLMODEL::CELLMODEL(): + _type(MED_NONE), + _dimension(0), + _numberOfNodes(0), + _numberOfVertexes(0), + _numberOfConstituentsDimension(0), + _numberOfConstituents((int*)NULL), + _numberOfNodeOfEachConstituent((int**)NULL), + _constituents((int***)NULL), + _constituentsType((medGeometryElement**)NULL) +{ +} +inline CELLMODEL::CELLMODEL(const CELLMODEL &m) +{ + init(m) ; +} +inline CELLMODEL::~CELLMODEL() +{ + MESSAGE("CELLMODEL::~CELLMODEL() destroying the cell"); + clean() ; +}; +inline CELLMODEL & CELLMODEL::operator=(const CELLMODEL &m) +{ + clean() ; + init(m) ; + return *this ; +} inline string CELLMODEL::getName() const { - return _name ; + return _name ; } inline int CELLMODEL::getNumberOfVertexes() const { - return _numberOfVertexes; + return _numberOfVertexes; } inline int CELLMODEL::getNumberOfNodes() const { - return _numberOfNodes; + return _numberOfNodes; } inline int CELLMODEL::getDimension() const { - return _dimension; + return _dimension; } inline medGeometryElement CELLMODEL::getType() const { - return _type; + return _type; } -inline vector< vector > CELLMODEL::getConstituents(int dim) const +inline int** CELLMODEL::getConstituents(int dim) const { return _constituents[dim-1] ; } inline int CELLMODEL::getNumberOfConstituents(int dim) const { - return _constituents[dim-1].size() ; + return _numberOfConstituents[dim-1] ; } -inline vector CELLMODEL::getNodesConstituent(int dim,int num) const +inline int* CELLMODEL::getNodesConstituent(int dim,int num) const { return _constituents[dim-1][num-1]; } -inline int CELLMODEL::getNodeConstituent(int dim,int num,int nodesNumber) +inline int CELLMODEL::getNodeConstituent(int dim,int num,int nodesNumber) const { return _constituents[dim-1][num-1][nodesNumber-1] ; } -inline vector CELLMODEL::getConstituentsType(int dim) const +inline medGeometryElement* CELLMODEL::getConstituentsType(int dim) const { return _constituentsType[dim-1]; } diff --git a/src/MEDMEM/MEDMEM_Connectivity.cxx b/src/MEDMEM/MEDMEM_Connectivity.cxx index 0bba6d277..72ac52e67 100644 --- a/src/MEDMEM/MEDMEM_Connectivity.cxx +++ b/src/MEDMEM/MEDMEM_Connectivity.cxx @@ -1,3 +1,30 @@ +// 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" #include "MEDMEM_CellModel.hxx" @@ -7,65 +34,251 @@ #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]; +} + +/*! + Copy Constructor. +*/ +//------------------------------------------------------// +CONNECTIVITY::CONNECTIVITY (const CONNECTIVITY & m): +//----------------------------------------------------// + _entity (m._entity), + _typeConnectivity (m._typeConnectivity), + _numberOfTypes (m._numberOfTypes), + _entityDimension (m._entityDimension), + _numberOfNodes (m._numberOfNodes) +{ + 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[_numberOfTypes]; + for (int i=0;i<_numberOfTypes;i++) + _type[i] = CELLMODEL(m._type[i]); + } + else + _type = (CELLMODEL *) NULL; + + 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) + _nodal = new MEDSKYLINEARRAY(* m._nodal); + else + _nodal = (MEDSKYLINEARRAY *) NULL; + + if (m._descending != NULL) + _descending = new MEDSKYLINEARRAY(* m._descending); + else + _descending = (MEDSKYLINEARRAY *) NULL; + + if (m._reverseNodalConnectivity != NULL) + _reverseNodalConnectivity = new MEDSKYLINEARRAY(* m._reverseNodalConnectivity); + else + _reverseNodalConnectivity = (MEDSKYLINEARRAY *) NULL; + + if (m._reverseDescendingConnectivity != NULL) + _reverseDescendingConnectivity = new MEDSKYLINEARRAY(* m._reverseDescendingConnectivity); + else + _reverseDescendingConnectivity = (MEDSKYLINEARRAY *) NULL; + + if (m._neighbourhood != NULL) + _neighbourhood = new MEDSKYLINEARRAY(* m._neighbourhood); + else + _neighbourhood = (MEDSKYLINEARRAY *) NULL; + + if (m._constituent != NULL) + _constituent = new CONNECTIVITY(* m._constituent); + 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 */ @@ -81,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); } } @@ -108,48 +321,51 @@ 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; } // 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(); - 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(); - 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 @@ -173,162 +389,224 @@ void CONNECTIVITY::updateFamily(vector myFamilies) int index1 = 0; int indexm1 = 0; + _constituent->calculateReverseNodalConnectivity(); + for (int iOldFace=0;iOldFacegetReverseNodalConnectivity(); + 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 NumberOfFacesInList=EndIndexFaceArrayFirstNode-BeginIndexFaceArrayFirstNode; + + int * FacesList = new int[NumberOfFacesInList]; + + for (int l=BeginIndexFaceArrayFirstNode; l1) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one face found ("< 2) - throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This face/edge should not be a (d-1) cell because it has "<_nodal because of reversity - int * oldArray = oldConstituentValue+face_it_beginOld-1; - int * newArray = newConstituentValue+face_it_beginNew-1; - for(int iarray=0;iarray 2) + 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 !!!! + + _reverseDescendingConnectivity->setIJ(FacesList[0],1,cell2); + // Updating _constituent->_nodal because of reversity + const int * oldArray = oldConstituentValue+face_it_beginOld-1; + for(int iarray=1;iarray<=face_size_itNew;iarray++){ + _constituent->_nodal->setIJ(FacesList[0],iarray,oldArray[iarray-1]); } + + // Updating _reverseDescendingConnectivity + + + _reverseDescendingConnectivity->setIJ(FacesList[0],2,cell1); + + // Updating _descending for cell1 and cell2 + for(int iface=newDescendingIndex[cell1-1];iface<=newDescendingIndex[cell1];iface++) + if (_descending->getIndexValue(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 "<getnumber()->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) - Connectivity=_nodal; + { + calculateNodalConnectivity(); + Connectivity=_nodal; + } else - Connectivity=_descending; + { + 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 @@ -340,13 +618,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) @@ -355,31 +633,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 . @@ -388,15 +666,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. @@ -406,11 +684,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 . @@ -423,14 +701,15 @@ 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) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_NONE")); + 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; for (med_int i=0; i<_numberOfTypes; i++) @@ -441,13 +720,13 @@ med_int CONNECTIVITY::getNumberOf(medEntityMesh Entity, medGeometryElement Type) if (_constituent != NULL) return _constituent->getNumberOf(Entity,Type); - return 0 ; // valid if they are nothing ! - //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) //--------------------------------------------------------------// { @@ -474,7 +753,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) @@ -491,7 +770,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"); @@ -500,7 +779,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(); @@ -510,7 +789,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(); @@ -521,31 +800,32 @@ 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 - if (_entity==MED_CELL) { - // we want descending connectivity - calculateDescendingConnectivity(); - return _reverseDescendingConnectivity->getValue(); - } - throw MEDEXCEPTION("CONNECTIVITY::getReverseDescendingConnectivity : Error Only in MED_CELL connectivity"); + // it is in _constituent connectivity only if we are in MED_CELL + // (we could not for instance calculate face-edge connectivity !) + if (_entity!=MED_CELL) + throw MEDEXCEPTION("CONNECTIVITY::getReverseDescendingConnectivity : Error Only in MED_CELL connectivity"); + + // we need descending connectivity + calculateDescendingConnectivity(); + return _reverseDescendingConnectivity->getValue(); } /*! 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 - if (_entity==MED_CELL) { - // we want descending connectivity - calculateDescendingConnectivity(); - return _reverseDescendingConnectivity->getIndex(); - } - throw MEDEXCEPTION("CONNECTIVITY::getReverseDescendingConnectivityIndex : Error Only in MED_CELL connectivity"); + if (_entity!=MED_CELL) + throw MEDEXCEPTION("CONNECTIVITY::getReverseDescendingConnectivityIndex : Error Only in MED_CELL connectivity"); + + // we need descending connectivity + calculateDescendingConnectivity(); + return _reverseDescendingConnectivity->getIndex(); } /*! A DOCUMENTER (et a finir ???) */ @@ -567,14 +847,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; @@ -590,9 +868,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); } } @@ -604,24 +882,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 */ @@ -645,49 +927,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++; @@ -757,10 +1044,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]; @@ -768,122 +1055,106 @@ 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 * CellsList = new int[NumberOfCellsInList] ; - for (int l=ReverseNodalConnectivityIndex_0; l 0) { // we could have no element ! + int * CellsList = new int[NumberOfCellsInList]; + for (int l=ReverseNodalConnectivityIndex_0; l1) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one other Cell ("<getIJ(CellNumber,Type2.getNodeConstituent(1,l,m)) == NodesLists[n-1]) - counter++ ; + delete [] CellsList; + CellsList = NewCellsList; + } + + if (NumberOfCellsInList > 0) { // We have found some elements ! + 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++; + } + 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; + } + if (find2) + break; } - 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 ; - } - if (find2) - break ; + if (!find2) + INFOS(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!"); // exception ? + } + } else { + ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0; } - if (!find2) - INFOS(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!") ; // exception ? - } else - 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 @@ -899,9 +1170,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); } @@ -939,7 +1235,7 @@ void CONNECTIVITY::calculateDescendingConnectivity() // if (myConnectivity->getEntity()!=MED_CELL) // throw MEDEXCEPTION("CONNECTIVITY::calculateReverseDescending // Connectivity : we need MED_CELL connectivity !"); -// return ; +// return; // } /*! Not implemented yet */ @@ -948,7 +1244,7 @@ void CONNECTIVITY::calculateNeighbourhood(CONNECTIVITY &myConnectivity) //--------------------------------------------------------------------// { // Mesh dimension ! - return ; + return; } @@ -956,7 +1252,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 @@ -965,11 +1261,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_Connectivity.hxx b/src/MEDMEM/MEDMEM_Connectivity.hxx index 003e4ca6b..9986a2350 100644 --- a/src/MEDMEM/MEDMEM_Connectivity.hxx +++ b/src/MEDMEM/MEDMEM_Connectivity.hxx @@ -1,3 +1,29 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_Connectivity.hxx +// Module : MED + #ifndef CONNECTIVITY_HXX #define CONNECTIVITY_HXX @@ -14,37 +40,38 @@ class CELLMODEL; class FAMILY; /*! - this class deals with all type of connectivity - this a recursive class in order to store - + This class deals with all type of connectivity ./n + it a recursive class. */ -class CONNECTIVITY // recursive class +/* ------------------------------------------- */ +class CONNECTIVITY +/* ------------------------------------------- */ { - /* - Class Attributs - */ + /* ---------------------- */ + /* Class Attributs */ + /* ---------------------- */ protected: /*! contains MED_CELL MED_FACE or MED_EDGE */ - medEntityMesh _entity ; + medEntityMesh _entity; /*! contains MED_NODAL or MED_DESCEND */ - medConnectivity _typeConnectivity ; + medConnectivity _typeConnectivity; /*! count of differents cells types used by the mesh */ - med_int _numberOfTypes ; + med_int _numberOfTypes; /*! array of all med_geometric_type used by MESH. */ - medGeometryElement* _geometricTypes ; + medGeometryElement* _geometricTypes; /*! map indexed by med_geometric_type which contains the different 'CellModel' used by MESH. */ - CELLMODEL * _type ; + CELLMODEL * _type; /*! contains the dimension of the entity */ - med_int _entityDimension ; + med_int _entityDimension; /*! needed by calculateReverseNodalConnectivity */ - med_int _numberOfNodes ; + med_int _numberOfNodes; /*! array of size _numberOfTypes+1 which gives for each cell type the first @@ -55,167 +82,273 @@ protected: ( 0 <= i < _numberOfTypes ). Note that _count[_numberOfTypes] returns total cells count + 1 */ - med_int * _count ; - - /*! pointer on an array which stores the nodal connectivity */ - MEDSKYLINEARRAY* _nodal ; - /*! pointer on an array which stores the descending connectivity */ - MEDSKYLINEARRAY* _descending ; - /*! pointer on an array which stores the resverse nodal connectivity */ - MEDSKYLINEARRAY* _reverseNodalConnectivity ; - /*! pointer on an array which stores the reverse descending connectivity */ - MEDSKYLINEARRAY* _reverseDescendingConnectivity ; + med_int * _count; + + /*! pointer to an array which stores the nodal connectivity */ + MEDSKYLINEARRAY* _nodal; + /*! pointer to an array which stores + the descending connectivity */ + MEDSKYLINEARRAY* _descending; + /*! pointer to an array which stores + the reverse nodal connectivity */ + MEDSKYLINEARRAY* _reverseNodalConnectivity; + /*! pointer to an array which stores + the reverse descending connectivity */ + MEDSKYLINEARRAY* _reverseDescendingConnectivity; /*! if face or edge, list of 2 cells or 2 faces it belongs to. If 2nd number equals 0, we have a boundary entity. We could use MEDSKYLINEARRAY, but we suppose we have always only 2 (or 1) entities. */ - MEDSKYLINEARRAY* _neighbourhood ; + MEDSKYLINEARRAY* _neighbourhood; /*! connectivity of sub cell if descendant connectivity is calculated */ - CONNECTIVITY * _constituent ; + CONNECTIVITY * _constituent; - /* - Class Methods - */ + /* -------------------- */ + /* Class Methods */ + /* -------------------- */ private: - /*! does nothing if already exists, else + /*! private method :/n + does nothing if already exists, else evaluates _nodal from _descending */ - void calculateNodalConnectivity() ; - /*! does nothing if already exists, else + void calculateNodalConnectivity(); + /*! private method :/n + does nothing if already exists, else evaluates from _nodal */ - void calculateReverseNodalConnectivity() ; - /*! does nothing if already exists, else + void calculateReverseNodalConnectivity(); + /*! private method :/n + does nothing if already exists, else evaluates _descending from _nodal */ - void calculateDescendingConnectivity() ; - /*! does nothing if already exists, else + void calculateDescendingConnectivity(); + /*! private method :/n + does nothing if already exists, else evaluates from _descending */ - // void calculateReverseDescendingConnectivity(CONNECTIVITY *myConnectivity) ; - /*! does nothing if already exists, else + // void calculateReverseDescendingConnectivity(CONNECTIVITY *myConnectivity); + + const med_int* getReverseNodalConnectivity (); + const med_int* getReverseNodalConnectivityIndex (); + const med_int* getReverseDescendingConnectivity (); + const med_int* getReverseDescendingConnectivityIndex (); + + /*! private method :/n + does nothing if already exists, else evaluates _neighbourhood from _descending */ - void calculateNeighbourhood(CONNECTIVITY &myConnectivity) ; + void calculateNeighbourhood(CONNECTIVITY &myConnectivity); public: friend class MED_MESH_RDONLY_DRIVER; friend class MED_MESH_WRONLY_DRIVER; - CONNECTIVITY(medEntityMesh Entity=MED_CELL); - CONNECTIVITY(int numberOfTypes, medEntityMesh Entity=MED_CELL); - ~CONNECTIVITY(); + // in order to fill CONNECTIVITY of MESH + friend class GRID; + + CONNECTIVITY (medEntityMesh Entity=MED_CELL); + CONNECTIVITY (int numberOfTypes, medEntityMesh Entity=MED_CELL); + CONNECTIVITY (const CONNECTIVITY & m); + ~CONNECTIVITY (); + + void setConstituent (CONNECTIVITY * Constituent) + throw (MEDEXCEPTION); + + void setGeometricTypes (const medGeometryElement * Types, + const medEntityMesh Entity) + throw (MEDEXCEPTION); - inline bool existConnectivity (medConnectivity connectivityType, medEntityMesh Entity) const ; - void calculateConnectivity (medConnectivity connectivityType, medEntityMesh Entity) ; - void updateFamily(vector myFamilies) ; + void setCount (const int * Count, const medEntityMesh Entity) + throw (MEDEXCEPTION); - inline medEntityMesh getEntity () const; - inline med_int getNumberOfTypes (medEntityMesh Entity) const; - inline medGeometryElement * getGeometricTypes (medEntityMesh Entity) const; - medGeometryElement getElementType(medEntityMesh Entity,int Number) const ; - inline int * getGlobalNumberingIndex (medEntityMesh Entity) const ; + void setNodal (const int * Connectivity, + const medEntityMesh Entity, + const medGeometryElement Type) + throw (MEDEXCEPTION); - med_int * getConnectivity (medConnectivity ConnectivityType, medEntityMesh Entity, - medGeometryElement Type) ; - med_int * getConnectivityIndex (medConnectivity ConnectivityType,medEntityMesh Entity) ; + inline bool existConnectivity (medConnectivity connectivityType, medEntityMesh Entity) const; + + void calculateConnectivity (medConnectivity connectivityType, medEntityMesh Entity); + + void updateFamily (vector myFamilies); + + inline medEntityMesh getEntity () const; + inline med_int getNumberOfTypes (medEntityMesh Entity) const; + inline const medGeometryElement * getGeometricTypes (medEntityMesh Entity) const + throw (MEDEXCEPTION); + medGeometryElement getElementType (medEntityMesh Entity, + int Number) const; + inline const int * getGlobalNumberingIndex (medEntityMesh Entity) const + throw (MEDEXCEPTION); + + const med_int * getConnectivity (medConnectivity ConnectivityType, + medEntityMesh Entity, + medGeometryElement Type); + const med_int * getConnectivityIndex (medConnectivity ConnectivityType, + medEntityMesh Entity); - CELLMODEL & getType (medGeometryElement Type) const; - CELLMODEL * getCellsTypes (medEntityMesh Entity) const; + const CELLMODEL & getType (medGeometryElement Type) const; + const CELLMODEL * getCellsTypes (medEntityMesh Entity) const + throw (MEDEXCEPTION); - med_int getNumberOfNodesInType (medGeometryElement Type) const; - med_int getNumberOfSubCellInType (medGeometryElement Type) const; - med_int getNumberOf (medEntityMesh Entity, medGeometryElement Type) const; - med_int* getValue (medConnectivity TypeConnectivity, medGeometryElement Type) ; - med_int* getValueIndex (medConnectivity TypeConnectivity) ; - med_int* getReverseNodalConnectivity () ; - med_int* getReverseNodalConnectivityIndex () ; - med_int* getReverseDescendingConnectivity () ; - med_int* getReverseDescendingConnectivityIndex () ; - med_int* getNeighbourhood() const; - -} ; + med_int getNumberOfNodesInType (medGeometryElement Type) const; + med_int getNumberOfSubCellInType (medGeometryElement Type) const; + med_int getNumberOf (medEntityMesh Entity, + medGeometryElement Type) const; + const med_int* getValue (medConnectivity TypeConnectivity, + medGeometryElement Type); + const med_int* getValueIndex (medConnectivity TypeConnectivity); + + inline const med_int* getReverseConnectivity (medConnectivity ConnectivityType, + medEntityMesh Entity=MED_CELL) + throw (MEDEXCEPTION); + inline const med_int* getReverseConnectivityIndex (medConnectivity ConnectivityType, + medEntityMesh Entity=MED_CELL) + throw (MEDEXCEPTION); + + const med_int* getNeighbourhood() const; + +}; /*----------------------*/ /* Methodes Inline */ /*----------------------*/ /*! Returns the medEntityMesh */ +//--------------------------------------------------// inline medEntityMesh CONNECTIVITY::getEntity() const +//--------------------------------------------------// { - return _entity; + return _entity; } -/*! Returns the number of different types existing in the specified entity. - +/*! Returns the number of different types + existing in the specified entity. /n Note : Not implemented for MED_ALL_ENTITIES. */ +//-----------------------------------------------------------------------// inline med_int CONNECTIVITY::getNumberOfTypes(medEntityMesh Entity) const +//-----------------------------------------------------------------------// { MESSAGE("CONNECTIVITY::getNumberOfTypes : Entity = "< types existing in the mesh for the given medEntityMesh. - - Note : Not implemented for MED_ALL_ENTITIES. */ -inline medGeometryElement* CONNECTIVITY::getGeometricTypes(medEntityMesh Entity) const +/*! Returns an array of all types existing in the mesh + for the given medEntityMesh./n + Note : Not implemented for MED_ALL_ENTITIES. /n + Throws an exception if Entity is unknown */ +//------------------------------------------------------------------------------------------// +inline const medGeometryElement* CONNECTIVITY::getGeometricTypes(medEntityMesh Entity) const + throw (MEDEXCEPTION) +//------------------------------------------------------------------------------------------// { if (_entity==Entity) - return _geometricTypes; + return _geometricTypes; else if (_constituent!=NULL) - return _constituent->getGeometricTypes(Entity) ; + return _constituent->getGeometricTypes(Entity); else - throw MEDEXCEPTION("Entity not defined !") ; + throw MEDEXCEPTION("Entity not defined !"); } /*! A DOCUMENTER */ -inline int * CONNECTIVITY::getGlobalNumberingIndex(medEntityMesh Entity) const +//----------------------------------------------------------------------------------// +inline const int * CONNECTIVITY::getGlobalNumberingIndex(medEntityMesh Entity) const + throw (MEDEXCEPTION) +//----------------------------------------------------------------------------------// { if (_entity==Entity) - return _count; + return _count; else if (_constituent!=NULL) - return _constituent->getGlobalNumberingIndex(Entity) ; + return _constituent->getGlobalNumberingIndex(Entity); else - throw MEDEXCEPTION("Entity not defined !") ; + throw MEDEXCEPTION("Entity not defined !"); } /*! Returns true if a connectivity exists on elements of type "Entity" */ -inline bool CONNECTIVITY::existConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity) const +//-----------------------------------------------------------------------------// +inline bool CONNECTIVITY::existConnectivity( medConnectivity ConnectivityType, + medEntityMesh Entity) const +//-----------------------------------------------------------------------------// { if (_entity==Entity) { MESSAGE("existConnectivity : _entity==Entity="<existConnectivity(ConnectivityType,Entity) ; - return false ; + return _constituent->existConnectivity(ConnectivityType,Entity); + return false; } /*! -Return an array which contain CELLMODEL foreach element type present in connectivity for given medEntityMesh (similar as getGeometricTypes) - +Returns an array containing CELLMODEL foreach element type present +in connectivity for given medEntityMesh (similar as getGeometricTypes)./n Throw an execption if the given entity is not defined or if the array is not defined. */ -inline CELLMODEL * CONNECTIVITY::getCellsTypes(medEntityMesh Entity) const +//-----------------------------------------------------------------------------// +inline const CELLMODEL * CONNECTIVITY::getCellsTypes(medEntityMesh Entity) const + throw (MEDEXCEPTION) +//-----------------------------------------------------------------------------// { if (Entity == _entity) if (_type!=NULL) - return _type ; + return _type; else - throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) : CELLMODEL array is not defined !"); + throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) : + CELLMODEL array is not defined !"); else if (_constituent != NULL) - return _constituent->getCellsTypes(Entity) ; + return _constituent->getCellsTypes(Entity); else throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) : Not found Entity !"); } +/*! A DOCUMENTER */ +//------------------------------------------------------------------------------------------// +inline const med_int* CONNECTIVITY::getReverseConnectivity( medConnectivity ConnectivityType, + medEntityMesh Entity) + throw (MEDEXCEPTION) +//------------------------------------------------------------------------------------------// +{ + if(_entity==Entity) + if (ConnectivityType==MED_NODAL) + return getReverseNodalConnectivity(); + else if (ConnectivityType==MED_DESCENDING) + return getReverseDescendingConnectivity(); + else + throw MEDEXCEPTION("MESH::getReverseConnectivity : connectivity mode not supported !"); + + // other entity : + if (NULL==_constituent) + calculateDescendingConnectivity(); + return _constituent->getReverseConnectivity(ConnectivityType,Entity); +} + +/*! A DOCUMENTER */ +//-----------------------------------------------------------------------------------------------// +inline const med_int* CONNECTIVITY::getReverseConnectivityIndex(medConnectivity ConnectivityType, + medEntityMesh Entity) + throw (MEDEXCEPTION) +//-----------------------------------------------------------------------------------------------// +{ + if(_entity==Entity) + if (ConnectivityType==MED_NODAL) + return getReverseNodalConnectivityIndex(); + else if (ConnectivityType==MED_DESCENDING) + return getReverseDescendingConnectivityIndex(); + else + throw MEDEXCEPTION("MESH::getReverseConnectivityIndex : connectivity mode not supported !"); + + // other entity : + if (NULL==_constituent) + calculateDescendingConnectivity(); + return _constituent->getReverseConnectivityIndex(ConnectivityType,Entity); +} + #endif /* CONNECTIVITY_HXX */ diff --git a/src/MEDMEM/MEDMEM_Coordinate.cxx b/src/MEDMEM/MEDMEM_Coordinate.cxx index 8a5975d6b..686c618bc 100644 --- a/src/MEDMEM/MEDMEM_Coordinate.cxx +++ b/src/MEDMEM/MEDMEM_Coordinate.cxx @@ -1,88 +1,225 @@ +// 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.cxx +// Module : MED + +using namespace std; #include "MEDMEM_Coordinate.hxx" +#include "MEDMEM_Exception.hxx" +#include "MEDMEM_STRING.hxx" + #include "utilities.h" -/*! This class contains coordinates of the nodes */ +/*! Default Constructor : should not be used */ //----------------------------------------------------------// -COORDINATE::COORDINATE():_coordinate((MEDARRAY*)NULL), - _coordinateName((string*)NULL), - _coordinateUnit((string*)NULL), - _nodeNumber((int*)NULL) +COORDINATE::COORDINATE():_coordinate(MEDARRAY()), + _coordinateName(), + _coordinateUnit(), + _coordinateSystem(""), + _nodeNumber() //----------------------------------------------------------// { BEGIN_OF("Default Constructor COORDINATE"); } +/*! This constructor allocate a MEDARRAY of SpaceDimension * NumberOfNodes./n + It will create empty array for optional data (nodeNumber..) */ //------------------------------------------------------------------------------// -COORDINATE::COORDINATE(medModeSwitch Mode,int SpaceDimension, int NumberOfNodes): - _nodeNumber((int*)NULL) +COORDINATE::COORDINATE(int SpaceDimension, int NumberOfNodes, medModeSwitch Mode): + _nodeNumber(), + _coordinateUnit(SpaceDimension), + _coordinateSystem(""), + _coordinateName(SpaceDimension), + _coordinate(SpaceDimension,NumberOfNodes,Mode) + //------------------------------------------------------------------------------// { BEGIN_OF("Constructor COORDINATE"); - _coordinateName = new string[SpaceDimension] ; - _coordinateUnit = new string[SpaceDimension] ; - _coordinate = new MEDARRAY(SpaceDimension,NumberOfNodes,Mode); } + +/*! This constructor will COPY all data (it is a deep copy) included in m./n + But only the default storage mode of coordinates array + will be copied (not both storage representation modes even if they both + exist in original object) : for example only full_interlace mode */ +//------------------------------------------------------------------------------// +COORDINATE::COORDINATE(const COORDINATE & m): + _coordinateSystem(m._coordinateSystem), + _coordinate(m._coordinate,false) +//------------------------------------------------------------------------------// +{ + BEGIN_OF("Copy Constructor COORDINATE"); + + int spaceDimension = _coordinate.getLeadingValue(); + int numberOfNodes = _coordinate.getLengthValue(); + + SCRUTE(spaceDimension); + setCoordinatesNames((const string*)m._coordinateName) ; + setCoordinatesUnits((const string*)m._coordinateUnit) ; + + if ( (const int * const) m._nodeNumber != NULL) + _nodeNumber.set(numberOfNodes,(const med_int*)m._nodeNumber); + // PG : it's default no ? +// else +// { +// _nodeNumber.set(0); +// } +} + + +/* does nothing : all attributs are object (not pointers) */ //----------------------// COORDINATE::~COORDINATE() //----------------------// { - MESSAGE("Debut Destructeur COORDINATE"); - if (_coordinate!=NULL) - delete _coordinate ; - if (_coordinateName!=NULL) - delete[] _coordinateName ; - if (_coordinateUnit!=NULL) - delete[] _coordinateUnit ; - if (_nodeNumber!=NULL) - delete[] _nodeNumber ; - } + MESSAGE("~COORDINATE()"); +} -/*! set the attribute _coordinate with Coordinate */ +/*! sets the attribute _coordinate with Coordinate */ //----------------------------------------------------------// void COORDINATE::setCoordinates(MEDARRAY *Coordinate) //----------------------------------------------------------// { - _coordinate=Coordinate ; + + const medModeSwitch mode = Coordinate->getMode(); + const int spaceDimension = (int) Coordinate->getLeadingValue(); + const int numberOfNodes = (int) Coordinate->getLengthValue(); + if ( Coordinate->get(mode) != NULL) + { + MEDARRAY pourAttribut(*Coordinate,false); + _coordinate = pourAttribut; + //_coordinate.set(mode,Coordinate->get(mode)); + } + else + { + throw MED_EXCEPTION ( LOCALIZED(STRING("setCoordinates(MEDARRAY + *Coordinate)") << "No Coordinate")); + } } -/*! set the attribute _coordinateName with CoordinateName */ +/*! + Sets the value in attribute _coordinate with Coordinate. + _coordinate must be allocated (with + COORDINATE::COORDINATE(int,int,medModeSwitch). +*/ //----------------------------------------------------------// -void COORDINATE::setCoordinatesNames(string * CoordinateName) +void COORDINATE::setCoordinates(const medModeSwitch Mode, + const double *Coordinate) //----------------------------------------------------------// -{ - _coordinateName=CoordinateName ; +{ +// if (_coordinate == NULL) +// throw MEDEXCEPTION("COORDINATE::setCoordinates(double*) : coordinate array not allocated !"); + + _coordinate.set(Mode,Coordinate); +} + +/*! sets the attribute _coordinateName with CoordinateName */ +//----------------------------------------------------------// +void COORDINATE::setCoordinatesNames(const string * CoordinateName) +//----------------------------------------------------------// +{ + int SpaceDimension = getSpaceDimension() ; + _coordinateName.set(SpaceDimension) ; + for (int i=0; iget(Mode) ; + return _coordinate.get(Mode) ; } /* returns the coordinate of node Number on axis Axis */ @@ -90,53 +227,53 @@ const double * COORDINATE::getCoordinates (medModeSwitch Mode) double COORDINATE::getCoordinate(int Number,int Axis) //----------------------------------------------------// { - return _coordinate->getIJ(Number,Axis) ; + return _coordinate.getIJ(Number,Axis) ; } /* returns all nodes coordinates from axis Axis */ //----------------------------------------------------// -const double * COORDINATE::getCoordinateAxis(int Axis) +const double * COORDINATE::getCoordinateAxis(int Axis) //----------------------------------------------------// { //< return all nodes coordinates from axis Axis - return _coordinate->getI(MED_NO_INTERLACE,Axis) ; + return _coordinate.getColumn(Axis) ; } -/*! Returns an array with names of coordinates. - Example : - - x,y,z - - r,teta,phi +/*! returns an array with names of coordinates. /n + Example : /n + - x,y,z /n + - r,teta,phi /n - ... */ //--------------------------------------// -string * COORDINATE::getCoordinatesNames() +const string * COORDINATE::getCoordinatesNames() const { return _coordinateName ; } /* returns the name of axis Axis */ //-------------------------------------------// -string COORDINATE::getCoordinateName(int Axis) +string COORDINATE::getCoordinateName(int Axis) const //-------------------------------------------// { return _coordinateName[Axis-1]; } -/*! Returns an array with units of coordinates (cm, m, mm, ...) +/*! returns an array with units of coordinates (cm, m, mm, ...) It could be empty. We suppose we are IS (meter). */ //-----------------------------------------------------// -string * COORDINATE::getCoordinatesUnits() +const string * COORDINATE::getCoordinatesUnits() const //-----------------------------------------------------// { return _coordinateUnit ; } -/*! Returns the unit of axis Axis */ +/*! returns the unit of axis Axis */ //------------------------------------------// -string COORDINATE::getCoordinateUnit(int Axis) +string COORDINATE::getCoordinateUnit(int Axis) const //------------------------------------------// { return _coordinateUnit[Axis-1] ; } -/*! Returns "CARTESIAN", "CYLINDRICAL" or "SPHERICAL"*/ +/*! returns "CARTESIAN", "CYLINDRICAL" or "SPHERICAL"*/ //---------------------------------------------------// string COORDINATE::getCoordinatesSystem() const //---------------------------------------------------// diff --git a/src/MEDMEM/MEDMEM_Coordinate.hxx b/src/MEDMEM/MEDMEM_Coordinate.hxx index c2f1fd916..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$ @@ -8,32 +34,49 @@ #include +#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; + + + /*! _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 + + Storing the object (not a pointer to this object) is more convenient for memory + management. + */ + MEDARRAY _coordinate; - // all in _coordinate object !!! - // int _spaceDimension; - // int _numberOfNodes; + /*! PointerOf to an array of size spaceDimension storing axes names*/ + PointerOf _coordinateName; + + /*! PointerOf to an array of size spaceDimension storing units */ + PointerOf _coordinateUnit; + + /*! PointerOf to an array of size NumberOfNodes : optional nodes numbers */ + PointerOf _nodeNumber; - /*! array of size spaceDimension*NumberOfNodes */ - MEDARRAY* _coordinate; - /*! array of size spaceDimension */ - string * _coordinateName; - /*! array of size spaceDimension */ - string * _coordinateUnit; - /*! array of size NumberOfNodes : optionnal nodes numbers */ - int * _nodeNumber; public : @@ -42,25 +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 setNodesNumbers(int * NodeNumber); - - int* getNodesNumbers() const; + 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 6e3aa4efd..9ca1920f2 100644 --- a/src/MEDMEM/MEDMEM_DriversDef.cxx +++ b/src/MEDMEM/MEDMEM_DriversDef.cxx @@ -1,10 +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" ; @@ -37,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_DriversDef.hxx b/src/MEDMEM/MEDMEM_DriversDef.hxx index 5e66d94bd..873bb8689 100644 --- a/src/MEDMEM/MEDMEM_DriversDef.hxx +++ b/src/MEDMEM/MEDMEM_DriversDef.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_DriversDef.hxx +// Module : MED + # ifndef DRIVERS_DEF_HXX # define DRIVERS_DEF_HXX @@ -9,36 +35,66 @@ using namespace std ; #include "MEDMEM_define.hxx" -namespace MED_FR { +namespace MED_FR +{ -// Returns the (string) name of the geometry of -// an element given by a med_geometrie_element value +/*! This Class inherits from map. /n + It is a constant map association int (which is a med_geometrie_element) and string. /n + Operator [] returns the (string) name of the geometry of an element + given by a med_geometrie_element value. /n + Such a static map is instancied and can be used in any code to have + the name of the geometry of an element : MED_FR:GEO_NAME + A simple test/use case can be found in test/testUGeoNameMeshEntities.cxx */ +//---------------------------------------- class GEO_NAME : public map +//---------------------------------------- { public : - GEO_NAME (); - + GEO_NAME(); string & operator[]( const MED_FR::med_geometrie_element &c ) const; } ; - static const GEO_NAME geoNames ; + +// ____________________________ -// Returns the (string) name of the type of -// an entity given by a med_entite_maillage value +/*! This Class inherits from map. /n + It is a constant map association int (which is a med_entite_maillage) and string. /n + Operator[] returns the (string) name of the type of an entity given by + a med_entite_maillage value. /n + Such a static map is instancied and can be used in any code to have + the name of the geometry of an element : MED_FR:ENT_NAME + A simple test/use case can be found in test/testUGeoNameMeshEntities.cxx */ + +//---------------------------------------- class ENT_NAME : public map +//---------------------------------------- { public : + ENT_NAME (); string & operator[]( const MED_FR::med_entite_maillage &c ) const; } ; static const ENT_NAME entNames ; +// ____________________________ + +/*! This Class inherits from map. /n + It is a constant map association int (which is a med_entite_maillage) and a list. /n + Operator[] returns the list of all exisiting med_geometrie_element for + a med_entite_maillage value. /n + Such a static map is instancied and can be used in any code to have + the name of the geometry of an element : MED_FR:MESH_ENTITIES + A simple test/use case can be found in test/testUGeoNameMeshEntities.cxx */ + + +//-------------------------------------------------------------------------------- class MESH_ENTITIES : public map > +//-------------------------------------------------------------------------------- { public : @@ -47,7 +103,8 @@ public : const list & operator[]( const MED_FR::med_entite_maillage &c ) const; private: - // This operator is used to initialize class objects of type const list + /*! This operator is used to initialize class objects of + type const list */ list & operator[]( const MED_FR::med_entite_maillage &c ); } ; diff --git a/src/MEDMEM/MEDMEM_Exception.cxx b/src/MEDMEM/MEDMEM_Exception.cxx index b43b726a3..915f4fc75 100644 --- a/src/MEDMEM/MEDMEM_Exception.cxx +++ b/src/MEDMEM/MEDMEM_Exception.cxx @@ -1,3 +1,30 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_Exception.cxx +// Module : MED + +using namespace std; /* File MedException.cxx $Header$ @@ -16,8 +43,11 @@ extern "C" } +/*! + \internal + Function used to duplicate char * +*/ const char* duplicate( const char *const str ) ; - const char* duplicate( const char *const str ) { ASSERT(str!=NULL) ; @@ -29,52 +59,78 @@ const char* duplicate( const char *const str ) return new_str ; } +/*! + \internal Default Constructor (Should not be used) +*/ +// ------------------------------------------------------ // MEDEXCEPTION::MEDEXCEPTION( void ): exception() , _text(0) +// ------------------------------------------------------ // { MESSAGE( "You must user the standard builder : MEDEXCEPTION::MEDEXCEPTION( const char *text )" ) ; INTERRUPTION(1) ; } +/*! + \internal + Function used to elaborate the text of the MEDEXCEPTION +*/ +// --------------------------------------------------------------------------------------- // const char *makeText( const char *text, const char *fileName, const unsigned int lineNumber ) +// --------------------------------------------------------------------------------------- // { char *newText = 0 ; ASSERT(text) ; - const size_t l1 = 1+strlen(text) ; - ASSERT(l1>1) ; + const size_t l1 = strlen(text) ; const char* prefix = "MED Exception" ; - const size_t l0 = 2+strlen(prefix) ; + const size_t l0 = strlen(prefix) ; if ( fileName ) - { - const size_t l2 = 4+strlen(fileName) ; - ASSERT(l2>4) ; + { + const size_t l2 = strlen(fileName) ; ASSERT(lineNumber>=1) ; - const size_t l3 = 4+int(log10(float(lineNumber))) ; - - newText = new char [ 1+l0+l1+l2+l3 ] ; + const size_t l3 = 1+int(log10(float(lineNumber))) ; + + const size_t l4 = l0+l1+l2+l3+10+1 ; + newText = new char [ l4 ] ; sprintf( newText , "%s in %s [%u] : %s" , prefix, fileName, lineNumber, text ) ; - } + ASSERT(newText[l4-1] == '\0' ); + + } else - { - newText = new char [ 1+l0+l1 ] ; + { + newText = new char [ l0+l1+3+1 ] ; sprintf( newText , "%s : %s" , prefix, text ) ; - } + } ASSERT(newText) ; return newText ; } - -MEDEXCEPTION::MEDEXCEPTION( const char *text, const char *fileName, const unsigned int lineNumber ) : exception(), _text( makeText( text , fileName , lineNumber ) ) +/*! + Constructor : \n + It will create the text of the MEDEXCEPTION from the different parameters. + It will take the form : \n + MEDEXCEPTION, fileName, lineNumber and text of the exception +*/ +// ------------------------------------------------------------------------------------------------ // +MEDEXCEPTION::MEDEXCEPTION( const char *text, const char *fileName, const unsigned int lineNumber ) : + exception(), _text( makeText( text , fileName , lineNumber ) ) +// ------------------------------------------------------------------------------------------------ // { MESSAGE(_text); } +/*! + Destructor : \n + If necessary desallocates Memory +*/ +// ------------------------------------// MEDEXCEPTION::~MEDEXCEPTION() throw () +// ------------------------------------// { if ( _text ) { @@ -86,22 +142,33 @@ MEDEXCEPTION::~MEDEXCEPTION() throw () } - +/*! + Copy Constructor : \n + Should not be used very often +*/ +// ----------------------------------------------------------------------- // MEDEXCEPTION::MEDEXCEPTION( const MEDEXCEPTION &ex ): _text(duplicate(ex._text)) +// ----------------------------------------------------------------------- // { ; } - - +/*! + Operator << : put the message to the given stream. +*/ +// ------------------------------------------------------- // ostream & operator<<( ostream &os , const MEDEXCEPTION &ex ) +// ------------------------------------------------------- // { os << ex._text ; return os ; } - - +/*! + Return a char * which contain the message. +*/ +// ------------------------------------------------- // const char* MEDEXCEPTION::what( void ) const throw () +// ------------------------------------------------- // { return _text ; } @@ -115,8 +182,8 @@ MED_DRIVER_NOT_FOUND_EXCEPTION::MED_DRIVER_NOT_FOUND_EXCEPTION(const MED_DRIVER_ MED_DRIVER_NOT_FOUND_EXCEPTION::MED_DRIVER_NOT_FOUND_EXCEPTION ( - const char *text, const char *fileName=0, - const unsigned int lineNumber=0 + const char *text, const char *fileName/*=0*/, + const unsigned int lineNumber/*=0*/ ) : MEDEXCEPTION(text, fileName, lineNumber) {}; MED_DRIVER_NOT_FOUND_EXCEPTION::~MED_DRIVER_NOT_FOUND_EXCEPTION() throw (){}; diff --git a/src/MEDMEM/MEDMEM_Exception.hxx b/src/MEDMEM/MEDMEM_Exception.hxx index 9b5bc55d8..aa4245f61 100644 --- a/src/MEDMEM/MEDMEM_Exception.hxx +++ b/src/MEDMEM/MEDMEM_Exception.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_Exception.hxx +// Module : MED + /* File MedException.hxx $Header$ @@ -16,7 +42,14 @@ using namespace std; #endif #define MED_EXCEPTION MEDEXCEPTION -class MEDEXCEPTION : public exception + +/*! + Class used to throws exception.\n + Inherits from public exception. +*/ +//--------------------------------------// + class MEDEXCEPTION : public exception +//--------------------------------------// { private : MEDEXCEPTION(void); @@ -34,7 +67,9 @@ public : } ; +//---------------------------------------------------------// class MED_DRIVER_NOT_FOUND_EXCEPTION : public MEDEXCEPTION +//---------------------------------------------------------// { private : MED_DRIVER_NOT_FOUND_EXCEPTION(void); diff --git a/src/MEDMEM/MEDMEM_Family.cxx b/src/MEDMEM/MEDMEM_Family.cxx index 9264613a8..d85fa5ec5 100644 --- a/src/MEDMEM/MEDMEM_Family.cxx +++ b/src/MEDMEM/MEDMEM_Family.cxx @@ -1,3 +1,30 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_Family.cxx +// Module : MED + +using namespace std; /* File MEDMEM_Family.cxx $Header$ @@ -15,16 +42,25 @@ FAMILY::FAMILY():_identifier(0), _numberOfAttribute(0), FAMILY::FAMILY(MESH* Mesh, int Identifier, string Name, int NumberOfAttribute, int *AttributeIdentifier, int *AttributeValue, string AttributeDescription, - int NumberOfGroup, string GroupName + int NumberOfGroup, string GroupName, + int * MEDArrayNodeFamily, + int ** MEDArrayCellFamily, + int ** MEDArrayFaceFamily, + int ** MEDArrayEdgeFamily ): SUPPORT(Mesh,Name), _identifier(Identifier), _numberOfAttribute(NumberOfAttribute), - _attributeIdentifier(AttributeIdentifier), - _attributeValue(AttributeValue), _numberOfGroup(NumberOfGroup) { MESSAGE("FAMILY(int Identifier, string Name, int NumberOfAttribute,int *AttributeIdentifier,int *AttributeValue,string AttributeDescription,int NumberOfGroup,string GroupName, int ** Number) : "< of node numbers belonging to the family <_identifier> int NumberOfNodes = _mesh->getNumberOfNodes(); int NumberOfNodesInFamily = 0 ; - int * NodeFamilyNumber = _mesh->getMEDArrayNodeFamily() ; // EF : TEMPORAIRE !! + //int * NodeFamilyNumber = _mesh->getMEDArrayNodeFamily() ; // EF : TEMPORAIRE !! int * tmp_NodesList = new int[NumberOfNodes] ; // Un peu brutal...., oui mais ce n'est qu'un tableau de travail ! for (int i=0; i0) { Find = true ; _entity = MED_NODE ; - _numberOfGeometricType = 1 ; - _geometricType = new medGeometryElement[1] ; - _geometricType[0]=MED_NONE ; +// _numberOfGeometricType = 1 ; +// _geometricType = new medGeometryElement[1] ; +// _geometricType[0]=MED_NONE ; // family on all NODE - if (NumberOfNodesInFamily==NumberOfNodes) + if (NumberOfNodesInFamily==NumberOfNodes) { _isOnAllElts = true ; - else { + update(); + } else { + _numberOfGeometricType = 1 ; + if (_geometricType!=NULL) delete[] _geometricType ; + _geometricType = new medGeometryElement[1] ; + _geometricType[0]=MED_NONE ; _isOnAllElts= false ; - _numberOfEntities = new int[1] ; - _numberOfEntities[0]=NumberOfNodesInFamily ; - _totalNumberOfEntities=NumberOfNodesInFamily; + if (_numberOfElements!=NULL) delete[] _numberOfElements ; + _numberOfElements = new int[1] ; + _numberOfElements[0]=NumberOfNodesInFamily ; + _totalNumberOfElements=NumberOfNodesInFamily; - _number=new MEDSKYLINEARRAY(1,NumberOfNodesInFamily) ; - int * NumberIndex = _number->getIndex(); - int * NumberValue = _number->getValue(); +// _number=new MEDSKYLINEARRAY(1,NumberOfNodesInFamily) ; +// int * NumberIndex = _number->getIndex(); +// int * NumberValue = _number->getValue(); + int * NumberIndex = new int[2]; + int * NumberValue = new int[NumberOfNodesInFamily]; + NumberIndex[0]=1; //set the MEDSKYLINEARRAY Index table NumberIndex[1]=1+NumberOfNodesInFamily; //set the MEDSKYLINEARRAY Index table for(int i=0; i in order to create // ?? the list of node numbers belonging to the family <_identifier> if (!Find) { - - // Get cell types information from <_mesh> - int numberOfCellTypes = _mesh->getNumberOfTypes(MED_CELL) ; - medGeometryElement * cellTypes = _mesh->getTypes(MED_CELL) ; - - int * numberOfCellsInFamily = new int[numberOfCellTypes] ; - int numberOfCellTypesInFamily = 0 ; - - medGeometryElement * tmp_CellsTypes = new medGeometryElement[numberOfCellTypes]; - int ** tmp_CellsLists = new int*[numberOfCellTypes] ; - int * GeometricTypeNumber = new int[numberOfCellTypes] ; - int ** CellFamilyNumber = _mesh->getMEDArrayCellFamily(); // EF: TEMPORAIRE - int * GlobalNumberingIndex = _mesh->getGlobalNumberingIndex(MED_CELL); - - // we search for all cell in this family - for (int cellTypeNumber=0; cellTypeNumber < numberOfCellTypes; cellTypeNumber++) { - - int NumberOfCells = _mesh->getNumberOfElements(MED_CELL,cellTypes[cellTypeNumber]) ; - int NumberOfCellsInThisFamily = 0 ; - int * CellsOfThisFamilyNumber = CellFamilyNumber[cellTypeNumber]; - int * tmp_CellsList = new int[NumberOfCells]; - - for (int i=0; i0) {// we have found some cells - numberOfCellsInFamily[numberOfCellTypesInFamily]=NumberOfCellsInThisFamily; - int * CellsList=new int[NumberOfCellsInThisFamily] ; - - for (int i=0;i0) { // we have found cells - Find = true ; - _entity = MED_CELL ; - _numberOfGeometricType = numberOfCellTypesInFamily ; - _geometricType = new medGeometryElement[numberOfCellTypesInFamily] ; - _geometricTypeNumber = new int[numberOfCellTypesInFamily] ; - _isOnAllElts = false ; - _numberOfEntities = new int[numberOfCellTypesInFamily] ; - _totalNumberOfEntities=0; - for (int i=0; igetNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)) { - _isOnAllElts = true ; - delete[] _numberOfEntities ; - _numberOfEntities=(int*)NULL; - } else { - _number=new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities); - int *NumberValue=_number->getValue(); - int *NumberIndex=_number->getIndex(); - NumberIndex[0]=1; - for (int i=0; i<_numberOfGeometricType; i++) { - NumberIndex[i+1]=NumberIndex[i]+_numberOfEntities[i]; - for (int j=NumberIndex[i]; jexistConnectivity(MED_NODAL,MED_FACE))|(_mesh->existConnectivity(MED_DESCENDING,MED_FACE))) { - int NumberOfFacesType = _mesh->getNumberOfTypes(MED_FACE) ; - medGeometryElement * FacesType = _mesh->getTypes(MED_FACE) ; - int * NumberOfFacesInFamily = new int[NumberOfFacesType] ; - int NumberOfFacesTypeInFamily = 0 ; - medGeometryElement * tmp_FacesTypes = new medGeometryElement[NumberOfFacesType]; - int ** tmp_FacesLists = new int*[NumberOfFacesType] ; - int * GeometricTypeNumber = new int[NumberOfFacesType] ; - int ** FaceFamilyNumber = _mesh->getMEDArrayFaceFamily(); - int * GlobalNumberingIndex = _mesh->getGlobalNumberingIndex(MED_FACE); - // we search all face in this family - for (int FaceTypeNumber=0; FaceTypeNumbergetNumberOfElements(MED_FACE,FacesType[FaceTypeNumber]) ; - int NumberOfFacesInThisFamily = 0 ; - int * FaceOfThisFamilyNumber = FaceFamilyNumber[FaceTypeNumber]; - int * tmp_FacesList = new int[NumberOfThisFaces]; - for (int i=0; i0) {// we have found some faces - NumberOfFacesInFamily[NumberOfFacesTypeInFamily]=NumberOfFacesInThisFamily; - int * FacesList=new int[NumberOfFacesInThisFamily] ; - for (int i=0;i0) { // we have found faces - Find = true ; - _entity = MED_FACE ; - _numberOfGeometricType = NumberOfFacesTypeInFamily ; - _geometricType = new medGeometryElement[NumberOfFacesTypeInFamily] ; - _geometricTypeNumber = new int[NumberOfFacesTypeInFamily] ; - _isOnAllElts = false ; - _numberOfEntities = new int[NumberOfFacesTypeInFamily] ; - _totalNumberOfEntities=0; - for (int i=0; igetNumberOfElements(MED_FACE,MED_ALL_ELEMENTS)) { -// _isOnAllElts = true ; -// delete[] _numberOfEntities ; -// _numberOfEntities=(int*)NULL; -// } else { - _number=new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities); - int *NumberValue=_number->getValue(); - int *NumberIndex=_number->getIndex(); - NumberIndex[0]=1; - for (int i=0; i<_numberOfGeometricType; i++) { - NumberIndex[i+1]=NumberIndex[i]+_numberOfEntities[i]; - for (int j=NumberIndex[i]; jexistConnectivity(MED_NODAL,MED_EDGE))|(_mesh->existConnectivity(MED_DESCENDING,MED_EDGE))) { - int NumberOfEdgesType = _mesh->getNumberOfTypes(MED_EDGE) ; - medGeometryElement * EdgesType = _mesh->getTypes(MED_EDGE) ; - int * NumberOfEdgesInFamily = new int[NumberOfEdgesType] ; - int NumberOfEdgesTypeInFamily = 0 ; - medGeometryElement * tmp_EdgesTypes = new medGeometryElement[NumberOfEdgesType]; - int ** tmp_EdgesLists = new int*[NumberOfEdgesType] ; - int * GeometricTypeNumber = new int[NumberOfEdgesType] ; - int ** EdgeFamilyNumber = _mesh->getMEDArrayEdgeFamily(); - int * GlobalNumberingIndex = _mesh->getGlobalNumberingIndex(MED_EDGE); - // we search all edge in this family - for (int EdgeTypeNumber=0; EdgeTypeNumbergetNumberOfElements(MED_EDGE,EdgesType[EdgeTypeNumber]) ; - int NumberOfEdgesInThisFamily = 0 ; - int * EdgeOfThisFamilyNumber = EdgeFamilyNumber[EdgeTypeNumber]; - int * tmp_EdgesList = new int[NumberOfThisEdges]; - for (int i=0; i0) {// we have found some edges - NumberOfEdgesInFamily[NumberOfEdgesTypeInFamily]=NumberOfEdgesInThisFamily; - int * EdgesList=new int[NumberOfEdgesInThisFamily] ; - for (int i=0;i0) { // we have found edges - Find = true ; - _entity = MED_EDGE ; - _numberOfGeometricType = NumberOfEdgesTypeInFamily ; - _geometricType = new medGeometryElement[NumberOfEdgesTypeInFamily] ; - _geometricTypeNumber = new int[NumberOfEdgesTypeInFamily] ; - _isOnAllElts = false ; - _numberOfEntities = new int[NumberOfEdgesTypeInFamily] ; - _totalNumberOfEntities=0; - for (int i=0; igetNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS)) { -// _isOnAllElts = true ; -// delete[] _numberOfEntities ; -// _numberOfEntities=(int*)NULL; -// } else { - _number=new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities); - int *NumberValue=_number->getValue(); - int *NumberIndex=_number->getIndex(); - NumberIndex[0]=1; - for (int i=0; i<_numberOfGeometricType; i++) { - NumberIndex[i+1]=NumberIndex[i]+_numberOfEntities[i]; - for (int j=NumberIndex[i]; j + int numberOfTypes = _mesh->getNumberOfTypes(Entity) ; + const medGeometryElement * types = _mesh->getTypes(Entity) ; + + int * numberOfElementsInFamily = new int[numberOfTypes] ; + int numberOfElementTypesInFamily = 0 ; + + medGeometryElement * tmp_Types = new medGeometryElement[numberOfTypes]; + int ** tmp_ElementsLists = new int*[numberOfTypes] ; + // int * GeometricTypeNumber = new int[numberOfTypes] ; + const int * GlobalNumberingIndex = _mesh->getGlobalNumberingIndex(Entity); + + // we search for all elements in this family + for (int TypeNumber=0; TypeNumber < numberOfTypes; TypeNumber++) { + + int NumberOfElements = _mesh->getNumberOfElements(Entity,types[TypeNumber]) ; + int NumberOfElementsInThisFamily = 0 ; + int * ElementsOfThisFamilyNumber = FamilyNumber[TypeNumber]; + int * tmp_ElementsList = new int[NumberOfElements]; + + for (int i=0; i0) {// we have found some elements + numberOfElementsInFamily[numberOfElementTypesInFamily]=NumberOfElementsInThisFamily; + + //int * ElementsList = tmp_ElementsList.resize(NumberOfElementsInThisFamily); + int * ElementsList = new int[NumberOfElementsInThisFamily] ; + memcpy(ElementsList,tmp_ElementsList,sizeof(int)*NumberOfElementsInThisFamily); // RESIZE de tmp_NodesList serait plus efficace !!!!!!!! + + tmp_ElementsLists[numberOfElementTypesInFamily]=ElementsList ; + tmp_Types[numberOfElementTypesInFamily]=types[TypeNumber]; + // GeometricTypeNumber[numberOfElementTypesInFamily]=TypeNumber+1; + numberOfElementTypesInFamily++; + // delete [] ElementsList; + } + delete[] tmp_ElementsList; + } + + // we define all attribut in SUPPORT : + if (numberOfElementTypesInFamily>0) { // we have found elements + Find = true ; + _entity = Entity ; + _numberOfGeometricType = numberOfElementTypesInFamily ; + if (_geometricType!=NULL) delete[] _geometricType ; + _geometricType = new medGeometryElement[numberOfElementTypesInFamily] ; + _isOnAllElts = false ; + if (_numberOfElements!=NULL) delete[] _numberOfElements ; + _numberOfElements = new int[numberOfElementTypesInFamily] ; + _totalNumberOfElements=0; + + //_numberOfGaussPoint = new int[numberOfElementTypesInFamily] ; + + //int * numberIndex = new int[numberOfElementTypesInFamily+1]; + //numberIndex[0]=1; + for (int i=0; igetNumberOfElements(Entity,MED_ALL_ELEMENTS)) { + _isOnAllElts = true ; + // all others attributs are rights ! + for (int i=0; i<_numberOfGeometricType; i++) + delete[] tmp_ElementsLists[i]; + } else { + int *NumberValue = new int[_totalNumberOfElements]; + int *NumberIndex = new int[_numberOfGeometricType+1]; + NumberIndex[0]=1; + for (int i=0; i<_numberOfGeometricType; i++) { + NumberIndex[i+1]=NumberIndex[i]+_numberOfElements[i]; + for (int j=NumberIndex[i]; j #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 + ) ; + + /*! Copy Constructor. */ + FAMILY(const FAMILY & m); - // 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) ; + /*! 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); @@ -61,7 +147,7 @@ public: // inline methods : -/* Set the attribute _identifier to Identifier. */ +/*! Sets the attribute _identifier to Identifier. */ //---------------------------------------------- inline void FAMILY::setIdentifier(int Identifier) //---------------------------------------------- @@ -69,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) //-------------------------------------------------------------- @@ -77,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) //--------------------------------------------------------------------- @@ -85,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) //----------------------------------------------------------- @@ -93,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) //-------------------------------------------------------------------------- @@ -101,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) //------------------------------------------------------- @@ -109,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 //----------------------------------------------- @@ -158,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.cxx b/src/MEDMEM/MEDMEM_Field.cxx index 7329c8513..18191c26d 100644 --- a/src/MEDMEM/MEDMEM_Field.cxx +++ b/src/MEDMEM/MEDMEM_Field.cxx @@ -1,11 +1,39 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_Field.cxx +// Module : MED + +using namespace std; #include "MEDMEM_Field.hxx" // --------------------------------- // FIELD_ : Constructors // --------------------------------- FIELD_::FIELD_(): + _isRead(false), _name(""), _description(""), _support((SUPPORT *)NULL), - _numberOfComponents(0), _componentsTypes((int *)NULL), + _numberOfComponents(0), _numberOfValues(0),_componentsTypes((int *)NULL), _componentsNames((string *)NULL), _componentsDescriptions((string *)NULL), _componentsUnits((UNIT*)NULL), @@ -16,12 +44,14 @@ FIELD_::FIELD_(): } FIELD_::FIELD_(const SUPPORT * Support, const int NumberOfComponents): + _isRead(false), _name(""), _description(""), _support(Support), _numberOfComponents(NumberOfComponents), _iterationNumber(-1),_time(0.0),_orderNumber(-1) { MESSAGE("FIELD_(const SUPPORT * Support, const int NumberOfComponents)"); + _numberOfValues = Support->getNumberOfElements(MED_ALL_ELEMENTS); _componentsTypes = new int[NumberOfComponents] ; _componentsNames = new string[NumberOfComponents]; _componentsDescriptions = new string[NumberOfComponents]; @@ -34,19 +64,45 @@ FIELD_::FIELD_(const SUPPORT * Support, const int NumberOfComponents): FIELD_::FIELD_(const FIELD_ &m) { + _isRead = m._isRead ; _name = m._name; _description = m._description; _support = m._support; _numberOfComponents = m._numberOfComponents; - _componentsTypes = m._componentsTypes; - _componentsNames = m._componentsNames; - _componentsDescriptions = m._componentsDescriptions; - _componentsUnits = m._componentsUnits; - _MEDComponentsUnits = m._MEDComponentsUnits; + _numberOfValues = m._numberOfValues; + + if (m._componentsTypes != NULL) + { + _componentsTypes = new int[m._numberOfComponents] ; + memcpy(_componentsTypes,m._componentsTypes,sizeof(int)*m._numberOfComponents); + /* + _componentsTypes = new int[m._numberOfComponents] ; + for(int i=0;i _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(GENDRIVER & driver); + 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 read (const GENDRIVER &); + virtual void read(int index=0); virtual void write(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 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; }; @@ -128,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 ; } @@ -273,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_ { @@ -280,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 ; @@ -314,20 +581,20 @@ private: public: FIELD(); - FIELD(const FIELD &m); // A FAIRE + FIELD(const FIELD &m); FIELD & operator=(const FIELD &m); // A FAIRE FIELD(const SUPPORT * Support, const int NumberOfComponents); // Ajout NB Constructeur FIELD avec allocation de memoire de tous ses attribut - FIELD(driverTypes driverType, const string & fileName="", - const string & fieldName=""); - ~FIELD(); + FIELD(const SUPPORT * Support, driverTypes driverType, + const string & fileName="", const string & fieldName=""); + ~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); @@ -336,86 +603,201 @@ public: void allocValue(const int NumberOfComponents, const int LengthValue); void deallocValue(); - - inline void read(int index=0); + + 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 () { } -template FIELD::FIELD(const FIELD &m): +/*! + Copy constructor. +*/ +template FIELD::FIELD(const FIELD & m): FIELD_((FIELD_) m) { - _value = m._value; - _drivers = m._drivers; + if (m._value != NULL) + { + // copie only default ! + _value = new MEDARRAY::MEDARRAY(* m._value,false); + } + else + _value = (MEDARRAY *) NULL; + //_drivers = m._drivers; } -template FIELD & FIELD::FIELD::operator=(const FIELD &m) +/*! + +*/ +template FIELD & FIELD::operator=(const FIELD &m) { } -template FIELD::FIELD(driverTypes driverType, - const string & fileName="", - const string & fieldName="") +/*! + Constructor. +*/ +template FIELD::FIELD(const SUPPORT * Support, + 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=\"\") : "; + + int current; + + BEGIN_OF(LOC); + + init(); + + _support = Support; + _value = (MEDARRAY*)NULL; + + 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); } -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) @@ -433,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 !"); @@ -447,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)"); @@ -467,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()"); } @@ -492,21 +885,25 @@ template FIELD::INSTANCE_DE > FI template const FIELD::INSTANCE * const FIELD::instances[] = { &FIELD::inst_med } ; -template int FIELD::addDriver(driverTypes driverType, - const string & fileName="Default File Name.med", - const string & driverName="Default Field Name") +/*! + 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; @@ -514,122 +911,322 @@ 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); }; -template void FIELD::rmDriver (int index=0) +/*! + 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::setValue(MEDARRAY *Value) -{ - _value=Value ; } -template inline T* FIELD::getValue(medModeSwitch Mode) const -{ - return _value->get(Mode) ; + +/*! + \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(); + _drivers[index]->close(); + } + + END_OF(LOC); + } -template inline T* FIELD::getValueI(medModeSwitch Mode,int i) const + +/*! + \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->getI(Mode,i) ; + return _value ; } -template inline T FIELD::getValueIJ(int i,int j) const + +/*! + Return a reference to values array to read them. +*/ +template inline const T* FIELD::getValue(medModeSwitch Mode) const { - return _value->getIJ(i,j) ; + return _value->get(Mode) ; } +/*! + 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 +{ + if ( Mode == MED_FULL_INTERLACE ) + { + return _value->getRow(i) ; + } + ASSERT ( Mode == MED_NO_INTERLACE); + return _value->getColumn(i); +} + +/*! + 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) ; +} + +/*! + 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_GenDriver.cxx b/src/MEDMEM/MEDMEM_GenDriver.cxx index 08b8a1548..41b077695 100644 --- a/src/MEDMEM/MEDMEM_GenDriver.cxx +++ b/src/MEDMEM/MEDMEM_GenDriver.cxx @@ -1,25 +1,71 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_GenDriver.cxx +// Module : MED + +using namespace std; #include "MEDMEM_GenDriver.hxx" +#include "MEDMEM_STRING.hxx" +#include "MEDMEM_Exception.hxx" -GENDRIVER::GENDRIVER(): _fileName(""),_accessMode((med_mode_acces)MED_INVALID),_status(MED_INVALID),_driverType(NO_DRIVER) {} +GENDRIVER::GENDRIVER(): _id(MED_INVALID), + _fileName(""), + _accessMode( (med_mode_acces) MED_INVALID ), + _status(MED_INVALID), + _driverType(NO_DRIVER) {} GENDRIVER::GENDRIVER(const string & fileName, - med_mode_acces accessMode=(med_mode_acces) MED_INVALID): _fileName(fileName), + med_mode_acces accessMode=(med_mode_acces) MED_INVALID): _id(MED_INVALID), + _fileName(fileName), _accessMode(accessMode), _status(MED_CLOSED), _driverType(NO_DRIVER) {} -GENDRIVER::GENDRIVER(const GENDRIVER & genDriver):_fileName(genDriver._fileName), - _accessMode(genDriver._accessMode), - _status(genDriver._status),_driverType(NO_DRIVER) {} +GENDRIVER::GENDRIVER(const GENDRIVER & genDriver): + //_id(MED_INVALID), + _id(genDriver._id), + _fileName(genDriver._fileName), + _accessMode(genDriver._accessMode), + _status(genDriver._status), + _driverType(genDriver._driverType) +{} + GENDRIVER::~GENDRIVER() {} GENDRIVER & GENDRIVER::operator=(const GENDRIVER & genDriver) { + const char * LOC = " GENDRIVER & GENDRIVER::operator=(const GENDRIVER & genDriver) : "; + + BEGIN_OF(LOC); + _fileName = genDriver._fileName; _accessMode = genDriver._accessMode; _status = genDriver._status; - + _id = genDriver._id; return *this; + + END_OF(LOC); } void GENDRIVER::writeFrom ( void ) {}; @@ -28,16 +74,62 @@ void GENDRIVER::readFileStruct ( void ) {}; void GENDRIVER::setMeshName (const string & meshName) {}; void GENDRIVER::setFieldName (const string & fieldName) {}; +void GENDRIVER::setId ( int id ) { + const char * LOC = "void GENDRIVER::setId ( int id ) : "; + + BEGIN_OF(LOC); + + if ( id >= 0 ) _id=id; else _id = MED_INVALID ; + + END_OF(LOC); +}; + +int GENDRIVER::getId ( void) const { + const char * LOC = "int GENDRIVER::getId ( void) const "; + + BEGIN_OF(LOC); + + return _id ; + + END_OF(LOC); +}; + string GENDRIVER::getFileName() const { + + const char * LOC = "string GENDRIVER::getFileName() const : "; + BEGIN_OF(LOC); + return _fileName; + + END_OF(LOC); } - + + void GENDRIVER::setFileName(const string & fileName) { - _fileName = fileName; + + const char * LOC = "void GENDRIVER::setFileName(const string & fileName) : "; + BEGIN_OF(LOC); + + if ( _status == MED_OPENED ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<" File |" << _fileName + << "| is still openned, close it before openning : | " << fileName << "|")); + else + _fileName = fileName; + + END_OF(LOC); } + + med_mode_acces GENDRIVER::getAccessMode() const { + + const char * LOC = "med_mode_acces GENDRIVER::getAccessMode() const : "; + + BEGIN_OF(LOC); + return _accessMode; + + END_OF(LOC); } ostream & operator<<(ostream &os,const GENDRIVER & drv) @@ -66,10 +158,14 @@ ostream & operator<<(ostream &os,const GENDRIVER & drv) return os; } +// Test if this driver has been created from MED driver bool GENDRIVER::operator ==(const GENDRIVER &genDriver) const { + const char * LOC = "bool GENDRIVER::operator ==(const GENDRIVER &genDriver) const : "; + + MESSAGE(LOC); + return ( _id == genDriver._id ) && - ( _fileName == genDriver._fileName ) && ( _driverType == genDriver._driverType ); }; diff --git a/src/MEDMEM/MEDMEM_GenDriver.hxx b/src/MEDMEM/MEDMEM_GenDriver.hxx index fe7f851b6..9e9813cf7 100644 --- a/src/MEDMEM/MEDMEM_GenDriver.hxx +++ b/src/MEDMEM/MEDMEM_GenDriver.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_GenDriver.hxx +// Module : MED + #ifndef GENDRIVER_HXX #define GENDRIVER_HXX @@ -8,11 +34,18 @@ /* Generic Read/Write Driver Class for Meshes & Fields */ -typedef enum { MED_DRIVER = 0, VTK_DRIVER = 1, NO_DRIVER = 255 } driverTypes; +/* Modify the following line to add a new driver type (step 1) */ +typedef enum { MED_DRIVER = 0, GIBI_DRIVER = 1, VTK_DRIVER = 254, NO_DRIVER = 255 } driverTypes; using namespace MED_EN; using namespace std; +/*! + + Virtual class GENDRIVER use by all driver. + +*/ + class GENDRIVER { protected : @@ -20,29 +53,61 @@ protected : int _id; // MED_INVALID : if the driver hasn't been created by a MedMedDriver // the MedMedDriver index of the driver vector in the MED object where it has been created /*File related part*/ - string _fileName; - med_mode_acces _accessMode; - int _status; + string _fileName; // The name of the file currently in use. + med_mode_acces _accessMode; // The file access mode set by the adequate construtor. + int _status; // The file status {MED_INVALID, MED_OPENED, MED_CLOSED } driverTypes _driverType; // A FAIRE LE POSITIONNER DS TOUTES LES SS CLASSES !! public: + /*! + Constructor. + */ GENDRIVER(); - + /*! + Constructor. + */ GENDRIVER(const string & fileName,med_mode_acces accessMode); + /*! + Copy constructor. + */ GENDRIVER(const GENDRIVER & genDriver); - ~GENDRIVER(); + /*! + Destructor. + */ + virtual ~GENDRIVER(); + + /*! + Operator = : duplicate the given genDriver. + */ GENDRIVER & operator=(const GENDRIVER & genDriver); + /*! + Operator << : put GENDRIVER object information to the given stream + */ friend ostream & operator<<(ostream &os,const GENDRIVER &genDriver); bool operator ==(const GENDRIVER &genDriver) const; - + /*! + Open file. + */ virtual void open ( void ) = 0; + /*! + Close file. + */ virtual void close( void ) = 0; + /*! + Write object in opened file. + */ virtual void write( void ) const = 0; + /*! + Read object in opened file. + */ virtual void read ( void ) = 0; + // needed to duplicate arrays + virtual GENDRIVER * copy ( void ) const = 0 ; + // MED related part virtual void writeFrom ( void ); virtual void readFileStruct ( void ); @@ -51,8 +116,10 @@ public: // FIELD related Part virtual void setFieldName ( const string & fieldName); + void setId ( int id = MED_INVALID ); + int getId ( void ) const ; string getFileName () const; - void setFileName (const string & fileName); + void setFileName ( const string & fileName); med_mode_acces getAccessMode() const; }; diff --git a/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx b/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx new file mode 100644 index 000000000..0da08ffa5 --- /dev/null +++ b/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx @@ -0,0 +1,230 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : MEDMEM_GibiMeshDriver.cxx +// Module : MED + +using namespace std; +#include "MEDMEM_GibiMeshDriver.hxx" + +#include "MEDMEM_DriversDef.hxx" + +#include "MEDMEM_Family.hxx" +#include "MEDMEM_Group.hxx" +#include "MEDMEM_Coordinate.hxx" +#include "MEDMEM_Connectivity.hxx" +#include "MEDMEM_Mesh.hxx" +#include "MEDMEM_CellModel.hxx" + +// Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor + +GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(): + GENDRIVER(), + _ptrMesh(( MESH *)MED_NULL), + // A VOIR _medIdt(MED_INVALID), + _meshName("") +{ +} + +GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(const string & fileName, + MESH * ptrMesh, + MED_EN::med_mode_acces accessMode): + GENDRIVER(fileName,accessMode), + _ptrMesh(ptrMesh), + // A VOIR _medIdt(MED_INVALID), + _meshName("") +{ +} + +GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(const GIBI_MESH_DRIVER & driver): + GENDRIVER(driver), + _ptrMesh(driver._ptrMesh), + // A VOIR _medIdt(MED_INVALID), + _meshName(driver._meshName) +{ +} + +GIBI_MESH_DRIVER::~GIBI_MESH_DRIVER() +{ +} + +void GIBI_MESH_DRIVER::open() + throw (MEDEXCEPTION) +{ + const char * LOC = "GIBI_MESH_DRIVER::open()" ; + BEGIN_OF(LOC); + +// if (_medIdt > 0) +// _status = MED_OPENED; +// else { +// _medIdt = MED_INVALID; +// _status = MED_CLOSED; +// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode)); +// } + + END_OF(LOC); +} + +void GIBI_MESH_DRIVER::close() + throw (MEDEXCEPTION) +{ + const char * LOC = "GIBI_MESH_DRIVER::close() " ; + BEGIN_OF(LOC); + +// 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 !" +// ) +// ); +// _status = MED_CLOSED; +// _medIdt = MED_INVALID; +// } + + END_OF(LOC); +} + +void GIBI_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; }; +string GIBI_MESH_DRIVER::getMeshName() const { return _meshName; }; + + +//---------------------------------- RDONLY PART ------------------------------------------------------------- + +GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(): GIBI_MESH_DRIVER() +{ +} + +GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const string & fileName, + MESH * ptrMesh): + GIBI_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY) +{ + MESSAGE("GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); +} + +GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver): + GIBI_MESH_DRIVER(driver) +{ +} + +GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER() +{ + //MESSAGE("GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER() has been destroyed"); +} + +GENDRIVER * GIBI_MESH_RDONLY_DRIVER::copy(void) const +{ + return new GIBI_MESH_RDONLY_DRIVER(*this); +} + +void GIBI_MESH_RDONLY_DRIVER::read(void) + throw (MEDEXCEPTION) +{ + const char * LOC = "GIBI_MESH_RDONLY_DRIVER::read() : " ; + BEGIN_OF(LOC); + + if (_status!=MED_OPENED) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << " (the file is not opened)." )) ; + + _ptrMesh->_name = _meshName; + + + END_OF(LOC); +} + +void GIBI_MESH_RDONLY_DRIVER::write( void ) const + throw (MEDEXCEPTION) +{ + throw MEDEXCEPTION("GIBI_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !"); +} + + +/*--------------------- WRONLY PART -------------------------------*/ + +GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER():GIBI_MESH_DRIVER() +{ +} + +GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName, + MESH * ptrMesh): + GIBI_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY) +{ + MESSAGE("GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); +} + +GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const GIBI_MESH_WRONLY_DRIVER & driver): + GIBI_MESH_DRIVER(driver) +{ +} + +GIBI_MESH_WRONLY_DRIVER::~GIBI_MESH_WRONLY_DRIVER() +{ + //MESSAGE("GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed"); +} + +GENDRIVER * GIBI_MESH_WRONLY_DRIVER::copy(void) const +{ + return new GIBI_MESH_WRONLY_DRIVER(*this); +} + +void GIBI_MESH_WRONLY_DRIVER::read (void) + throw (MEDEXCEPTION) +{ + throw MEDEXCEPTION("GIBI_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !"); +} + +void GIBI_MESH_WRONLY_DRIVER::write(void) const + throw (MEDEXCEPTION) +{ + const char * LOC = "void GIBI_MESH_WRONLY_DRIVER::write(void) const : "; + BEGIN_OF(LOC); + + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "Write Driver isn\'t implemented")); + + END_OF(LOC); +} + + + +/*--------------------- RDWR PART -------------------------------*/ + +GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER():GIBI_MESH_DRIVER() +{ +} + +GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName, + MESH * ptrMesh): + GIBI_MESH_DRIVER(fileName,ptrMesh,MED_RDWR) +{ + MESSAGE("GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); +} + +GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const GIBI_MESH_RDWR_DRIVER & driver): + GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_DRIVER(driver) +{ +} + +GIBI_MESH_RDWR_DRIVER::~GIBI_MESH_RDWR_DRIVER() { + //MESSAGE("GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed"); +} + +GENDRIVER * GIBI_MESH_RDWR_DRIVER::copy(void) const +{ + return new GIBI_MESH_RDWR_DRIVER(*this); +} + +void GIBI_MESH_RDWR_DRIVER::write(void) const + throw (MEDEXCEPTION) +{ + GIBI_MESH_WRONLY_DRIVER::write(); +} +void GIBI_MESH_RDWR_DRIVER::read (void) + throw (MEDEXCEPTION) +{ + GIBI_MESH_RDONLY_DRIVER::read(); +} diff --git a/src/MEDMEM/MEDMEM_GibiMeshDriver.hxx b/src/MEDMEM/MEDMEM_GibiMeshDriver.hxx new file mode 100644 index 000000000..a6a154958 --- /dev/null +++ b/src/MEDMEM/MEDMEM_GibiMeshDriver.hxx @@ -0,0 +1,218 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : MEDMEM_GibiMeshDriver.hxx +// Module : MED + +#ifndef GIBI_MESH_DRIVER_HXX +#define GIBI_MESH_DRIVER_HXX + +#include +#include + +#include "MEDMEM_define.hxx" +#include "MEDMEM_GenDriver.hxx" + +#include "MEDMEM_STRING.hxx" +#include "MEDMEM_Exception.hxx" +#include "utilities.h" + +class MESH; +class FAMILY; +class GROUP; +class CONNECTIVITY; + +/*! + + Driver GIBI for MESH. + + Generic part : implement the readopen and close methods. + +*/ + + +class GIBI_MESH_DRIVER : public GENDRIVER +{ +protected: + + MESH * _ptrMesh; + // A VOIR FILE DESCRIPTEUR ? MED_FR::med_idt _medIdt; + string _meshName; + +public : + + /*! + Constructor. + */ + GIBI_MESH_DRIVER() ; + /*! + Constructor. + */ + GIBI_MESH_DRIVER(const string & fileName, + MESH * ptrMesh, + med_mode_acces accessMode) ; + /*! + Copy constructor. + */ + GIBI_MESH_DRIVER(const GIBI_MESH_DRIVER & driver) ; + + /*! + Destructor. + */ + virtual ~GIBI_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 ; + +}; + + +class GIBI_MESH_RDONLY_DRIVER : public virtual GIBI_MESH_DRIVER +{ + +public : + + /*! + Constructor. + */ + GIBI_MESH_RDONLY_DRIVER() ; + /*! + Constructor. + */ + GIBI_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ; + /*! + Copy constructor. + */ + GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver) ; + + /*! + Destructor. + */ + virtual ~GIBI_MESH_RDONLY_DRIVER() ; + + /*! + 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: + + GENDRIVER * copy ( void ) const ; + +}; + +/*! + + Driver Med for MESH : Write only. + + Implement write method. + +*/ + +class GIBI_MESH_WRONLY_DRIVER : public virtual GIBI_MESH_DRIVER { + +public : + + /*! + Constructor. + */ + GIBI_MESH_WRONLY_DRIVER() ; + /*! + Constructor. + */ + GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) ; + /*! + Copy constructor. + */ + GIBI_MESH_WRONLY_DRIVER(const GIBI_MESH_WRONLY_DRIVER & driver) ; + + /*! + Destructor. + */ + virtual ~GIBI_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: + + GENDRIVER * copy ( void ) const ; +}; + + +/*! + + Driver GIBI for MESH : Read write. + - Use read method from GIBI_MESH_RDONLY_DRIVER + - Use write method from GIBI_MESH_WRONLY_DRIVER + +*/ + +class GIBI_MESH_RDWR_DRIVER : public GIBI_MESH_RDONLY_DRIVER, public GIBI_MESH_WRONLY_DRIVER { + +public : + + /*! + Constructor. + */ + GIBI_MESH_RDWR_DRIVER() ; + /*! + Constructor. + */ + GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ; + /*! + Copy constructor. + */ + GIBI_MESH_RDWR_DRIVER(const GIBI_MESH_RDWR_DRIVER & driver) ; + + /*! + Destructor. + */ + ~GIBI_MESH_RDWR_DRIVER() ; + + /*! + 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 /* GIBI_MESH_DRIVER_HXX */ diff --git a/src/MEDMEM/MEDMEM_Grid.cxx b/src/MEDMEM/MEDMEM_Grid.cxx new file mode 100644 index 000000000..40d448b08 --- /dev/null +++ b/src/MEDMEM/MEDMEM_Grid.cxx @@ -0,0 +1,951 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : MEDMEM_Grid.hxx +// Author : Edward AGAPOV (eap) +// Module : MED +// $Header$ + +using namespace std; +#include "MEDMEM_Grid.hxx" +#include +#include + +//======================================================================= +//function : GRID +//purpose : empty constructor +//======================================================================= + +GRID::GRID() { + init(); + MESSAGE("A GRID CREATED"); +} + +//======================================================================= +//function : GRID +//purpose : empty constructor +//======================================================================= + +GRID::GRID(const med_grid_type type) +{ + init(); + _gridType = type; + MESSAGE("A TYPED GRID CREATED"); +} + +//======================================================================= +//function : GRID +//purpose : copying constructor +//======================================================================= + +GRID::GRID(const GRID& otherGrid) { + *this = otherGrid; +} + +//======================================================================= +//function : ~GRID +//purpose : destructor +//======================================================================= + +GRID::~GRID() { + MESSAGE("GRID::~GRID() : Destroying the Grid"); + if ( _iArray != (double* ) NULL) delete [] _iArray; + if ( _jArray != (double* ) NULL) delete [] _jArray; + if ( _kArray != (double* ) NULL) delete [] _kArray; +} + +//======================================================================= +//function : init +//purpose : +//======================================================================= + +void GRID::init() +{ + _gridType = MED_CARTESIAN; + + _iArray = _jArray = _kArray = (double* ) NULL; + _iArrayLength = _jArrayLength = _kArrayLength = 0; + + _is_coordinates_filled = false; + _is_connectivity_filled = false; + + MESH::init(); + + _isAGrid = true; +} + +//======================================================================= +//function: operator= +//purpose : operator= +//======================================================================= + +GRID & GRID::operator=(const GRID & otherGrid) +{ + // NOT IMPLEMENTED + + MESH::operator=(otherGrid); + return *this; +} + +//======================================================================= +//function : GRID +//purpose : Create a GRID object using a MESH driver of type +// (MED_DRIVER, ....) associated with file . +//======================================================================= + +GRID::GRID(driverTypes driverType, + const string & fileName, + const string & driverName) { + const char * LOC ="GRID::GRID(driverTypes , const string & , const string &) : "; + + BEGIN_OF(LOC); + +// int current; + + init(); + MESH(driverType,fileName,driverName); + +// current = addDriver(driverType,fileName,driverName); + +// switch(_drivers[current]->getAccessMode() ) { +// case MED_RDONLY : +// MESSAGE(LOC << "driverType must have a MED_RDWR accessMode"); +// rmDriver(current); +// break; +// default: {} +// } +// _drivers[current]->open(); +// _drivers[current]->read(); +// _drivers[current]->close(); + +// // fill some fields of MESH +// fillMeshAfterRead(); + + END_OF(LOC); +}; + +//======================================================================= +//function : fillMeshAfterRead +//purpose : +//======================================================================= + +void GRID::fillMeshAfterRead() +{ + // fill not only MESH (:-) + _is_coordinates_filled = false; + _is_connectivity_filled = false; + + if (_gridType == MED_BODY_FITTED) + { + _is_coordinates_filled = true; + + // nb of nodes in each direction is not known, set anything + // in order to be able to work anyhow +// INFOS("GRID::fillMeshAfterRead(): This stub must be removed"); +// switch (_spaceDimension) { +// case 1: +// _iArrayLength = _numberOfNodes; +// _jArrayLength = 0; +// _kArrayLength = 0; +// break; +// case 2: +// _iArrayLength = 2; +// _jArrayLength = _numberOfNodes / _iArrayLength; +// _kArrayLength = 0; +// break; +// default: +// _iArrayLength = 2; +// _jArrayLength = _numberOfNodes / _iArrayLength / 2; +// _kArrayLength = _numberOfNodes / _iArrayLength / _jArrayLength; +// } + //cout << "ARRAY LENGTHS: " << _iArrayLength << " " << _jArrayLength +// << " " << _kArrayLength << endl; + } +// else { +// int NbNodes = _iArrayLength; +// if (_jArrayLength) +// NbNodes *= _jArrayLength; +// if (_kArrayLength) +// NbNodes *= _kArrayLength; +// MESH::_numberOfNodes = NbNodes; +// } + + MESH::_meshDimension = MESH::_spaceDimension; +} + +//======================================================================= +//function : fillCoordinates +//purpose : +//======================================================================= + +void GRID::fillCoordinates() +{ + if (_is_coordinates_filled) + { + MESSAGE("GRID::fillCoordinates(): Already filled"); + return; + } + + const char * LOC ="GRID::fillCoordinates()"; + BEGIN_OF(LOC); + + double* myCoord = + const_cast ( _coordinate->getCoordinates(MED_FULL_INTERLACE) ); + + bool hasJ = _jArrayLength, hasK = _kArrayLength; + int J = hasJ ? _jArrayLength : 1; + int K = hasK ? _kArrayLength : 1; + int nb, i, j, k; + for (k=0; k < K; ++k) { + for (j=0; j < J; ++j) { + for (i=0; i < _iArrayLength; ++i) { + + * myCoord = _iArray[ i ]; + ++ myCoord; + + if (hasJ) + { + * myCoord = _jArray[ j ]; + ++ myCoord; + + if (hasK) + { + * myCoord = _jArray[ k ]; + ++ myCoord; + } + } + } + } + } + + _is_coordinates_filled = true; + END_OF(LOC); +} + +//======================================================================= +//function : makeConnectivity +//purpose : +//======================================================================= + +CONNECTIVITY * GRID::makeConnectivity (const medEntityMesh Entity, + const medGeometryElement Geometry, + const int NbEntities, + const int NbNodes, + int * NodeNumbers) +{ + CONNECTIVITY * Connectivity = new CONNECTIVITY(Entity) ; + Connectivity->_numberOfNodes = NbNodes ; + Connectivity->_entityDimension = Geometry/100 ; + + int numberOfGeometricType = 1; + Connectivity->_numberOfTypes = numberOfGeometricType; + + Connectivity->_count = new int [numberOfGeometricType + 1] ; + Connectivity->_count[0] = 1; + Connectivity->_count[1] = 1 + NbEntities; + + Connectivity->_type = new CELLMODEL [numberOfGeometricType]; + Connectivity->_type[0] = CELLMODEL( Geometry ) ; + + Connectivity->_geometricTypes = new medGeometryElement [ numberOfGeometricType ]; + Connectivity->_geometricTypes[0] = Geometry; + + // Connectivity->_nodal = new MEDSKYLINEARRAY() ; + int * skyLineArrayIndex = new int [NbEntities + 1]; + int i, j, nbEntityNodes = Connectivity->_type[0].getNumberOfNodes(); + for (i=0, j=1; i <= NbEntities; ++i, j += nbEntityNodes) + skyLineArrayIndex [ i ] = j; + + // Connectivity->_nodal->setMEDSKYLINEARRAY (NbEntities, NbNodes, + //skyLineArrayIndex, NodeNumbers); + + Connectivity->_nodal = new MEDSKYLINEARRAY (NbEntities, NbNodes, + skyLineArrayIndex, NodeNumbers); + + delete [] skyLineArrayIndex; + + // test connectivity right away +// for (med_int j = 0; j < numberOfGeometricType; j++) +// { +// int node_number = Connectivity->_type[j].getNumberOfNodes(); +// for (med_int k = Connectivity->_count[j]; k < Connectivity->_count[j+1]; k++) +// for (med_int local_node_number = 1 ; local_node_number < node_number+1; local_node_number++) +// { +// cout << "MEDSKYLINEARRAY::getIJ(" << k << ", " << local_node_number << endl; +// med_int global_node = Connectivity->_nodal->getIJ(k,local_node_number) ; +// cout << "...= " << global_node << endl; +// } +// } + + return Connectivity; +} + +//======================================================================= +//function : fillConnectivity +//purpose : fill _coordinates and _connectivity of MESH if not yet done +//======================================================================= + +void GRID::fillConnectivity() +{ + if (_is_connectivity_filled) + { + MESSAGE("GRID::fillConnectivity(): Already filled"); + return; + } + + const char * LOC = "GRID::fillConnectivity() "; + BEGIN_OF(LOC); + + int nbCells, nbFaces, nbEdges; + int nbCNodes, nbFNodes, nbENodes; + int indexC, indexF, indexE; + int * nodeCNumbers, * nodeFNumbers, * nodeENumbers; + // about descending connectivity + int nbSub, nbRevSub, indexSub, indexRevSub, * subNumbers, * subRevNumbers; + + bool hasFaces = _kArrayLength, hasEdges = _jArrayLength; + + int iLenMin1 = _iArrayLength-1, jLenMin1 = _jArrayLength-1; + int kLenMin1 = _kArrayLength-1, ijLenMin1 = iLenMin1 * jLenMin1; + if (!hasEdges) jLenMin1 = 1; + if (!hasFaces) kLenMin1 = 1; + + // nb of cells and of their connectivity nodes + + nbCells = iLenMin1 * jLenMin1 * kLenMin1; + nbCNodes = nbCells * 2 * (hasEdges ? 2 : 1) * (hasFaces ? 2 : 1); + nodeCNumbers = new int [ nbCNodes ]; + + // nb of faces and of their connectivity nodes + + if (hasFaces) { + nbFaces = _iArrayLength * jLenMin1 * kLenMin1; + nbFaces += _jArrayLength * kLenMin1 * iLenMin1; + nbFaces += _kArrayLength * iLenMin1 * jLenMin1; + nbFNodes = nbFaces * 4; + nodeFNumbers = new int [ nbFNodes ]; + } else + nbFaces = nbFNodes = 0; + + // nb of edges and of their connectivity nodes + + if (hasEdges) { + if (_kArrayLength) { // 3d grid + nbEdges = iLenMin1 * _jArrayLength * _kArrayLength; + nbEdges += jLenMin1 * _kArrayLength * _iArrayLength; + nbEdges += kLenMin1 * _iArrayLength * _jArrayLength; + } + else if (_jArrayLength) { // 2d + nbEdges = iLenMin1 * _jArrayLength; + nbEdges += jLenMin1 * _iArrayLength; + } + nbENodes = nbEdges * 2; + nodeENumbers = new int [ nbENodes ]; + } else + nbEdges = nbENodes = 0; + + // nb of descending connectivity Elements + + if (hasFaces) + { + nbSub = nbCells * 6; + nbRevSub = nbFaces * 2; + } + else + { + nbSub = nbCells * 4; + nbRevSub = nbEdges * 2; + } + subNumbers = new int [ nbSub ]; + subRevNumbers = new int [ nbRevSub ]; + for (int r=0; r_descending = new MEDSKYLINEARRAY() ; + int * skyLineArrayIndex = new int [nbCells + 1]; + int nbEntitySub = CellCNCT->_type[0].getNumberOfConstituents(1); + for (i=0, j=1; i <= nbCells; ++i, j += nbEntitySub) + skyLineArrayIndex [ i ] = j; + // CellCNCT->_descending->setMEDSKYLINEARRAY (nbCells, nbSub, + // skyLineArrayIndex, subNumbers); + CellCNCT->_descending = new MEDSKYLINEARRAY (nbCells, nbSub, + skyLineArrayIndex, + subNumbers); + delete [] skyLineArrayIndex; + } + delete [] subNumbers; + + // reverse descending + { + // CellCNCT->_reverseDescendingConnectivity = new MEDSKYLINEARRAY() ; + nbSub = nbRevSub/2; + int * skyLineArrayIndex = new int [nbSub + 1]; + for (i=0, j=1; i <= nbSub; ++i, j += 2) + skyLineArrayIndex [ i ] = j; + // CellCNCT->_reverseDescendingConnectivity->setMEDSKYLINEARRAY + // (nbSub, nbRevSub, skyLineArrayIndex, subRevNumbers); + + CellCNCT->_reverseDescendingConnectivity = + new MEDSKYLINEARRAY(nbSub, nbRevSub, skyLineArrayIndex, subRevNumbers); + + delete [] skyLineArrayIndex; + } + delete [] subRevNumbers; + + // make connectivity for FACE and/or EDGE + + if (hasFaces) { + FaceCNCT = makeConnectivity (MED_FACE, MED_QUAD4, nbFaces, nbFNodes, nodeFNumbers); + + delete [] nodeFNumbers; + + CellCNCT->_constituent = FaceCNCT; + } + if (hasEdges) { + EdgeCNCT = makeConnectivity (MED_EDGE, MED_SEG2, nbEdges, nbENodes, nodeENumbers); + + delete [] nodeENumbers; + + if (hasFaces) + FaceCNCT->_constituent = EdgeCNCT; + else + CellCNCT->_constituent = EdgeCNCT; + } + + MESH::_connectivity = CellCNCT; + + _is_connectivity_filled = true; + + END_OF(LOC); +} + +//======================================================================= +//function : getArrayLength +//purpose : return array length. Axis = [1,2,3] meaning [i,j,k], +//======================================================================= + +int GRID::getArrayLength( const int Axis ) throw (MEDEXCEPTION) +{ + switch (Axis) { + case 1: return _iArrayLength; + case 2: return _jArrayLength; + case 3: return _kArrayLength; + default: + throw MED_EXCEPTION ( LOCALIZED( STRING("GRID::getArrayLength ( ") << Axis << ")")); + } + return 0; +} + +//======================================================================= +//function : getArrayValue +//purpose : return i-th array component. Axis = [1,2,3] meaning [i,j,k], +// exception if Axis out of [1-3] range +// exception if i is out of range 0 <= i < getArrayLength(Axis); +//======================================================================= + +const double GRID::getArrayValue (const int Axis, const int i) + throw (MEDEXCEPTION) +{ + if (i < 0 || i >= getArrayLength(Axis)) + throw MED_EXCEPTION + ( LOCALIZED(STRING("GRID::getArrayValue ( ") << Axis << ", " << i << ")")); + + switch (Axis) { + case 1: return _iArray[ i ]; + case 2: return _jArray[ i ]; + default: return _kArray[ i ]; + } + return 0.0; +} + +//======================================================================= +//function : getEdgeNumber +//purpose : +//======================================================================= + +int GRID::getEdgeNumber(const int Axis, const int i, const int j, const int k) + throw (MEDEXCEPTION) +{ + const char * LOC = "GRID::getEdgeNumber(Axis, i,j,k) :"; + + int Len[4] = {0,_iArrayLength, _jArrayLength, _kArrayLength }, I=1, J=2, K=3; + int maxAxis = Len[ K ] ? 3 : 2; + + if (Axis <= 0 || Axis > maxAxis) + throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Axis out of range: " << Axis)); + + Len[Axis]--; + int Nb = 1 + i + j*Len[ I ] + k*Len[ J ]*Len[ K ]; + Len[Axis]++ ; + + if (!Len[ K ]) + Len[ K ] = 1; + + if (Axis > 1) { // add all edges in i direction + Len[I]-- ; + Nb += Len[ I ]*Len[ J ]*Len[ K ]; + Len[I]++ ; + } + if (Axis > 2) { // add all edges in j direction + Len[J]-- ; + Nb += Len[ I ]*Len[ J ]*Len[ K ]; + } + + return Nb; +} + +//======================================================================= +//function : getFaceNumber +//purpose : return a NODE, EDGE, FACE, CELL number by its position in the grid. +// Axis [1,2,3] means one of directions: along i, j or k +// For Cell contituents (FACE or EDGE), Axis selects one of those having same (i,j,k): +// * a FACE which is normal to direction along given Axis; +// * an EDGE going along given Axis. +// Exception for Axis out of range +//======================================================================= + +int GRID::getFaceNumber(const int Axis, const int i, const int j, const int k) + throw (MEDEXCEPTION) +{ + const char * LOC = "GRID::getFaceNumber(Axis, i,j,k) :"; + +// if (Axis <= 0 || Axis > 3) + if (Axis < 0 || Axis > 3) + throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Axis = " << Axis)); + + int Len[4] = {0,_iArrayLength-1, _jArrayLength-1, _kArrayLength-1 }, I=1, J=2, K=3; + + Len[Axis]++; + int Nb = 1 + i + j*Len[ I ] + k*Len[ J ]*Len[ K ]; + Len[Axis]--; + + if (Axis > 1) { // add all faces in i direction + Len[I]++ ; + Nb += Len[ I ]*Len[ J ]*Len[ K ]; + Len[I]-- ; + } + if (Axis > 2) { // add all faces in j direction + Len[J]++ ; + Nb += Len[ I ]*Len[ J ]*Len[ K ]; + } + + return Nb; +} + +//======================================================================= +//function : getNodePosition +//purpose : +//======================================================================= + +void GRID::getNodePosition(const int Number, int& i, int& j, int& k) + throw (MEDEXCEPTION) +{ + const char * LOC = "GRID::getNodePosition(Number, i,j,k) :"; + + if (Number <= 0 || Number > _numberOfNodes) + throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number)); + + int Len[] = {_iArrayLength, _jArrayLength, _kArrayLength }, I=0, J=1, K=2; + + int ijLen = Len[I] * Len[J]; // nb in a full k layer + int kLen = (Number - 1) % ijLen; // nb in the non full k layer + + i = kLen % Len[J]; + j = kLen / Len[J]; + k = (Number - 1) / ijLen; + + ////cout <<" NODE POS: " << Number << " - " << i << ", " << j << ", " << k << endl; +} + +//======================================================================= +//function : getCellPosition +//purpose : +//======================================================================= + +void GRID::getCellPosition(const int Number, int& i, int& j, int& k) + throw (MEDEXCEPTION) +{ + const char * LOC = "GRID::getCellPosition(Number, i,j,k) :"; + + int Len[4] = {0,_iArrayLength-1, _jArrayLength-1, _kArrayLength-1 }, I=1, J=2, K=3; + +// if (Number <= 0 || Number > getCellNumber(Len[I]-1, Len[J]-1, Len[K]-1)) +// throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number)); + + int ijLen = Len[I] * Len[J]; // nb in a full k layer + int kLen = (Number - 1) % ijLen; // nb in the non full k layer + + i = kLen % Len[J]; + j = kLen / Len[J]; + k = (Number - 1) / ijLen; +} + +//======================================================================= +//function : getEdgePosition +//purpose : +//======================================================================= + +void GRID::getEdgePosition(const int Number, int& Axis, int& i, int& j, int& k) + throw (MEDEXCEPTION) +{ + const char * LOC = "GRID::getEdgePosition(Number, i,j,k) :"; + + if (!_jArrayLength) + throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "no edges in the grid: ")); + + if (Number <= 0) + throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number)); + + int Len[4] = {0,_iArrayLength, _jArrayLength, _kArrayLength }, I=1, J=2, K=3; + + int theNb = Number; + int maxAxis = _kArrayLength ? 3 : 2; + + for (Axis = 1; Axis <= maxAxis; ++Axis) + { + Len[Axis]--; // one less edge in Axis direction + + // max edge number in Axis direction + int maxNb = getEdgeNumber (Axis, Len[I]-1, Len[J]-1, Len[K]-1); + + if (theNb > maxNb) + { + Len[Axis]++; + theNb -= maxNb; + continue; + } + + if (theNb == maxNb) + { + i = Len[I]-1; + j = Len[J]-1; + k = Len[K]-1; + } + else + { + int ijLen = Len[I] * Len[J]; // nb in a full k layer + int kLen = (theNb - 1) % ijLen; // nb in the non full k layer + i = kLen % Len[J]; + j = kLen / Len[J]; + k = (theNb - 1) / ijLen; + } + return; + } + + throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number)); +} + +//======================================================================= +//function : getFacePosition +//purpose : return position (i,j,k) of an entity #Number +// Axis [1,2,3] means one of directions: along i, j or k +// For Cell contituents (FACE or EDGE), Axis selects one of those having same (i,j,k): +// * a FACE which is normal to direction along given Axis; +// * an EDGE going along given Axis. +// Exception for Number out of range +//======================================================================= + +void GRID::getFacePosition(const int Number, int& Axis, int& i, int& j, int& k) + throw (MEDEXCEPTION) +{ + const char * LOC = "GRID::getFacePosition(Number, i,j,k) :"; + + if (_kArrayLength == 0) { + getCellPosition(Number, i, j, k); + Axis = 1; + return; + }; + + if (!_kArrayLength) + throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "no faces in the grid: ")); + + if ( Number <= 0 ) + throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number)); + + int Len[4] = {0,_iArrayLength-1, _jArrayLength-1, _kArrayLength-1 }, I=1, J=2, K=3; + int theNb = Number; + + for (Axis = 1; Axis <= 3; ++Axis) + { + Len[Axis]++; + + // max face number in Axis direction + int maxNb = getFaceNumber (Axis, Len[I]-1, Len[J]-1, Len[K]-1); + + if (theNb > maxNb) + { + Len[Axis]--; + theNb -= maxNb; + continue; + } + + if (theNb == maxNb) + { + i = Len[I]-1; + j = Len[J]-1; + k = Len[K]-1; + } + else + { + int ijLen = Len[I] * Len[J]; // nb in a full k layer + int kLen = (theNb - 1) % ijLen; // nb in the non full k layer + i = kLen % Len[J]; + j = kLen / Len[J]; + k = (theNb - 1) / ijLen; + } + return; + } + + throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number)); +} + +//======================================================================= +//function : writeUnstructured +//purpose : write a Grid as an Unstructured mesh +//======================================================================= + +void GRID::writeUnstructured(int index, const string & driverName) +{ + const char * LOC = "GRID::writeUnstructured(int index=0, const string & driverName) : "; + BEGIN_OF(LOC); + + if ( _drivers[index] ) { + + makeUnstructured(); + _isAGrid = false; + + _drivers[index]->open(); + if (driverName != "") _drivers[index]->setMeshName(driverName); + _drivers[index]->write(); + _drivers[index]->close(); + + _isAGrid = true; + } + else + throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) + << "The index given is invalid, index must be between 0 and |" + << _drivers.size() + ) + ); + END_OF(LOC); +} diff --git a/src/MEDMEM/MEDMEM_Grid.hxx b/src/MEDMEM/MEDMEM_Grid.hxx new file mode 100644 index 000000000..09f938bc5 --- /dev/null +++ b/src/MEDMEM/MEDMEM_Grid.hxx @@ -0,0 +1,260 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : MEDMEM_Grid.hxx +// Author : Edward AGAPOV (eap) +// Module : MED +// $Header$ + +#ifndef MEDMEM_Grid_HeaderFile +#define MEDMEM_Grid_HeaderFile + +#include "MEDMEM_Mesh.hxx" + +// class containing structured mesh data + +class GRID: public MESH +{ + protected: + //-----------------------// + // Fields + //-----------------------// + + // 1. grid type: MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED + med_grid_type _gridType; + + // 2. node coordinates + // For MED_BODY_FITTED MESH::_coordinate is used + + // 2.1. i component array: X for MED_CARTESIAN, R for MED_POLAR + int _iArrayLength; + double* _iArray; + // 2.2. j component array: Y for MED_CARTESIAN, Theta for MED_POLAR + int _jArrayLength; + double* _jArray; + // 2.3. k component array: Z for both MED_CARTESIAN and MED_POLAR + int _kArrayLength; + double* _kArray; + + // 3. flags to know that _coordinates and _connectivity of MESH are filled + bool _is_coordinates_filled; + bool _is_connectivity_filled; + + //-----------------------// + // Protected Methods + //-----------------------// + + CONNECTIVITY * makeConnectivity (const medEntityMesh Entity, + const medGeometryElement Geometry, + const int NbEntities, + const int NbNodes, + int * NodeNumbers); + // creates nodal connectivity + + + // Suppose a READ Driver to do the following except filling _[ijk]Array's + // 1) fill MESH fields: + // * _name + // * _spaceDimension + // * _meshDimension + // * _numberOfNodesFamilies, _numberOfCellsFamilies, ect + // * _familyNode, _familyCell, etc + // * _numberOfNodesGroups, _numberOfCellsGroups, etc + // * _groupNode, _groupCell, etc + // * _ + // 2) create MESH::_coordinate without setting _coordinate->_coordinate and set: + // * _coordinate->_coordinateSystem + // * _coordinate->_coordinateName + // * _coordinate->_coordinateUnit + + + public: + //-----------------------// + // Methods + //-----------------------// + + GRID(); + GRID(const med_grid_type type); + GRID(const GRID &m); + GRID( driverTypes driverType, const string & fileName="",const string & meshName=""); + GRID & operator=(const GRID &m); + virtual ~GRID(); + virtual void init(); + + void fillCoordinates(); + void fillConnectivity(); + // fill _coordinates and _connectivity of MESH if not yet done + + inline void makeUnstructured(); + // fill both coordinates and connectivity of MESH + + void fillMeshAfterRead(); + // fill some fields (_numberOfNodes, etc.) after reading + + void writeUnstructured(int index=0, const string & driverName = ""); + // write a Grid as an Unstructured mesh + + // API Methods returning fields of MESH that are filled while reading. + // So they need not to be redefined + +// string getName() const; +// int getSpaceDimension(); +// int getMeshDimension(); +// string getCoordinatesSystem(); +// int getNumberOfNodes(); +// string * getCoordinatesNames(); +// string * getCoordinatesUnits(); +// int getNumberOfFamilies(medEntityMesh Entity); +// vector getFamilies(medEntityMesh Entity); +// FAMILY* getFamily(medEntityMesh Entity,int i); +// int getNumberOfGroups(medEntityMesh Entity); +// vector getGroups(medEntityMesh Entity); +// GROUP* getGroup(medEntityMesh Entity,int i); + + +// Since a MESH itself knows if it is a GRID, it calls fillConnectivity() +// or fillCoordinates() whenever needed. So no redifinition of the following methods + +// const double * getCoordinates(medModeSwitch Mode); +// COORDINATE * getCoordinateptr(); +// const double getCoordinate(int Number,int Axis); +// int getNumberOfTypes(medEntityMesh Entity); +// medGeometryElement * getTypes(medEntityMesh Entity); +// CELLMODEL * getCellsTypes(medEntityMesh Entity); +// medGeometryElement getElementType(medEntityMesh Entity,int Number) ; +// int getNumberOfElements(medEntityMesh Entity,medGeometryElement Type); +// int getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity) ; +// int * getGlobalNumberingIndex(medEntityMesh Entity); +// int * getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity, medGeometryElement Type); +// int * getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity); +// int * getReverseConnectivity(medConnectivity ConnectivityType); +// int * getReverseConnectivityIndex(medConnectivity ConnectivityType); +// bool existConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity); +// void calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity); +// FIELD* getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) ; +// FIELD* getArea(const SUPPORT * Support) throw (MEDEXCEPTION) ; +// FIELD* getLength(const SUPPORT * Support) throw (MEDEXCEPTION) ; +// FIELD* getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) ; +// FIELD* getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION) ; + + + // Specific GRID methods + + inline int getNodeNumber(const int i, const int j=0, const int k=0); + // return a NODE number by its position in the grid. + // WARNING: be carefull, there is no check that i,j,k are within a good range + // A good range is: 0 <= X < getArrayLength( X_Axis ) + inline int getCellNumber(const int i, const int j=0, const int k=0) ; + // return a CELL number by its position in the grid. + // WARNING: be carefull, there is no check that i,j,k are within a good range + // A good range is: 0 <= X < (getArrayLength( X_Axis )-1) + + int getEdgeNumber(const int Axis, const int i, const int j=0, const int k=0) throw (MEDEXCEPTION) ; + // return an EDGE number by its position in the grid. + // Axis [1,2,3] means one of directions: along i, j or k. + // It selects an edge of ones having same (i,j,k): + // * an EDGE going along given Axis. + // Exception for Axis out of range or when there is no edges in the grid (1D) + // WARNING: be carefull, there is no check that i,j,k are within a good range + // A good range is: + // 0 <= X < (getArrayLength( X_Axis )-1) + // 0 <= X < getArrayLength( NOT_X_Axis ) + + int getFaceNumber(const int Axis, const int i, const int j=0, const int k=0) throw (MEDEXCEPTION) ; + // return a FACE number by its position in the grid. + // Axis [1,2,3] means one of directions: along i, j or k. + // It selects a face of ones having same (i,j,k): + // * a FACE which is normal to given Axis + // Exception for Axis out of range or when there is no faces in the grid (1,2D) + // WARNING: be carefull, there is no check that i,j,k are within a good range + // A good range is: + // 0 <= X < (getArrayLength( NOT_X_Axis )-1) + // 0 <= X < getArrayLength( X_Axis ) + + + void getNodePosition(const int Number, int& i, int& j, int& k) throw (MEDEXCEPTION) ; + void getCellPosition(const int Number, int& i, int& j, int& k) throw (MEDEXCEPTION) ; + void getEdgePosition(const int Number, int& Axis, int& i, int& j, int& k) throw (MEDEXCEPTION) ; + void getFacePosition(const int Number, int& Axis, int& i, int& j, int& k) throw (MEDEXCEPTION) ; + // return position (i,j,k) of an entity #Number + // Axis: [1,2,3], see get*Number for details + // Exception for Number out of range + + + // Access to fields + + inline med_grid_type getGridType() const; + // return MED_CARTESIAN, MED_POLAR or MED_BODY_FITTED + + int getArrayLength( const int Axis ) throw (MEDEXCEPTION); + // return array length. Axis = [1,2,3] meaning [i,j,k], + // exception if Axis out of [1-3] range + + const double getArrayValue (const int Axis, const int i) throw (MEDEXCEPTION) ; + // return i-th array component. Axis = [1,2,3] meaning [i,j,k], + // exception if Axis out of [1 - 3] range + // exception if i is out of range [0 - (getArrayLength(Axis)-1)]; + + // Setting fields + + inline void setGridType(med_grid_type gridType); + + friend class MED_MESH_RDONLY_DRIVER; + friend class MED_MESH_WRONLY_DRIVER; + +}; + + + //----------------------------------// + // Inline Methods Implementation + //----------------------------------// + +inline med_grid_type GRID::getGridType() const +{ + return _gridType; +} +//======================================================================= +//function : getNodeNumber +//purpose : +//======================================================================= + +inline int GRID::getNodeNumber(const int i, const int j, const int k) +{ + return 1 + i + _iArrayLength * j + _iArrayLength * _jArrayLength * k; +} + +//======================================================================= +//function : getCellNumber +//purpose : +//======================================================================= + +inline int GRID::getCellNumber(const int i, const int j, const int k) +{ + return 1 + i + (_iArrayLength-1) * j + (_iArrayLength-1) * (_jArrayLength-1) * k; +} + +//======================================================================= +//function : makeUnstructured +//purpose : fill coordinates and connectivity of MESH +//======================================================================= + +inline void GRID::makeUnstructured() +{ + fillCoordinates(); + fillConnectivity(); +} + +//======================================================================= +//function : setGridType +//purpose : set the _gridType field od the class GRID +//======================================================================= + +inline void GRID::setGridType(med_grid_type gridType) +{ + _gridType = gridType; +} + +#endif diff --git a/src/MEDMEM/MEDMEM_Group.cxx b/src/MEDMEM/MEDMEM_Group.cxx index 030039043..4a883f3a5 100644 --- a/src/MEDMEM/MEDMEM_Group.cxx +++ b/src/MEDMEM/MEDMEM_Group.cxx @@ -1,3 +1,30 @@ +// 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.cxx +// Module : MED + +using namespace std; /* File Group.cxx $Header$ @@ -25,35 +52,61 @@ GROUP & GROUP::operator=(const GROUP &group) return *this; }; -GROUP::GROUP(const string & name, const list & families) +ostream & operator<<(ostream &os, GROUP &myGroup) +{ + os << (SUPPORT) myGroup; + + int numberoffamilies = myGroup.getNumberOfFamilies(); + os << " - Families ("<getName().c_str()< & families) throw (MEDEXCEPTION) { const char * LOC = "GROUP( const string & , const list & ) : " ; BEGIN_OF(LOC); MESSAGE(LOC<getMesh() ; _entity = myFamily->getEntity() ; + bool isOnAllElts = myFamily->isOnAllElements() ; + if ((numberOfFamilies==1)&(isOnAllElts)) + { + _numberOfFamilies = numberOfFamilies; + _isOnAllElts = false ; + _family.resize(_numberOfFamilies) ; + _family[0] = myFamily; + return; + } + else if ((!(numberOfFamilies==1))&(isOnAllElts)) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "building of a GROUP object from several FAMILY, and one of them is on all entities" )) ; + _numberOfGeometricType = myFamily->getNumberOfTypes() ; _geometricType = new medGeometryElement[_numberOfGeometricType]; //_geometricTypeNumber = new int[_numberOfGeometricType] ; _numberOfGaussPoint = new int[_numberOfGeometricType] ; - _numberOfEntities = new int[_numberOfGeometricType] ; - medGeometryElement * geometricType = myFamily->getTypes() ; + _numberOfElements = new int[_numberOfGeometricType] ; + const medGeometryElement * geometricType = myFamily->getTypes() ; //int * geometricTypeNumber = myFamily->getGeometricTypeNumber() ; - int * numberOfGaussPoint = myFamily->getNumberOfGaussPoint() ; + const int * numberOfGaussPoint = myFamily->getNumberOfGaussPoint() ; for (int i=0 ; i<_numberOfGeometricType; i++) { _geometricType[i]= geometricType[i] ; // _geometricTypeNumber[i] = geometricTypeNumber[i] ; _numberOfGaussPoint[i] = numberOfGaussPoint[i] ; - _numberOfEntities[i]=myFamily->getNumberOfElements(geometricType[i]); + _numberOfElements[i]=myFamily->getNumberOfElements(geometricType[i]); } _isOnAllElts = false ; - _totalNumberOfEntities = myFamily->getNumberOfElements(MED_ALL_ELEMENTS) ; + //_totalNumberOfEntities = myFamily->getNumberOfElements(MED_ALL_ELEMENTS) ; _number = new MEDSKYLINEARRAY(*myFamily->getnumber()) ; _numberOfFamilies = families.size(); @@ -69,46 +122,62 @@ GROUP::GROUP(const string & name, const list & families) END_OF(LOC); }; -void GROUP::init(const list & families) +GROUP::GROUP(const GROUP & m):SUPPORT(m) { - const char * LOC = "GROUP::init( const list & ) : " ; + _numberOfFamilies = m._numberOfFamilies; + _family = m._family; +}; + +// void GROUP::init(const list & families) +// { +// const char * LOC = "GROUP::init( const list & ) : " ; - BEGIN_OF(LOC); +// BEGIN_OF(LOC); - FAMILY * myFamily = families.front() ; - _mesh = myFamily->getMesh() ; - _entity = myFamily->getEntity() ; - _numberOfGeometricType = myFamily->getNumberOfTypes() ; - _geometricType = new medGeometryElement[_numberOfGeometricType]; - //_geometricTypeNumber = new int[_numberOfGeometricType] ; - _numberOfGaussPoint = new int[_numberOfGeometricType] ; - _numberOfEntities = new int[_numberOfGeometricType] ; - medGeometryElement * geometricType = myFamily->getTypes() ; - //int * geometricTypeNumber = myFamily->getGeometricTypeNumber() ; - int * numberOfGaussPoint = myFamily->getNumberOfGaussPoint() ; - for (int i=0 ; i<_numberOfGeometricType; i++) { - _geometricType[i]= geometricType[i] ; - // _geometricTypeNumber[i] = geometricTypeNumber[i] ; - _numberOfGaussPoint[i] = numberOfGaussPoint[i] ; - _numberOfEntities[i]=myFamily->getNumberOfElements(geometricType[i]); - } - _isOnAllElts = false ; - _totalNumberOfEntities = myFamily->getNumberOfElements(MED_ALL_ELEMENTS) ; - _number = new MEDSKYLINEARRAY(*myFamily->getnumber()) ; +// FAMILY * myFamily = families.front() ; +// _mesh = myFamily->getMesh() ; + +// _isOnAllElts = myFamily->isOnAllElements() ; + +// SCRUTE(_mesh); + +// SCRUTE(_isOnAllElts); + +// _entity = myFamily->getEntity() ; + +// SCRUTE(_mesh->getNumberOfTypes(_entity)); + +// _numberOfGeometricType = myFamily->getNumberOfTypes() ; +// _geometricType = new medGeometryElement[_numberOfGeometricType]; +// //_geometricTypeNumber = new int[_numberOfGeometricType] ; +// _numberOfGaussPoint = new int[_numberOfGeometricType] ; +// _numberOfElements = new int[_numberOfGeometricType] ; +// medGeometryElement * geometricType = myFamily->getTypes() ; +// //int * geometricTypeNumber = myFamily->getGeometricTypeNumber() ; +// int * numberOfGaussPoint = myFamily->getNumberOfGaussPoint() ; +// for (int i=0 ; i<_numberOfGeometricType; i++) { +// _geometricType[i]= geometricType[i] ; +// // _geometricTypeNumber[i] = geometricTypeNumber[i] ; +// _numberOfGaussPoint[i] = numberOfGaussPoint[i] ; +// _numberOfElements[i]=myFamily->getNumberOfElements(geometricType[i]); +// } +// _isOnAllElts = false ; +// _totalNumberOfEntities = myFamily->getNumberOfElements(MED_ALL_ELEMENTS) ; +// _number = new MEDSKYLINEARRAY(*myFamily->getnumber()) ; - _numberOfFamilies = families.size(); - _family.resize(_numberOfFamilies) ; - list::const_iterator liIni = families.begin() ; - _family[0]=(*liIni); - liIni++; - list::const_iterator li ; - int it = 1 ; - for (li=liIni;li!=families.end();li++) { - blending(*li); - _family[it] = (*li) ; - it++ ; - } +// _numberOfFamilies = families.size(); +// _family.resize(_numberOfFamilies) ; +// list::const_iterator liIni = families.begin() ; +// _family[0]=(*liIni); +// liIni++; +// list::const_iterator li ; +// int it = 1 ; +// for (li=liIni;li!=families.end();li++) { +// blending(*li); +// _family[it] = (*li) ; +// it++ ; +// } - END_OF(LOC); -}; +// END_OF(LOC); +// }; diff --git a/src/MEDMEM/MEDMEM_Group.hxx b/src/MEDMEM/MEDMEM_Group.hxx index 29f0e1f00..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,20 +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(); - GROUP(const string & name, const list & family); + /*! Constructor. */ + GROUP(const string & name, const list & family) throw (MEDEXCEPTION) ; + /*! 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); @@ -34,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.cxx b/src/MEDMEM/MEDMEM_Med.cxx index 85fdccbfe..bc242f80e 100644 --- a/src/MEDMEM/MEDMEM_Med.cxx +++ b/src/MEDMEM/MEDMEM_Med.cxx @@ -1,44 +1,191 @@ +// 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.cxx +// Module : MED + +using namespace std; +# include + # include "MEDMEM_Med.hxx" # include "MEDMEM_STRING.hxx" # include "MEDMEM_Mesh.hxx" +# include "MEDMEM_Grid.hxx" # include "MEDMEM_Field.hxx" # include "MEDMEM_Exception.hxx" # include "utilities.h" -// MED constructors +/*! + Constructor. +*/ MED::MED() { - const char * LOC = "MED::MED() : "; - - MESSAGE(LOC << "Construction..."); - + MESSAGE("MED::MED()"); }; -MED::MED(driverTypes driverType, const string & fileName) { +/*! + Constructor. +*/ +MED::MED(driverTypes driverType, const string & fileName) +{ const char * LOC = "MED::MED(driverTypes driverType, const string & fileName) : "; - int current; + BEGIN_OF(LOC); + + MED_MED_RDONLY_DRIVER * myDriver = new MED_MED_RDONLY_DRIVER(fileName,this) ; + int current = addDriver(*myDriver); + //int current= addDriver(driverType,fileName); - BEGIN_OF(STRING(LOC)); - current = addDriver(driverType,fileName); _drivers[current]->open(); _drivers[current]->readFileStruct(); _drivers[current]->close(); - END_OF(STRING(LOC)); + + END_OF(LOC); }; +/*! + Destructor. +*/ MED::~MED() { + const char * LOC = "MED::~MED() : "; + BEGIN_OF(LOC); + + // Analysis of the object MED + + int index; + + map::const_iterator currentField; + index = 0; + for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) { + if ( (*currentField).first != NULL) index++; + } + + MESSAGE(LOC << " there is(are) " << index << " field(s):"); + for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) { + if ( (*currentField).first != NULL) MESSAGE(" " << ((*currentField).first)->getName().c_str()); + } + + map >::iterator itSupportOnMesh ; + index = 0; + for ( itSupportOnMesh=_support.begin();itSupportOnMesh != _support.end(); itSupportOnMesh++ ) { + map::iterator itSupport ; + for ( itSupport=(*itSupportOnMesh).second.begin();itSupport!=(*itSupportOnMesh).second.end();itSupport++) + index++; + } + + MESSAGE(LOC << " there is(are) " << index << " support(s):"); + + map::const_iterator currentMesh; + index =0; + for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) { + if ( (*currentMesh).second != NULL) + index++; + } + + MESSAGE(LOC << " there is(are) " << index << " meshe(s):"); +// for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) { +// if ( (*currentMesh).second != NULL) +// { +// SCRUTE((*currentMesh).second); + +// string meshName = ((*currentMesh).second)->getName(); + +// MESSAGE(" " << meshName); +// } +// } + + // delete all ? : PG : YES ! + // map::const_iterator currentField; + for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) { + if ( (*currentField).first != NULL) { + // cast in right type to delete it ! + switch ((*currentField).first->getValueType()) { + case MED_INT32 : + // mpv: such recursive destructors call is problematic for current ALLIANCES algorithms + //delete (FIELD*) (*currentField).first ; + break ; + case MED_REEL64 : + // mpv: such recursive destructors call is problematic for current ALLIANCES algorithms + //delete (FIELD*) (*currentField).first ; + break ; + default : + INFOS("Field has type different of int or double, could not destroy its values array !") ; + // mpv: such recursive destructors call is problematic for current ALLIANCES algorithms + //delete (*currentField).first; + } + } + } + // map >::iterator itSupportOnMesh ; + for ( itSupportOnMesh=_support.begin();itSupportOnMesh != _support.end(); itSupportOnMesh++ ) { + map::iterator itSupport ; + for ( itSupport=(*itSupportOnMesh).second.begin();itSupport!=(*itSupportOnMesh).second.end();itSupport++) + ;// mpv: such recursive destructors call is problematic for current ALLIANCES algorithms + //delete (*itSupport).second ; + } + + // map::const_iterator currentMesh; + for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) { + if ( (*currentMesh).second != NULL) + { + if (!((*currentMesh).second)->getIsAGrid()) + ;// mpv: such recursive destructors call is problematic for current ALLIANCES algorithms + //delete (*currentMesh).second; + else + ;// mpv: such recursive destructors call is problematic for current ALLIANCES algorithms + //delete (GRID *) (*currentMesh).second; + } + } + + index =_drivers.size(); + + MESSAGE(LOC << "In this object MED there is(are) " << index << " driver(s):"); + + for (int ind=0; ind < _drivers.size(); ind++ ) + { + SCRUTE(_drivers[ind]); + if ( _drivers[ind] != NULL) delete _drivers[ind]; + } + + + + END_OF(LOC); } ; // ------- Drivers Management Part -MED::INSTANCE_DE MED::inst_med ; -//MED::INSTANCE_DE MED::inst_vtk ; +// Add your new driver instance declaration here (step 3-1) +MED::INSTANCE_DE MED::inst_med ; +MED::INSTANCE_DE MED::inst_vtk ; -const MED::INSTANCE * const MED::instances[] = { &MED::inst_med }; //, &MED::inst_vtk } ; +// Add your new driver instance in the MED instance list (step 3-2) +const MED::INSTANCE * const MED::instances[] = { &MED::inst_med, &MED::inst_vtk }; +/*! + Create the specified driver and return its index reference to path to + read or write methods. +*/ int MED::addDriver(driverTypes driverType, const string & fileName="Default File Name.med") { const char * LOC = "MED::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\") : "; @@ -47,17 +194,48 @@ int MED::addDriver(driverTypes driverType, const string & fileName="Default File BEGIN_OF(LOC); + MESSAGE(LOC << " the file name is " << fileName); driver = instances[driverType]->run(fileName, this) ; - _drivers.push_back(driver); current = _drivers.size()-1; - // _drivers[current]->set... + driver->setId(current); END_OF(LOC); return current; } +/*! + Duplicate the given driver and return its index reference to path to + read or write methods. +*/ +int MED::addDriver(GENDRIVER & driver) { + const char * LOC = "MED::addDriver(GENDRIVER &) : "; + int current; + + BEGIN_OF(LOC); + + SCRUTE(_drivers.size()); + + _drivers.push_back(&driver); -void MED::rmDriver (int index=0) { + SCRUTE(_drivers.size()); + + SCRUTE(_drivers[0]); + SCRUTE(driver); + + current = _drivers.size()-1; + driver.setId(current); + + END_OF(LOC); + return current; + +} + +/*! + Remove the driver referenced by its index. +*/ +void MED::rmDriver (int index/*=0*/) + throw (MED_EXCEPTION) +{ const char * LOC = "MED::rmDriver (int index=0): "; BEGIN_OF(LOC); @@ -73,16 +251,18 @@ void MED::rmDriver (int index=0) { END_OF(LOC); } - -void MED::writeFrom (int index=0) +/*! + ??? to do comment ??? +*/ +void MED::writeFrom (int index/*=0*/) + throw (MED_EXCEPTION) { const char * LOC = "MED::write (int index=0): "; BEGIN_OF(LOC); if (_drivers[index]) { - _drivers[index]->open(); - _drivers[index]->writeFrom(); - _drivers[index]->close(); + // open and close are made by all objects ! + _drivers[index]->writeFrom(); } throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "The index given is invalid, index must be between 0 and |" @@ -92,16 +272,18 @@ void MED::writeFrom (int index=0) END_OF(LOC); }; - -void MED::write (int index=0) +/*! + Write all objects with the driver given by its index. +*/ +void MED::write (int index/*=0*/) + throw (MED_EXCEPTION) { - const char * LOC = "MED::writeAll (int index=0): "; + const char * LOC = "MED::write (int index=0): "; BEGIN_OF(LOC); if (_drivers[index]) { - _drivers[index]->open(); + // open and close are made by the subsequent objects ! _drivers[index]->write(); - _drivers[index]->close(); } else throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) @@ -112,8 +294,17 @@ void MED::write (int index=0) END_OF(LOC); }; +/*! + Parse all the file and generate empty object. -void MED::readFileStruct (int index=0) { + All object must be read explicitly later with their own method read + or use MED::read to read all. + + This method is automaticaly call by constructor with driver information. +*/ +void MED::readFileStruct (int index/*=0*/) + throw (MED_EXCEPTION) +{ const char * LOC = "MED::readFileStruct (int index=0): "; BEGIN_OF(LOC); @@ -131,28 +322,39 @@ void MED::readFileStruct (int index=0) { END_OF(LOC); } -// void MED::read (int index=0) -// { -// const char * LOC = "MED::read (int index=0): "; -// BEGIN_OF(LOC); +/*! + Read all objects in the file specified in the driver given by its index. +*/ +void MED::read (int index/*=0*/) + throw (MED_EXCEPTION) +{ + const char * LOC = "MED::read (int index=0): "; + BEGIN_OF(LOC); -// if (_drivers[index]) -// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) -// << "The index given is invalid, index must be between >0 and < |" -// << _drivers.size()-1 -// ) -// ); -// // GERER LE 0 -// _drivers[index]->open(); -// _drivers[index]->read(); -// _drivers[index]->close(); - -// END_OF(LOC); - -// }; + if (_drivers[index]) { + // open and close are made by all objects ! + SCRUTE(index); + SCRUTE(_drivers[index]); + SCRUTE(&_drivers[index]); + // _drivers[index]->open(); + _drivers[index]->read(); + // _drivers[index]->close(); + } + else + throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) + << "The index given is invalid, index must be between >0 and < |" + << _drivers.size()-1 + ) + ); + END_OF(LOC); + +}; // ------- End Of Drivers Management Part +/*! + Get the number of MESH objects. +*/ int MED::getNumberOfMeshes ( void ) const { const char * LOC = "MED::getNumberOfMeshes ( void ) const : "; @@ -163,19 +365,31 @@ int MED::getNumberOfMeshes ( void ) const { END_OF(LOC); }; +/*! + Get the number of FIELD objects. +*/ int MED::getNumberOfFields ( void ) const { const char * LOC = "MED::getNumberOfFields ( void ) const : "; BEGIN_OF(LOC); - // return _meshName.size(); return _fields.size(); // we get number of field with different name END_OF(LOC); }; -void MED::getMeshNames ( string * meshNames ) const { +/*! + Get the names of all MESH objects. + meshNames is an in/out argument. + + It is a string array of size the + number of MESH objects. It must be allocated before calling + this method. All names are put in it. +*/ +void MED::getMeshNames ( string * meshNames ) const + throw (MED_EXCEPTION) +{ const char * LOC = "MED::getMeshNames ( string * ) const : "; BEGIN_OF(LOC); int meshNamesSize; @@ -202,6 +416,11 @@ void MED::getMeshNames ( string * meshNames ) const { END_OF(LOC); }; +/*! + Get the names of all MESH objects. + + Return a deque object which contain the name of all MESH objects. +*/ deque MED::getMeshNames () const { const char * LOC = "MED::getMeshNames () const : "; @@ -222,14 +441,19 @@ deque MED::getMeshNames () const { return meshNames ; }; -MESH * MED::getMesh ( const string & meshName ) const { + +/*! + Return a reference to the MESH object named meshName. +*/ +MESH * MED::getMesh ( const string & meshName ) const + throw (MED_EXCEPTION) +{ const char * LOC = "MED::getMesh ( const string & meshName ) const : "; BEGIN_OF(LOC); map::const_iterator itMeshes = _meshes.find(meshName); - // if ( itMeshes == _meshName.end() ) if ( itMeshes == _meshes.end() ) throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "There is no known mesh named |" @@ -242,7 +466,13 @@ MESH * MED::getMesh ( const string & meshName ) const { END_OF(LOC); } -MESH * MED::getMesh (const FIELD_ * const field ) const { +/*! + \internal Return a reference to the MESH object associated with + field argument. +*/ +MESH * MED::getMesh (const FIELD_ * const field ) const + throw (MED_EXCEPTION) +{ const char * LOC = "MED::getMesh ( const FIELD * field ) const : "; BEGIN_OF(LOC); @@ -252,7 +482,7 @@ MESH * MED::getMesh (const FIELD_ * const field ) const { if ( itMeshName == _meshName.end() ) throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "There is no known field associated with |" + << "There is no known mesh associated with |" << field << "| pointer" ) ); @@ -273,8 +503,18 @@ MESH * MED::getMesh (const FIELD_ * const field ) const { }; -void MED::getFieldNames ( string * fieldNames ) const { +/*! + Get the names of all FIELD objects. + + fieldNames is an in/out argument. + It is an array of string of size the + number of FIELD objects. It must be allocated before calling + this method. All names are put in it. +*/ +void MED::getFieldNames ( string * fieldNames ) const + throw (MED_EXCEPTION) +{ const char * LOC = "MED::getFieldNames ( string * ) const : "; BEGIN_OF(LOC); @@ -301,6 +541,11 @@ void MED::getFieldNames ( string * fieldNames ) const { }; +/*! + Get the names of all FIELD objects. + + Return a deque object which contain the name of all FIELD objects. +*/ deque MED::getFieldNames () const { const char * LOC = "MED::getFieldNames ( ) const : "; @@ -321,7 +566,13 @@ deque MED::getFieldNames () const { return fieldNames ; }; -deque MED::getFieldIteration (const string & fieldName) const { +/*! + Return a deque which contain all iteration step for the FIELD + identified by its name. +*/ +deque MED::getFieldIteration (const string & fieldName) const + throw (MED_EXCEPTION) +{ const char * LOC = "MED::getFieldIteration ( const string & ) const : "; BEGIN_OF(LOC); @@ -351,7 +602,13 @@ deque MED::getFieldIteration (const string & fieldName) const { return Iteration ; }; -FIELD_ * MED::getField ( const string & fieldName, const int dt=MED_NOPDT, const int it=MED_NOPDT ) const { +/*! + Return a reference to the FIELD object named fieldName with + time step number dt and order number it. +*/ +FIELD_ * MED::getField ( const string & fieldName, const int dt=MED_NOPDT, const int it=MED_NOPDT ) const + throw (MED_EXCEPTION) +{ const char * LOC = "MED::getField ( const string &, const int, const int ) const : "; BEGIN_OF(LOC); @@ -395,8 +652,12 @@ FIELD_ * MED::getField ( const string & fieldName, const int dt=MED_NO // return os; // }; - +/*! + Return a map which contain + foreach entity, a reference to the SUPPORT on all elements. +*/ const map & MED::getSupports(const string & meshName) const + throw (MED_EXCEPTION) { const char * LOC = "MED::getSupports ( const string ) const : "; BEGIN_OF(LOC); @@ -413,7 +674,12 @@ const map & MED::getSupports(const string return (*itSupportOnMesh).second ; } +/*! + Return a reference to the SUPPORT object on all elements of entity + for the MESH named meshName. +*/ SUPPORT * MED::getSupport (const string & meshName,MED_FR::med_entite_maillage entity) const + throw (MED_EXCEPTION) { const char * LOC = "MED::getSupport ( const string, MED_FR::med_entite_maillage ) const : "; BEGIN_OF(LOC); @@ -441,6 +707,10 @@ SUPPORT * MED::getSupport (const string & meshName,MED_FR::med_entite_maillage return (*itSupport).second ; }; +/*! + Temporary method : when all MESH objects are read, this methods + update all SUPPORT objects with the rigth dimension. +*/ void MED::updateSupport () { @@ -456,24 +726,82 @@ void MED::updateSupport () } catch (MEDEXCEPTION & ex) { // entity not defined in mesh -> we remove support on it ! + MESSAGE(LOC<getName()).size() ) + throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrMesh->_name must not be NULL !")); + + _meshes[meshName] = ptrMesh; // if ptrMesh->meshName already exists it is modified - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "WARNING method not yet implemented")); + END_OF(LOC); } -void MED::addField(const FIELD_ * const ptrField) throw (MEDEXCEPTION) +/*! + Add the given FIELD object. MED object control it, + and destroy it, so you must not destroy it after. + + The fieldName is given by the FIELD object. +*/ +void MED::addField( FIELD_ * const ptrField) + throw (MED_EXCEPTION) { const char * LOC = "MED::addField(const FIELD_ * const ptrField): "; + BEGIN_OF(LOC); + + if ( ! ptrField ) + throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrField must not be NULL !")); + + string fieldName; + if ( ! (fieldName = ptrField->getName()).size() ) + throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrField->_name must not be NULL !")); + + SUPPORT * ptrSupport; + if ( ! ( ptrSupport = (SUPPORT * ) ptrField->getSupport()) ) + throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrField->_support must not be NULL !")); + + MESH * ptrMesh; + if ( ! ( ptrMesh = ptrSupport->getMesh()) ) + throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrField->_support->_mesh must not be NULL !")); - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "WARNING method not yet implemented")); + string meshName; + if ( ! ( meshName = ptrMesh->getName()).size() ) + throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrField->_support->_mesh->_name must not be NULL !")); + + DT_IT_ dtIt; + dtIt.dt = ptrField->getIterationNumber(); + dtIt.it = ptrField->getOrderNumber(); + + _fields [fieldName][dtIt] = ptrField; // if it already exists it is replaced + _meshName [ptrField] = meshName; // if it already exists it is replaced + _meshes [meshName] = ptrMesh; // if it already exists it is replaced + + int numberOfTypes = ptrSupport->getNumberOfTypes(); + _support [meshName][ (MED_FR::med_entite_maillage) ptrSupport->getEntity()] = ptrSupport;// if it already exists it is replaced + + + END_OF(LOC); } diff --git a/src/MEDMEM/MEDMEM_Med.hxx b/src/MEDMEM/MEDMEM_Med.hxx index 9bf6753fd..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; @@ -37,22 +67,33 @@ typedef map MAP_DT_IT_; // CONTAINNED WITHIN A FILE OF TYPE GIVEN BY THE PARAMETER // - 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,39 +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); - 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); + int addDriver (GENDRIVER & driver); + 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_MedFieldDriver.hxx b/src/MEDMEM/MEDMEM_MedFieldDriver.hxx index ae247480c..805536bf2 100644 --- a/src/MEDMEM/MEDMEM_MedFieldDriver.hxx +++ b/src/MEDMEM/MEDMEM_MedFieldDriver.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_MedFieldDriver.hxx +// Module : MED + #ifndef MED_FIELD_DRIVER_HXX #define MED_FIELD_DRIVER_HXX @@ -11,13 +37,25 @@ #include "MEDMEM_STRING.hxx" #include "MEDMEM_Exception.hxx" #include "MEDMEM_Unit.hxx" +#include "MEDMEM_Array.hxx" +#include "MEDMEM_Support.hxx" //#include "MEDMEM_Field.hxx" +#include "MEDMEM_Mesh.hxx" //using namespace MED_FR ; template class FIELD; // A QD LA CLASSE MED_ALL_ELEMENTS_DRIVER.... :) pour mutualiser le open ..... avec led _medIdt... + +/*! + + Driver Med for FIELD. + + Generic part : implement open and close methods. + +*/ + template class MED_FIELD_DRIVER : public GENDRIVER { protected: @@ -36,28 +74,66 @@ public : // static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE]; + /*! + Constructor. + */ MED_FIELD_DRIVER():GENDRIVER(), _ptrField((FIELD *)MED_NULL),_medIdt(MED_INVALID), _fieldName(""),_fieldNum(MED_INVALID) {} + /*! + Constructor. + */ MED_FIELD_DRIVER(const string & fileName, FIELD * ptrField, med_mode_acces accessMode) : GENDRIVER(fileName,accessMode), _ptrField((FIELD *) ptrField),_medIdt(MED_INVALID), - _fieldName(""),_fieldNum(MED_INVALID) + _fieldName(fileName),_fieldNum(MED_INVALID) { } - - void open() { + + /*! + Copy constructor. + */ + MED_FIELD_DRIVER(const MED_FIELD_DRIVER & fieldDriver): + GENDRIVER(fieldDriver), + _ptrField(fieldDriver._ptrField), + _medIdt(MED_INVALID), + _fieldName(fieldDriver._fieldName), + _fieldNum(fieldDriver._fieldNum) + { + } + + /*! + Destructor. + */ + virtual ~MED_FIELD_DRIVER() { + } + + void open() throw (MEDEXCEPTION) + { const char * LOC = "MED_FIELD_DRIVER::open() "; BEGIN_OF(LOC); // we must set fieldname before open, because we must find field number in file (if it exist !!!) + if ( _fileName == "" ) + throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) + << "_fileName is |\"\"|, please set a correct fileName before calling open()" + ) + ); MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode); _medIdt = MED_FR::MEDouvrir( (const_cast (_fileName.c_str())),(MED_FR::med_mode_acces) _accessMode); MESSAGE(LOC<<"_medIdt : "<< _medIdt ); - if (_medIdt > 0) _status=MED_OPENED; else { + if (_medIdt > 0) + _status=MED_OPENED; + else { _status = MED_INVALID; + _medIdt = MED_INVALID; + throw MED_EXCEPTION (LOCALIZED( STRING(LOC) + << "Can't open |" << _fileName + << "|, _medIdt : " << _medIdt + ) + ); } END_OF(LOC); @@ -68,7 +144,7 @@ public : MED_FR::med_int err = 0; if (_status == MED_OPENED) { err=MED_FR::MEDfermer(_medIdt); - H5close(); + H5close(); // If we call H5close() all the files are closed. _status = MED_CLOSED; _medIdt = MED_INVALID; MESSAGE(" MED_FIELD_DRIVER::close() : MEDfermer : _medIdt= " << _medIdt ); @@ -79,40 +155,97 @@ public : virtual void write( void ) const = 0 ; virtual void read ( void ) = 0 ; + + /*! + Set the name of the FIELD asked in file. + + It could be different than the name of the FIELD object. + */ void setFieldName(const string & fieldName) ; + /*! + Get the name of the FIELD asked in file. + */ string getFieldName() const ; + +private: + virtual GENDRIVER * copy ( void ) const = 0 ; + }; +/*! + + Driver Med for FIELD : Read only. + + Implement read method. + +*/ + template class MED_FIELD_RDONLY_DRIVER : public virtual MED_FIELD_DRIVER { public : + /*! + Constructor. + */ MED_FIELD_RDONLY_DRIVER():MED_FIELD_DRIVER() {}; + /*! + Constructor. + */ MED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD * ptrField): MED_FIELD_DRIVER(fileName,ptrField,MED_RDONLY) { BEGIN_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD * ptrField)"); END_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD * ptrField)"); } - ~MED_FIELD_RDONLY_DRIVER() { - BEGIN_OF("MED_FIELD_RDONLY_DRIVER::~MED_FIELD_RDONLY_DRIVER()"); - END_OF("MED_FIELD_RDONLY_DRIVER::~MED_FIELD_RDONLY_DRIVER()"); - } + /*! + Copy constructor. + */ + MED_FIELD_RDONLY_DRIVER(const MED_FIELD_RDONLY_DRIVER & fieldDriver): + MED_FIELD_DRIVER(fieldDriver) {}; + + /*! + Destructor. + */ + virtual ~MED_FIELD_RDONLY_DRIVER() {}; // CREER UNE METHODE POUR LIRE LA LISTE DES MAILLAGES ..... - void write( void ) const ; - void read ( void ) ; + /*! + Return a MEDEXCEPTION : it is the read-only driver. + */ + void write( void ) const throw (MEDEXCEPTION) ; + /*! + Read FIELD in the specified file. + */ + void read ( void ) throw (MEDEXCEPTION) ; + +private: + GENDRIVER * copy( void ) const ; + }; +/*! + + Driver Med for FIELD : Write only. + + Implement write method. + +*/ + template class MED_FIELD_WRONLY_DRIVER : public virtual MED_FIELD_DRIVER { public : + /*! + Constructor. + */ MED_FIELD_WRONLY_DRIVER():MED_FIELD_DRIVER() {} + /*! + Constructor. + */ MED_FIELD_WRONLY_DRIVER(const string & fileName, FIELD * ptrField): MED_FIELD_DRIVER(fileName,ptrField,MED_WRONLY) { @@ -120,30 +253,83 @@ public : END_OF("MED_FIELD_WRONLY_DRIVER::MED_FIELD_WRONLY_DRIVER(const string & fileName, const FIELD * ptrField)"); }; - ~MED_FIELD_WRONLY_DRIVER() { } + /*! + Copy constructor. + */ + MED_FIELD_WRONLY_DRIVER(const MED_FIELD_WRONLY_DRIVER & fieldDriver): + MED_FIELD_DRIVER(fieldDriver) {}; + + /*! + Destructor. + */ + virtual ~MED_FIELD_WRONLY_DRIVER() {}; + + /*! + Write FIELD 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: + GENDRIVER * copy( void ) const ; - void write( void ) const ; - void read ( void ) ; }; +/*! + + Driver Med for FIELD : Read write. + - Use read method from MED_FIELD_RDONLY_DRIVER + - Use write method from MED_FIELD_WDONLY_DRIVER + +*/ + template class MED_FIELD_RDWR_DRIVER : public MED_FIELD_RDONLY_DRIVER, public MED_FIELD_WRONLY_DRIVER { public : + /*! + Constructor. + */ MED_FIELD_RDWR_DRIVER():MED_FIELD_DRIVER() {} + /*! + Constructor. + */ MED_FIELD_RDWR_DRIVER(const string & fileName, FIELD * ptrField): MED_FIELD_DRIVER(fileName,ptrField,MED_RDWR) { BEGIN_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD * ptrField)"); + //_accessMode = MED_RDWR ; END_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD * ptrField)"); }; - ~MED_FIELD_RDWR_DRIVER() { } + /*! + Copy constructor. + */ + MED_FIELD_RDWR_DRIVER(const MED_FIELD_RDWR_DRIVER & fieldDriver): + MED_FIELD_DRIVER(fieldDriver) {}; + + /*! + Destructor. + */ + ~MED_FIELD_RDWR_DRIVER() {}; + + /*! + Write FIELD in the specified file. + */ + void write(void) const throw (MEDEXCEPTION) ; + /*! + Read FIELD in the specified file. + */ + void read (void) throw (MEDEXCEPTION) ; + +private: + GENDRIVER * copy( void ) const ; - void write(void) const ; - void read (void) ; }; @@ -208,7 +394,15 @@ template string MED_FIELD_DRIVER::getFieldName() const /*--------------------- RDONLY PART -------------------------------*/ +template GENDRIVER * MED_FIELD_RDONLY_DRIVER::copy(void) const +{ + MED_FIELD_RDONLY_DRIVER * myDriver = + new MED_FIELD_RDONLY_DRIVER(*this); + return myDriver ; +} + template void MED_FIELD_RDONLY_DRIVER::read(void) + throw (MEDEXCEPTION) { const char * LOC = " MED_FIELD_RDONLY_DRIVER::read() " ; BEGIN_OF(LOC); @@ -262,6 +456,9 @@ template void MED_FIELD_RDONLY_DRIVER::read(void) _fieldNum = i ; break ; } + // not found : release memory and search next field ! + delete[] componentName ; + delete[] unitName ; } } @@ -296,7 +493,7 @@ template void MED_FIELD_RDONLY_DRIVER::read(void) // read values for each geometric type in _support int NumberOfTypes = _ptrField->_support->getNumberOfTypes() ; - medGeometryElement *Types = _ptrField->_support->getTypes() ; + const medGeometryElement *Types = _ptrField->_support->getTypes() ; T ** myValues = new (T*)[NumberOfTypes] ; int * NumberOfValues = new int[NumberOfTypes] ; int TotalNumberOfValues = 0 ; @@ -336,6 +533,21 @@ template void MED_FIELD_RDONLY_DRIVER::read(void) _ptrField->getOrderNumber() ) < 0) { // we must do some delete !!! + for(int j=0; j<=i;j++) + delete[] myValues[j]; + delete[] myValues; + delete[] NumberOfValues ; + delete[] ProfilName; + delete[] _ptrField->_componentsTypes ; + delete[] _ptrField->_componentsNames ; + delete[] _ptrField->_componentsUnits ; + delete[] _ptrField->_componentsDescriptions ; + delete[] _ptrField->_MEDComponentsUnits ; + _ptrField->_componentsTypes = NULL ; + _ptrField->_componentsNames = NULL ; + _ptrField->_componentsUnits = NULL ; + _ptrField->_componentsDescriptions = NULL ; + _ptrField->_MEDComponentsUnits = NULL ; _fieldNum = MED_INVALID ; // we have not found right field, so reset the field number throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": ERROR when read value")) ; } @@ -350,21 +562,25 @@ template void MED_FIELD_RDONLY_DRIVER::read(void) _ptrField->_value=new MEDARRAY(numberOfComponents,TotalNumberOfValues,MED_EN::MED_NO_INTERLACE); MEDARRAY * Values = _ptrField->_value ; // create by constructor ??? - // check if dimensions are right - if (Values->getLeadingValue() != numberOfComponents) - throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": leading dimension are false : "<getLeadingValue()<<" and "<getLengthValue() != TotalNumberOfValues) - throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": length dimension are false : "<getLengthValue()<<" and "<getLeadingValue() != numberOfComponents) + // throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": leading dimension are false : "<getLeadingValue()<<" and "<getLengthValue() != TotalNumberOfValues) + // throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": length dimension are false : "<getLengthValue()<<" and "<getI(MED_NO_INTERLACE,i+1) ; - int Count = 0 ; + //T * ValuesT = Values->getRow(i+1) ; + int Count = 1 ; for (int j=0; j_numberOfValues+=NumberOf; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!! int offset = NumberOf*i ; for (int k=0 ; ksetIJ(Count,i+1,myValue[k+offset]); + SCRUTE(Count); + SCRUTE(Values->getIJ(Count,i+1)); Count++; } } @@ -374,23 +590,36 @@ template void MED_FIELD_RDONLY_DRIVER::read(void) delete[] myValues[j] ; delete[] myValues ; delete[] NumberOfValues ; + + _ptrField->_isRead = true ; } + END_OF(LOC); } template void MED_FIELD_RDONLY_DRIVER::write( void ) const + throw (MEDEXCEPTION) { throw MEDEXCEPTION("MED_FIELD_RDONLY_DRIVER::write : Can't write with a RDONLY driver !"); } /*--------------------- WRONLY PART -------------------------------*/ +template GENDRIVER * MED_FIELD_WRONLY_DRIVER::copy(void) const +{ + MED_FIELD_WRONLY_DRIVER * myDriver = + new MED_FIELD_WRONLY_DRIVER(*this); + return myDriver ; +} + template void MED_FIELD_WRONLY_DRIVER::read (void) + throw (MEDEXCEPTION) { - throw MEDEXCEPTION("MED_FIELD_WRONLY_DRIVER::write : Can't read with a WRONLY driver !"); + throw MEDEXCEPTION("MED_FIELD_WRONLY_DRIVER::read : Can't read with a WRONLY driver !"); } template void MED_FIELD_WRONLY_DRIVER::write(void) const + throw (MEDEXCEPTION) { const char * LOC = "MED_FIELD_WRONLY_DRIVER::write(void) const " ; BEGIN_OF(LOC); @@ -402,8 +631,8 @@ template void MED_FIELD_WRONLY_DRIVER::write(void) const string component_name(component_count*MED_TAILLE_PNOM,' ') ; string component_unit(component_count*MED_TAILLE_PNOM,' ') ; - string * listcomponent_name=_ptrField->getComponentsNames() ; - string * listcomponent_unit=_ptrField->getMEDComponentsUnits() ; + const string * listcomponent_name=_ptrField->getComponentsNames() ; + const string * listcomponent_unit=_ptrField->getMEDComponentsUnits() ; int length ; for (int i=0; i < component_count ; i++) { length = min(MED_TAILLE_PNOM,(int)listcomponent_name[i].size()); @@ -495,8 +724,8 @@ template void MED_FIELD_WRONLY_DRIVER::write(void) const // on boucle sur tout les types pour ecrire les tableaux de valeur int NumberOfType = mySupport->getNumberOfTypes() ; int Index = 1 ; - medGeometryElement * Types = mySupport->getTypes() ; - int * NumberOfGaussPoint = mySupport->getNumberOfGaussPoint() ; + const medGeometryElement * Types = mySupport->getTypes() ; + const int * NumberOfGaussPoint = mySupport->getNumberOfGaussPoint() ; for (int i=0;igetNumberOfElements(Types[i]) ; @@ -510,7 +739,7 @@ template void MED_FIELD_WRONLY_DRIVER::write(void) const MESSAGE(" "<<_ptrField->getOrderNumber()); MESSAGE("MEDchampEcr :"<getValueI(MED_EN::MED_FULL_INTERLACE,Index) ; + const T * value = _ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ; err=MED_FR::MEDchampEcr(_medIdt, const_cast ( MeshName.c_str()) , //( string(mesh_name).resize(MED_TAILLE_NOM).c_str()) const_cast ( (_ptrField->getName()).c_str()), @@ -537,7 +766,15 @@ template void MED_FIELD_WRONLY_DRIVER::write(void) const /*--------------------- RDWR PART -------------------------------*/ +template GENDRIVER * MED_FIELD_RDWR_DRIVER::copy(void) const +{ + MED_FIELD_RDWR_DRIVER * myDriver = + new MED_FIELD_RDWR_DRIVER(*this); + return myDriver ; +} + template void MED_FIELD_RDWR_DRIVER::write(void) const + throw (MEDEXCEPTION) { BEGIN_OF("MED_FIELD_RDWR_DRIVER::write(void)"); MED_FIELD_WRONLY_DRIVER::write(); @@ -545,6 +782,7 @@ template void MED_FIELD_RDWR_DRIVER::write(void) const } template void MED_FIELD_RDWR_DRIVER::read (void) + throw (MEDEXCEPTION) { BEGIN_OF("MED_FIELD_RDWR_DRIVER::read(void)"); MED_FIELD_RDONLY_DRIVER::read(); diff --git a/src/MEDMEM/MEDMEM_MedMedDriver.cxx b/src/MEDMEM/MEDMEM_MedMedDriver.cxx index edb9ef762..6b7d09332 100644 --- a/src/MEDMEM/MEDMEM_MedMedDriver.cxx +++ b/src/MEDMEM/MEDMEM_MedMedDriver.cxx @@ -1,3 +1,30 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_MedMedDriver.cxx +// Module : MED + +using namespace std; # include # include "MEDMEM_MedMedDriver.hxx" @@ -5,6 +32,7 @@ # include "MEDMEM_DriversDef.hxx" # include "MEDMEM_Mesh.hxx" +# include "MEDMEM_Grid.hxx" # include "MEDMEM_Field.hxx" // EN ATTENDANT L'utilisation de MedFieldDriver.hxx ds Field.hxx # include "MEDMEM_MedFieldDriver.hxx" @@ -15,42 +43,78 @@ using namespace MED_FR; MED_MED_DRIVER::MED_MED_DRIVER(): GENDRIVER(), - _ptrMed((MED * const)MED_NULL), - _medIdt(MED_INVALID) + _ptrMed((MED * const)MED_NULL),_medIdt(MED_INVALID) {} MED_MED_DRIVER::MED_MED_DRIVER(const string & fileName, MED * const ptrMed): GENDRIVER(fileName,MED_EN::MED_RDWR), _ptrMed(ptrMed), _medIdt(MED_INVALID) -{} +{ + _ptrMed->addDriver(*this); // The specific MED driver id is set within the addDriver method. +} MED_MED_DRIVER::MED_MED_DRIVER(const string & fileName, MED * const ptrMed, MED_EN::med_mode_acces accessMode): GENDRIVER(fileName,accessMode), _ptrMed(ptrMed), _medIdt(MED_INVALID) -{} - +{ +} //REM : As t'on besoin du champ _status : _medIdt <-> _status ? Oui +MED_MED_DRIVER::MED_MED_DRIVER(const MED_MED_DRIVER & driver): + GENDRIVER(driver), + _ptrMed(driver._ptrMed), + _medIdt(MED_INVALID) +{ +} + +MED_MED_DRIVER::~MED_MED_DRIVER() +{ + MESSAGE("MED_MED_DRIVER::~MED_MED_DRIVER() has been destroyed"); +} + +// GENDRIVER * MED_MED_DRIVER::copy(void) const +// { +// return new MED_MED_DRIVER(*this) ; +// } +void MED_MED_DRIVER::read() +{ +} +void MED_MED_DRIVER::readFileStruct() +{ +} +void MED_MED_DRIVER::write() const +{ +} +GENDRIVER * MED_MED_DRIVER::copy(void) const +{ +} +void MED_MED_DRIVER::writeFrom() const +{ +} + + -void MED_MED_DRIVER::open() { +void MED_MED_DRIVER::open() + throw (MEDEXCEPTION) +{ const char * LOC ="MED_MED_DRIVER::open() : "; BEGIN_OF(LOC); // REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE - if ( _medIdt != MED_INVALID ) - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "_medIdt is already in use, please close the file |" - << _fileName << "| before calling open()" - ) - ); +// if ( _medIdt != MED_INVALID ) +// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) +// << "_medIdt is already in use, please close the file |" +// << _fileName << "| before calling open()" +// ) +// ); - if ( _status != MED_CLOSED ) - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "_status is closed, please close the file |" - << _fileName << "| before calling open()" - ) - ); +// if ( _status != MED_CLOSED ) +// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) +// << "_status is closed, please close the file |" +// << _fileName << "| before calling open()" +// ) +// ); if ( _fileName == "" ) throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) @@ -58,9 +122,12 @@ void MED_MED_DRIVER::open() { ) ); + MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode); _medIdt = MEDouvrir( (const_cast (_fileName.c_str())), (MED_FR::med_mode_acces) _accessMode); + MESSAGE(LOC<<" _medIdt = "<<_medIdt); - if (_medIdt > 0) _status=MED_OPENED; + if (_medIdt > 0) + _status=MED_OPENED; else { _status = MED_CLOSED; _medIdt = MED_INVALID; @@ -70,45 +137,74 @@ void MED_MED_DRIVER::open() { ) ); } - + END_OF(LOC); } -void MED_MED_DRIVER::close() { +void MED_MED_DRIVER::close() +{ MED_FR::med_int err = 0; const char * LOC = "MED_MED_DRIVER::close() : "; - if ( _status == MED_CLOSED) - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |" - << _fileName << "| is already closed" - ) - ); +// if ( _status == MED_CLOSED) +// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |" +// << _fileName << "| is already closed" +// ) +// ); - if ( _medIdt == MED_INVALID ) - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_medIdt invalid, but the file |" - << _fileName << "| seems to be openned !" - ) - ); +// if ( _medIdt == MED_INVALID ) +// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_medIdt invalid, but the file |" +// << _fileName << "| seems to be openned !" +// ) +// ); + + if ( _medIdt != MED_INVALID ) + err=MEDfermer(_medIdt); - err=MEDfermer(_medIdt); +// if (err != MED_VALID) +// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |" +// << _fileName << "| couldn't be closed" +// ) +// ); _status = MED_CLOSED; _medIdt = MED_INVALID; - - if (err != MED_VALID) - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |" - << _fileName << "| couldn't be closed" - ) - ); - + END_OF(LOC); } +// ------------- Read Only Part -------------- + +MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER():MED_MED_DRIVER() +{ +} + +MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed): + MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_RDONLY) +{ + MESSAGE("MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed) Constructeur read only"); +} + +MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const MED_MED_RDONLY_DRIVER & driver): + MED_MED_DRIVER(driver) +{ +} + +MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER() +{ + MESSAGE("MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER() has been destroyed"); +} + +GENDRIVER * MED_MED_RDONLY_DRIVER::copy(void) const +{ + return new MED_MED_RDONLY_DRIVER(*this) ; +} -void MED_MED_DRIVER::readFileStruct( void ) +void MED_MED_RDONLY_DRIVER::readFileStruct( void ) + throw (MEDEXCEPTION) { const char * LOC = "MED_MED_DRIVER::readFileStruct() : "; int err,i,j; @@ -135,6 +231,16 @@ void MED_MED_DRIVER::readFileStruct( void ) MESH_ENTITIES::const_iterator currentEntity; for (i=1;i<=numberOfMeshes;i++) { + + // find out if the mesh is a Grid + + int isAGrid = false; + MED_FR::med_grid_type type; + + err = MEDgridInfo (_medIdt, i, &isAGrid, &type); + if (err != MED_VALID) + throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "error in MEDgridInfo()") ); + err = MEDmaaInfo(_medIdt, i ,meshName, &meshDim) ; if (err != MED_VALID) throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": can't get information about the mesh n°" @@ -143,19 +249,54 @@ void MED_MED_DRIVER::readFileStruct( void ) ); MESSAGE(LOC<<": Mesh n°"<setMeshName(meshName); - ptrMesh->addDriver(*_ptrDriver); - _ptrMed->_meshes[meshName] = ptrMesh; + if (isAGrid) + ptrMesh = new GRID((MED_EN::med_grid_type) type); + else + ptrMesh = new MESH(); + + //MED_MESH_RDWR_DRIVER * _ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh); + MED_EN::med_mode_acces myMode = getAccessMode(); + MED_MESH_DRIVER * ptrDriver ; + switch (myMode) { + case MED_EN::MED_LECT: + ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh); + break ; + case MED_EN::MED_REMP: + ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh); + break ; + case MED_EN::MED_ECRI: // should never append !! + ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh); + break; + default: + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !")); + } + ptrDriver->setId ( getId() ); + ptrDriver->setMeshName ( meshName ); + ptrMesh->addDriver(*ptrDriver); + delete ptrDriver ; + + if (isAGrid) + _ptrMed->_meshes[meshName] = (MESH *) ptrMesh; + else + _ptrMed->_meshes[meshName] = ptrMesh; + + ptrMesh->setName(meshName); + + SCRUTE(ptrMesh); + + MESSAGE(LOC<<"is" << (isAGrid ? "" : " NOT") << " a GRID and its name is "<getName()); + // we create all global support (for each entity type : for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) { string supportName="SupportOnAll_" ; supportName+=entNames[(MED_FR::med_entite_maillage)(*currentEntity).first] ; - (_ptrMed->_support)[meshName][(MED_FR::med_entite_maillage)(*currentEntity).first]=new SUPPORT(ptrMesh,supportName,(MED_EN::medEntityMesh) (*currentEntity).first) ; + //(_ptrMed->_support)[meshName][(MED_FR::med_entite_maillage)(*currentEntity).first]=new SUPPORT(ptrMesh,supportName,(MED_EN::medEntityMesh) (*currentEntity).first) ; + SUPPORT* mySupport = new SUPPORT() ; + mySupport->setName(supportName); + mySupport->setMesh(ptrMesh); + mySupport->setEntity((MED_EN::medEntityMesh) (*currentEntity).first); + mySupport->setAll(true); + (_ptrMed->_support)[meshName][(MED_FR::med_entite_maillage)(*currentEntity).first] = mySupport ; } } } @@ -316,7 +457,21 @@ void MED_MED_DRIVER::readFileStruct( void ) ((FIELD*) ptrField)->setNumberOfComponents(numberOfComponents); ((FIELD*) ptrField)->setName(fieldName) ; //provisoire, pour debug MESSAGE("#### SET NAME in FIELD : "< (_fileName, (FIELD *) ptrField); + + MED_EN::med_mode_acces myMode = getAccessMode(); + switch (myMode) { + case MED_EN::MED_LECT: + ptrDriver = new MED_FIELD_RDONLY_DRIVER(_fileName, (FIELD *)ptrField); + break ; + case MED_EN::MED_REMP: + ptrDriver = new MED_FIELD_RDWR_DRIVER(_fileName, (FIELD *)ptrField); + break ; + case MED_EN::MED_ECRI: // should never append !! + ptrDriver = new MED_FIELD_RDONLY_DRIVER(_fileName, (FIELD *)ptrField); + break; + default: + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !")); + } break; } case MED_FR::MED_REEL64 : { @@ -327,7 +482,20 @@ void MED_MED_DRIVER::readFileStruct( void ) ((FIELD*) ptrField)->setName(fieldName) ; //provisoire, pour debug MESSAGE("#### SET NAME in FIELD : "<(_fileName, (FIELD *) ptrField); + MED_EN::med_mode_acces myMode = getAccessMode(); + switch (myMode) { + case MED_EN::MED_LECT: + ptrDriver = new MED_FIELD_RDONLY_DRIVER(_fileName, (FIELD *)ptrField); + break ; + case MED_EN::MED_REMP: + ptrDriver = new MED_FIELD_RDWR_DRIVER(_fileName, (FIELD *)ptrField); + break ; + case MED_EN::MED_ECRI: // should never append !! + ptrDriver = new MED_FIELD_RDONLY_DRIVER(_fileName, (FIELD *)ptrField); + break; + default: + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !")); + } break; } default : { @@ -349,15 +517,16 @@ void MED_MED_DRIVER::readFileStruct( void ) MESSAGE("timeStepNumber :"<setIterationNumber ( timeStepNumber); // A ajouter dans la classe FIELD ptrField->setOrderNumber ( orderNumber); - ptrField->setTime ( timeStep); + ptrField->setTime ( timeStep); // Create a driver for this (field n°dt,n°it) - + ptrDriver->setId ( getId() ); MESSAGE("###### ptrDriver->setFieldName : #"<setFieldName(fieldName); - ptrField->addDriver(*ptrDriver); - + // driver is duplicated : remove it + delete ptrDriver; + DT_IT_ dtIt; dtIt.dt = timeStepNumber; dtIt.it = orderNumber; @@ -382,17 +551,88 @@ void MED_MED_DRIVER::readFileStruct( void ) } -void MED_MED_DRIVER::read( void ) { - +// This method ask the drivers of all MESH/FIELD objects created from this MED driver +// to read themselves +void MED_MED_RDONLY_DRIVER::read( void ) + throw (MEDEXCEPTION) // from objects method read ! +{ const char * LOC = "MED_MED_DRIVER::read() : "; BEGIN_OF(LOC); - MESSAGE("METHODE PAS ENCORE IMPLEMENTEE !!! "); + + const map & _meshes = const_cast& > (_ptrMed->_meshes); + map::const_iterator currentMesh; + + const map & _meshName = const_cast& > (_ptrMed->_meshName); + map::const_iterator currentField; + + for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) + (*currentMesh).second->read(*this); + //(*currentMesh).second->read(); // default reader, from readFileStruct + + // PROVISOIRE + _ptrMed->updateSupport() ; + + for ( currentField =_meshName.begin(); currentField != _meshName.end(); currentField++ ) + (*currentField).first->read(*this); + //(*currentField).first->read(); // default reader, from readFileStruct + END_OF(LOC); } -void MED_MED_DRIVER::writeFrom( void) const { - +void MED_MED_RDONLY_DRIVER::write(void) const + throw (MEDEXCEPTION) +{ + throw MEDEXCEPTION("MED_MED_RDONLY_DRIVER::write : Can't write with a RDONLY driver !"); +} + +void MED_MED_RDONLY_DRIVER::writeFrom(void) const + throw (MEDEXCEPTION) +{ + throw MEDEXCEPTION("MED_MED_RDONLY_DRIVER::writeFrom : Can't write with a RDONLY driver !"); +} + +// ------------- Write Only Part -------------- + +MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER():MED_MED_DRIVER() +{ +} + +MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed): + MED_MED_DRIVER(fileName,ptrMed) +{} + +MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const MED_MED_WRONLY_DRIVER & driver): + MED_MED_DRIVER(driver) +{} + +MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER() +{ + MESSAGE("MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER() has been destroyed"); +} + +GENDRIVER * MED_MED_WRONLY_DRIVER::copy(void) const +{ + return new MED_MED_WRONLY_DRIVER(*this) ; +} + +void MED_MED_WRONLY_DRIVER::read(void) + throw (MEDEXCEPTION) +{ + throw MEDEXCEPTION("MED_MED_WRONLY_DRIVER::read : Can't read with a WRONLY driver !"); +} + +void MED_MED_WRONLY_DRIVER::readFileStruct(void) + throw (MEDEXCEPTION) +{ + throw MEDEXCEPTION("MED_MED_WRONLY_DRIVER::read : Can't read with a WRONLY driver !"); +} + +// This method ask the drivers of all MESH/FIELD objects created from this MED driver +// to write themselves +void MED_MED_WRONLY_DRIVER::writeFrom( void) const + throw (MEDEXCEPTION) //from object method write ! +{ const char * LOC = "MED_MED_DRIVER::writeFrom() : "; BEGIN_OF(LOC); @@ -406,14 +646,11 @@ void MED_MED_DRIVER::writeFrom( void) const { for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) { try { (*currentMesh).second->write(*this); - // A CREER pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id + // On utilise pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id } catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) { continue; } - // catch (const MED_EXCEPTION & ex) { - // throw ex; // DOIT-ON CREER UNE NOUVELLE EXCEPTION AVEC UN MESSAGE INDIQUANT LA PILE - // } } for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) { @@ -429,110 +666,94 @@ void MED_MED_DRIVER::writeFrom( void) const { } -void MED_MED_DRIVER::write(void ) const { - +void MED_MED_WRONLY_DRIVER::write(void ) const + throw (MEDEXCEPTION) // from object method write ! +{ const char * LOC = "MED_MED_DRIVER::write() : "; + int current; BEGIN_OF(LOC); - // BCLE SUR LES DRIVERS AVEC APPELS WriteFrom - END_OF(LOC); + // BCLE SUR LES OBJETS AVEC AJOUT DE DRIVER ET APPELS write -} + const map & _meshes = const_cast& > (_ptrMed->_meshes); + map::const_iterator currentMesh; -MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed): - MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_RDONLY) -{ - MESSAGE("MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed) Constructeur read only"); -} + const map & _meshName = const_cast& > (_ptrMed->_meshName); + map::const_iterator currentField; + + for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) { + //current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName); + current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName,(*currentMesh).second->getName()); + // put right _id in Mesh driver (same as this._id) + (*currentMesh).second->_drivers[current]->setId( getId() ); + //(*currentMesh).second->write(current) ; + } -void MED_MED_RDONLY_DRIVER::open() { - BEGIN_OF("MED_MED_RDONLY_DRIVER::open()"); - MED_MED_DRIVER::open(); - END_OF("MED_MED_RDONLY_DRIVER::open()"); -} + for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) { + //current = (*currentField).first->addDriver(MED_DRIVER,_fileName); + current = (*currentField).first->addDriver(MED_DRIVER,_fileName,(*currentField).first->getName()); + // put right _id in Field driver (same as this._id) + (*currentField).first->_drivers[current]->setId( getId() ); + //(*currentField).first->write(current) ; + } -void MED_MED_RDONLY_DRIVER::close() { - BEGIN_OF("MED_MED_RDONLY_DRIVER::close()"); - MED_MED_DRIVER::close(); - END_OF("MED_MED_RDONLY_DRIVER::clode()"); -} + // that's work, but it is more efficenty to write directly when we had driver, no ? + writeFrom(); + + END_OF(LOC); -void MED_MED_RDONLY_DRIVER::read(void) { - BEGIN_OF("MED_MED_RDONLY_DRIVER::read(void)"); - MED_MED_DRIVER::read(); - END_OF("MED_MED_RDONLY_DRIVER::read(void)"); } -void MED_MED_RDONLY_DRIVER::readFileStruct(void) { - BEGIN_OF("MED_MED_RDONLY_DRIVER::readFileStruct(void)"); - MED_MED_DRIVER::readFileStruct(); - END_OF("MED_MED_RDONLY_DRIVER::readFileStruct(void)"); -} +// ------------- Read Write Part -------------- -MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed): - MED_MED_DRIVER(fileName,ptrMed) +MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER() {} -void MED_MED_WRONLY_DRIVER::open() { - BEGIN_OF("MED_MED_WRONLY_DRIVER::open()"); - MED_MED_DRIVER::open(); - END_OF("MED_MED_WRONLY_DRIVER::open()"); -} - -void MED_MED_WRONLY_DRIVER::close() { - BEGIN_OF("MED_MED_WRONLY_DRIVER::close()"); - MED_MED_DRIVER::close(); - END_OF("MED_MED_WRONLY_DRIVER::clode()"); -} - -void MED_MED_WRONLY_DRIVER::write(void) const { - BEGIN_OF("MED_MED_WRONLY_DRIVER::write(void) const"); - MED_MED_DRIVER::write(); - END_OF("MED_MED_WRONLY_DRIVER::write(void) const"); -} - -void MED_MED_WRONLY_DRIVER::writeFrom(void) const { - BEGIN_OF("MED_MED_WRONLY_DRIVER::writeFrom(void) const"); - MED_MED_DRIVER::writeFrom(); - END_OF("MED_MED_WRONLY_DRIVER::writeFrom(void) const"); -} - MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER(const string & fileName, MED * const ptrMed): MED_MED_DRIVER(fileName,ptrMed) {} -void MED_MED_RDWR_DRIVER::open() { - BEGIN_OF("MED_MED_RDWR_DRIVER::open()"); - MED_MED_DRIVER::open(); - END_OF("MED_MED_RDWR_DRIVER::open()"); +MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER(const MED_MED_RDWR_DRIVER & driver): + MED_MED_DRIVER(driver) +{} + +MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER() { + MESSAGE("MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER() has been destroyed"); } -void MED_MED_RDWR_DRIVER::close() { - BEGIN_OF("MED_MED_RDWR_DRIVER::close()"); - MED_MED_DRIVER::close(); - END_OF("MED_MED_RDWR_DRIVER::clode()"); +GENDRIVER * MED_MED_RDWR_DRIVER::copy(void) const +{ + return new MED_MED_RDWR_DRIVER(*this) ; } -void MED_MED_RDWR_DRIVER::read(void) { +void MED_MED_RDWR_DRIVER::read(void) + throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::read() +{ BEGIN_OF("MED_MED_RDWR_DRIVER::read(void)"); MED_MED_RDONLY_DRIVER::read(); END_OF("MED_MED_RDWR_DRIVER::read(void)"); } -void MED_MED_RDWR_DRIVER::readFileStruct(void) { +void MED_MED_RDWR_DRIVER::readFileStruct(void) + throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::readFileStruct() +{ BEGIN_OF("MED_MED_RDWR_DRIVER::readFileStruct(void)"); MED_MED_RDONLY_DRIVER::readFileStruct(); END_OF("MED_MED_RDWR_DRIVER::readFileStruct(void)"); } -void MED_MED_RDWR_DRIVER::write(void) const { +void MED_MED_RDWR_DRIVER::write(void) const + throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::write() +{ BEGIN_OF("MED_MED_RDWR_DRIVER::write(void) const"); MED_MED_WRONLY_DRIVER::write(); END_OF("MED_MED_RDWR_DRIVER::write(void) const"); } -void MED_MED_RDWR_DRIVER::writeFrom(void) const { +void MED_MED_RDWR_DRIVER::writeFrom(void) const + throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::writeFrom(); +{ BEGIN_OF("MED_MED_RDWR_DRIVER::writeFrom(void) const"); MED_MED_WRONLY_DRIVER::writeFrom(); END_OF("MED_MED_RDWR_DRIVER::writeFrom(void) const"); diff --git a/src/MEDMEM/MEDMEM_MedMedDriver.hxx b/src/MEDMEM/MEDMEM_MedMedDriver.hxx index 33a688660..db6375d0c 100644 --- a/src/MEDMEM/MEDMEM_MedMedDriver.hxx +++ b/src/MEDMEM/MEDMEM_MedMedDriver.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_MedMedDriver.hxx +// Module : MED + #ifndef MED_MED_DRIVER_HXX #define MED_MED_DRIVER_HXX @@ -16,6 +42,14 @@ class MESH; class FIELD_; class MED; +/*! + + Driver Med for MED. + + Generic part : implement open and close methods. + +*/ + // This driver pilots within a MED class read/write accesses of fields/meshes class MED_MED_DRIVER : public GENDRIVER { @@ -28,82 +62,207 @@ protected: // MED_MED_DRIVER(); public : + /*! + Constructor. + */ MED_MED_DRIVER(); - + /*! + Constructor. + */ MED_MED_DRIVER(const string & fileName, MED * const ptrMed); - + /*! + Constructor. + */ MED_MED_DRIVER(const string & fileName, MED * const ptrMed, MED_EN::med_mode_acces accessMode); + // OPERATEUR DE RECOPIE AVEC _medIdt ?? + /*! + Copy constructor. + */ + MED_MED_DRIVER(const MED_MED_DRIVER & driver); - void open(); + /*! + Destructor. + */ + virtual ~MED_MED_DRIVER() ; + + void open() throw (MEDEXCEPTION) ; void close(); + //virtual void write ( void ) const = 0 ; virtual void write ( void ) const ; - virtual void writeFrom ( void ) const ; - virtual void read ( void ) ; + //virtual void writeFrom ( void ) const = 0 ; + virtual void writeFrom ( void ) const ; + //virtual void read ( void ) = 0 ; + virtual void read ( void ) ; + //virtual void readFileStruct ( void ) = 0 ; virtual void readFileStruct ( void ) ; +private: + //virtual GENDRIVER * copy ( void ) const = 0 ; + virtual GENDRIVER * copy ( void ) const ; + }; +/*! + + Driver Med for MED : Read only. + + Implement read method. + +*/ + class MED_MED_RDONLY_DRIVER : public virtual MED_MED_DRIVER { public : - MED_MED_RDONLY_DRIVER():MED_MED_DRIVER(){}; - + /*! + Constructor. + */ + MED_MED_RDONLY_DRIVER(); + /*! + Constructor. + */ MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed); + /*! + Copy constructor. + */ + MED_MED_RDONLY_DRIVER(const MED_MED_RDONLY_DRIVER & driver); - ~MED_MED_RDONLY_DRIVER() { - MESSAGE("MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER() has been destroyed"); - } + /*! + Destructor. + */ + virtual ~MED_MED_RDONLY_DRIVER(); - void open(); - void close(); + /*! + Return a MEDEXCEPTION : it is the read-only driver. + */ + void write ( void ) const throw (MEDEXCEPTION) ; + /*! + Return a MEDEXCEPTION : it is the read-only driver. + */ + void writeFrom ( void ) const throw (MEDEXCEPTION) ; + /*! + Read all from the file. + */ + void read ( void ) throw (MEDEXCEPTION); + /*! + Read only table of contents of the file. + + All objects are created but there values are not read. + */ + void readFileStruct ( void ) throw (MEDEXCEPTION) ; + +private: + virtual GENDRIVER * copy ( void ) const ; - void read ( void ) ; - void readFileStruct ( void ) ; }; +/*! + + Driver Med for MED : Write only. + + Implement write method. + +*/ + class MED_MED_WRONLY_DRIVER : public virtual MED_MED_DRIVER { public : - MED_MED_WRONLY_DRIVER():MED_MED_DRIVER(){}; - + /*! + Constructor. + */ + MED_MED_WRONLY_DRIVER(); + /*! + Constructor. + */ MED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed); + /*! + Copy constructor. + */ + MED_MED_WRONLY_DRIVER(const MED_MED_WRONLY_DRIVER & driver); - ~MED_MED_WRONLY_DRIVER() { - MESSAGE("MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER() has been destroyed"); - } + /*! + Destructor. + */ + virtual ~MED_MED_WRONLY_DRIVER(); - void open(); - void close(); + /*! + Write all in file. + */ + void write ( void ) const throw (MEDEXCEPTION); + /*! + Write only objects created from this MED driver in file. + */ + void writeFrom ( void ) const throw (MEDEXCEPTION); + /*! + Return a MEDEXCEPTION : it is the write-only driver. + */ + void read ( void ) throw (MEDEXCEPTION) ; + /*! + Return a MEDEXCEPTION : it is the write-only driver. + */ + void readFileStruct ( void ) throw (MEDEXCEPTION) ; + +private: + virtual GENDRIVER * copy ( void ) const ; - void write ( void ) const ; - void writeFrom ( void ) const ; }; +/*! + + Driver Med for MED : Read write. + - Use read method from MED_MED_RDONLY_DRIVER + - Use write method from MED_MED_WDONLY_DRIVER + +*/ + class MED_MED_RDWR_DRIVER : public virtual MED_MED_RDONLY_DRIVER, - public virtual MED_MED_WRONLY_DRIVER, - public virtual MED_MED_DRIVER + public virtual MED_MED_WRONLY_DRIVER { public : - MED_MED_RDWR_DRIVER():MED_MED_DRIVER(){}; - + /*! + Constructor. + */ + MED_MED_RDWR_DRIVER(); + /*! + Constructor. + */ MED_MED_RDWR_DRIVER(const string & fileName, MED * const ptrMed); + /*! + Copy constructor. + */ + MED_MED_RDWR_DRIVER(const MED_MED_RDWR_DRIVER & driver); - ~MED_MED_RDWR_DRIVER() { - MESSAGE("MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER() has been destroyed"); - } + /*! + Destructor. + */ + ~MED_MED_RDWR_DRIVER(); - void open(); - void close(); + /*! + Write all in file. + */ + void write ( void ) const throw (MEDEXCEPTION); + /*! + Write only objects created from this MED driver in file. + */ + void writeFrom ( void ) const throw (MEDEXCEPTION); + /*! + Read all from the file. + */ + void read ( void ) throw (MEDEXCEPTION); + /*! + Read only table of contents of the file. + + All objects are created but there values are not read. + */ + void readFileStruct ( void ) throw (MEDEXCEPTION); + +private: + virtual GENDRIVER * copy ( void ) const ; - void write ( void ) const ; - void writeFrom ( void ) const ; - void read ( void ) ; - void readFileStruct ( void ) ; }; #endif /* MED_MED_DRIVER_HXX */ diff --git a/src/MEDMEM/MEDMEM_MedMeshDriver.cxx b/src/MEDMEM/MEDMEM_MedMeshDriver.cxx index c5dde7ed0..cd764c0c1 100644 --- a/src/MEDMEM/MEDMEM_MedMeshDriver.cxx +++ b/src/MEDMEM/MEDMEM_MedMeshDriver.cxx @@ -1,3 +1,30 @@ +// 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.cxx +// Module : MED + +using namespace std; #include "MEDMEM_MedMeshDriver.hxx" #include "MEDMEM_DriversDef.hxx" @@ -8,20 +35,92 @@ #include "MEDMEM_Connectivity.hxx" #include "MEDMEM_Mesh.hxx" #include "MEDMEM_CellModel.hxx" +#include "MEDMEM_Grid.hxx" extern "C" { extern med_idt _MEDdatagroupOuvrir(med_idt pid, char *nom); extern med_err _MEDdatagroupFermer(med_idt id); } -using namespace MED_FR; // Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor +MED_MESH_DRIVER::MED_MESH_DRIVER(): + GENDRIVER(), + _ptrMesh(( MESH *)MED_NULL), + _medIdt(MED_INVALID), + _meshName(""), + _meshNum(MED_INVALID) +{ +} + +MED_MESH_DRIVER::MED_MESH_DRIVER(const string & fileName, + MESH * ptrMesh, + MED_EN::med_mode_acces accessMode): + GENDRIVER(fileName,accessMode), + _ptrMesh(ptrMesh), + _medIdt(MED_INVALID), + _meshName(""), + _meshNum(MED_INVALID) +{ +} + +MED_MESH_DRIVER::MED_MESH_DRIVER(const MED_MESH_DRIVER & driver): + GENDRIVER(driver), + _ptrMesh(driver._ptrMesh), + _medIdt(MED_INVALID), + _meshName(driver._meshName), + _meshNum(driver._meshNum) +{ +} + +MED_MESH_DRIVER::~MED_MESH_DRIVER() +{ +} + +void MED_MESH_DRIVER::open() + throw (MEDEXCEPTION) +{ + const char * LOC = "MED_MESH_DRIVER::open()" ; + BEGIN_OF(LOC); + MESSAGE(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode); + _medIdt = MED_FR::MEDouvrir( (const_cast (_fileName.c_str())),(MED_FR::med_mode_acces) _accessMode); + MESSAGE(LOC<<" _medIdt : "<< _medIdt ); + if (_medIdt > 0) + _status = MED_OPENED; + else { + _medIdt = MED_INVALID; + _status = MED_CLOSED; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode)); + } + + END_OF(LOC); +} + +void MED_MESH_DRIVER::close() + throw (MEDEXCEPTION) +{ + const char * LOC = "MED_MESH_DRIVER::close() " ; + BEGIN_OF(LOC); + 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); +} + void MED_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; }; string MED_MESH_DRIVER::getMeshName() const { return _meshName; }; -//---------------------------------- RDONLY PART ------------------------------------------------------------- - //A FAIRE UTILISER LES MAPS... const MED_FR::med_geometrie_element MED_MESH_DRIVER::all_cell_type[MED_NBR_GEOMETRIE_MAILLE]= { MED_FR::MED_POINT1,MED_FR::MED_SEG2,MED_FR::MED_SEG3,MED_FR::MED_TRIA3,MED_FR::MED_QUAD4,MED_FR::MED_TRIA6,MED_FR::MED_QUAD8, @@ -34,18 +133,71 @@ const char * const MED_MESH_DRIVER::all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE] "MED_PENTA15","MED_HEXA20"}; +//---------------------------------- RDONLY PART ------------------------------------------------------------- +MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(): MED_MESH_DRIVER() +{ +} + +MED_MESH_RDONLY_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::MED_MESH_RDONLY_DRIVER(const MED_MESH_RDONLY_DRIVER & driver): + MED_MESH_DRIVER(driver) +{ +} + +MED_MESH_RDONLY_DRIVER::~MED_MESH_RDONLY_DRIVER() +{ + //MESSAGE("MED_MESH_RDONLY_DRIVER::~MED_MESH_RDONLY_DRIVER() has been destroyed"); +} + +GENDRIVER * MED_MESH_RDONLY_DRIVER::copy(void) const +{ + return new MED_MESH_RDONLY_DRIVER(*this); +} void MED_MESH_RDONLY_DRIVER::read(void) + throw (MEDEXCEPTION) { const char * LOC = "MED_MESH_RDONLY_DRIVER::read() : " ; BEGIN_OF(LOC); if (_status!=MED_OPENED) - throw MEDEXCEPTION(" "); - //throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << _medIdt << " (the file is not opened)." )) ; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << _medIdt << " (the file is not opened)." )) ; _ptrMesh->_name = _meshName; - + + SCRUTE(_ptrMesh->getIsAGrid()); + + if (_ptrMesh->getIsAGrid()) + { + getGRID( ); + + // always call getFAMILY : families are requiered !!!! + +// int nbFam = MEDnFam(_medIdt, +// const_cast (_meshName.c_str()), +// 0, +// MED_FR::MED_FAMILLE); +// if (nbFam > 0) + { +// getFAMILY(); + + if (getFAMILY()!=MED_VALID) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY when the mesh is a grid")) ; + + buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ; + _ptrMesh->_numberOfNodesGroups = _ptrMesh->_groupNode.size() ; + } + + END_OF(LOC); + return; + } + if (getCOORDINATE()!=MED_VALID) throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOORDINATE" )) ; @@ -71,11 +223,199 @@ void MED_MESH_RDONLY_DRIVER::read(void) buildAllGroups(_ptrMesh->_groupEdge,_ptrMesh->_familyEdge) ; _ptrMesh->_numberOfEdgesGroups = _ptrMesh->_groupEdge.size() ; + MESSAGE(LOC<<"Checking of CellModel !!!!!!!"); + + int nbOfTypes = _ptrMesh->_connectivity->_numberOfTypes; +// for(int i=0;i_connectivity->_type[i]) ; +// } + END_OF(LOC); } +//======================================================================= +//function : getGRID +//purpose : +//======================================================================= +void MED_MESH_RDONLY_DRIVER::getGRID() +{ + const char * LOC = "MED_MESH_RDONLY_DRIVER::getGRID() : " ; + BEGIN_OF(LOC); + + if (_status!=MED_OPENED) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "med file is not opened")); + + GRID * ptrGrid = (GRID *) _ptrMesh; + + int err, i; + + // Read the dimension of the space for the mesh <_meshName> + int SpaceDimension = MED_FR::MEDdimLire(_medIdt,const_cast (_meshName.c_str())) ; + if ( SpaceDimension <= MED_VALID ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The space dimension |" << SpaceDimension << + "| seems to be incorrect " << "for the mesh : |" << + _meshName << "|")) ; + _ptrMesh->_spaceDimension = SpaceDimension; + + // Read Array length + int * ArrayLen[] = { & ptrGrid->_iArrayLength, + & ptrGrid->_jArrayLength, + & ptrGrid->_kArrayLength }; + int idim; + for (idim = 0; idim < _ptrMesh->_spaceDimension; ++idim) + { + int lenght = MED_FR::MEDnGrid(_medIdt, + const_cast (_ptrMesh->_name.c_str()), + (MED_FR::med_grid) + idim + ); + if ( lenght <= MED_VALID ) + throw MEDEXCEPTION(STRING(LOC) <<"The number of nodes |" << lenght << + "| seems to be incorrect " + << "for the mesh : |" << _meshName << "|" ) ; + + ArrayLen [idim][0] = lenght; + } + + MED_FR::med_repere rep ; + string tmp_nom_coord (MED_TAILLE_PNOM*(_ptrMesh->_spaceDimension)+1,' '); + string tmp_unit_coord(MED_TAILLE_PNOM*(_ptrMesh->_spaceDimension)+1,' '); + char * tmp_nom = (const_cast ( tmp_nom_coord.c_str()) ) ; + char * tmp_unit= (const_cast ( tmp_unit_coord.c_str()) ) ; + + // Read node coordinates for MED_BODY_FITTED grid + if (ptrGrid->getGridType() == MED_EN::MED_BODY_FITTED) + { + // Read nb of nodes + int NumberOfNodes = MED_FR::MEDnGrid(_medIdt, + const_cast (_meshName.c_str()), + MED_FR::MED_GRID_NOEUD); + if ( NumberOfNodes <= MED_VALID ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" << NumberOfNodes << + "| seems to be incorrect " + << "for the mesh : |" << _meshName << "|" )) ; + _ptrMesh->_numberOfNodes = NumberOfNodes ; + + // this array is useless because families numbers are read in getFAMILY + int * MEDArrayNodeFamily = new int[ NumberOfNodes ]; + // create coordinates + _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes, + MED_EN::MED_FULL_INTERLACE); + + // Read coordinates and families + double * coo = const_cast + (_ptrMesh->_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE)); + + err = MED_FR::MEDbodyFittedLire (_medIdt, + const_cast (_ptrMesh->_name.c_str()), + _ptrMesh->_spaceDimension, + coo, + MED_FR::MED_FULL_INTERLACE, + & rep, + tmp_nom, + tmp_unit, + MEDArrayNodeFamily, + NumberOfNodes); + delete[] MEDArrayNodeFamily; + if (err != MED_VALID) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in MEDbodyFittedLire()")); + + // _ptrMesh->_MEDArrayNodeFamily = fam ; + + } + else + { + // Read Arrays and Node families in Cartesian or Polar Grid + + int nbNodes = 1; + double * Array[] = { (double*) 0, (double*) 0, (double*) 0 }; + for (idim = 0; idim < _ptrMesh->_spaceDimension; ++idim) + { + int nbNodesDim = * ArrayLen [idim]; + nbNodes *= nbNodesDim; + Array [idim] = new double [ nbNodesDim ]; + err = MED_FR::MEDgridLire (_medIdt, + const_cast (_ptrMesh->_name.c_str()), + _ptrMesh->_spaceDimension, + Array [idim], + idim, + MED_FR::MED_FULL_INTERLACE, + & rep, + tmp_nom, + tmp_unit); + if (err != MED_VALID) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Error in MEDgridLire for dimention" << idim )); + + } + ptrGrid->_iArray = Array[0]; + ptrGrid->_jArray = Array[1]; + ptrGrid->_kArray = Array[2]; + + _ptrMesh->_numberOfNodes = nbNodes ; + + // create coordinates + _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,nbNodes, + MED_EN::MED_FULL_INTERLACE); + // Read node families +// int nbFamNodes = MED_FR::MEDnGrid(_medIdt, +// const_cast (_ptrMesh->_name.c_str()), +// MED_FR::MED_FAM_NOEUD); +// if (nbFamNodes > 0) +// { +// // int * fam = new int[ nbFamNodes ]; + +// //_ptrMesh->_MEDArrayNodeFamily = new int[ nbFamNodes ]; +// // this array is useless because families numbers are read in getFAMILY +// int * MEDArrayNodeFamily = new int[ nbFamNodes ]; + +// err = MED_FR::MEDfamGridLire (_medIdt, +// const_cast (_ptrMesh->_name.c_str()), +// MEDArrayNodeFamily, +// nbFamNodes, +// MED_FR::MED_NOEUD); + +// if (err != MED_VALID) +// throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read grid nodes families for " +// << idim << "-th dimention")); +// else +// _ptrMesh->_MEDArrayNodeFamily = fam; +// } + + } // end read Cartesian or Polar Grid + + // set coordinate names + + for (i=0; i<_ptrMesh->_spaceDimension; ++i ) { + string myStringName(tmp_nom,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ; + string myStringUnit(tmp_unit,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ; + // suppress space at the end + int j ; + for(j=MED_TAILLE_PNOM-1;j>=0;j--) + if (myStringName[j] != ' ') break ; + _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1); + for(j=MED_TAILLE_PNOM-1;j>=0;j--) + if (myStringUnit[j] != ' ') break ; + _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1); + } + + string coordinateSystem = "UNDEFINED"; + + if( rep == MED_FR::MED_CART) coordinateSystem = "CARTESIAN"; + else if ( rep == MED_FR::MED_CYL) coordinateSystem = "CYLINDRICAL"; + else if ( rep == MED_FR::MED_SPHER) coordinateSystem = "SPHERICAL"; + + _ptrMesh->_coordinate->setCoordinatesSystem(coordinateSystem); + + + END_OF(LOC); +} + +//======================================================================= +//function : getCOORDINATE // A FAIRE : RENVOYER DU VOID +//======================================================================= int MED_MESH_RDONLY_DRIVER::getCOORDINATE() { const char * LOC = "MED_MESH_RDONLY_DRIVER::getCOORDINATE() : " ; @@ -87,7 +427,7 @@ int MED_MESH_RDONLY_DRIVER::getCOORDINATE() // Read the dimension of the space for the mesh <_meshName> // to be able to create a COORDINATE object - int SpaceDimension = MEDdimLire(_medIdt,const_cast (_meshName.c_str())) ; + int SpaceDimension = MED_FR::MEDdimLire(_medIdt,const_cast (_meshName.c_str())) ; if ( SpaceDimension <= MED_VALID ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The space dimension |" << SpaceDimension << "| seems to be incorrect " << "for the mesh : |" << _meshName << "|")) ; @@ -111,7 +451,7 @@ int MED_MESH_RDONLY_DRIVER::getCOORDINATE() // create a COORDINATE object - _ptrMesh->_coordinate = new COORDINATE(MED_EN::MED_FULL_INTERLACE, SpaceDimension, NumberOfNodes); + _ptrMesh->_coordinate = new COORDINATE(SpaceDimension, NumberOfNodes, MED_EN::MED_FULL_INTERLACE); MED_FR::med_repere rep ; // ATTENTION ---> DOIT ETRE INTEGRE DS MESH EF: FAIT NON? string tmp_nom_coord (MED_TAILLE_PNOM*(_ptrMesh->_spaceDimension)+1,'\0'); @@ -122,7 +462,8 @@ int MED_MESH_RDONLY_DRIVER::getCOORDINATE() err=MEDcoordLire(_medIdt, const_cast (_ptrMesh->_name.c_str()), _ptrMesh->_spaceDimension, - const_cast ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ), + //const_cast ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ), + const_cast ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ), MED_FR::MED_FULL_INTERLACE, MED_ALL, // we read all the coordinates NULL, // we don't use a profile @@ -136,10 +477,18 @@ int MED_MESH_RDONLY_DRIVER::getCOORDINATE() << "| and units |" << tmp_unit << " |")) ; + for (int i=0;i<_ptrMesh->_spaceDimension;i++) { - // PG : What about blank !!!!! - _ptrMesh->_coordinate->_coordinateName[i]=string(tmp_nom,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ; - _ptrMesh->_coordinate->_coordinateUnit[i]=string(tmp_unit,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM); + string myStringName(tmp_nom,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ; + string myStringUnit(tmp_unit,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ; + // suppress space at the end + int j ; + for(j=MED_TAILLE_PNOM-1;j>=0;j--) + if (myStringName[j] != ' ') break ; + _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1); + for(j=MED_TAILLE_PNOM-1;j>=0;j--) + if (myStringUnit[j] != ' ') break ; + _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1); } // Pourquoi le stocker sous forme de chaîne ? @@ -167,7 +516,7 @@ int MED_MESH_RDONLY_DRIVER::getCOORDINATE() } } - // Read the unused optionnal node Names + // Read the unused optional node Names char * tmp_node_name = new char[NumberOfNodes*MED_TAILLE_PNOM+1]; tmp_node_name[NumberOfNodes]='\0' ; err=MEDnomLire(_medIdt,const_cast (_ptrMesh->_name.c_str()), @@ -178,17 +527,19 @@ int MED_MESH_RDONLY_DRIVER::getCOORDINATE() delete[] tmp_node_name ; - // ??? Read the unused optionnal node Numbers ??? + // ??? Read the unused optional node Numbers ??? int * tmp_node_number = new int[NumberOfNodes] ; err=MEDnumLire(_medIdt,const_cast (_ptrMesh->_name.c_str()), - tmp_node_number,NumberOfNodes,MED_NOEUD,(MED_FR::med_geometrie_element)0); + tmp_node_number,NumberOfNodes,MED_FR::MED_NOEUD,(MED_FR::med_geometrie_element)0); if (err == MED_VALID) { INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING"); INFOS(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have numbers but we do not take care of them !"); INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING"); - _ptrMesh->_coordinate->_nodeNumber = tmp_node_number ; - } else - delete[] tmp_node_number ; + _ptrMesh->_coordinate->_nodeNumber.set(NumberOfNodes) ; + memcpy((int*)_ptrMesh->_coordinate->_nodeNumber,tmp_node_number,sizeof(int)*NumberOfNodes) ; + } + + delete[] tmp_node_number ; END_OF(LOC); return MED_VALID; @@ -378,7 +729,7 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity) int numberOfEdgesTypes = 0; int * tmp_faces_count = new int[MED_NBR_GEOMETRIE_MAILLE] ; int numberOfFacesTypes = 0; - if ((version_med != "2.2")&(Entity==MED_MAILLE)) { + if ((version_med != "2.2")&(Entity==MED_FR::MED_MAILLE)) { Connectivity->_numberOfTypes=0; for (int i=1;i0) { - Connectivity->_count[TypeNumber]=Connectivity->_count[TypeNumber-1]+tmp_cells_count[i]; - + CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i]) ; Connectivity->_type[TypeNumber-1]=t ; @@ -439,8 +789,10 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity) } // Creation of the MEDSKYLINEARRAY - Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,size) ; - int * NodalIndex = Connectivity->_nodal->getIndex() ; + //Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,size) ; + //int * NodalIndex = Connectivity->_nodal->getIndex() ; + int * NodalValue = new int[size] ; + int * NodalIndex = new int[Connectivity->_count[Connectivity->_numberOfTypes]] ; NodalIndex[0]=1 ; // Fill the MEDSKYLINEARRAY by reading the MED file. @@ -476,14 +828,21 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity) MESSAGE(LOC<<": MEDconnLire returns "<_nodal->getI(Connectivity->_count[i]) ; + int * ConnectivityArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ; for (int j=0; j_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1, + size, + NodalIndex, + NodalValue) ; + delete[] NodalIndex; + delete[] NodalValue; + } // end of bloc to read CELL delete[] tmp_cells_count; @@ -514,8 +873,10 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity) } // Creation of the MEDSKYLINEARRAY - constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ; - int * NodalIndex = constituent->_nodal->getIndex() ; + //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ; + //int * NodalIndex = constituent->_nodal->getIndex() ; + int * NodalValue = new int[size] ; + int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ; NodalIndex[0]=1 ; // Fill the MEDSKYLINEARRAY by reading the MED file. @@ -544,7 +905,7 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity) return MED_ERROR ; } - int * constituentArray = constituent->_nodal->getI(constituent->_count[i]) ; + int * constituentArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ; for (int j=0; j_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1, + size, + NodalIndex, + NodalValue) ; + delete[] NodalIndex ; + delete[] NodalValue ; + Connectivity->_constituent = constituent ; } @@ -561,7 +929,7 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity) // =============== if (numberOfEdgesTypes!=0) { CONNECTIVITY * constituent = new CONNECTIVITY(numberOfEdgesTypes,MED_EDGE) ; - constituent->_entityDimension = 2 ; + constituent->_entityDimension = 1 ; constituent->_count[0]=1 ; int size = 0 ; @@ -582,8 +950,10 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity) } // Creation of the MEDSKYLINEARRAY - constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ; - int * NodalIndex = constituent->_nodal->getIndex() ; + //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ; + //int * NodalIndex = constituent->_nodal->getIndex() ; + int * NodalValue = new int[size] ; + int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ; NodalIndex[0]=1 ; // Fill the MEDSKYLINEARRAY by reading the MED file. @@ -601,7 +971,7 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity) int * tmp_constituentArray = new int[(NumberOfNodeByEdge+1)*tmp_numberOfEdges] ; int err=MEDconnLire(_medIdt,const_cast (_ptrMesh->_name.c_str()), - Connectivity->_entityDimension,tmp_constituentArray, + _ptrMesh->_spaceDimension,tmp_constituentArray, MED_FR::MED_FULL_INTERLACE,NULL,0,MED_FR::MED_MAILLE,med_type,MED_FR::MED_NOD); if ( err != MED_VALID) { MESSAGE(LOC<<": MEDconnLire returns "<_nodal->getI(constituent->_count[i]) ; + int * constituentArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ; for (int j=0; j_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1, + size, + NodalIndex, + NodalValue) ; + + delete[] NodalIndex ; + delete[] NodalValue ; + if (Connectivity->_entityDimension == 3) { if (Connectivity->_constituent==NULL) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Edges are defined but there are no Faces !")); @@ -686,28 +1064,65 @@ int MED_MESH_RDONLY_DRIVER::getFAMILY() if (_status==MED_OPENED) { int err = 0 ; - // read number : - // NODE : - err = getNodesFamiliesNumber() ; // error only if (_status!=MED_OPENED), other case exeception ! - // CELL - _ptrMesh->_MEDArrayCellFamily = new (int*)[_ptrMesh->_connectivity->_numberOfTypes] ; // ET SI IL N'Y A PAS DE CELLS ? - getCellsFamiliesNumber(_ptrMesh->_MEDArrayCellFamily,_ptrMesh->_connectivity) ; - if (_ptrMesh->_connectivity->_constituent != NULL) { - if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE) { - // FACE - _ptrMesh->_MEDArrayFaceFamily = new (int*)[_ptrMesh->_connectivity->_constituent->_numberOfTypes] ; - getCellsFamiliesNumber(_ptrMesh->_MEDArrayFaceFamily,_ptrMesh->_connectivity->_constituent) ; - } else { - // EDGE in 2D - _ptrMesh->_MEDArrayEdgeFamily = new (int*)[_ptrMesh->_connectivity->_constituent->_numberOfTypes] ; - getCellsFamiliesNumber(_ptrMesh->_MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent) ; + + int * MEDArrayNodeFamily = NULL ; + int ** MEDArrayCellFamily = NULL ; + int ** MEDArrayFaceFamily = NULL ; + int ** MEDArrayEdgeFamily = NULL ; + + if ( !_ptrMesh->getIsAGrid() ) + { + // read number : + // NODE : + MEDArrayNodeFamily = new int[_ptrMesh->getNumberOfNodes()] ; + err = getNodesFamiliesNumber(MEDArrayNodeFamily) ; // error only if (_status!=MED_OPENED), other case exeception ! + // CELL + MEDArrayCellFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_CELL)] ; // ET SI IL N'Y A PAS DE CELLS ? + const medGeometryElement * myTypes = _ptrMesh->getTypes(MED_CELL); + for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++) + MEDArrayCellFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_CELL,myTypes[i])] ; + + getCellsFamiliesNumber(MEDArrayCellFamily,_ptrMesh->_connectivity) ; + if (_ptrMesh->_connectivity->_constituent != NULL) { + if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE) { + // FACE + MEDArrayFaceFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_FACE)] ; + myTypes = _ptrMesh->getTypes(MED_FACE); + for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++) + MEDArrayFaceFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_FACE,myTypes[i])] ; + + getCellsFamiliesNumber(MEDArrayFaceFamily,_ptrMesh->_connectivity->_constituent) ; + } else { + // EDGE in 2D + MEDArrayEdgeFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_EDGE)] ; + myTypes = _ptrMesh->getTypes(MED_EDGE); + for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++) + MEDArrayEdgeFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes[i])] ; + getCellsFamiliesNumber(MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent) ; + } + // EDGE in 3D + if (_ptrMesh->_connectivity->_constituent->_constituent != NULL) { + MEDArrayEdgeFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_EDGE)] ; + myTypes = _ptrMesh->getTypes(MED_EDGE); + for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++) + MEDArrayEdgeFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes[i])] ; + getCellsFamiliesNumber(MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent->_constituent) ; // we are in 3D ! + } + } } - // EDGE in 3D - if (_ptrMesh->_connectivity->_constituent->_constituent != NULL) { - _ptrMesh->_MEDArrayEdgeFamily = new (int*)[_ptrMesh->_connectivity->_constituent->_constituent->_numberOfTypes] ; - getCellsFamiliesNumber(_ptrMesh->_MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent) ; // we are in 3D ! + else + { + // node + int NumberOfNodes = _ptrMesh->getNumberOfNodes() ; + MEDArrayNodeFamily = new int[ NumberOfNodes ]; + err = MED_FR::MEDfamGridLire (_medIdt, + const_cast (_ptrMesh->_name.c_str()), + MEDArrayNodeFamily, + NumberOfNodes, + MED_FR::MED_NOEUD); + + // what about cell face and edge ? } - } // Creation of the families int NumberOfFamilies = MEDnFam(_medIdt,const_cast (_meshName.c_str()),0,MED_FR::MED_FAMILLE) ; @@ -739,13 +1154,13 @@ int MED_MESH_RDONLY_DRIVER::getFAMILY() int * AttributesIdentifier = new int[NumberOfAttributes] ; int * AttributesValues = new int[NumberOfAttributes] ; string AttributesDescription(MED_TAILLE_DESC*NumberOfAttributes,' ') ; - string GroupsNames(MED_TAILLE_LNOM*NumberOfGroups,' ') ; - err = MEDfamInfo(_medIdt,const_cast (_meshName.c_str()), - i+1,const_cast (FamilyName.c_str()), - &FamilyIdentifier,AttributesIdentifier,AttributesValues, - const_cast (AttributesDescription.c_str()), - &NumberOfAttributes, - const_cast (GroupsNames.c_str()),&NumberOfGroups + string GroupsNames(MED_TAILLE_LNOM*NumberOfGroups+1,' ') ; + err = MED_FR::MEDfamInfo(_medIdt,const_cast (_meshName.c_str()), + i+1,const_cast (FamilyName.c_str()), + &FamilyIdentifier,AttributesIdentifier,AttributesValues, + const_cast (AttributesDescription.c_str()), + &NumberOfAttributes, + const_cast (GroupsNames.c_str()),&NumberOfGroups ); //SCRUTE(GroupsNames); if (err != MED_VALID) @@ -754,27 +1169,60 @@ int MED_MESH_RDONLY_DRIVER::getFAMILY() FAMILY * Family = new FAMILY(_ptrMesh,FamilyIdentifier,FamilyName, NumberOfAttributes,AttributesIdentifier, AttributesValues,AttributesDescription, - NumberOfGroups,GroupsNames) ; - switch (Family->getEntity()) { - case MED_EN::MED_NODE : - NodeFamilyVector.push_back(Family) ; - numberOfNodesFamilies++ ; - break ; - case MED_EN::MED_CELL : - CellFamilyVector.push_back(Family) ; - numberOfCellsFamilies++ ; - break ; - case MED_EN::MED_FACE : - FaceFamilyVector.push_back(Family) ; - numberOfFacesFamilies++ ; - break ; - case MED_EN::MED_EDGE : - EdgeFamilyVector.push_back(Family) ; - numberOfEdgesFamilies++ ; - break ; - } + NumberOfGroups,GroupsNames, + MEDArrayNodeFamily, + MEDArrayCellFamily, + MEDArrayFaceFamily, + MEDArrayEdgeFamily + ) ; + // All good ? + // if nothing found, delete Family + if (Family->getNumberOfTypes() == 0) { + INFOS(LOC<<"Nothing found for family "<getEntity()) { + case MED_EN::MED_NODE : + NodeFamilyVector.push_back(Family) ; + numberOfNodesFamilies++ ; + break ; + case MED_EN::MED_CELL : + CellFamilyVector.push_back(Family) ; + numberOfCellsFamilies++ ; + break ; + case MED_EN::MED_FACE : + FaceFamilyVector.push_back(Family) ; + numberOfFacesFamilies++ ; + break ; + case MED_EN::MED_EDGE : + EdgeFamilyVector.push_back(Family) ; + numberOfEdgesFamilies++ ; + break ; + } } + + delete [] AttributesIdentifier ; + delete [] AttributesValues ; } + + if (MEDArrayNodeFamily != NULL) + delete[] MEDArrayNodeFamily ; + if (MEDArrayCellFamily != NULL) { + for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++) + delete[] MEDArrayCellFamily[i] ; + delete[] MEDArrayCellFamily ; + } + if (MEDArrayFaceFamily != NULL) { + for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++) + delete[] MEDArrayFaceFamily[i] ; + delete[] MEDArrayFaceFamily ; + } + if (MEDArrayEdgeFamily != NULL) { + for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++) + delete[] MEDArrayEdgeFamily[i] ; + delete[] MEDArrayEdgeFamily ; + } + _ptrMesh->_numberOfNodesFamilies = numberOfNodesFamilies ; _ptrMesh->_numberOfCellsFamilies = numberOfCellsFamilies ; _ptrMesh->_numberOfFacesFamilies = numberOfFacesFamilies ; @@ -786,23 +1234,21 @@ int MED_MESH_RDONLY_DRIVER::getFAMILY() return MED_ERROR; } -int MED_MESH_RDONLY_DRIVER::getNodesFamiliesNumber() +int MED_MESH_RDONLY_DRIVER::getNodesFamiliesNumber(int * MEDArrayNodeFamily) { const char * LOC = "MED_MESH_RDONLY_DRIVER::getNodesFamiliesNumber() : " ; BEGIN_OF(LOC); if (_status==MED_OPENED) { int err = 0 ; - int * tmp_NodesFamilies = new int[_ptrMesh->getNumberOfNodes()] ; err = MEDfamLire(_medIdt,(const_cast (_ptrMesh->_name.c_str())), - tmp_NodesFamilies, _ptrMesh->getNumberOfNodes(), - MED_NOEUD,(enum MED_FR::med_geometrie_element) MED_NONE); + MEDArrayNodeFamily, + _ptrMesh->getNumberOfNodes(), + MED_FR::MED_NOEUD,(enum MED_FR::med_geometrie_element) MED_NONE); if ( err != MED_VALID) { - delete[] tmp_NodesFamilies ; throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "There is no family for the |"<< _ptrMesh->getNumberOfNodes() << "| nodes in mesh |" << _ptrMesh->_name.c_str() << "|" )); } - _ptrMesh->_MEDArrayNodeFamily = tmp_NodesFamilies ; END_OF(LOC); return MED_VALID; } @@ -818,10 +1264,8 @@ int MED_MESH_RDONLY_DRIVER::getCellsFamiliesNumber(int **MEDArrayFamily,CONNECT int i, err = 0 ; for (i=0;i_numberOfTypes;i++) { int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ; - int * fam = new int[NumberOfCell] ; - err=MEDfamLire(_medIdt,const_cast (_ptrMesh->_name.c_str()), - fam,NumberOfCell, + MEDArrayFamily[i],NumberOfCell, (MED_FR::med_entite_maillage) Connectivity->_entity, (MED_FR::med_geometrie_element) Connectivity->_geometricTypes[i]); @@ -829,12 +1273,11 @@ int MED_MESH_RDONLY_DRIVER::getCellsFamiliesNumber(int **MEDArrayFamily,CONNECT if (err != MED_VALID) { MESSAGE(LOC<<"search face/edge family on cell !!!"); err=MEDfamLire(_medIdt,const_cast (_ptrMesh->_name.c_str()), - fam,NumberOfCell, + MEDArrayFamily[i],NumberOfCell, MED_FR::MED_MAILLE, (MED_FR::med_geometrie_element) Connectivity->_geometricTypes[i]); } - MEDArrayFamily[i]=fam ; if (err != MED_VALID) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Family not found for entity "<_entity<<" and geometric type "<_geometricTypes[i])); @@ -869,12 +1312,12 @@ void MED_MESH_RDONLY_DRIVER::buildAllGroups(vector & Groups, vector >::const_iterator currentGroup ; int it = 0 ; for(currentGroup=groupsNames.begin();currentGroup!=groupsNames.end();currentGroup++) { - // GROUP * myGroup = new GROUP((*currentGroup).first,(*currentGroup).second) ; - GROUP * myGroup = new GROUP() ; - myGroup->setName((*currentGroup).first); - SCRUTE(myGroup->getName()); - //myGroup->setMesh(_ptrMesh); - myGroup->init((*currentGroup).second); + GROUP * myGroup = new GROUP((*currentGroup).first,(*currentGroup).second) ; +// GROUP * myGroup = new GROUP() ; +// myGroup->setName((*currentGroup).first); +// SCRUTE(myGroup->getName()); +// //myGroup->setMesh(_ptrMesh); +// myGroup->init((*currentGroup).second); Groups[it]=myGroup; //SCRUTE(it); it++; @@ -898,50 +1341,94 @@ void MED_MESH_RDONLY_DRIVER::updateFamily() } -void MED_MESH_RDONLY_DRIVER::write( void ) const { INFOS("MED_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");} +void MED_MESH_RDONLY_DRIVER::write( void ) const + throw (MEDEXCEPTION) +{ + throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !"); +} -/*--------------------- RDWR PART -------------------------------*/ +/*--------------------- WRONLY PART -------------------------------*/ -void MED_MESH_RDWR_DRIVER::write(void) const { MED_MESH_WRONLY_DRIVER::write(); } -void MED_MESH_RDWR_DRIVER::read (void) { MED_MESH_RDONLY_DRIVER::read(); } +MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER():MED_MESH_DRIVER() +{ +} + +MED_MESH_WRONLY_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::MED_MESH_WRONLY_DRIVER(const MED_MESH_WRONLY_DRIVER & driver): + MED_MESH_DRIVER(driver) +{ +} -/*--------------------- WRONLY PART -------------------------------*/ -void MED_MESH_WRONLY_DRIVER::read (void) { INFOS("MED_MESH_WRONLY_DRIVER::write : Can't read with a WRONLY driver !");} +MED_MESH_WRONLY_DRIVER::~MED_MESH_WRONLY_DRIVER() +{ + //MESSAGE("MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed"); +} -void MED_MESH_WRONLY_DRIVER::write(void) const { +GENDRIVER * MED_MESH_WRONLY_DRIVER::copy(void) const +{ + return new MED_MESH_WRONLY_DRIVER(*this); +} + +void MED_MESH_WRONLY_DRIVER::read (void) + throw (MEDEXCEPTION) +{ + throw MEDEXCEPTION("MED_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !"); +} + +void MED_MESH_WRONLY_DRIVER::write(void) const + throw (MEDEXCEPTION) +{ const char * LOC = "void MED_MESH_WRONLY_DRIVER::write(void) const : "; BEGIN_OF(LOC); // we must first create mesh !! - MESSAGE(LOC<< "MeshName : "<< _meshName <<"FileName : "<<_fileName<<" MedIdt : "<< _medIdt); + MESSAGE(LOC << "MeshName : |" << _meshName << "| FileName : |"<<_fileName<<"| MedIdt : | "<< _medIdt << "|"); - if (writeCoordinates()!=MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeCoordinates()" )) ; + if (_status!=MED_OPENED) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "File "<<_fileName<<" is not open. Open it before write !")); - if (writeConnectivities(MED_EN::MED_CELL)!=MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_CELL)" )) ; - if (writeConnectivities(MED_EN::MED_FACE)!=MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_FACE)" )) ; - if (writeConnectivities(MED_EN::MED_EDGE)!=MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_EDGE)" )) ; + if (_ptrMesh->getIsAGrid()) + { + if ( writeGRID() != MED_VALID ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeGRID()" )) ; + } + else + { + if (writeCoordinates()!=MED_VALID) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeCoordinates()" )) ; + + if (writeConnectivities(MED_EN::MED_CELL)!=MED_VALID) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_CELL)" )) ; + if (writeConnectivities(MED_EN::MED_FACE)!=MED_VALID) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_FACE)" )) ; + if (writeConnectivities(MED_EN::MED_EDGE)!=MED_VALID) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_EDGE)" )) ; + } if (writeFamilyNumbers() !=MED_VALID) throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilyNumbers()" )) ; - + + // well we must first write zero family : if (_status==MED_OPENED) { int err ; // test if the family already exists (HDF trick waiting a MED evolution to be replaced) string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/FAMILLE_0/"; - SCRUTE("|"< (dataGroupFam.c_str()) ) < MED_VALID ) { SCRUTE(err); - err = MEDfamCr( _medIdt, const_cast ( _meshName.c_str() ), - "FAMILLE_0", 0, - (int*)NULL, (int*)NULL, (char*)NULL, 0, - (char*)NULL, 0); + err = MED_FR::MEDfamCr( _medIdt, + const_cast ( _meshName.c_str() ), + "FAMILLE_0", 0, + (int*)NULL, (int*)NULL, (char*)NULL, 0, + (char*)NULL, 0); if ( err != MED_VALID) throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |FAMILLE_0| with identifier |0| groups names || and attributes descriptions ||")) ; @@ -970,79 +1457,231 @@ void MED_MESH_WRONLY_DRIVER::write(void) const { END_OF(LOC); } +//======================================================================= +//function : writeGRID +//purpose : +//======================================================================= + +int MED_MESH_WRONLY_DRIVER::writeGRID() const +{ + const char * LOC = "MED_MESH_WRONLY_DRIVER::writeGRID() : " ; + BEGIN_OF(LOC); + + if (_status!=MED_OPENED) + { + MESSAGE (LOC<<" Not open !!!"); + return MED_ERROR; + } + GRID * ptrGrid = (GRID*) _ptrMesh; + + MED_FR::med_err err = MED_ERROR; + MED_FR::med_repere rep; + string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM,' '); + string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM,' '); + + // Test if the mesh <_meshName> already exists + // If it doesn't exists create it + // If it already exists verify if its dimension is the same as <_ptrMesh->_spaceDimension> + // rem : <_meshName> is the driver meshName not _meshName> + int dim = MED_FR::MEDdimLire(_medIdt, const_cast (_meshName.c_str()) ); + if (dim < MED_VALID) + { + err = MEDgridCr(_medIdt, + const_cast (_meshName.c_str()), + _ptrMesh->_spaceDimension, + (MED_FR::med_grid_type) ptrGrid->getGridType()); + if (err != MED_VALID) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Grid")); + else + MESSAGE(LOC<<"Grid "<<_meshName<<" created in file "<<_fileName<<" !"); + } + else if (dim != _ptrMesh->_spaceDimension) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() << + "| already exists in file |" << _fileName << + "| with dimension |" << dim << + "| but the dimension of the mesh we want to write is |" + << _ptrMesh->_spaceDimension <<"|" )) ; + + // Recompose the <_spaceDimension> strings in 1 string + int lengthString ; + string valueString ; + for (int i=0;i<_ptrMesh->_spaceDimension;i++) { + SCRUTE(i); + valueString = _ptrMesh->_coordinate->_coordinateName[i] ; + lengthString = (MED_TAILLE_PNOM_coordinate->_coordinateUnit[i]; + lengthString = (MED_TAILLE_PNOM_coordinate->_coordinateSystem; + if (coordinateSystem == "CARTESIAN") + rep = MED_FR::MED_CART; + else if ( coordinateSystem == "CYLINDRICAL") + rep = MED_FR::MED_CYL; + else if ( coordinateSystem == "SPHERICAL" ) + rep = MED_FR::MED_SPHER; + else + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() << + "| doesn't have a valid coordinate system : |" + << _ptrMesh->_coordinate->_coordinateSystem + << "|" )) ; + + int ArrayLen[] = { ptrGrid->_iArrayLength, + ptrGrid->_jArrayLength, + ptrGrid->_kArrayLength }; + + // Write node coordinates for MED_BODY_FITTED grid + if (ptrGrid->getGridType() == MED_EN::MED_BODY_FITTED) + { + + // Write Coordinates and families + double * coo = const_cast + (_ptrMesh->_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE)); + + // Write unused families + int * MEDArrayNodeFamily = new int[_ptrMesh->_numberOfNodes] ; + + err = MEDbodyFittedEcr (_medIdt, + const_cast (_ptrMesh->_name.c_str()), + _ptrMesh->_spaceDimension, + coo, + ArrayLen, + MED_FR::MED_FULL_INTERLACE, + rep, + const_cast (tmp_name.c_str()), + const_cast (tmp_unit.c_str()), + MEDArrayNodeFamily, + _ptrMesh->_numberOfNodes, + MED_FR::MED_REMP); + delete[] MEDArrayNodeFamily; + + if (err != MED_VALID) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in MEDbodyFittedEcr()")); + + } + else + { + // Write Arrays of Cartesian or Polar Grid + + double * Array[] = { ptrGrid->_iArray, + ptrGrid->_jArray, + ptrGrid->_kArray }; + int idim; + for (idim = 0; idim < _ptrMesh->_spaceDimension; ++idim) + { + err = MEDgridEcr (_medIdt, + const_cast (_ptrMesh->_name.c_str()), + _ptrMesh->_spaceDimension, + Array [idim], + ArrayLen [idim], + idim, + MED_FR::MED_FULL_INTERLACE, + rep, + const_cast (tmp_name.c_str()), + const_cast (tmp_unit.c_str()), + MED_FR::MED_REMP); + if (err != MED_VALID) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read grid coordinates for " + << idim << "-th dimention")); + } + +// err = MEDfamGridEcr(_medIdt, +// const_cast (_ptrMesh->_name.c_str()), +// _ptrMesh->_MEDArrayNodeFamily, +// _ptrMesh->_numberOfNodes, +// MED_FR::MED_REMP, +// MED_FR::MED_NOEUD); + if (err != MED_VALID) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in MEDfamGridEcr()")); + + } // end Write Cartesian or Polar Grid + + END_OF(LOC); + return MED_VALID; +} + +//======================================================================= +//function : writeCoordinates +//purpose : +//======================================================================= int MED_MESH_WRONLY_DRIVER::writeCoordinates() const { const char * LOC = "int MED_MESH_WRONLY_DRIVER::writeCoordinates() const : "; BEGIN_OF(LOC); - if (_status==MED_OPENED) { - MED_FR::med_err err = MED_ERROR; - MED_FR::med_repere rep; - string tmp_name,tmp_unit; + MED_FR::med_err err = MED_ERROR; + MED_FR::med_repere rep; + string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM,' '); + string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM,' '); - // Recompose the <_spaceDimension> strings in 1 string - for (int i=0;i<_ptrMesh->_spaceDimension;i++) { - tmp_name += _ptrMesh->_coordinate->_coordinateName[i]; - tmp_unit += _ptrMesh->_coordinate->_coordinateUnit[i]; - - } + // Recompose the <_spaceDimension> strings in 1 string + int lengthString ; + string valueString ; + for (int i=0;i<_ptrMesh->_spaceDimension;i++) { + valueString = _ptrMesh->_coordinate->_coordinateName[i] ; + lengthString = (MED_TAILLE_PNOM_coordinate->_coordinateUnit[i]; + lengthString = (MED_TAILLE_PNOM already exists - // If it doesn't exists create it - // If it already exists verify if its dimension is the same as <_ptrMesh->_spaceDimension> - // rem : <_meshName> is the driver meshName not _meshName> - int dim = MEDdimLire(_medIdt, const_cast (_meshName.c_str()) ); - if (dim < MED_VALID) - if (MEDmaaCr(_medIdt,const_cast (_meshName.c_str()),_ptrMesh->_spaceDimension) != 0 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh")); - else - { - MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !"); - } - else if (dim != _ptrMesh->_spaceDimension) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| already exists in file |" << _fileName - << "| with dimension |" << dim << "| but the dimension of the mesh we want to write is |" - << _ptrMesh->_spaceDimension <<"|" )) ; + // Test if the mesh <_meshName> already exists + // If it doesn't exists create it + // If it already exists verify if its dimension is the same as <_ptrMesh->_spaceDimension> + // rem : <_meshName> is the driver meshName not _meshName> + int dim = MED_FR::MEDdimLire(_medIdt, const_cast (_meshName.c_str()) ); + if (dim < MED_VALID) + if (MED_FR::MEDmaaCr(_medIdt,const_cast (_meshName.c_str()),_ptrMesh->_spaceDimension) != 0 ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh : |" << _meshName << "|")); + else + { + MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !"); + } + else if (dim != _ptrMesh->_spaceDimension) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| already exists in file |" << _fileName + << "| with dimension |" << dim << "| but the dimension of the mesh we want to write is |" + << _ptrMesh->_spaceDimension <<"|" )) ; - // Pourquoi le stocker sous forme de chaîne ? - const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem; - if (coordinateSystem == "CARTESIAN") - rep = MED_FR::MED_CART; - else if ( coordinateSystem == "CYLINDRICAL") - rep = MED_FR::MED_CYL; - else if ( coordinateSystem == "SPHERICAL" ) - rep = MED_FR::MED_SPHER; - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| doesn't have a valid coordinate system : |" - << _ptrMesh->_coordinate->_coordinateSystem - << "|" )) ; + // Pourquoi le stocker sous forme de chaîne ? + const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem; + if (coordinateSystem == "CARTESIAN") + rep = MED_FR::MED_CART; + else if ( coordinateSystem == "CYLINDRICAL") + rep = MED_FR::MED_CYL; + else if ( coordinateSystem == "SPHERICAL" ) + rep = MED_FR::MED_SPHER; + else + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| doesn't have a valid coordinate system : |" + << _ptrMesh->_coordinate->_coordinateSystem + << "|" )) ; - err = MEDcoordEcr(_medIdt, const_cast (_meshName.c_str()), - _ptrMesh->_spaceDimension, - const_cast ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ), - MED_FR::MED_FULL_INTERLACE, - _ptrMesh->_numberOfNodes, // _ptrMesh->_coordinate->_numberOfNodes - MED_FR::MED_REMP, - rep, - const_cast (tmp_name.c_str()), - const_cast (tmp_unit.c_str()) - ); - - if (err<0) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of mesh |" << _meshName.c_str() << "| in file |" << _fileName - << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and" - << " with units names |" << tmp_name - << "| and units |" << tmp_unit - << " |")) ; + err = MEDcoordEcr(_medIdt, const_cast (_meshName.c_str()), + _ptrMesh->_spaceDimension, + //const_cast ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ), + const_cast ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ), + MED_FR::MED_FULL_INTERLACE, + _ptrMesh->_numberOfNodes, // _ptrMesh->_coordinate->_numberOfNodes + MED_FR::MED_REMP, + rep, + const_cast (tmp_name.c_str()), + const_cast (tmp_unit.c_str()) + ); + + if (err<0) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of mesh |" << _meshName.c_str() << "| in file |" << _fileName + << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and" + << " with units names |" << tmp_name + << "| and units |" << tmp_unit + << " |")) ; - END_OF(LOC); + END_OF(LOC); - return MED_VALID; - } - - MESSAGE (LOC<<" Not open !!!"); - return MED_ERROR; + return MED_VALID; } @@ -1055,104 +1694,83 @@ int MED_MESH_WRONLY_DRIVER::writeConnectivities(medEntityMesh entity) const { MED_FR::med_err err; - if (_status==MED_OPENED) { - - // REM SI LA METHODE EST APPELEE DIRECTEMENT ET QUE LE MAILLAGE N'EST PAS CREE IL Y A PB ! + // REM SI LA METHODE EST APPELEE DIRECTEMENT ET QUE LE MAILLAGE N'EST PAS CREE IL Y A PB ! + // PG : IMPOSSIBLE : LA METHODE EST PRIVEE ! // A FAIRE : A tester surtout dans les methodes de MESH. // if ( _ptrMesh->_connectivity == (CONNECTIVITY *) MED_INVALID ) - if ( _ptrMesh->_connectivity == (CONNECTIVITY *) NULL ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The connectivity is not defined in the MESH object ")) ; + if ( _ptrMesh->_connectivity == (CONNECTIVITY *) NULL ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The connectivity is not defined in the MESH object ")) ; - if ( _ptrMesh->existConnectivity(MED_NODAL,entity) ) { + if ( _ptrMesh->existConnectivity(MED_NODAL,entity) ) { - int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ; - medGeometryElement * types = _ptrMesh->getTypes (entity) ; + int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ; + const medGeometryElement * types = _ptrMesh->getTypes (entity) ; - for (int i=0; igetNumberOfElements (entity,types[i]); - int * connectivity = _ptrMesh->getConnectivity (MED_EN::MED_FULL_INTERLACE, - MED_NODAL, entity, types[i]); // ?? et SI MED_NODAL n'existe pas, recalcul auto ?? + int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]); + const int * connectivity = _ptrMesh->getConnectivity (MED_EN::MED_FULL_INTERLACE, + MED_NODAL, entity, types[i]); // ?? et SI MED_NODAL n'existe pas, recalcul auto ?? - // Pour l'instant la class utilise le multi..... - int multi = 0 ; - if (entity==MED_EN::MED_CELL) - if ( (types[i]/ 100) < _ptrMesh->_spaceDimension) - multi=1 ; - int numberOfNodes = types[i]%100 ; - int * connectivityArray = new int[numberOfElements*(numberOfNodes+multi)]; - for (int j=0 ; j_spaceDimension) + multi=1 ; + int numberOfNodes = types[i]%100 ; + int * connectivityArray = new int[numberOfElements*(numberOfNodes+multi)]; + for (int j=0 ; j0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0; - } - err = MEDconnEcr( _medIdt, const_cast ( _meshName.c_str()), _ptrMesh->_spaceDimension, - connectivityArray, MED_FR::MED_FULL_INTERLACE , numberOfElements, - MED_FR::MED_REMP, - (MED_FR::med_entite_maillage ) entity, - (MED_FR::med_geometrie_element) types[i], MED_NOD ); - delete[] connectivityArray ; - - if (err<0) // ETENDRE LES EXPLICATIONS - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName - << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and" - )) ; - } - } - // Connctivity descending : - if ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) { - - int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ; - medGeometryElement * types = _ptrMesh->getTypes (entity) ; - - for (int i=0; igetNumberOfElements (entity,types[i]); - int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]); - - // Pour l'instant la class utilise le multi..... - err = MEDconnEcr( _medIdt, const_cast ( _meshName.c_str()), _ptrMesh->_spaceDimension, - connectivity, MED_FR::MED_FULL_INTERLACE , numberOfElements, - MED_FR::MED_REMP, - (MED_FR::med_entite_maillage ) entity, - (MED_FR::med_geometrie_element) types[i], MED_DESC ); - - if (err<0) // ETENDRE LES EXPLICATIONS - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName - << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and" - )) ; } + err = MEDconnEcr( _medIdt, const_cast ( _meshName.c_str()), _ptrMesh->_spaceDimension, + connectivityArray, MED_FR::MED_FULL_INTERLACE , numberOfElements, + MED_FR::MED_REMP, + (MED_FR::med_entite_maillage ) entity, + (MED_FR::med_geometrie_element) types[i], MED_FR::MED_NOD ); + delete[] connectivityArray ; + + if (err<0) // ETENDRE LES EXPLICATIONS + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName + << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and" + )) ; } - // Connctivity descending : - if ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) { + } + // Connctivity descending : + if ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) { - int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ; - medGeometryElement * types = _ptrMesh->getTypes (entity) ; + int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ; + const medGeometryElement * types = _ptrMesh->getTypes (entity) ; - for (int i=0; igetNumberOfElements (entity,types[i]); - int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]); + int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]); + const int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]); - // Pour l'instant la class utilise le multi..... - err = MEDconnEcr( _medIdt, const_cast ( _meshName.c_str()), _ptrMesh->_spaceDimension, - connectivity, MED_FR::MED_FULL_INTERLACE , numberOfElements, - MED_FR::MED_REMP, - (MED_FR::med_entite_maillage ) entity, - (MED_FR::med_geometrie_element) types[i], MED_DESC ); + // Pour l'instant la class utilise le multi..... + err = MED_FR::MEDconnEcr( _medIdt, + const_cast ( _meshName.c_str()), + _ptrMesh->_spaceDimension, + const_cast (connectivity), + MED_FR::MED_FULL_INTERLACE, + numberOfElements, + MED_FR::MED_REMP, + (MED_FR::med_entite_maillage ) entity, + (MED_FR::med_geometrie_element) types[i], + MED_FR::MED_DESC ); - if (err<0) // ETENDRE LES EXPLICATIONS - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName - << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and" - )) ; + if (err<0) // ETENDRE LES EXPLICATIONS + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName + << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and" + )) ; - } } - END_OF(LOC); - return MED_VALID; } - return MED_ERROR; + END_OF(LOC); + return MED_VALID; } int MED_MESH_WRONLY_DRIVER::writeFamilyNumbers() const { @@ -1162,135 +1780,287 @@ int MED_MESH_WRONLY_DRIVER::writeFamilyNumbers() const { MED_FR::med_err err; - if (_status==MED_OPENED) { + // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArrayNodeFamily DOIT ETRE ENLEVER DE LA CLASSE MESH + + { // Node related block + + // We build the array from the families list objects : + int NumberOfNodes = _ptrMesh->getNumberOfNodes() ; + int * MEDArrayNodeFamily = new int[NumberOfNodes] ; + // family 0 by default + for (int i=0; i myFamilies = _ptrMesh->getFamilies(MED_NODE); + vector * myFamilies = &_ptrMesh->_familyNode; + int NumberOfNodesFamilies = myFamilies->size() ; + //bool ToDestroy = false; + if (0 == NumberOfNodesFamilies) { + //ToDestroy = true ; + vector myGroups = _ptrMesh->getGroups(MED_NODE); + int NumberOfGroups = myGroups.size() ; + // build families from groups + for (int i=0; isetIdentifier(i+1); + myFamilies->push_back(myFamily); + } + NumberOfNodesFamilies=myFamilies->size() ; + } + for (int i=0 ; igetName()); + int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ; + int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ; + if ((*myFamilies)[i]->isOnAllElements()) + for (int j=0; jgetNumber(MED_ALL_ELEMENTS) ; + for (int j=0; jgetIsAGrid() ) + err = MEDfamEcr(_medIdt, const_cast ( _meshName.c_str() ), + MEDArrayNodeFamily, NumberOfNodes,MED_FR::MED_REMP , + MED_FR::MED_NOEUD, + (enum MED_FR::med_geometrie_element) MED_NONE); + else + err = MEDfamGridEcr(_medIdt, + const_cast (_ptrMesh->_name.c_str()), + MEDArrayNodeFamily, + NumberOfNodes, + MED_FR::MED_REMP, + MED_FR::MED_NOEUD); - // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArrayNodeFamily DOIT ETRE ENLEVER DE LA CLASSE MESH - err = MEDfamEcr(_medIdt, const_cast ( _meshName.c_str() ), - _ptrMesh->_MEDArrayNodeFamily, _ptrMesh->getNumberOfNodes(),MED_FR::MED_REMP , - MED_NOEUD,(enum MED_FR::med_geometrie_element) MED_NONE); if ( err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write node family for the |"<< _ptrMesh->getNumberOfNodes() - << "| nodes in mesh |" - << _ptrMesh->_name.c_str() << "|" )); + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write node family for the |"<< NumberOfNodes + << "| nodes in mesh |" + << _ptrMesh->_name.c_str() << "|" )); + delete[] MEDArrayNodeFamily; + //if (true == ToDestroy) + // for (int i=0; i_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH + if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) { + int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ; + const medGeometryElement * types = _ptrMesh->getTypes (entity) ; + + // We build the array from the families list objects : + int NumberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS); + int * MEDArrayFamily = new int[NumberOfElements] ; + // family 0 by default + for (int i=0; i myFamilies = _ptrMesh->getFamilies(entity); + vector * myFamilies = &_ptrMesh->_familyCell ; + int NumberOfFamilies = myFamilies->size() ; + //bool ToDestroy = false; + if (0 == NumberOfFamilies) { + //ToDestroy = true ; + vector myGroups = _ptrMesh->getGroups(entity); + int NumberOfGroups = myGroups.size() ; + // build families from groups + for (int i=0; igetName() ); + SUPPORT * mySupport = myGroups[i] ; + FAMILY* myFamily = new FAMILY(*mySupport); + myFamily->setIdentifier(-i-1); + myFamilies->push_back(myFamily); + } + NumberOfFamilies=myFamilies->size() ; + } + for (int i=0 ; igetIdentifier() ; + int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ; + if ((*myFamilies)[i]->isOnAllElements()) + for (int ii=0; iigetNumber(MED_ALL_ELEMENTS) ; + for (int ii=0; ii_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH - if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) { + const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ; - int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ; - medGeometryElement * types = _ptrMesh->getTypes (entity) ; - - for (int i=0; i ( _meshName.c_str() ), - _ptrMesh->_MEDArrayCellFamily[i], _ptrMesh->getNumberOfElements(entity, types[i]), - MED_FR::MED_REMP , - (MED_FR::med_entite_maillage) entity, - (MED_FR::med_geometrie_element) types[i]); - - if ( err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i]) - << "| cells of geometric type |" << geoNames[ (MED_FR::med_geometrie_element) types[i]] <<"|in mesh |" - << _ptrMesh->_name.c_str() << "|" )); - } + err = MEDfamEcr(_medIdt, const_cast ( _meshName.c_str() ), + MEDArrayFamily+typeCount[i]-1,typeCount[i+1]-typeCount[i], + MED_FR::MED_REMP , + (MED_FR::med_entite_maillage) entity, + (MED_FR::med_geometrie_element) types[i] +); + MESSAGE("OK "<getNumberOfElements(entity, types[i]) + << "| cells of geometric type |" << MED_FR::geoNames[ (MED_FR::med_geometrie_element) types[i]] <<"|in mesh |" + << _ptrMesh->_name.c_str() << "|" )); } + delete[] MEDArrayFamily ; + //if (true == ToDestroy) { + // int NumberOfFamilies = myFamilies->size(); + // for (int i=0; i_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH - if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) { + { // FACE RELATED BLOCK + medEntityMesh entity=MED_EN::MED_FACE; + // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH + if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) { - int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ; - medGeometryElement * types = _ptrMesh->getTypes (entity) ; + int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ; + const medGeometryElement * types = _ptrMesh->getTypes (entity) ; + SCRUTE(numberOfTypes); - int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ; - int * familyArray = new int[numberOfElements] ; - for (int i=0;igetNumberOfFamilies(entity) ; - vector myFamilies = _ptrMesh->getFamilies(entity) ; - for (int i=0;igetIdentifier() ; - int numberOfFamilyElements = myFamilies[i]->getNumberOfElements(MED_ALL_ELEMENTS) ; - int * myFamilyElements = myFamilies[i]->getNumber(MED_ALL_ELEMENTS) ; + int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ; + int * familyArray = new int[numberOfElements] ; + for (int i=0;igetNumberOfFamilies(entity) ; + //vector myFamilies = _ptrMesh->getFamilies(entity) ; + vector * myFamilies = &_ptrMesh->_familyFace ; + //bool ToDestroy = false; + if (0 == numberOfFamilies) { + //ToDestroy = true ; + vector myGroups = _ptrMesh->getGroups(entity); + int NumberOfGroups = myGroups.size() ; + // build families from groups + for (int i=0; igetName() ); + SUPPORT * mySupport = myGroups[i] ; + FAMILY* myFamily = new FAMILY(*mySupport); + myFamily->setIdentifier(-i-1000); + myFamilies->push_back(myFamily); + } + numberOfFamilies=myFamilies->size() ; + } + for (int i=0;igetIdentifier() ; + int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ; + if ((*myFamilies)[i]->isOnAllElements()) + for (int ii=0; iigetNumber(MED_ALL_ELEMENTS) ; for (int ii=0;iigetGlobalNumberingIndex(entity) ; - - for (int i=0; igetGlobalNumberingIndex(entity) ; - int typeNumberOfElements = typeCount[i+1] - typeCount[i] ; - err = MEDfamEcr(_medIdt, const_cast ( _meshName.c_str() ), - familyArray+typeCount[i]-1, typeNumberOfElements, - MED_FR::MED_REMP , - (MED_FR::med_entite_maillage) entity, - (MED_FR::med_geometrie_element) types[i]); + for (int i=0; igetNumberOfElements(entity, types[i]) - << "| faces of geometric type |" << geoNames[ (MED_FR::med_geometrie_element) types[i]] <<"|in mesh |" - << _ptrMesh->_name.c_str() << "|" )); - } - delete[] familyArray ; + int typeNumberOfElements = typeCount[i+1] - typeCount[i] ; + err = MEDfamEcr(_medIdt, const_cast ( _meshName.c_str() ), + familyArray+typeCount[i]-1, typeNumberOfElements, + MED_FR::MED_REMP , + (MED_FR::med_entite_maillage) entity, + (MED_FR::med_geometrie_element) types[i]); + + if ( err != MED_VALID) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i]) + << "| faces of geometric type |" << MED_FR::geoNames[ (MED_FR::med_geometrie_element) types[i]] <<"|in mesh |" + << _ptrMesh->_name.c_str() << "|" )); } + delete[] familyArray ; + //if (true == ToDestroy) { + // int NumberOfFamilies = myFamilies->size(); + // for (int i=0; i_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH - if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) { + { // EDGE RELATED BLOCK + //medEntityMesh entity=MED_EN::MED_FACE; + medEntityMesh entity=MED_EN::MED_EDGE; + // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH + if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) { - int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ; - medGeometryElement * types = _ptrMesh->getTypes (entity) ; + int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ; + const medGeometryElement * types = _ptrMesh->getTypes (entity) ; - int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ; - int * familyArray = new int[numberOfElements] ; - for (int i=0;igetNumberOfFamilies(entity) ; - vector myFamilies = _ptrMesh->getFamilies(entity) ; - for (int i=0;igetIdentifier() ; - int numberOfFamilyElements = myFamilies[i]->getNumberOfElements(MED_ALL_ELEMENTS) ; - int * myFamilyElements = myFamilies[i]->getNumber(MED_ALL_ELEMENTS) ; + int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ; + int * familyArray = new int[numberOfElements] ; + for (int i=0;igetNumberOfFamilies(entity) ; + //vector myFamilies = _ptrMesh->getFamilies(entity) ; + vector * myFamilies = &_ptrMesh->_familyEdge ; + //bool ToDestroy = false; + if (0 == numberOfFamilies) { + //ToDestroy = true ; + vector myGroups = _ptrMesh->getGroups(entity); + int NumberOfGroups = myGroups.size() ; + // build families from groups + for (int i=0; igetName() ); + SUPPORT * mySupport = myGroups[i] ; + FAMILY* myFamily = new FAMILY(*mySupport); + myFamily->setIdentifier(-i-2000); + myFamilies->push_back(myFamily); + } + numberOfFamilies=myFamilies->size() ; + } + for (int i=0;igetIdentifier() ; + int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ; + if ((*myFamilies)[i]->isOnAllElements()) + for (int ii=0; iigetNumber(MED_ALL_ELEMENTS) ; for (int ii=0;iigetGlobalNumberingIndex(entity) ; + const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ; - for (int i=0; i ( _meshName.c_str() ), - familyArray+typeCount[i]-1, typeNumberOfElements, - MED_FR::MED_REMP , - (MED_FR::med_entite_maillage) entity, - (MED_FR::med_geometrie_element) types[i]); + int typeNumberOfElements = typeCount[i+1] - typeCount[i] ; + err = MEDfamEcr(_medIdt, const_cast ( _meshName.c_str() ), + familyArray+typeCount[i]-1, typeNumberOfElements, + MED_FR::MED_REMP , + (MED_FR::med_entite_maillage) entity, + (MED_FR::med_geometrie_element) types[i]); - if ( err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i]) - << "| edges of geometric type |" << geoNames[ (MED_FR::med_geometrie_element) types[i]] <<"|in mesh |" - << _ptrMesh->_name.c_str() << "|" )); - } + if ( err != MED_VALID) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i]) + << "| edges of geometric type |" << MED_FR::geoNames[ (MED_FR::med_geometrie_element) types[i]] <<"|in mesh |" + << _ptrMesh->_name.c_str() << "|" )); } + delete[] familyArray ; + //if (true == ToDestroy) { + // int NumberOfFamilies = myFamilies->size(); + // for (int i=0; i & families ) const { const char * LOC="int MED_MESH_WRONLY_DRIVER::writeFamilies(vector families) const : "; @@ -1298,91 +2068,129 @@ int MED_MESH_WRONLY_DRIVER::writeFamilies(vector & families ) const { MED_FR::med_err err; - if (_status==MED_OPENED) { + MESSAGE(LOC<<" families.size() :"<getNumberOfAttributes (); + string attributesDescriptions = ""; - int numberOfAttributes = families[i]->getNumberOfAttributes (); - string attributesDescriptions = ""; - - // Recompose the attributes descriptions arg for MED - for (int j=0; j < numberOfAttributes; j++) { + // Recompose the attributes descriptions arg for MED + for (int j=0; j < numberOfAttributes; j++) { - string attributeDescription = families[i]->getAttributeDescription(j+1); + string attributeDescription = families[i]->getAttributeDescription(j+1); - if ( attributeDescription.size() > MED_TAILLE_DESC ) - throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the attribute description n° |" << j+1 << "| of the family |" << families[i]->getName() - << "| with identifier |" << families[i]->getIdentifier() << "| is |" - << attributeDescription.size() <<"| and is more than |" << MED_TAILLE_DESC << "|")) ; + if ( attributeDescription.size() > MED_TAILLE_DESC ) + throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the attribute description n° |" << j+1 << "| of the family |" << families[i]->getName() + << "| with identifier |" << families[i]->getIdentifier() << "| is |" + << attributeDescription.size() <<"| and is more than |" << MED_TAILLE_DESC << "|")) ; - attributesDescriptions += attributeDescription; - } + attributesDescriptions += attributeDescription; + } - int numberOfGroups = families[i]->getNumberOfGroups(); - string groupsNames(numberOfGroups*MED_TAILLE_LNOM,'\0') ; - // Recompose the groups names arg for MED - for (int j=0; j < numberOfGroups; j++) { + int numberOfGroups = families[i]->getNumberOfGroups(); + string groupsNames(numberOfGroups*MED_TAILLE_LNOM,'\0') ; + // Recompose the groups names arg for MED + for (int j=0; j < numberOfGroups; j++) { - string groupName = families[i]->getGroupName(j+1); + string groupName = families[i]->getGroupName(j+1); - if ( groupName.size() > MED_TAILLE_LNOM ) - throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the group name n° |" << j+1 << "| of the family |" << families[i]->getName() - << "| with identifier |" << families[i]->getIdentifier() << "| is |" - << groupName.size() <<"| and is more than |" << MED_TAILLE_LNOM << "|")) ; + if ( groupName.size() > MED_TAILLE_LNOM ) + throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the group name n° |" << j+1 << "| of the family |" << families[i]->getName() + << "| with identifier |" << families[i]->getIdentifier() << "| is |" + << groupName.size() <<"| and is more than |" << MED_TAILLE_LNOM << "|")) ; - int length = min(MED_TAILLE_LNOM,(int)groupName.size()); - groupsNames.replace(j*MED_TAILLE_LNOM,length, groupName,0,length); + int length = min(MED_TAILLE_LNOM,(int)groupName.size()); + groupsNames.replace(j*MED_TAILLE_LNOM,length, groupName,0,length); - } - - // test if the family already exists (HDF trick waiting a MED evolution to be replaced) - string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/"+families[i]->getName()+"/"; - SCRUTE("|"< (dataGroupFam.c_str()) ) < MED_VALID ) { - SCRUTE(err); - - MESSAGE(LOC<<"families[i]->getName().c_str() : "<getName().c_str()); - MESSAGE(LOC<<"_meshName.c_str() : "<<_meshName.c_str()); - MESSAGE(LOC<<"families[i]->getIdentifier() : "<getIdentifier()); - MESSAGE(LOC<<"families[i]->getAttributesIdentifiers() : "<getAttributesIdentifiers()[0]); - MESSAGE(LOC<<"families[i]->getAttributesValues() : "<getAttributesValues()[0]); - MESSAGE(LOC<<"attributesDescriptions.c_str() : "< ( _meshName.c_str() ), - const_cast ( families[i]->getName().c_str() ), - families[i]->getIdentifier(), - families[i]->getAttributesIdentifiers(), - families[i]->getAttributesValues(), - const_cast (attributesDescriptions.c_str()), - numberOfAttributes, - const_cast (groupsNames.c_str()), - numberOfGroups); - SCRUTE(err); - if ( err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |" << families[i]->getName() - << "| with identifier |" << families[i]->getIdentifier() << "| groups names |" - << groupsNames <<"| and attributes descriptions |" << attributesDescriptions << "|")) ; - } - else - _MEDdatagroupFermer(_medIdt); + } + // test if the family already exists (HDF trick waiting a MED evolution to be replaced) + string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/"+families[i]->getName()+"/"; + SCRUTE("|"< (dataGroupFam.c_str()) ) < MED_VALID ) { + SCRUTE(err); + MESSAGE(LOC<<"families[i]->getName().c_str() : "<getName().c_str()); + MESSAGE(LOC<<"_meshName.c_str() : "<<_meshName.c_str()); + MESSAGE(LOC<<"families[i]->getIdentifier() : "<getIdentifier()); + MESSAGE(LOC<<"numberOfAttributes : "<getAttributesIdentifiers() : "<getAttributesIdentifiers()[0]); + //MESSAGE(LOC<<"families[i]->getAttributesValues() : "<getAttributesValues()[0]); + MESSAGE(LOC<<"attributesDescriptions.c_str() : "< ( _meshName.c_str() ), + const_cast ( families[i]->getName().c_str() ), + families[i]->getIdentifier(), + families[i]->getAttributesIdentifiers(), + families[i]->getAttributesValues(), + const_cast (attributesDescriptions.c_str()), + numberOfAttributes, + const_cast (groupsNames.c_str()), + numberOfGroups); + SCRUTE(err); + if ( err != MED_VALID) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |" << families[i]->getName() + << "| with identifier |" << families[i]->getIdentifier() << "| groups names |" + << groupsNames <<"| and attributes descriptions |" << attributesDescriptions << "|")) ; } + else + _MEDdatagroupFermer(_medIdt); + - END_OF(LOC); - - return MED_VALID; } - return MED_ERROR; + + END_OF(LOC); + + return MED_VALID; } // A FAIRE POUR LES NOEUDS ET LES ELEMENTS ret = MEDfamEcr( + + + +/*--------------------- RDWR PART -------------------------------*/ + +MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER():MED_MESH_DRIVER() +{ +} + +MED_MESH_RDWR_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"); +} + +MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const MED_MESH_RDWR_DRIVER & driver): + MED_MESH_RDONLY_DRIVER::MED_MESH_DRIVER(driver) +{ +} + +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"); +} + +GENDRIVER * MED_MESH_RDWR_DRIVER::copy(void) const +{ + return new MED_MESH_RDWR_DRIVER(*this); +} + +void MED_MESH_RDWR_DRIVER::write(void) const + throw (MEDEXCEPTION) +{ + MED_MESH_WRONLY_DRIVER::write(); +} +void MED_MESH_RDWR_DRIVER::read (void) + throw (MEDEXCEPTION) +{ + MED_MESH_RDONLY_DRIVER::read(); +} + diff --git a/src/MEDMEM/MEDMEM_MedMeshDriver.hxx b/src/MEDMEM/MEDMEM_MedMeshDriver.hxx index 469f22e50..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 (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_Mesh.cxx b/src/MEDMEM/MEDMEM_Mesh.cxx index 9f41519e1..0050168db 100644 --- a/src/MEDMEM/MEDMEM_Mesh.cxx +++ b/src/MEDMEM/MEDMEM_Mesh.cxx @@ -1,3 +1,30 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_Mesh.cxx +// Module : MED + +using namespace std; /* File Mesh.cxx $Header$ @@ -8,13 +35,17 @@ #include #include +#include "MEDMEM_DriversDef.hxx" #include "MEDMEM_Field.hxx" #include "MEDMEM_Mesh.hxx" +#include "MEDMEM_Support.hxx" #include "MEDMEM_Family.hxx" #include "MEDMEM_Group.hxx" +#include "MEDMEM_Coordinate.hxx" #include "MEDMEM_Connectivity.hxx" #include "MEDMEM_CellModel.hxx" +#include "MEDMEM_Grid.hxx" //update Families with content list //int family_count(int family_number, int count, int * entities_number, int * entities_list) ; @@ -24,13 +55,17 @@ // MESH::INSTANCE_DE MESH::inst_med_rdonly ; //const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med_rdonly , &MESH::inst_med_rdwr } ; +// Add a similar line for your personnal driver (step 3) MESH::INSTANCE_DE MESH::inst_med ; -const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med } ; +MESH::INSTANCE_DE MESH::inst_gibi ; +// Add your own driver in the driver list (step 4) +// Note the list must be coherent with the driver type list defined in MEDMEM_DRIVER.hxx. +const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med, &MESH::inst_gibi } ; /*! Add a MESH driver of type (MED_DRIVER, ....) associated with file . The meshname used in the file is . addDriver returns an int handler. */ int MESH::addDriver(driverTypes driverType, - const string & fileName="Default File Name.med",const string & driverName="Default Mesh Name") { + const string & fileName/*="Default File Name.med"*/,const string & driverName/*="Default Mesh Name"*/) { const char * LOC = "MESH::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Mesh Name\") : "; @@ -55,15 +90,17 @@ int MESH::addDriver(GENDRIVER & driver) { const char * LOC = "MESH::addDriver(GENDRIVER &) : "; BEGIN_OF(LOC); - // A FAIRE VERIFIER QUE LE DRIVER EST DE TYPE MESH !! - _drivers.push_back(&driver); + // A faire : Vérifier que le driver est de type MESH. + GENDRIVER * newDriver = driver.copy() ; + + _drivers.push_back(newDriver); return _drivers.size()-1; - + END_OF(LOC); } /*! Remove an existing MESH driver. */ -void MESH::rmDriver (int index=0) { +void MESH::rmDriver (int index/*=0*/) { const char * LOC = "MESH::rmDriver (int index=0): "; BEGIN_OF(LOC); @@ -88,17 +125,12 @@ void MESH::rmDriver (int index=0) { void MESH::init() { + const char * LOC = "MESH::init(): "; + + BEGIN_OF(LOC); + string _name = "NOT DEFINED"; // A POSITIONNER EN FCT DES IOS ? - _numberOfMEDNodeFamily = MED_INVALID; - _MEDArrayNodeFamily = (int * ) NULL; // SOLUTION TEMPORAIRE - _numberOfMEDCellFamily = (int * ) NULL; - _numberOfMEDFaceFamily = (int * ) NULL; - _numberOfMEDEdgeFamily = (int * ) NULL; - _MEDArrayCellFamily = (int **) NULL; // SOLUTION TEMPORAIRE - _MEDArrayFaceFamily = (int **) NULL; // SOLUTION TEMPORAIRE - _MEDArrayEdgeFamily = (int **) NULL; // SOLUTION TEMPORAIRE - COORDINATE * _coordinate = (COORDINATE *) NULL; CONNECTIVITY * _connectivity = (CONNECTIVITY *) NULL; @@ -116,58 +148,146 @@ void MESH::init() { _numberOfFacesGroups = 0; _numberOfEdgesGroups = 0; + _isAGrid = false; }; /*! Create an empty MESH. */ -MESH::MESH() { +MESH::MESH():_coordinate(NULL),_connectivity(NULL) { init(); }; -MESH::MESH(const MESH &m) +MESH::MESH(MESH &m) { - // VERIFIER QUE TS LES OPERATEURS DE RECOPIE DES ATTRIBUTS - // SONT CORRECTS. - *this = m; + _name=m._name; + _isAGrid = m._isAGrid; + + if (m._coordinate != NULL) + _coordinate = new COORDINATE(* m._coordinate); + else + _coordinate = (COORDINATE *) NULL; + + if (m._connectivity != NULL) + _connectivity = new CONNECTIVITY(* m._connectivity); + else + _connectivity = (CONNECTIVITY *) NULL; + + _spaceDimension = m._spaceDimension; + _meshDimension = m._meshDimension; + _numberOfNodes = m._numberOfNodes; + + _numberOfNodesFamilies = m._numberOfNodesFamilies; + _familyNode = m._familyNode; + for (int i=0; isetMesh(this); + } + + _numberOfCellsFamilies = m._numberOfCellsFamilies; + _familyCell = m._familyCell; + for (int i=0; isetMesh(this); + } + + _numberOfFacesFamilies = m._numberOfFacesFamilies; + _familyFace = m._familyFace; + for (int i=0; isetMesh(this); + } + + _numberOfEdgesFamilies = m._numberOfEdgesFamilies; + _familyEdge = m._familyEdge; + for (int i=0; isetMesh(this); + } + + _numberOfNodesGroups = m._numberOfNodesGroups; + _groupNode = m._groupNode; + for (int i=0; isetMesh(this); + } + + _numberOfCellsGroups = m._numberOfCellsGroups; + _groupCell = m._groupCell; + for (int i=0; isetMesh(this); + } + + _numberOfFacesGroups = m._numberOfFacesGroups; + _groupFace = m._groupFace; + for (int i=0; isetMesh(this); + } + + _numberOfEdgesGroups = m._numberOfEdgesGroups; + _groupEdge = m._groupEdge; + for (int i=0; isetMesh(this); + } + + //_drivers = m._drivers; //Recopie des drivers? } MESH::~MESH() { - if ( _MEDArrayNodeFamily != (int * ) NULL) delete [] _MEDArrayNodeFamily; // SOLUTION TEMPORAIRE - if ( _numberOfMEDCellFamily != (int * ) NULL) delete [] _numberOfMEDCellFamily; - if ( _numberOfMEDFaceFamily != (int * ) NULL) delete [] _numberOfMEDFaceFamily; - if ( _numberOfMEDEdgeFamily != (int * ) NULL) delete [] _numberOfMEDEdgeFamily; - // IL FAUT FAIRE UNE BOUCLE DE DESALLOCATION - if ( _MEDArrayCellFamily != (int **) NULL) delete [] _MEDArrayCellFamily; // SOLUTION TEMPORAIRE - if ( _MEDArrayFaceFamily != (int **) NULL) delete [] _MEDArrayFaceFamily; // SOLUTION TEMPORAIRE - if ( _MEDArrayEdgeFamily != (int **) NULL) delete [] _MEDArrayEdgeFamily; // SOLUTION TEMPORAIRE - - if (_coordinate != NULL) delete _coordinate ; - if (_connectivity != NULL) delete _connectivity ; + MESSAGE("MESH::~MESH() : Destroying the Mesh"); + if (_coordinate != ((COORDINATE *) NULL)) delete _coordinate ; + if (_connectivity != ((CONNECTIVITY *) NULL)) delete _connectivity ; int size ; size = _familyNode.size() ; for (int i=0;i. The meshname must already exists in the file.*/ -MESH::MESH(driverTypes driverType, const string & fileName="", const string & driverName="") { +MESH::MESH(driverTypes driverType, const string & fileName/*=""*/, const string & driverName/*=""*/) { const char * LOC ="MESH::MESH(driverTypes driverType, const string & fileName="", const string & driverName="") : "; int current; @@ -220,18 +340,25 @@ MESH::MESH(driverTypes driverType, const string & fileName="", const string & init(); - current = addDriver(driverType,fileName,driverName); - switch(_drivers[current]->getAccessMode() ) { - case MED_RDONLY : { - MESSAGE("MESH::MESH(driverTypes driverType, .....) : driverType must have a MED_RDWR accessMode"); - rmDriver(current); - break;} - default : { - } - } + MED_MESH_RDONLY_DRIVER myDriver(fileName,this) ; + myDriver.setMeshName(driverName); + current = addDriver(myDriver); +// current = addDriver(driverType,fileName,driverName); +// switch(_drivers[current]->getAccessMode() ) { +// case MED_WRONLY : { +// MESSAGE("MESH::MESH(driverTypes driverType, .....) : driverType must not be a MED_WRONLY accessMode"); +// rmDriver(current); +// break;} +// default : { +// } +// } _drivers[current]->open(); _drivers[current]->read(); _drivers[current]->close(); + + if (_isAGrid) + ((GRID *) this)->fillMeshAfterRead(); + END_OF(LOC); }; @@ -246,62 +373,127 @@ MESH::MESH(driverTypes driverType, const string & fileName="", const string & ostream & operator<<(ostream &os, MESH &myMesh) { -// int space_dimension = myMesh.get_space_dimension(); -// os << "Space dimension "<< space_dimension << endl ; -// int nodes_count = myMesh.get_nodes_count() ; -// os << "Nodes count : "<< nodes_count << endl ; -// double * coord = myMesh.get_coordinates(); -// os << "Coordinates :" << endl ; -// string * coordinate_name = myMesh.get_coordinates_name() ; -// string * coordinate_unit = myMesh.get_coordinates_unit() ; - -// for(int i=0;i nodes_Families = myMesh.get_nodes_Families() ; -// for(int i=0;i cells_Families = myMesh.get_cells_Families() ; -// for(int i=0;iexistConnectivity(MED_NODAL,MED_CELL) && myConnectivity->existConnectivity(MED_DESCENDING,MED_CELL)) + { + os << endl << "SHOW CONNECTIVITY (DESCENDING) :" << endl; + int numberofelements; + const int * connectivity; + const int * connectivity_index; + myMesh.calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL); + try { + numberofelements = myMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); + connectivity = myMesh.getConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS); + connectivity_index = myMesh.getConnectivityIndex(MED_DESCENDING,MED_CELL); + } + catch (MEDEXCEPTION m) { + os << m.what() << endl; + exit (-1); + } + for (int j=0;jsetAll(false); - int * myConnectivityValue = getReverseConnectivity(MED_DESCENDING) ; - int * myConnectivityIndex = getReverseConnectivityIndex(MED_DESCENDING) ; + const int * myConnectivityValue = getReverseConnectivity(MED_DESCENDING) ; + const int * myConnectivityIndex = getReverseConnectivityIndex(MED_DESCENDING) ; int numberOf = getNumberOfElements(Entity,MED_ALL_ELEMENTS) ; list myElementsList ; int size = 0 ; - SCRUTE(numberOf) ; for (int i=0 ; i::iterator myElementsListIt ; for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) { myListArray[id]=(*myElementsListIt) ; - SCRUTE(id); - SCRUTE(myListArray[id]); id ++ ; } @@ -410,22 +598,22 @@ SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION) medGeometryElement* geometricType ; int * numberOfGaussPoint ; int * geometricTypeNumber ; - int * numberOfEntities ; - MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ; + int * numberOfElements ; + //MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ; int * mySkyLineArrayIndex ; int numberOfType = getNumberOfTypes(Entity) ; if (numberOfType == 1) { // wonderfull : it's easy ! numberOfGeometricType = 1 ; geometricType = new medGeometryElement[1] ; - medGeometryElement * allType = getTypes(Entity); + const medGeometryElement * allType = getTypes(Entity); geometricType[0] = allType[0] ; numberOfGaussPoint = new int[1] ; numberOfGaussPoint[0] = 1 ; geometricTypeNumber = new int[1] ; // not use, but initialized to nothing geometricTypeNumber[0] = 0 ; - numberOfEntities = new int[1] ; - numberOfEntities[0] = size ; + numberOfElements = new int[1] ; + numberOfElements[0] = size ; mySkyLineArrayIndex = new int[2] ; mySkyLineArrayIndex[0]=1 ; mySkyLineArrayIndex[1]=1+size ; @@ -441,10 +629,10 @@ SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION) } numberOfGeometricType = theType.size() ; geometricType = new medGeometryElement[numberOfGeometricType] ; - medGeometryElement * allType = getTypes(Entity); + const medGeometryElement * allType = getTypes(Entity); numberOfGaussPoint = new int[numberOfGeometricType] ; geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing - numberOfEntities = new int[numberOfGeometricType] ; + numberOfElements = new int[numberOfGeometricType] ; mySkyLineArrayIndex = new int[numberOfGeometricType+1] ; int index = 0 ; mySkyLineArrayIndex[0]=1 ; @@ -453,53 +641,64 @@ SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION) geometricType[index] = (*theTypeIt).first ; numberOfGaussPoint[index] = 1 ; geometricTypeNumber[index] = 0 ; - numberOfEntities[index] = (*theTypeIt).second ; - mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfEntities[index] ; + numberOfElements[index] = (*theTypeIt).second ; + mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfElements[index] ; index++ ; } } - mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ; + //mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ; + MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ; mySupport->setNumberOfGeometricType(numberOfGeometricType) ; mySupport->setGeometricType(geometricType) ; mySupport->setNumberOfGaussPoint(numberOfGaussPoint) ; - mySupport->setGeometricTypeNumber(geometricTypeNumber) ; - mySupport->setNumberOfEntities(numberOfEntities) ; - mySupport->setTotalNumberOfEntities(size) ; + mySupport->setNumberOfElements(numberOfElements) ; + mySupport->setTotalNumberOfElements(size) ; + // mySupport->setGeometricTypeNumber(geometricTypeNumber) ; mySupport->setNumber(mySkyLineArray) ; + delete[] numberOfElements; + delete[] geometricTypeNumber; + delete[] numberOfGaussPoint; + delete[] geometricType; + delete[] mySkyLineArrayIndex; + delete[] myListArray; +// delete mySkyLineArray; + END_OF(LOC) ; return mySupport ; } -FIELD* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) +FIELD* MESH::getVolume(const SUPPORT * Support) const throw (MEDEXCEPTION) { + const char * LOC = "MESH::getVolume(SUPPORT*) : "; + BEGIN_OF(LOC); + // Support must be on 3D elements - MESSAGE("MESH::getVolume(SUPPORT*)"); // Make sure that the MESH class is the same as the MESH class attribut // in the class Support MESH* myMesh = Support->getMesh(); if (this != myMesh) - throw MEDEXCEPTION("MESH::getVolume(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !"); + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !")); int dim_space = getSpaceDimension(); medEntityMesh support_entity = Support->getEntity(); bool onAll = Support->isOnAllElements(); int nb_type, length_values; - medGeometryElement* types; + const medGeometryElement* types; int nb_entity_type; // !!!! WARNING : use of nodal global numbering in the mesh !!!! - int* global_connectivity; + const int* global_connectivity; - if (onAll) - { - nb_type = myMesh->getNumberOfTypes(support_entity); - length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS); - types = getTypes(support_entity); - } - else +// if (onAll) +// { +// nb_type = myMesh->getNumberOfTypes(support_entity); +// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS); +// types = getTypes(support_entity); +// } +// else { nb_type = Support->getNumberOfTypes(); length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS); @@ -507,9 +706,7 @@ FIELD* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) } int index; - FIELD* Volume; - - Volume = new FIELD::FIELD(Support,1); + FIELD* Volume = new FIELD::FIELD(Support,1); // double *volume = new double [length_values]; Volume->setName("VOLUME"); Volume->setDescription("cells volume"); @@ -528,9 +725,10 @@ FIELD* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) Volume->setOrderNumber(0); Volume->setTime(0.0); - double *volume = Volume->getValue(MED_FULL_INTERLACE); + //const double *volume = Volume->getValue(MED_FULL_INTERLACE); + MEDARRAY *volume = Volume->getvalue(); - index = 0; + index = 1; const double * coord = getCoordinates(MED_FULL_INTERLACE); for (int i=0;i* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) } else { - nb_entity_type = Support->getNumberOfElements(type); - - int * supp_number = Support->getNumber(type); - int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS); - int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); - global_connectivity = new int[(type%100)*nb_entity_type]; - - for (int k_type = 0; k_typegetNumberOfElements(type); + + const int * supp_number = Support->getNumber(type); + const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS); + const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); + int * global_connectivity_tmp = new int[(type%100)*nb_entity_type]; + + for (int k_type = 0; k_type* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) (x2-x1)*((y3-y1)*(z4-z1) - (z3-z1)*(y4-y1)) + (x4-x1)*((y3-y1)*(z2-z1) - (z3-z1)*(y2-y1)))/6.0; - volume[index] = xvolume ; + //volume[index] = xvolume ; + volume->setIJ(index,1,xvolume) ; index++; } break; @@ -634,7 +836,8 @@ FIELD* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) (x5-x1)*((y4-y1)*(z3-z1) - (z4-z1)*(y3-y1))) )/6.0; - volume[index] = xvolume ; + //volume[index] = xvolume ; + volume->setIJ(index,1,xvolume) ; index = index++; } break; @@ -705,7 +908,8 @@ FIELD* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) xvolume = -2.0*(2.0*(A + B + D + E + G + H) + C + F + P)/9.0; - volume[index] = xvolume ; + //volume[index] = xvolume ; + volume->setIJ(index,1,xvolume) ; index++; } break; @@ -871,13 +1075,14 @@ FIELD* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) V + W) + 2.0*(I + R + U + X + Y + Z) + AA)/27.0; - volume[index] = xvolume ; + //volume[index] = xvolume ; + volume->setIJ(index,1,xvolume) ; index++; } break; } default : - throw MEDEXCEPTION("MESH::getVolume(SUPPORT*) Bad Support to get Volumes on it !"); + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Volumes on it !")); break; } } @@ -885,34 +1090,36 @@ FIELD* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) return Volume; } -FIELD* MESH::getArea(const SUPPORT * Support) throw (MEDEXCEPTION) +FIELD* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) { + const char * LOC = "MESH::getArea(SUPPORT*) : "; + BEGIN_OF(LOC); + // Support must be on 2D elements - MESSAGE("MESH::getArea(SUPPORT*)"); // Make sure that the MESH class is the same as the MESH class attribut // in the class Support MESH* myMesh = Support->getMesh(); if (this != myMesh) - throw MEDEXCEPTION("MESH::getArea(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !"); + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !")); int dim_space = getSpaceDimension(); medEntityMesh support_entity = Support->getEntity(); bool onAll = Support->isOnAllElements(); int nb_type, length_values; - medGeometryElement* types; + const medGeometryElement* types; int nb_entity_type; // !!!! WARNING : use of nodal global numbering in the mesh !!!! - int* global_connectivity; + const int* global_connectivity; - if (onAll) - { - nb_type = myMesh->getNumberOfTypes(support_entity); - length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS); - types = getTypes(support_entity); - } - else +// if (onAll) +// { +// nb_type = myMesh->getNumberOfTypes(support_entity); +// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS); +// types = getTypes(support_entity); +// } +// else { nb_type = Support->getNumberOfTypes(); length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS); @@ -959,18 +1166,23 @@ FIELD* MESH::getArea(const SUPPORT * Support) throw (MEDEXCEPTION) } else { - nb_entity_type = Support->getNumberOfElements(type); + // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all !")); + + nb_entity_type = Support->getNumberOfElements(type); + + const int * supp_number = Support->getNumber(type); + const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS); + const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); + int * global_connectivity_tmp = new int[(type%100)*nb_entity_type]; + + for (int k_type = 0; k_typegetNumber(type); - int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS); - int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); - global_connectivity = new int[(type%100)*nb_entity_type]; - - for (int k_type = 0; k_type* MESH::getArea(const SUPPORT * Support) throw (MEDEXCEPTION) break; } default : - throw MEDEXCEPTION("MESH::getArea(SUPPORT*) Bad Support to get Areas on it !"); + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Areas on it !")); break; } } Area->setValue(MED_FULL_INTERLACE,area); - + delete[] area; return Area; } -FIELD* MESH::getLength(const SUPPORT * Support) throw (MEDEXCEPTION) +FIELD* MESH::getLength(const SUPPORT * Support) const throw (MEDEXCEPTION) { + const char * LOC = "MESH::getLength(SUPPORT*) : "; + BEGIN_OF(LOC); + // Support must be on 1D elements - MESSAGE("MESH::getLength(SUPPORT*)"); // Make sure that the MESH class is the same as the MESH class attribut // in the class Support MESH* myMesh = Support->getMesh(); if (this != myMesh) - throw MEDEXCEPTION("MESH::getLength(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !"); + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !")); int dim_space = getSpaceDimension(); medEntityMesh support_entity = Support->getEntity(); bool onAll = Support->isOnAllElements(); int nb_type, length_values; - medGeometryElement* types; + const medGeometryElement* types; int nb_entity_type; // !!!! WARNING : use of nodal global numbering in the mesh !!!! - int* global_connectivity; + const int* global_connectivity; - if (onAll) - { - nb_type = myMesh->getNumberOfTypes(support_entity); - length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS); - types = getTypes(support_entity); - } - else +// if (onAll) +// { +// nb_type = myMesh->getNumberOfTypes(support_entity); +// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS); +// types = getTypes(support_entity); +// } +// else { nb_type = Support->getNumberOfTypes(); length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS); @@ -1125,10 +1339,11 @@ FIELD* MESH::getLength(const SUPPORT * Support) throw (MEDEXCEPTION) // double *length = new double [length_values]; Length->setValueType(MED_REEL64); - double *length = Length->getValue(MED_FULL_INTERLACE); + //const double *length = Length->getValue(MED_FULL_INTERLACE); + MEDARRAY * length = Length->getvalue(); const double * coord = getCoordinates(MED_FULL_INTERLACE); - index = 0; + index = 1; for (int i=0;i* MESH::getLength(const SUPPORT * Support) throw (MEDEXCEPTION) } else { - nb_entity_type = Support->getNumberOfElements(type); + //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all !")); - int * supp_number = Support->getNumber(type); - int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS); - int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); - global_connectivity = new int[(type%100)*nb_entity_type]; + nb_entity_type = Support->getNumberOfElements(type); - for (int k_type = 0; k_typegetNumber(type); + const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS); + const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); + int* global_connectivity_tmp = new int[(type%100)*nb_entity_type]; + + for (int k_type = 0; k_type* MESH::getLength(const SUPPORT * Support) throw (MEDEXCEPTION) xlength = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2) + (z1 - z2)*(z1 - z2)); - length[index] = xlength ; + length->setIJ(index,1,xlength) ; index++; } break; } default : - throw MEDEXCEPTION("MESH::getLength(SUPPORT*) Bad Support to get Lengths on it !"); + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Lengths on it !")); break; } } @@ -1193,34 +1411,36 @@ FIELD* MESH::getLength(const SUPPORT * Support) throw (MEDEXCEPTION) return Length; } -FIELD* MESH::getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) +FIELD* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTION) { + const char * LOC = "MESH::getNormal(SUPPORT*) : "; + BEGIN_OF(LOC); + // Support must be on 2D or 1D elements - MESSAGE("MESH::getNormal(SUPPORT*)"); // Make sure that the MESH class is the same as the MESH class attribut // in the class Support MESH* myMesh = Support->getMesh(); if (this != myMesh) - throw MEDEXCEPTION("MESH::getNormal(SUPPORT*) no compatibility between *this and SUPPORT::_mesh : pointeur problem !"); + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh : pointeur problem !")); int dim_space = getSpaceDimension(); medEntityMesh support_entity = Support->getEntity(); bool onAll = Support->isOnAllElements(); int nb_type, length_values; - medGeometryElement* types; + const medGeometryElement* types; int nb_entity_type; // !!!! WARNING : use of nodal global numbering in the mesh !!!! - int* global_connectivity; + const int* global_connectivity; - if (onAll) - { - nb_type = myMesh->getNumberOfTypes(support_entity); - length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS); - types = getTypes(support_entity); - } - else +// if (onAll) +// { +// nb_type = myMesh->getNumberOfTypes(support_entity); +// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS); +// types = getTypes(support_entity); +// } +// else { nb_type = Support->getNumberOfTypes(); length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS); @@ -1232,17 +1452,16 @@ FIELD* MESH::getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) FIELD* Normal = new FIELD::FIELD(Support,dim_space); Normal->setName("NORMAL"); Normal->setDescription("cells or faces normal"); - for (int k=0;ksetComponentName(kp1,"normal"); - Normal->setComponentDescription(kp1,"desc-comp"); - Normal->setMEDComponentUnit(kp1,"unit"); + for (int k=1;k<=dim_space;k++) { + Normal->setComponentName(k,"normal"); + Normal->setComponentDescription(k,"desc-comp"); + Normal->setMEDComponentUnit(k,"unit"); } Normal->setValueType(MED_REEL64); - Normal->setIterationNumber(0); - Normal->setOrderNumber(0); + Normal->setIterationNumber(MED_NOPDT); + Normal->setOrderNumber(MED_NONOR); Normal->setTime(0.0); double * normal = new double [dim_space*length_values]; @@ -1263,7 +1482,7 @@ FIELD* MESH::getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) (type==MED_QUAD4) || (type==MED_QUAD8)) && (dim_space != 3)) || (((type==MED_SEG2) || (type==MED_SEG3)) && (dim_space != 2)) ) - throw MEDEXCEPTION("MESH::getNormal(SUPPORT*) no compatibility between *this and SUPPORT::_mesh : dimension problem !"); + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh : dimension problem !")); double xnormal1, xnormal2, xnormal3 ; @@ -1274,18 +1493,22 @@ FIELD* MESH::getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) } else { - nb_entity_type = Support->getNumberOfElements(type); - - int * supp_number = Support->getNumber(type); - int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS); - int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); - global_connectivity = new int[(type%100)*nb_entity_type]; + // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all for instance !")); + nb_entity_type = Support->getNumberOfElements(type); + + const int * supp_number = Support->getNumber(type); + const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS); + const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); + int * global_connectivity_tmp = new int[(type%100)*nb_entity_type]; + + for (int k_type = 0; k_type* MESH::getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) break; } default : - throw MEDEXCEPTION("MESH::getNormal(SUPPORT*) Bad Support to get Normals on it !"); + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Normals on it !")); break; } } Normal->setValue(MED_FULL_INTERLACE,normal); + delete[] normal ; + + END_OF(LOC); return Normal; } -FIELD* MESH::getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION) +FIELD* MESH::getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION) { - MESSAGE("MESH::getBarycenter(SUPPORT*)"); + const char * LOC = "MESH::getBarycenter(SUPPORT*) : "; + BEGIN_OF(LOC); // Make sure that the MESH class is the same as the MESH class attribut // in the class Support MESH* myMesh = Support->getMesh(); if (this != myMesh) - throw MEDEXCEPTION("MESH::getBarycenter(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !"); + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !")); int dim_space = getSpaceDimension(); medEntityMesh support_entity = Support->getEntity(); bool onAll = Support->isOnAllElements(); int nb_type, length_values; - medGeometryElement* types; + const medGeometryElement* types; int nb_entity_type; // !!!! WARNING : use of nodal global numbering in the mesh !!!! - int* global_connectivity; + const int* global_connectivity; - if (onAll) - { - nb_type = myMesh->getNumberOfTypes(support_entity); - length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS); - types = getTypes(support_entity); - } - else +// if (onAll) +// { +// nb_type = myMesh->getNumberOfTypes(support_entity); +// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS); +// types = getTypes(support_entity); +// } +// else { nb_type = Support->getNumberOfTypes(); length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS); @@ -1494,18 +1721,20 @@ FIELD* MESH::getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION) } else { - nb_entity_type = Support->getNumberOfElements(type); - - int * supp_number = Support->getNumber(type); - int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS); - int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); - global_connectivity = new int[(type%100)*nb_entity_type]; - - for (int k_type = 0; k_typegetNumberOfElements(type); + + const int * supp_number = Support->getNumber(type); + const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS); + const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); + int * global_connectivity_tmp = new int[(type%100)*nb_entity_type]; + + for (int k_type = 0; k_type* MESH::getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION) break; } default : - throw MEDEXCEPTION("MESH::getBarycenter(SUPPORT*) Bad Support to get a barycenter on it (in fact unknown type) !"); + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get a barycenter on it (in fact unknown type) !")); break; } } Barycenter->setValue(MED_FULL_INTERLACE,barycenter); + delete[] barycenter ; + + END_OF(LOC); + return Barycenter; } + +//======================================================================= +//function : checkGridFillCoords +//purpose : if this->_isAGrid, assure that _coordinate is filled +//======================================================================= + +inline void MESH::checkGridFillCoords() const +{ + if (_isAGrid) + ((GRID *) this)->fillCoordinates(); +} + +//======================================================================= +//function : checkGridFillConnectivity +//purpose : if this->_isAGrid, assure that _connectivity is filled +//======================================================================= + +inline void MESH::checkGridFillConnectivity() const +{ + if (_isAGrid) + ((GRID *) this)->fillConnectivity(); +} + + +void MESH::read(int index) +{ + const char * LOC = "MESH::read(int index=0) : "; + BEGIN_OF(LOC); + + if (_drivers[index]) { + _drivers[index]->open(); + _drivers[index]->read(); + _drivers[index]->close(); + } + else + throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) + << "The index given is invalid, index must be between 0 and |" + << _drivers.size() + ) + ); + if (_isAGrid) + ((GRID *) this)->fillMeshAfterRead(); + + END_OF(LOC); +} +//======================================================================= +//function : getSkin +//purpose : +//======================================================================= + +SUPPORT * MESH::getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION) +{ + const char * LOC = "MESH::getSkin : " ; + BEGIN_OF(LOC) ; + // some test : + if (this != Support3D->getMesh()) + throw MEDEXCEPTION(STRING(LOC) << "no compatibility between *this and SUPPORT::_mesh !"); + if (_meshDimension != 3 || Support3D->getEntity() != MED_CELL) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Defined on 3D cells only")); + + // well, all rigth ! + SUPPORT * mySupport = new SUPPORT(this,"Skin",MED_FACE); + mySupport->setAll(false); + + list myElementsList ; + int i,j, size = 0 ; + + calculateConnectivity(MED_FULL_INTERLACE, MED_DESCENDING, MED_CELL); + if (Support3D->isOnAllElements()) + { + int * myConnectivityValue = const_cast (getReverseConnectivity(MED_DESCENDING)) ; + int nbFaces = getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS); + for (i=0, j=1 ; j<=nbFaces; ++j, i += 2) + { + int cellNb1 = myConnectivityValue [i]; + int cellNb2 = myConnectivityValue [i+1]; + //MESSAGE( " FACE # " << j << " -- Cells: " << cellNb1 << ", " << cellNb2 ); + if ((cellNb1 == 0 || cellNb2 == 0) && (cellNb1 + cellNb2 > 0)) + { + myElementsList.push_back( j ) ; + size++ ; + } + } + } + else + { + map FaceNbEncounterNb; + + int * myConnectivityValue = const_cast + (getConnectivity(MED_FULL_INTERLACE, MED_DESCENDING, + MED_CELL, MED_ALL_ELEMENTS)); + int * myConnectivityIndex = const_cast (getConnectivityIndex(MED_DESCENDING, MED_CELL)); + int * myCellNbs = const_cast (Support3D->getnumber()->getValue()); + int nbCells = Support3D->getnumber()->getLength(); + for (i=0; i::iterator FaceNbEncounterNbItr; + for (FaceNbEncounterNbItr = FaceNbEncounterNb.begin(); + FaceNbEncounterNbItr != FaceNbEncounterNb.end(); + FaceNbEncounterNbItr ++) + if ((*FaceNbEncounterNbItr).second == 1) + { + myElementsList.push_back( (*FaceNbEncounterNbItr).first) ; + size++ ; + } + } + // Well, we must know how many geometric type we have found + int * myListArray = new int[size] ; + int id = 0 ; + list::iterator myElementsListIt ; + for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) { + myListArray[id]=(*myElementsListIt) ; + id ++ ; + } + + int numberOfGeometricType ; + medGeometryElement* geometricType ; + int * numberOfGaussPoint ; + int * geometricTypeNumber ; + int * numberOfEntities ; + // MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ; + int * mySkyLineArrayIndex ; + + int numberOfType = getNumberOfTypes(MED_FACE) ; + if (numberOfType == 1) { // wonderfull : it's easy ! + numberOfGeometricType = 1 ; + geometricType = new medGeometryElement[1] ; + const medGeometryElement * allType = getTypes(MED_FACE); + geometricType[0] = allType[0] ; + numberOfGaussPoint = new int[1] ; + numberOfGaussPoint[0] = 1 ; + geometricTypeNumber = new int[1] ; // not use, but initialized to nothing + geometricTypeNumber[0] = 0 ; + numberOfEntities = new int[1] ; + numberOfEntities[0] = size ; + mySkyLineArrayIndex = new int[2] ; + mySkyLineArrayIndex[0]=1 ; + mySkyLineArrayIndex[1]=1+size ; + } + else {// hemmm + map theType ; + for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) { + medGeometryElement myType = getElementType(MED_FACE,*myElementsListIt) ; + if (theType.find(myType) != theType.end() ) + theType[myType]+=1 ; + else + theType[myType]=1 ; + } + numberOfGeometricType = theType.size() ; + geometricType = new medGeometryElement[numberOfGeometricType] ; + const medGeometryElement * allType = getTypes(MED_FACE); + numberOfGaussPoint = new int[numberOfGeometricType] ; + geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing + numberOfEntities = new int[numberOfGeometricType] ; + mySkyLineArrayIndex = new int[numberOfGeometricType+1] ; + int index = 0 ; + mySkyLineArrayIndex[0]=1 ; + map::iterator theTypeIt ; + for (theTypeIt=theType.begin();theTypeIt!=theType.end();theTypeIt++) { + geometricType[index] = (*theTypeIt).first ; + numberOfGaussPoint[index] = 1 ; + geometricTypeNumber[index] = 0 ; + numberOfEntities[index] = (*theTypeIt).second ; + mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfEntities[index] ; + index++ ; + } + } + // mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ; + MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ; + + mySupport->setNumberOfGeometricType(numberOfGeometricType) ; + mySupport->setGeometricType(geometricType) ; + mySupport->setNumberOfGaussPoint(numberOfGaussPoint) ; + // mySupport->setGeometricTypeNumber(geometricTypeNumber) ; + mySupport->setNumberOfElements(numberOfEntities) ; + mySupport->setTotalNumberOfElements(size) ; + mySupport->setNumber(mySkyLineArray) ; + + delete[] numberOfEntities; + delete[] geometricTypeNumber; + delete[] numberOfGaussPoint; + delete[] geometricType; + delete[] mySkyLineArrayIndex; + delete[] myListArray; +// delete mySkyLineArray; + + END_OF(LOC) ; + return mySupport ; + +} diff --git a/src/MEDMEM/MEDMEM_Mesh.hxx b/src/MEDMEM/MEDMEM_Mesh.hxx index 48b5e0243..9fad12dfa 100644 --- a/src/MEDMEM/MEDMEM_Mesh.hxx +++ b/src/MEDMEM/MEDMEM_Mesh.hxx @@ -1,3 +1,29 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_Mesh.hxx +// Module : MED + #ifndef MESH_HXX #define MESH_HXX @@ -13,12 +39,15 @@ #include "MEDMEM_Coordinate.hxx" #include "MEDMEM_Connectivity.hxx" +// Add your own driver header (step 2) #include "MEDMEM_MedMeshDriver.hxx" +#include "MEDMEM_MedMedDriver.hxx" +#include "MEDMEM_GibiMeshDriver.hxx" class CELLMODEL; -class FAMILY; -class GROUP; -class SUPPORT; +class FAMILY; +class GROUP; +class SUPPORT; template class FIELD; @@ -28,17 +57,17 @@ template class FIELD; using namespace MED_EN; -/*! This class contains all the informations related with a MESH : +/*! This class contains all the informations related with a MESH : - COORDINATES - CONNECTIVITIES - FAMILIES OF NODES - FAMILIES OF CELLS - FAMILIES OF FACES - FAMILIES OF EDGES - + NOTE: A Family is only on one type of entity (MED_CELL, MED_FACE, MED_EDGE, MED_NODE). You can't have a family on MED_CELL and MED_FACE - + */ class MESH @@ -49,25 +78,27 @@ public : // ------- Drivers Management Part protected: - + //-----------------------// - class INSTANCE + class INSTANCE //-----------------------// { public: virtual GENDRIVER * run(const string & fileName, MESH * ptrMesh) const = 0 ; } ; - + //-------------------------------------------------------// - template class INSTANCE_DE : public INSTANCE + template class INSTANCE_DE : public INSTANCE //-------------------------------------------------------// { public : - GENDRIVER * run(const string & fileName, MESH * ptrMesh) const + GENDRIVER * run(const string & fileName, MESH * ptrMesh) const { return new T(fileName,ptrMesh) ; } } ; - - static INSTANCE_DE inst_med ; + + // Add a similar line for your personnal driver (step 3) + static INSTANCE_DE inst_med ; + static INSTANCE_DE inst_gibi ; //static INSTANCE_DE inst_vtk ; static const INSTANCE * const instances[] ; @@ -82,15 +113,6 @@ protected : string _name; // A POSITIONNER EN FCT DES IOS ? - int _numberOfMEDNodeFamily ; // INUTILE - int * _MEDArrayNodeFamily ; // SOLUTION TEMPORAIRE - int * _numberOfMEDCellFamily ; // INUTILE - int * _numberOfMEDFaceFamily ; // INUTILE - int * _numberOfMEDEdgeFamily ; // INUTILE - int ** _MEDArrayCellFamily ; // SOLUTION TEMPORAIRE - int ** _MEDArrayFaceFamily ; // SOLUTION TEMPORAIRE - int ** _MEDArrayEdgeFamily ; // SOLUTION TEMPORAIRE - COORDINATE * _coordinate; CONNECTIVITY * _connectivity; @@ -99,58 +121,69 @@ protected : int _numberOfNodes ; int _numberOfNodesFamilies; //INUTILE ? -> _familyNode.size() - vector _familyNode ; // array of size _numberOfNodesFamilies; + vector _familyNode ; // array of size _numberOfNodesFamilies; int _numberOfCellsFamilies; - vector _familyCell ; // array of size _numberOfCellsFamilies; + vector _familyCell ; // array of size _numberOfCellsFamilies; int _numberOfFacesFamilies; - vector _familyFace ; // array of size _numberOfFacesFamilies; + vector _familyFace ; // array of size _numberOfFacesFamilies; int _numberOfEdgesFamilies; vector _familyEdge ; // array of size _numberOfEdgesFamilies; int _numberOfNodesGroups; //INUTILE ? - vector _groupNode; // array of size _numberOfNodesGroups; + vector _groupNode; // array of size _numberOfNodesGroups; int _numberOfCellsGroups; //INUTILE ? - vector _groupCell; // array of size _numberOfCellsGroups; + vector _groupCell; // array of size _numberOfCellsGroups; int _numberOfFacesGroups; //INUTILE ? - vector _groupFace; // array of size _numberOfFacesGroups; + vector _groupFace; // array of size _numberOfFacesGroups; int _numberOfEdgesGroups; //INUTILE ? - vector _groupEdge; // array of size _numberOfEdgesGroups; + vector _groupEdge; // array of size _numberOfEdgesGroups; // list of all Group vector _drivers; // Storage of the drivers currently in use - + + bool _isAGrid; // am I a GRID or not + //-----------------------// // Methods //-----------------------// + inline void checkGridFillCoords() const; + inline void checkGridFillConnectivity() const; + // if this->_isAGrid, assure that _coordinate and _connectivity are filled + public : + // Add your personnal driver line (step 2) friend class MED_MESH_RDONLY_DRIVER; friend class MED_MESH_WRONLY_DRIVER; + friend class MED_MED_RDONLY_DRIVER; + friend class MED_MED_WRONLY_DRIVER; + friend class MED_MED_RDWR_DRIVER; + + friend class GIBI_MESH_RDONLY_DRIVER; + friend class GIBI_MESH_WRONLY_DRIVER; + friend class GIBI_MESH_RDWR_DRIVER; + void init(); MESH(); - MESH(const MESH &m); + MESH(MESH &m); MESH & operator=(const MESH &m); - MESH( driverTypes driverType, const string & fileName="", - const string & meshName=""); + MESH( driverTypes driverType, const string & fileName="", + const string & meshName=""); ~MESH(); friend ostream & operator<<(ostream &os, MESH &my) ; - int addDriver(driverTypes driverType, - const string & fileName ="Default File Name.med", - const string & driverName="Default Mesh Name"); + int addDriver(driverTypes driverType, + const string & fileName ="Default File Name.med", + const string & driverName="Default Mesh Name"); int addDriver(GENDRIVER & driver); void rmDriver(int index=0); - inline void read(int index=0); + void read(int index=0); + inline void read(const MED_MED_DRIVER & genDriver); inline void write(int index=0, const string & driverName = ""); - inline void write(const GENDRIVER &); - - inline int * getMEDArrayNodeFamily() ; - inline int ** getMEDArrayCellFamily() ; - inline int ** getMEDArrayFaceFamily() ; - inline int ** getMEDArrayEdgeFamily() ; + inline void write(const MED_MED_DRIVER & genDriver); // void calculateReverseConnectivity(); // void createFaces(); //Faces creation => full constituent informations @@ -160,175 +193,205 @@ public : inline void setName(string name); inline string getName() const; - inline int getSpaceDimension(); - inline int getMeshDimension(); - - inline int getNumberOfNodes(); - inline COORDINATE * getCoordinateptr(); - inline string getCoordinatesSystem(); - inline const double * getCoordinates(medModeSwitch Mode); - inline const double getCoordinate(int Number,int Axis); - inline string * getCoordinatesNames(); - inline string * getCoordinatesUnits(); + inline int getSpaceDimension() const ; + inline int getMeshDimension() const ; + inline bool getIsAGrid(); + + inline int getNumberOfNodes() const ; + inline const COORDINATE * getCoordinateptr() const ; + inline string getCoordinatesSystem() const ; + inline const double * getCoordinates(medModeSwitch Mode) const ; + inline const double getCoordinate(int Number,int Axis) const ; + inline const string * getCoordinatesNames() const ; + inline const string * getCoordinatesUnits() const ; // inline int * getNodesNumbers(); - inline int getNumberOfTypes(medEntityMesh Entity); - inline medGeometryElement * getTypes(medEntityMesh Entity); - inline CELLMODEL * getCellsTypes(medEntityMesh Entity); - inline int * getGlobalNumberingIndex(medEntityMesh Entity); - inline int getNumberOfElements(medEntityMesh Entity,medGeometryElement Type); - inline bool existConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity); - inline medGeometryElement getElementType(medEntityMesh Entity,int Number) ; - inline void calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity); - inline int * getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity, medGeometryElement Type); - inline int * getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity); - int getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity) ; - inline int * getReverseConnectivity(medConnectivity ConnectivityType); - inline int * getReverseConnectivityIndex(medConnectivity ConnectivityType); - - inline int getNumberOfFamilies(medEntityMesh Entity); - inline vector getFamilies(medEntityMesh Entity); - inline FAMILY* getFamily(medEntityMesh Entity,int i); - inline int getNumberOfGroups(medEntityMesh Entity); - inline vector getGroups(medEntityMesh Entity); - inline GROUP* getGroup(medEntityMesh Entity,int i); - - + inline int getNumberOfTypes(medEntityMesh Entity) const ; + inline const medGeometryElement * getTypes(medEntityMesh Entity) const ; + inline const CELLMODEL * getCellsTypes(medEntityMesh Entity) const ; + inline const int * getGlobalNumberingIndex(medEntityMesh Entity) const ; + inline int getNumberOfElements(medEntityMesh Entity,medGeometryElement Type) const ; + inline bool existConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity) const ; + inline medGeometryElement getElementType(medEntityMesh Entity,int Number) const ; + inline void calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity) ; + inline const int * getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity, medGeometryElement Type) const ; + inline const int * getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity) const ; + int getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity) const ; + inline const int * getReverseConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity=MED_CELL) const ; + inline const int * getReverseConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity=MED_CELL) const ; + + inline int getNumberOfFamilies(medEntityMesh Entity) const ; + inline const vector getFamilies(medEntityMesh Entity) const ; + inline const FAMILY* getFamily(medEntityMesh Entity,int i) const ; + inline int getNumberOfGroups(medEntityMesh Entity) const ; + inline const vector getGroups(medEntityMesh Entity) const ; + inline const GROUP* getGroup(medEntityMesh Entity,int i) const ; + inline const CONNECTIVITY* getConnectivityptr() const ; SUPPORT * getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION) ; + //SUPPORT * getBoundaryElements(medEntityMesh Entity) const throw (MEDEXCEPTION) ; // problème avec le maillage dans le support : le pointeur n'est pas const, mais sa valeur oui. A voir !!! PG + + SUPPORT * getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION) ; // Node DonneBarycentre(const Cell &m) const; - FIELD* getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 3D elements - FIELD* getArea(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 2D elements - FIELD* getLength(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 1D elements - FIELD* getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 2D elements - FIELD* getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION) ; - // FIELD* getNeighbourhood(SUPPORT * Support) throw (MEDEXCEPTION) ; // Il faut preciser ! + FIELD* getVolume(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 3D elements + FIELD* getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 2D elements + FIELD* getLength(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 1D elements + FIELD* getNormal(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 2D elements + FIELD* getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION) ; + // FIELD* getNeighbourhood(SUPPORT * Support) const throw (MEDEXCEPTION) ; // Il faut preciser ! }; // --------------------------------------- // Methodes Inline // --------------------------------------- -inline void MESH::read(int index=0) -{ - const char * LOC = "MESH::read(int index=0) : "; - BEGIN_OF(LOC); - - if (_drivers[index]) { - _drivers[index]->open(); - _drivers[index]->read(); - _drivers[index]->close(); - } - else - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "The index given is invalid, index must be between 0 and |" - << _drivers.size() - ) - ); - END_OF(LOC); -} +inline const CONNECTIVITY* MESH::getConnectivityptr() const +{ + return _connectivity; +} + +// inline void MESH::read(int index/*=0*/) +// { +// const char * LOC = "MESH::read(int index=0) : "; +// BEGIN_OF(LOC); + +// if (_drivers[index]) { +// _drivers[index]->open(); +// _drivers[index]->read(); +// _drivers[index]->close(); +// } +// else +// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) +// << "The index given is invalid, index must be between 0 and |" +// << _drivers.size() +// ) +// ); +// END_OF(LOC); +// } /*! Write all the content of the MESH using driver referenced by the handler */ -inline void MESH::write(int index=0, const string & driverName = "") -{ +inline void MESH::write(int index/*=0*/, const string & driverName/* = ""*/) +{ const char * LOC = "MESH::write(int index=0, const string & driverName = \"\") : "; BEGIN_OF(LOC); if ( _drivers[index] ) { - _drivers[index]->open(); - if (driverName != "") _drivers[index]->setMeshName(driverName); - _drivers[index]->write(); - _drivers[index]->close(); + _drivers[index]->open(); + if (driverName != "") _drivers[index]->setMeshName(driverName); + _drivers[index]->write(); + _drivers[index]->close(); } else - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "The index given is invalid, index must be between 0 and |" - << _drivers.size() + throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) + << "The index given is invalid, index must be between 0 and |" + << _drivers.size() ) - ); + ); + END_OF(LOC); +} + +// This method is MED specific : don't use it +// must be private. +inline void MESH::write(const MED_MED_DRIVER & genDriver) +{ + const char * LOC = "MESH::write(const MED_MED_DRIVER & genDriver): "; + BEGIN_OF(LOC); + + for (int index=0; index < _drivers.size(); index++ ) + if ( *_drivers[index] == genDriver ) { + _drivers[index]->open(); + _drivers[index]->write(); + _drivers[index]->close(); + // ? FINALEMENT PAS BESOIN DE L'EXCEPTION ? + } + END_OF(LOC); -} -// This method is MED specific : don't use it -// must be private. -inline void MESH::write(const GENDRIVER & genDriver) -{ - const char * LOC = "MESH::write(const GENDRIVER & genDriver): "; +} + +// This method is MED specific : don't use it +// must be private. +inline void MESH::read(const MED_MED_DRIVER & genDriver) +{ + const char * LOC = "MESH::read(const MED_MED_DRIVER & genDriver): "; BEGIN_OF(LOC); for (int index=0; index < _drivers.size(); index++ ) - if ( *_drivers[index] == genDriver ) { - _drivers[index]->open(); - _drivers[index]->write(); + if ( *_drivers[index] == genDriver ) { + _drivers[index]->open(); + _drivers[index]->read(); _drivers[index]->close(); // ? FINALEMENT PAS BESOIN DE L'EXCEPTION ? } - + END_OF(LOC); - -} + +} /*! Set the MESH name */ -inline void MESH::setName(string name) +inline void MESH::setName(string name) { _name=name ; //NOM interne à la classe } /*! Get the MESH name */ -inline string MESH::getName() const +inline string MESH::getName() const { return _name ; } /*! Get the dimension of the space */ -inline int MESH::getSpaceDimension() +inline int MESH::getSpaceDimension() const { return _spaceDimension; } /*! Get the dimension of the MESH */ -inline int MESH::getMeshDimension() +inline int MESH::getMeshDimension() const { return _meshDimension; } /*! Get the number of nodes used in the MESH */ -inline int MESH::getNumberOfNodes() +inline int MESH::getNumberOfNodes() const { return _numberOfNodes; } /*! Get the COORDINATES object. Use it only if you need COORDINATES informations not provided by the MESH class.*/ -inline COORDINATE * MESH::getCoordinateptr() +inline const COORDINATE * MESH::getCoordinateptr() const { + checkGridFillCoords(); return _coordinate; } /*! Get the system in which coordinates are given (CARTESIAN,CYLINDRICAL,SPHERICAL) __??MED_CART??__. */ -inline string MESH::getCoordinatesSystem() +inline string MESH::getCoordinatesSystem() const { return _coordinate->getCoordinatesSystem(); } /*! Get the whole coordinates array in a given interlacing mode. The interlacing mode are : - MED_NO_INTERLACE : X1 X2 Y1 Y2 Z1 Z2 - - MED_FULL_INTERLACE : X1 Y1 Z1 X2 Y2 Z2 + - MED_FULL_INTERLACE : X1 Y1 Z1 X2 Y2 Z2 */ -inline const double * MESH::getCoordinates(medModeSwitch Mode) +inline const double * MESH::getCoordinates(medModeSwitch Mode) const { + checkGridFillCoords(); return _coordinate->getCoordinates(Mode); } /*! Get the coordinate n° number on axis n°axis*/ -inline const double MESH::getCoordinate(int number, int axis) +inline const double MESH::getCoordinate(int number, int axis) const { + checkGridFillCoords(); return _coordinate->getCoordinate(number,axis); } /*! Get the coordinate names array ("x ","y ","z ") of size n*MED_TAILLE_PNOM */ -inline string * MESH::getCoordinatesNames() +inline const string * MESH::getCoordinatesNames() const { return _coordinate->getCoordinatesNames(); } @@ -336,65 +399,99 @@ inline string * MESH::getCoordinatesNames() /*! Get the coordinate unit names array ("cm ","cm ","cm ") of size n*MED_TAILLE_PNOM */ -inline string * MESH::getCoordinatesUnits() +inline const string * MESH::getCoordinatesUnits() const { return _coordinate->getCoordinatesUnits(); } -// int * MESH::getNodesNumbers() { +// int * MESH::getNodesNumbers() const +// { // return nodesNumbers; // } /*! Get the number of different geometric types for a given entity type. - For exemple getNumberOfTypes(MED_CELL) would return 2 is the MESH have some MED_TETRA4 and MED_HEXA6 in it. - medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_NODE, MED_ALL_ENTITIES + + For exemple getNumberOfTypes(MED_CELL) would return 3 is the MESH + have some MED_TETRA4, MED_PYRA5 and MED_HEXA6 in it. + + medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_NODE, MED_ALL_ENTITIES + + If entity is not defined, return 0. + + If there is no connectivity, return an exception. */ -inline int MESH::getNumberOfTypes(medEntityMesh entity) +inline int MESH::getNumberOfTypes(medEntityMesh entity) const { MESSAGE("MESH::getNumberOfTypes(medEntityMesh entity) : "<getNumberOfTypes(entity) ; throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !")); } -/*! +/*! Get the list of geometric types used by a given entity. medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_ALL_ENTITIES - REM : Don't use MED_NODE + + REM : Don't use MED_NODE + + If entity is not defined, return an exception. */ -inline medGeometryElement * MESH::getTypes(medEntityMesh entity) +inline const medGeometryElement * MESH::getTypes(medEntityMesh entity) const { if (entity == MED_NODE) throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : No medGeometryElement with MED_NODE entity !")); - + // return un tableau de taille 1 contenant MED_NONE, comme les supports pour etre coherent avec getNumberOfTypes ???? PG + + checkGridFillConnectivity(); if (_connectivity != NULL) return _connectivity->getGeometricTypes(entity) ; throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : Connectivity not defined !")); } -/*! +/*! Get the whole list of CELLMODEL used by cells of given type (medEntityMesh). + REMARK : Don't use MED_NODE as medEntityMesh */ -inline CELLMODEL * MESH::getCellsTypes(medEntityMesh Entity) +inline const CELLMODEL * MESH::getCellsTypes(medEntityMesh Entity) const { + checkGridFillConnectivity(); if (_connectivity != NULL) - return _connectivity->getCellsTypes(Entity) ; + return _connectivity->getCellsTypes(Entity) ; throw MEDEXCEPTION(LOCALIZED("MESH::getCellsTypes( medEntityMesh ) : Connectivity not defined !")); } -/*! Since informations related with an entity type are stored in independent arrays, the only way to - get a uniq index is to call this method. - For exemple if you want the global numbers of your ... ????? size ????? +/*! Return an array of size NumbreOfTypes+1 which contains, for each + geometric type of the given entity, the first global element number + of this type. + + For exemple, if we have a mesh with 5 triangles and 4 quadrangle : + - size of GlobalNumberingIndex is 3 + - GlobalNumberingIndex[0]=1 (the first type) + - GlobalNumberingIndex[1]=6 (the second type) + - GlobalNumberingIndex[2]=10 */ -inline int * MESH::getGlobalNumberingIndex(medEntityMesh entity) +inline const int * MESH::getGlobalNumberingIndex(medEntityMesh entity) const { + checkGridFillConnectivity(); if (_connectivity != NULL) - return _connectivity->getGlobalNumberingIndex(entity); + return _connectivity->getGlobalNumberingIndex(entity); throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !")); } -inline int MESH::getNumberOfElements(medEntityMesh entity, medGeometryElement Type) +/*! + Return the number of element of given geometric type of given entity. Return 0 if query is not defined. + + Example : + - getNumberOfElements(MED_NODE,MED_NONE) : number of node + - getNumberOfElements(MED_NODE,MED_TRIA3) : return 0 (not defined) + - getNumberOfElements(MED_FACE,MED_TRIA3) : return number of triangles + elements defined in face entity (0 if not defined) + - getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) : return total number + of elements defined in cell entity + */ +inline int MESH::getNumberOfElements(medEntityMesh entity, medGeometryElement Type) const { const char * LOC = "MESH::getNumberOfElements(medEntityMesh,medGeometryElement) : " ; if (entity==MED_NODE) @@ -402,72 +499,127 @@ inline int MESH::getNumberOfElements(medEntityMesh entity, medGeometryElement Ty return _numberOfNodes ; else return 0 ; - //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"wrong medGeometryElement with MED_NODE")); - else - if (_connectivity != (CONNECTIVITY*)NULL) - return _connectivity->getNumberOf(entity,Type) ; - else - return 0 ; + //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"wrong medGeometryElement with MED_NODE")); + else + { + checkGridFillConnectivity(); + if (_connectivity != (CONNECTIVITY*)NULL) + return _connectivity->getNumberOf(entity,Type) ; + else + return 0 ; //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"connectivity not defined !")); + } } -inline bool MESH::existConnectivity(medConnectivity connectivityType, medEntityMesh entity) +/*! + Return true if the wanted connectivity exist, else return false + (to use before a getSomething method). + */ +inline bool MESH::existConnectivity(medConnectivity connectivityType, medEntityMesh entity) const { + checkGridFillConnectivity(); if (_connectivity==(CONNECTIVITY*)NULL) throw MEDEXCEPTION("MESH::existConnectivity(medConnectivity,medEntityMesh) : no connectivity defined !"); return _connectivity->existConnectivity(connectivityType,entity) ; } /*! - Return the geometric type of element Number of entity Entity. + Return the geometric type of global element Number of entity Entity. Throw an exception if Entity is not defined or Number are wrong (too big). */ -inline medGeometryElement MESH::getElementType(medEntityMesh Entity,int Number) +inline medGeometryElement MESH::getElementType(medEntityMesh Entity,int Number) const { + checkGridFillConnectivity(); if (_connectivity==(CONNECTIVITY*)NULL) throw MEDEXCEPTION("MESH::getElementType(medEntityMesh,int) : no connectivity defined !"); return _connectivity->getElementType(Entity,Number) ; } +/*! + Calculate the ask connectivity. Return an exception if this could not be + done. Do nothing if connectivity already exist. + */ + inline void MESH::calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity) { + checkGridFillConnectivity(); if (Mode==MED_FULL_INTERLACE) _connectivity->calculateConnectivity(ConnectivityType,entity) ; else throw MEDEXCEPTION(LOCALIZED("MESH::calculateConnectivity : only for MED_FULL_INTERLACE mode")); } -inline int * MESH::getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity, medGeometryElement Type) +/*! + Return the required connectivity in the right mode for the given + geometric type of the given entity. + + To get connectivity for all geometric type, use Mode=MED_FULL_INTERLACE + and Type=MED_ALL_ELEMENTS. + You must also get the corresponding index array. + */ +inline const int * MESH::getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity, medGeometryElement Type) const { + checkGridFillConnectivity(); if (Mode==MED_FULL_INTERLACE) return _connectivity->getConnectivity(ConnectivityType,entity,Type) ; throw MEDEXCEPTION(LOCALIZED("MESH::getConnectivity : only for MED_FULL_INTERLACE mode")); } -inline int * MESH::getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh entity) +/*! + Return the required index array for a connectivity received in + MED_FULL_ENTERLACE mode and MED_ALL_ELEMENTS type. + + This array allow to find connectivity of each elements. + + Example : Connectivity of i^{th} elements (1<=i<=NumberOfElement) begin + at index ConnectivityIndex[i-1] and end at index ConnectivityIndex[i]-1 + in Connectivity array (Connectivity[ConnectivityIndex[i-1]-1] is the + first value) + */ +inline const int * MESH::getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh entity) const { + checkGridFillConnectivity(); return _connectivity->getConnectivityIndex(ConnectivityType, entity) ; } -inline int * MESH::getReverseConnectivity(medConnectivity ConnectivityType) +/*! + Return the reverse connectivity required by ConnectivityType : + - If ConnectivityType=MED_NODAL : return connectivity node-cell + - If ConnectivityType=MED_DESCENDING : return connectivity face-cell + + You must get ReverseConnectivityIndex array to use it. + */ +inline const int * MESH::getReverseConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/) const { - if (ConnectivityType==MED_NODAL) - return _connectivity->getReverseNodalConnectivity() ; - else if (ConnectivityType==MED_DESCENDING) - return _connectivity->getReverseDescendingConnectivity() ; - throw MEDEXCEPTION("MESH::getReverseConnectivity : connectivity mode not supported !"); + checkGridFillConnectivity(); + if (NULL==_connectivity) + throw MEDEXCEPTION("MESH::getReverseConnectivity : no connectivity defined in MESH !"); + + return _connectivity->getReverseConnectivity(ConnectivityType,Entity) ; } -inline int * MESH::getReverseConnectivityIndex(medConnectivity ConnectivityType) +/*! + Return the index array required by ConnectivityType. + + This array allow to find reverse connectivity of each elements. + + Example : Reverse connectivity of i^{th} elements (1<=i<=NumberOfElement) + begin at index ReverseConnectivityIndex[i-1] and end at index + ReverseConnectivityIndex[i]-1 + in ReverseConnectivity array ( + ReverseConnectivity[ReverseConnectivityIndex[i-1]-1] + is the first value) + */ +inline const int * MESH::getReverseConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/) const { - if (ConnectivityType==MED_NODAL) - return _connectivity->getReverseNodalConnectivityIndex() ; - else if (ConnectivityType==MED_DESCENDING) - return _connectivity->getReverseDescendingConnectivityIndex() ; - throw MEDEXCEPTION("MESH::getReverseConnectivityIndex : connectivity mode not supported !"); + checkGridFillConnectivity(); + if (NULL==_connectivity) + throw MEDEXCEPTION("MESH::getReverseConnectivityIndex : no connectivity defined in MESH !"); + + return _connectivity->getReverseConnectivityIndex(ConnectivityType,Entity) ; } -inline int MESH::getNumberOfFamilies (medEntityMesh entity) +inline int MESH::getNumberOfFamilies (medEntityMesh entity) const { switch (entity) { - case MED_NODE : + case MED_NODE : return _numberOfNodesFamilies ; - case MED_CELL : + case MED_CELL : return _numberOfCellsFamilies ; case MED_FACE : return _numberOfFacesFamilies ; @@ -477,12 +629,12 @@ inline int MESH::getNumberOfFamilies (medEntityMesh entity) throw MEDEXCEPTION("MESH::getNumberOfFamilies : Unknown entity"); } } -inline int MESH::getNumberOfGroups (medEntityMesh entity) +inline int MESH::getNumberOfGroups (medEntityMesh entity) const { switch (entity) { - case MED_NODE : + case MED_NODE : return _numberOfNodesGroups ; - case MED_CELL : + case MED_CELL : return _numberOfCellsGroups ; case MED_FACE : return _numberOfFacesGroups ; @@ -492,11 +644,12 @@ inline int MESH::getNumberOfGroups (medEntityMesh entity) throw MEDEXCEPTION("MESH::getNumberOfGroups : Unknown entity"); } } -vector MESH::getFamilies(medEntityMesh entity) { +const vector MESH::getFamilies(medEntityMesh entity) const +{ switch (entity) { - case MED_NODE : + case MED_NODE : return _familyNode ; - case MED_CELL : + case MED_CELL : return _familyCell ; case MED_FACE : return _familyFace ; @@ -507,11 +660,12 @@ vector MESH::getFamilies(medEntityMesh entity) { } } -vector MESH::getGroups(medEntityMesh entity) { +const vector MESH::getGroups(medEntityMesh entity) const +{ switch (entity) { - case MED_NODE : + case MED_NODE : return _groupNode ; - case MED_CELL : + case MED_CELL : return _groupCell ; case MED_FACE : return _groupFace ; @@ -522,8 +676,9 @@ vector MESH::getGroups(medEntityMesh entity) { } } -FAMILY* MESH::getFamily(medEntityMesh entity, int i) { - if (i<=0) +const FAMILY* MESH::getFamily(medEntityMesh entity, int i) const +{ + if (i<=0) throw MEDEXCEPTION("MESH::getFamily(i) : argument i must be > 0"); int NumberOfFamilies = 0 ; vector Family ; @@ -551,14 +706,15 @@ FAMILY* MESH::getFamily(medEntityMesh entity, int i) { default : throw MEDEXCEPTION("MESH::getFamilies : Unknown entity"); } - if (i>NumberOfFamilies) + if (i>NumberOfFamilies) throw MEDEXCEPTION("MESH::getFamily(entity,i) : argument i must be <= _numberOfFamilies"); - return Family[i-1]; + return Family[i-1]; } -GROUP* MESH::getGroup(medEntityMesh entity, int i) { +const GROUP* MESH::getGroup(medEntityMesh entity, int i) const +{ const char * LOC = "MESH::getGroup(medEntityMesh entity, int i) : " ; - if (i<=0) + if (i<=0) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"argument i must be > 0")); int NumberOfGroups = 0 ; vector Group ; @@ -586,9 +742,9 @@ GROUP* MESH::getGroup(medEntityMesh entity, int i) { default : throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Unknown entity")); } - if (i>NumberOfGroups) + if (i>NumberOfGroups) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"argument i="< + +#include "utilities.h" +#include "MEDMEM_STRING.hxx" +#include "MEDMEM_Exception.hxx" +#include "MEDMEM_define.hxx" + +#include "MEDMEM_Meshing.hxx" +#include "MEDMEM_Group.hxx" + +/*! Create an empty MESH. */ +MESHING::MESHING(): MESH() +{ + MESSAGE("MESHING::MESHING()"); + SCRUTE(_coordinate); + SCRUTE(_connectivity); +} + +MESHING::~MESHING() +{ + MESSAGE("Deletinh MESHING !!"); +} + +/*! Set the dimension of the space */ +void MESHING::setSpaceDimension(const int SpaceDimension) +{ + _spaceDimension = SpaceDimension ; +} + +/* Set the dimension of the MESHING */ +// void MESHING::setMeshDimension(const int MeshDimension) +// { +// _meshDimension = MeshDimension ; +// } + +/*! Set the number of nodes used in the MESH */ +void MESHING::setNumberOfNodes(const int NumberOfNodes) +{ + _numberOfNodes = NumberOfNodes ; +} + +/*! + Set the whole coordinates array in a given system and interlacing mode. + The system coordinates are : + - "CARTESIAN" + - "CYLINDRICAL" + - "SPHERICAL" + The interlacing mode are : + - MED_NO_INTERLACE : X1 X2 Y1 Y2 Z1 Z2 + - MED_FULL_INTERLACE : X1 Y1 Z1 X2 Y2 Z2 +*/ +void MESHING::setCoordinates(const int SpaceDimension, + const int NumberOfNodes, + const double * Coordinates, + const string System, + const medModeSwitch Mode) +{ + setSpaceDimension(SpaceDimension); + setNumberOfNodes(NumberOfNodes); + + SCRUTE(_coordinate); + SCRUTE(_connectivity); + //if (NULL != _coordinate) delete _coordinate; + + _coordinate = new COORDINATE(SpaceDimension, + NumberOfNodes, + Mode); + _coordinate->setCoordinates(Mode,Coordinates); + _coordinate->setCoordinatesSystem(System); +} + +/*! Set the system in which coordinates are given (CARTESIAN,CYLINDRICAL,SPHERICAL) __??MED_CART??__. */ +void MESHING::setCoordinatesSystem(const string System) + throw (MEDEXCEPTION) +{ + if (NULL == _coordinate) + throw MEDEXCEPTION(LOCALIZED("MESHING::setCoordinatesSystem : no coordinates defined")); + _coordinate->setCoordinatesSystem(System); +} + +/*! Set the coordinate names array ("x ","y ","z ") + of size n*MED_TAILLE_PNOM +*/ +void MESHING::setCoordinatesNames(const string * name) +{ +// int SpaceDimension = getSpaceDimension() ; +// _coordinate->setCoordinatesNames(SpaceDimension,name); + _coordinate->setCoordinatesNames(name); +} + +/*! + Set the (i+1)^th component of coordinate names array + ("x ","y ","z ") of size n*MED_TAILLE_PNOM +*/ +void MESHING::setCoordinateName(const string name, const int i) +{ + _coordinate->setCoordinateName(name,i); +} + +/*! Set the coordinate unit names array ("cm ","cm ","cm ") + of size n*MED_TAILLE_PNOM +*/ +void MESHING::setCoordinatesUnits(const string * units) +{ +// int SpaceDimension = getSpaceDimension() ; +// _coordinate->setCoordinatesUnits(SpaceDimension,units); + _coordinate->setCoordinatesUnits(units); +} + +/*! + Set the (i+1)^th component of the coordinate unit names array + ("cm ","cm ","cm ") of size n*MED_TAILLE_PNOM +*/ +void MESHING::setCoordinateUnit(const string unit, const int i) +{ + _coordinate->setCoordinateUnit(unit,i); +} + +/*! + Create a new connectivity object with the given number of type and + entity. If a connectivity already exist, delete it ! + + For exemple setNumberOfTypes(3,MED_CELL) create a connectivity with 3 + medGeometryElement in MESH for MED_CELL entity (like MED_TETRA4, + MED_PYRA5 and MED_HEXA6 for example). + + Return an exception if could not create the connectivity (as if we set + MED_FACE connectivity before MED_CELL). +*/ +void MESHING::setNumberOfTypes(const int NumberOfTypes, + const medEntityMesh Entity) + throw (MEDEXCEPTION) +{ + const char * LOC = "MESHING::setNumberOfTypes( medEntityMesh ) : "; + + // No defined for MED_NODE ! + if (Entity == MED_NODE) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not required with MED_NODE !")); + + if (MED_CELL == Entity) { + SCRUTE(_connectivity); +// if (_connectivity != (CONNECTIVITY *) NULL) +// delete _connectivity ; + _connectivity = new CONNECTIVITY(NumberOfTypes,Entity) ; + + } else { + + if (_connectivity == NULL) // we must have defined MED_CELL connectivity + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity on MED_CELL defined !")); + + if (MED_FACE == Entity) + if (3 != getSpaceDimension()) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity on MED_FACE could be defined in non 3D space !")); + + if (MED_EDGE == Entity) + if (3 == getSpaceDimension()) { + if (!_connectivity->existConnectivity(MED_NODAL,MED_FACE)) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity on MED_FACE defined !")); + } else { + if (2 != getSpaceDimension()) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Could not set connectivity on MED_EDGE !")); + } + // all rigth, we could create connectivity ! + CONNECTIVITY * myConnectivity = new CONNECTIVITY(NumberOfTypes,Entity) ; + _connectivity->setConstituent(myConnectivity); + } +} + +/*! + Set the list of geometric types used by a given entity. + medEntityMesh entity could be : MED_CELL, MED_FACE, MED_EDGE + + REM : Don't use MED_NODE and MED_ALL_ENTITIES + + If entity is not defined, throw an exception. +*/ +void MESHING::setTypes(const medGeometryElement * Types, + const medEntityMesh entity) + throw (MEDEXCEPTION) +{ + if (entity == MED_NODE) + throw MEDEXCEPTION(LOCALIZED("MESHING::setTypes : Not defined with MED_NODE entity !")); + + if (_connectivity == NULL) + throw MEDEXCEPTION(LOCALIZED("MESHING::setTypes : No connectivity defined !")); + + _connectivity->setGeometricTypes(Types,entity) ; +} + +/*! + Set the number of elements for each geometric type of given entity. + + Example : setNumberOfElements({12,23},MED_FACE) + if we have two type of face (MED_TRIA3 and MED_QUAD4), + we set 12 triangles and 23 quadrangles. +*/ +void MESHING::setNumberOfElements(const int * NumberOfElements, + medEntityMesh Entity) + throw (MEDEXCEPTION) +{ + const char * LOC = "MESHING::setNumberOfElements(const int *, medEntityMesh) : " ; + + if (Entity==MED_NODE) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined with MED_NODE entity !")); + + if (_connectivity == (CONNECTIVITY*)NULL) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity defined !")); + + int NumberOfTypes = getNumberOfTypes(Entity) ; + int * Count = new int[NumberOfTypes+1] ; + Count[0]=1 ; + for (int i=0; isetCount(Count,Entity) ; + delete[] Count ; +} + +/*! + Set the nodal connectivity for one geometric type of the given entity. + + Example : setConnectivity({1,2,3,1,4,2},MED_FACE,MED_TRIA3) + Define 2 triangles face defined with nodes 1,2,3 and 1,4,2. +*/ +void MESHING::setConnectivity(const int * Connectivity, + const medEntityMesh Entity, + const medGeometryElement Type) + throw (MEDEXCEPTION) +{ + const char * LOC = "MESHING::setConnectivity : " ; + + if (Entity==MED_NODE) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined with MED_NODE entity !")); + + if (_connectivity == (CONNECTIVITY*)NULL) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity defined !")); + + _connectivity->setNodal(Connectivity,Entity,Type) ; +} + +/*! + NOT YET IMPLEMENTED !! WARNING +*/ +void MESHING::setConnectivities (const int * ConnectivityIndex, + const int * ConnectivityValue, + const medConnectivity ConnectivityType, + const medEntityMesh Entity) + throw (MEDEXCEPTION) +{ + const char * LOC = "MESHING::setConnectivities : " ; + + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not Yet Implemented :: Warning !")); +} + +/*! +*/ + +// void MESHING::setGroup(const string name, +// const string description, +// const int NumberOfElements, +// const int * ElementsNumbers, +// const medEntityMesh Entity) +// { +// GROUP * myGroup = new GROUP() ; +// myGroup->setMesh(*this) ; +// myGroup->setName(name) ; +// myGroup->setDescription(description) ; +// myGroup->setEntity(Entity) ; +// // medEntityMesh and medGeometryElement ??? +// myGroup->setNumberOfGeometricType(NumberOfType) ; +// myGroup->setGeometricType(Type) ; +// myGroup->setNumberOfGaussPoint(NumberOfGaussPoint) ; +// myGroup->setNumberOfElements(NumberOfElements) ; +// myGroup->setNumber(Number) ; +// } + +void MESHING::addGroup(const GROUP & Group) + throw (MEDEXCEPTION) +{ + const char * LOC = "MESHING::addGroup : " ; + + GROUP * myGroup = new GROUP(Group) ; + switch(Group.getEntity()){ + case MED_CELL : { + _groupCell.push_back(myGroup); + _numberOfCellsGroups++; + break; + } + case MED_FACE : { + _groupFace.push_back(myGroup); + _numberOfFacesGroups++; + break; + } + case MED_EDGE : { + _groupEdge.push_back(myGroup); + _numberOfEdgesGroups++; + break; + } + case MED_NODE : { + _groupNode.push_back(myGroup); + _numberOfNodesGroups++; + break; + } + default : + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Entity !")); + } +} diff --git a/src/MEDMEM/MEDMEM_Meshing.hxx b/src/MEDMEM/MEDMEM_Meshing.hxx new file mode 100644 index 000000000..0b1b955f8 --- /dev/null +++ b/src/MEDMEM/MEDMEM_Meshing.hxx @@ -0,0 +1,76 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : MEDMEM_Meshing.hxx +// Module : MED + +/* + File MEDMEM_Meshing.hxx + $Header$ +*/ + +#ifndef MESHING_HXX +#define MESHING_HXX + +#include "MEDMEM_Mesh.hxx" + +using namespace MED_EN; + +/*! + This class MESHING is a special class to set a MESH object. +*/ + +class MESHING: public MESH +{ +public : + MESHING(); + ~MESHING(); + + void setSpaceDimension (const int SpaceDimension) ; + //void setMeshDimension (const int MeshDimension) ; + void setNumberOfNodes (const int NumberOfNodes) ; + void setCoordinates (const int SpaceDimension, + const int NumberOfNodes, + const double * Coordinates, + const string System, + const medModeSwitch Mode) ; + void setCoordinatesSystem(const string System) + throw (MEDEXCEPTION) ; + void setCoordinatesNames (const string * names) ; + void setCoordinateName (const string name, const int i) ; + void setCoordinatesUnits (const string * units) ; + void setCoordinateUnit (const string unit, const int i) ; + + void setNumberOfTypes (const int NumberOfTypes, + const medEntityMesh Entity) + throw (MEDEXCEPTION) ; + void setTypes (const medGeometryElement * Types, + const medEntityMesh Entity) + throw (MEDEXCEPTION) ; + void setNumberOfElements (const int * NumberOfElements, + const medEntityMesh Entity) + throw (MEDEXCEPTION) ; + void setConnectivity (const int * Connectivity, + const medEntityMesh Entity, + const medGeometryElement Type) + throw (MEDEXCEPTION) ; + + void setConnectivities (const int * ConnectivityIndex, + const int * ConnectivityValue, + const medConnectivity ConnectivityType, + const medEntityMesh Entity) + throw (MEDEXCEPTION) ; + +// void setGroup (const string name, +// const string description, +// const int NumberOfElements, +// const int * ElementsNumbers, +// const medEntityMesh Entity) ; + void addGroup (const GROUP & Group) + throw (MEDEXCEPTION) ; +}; + +#endif /* MESHING_HXX */ diff --git a/src/MEDMEM/MEDMEM_ModulusArray.hxx b/src/MEDMEM/MEDMEM_ModulusArray.hxx index 220cf2ba3..469d5b78a 100644 --- a/src/MEDMEM/MEDMEM_ModulusArray.hxx +++ b/src/MEDMEM/MEDMEM_ModulusArray.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_ModulusArray.hxx +// Module : MED + #ifndef __MEDMODULUSARRAY_H__ #define __MEDMODULUSARRAY_H__ @@ -15,22 +41,25 @@ class MEDMODULUSARRAY { private: int _length ; - int * _array ; + const int * _array ; public: - MEDMODULUSARRAY(int length, int * array) ; + MEDMODULUSARRAY(int length, const int * array) ; ~MEDMODULUSARRAY() ; - int & operator[](const int &i) const ; + const int & operator[](const int &i) const ; int compare(const MEDMODULUSARRAY &modulusArray) const; }; -MEDMODULUSARRAY::MEDMODULUSARRAY(int length, int * array) : +MEDMODULUSARRAY::MEDMODULUSARRAY(int length, const int * array) : _length(length), _array(array) { - // MESSAGE("MEDMODULUSARRAY::MEDMODULUSARRAY("< class PointerOf { protected : + /*! pointer to the pointed memory */ T* _pointer ; + /*! boolean setted to true if memory has to be desallocated */ bool _done ; + public : - PointerOf() ; // + PointerOf() ; + ~PointerOf() ; PointerOf( const int &size ) ; PointerOf( const T *pointer ) ; - ~PointerOf() ; - operator T*() ; + PointerOf( const int &size, const T *pointer ) ; + PointerOf( const PointerOf & pointerOf ) ; + PointerOf( const int &size, const PointerOf & pointerOf ) ; + operator T*() ; operator const T*() const ; - - //operator T*() const ; - void set( const int &size ) ; void set( const T *pointer ) ; + void set( const int &size, const T *pointer ) ; PointerOf& operator=( const PointerOf &pointer ) ; } ; -template PointerOf& PointerOf::operator=( const PointerOf &pointer ) +// ------------------------------------------------------------ // +// // +// Implementation // +// // +// ------------------------------------------------------------ // + + +/*! Creates a null T* pointer and sets the boolean (for desallocation) to false. */ +template PointerOf::PointerOf() : _pointer(0), _done(false) { - BEGIN_OF("PointerOf::operator=( const PointerOf &pointer )") ; - if ( &pointer != this ) - { - this->set( pointer._pointer ) ; - } - END_OF("PointerOf::operator=( const PointerOf &pointer )") ; - return *this ; } -template PointerOf::PointerOf() : _pointer(0), _done(false) +/*! Creates a standard T* pointer to the pointed memory. \n + The boolean for desallocation is setted to false. \n + Be aware : \n + - The "old" PointerOf always has propriety of the pointed memory. \n + - If the "old" PointerOf is detroyed, the "new" PointerOf points + a desallocated memory zone. */ +template PointerOf::PointerOf(const PointerOf & pointerOf) : _done(false), + _pointer((T*)(const T* const)pointerOf) { + BEGIN_OF("PointerOf::PointerOf(const PointerOf & pointerOf)"); + MESSAGE("Warning ! No Propriety Transfer"); + END_OF ("PointerOf::PointerOf(const PointerOf & pointerOf)"); } -template PointerOf::PointerOf( const int &size ) : _pointer( new T[ size ]), _done(true) +/*! + Duplicate array of size size pointed in pointerOf. +*/ +template PointerOf::PointerOf( const int &size, const PointerOf & pointerOf) : + _pointer((size,(T*)pointerOf)) +{ +} + +/*! If size <= 0, creates a null "T*" pointer\n + Else allocates memory and sets desallocation boolean to true./n + Memory will be desallocated when erasing this PointerOf*/ +template PointerOf::PointerOf( const int &size ) { + if (size <= 0) + { + _pointer=(T*)NULL; + _done=false; + } + else + { + _pointer = new T[ size ] ; + _done=true; + } } +/*! Creates a standard pointer to the memory zone pointed by T*. /n + T* owner is in charged of memory desallocation. /n + Memory will not be released when erasing this PointerOf*/ template PointerOf::PointerOf( const T* pointer ) : _pointer( (T*)pointer ), _done(false) { } +/*! If size <= 0, return an exception\n + Else duplicate array and sets desallocation boolean to true./n + Memory will be desallocated when erasing this PointerOf*/ +template PointerOf::PointerOf( const int &size, const T* pointer) +{ + if (size <= 0) + throw MEDEXCEPTION("PointerOf( const int,const T*) : array size <= 0"); + + _pointer = new T[ size ] ; + memcpy(_pointer,pointer,size*sizeof(T)); + _done=true; +} + +/*! The destuctor desallocates memory if necessary (that is if the attribute _done equals true).\n + The attribute _pointer is nullified */ template PointerOf::~PointerOf() { if ( _pointer ) @@ -70,49 +155,103 @@ template PointerOf::~PointerOf() } } +/*! Creates a standard pointer (T*) to the pointed memory. \n + The boolean for desallocation is setted to false. \n + Be aware : \n + - The "right" PointerOf always has propriety of the pointed memory. \n + - If the "right" PointerOf is detroyed, the "left" PointerOf points + a desallocated memory zone. + - it works the same way as PointerOf(const PointerOf & pointerOf) */ +template PointerOf& PointerOf::operator=( const PointerOf &pointer ) +{ + BEGIN_OF("PointerOf::operator=( const PointerOf &pointer )") ; + if ( &pointer != this ) + { + this->set( pointer._pointer ) ; + } + END_OF("PointerOf::operator=( const PointerOf &pointer )") ; + return *this ; +} + +/*! Returns _pointer.*/ template PointerOf::operator T*() { return _pointer ; } + +/*! Returns _pointer.*/ template PointerOf::operator const T*() const { return _pointer ; } -// template PointerOf::operator T*() const -// { -// return _pointer ; -// } +/*! If necessary, released memory holded by PointerOf/n. + Else allocates memory and sets desallocation boolean to true./n + Can be used in order to "nullify" an existing PointerOf/n + Memory will be desallocated when erasing this PointerOf*/ template void PointerOf::set( const int &size ) { - ASSERT(size>0) ; if ( _pointer && _done ) { - delete [] _pointer ; + delete [] _pointer ; _pointer=0 ; } - _pointer = new T[ size ] ; + if (size <= 0) + { + _pointer=(T*)NULL; + } + else + { + _pointer = new T[ size ] ; + } _done = true ; return ; } + +/*! If necessary, released memory holded by PointerOf/n. + Then, sets _pointer to the memory zone pointed by T*. /n + T* owner is in charged of memory desallocation. /n + memory will not be released when erasing this PointerOf*/ template void PointerOf::set( const T *pointer ) { - MESSAGE( "PointerOf::set( const T *pointer )" ) ; + MESSAGE( "BEGIN PointerOf::set( const T *pointer )" ) ; SCRUTE(pointer) ; SCRUTE(_done) ; if ( _pointer && _done ) { MESSAGE("PointerOf::set --> deleting _pointer") ; - delete [] _pointer ; + delete [] _pointer ; _pointer=0 ; _done=false ; } _pointer=(T*)pointer ; _done=false ; - MESSAGE( "PointerOf::set( const T *pointer )" ) ; + MESSAGE( "END PointerOf::set( const T *pointer )" ) ; return ; } +/*! If necessary, released memory holded by PointerOf/n. + If size <= 0, return an exception\n. + Else allocates memory and sets desallocation boolean to true./n + Can be used in order to "nullify" an existing PointerOf/n + Memory will be desallocated when erasing this PointerOf*/ +template void PointerOf::set( const int &size, const T *pointer) +{ + if ( _pointer && _done ) + { + delete [] _pointer ; + _pointer = NULL ; + } + if (size <= 0) + throw MEDEXCEPTION("PointerOf( const int,const T*) : array size <= 0"); + + _pointer = new T[ size ] ; + memcpy(_pointer,pointer,size*sizeof(T)); + _done=true; + + return ; +} + # endif /* # if ! defined( __PointerOf_HXX__ ) */ diff --git a/src/MEDMEM/MEDMEM_STRING.hxx b/src/MEDMEM/MEDMEM_STRING.hxx index 8920f5de3..be06dc2ab 100644 --- a/src/MEDMEM/MEDMEM_STRING.hxx +++ b/src/MEDMEM/MEDMEM_STRING.hxx @@ -1,37 +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 -# include -# include +# ifndef MEDMEM_STRING_HXX +# define MEDMEM_STRING_HXX using namespace std; +# include +# include + +/*! + 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 _s.str().c_str() ; - } - STRING() : _s() - { - } - template STRING( const T &valeur ) : _s() - { - _s << valeur ; - } - template STRING &operator<<( const T &valeur ) - { - _s << valeur ; - return *this ; - } -} ; + + STRING::STRING() :string(), _s() + { + } + + STRING::~STRING() + { + _s.freeze(false); + } + + STRING::operator const char * () const + { + return const_cast (this->c_str()) ; + } -// 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)) ; + 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 ) + { + + if ( _s.pcount() ) + { + _s.seekp(-1, ios::cur); // Back up before NULL + _s.rdbuf()->freeze(0); // Unfreeze it + } + + _s << valeur ; + _s << ends; + + 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 e1e5fb60f..f2b2a54b0 100644 --- a/src/MEDMEM/MEDMEM_SkyLineArray.cxx +++ b/src/MEDMEM/MEDMEM_SkyLineArray.cxx @@ -1,3 +1,30 @@ +// 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" @@ -7,43 +34,50 @@ MEDSKYLINEARRAY::MEDSKYLINEARRAY(): _count(0), _length(0), MESSAGE("Constructeur MEDSKYLINEARRAY sans parametre"); } -MEDSKYLINEARRAY::MEDSKYLINEARRAY(const MEDSKYLINEARRAY &myArray) +MEDSKYLINEARRAY::MEDSKYLINEARRAY(const MEDSKYLINEARRAY &myArray): + _count(myArray._count),_length(myArray._length), + _index(_count+1),_value(_length) { - MESSAGE("MEDSKYLINEARRAY(const MEDSKYLINEARRAY &)"); - _count = myArray._count ; - _length = myArray._length ; - _index = new med_int[_count+1] ; - _value = new med_int[_length] ; - memcpy(_index,myArray._index,sizeof(med_int)*(_count+1)); - memcpy(_value,myArray._value,sizeof(med_int)*_length); + BEGIN_OF("MEDSKYLINEARRAY(const MEDSKYLINEARRAY &)"); + memcpy(_index,myArray._index,sizeof(med_int)*(_count+1)); + memcpy(_value,myArray._value,sizeof(med_int)*_length); + END_OF("MEDSKYLINEARRAY(const MEDSKYLINEARRAY &)"); } MEDSKYLINEARRAY::~MEDSKYLINEARRAY() { MESSAGE("Destructeur ~MEDSKYLINEARRAY"); - if (_index != NULL) delete [] _index; - if (_value != NULL) delete [] _value; + //if (_index != NULL) delete [] _index; + //if (_value != NULL) delete [] _value; } -MEDSKYLINEARRAY::MEDSKYLINEARRAY(const med_int count , const med_int length ) : - _count(count), _length(length) +MEDSKYLINEARRAY::MEDSKYLINEARRAY(const med_int count, const med_int length): + _count(count), _length(length), + _index(_count+1),_value(_length) { - MESSAGE("Constructeur MEDSKYLINEARRAY(count="< _index ; // array of size _count+1 : _index[0]=1 and + // _index[_count]=length+1 + PointerOf _value ; // array of size _length public : MEDSKYLINEARRAY(); ~MEDSKYLINEARRAY(); MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray ); - MEDSKYLINEARRAY( const med_int count , const med_int length ); - - void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ; + MEDSKYLINEARRAY( const med_int count, const med_int length ); + MEDSKYLINEARRAY( const med_int count, const med_int length, + const med_int* index, const med_int* value ); + + //void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ; inline med_int getNumberOf() const; inline med_int getLength() const; - inline med_int* getIndex() const; - inline med_int* getValue() const; + inline const med_int* getIndex() const; + inline const med_int* getValue() const; inline med_int getNumberOfI(int i) const throw (MEDEXCEPTION) ; - inline med_int* getI(int i) const throw (MEDEXCEPTION) ; + inline const med_int* getI(int i) const throw (MEDEXCEPTION) ; inline med_int getIJ(int i, int j) const throw (MEDEXCEPTION) ; - + inline med_int getIndexValue(int i) const throw (MEDEXCEPTION) ; + + inline void setIndex(const med_int* index) ; + inline void setI(const med_int i, const med_int* values) throw (MEDEXCEPTION) ; + inline void setIJ(med_int i, med_int j, med_int value) throw (MEDEXCEPTION) ; + inline void setIndexValue(med_int i, med_int value) throw (MEDEXCEPTION) ; + } ; // --------------------------------------- @@ -45,13 +80,13 @@ inline med_int MEDSKYLINEARRAY::getLength() const { return _length ; }; -inline med_int* MEDSKYLINEARRAY::getIndex() const -{ - return _index ; +inline const med_int* MEDSKYLINEARRAY::getIndex() const +{ + return (const med_int*)_index ; } ; -inline med_int* MEDSKYLINEARRAY::getValue() const -{ - return _value ; +inline const med_int* MEDSKYLINEARRAY::getValue() const +{ + return (const med_int*)_value ; } ; inline med_int MEDSKYLINEARRAY::getNumberOfI(int i) const throw (MEDEXCEPTION) { @@ -61,16 +96,16 @@ inline med_int MEDSKYLINEARRAY::getNumberOfI(int i) const throw (MEDEXCEPTION) throw MEDEXCEPTION("MEDSKYLINEARRAY::getNumberOfI : argument is out of range"); return _index[i]-_index[i-1] ; } ; -inline med_int* MEDSKYLINEARRAY::getI(int i) const throw (MEDEXCEPTION) -{ +inline const med_int* MEDSKYLINEARRAY::getI(int i) const throw (MEDEXCEPTION) +{ if (i<1) throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument must be >= 1"); if (i>_count) throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument is out of range"); - return _value+_index[i-1]-1 ; + return _value+_index[i-1]-1 ; } inline med_int MEDSKYLINEARRAY::getIJ(int i, int j) const throw (MEDEXCEPTION) -{ +{ if (i<1) throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : first argument must be >= 1"); if (j<1) @@ -82,5 +117,54 @@ inline med_int MEDSKYLINEARRAY::getIJ(int i, int j) const throw (MEDEXCEPTION) return _value[_index[i-1]+j-2] ; } +inline med_int MEDSKYLINEARRAY::getIndexValue(int i) const throw (MEDEXCEPTION) +{ + if (i<1) + throw MEDEXCEPTION("MEDSKYLINEARRAY::getIndexValue : argument must be >= 1"); + if (i>_index[_count]) + throw MEDEXCEPTION("MEDSKYLINEARRAY::getIndexValue : argument is out of range") ; + return _value[i-1] ; +} + +inline void MEDSKYLINEARRAY::setIndex(const med_int* index) +{ + memcpy((med_int*)_index,index,(_count+1)*sizeof(med_int)); +} + + +inline void MEDSKYLINEARRAY::setIJ(med_int i, med_int j, med_int value) throw (MEDEXCEPTION) +{ + if (i<1) + throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : first argument must be >= 1"); + if (j<1) + throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : second argument must be >= 1"); + if (i>_count) + throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : first argument is out of range") ; + if (j>_index[i]) + throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : second argument is out of range") ; + + _value[_index[i-1]+j-2]=value ; + +} + +inline void MEDSKYLINEARRAY::setI(const med_int i, const med_int * values) throw (MEDEXCEPTION) +{ + if (i<1) + throw MEDEXCEPTION("MEDSKYLINEARRAY::setI : index must be >= 1"); +; + if (i>_count) + throw MEDEXCEPTION("MEDSKYLINEARRAY::setI : index is out of range") ; + + memcpy(_value+_index[i-1]-1,values,(_index[i]-_index[i-1])*sizeof(med_int)) ; +} + +inline void MEDSKYLINEARRAY::setIndexValue(med_int i, med_int value) throw (MEDEXCEPTION) +{ + if (i<1) + throw MEDEXCEPTION("MEDSKYLINEARRAY::setIndexValue : argument must be >= 1"); + if (i>_index[_count]) + throw MEDEXCEPTION("MEDSKYLINEARRAY::setIndexValue : argument is out of range") ; + _value[i-1]=value ; +} # endif diff --git a/src/MEDMEM/MEDMEM_Support.cxx b/src/MEDMEM/MEDMEM_Support.cxx index 4ba9918b3..197f8b148 100644 --- a/src/MEDMEM/MEDMEM_Support.cxx +++ b/src/MEDMEM/MEDMEM_Support.cxx @@ -1,3 +1,30 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_Support.cxx +// Module : MED + +using namespace std; /* File Support.cxx $Header$ @@ -6,82 +33,171 @@ #include #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): +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(const SUPPORT & m) +//-------------------------------------------------------------------------- +{ + const char * LOC = "SUPPORT::SUPPORT(SUPPORT & m) : " ; + BEGIN_OF(LOC) ; + + _name = m._name; + _description = m._description; + _mesh = m._mesh; // on recopie uniquement l'adresse + _entity = m._entity; + _numberOfGeometricType = m._numberOfGeometricType; + if (m._geometricType != NULL) + { + _geometricType = new medGeometryElement[m._numberOfGeometricType]; + memcpy(_geometricType,m._geometricType,m._numberOfGeometricType*sizeof(medGeometryElement)); + } + else + _geometricType = (medGeometryElement *) NULL; + if (m._numberOfGaussPoint != NULL) + { + _numberOfGaussPoint = new int[m._numberOfGeometricType]; + memcpy(_numberOfGaussPoint,m._numberOfGaussPoint,m._numberOfGeometricType*sizeof(int)); + } + 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; + _isOnAllElts = m._isOnAllElts; + if (m._numberOfElements != NULL) + { + _numberOfElements = new int[_numberOfGeometricType]; + memcpy(_numberOfElements,m._numberOfElements,_numberOfGeometricType*sizeof(int)); + } + else + _numberOfElements = (int *) NULL; + _totalNumberOfElements = m._totalNumberOfElements; + if (m._isOnAllElts == false) + _number = new MEDSKYLINEARRAY(* m._number); + else + _number = (MEDSKYLINEARRAY *) NULL; + + 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 : "<getName() << endl ; + os << "Entity : "<< my._entity << endl; + os << "Entity list : "<< endl; + if (!(my._isOnAllElts)) { + int numberoftypes = my._numberOfGeometricType ; + os << "NumberOfTypes : "<getI(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) //------------------- @@ -112,6 +245,8 @@ void SUPPORT::blending(SUPPORT * mySupport) const char * LOC = "SUPPORT::blending() : " ; BEGIN_OF(LOC) ; + MESSAGE(LOC<< "SUPPORT entry : " << *mySupport) ; + // on same entity : if ( _entity != mySupport->getEntity() ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Entities are different !")); @@ -141,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); + SCRUTE(numberOfElements2); + for(int j=0;j::iterator its ; for(its=elementList.begin();its!=elementList.end(); its++) { @@ -188,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")) ; @@ -201,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); }; @@ -236,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 ++ ; + } - MEDSKYLINEARRAY * number = new MEDSKYLINEARRAY(); + 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) ; + + setNumberOfGeometricType(numberOfGeometricType) ; + // setGeometricType(geometricType) ; + // setNumberOfGaussPoint(numberOfGaussPoint) ; + for (int i=0;isetMEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities,index,NumberValue); + _number->setIndex(mySkyLineArrayIndex); - if (_number!=NULL) delete _number ; - _number = number; + for (int i=0;isetIndexValue(i+1,myListArray[i]); + } - update(); + delete[] numberOfElements; + delete[] geometricTypeNumber; + delete[] numberOfGaussPoint; + delete[] geometricType; + delete[] mySkyLineArrayIndex; + delete[] myListArray; + delete mySkyLineArray; - END_OF(LOC); -}; + END_OF(LOC) ; +} diff --git a/src/MEDMEM/MEDMEM_Support.hxx b/src/MEDMEM/MEDMEM_Support.hxx index ea896fd79..ce3b2ebbb 100644 --- a/src/MEDMEM/MEDMEM_Support.hxx +++ b/src/MEDMEM/MEDMEM_Support.hxx @@ -1,6 +1,32 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_Support.hxx +// Module : MED + /* - File Support.hxx - $Header$ + File Support.hxx + $Header$ */ #ifndef SUPPORT_HXX @@ -10,220 +36,272 @@ #include #include "utilities.h" +#include "MEDMEM_STRING.hxx" #include "MEDMEM_Exception.hxx" #include "MEDMEM_define.hxx" #include "MEDMEM_SkyLineArray.hxx" -#include "MEDMEM_Mesh.hxx" +//#include "MEDMEM_Mesh.hxx" using namespace MED_EN; class MESH ; -class SUPPORT +/*! + + This class describe a support of elements on an entity of the mesh. + + It contains the list of meshes elements for an entity (MED_NODE, + MED_CELL, MED_FACE or MED_EDGE). + +*/ + +class SUPPORT { protected: - /*! name of the support */ + /*! + \if developper + Support name. + \endif + */ string _name; - /*! description of the support (optionnal) */ + + /*! + \if developper + Description of the support (optional). + \endif + */ string _description; - /*! reference to the mesh on which the support is defined */ + + /*! + \if developper + Reference to the mesh on which the support is defined. + \endif + */ MESH * _mesh; - /*! type of entity on which the support is defined - (only one for each support) */ + + /*! + \if developper + Type of entity on which the support is defined + (only one for each support). + \endif + */ medEntityMesh _entity ; - /*! number of geometric type defined in the support */ + + /*! + \if developper + Number of geometric type defined in the support. + \endif + */ int _numberOfGeometricType; - /*! array of all geometric type defined in the support */ + + /*! + \if developper + Array of all geometric type defined in the support. + \endif + */ medGeometryElement * _geometricType; - /*! array of size _numberOfGeometricType which contains - for each type the number of gauss point - (not yet implemented) */ - int * _numberOfGaussPoint ; - /*! array of size _numberOfGeometricType - which contains number of geometric - entity type in Mesh - (to get corresponding CellModel)*/ - int * _geometricTypeNumber; - /*! If true, we consider all entities of type _entity */ - bool _isOnAllElts; - /*! array of size _numberOfGeometricType wich contains - for each geometric type, count of entities. - (if _isOnAllElts is true, we could get same - information from _mesh) */ - int * _numberOfEntities; - /*! sum of each _numberOfEntities component (if - _isOnAllElts is true, we could get same - information from _mesh) */ - int _totalNumberOfEntities; + + /*! + \if developper + Array of size _numberOfGeometricType which contains + for each type the number of gauss point + (not yet implemented). + \endif + */ + int * _numberOfGaussPoint ; + + /* + \if developper + Array of size _numberOfGeometricType + which contains number of geometric + entity type in Mesh + (to get corresponding CellModel). + \endif + */ + //int * _geometricTypeNumber; + + /*! + \if developper + If true, we consider all entities of type _entity. + \endif + */ + bool _isOnAllElts; + + /*! + \if developper + Index array of size _numberOfGeometricType wich contains + for each geometric type, the number of elements of this type. + \endif + */ + int * _numberOfElements; + + /*! + \if developper + Sum of each _numberOfElements component. + \endif + */ + int _totalNumberOfElements; // the two following arrays are defined only if _isOnAllElts is false : - /* array of size _numberOfType+1 wich contains for - each geometric type, index in _number._value - (if _all is true, we must ask _mesh to get - information). _typeIndex[i+1]-_typeIndex[i] - represents count of entities of ith geometric - type. _typeIndex[_numberOfType] contains total - entities count. If _numberOf[i]=0, - _typeIndex[i+1]=_typeIndex[i] - defined only if _isOnAllElts is false*/ - // int * _typeIndex; - /*! array of size _index[_numberOfType] wich contain number of - entities of each geometric type. We use global numbering. - defined only if _isOnAllElts is false*/ - MEDSKYLINEARRAY * _number; + /* + \if developper + array of size _numberOfType+1 wich contains for + each geometric type, index in _number._value + (if _all is true, we must ask _mesh to get + information). _typeIndex[i+1]-_typeIndex[i] + represents count of entities of ith geometric + type. _typeIndex[_numberOfType] contains total + entities count. If _numberOf[i]=0, + _typeIndex[i+1]=_typeIndex[i] + defined only if _isOnAllElts is false + \endif + */ + // int * _typeIndex; + + /*! + \if developper + Array of size _index[_numberOfType]-1 wich contain number of + entities of each geometric type. We use global numbering.\n + Defined only if _isOnAllElts is false. + \endif + */ + MEDSKYLINEARRAY * _number; public: - SUPPORT(); - SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL); + SUPPORT(); + SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL); + SUPPORT(const SUPPORT & m); ~SUPPORT(); friend ostream & operator<<(ostream &os,const SUPPORT &my); - + // function to set all value when SUPPORT was created by MedMedDriver without all MESH information !!! Change with new API ! void update(); - + inline void setName(string Name); - inline void setDescription(string Description); - inline void setMesh(MESH *Mesh); - inline void setAll(bool All); - inline void setEntity(medEntityMesh Entity); - inline void setNumberOfGeometricType(int NumberOfGeometricType); - inline void setGeometricType(medGeometryElement *GeometricType); - inline void setNumberOfGaussPoint(int *NumberOfGaussPoint); - inline void setGeometricTypeNumber(int *GeometricTypeNumber); - inline void setNumberOfEntities(int *NumberOfEntities); - inline void setTotalNumberOfEntities(int TotalNumberOfEntities); - inline void setNumber(MEDSKYLINEARRAY * Number); - - inline string getName() const; - inline string getDescription() const; - inline MESH * getMesh() const; + inline void setDescription(string Description); + inline void setMesh(MESH *Mesh); + inline void setAll(bool All); + inline void setEntity(medEntityMesh Entity); + inline void setNumberOfGeometricType(int NumberOfGeometricType); + inline void setGeometricType(const medGeometryElement *GeometricType); + inline void setNumberOfGaussPoint(const int *NumberOfGaussPoint); + // inline void setGeometricTypeNumber(int *GeometricTypeNumber); + inline void setNumberOfElements(const int *NumberOfElements); + inline void setTotalNumberOfElements(int TotalNumberOfElements); + inline void setNumber(MEDSKYLINEARRAY * Number); + inline void setNumber(const int * index, const int* value); + + inline string getName() const; + inline string getDescription() const; + inline MESH * getMesh() const; inline medEntityMesh getEntity() const; - inline bool isOnAllElements() const; + inline bool isOnAllElements() const; inline int getNumberOfTypes() const; - inline medGeometryElement* getTypes() const ; - inline int * getNumberOfGaussPoint() const throw (MEDEXCEPTION); - inline int getNumberOfGaussPoint(medGeometryElement geomElement) const throw (MEDEXCEPTION); - inline int * getGeometricTypeNumber() const; - // inline int getNumberOfTotalEntity() const; + inline const medGeometryElement* getTypes() const ; + inline const int * getNumberOfGaussPoint() const throw (MEDEXCEPTION); + inline int getNumberOfGaussPoint(medGeometryElement geomElement) const throw (MEDEXCEPTION); + //inline int * getGeometricTypeNumber() const; + //inline int getTotalNumberOfElement() const; inline int getNumberOfElements(medGeometryElement GeometricType) const throw (MEDEXCEPTION); inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION); - inline int * getNumber(medGeometryElement GeometricType) const throw (MEDEXCEPTION); - inline int * getNumberIndex() const throw (MEDEXCEPTION); + inline const int * getNumber(medGeometryElement GeometricType) const throw (MEDEXCEPTION); + inline const int * getNumberIndex() const throw (MEDEXCEPTION); void blending(SUPPORT * mySupport); - /* - This function allows the user to set a support not on all entities Entity, - it should be used after an initialisation with the constructor - SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL) and - after the call to the function setAll(false). - It allocates and initialises all the attributs of the class SUPPORT. - */ - void setpartial(string Description, int NumberOfGeometricType, int TotalNumberOfEntity, medGeometryElement *GeometricType, int *NumberOfEntity, int *NumberValue); + + void getBoundaryElements() throw (MEDEXCEPTION); }; // _____________________ // Methodes Inline // _____________________ -/*! If isOnAllElements is false, returns number of elements in the - support else returns number of nodes. +/*! + If isOnAllElements is false, returns number of elements in the + support else returns number of nodes. - Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements - in entity of support. + Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements + in entity of support. - Note : If SUPPORT is defined on MED_NODE, use MED_NONE - medGeometryElement type. */ + Note : If SUPPORT is defined on MED_NODE, use MED_NONE + medGeometryElement type. +*/ //----------------------------------------------------------------------------- inline int SUPPORT::getNumberOfElements(medGeometryElement GeometricType) const -throw (MEDEXCEPTION) + throw (MEDEXCEPTION) //----------------------------------------------------------------------------- { - if (_isOnAllElts){ - return _mesh->getNumberOfElements(_entity,GeometricType); - } else { - if (GeometricType==MED_ALL_ELEMENTS) - return _totalNumberOfEntities; - for (int i=0;i<_numberOfGeometricType;i++) - if (_geometricType[i]==GeometricType) - return _numberOfEntities[i] ; - throw MEDEXCEPTION("Support::getNumberOfElements : Type not found !") ; - } + if (GeometricType==MED_ALL_ELEMENTS) + return _totalNumberOfElements; + for (int i=0;i<_numberOfGeometricType;i++) + if (_geometricType[i]==GeometricType) + return _numberOfElements[i]; + throw MEDEXCEPTION("Support::getNumberOfElements : Geometric type not found !") ; } -// inline int SUPPORT::getNumberOf(medGeometryElement GeometricType) const -// throw (MEDEXCEPTION) -// { -// if (GeometricType==MED_ALL_ELEMENTS) -// return _totalNumberOfEntities ; -// for (int i=0;i<_numberOfGeometricType;i++) -// if (_geometricType[i]==GeometricType) -// return _numberOfEntities[i] ; -// throw MEDEXCEPTION("Support::getNumberOf: GeometricType not found !"); -// } - -// inline int SUPPORT::getNumberOfTotalEntity() const -// { -// return _totalNumberOfEntities ; -// } //--------------------------------------------------------------------- -inline MEDSKYLINEARRAY * SUPPORT::getnumber() const - throw (MEDEXCEPTION) +inline MEDSKYLINEARRAY * SUPPORT::getnumber() const + throw (MEDEXCEPTION) //--------------------------------------------------------------------- { - if (_number==NULL) + if (_number==NULL) throw MEDEXCEPTION("Support::getnumber : Not defined !") ; return _number ; } -/*! If isOnAllElements is false, returns an array which contains - all number of given medGeometryElement. +/*! + If isOnAllElements is false, returns an array which contains + all number of given medGeometryElement. - Numbering is global, ie numbers are bounded by 1 and - MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and - MESH::getNumberOfElement(entity,geomElement). + Numbering is global, ie numbers are bounded by 1 and + MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and + MESH::getNumberOfElement(entity,geomElement). - Note : If SUPPORT is defined on MED_NODE, use MED_NONE - medGeometryElement type. */ + Note : If SUPPORT is defined on MED_NODE, use MED_NONE + medGeometryElement type. +*/ //--------------------------------------------------------------------- -inline int * SUPPORT::getNumber(medGeometryElement GeometricType) const - throw (MEDEXCEPTION) +inline const int * SUPPORT::getNumber(medGeometryElement GeometricType) const + throw (MEDEXCEPTION) //--------------------------------------------------------------------- { const char * LOC = "Support::getNumber : " ; - if (_isOnAllElts) + if (_isOnAllElts) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined, support is on all entity !")) ; if (GeometricType==MED_ALL_ELEMENTS) - return _number->getValue() ; + return _number->getValue() ; for (int i=0;i<_numberOfGeometricType;i++) if (_geometricType[i]==GeometricType) return _number->getI(i+1) ; throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"GeometricType not found !")) ; } -/*! If isOnAllElements is false, returns index of element number. - Use it with getNumber(MED_ALL_ELEMENTS). +/*! + If isOnAllElements is false, returns index of element number. + Use it with getNumber(MED_ALL_ELEMENTS). - Note : See getConnectivityIndex for details. */ + Note : See getConnectivityIndex for details. +*/ //------------------------------------------- -inline int * SUPPORT::getNumberIndex() const +inline const int * SUPPORT::getNumberIndex() const //------------------------------------------- -throw (MEDEXCEPTION) + throw (MEDEXCEPTION) { - if (_isOnAllElts) - throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ; - return _number->getIndex() ; + if (_isOnAllElts) + throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ; + return _number->getIndex() ; } /*! A DOCUMENTER */ //------------------------------------------------- -inline int * SUPPORT::getNumberOfGaussPoint() const -throw (MEDEXCEPTION) +inline const int * SUPPORT::getNumberOfGaussPoint() const + throw (MEDEXCEPTION) //------------------------------------------------- { if (_numberOfGaussPoint!=NULL) @@ -232,14 +310,16 @@ throw (MEDEXCEPTION) throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ; } -/*! Returns number of Gauss points for this medGeometryElement. +/*! + Returns number of Gauss points for this medGeometryElement. - Note : - - Not defined if SUPPORT is on MED_NODE. - - Not defined for MED_ALL_ELEMENTS medGeometryElement type. */ + Note : + - Not defined if SUPPORT is on MED_NODE. + - Not defined for MED_ALL_ELEMENTS medGeometryElement type. +*/ //----------------------------------------------------------------------------- -inline int SUPPORT::getNumberOfGaussPoint(medGeometryElement geomElement) const -throw (MEDEXCEPTION) +inline int SUPPORT::getNumberOfGaussPoint(medGeometryElement geomElement) const + throw (MEDEXCEPTION) //----------------------------------------------------------------------------- { if (_numberOfGaussPoint!=NULL) { @@ -250,196 +330,249 @@ throw (MEDEXCEPTION) } else throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ; } -// inline int SUPPORT::getNumberLength() const -// throw (MEDEXCEPTION) +// inline int SUPPORT::getNumberLength() const +// throw (MEDEXCEPTION) // { -// if (_isOnAllElts) +// if (_isOnAllElts) // throw MEDEXCEPTION("Support::getNumberLength : Not defined, support is on all entity !") ; // return _number->getLength() ; // } -/*! set the attribute _name to Name */ +/*! set the attribute _name to Name */ //-------------------------------------- inline void SUPPORT::setName(string Name) //-------------------------------------- -{ - _name=Name; +{ + _name=Name; } /*! set the attribute _description to Description */ //-------------------------------------------------- inline void SUPPORT::setDescription(string Description) //-------------------------------------------------- -{ - _description=Description; +{ + _description=Description; } -/*! set the reference _mesh to Mesh */ +/*! set the reference _mesh to Mesh */ //-------------------------------------- inline void SUPPORT::setMesh(MESH *Mesh) //-------------------------------------- -{ - _mesh=Mesh; +{ + _mesh=Mesh; } /*! set the attribute _isOnAllElts to All */ //------------------------------------------ inline void SUPPORT::setAll(bool All) //------------------------------------------ -{ - _isOnAllElts=All; +{ + _isOnAllElts=All; } /*! set the attribute _entity to Entity */ //------------------------------------------ inline void SUPPORT::setEntity(medEntityMesh Entity) -{ - _entity=Entity; - if ( Entity == MED_NODE) { - _numberOfGeometricType=1 ; - _geometricType=new medGeometryElement[1] ; // delete previous ??? - _geometricType[0]=MED_NONE ; - } +{ + _entity=Entity; +// if ( Entity == MED_NODE) { +// _numberOfGeometricType=1 ; +// if (_geometricType == (medGeometryElement *) NULL) +// _geometricType=new medGeometryElement[1] ; +// else +// { +// // delete previous ??? +// delete [] _geometricType; +// _geometricType=new medGeometryElement[1] ; +// } +// _geometricType[0]=MED_NONE ; +// } } /*! set the attribute _numberOfGeometricType to NumberOfGeometricType */ //--------------------------------------------------------------------- inline void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType) //--------------------------------------------------------------------- -{ - _numberOfGeometricType=NumberOfGeometricType; +{ + _numberOfGeometricType=NumberOfGeometricType; + if (_geometricType!=NULL) { + delete[] _geometricType ; + _geometricType = NULL ; + } + if (_numberOfElements!=NULL) { + delete[] _numberOfElements ; + _numberOfElements = NULL ; + } + if (_numberOfGaussPoint!=NULL) { + delete[] _numberOfGaussPoint ; + _numberOfGaussPoint = NULL ; + } } -/*! set the attribute _geometricType to geometricType */ +/*! set the attribute _geometricType to geometricType */ //--------------------------------------------------------------------- -inline void SUPPORT::setGeometricType(medGeometryElement *GeometricType) +inline void SUPPORT::setGeometricType(const medGeometryElement *GeometricType) //--------------------------------------------------------------------- -{ - _geometricType=GeometricType; +{ + if (NULL == _geometricType) + _geometricType=new medGeometryElement[_numberOfGeometricType]; + for (int i=0;i<_numberOfGeometricType;i++) + _geometricType[i] = GeometricType[i]; + // _geometricType=GeometricType; } -/*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */ +/*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */ //----------------------------------------------------------------- -inline void SUPPORT::setNumberOfGaussPoint(int *NumberOfGaussPoint) +inline void SUPPORT::setNumberOfGaussPoint(const int *NumberOfGaussPoint) //----------------------------------------------------------------- { - _numberOfGaussPoint = NumberOfGaussPoint ; + if (NULL == _numberOfGaussPoint) + _numberOfGaussPoint=new int[_numberOfGeometricType]; + for (int i=0;i<_numberOfGeometricType;i++) + _numberOfGaussPoint[i] = NumberOfGaussPoint[i]; + // _numberOfGaussPoint = NumberOfGaussPoint ; } -/*! set the attribute _geometricTypeNumber to GeometricTypeNumber */ +/*! set the attribute _geometricTypeNumber to GeometricTypeNumber */ //------------------------------------------------------------------- -inline void SUPPORT::setGeometricTypeNumber(int *GeometricTypeNumber) +//inline void SUPPORT::setGeometricTypeNumber(int *GeometricTypeNumber) //------------------------------------------------------------------- -{ - _geometricTypeNumber=GeometricTypeNumber; -} +//{ +// _geometricTypeNumber=GeometricTypeNumber; +//} -/*! set the attribute _numberOfEntities to NumberOfEntities */ +/*! + Set the attribute _numberOfElements to NumberOfElements and + calculate the total number of elements. +*/ //---------------------------------------------------------- -inline void SUPPORT::setNumberOfEntities(int *NumberOfEntities) +inline void SUPPORT::setNumberOfElements(const int *NumberOfElements) //---------------------------------------------------------- -{ - _numberOfEntities=NumberOfEntities; +{ + if (NULL == _numberOfElements) + _numberOfElements=new int[_numberOfGeometricType]; + memcpy(_numberOfElements,NumberOfElements,sizeof(int)*_numberOfGeometricType); + _totalNumberOfElements = 0 ; + for (int i=0;i<_numberOfGeometricType;i++) + _totalNumberOfElements+=_numberOfElements[i]; } -/*! set the attribute _totalNumberOfEntities to TotalNumberOfEntities */ +/*! set the attribute _totalNumberOfElements to TotalNumberOfElements */ //-------------------------------------------------------------------- -inline void SUPPORT::setTotalNumberOfEntities(int TotalNumberOfEntities) +inline void SUPPORT::setTotalNumberOfElements(int TotalNumberOfElements) //-------------------------------------------------------------------- -{ - _totalNumberOfEntities=TotalNumberOfEntities; +{ + _totalNumberOfElements=TotalNumberOfElements; } -/*! set the attribute _number to Number */ +/*! set the attribute _number to Number */ //--------------------------------------------------- inline void SUPPORT::setNumber(MEDSKYLINEARRAY * Number) //--------------------------------------------------- -{ - _number=Number; +{ + if (_number != NULL) delete _number ; + _number=Number; +} + +/*! set the attribute _number with index and value arrays */ +//--------------------------------------------------- +inline void SUPPORT::setNumber(const int * index, const int* value) +//--------------------------------------------------- +{ + if (_number != NULL) delete _number ; + _number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value); } /*! returns the name of the support. */ //------------------------------------ -inline string SUPPORT::getName() const +inline string SUPPORT::getName() const //------------------------------------ -{ - return _name; +{ + return _name; } /*! returns the description of the support. */ //-------------------------------------------- -inline string SUPPORT::getDescription() const +inline string SUPPORT::getDescription() const //-------------------------------------------- -{ - return _description; +{ + return _description; } -/*! returns a refernce to the mesh */ +/*! returns a reference to the mesh */ //------------------------------------ -inline MESH * SUPPORT::getMesh() const +inline MESH * SUPPORT::getMesh() const //------------------------------------ -{ - return _mesh; +{ + return _mesh; } -/*! Returns true if all elements of this entity are - concerned, false otherwise. - If true, you must use mesh reference (getMesh) to get more information.*/ +/*! + Returns true if all elements of this entity are + concerned, false otherwise. + If true, you must use mesh reference (getMesh) to get more information. +*/ //------------------------------------------ -inline bool SUPPORT::isOnAllElements() const +inline bool SUPPORT::isOnAllElements() const //------------------------------------------ -{ - return _isOnAllElts; +{ + return _isOnAllElts; } -/*! Returns number of geometric Types - defines in the support */ +/*! + Returns number of geometric Types + defines in the support +*/ //------------------------------------------ -inline int SUPPORT::getNumberOfTypes() const +inline int SUPPORT::getNumberOfTypes() const //------------------------------------------ -{ - if ((_isOnAllElts)&(_entity != MED_NODE)) - return _mesh->getNumberOfTypes(_entity) ; - else - return _numberOfGeometricType ; +{ + // if ((_isOnAllElts)&(_entity != MED_NODE)) + // return _mesh->getNumberOfTypes(_entity) ; + // else + return _numberOfGeometricType ; } -/*! Returns the medEntityMesh's type used by the support. - Note : A support deals only with one entity's type - (for example : MED_FACE or MED_NODE)*/ +/*! + Returns the medEntityMesh's type used by the support. + Note : A support deals only with one entity's type + (for example : MED_FACE or MED_NODE) +*/ //--------------------------------------------- -inline medEntityMesh SUPPORT::getEntity() const +inline medEntityMesh SUPPORT::getEntity() const //--------------------------------------------- -{ - return _entity; +{ + return _entity; } -/*! If isOnAllElements is false, returns an array of - types used by the support. +/*! + If isOnAllElements is false, returns an array of + types used by the support. - is given by getEntity. */ + is given by getEntity. +*/ //--------------------------------------------------- -inline medGeometryElement * SUPPORT::getTypes() const +inline const medGeometryElement * SUPPORT::getTypes() const //--------------------------------------------------- { - if ((_isOnAllElts)&(_entity != MED_NODE)) - return _mesh->getTypes(_entity) ; - else - return _geometricType; + // if ((_isOnAllElts)&(_entity != MED_NODE)) + // return _mesh->getTypes(_entity) ; + // else + return _geometricType; } //--------------------------------------------------- -inline int * SUPPORT::getGeometricTypeNumber() const +//inline int * SUPPORT::getGeometricTypeNumber() const //--------------------------------------------------- -{ - const char * LOC = "SUPPORT::getGeometricTypeNumber() : "; - if (_isOnAllElts) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined (is on all elements) !")); - if (_geometricTypeNumber==NULL) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined !")); - return _geometricTypeNumber; -} +// { +// const char * LOC = "SUPPORT::getGeometricTypeNumber() : "; +// if (_isOnAllElts) +// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined (is on all elements) !")); +// if (_geometricTypeNumber==NULL) +// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined !")); +// return _geometricTypeNumber; +// } + - #endif /* SUPPORT_HXX */ diff --git a/src/MEDMEM/MEDMEM_TypeMeshDriver.cxx b/src/MEDMEM/MEDMEM_TypeMeshDriver.cxx new file mode 100644 index 000000000..413436daa --- /dev/null +++ b/src/MEDMEM/MEDMEM_TypeMeshDriver.cxx @@ -0,0 +1,229 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : MEDMEM_TypeMeshDriver.cxx +// Module : MED + +#include "MEDMEM_TypeMeshDriver.hxx" + +#include "MEDMEM_DriversDef.hxx" + +#include "MEDMEM_Family.hxx" +#include "MEDMEM_Group.hxx" +#include "MEDMEM_Coordinate.hxx" +#include "MEDMEM_Connectivity.hxx" +#include "MEDMEM_Mesh.hxx" +#include "MEDMEM_CellModel.hxx" + +// Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor + +TYPE_MESH_DRIVER::TYPE_MESH_DRIVER(): + GENDRIVER(), + _ptrMesh(( MESH *)MED_NULL), + // A VOIR _medIdt(MED_INVALID), + _meshName("") +{ +} + +TYPE_MESH_DRIVER::TYPE_MESH_DRIVER(const string & fileName, + MESH * ptrMesh, + MED_EN::med_mode_acces accessMode): + GENDRIVER(fileName,accessMode), + _ptrMesh(ptrMesh), + // A VOIR _medIdt(MED_INVALID), + _meshName("") +{ +} + +TYPE_MESH_DRIVER::TYPE_MESH_DRIVER(const TYPE_MESH_DRIVER & driver): + GENDRIVER(driver), + _ptrMesh(driver._ptrMesh), + // A VOIR _medIdt(MED_INVALID), + _meshName(driver._meshName) +{ +} + +TYPE_MESH_DRIVER::~TYPE_MESH_DRIVER() +{ +} + +void TYPE_MESH_DRIVER::open() + throw (MEDEXCEPTION) +{ + const char * LOC = "TYPE_MESH_DRIVER::open()" ; + BEGIN_OF(LOC); + +// if (_medIdt > 0) +// _status = MED_OPENED; +// else { +// _medIdt = MED_INVALID; +// _status = MED_CLOSED; +// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode)); +// } + + END_OF(LOC); +} + +void TYPE_MESH_DRIVER::close() + throw (MEDEXCEPTION) +{ + const char * LOC = "TYPE_MESH_DRIVER::close() " ; + BEGIN_OF(LOC); + +// 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 !" +// ) +// ); +// _status = MED_CLOSED; +// _medIdt = MED_INVALID; +// } + + END_OF(LOC); +} + +void TYPE_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; }; +string TYPE_MESH_DRIVER::getMeshName() const { return _meshName; }; + + +//---------------------------------- RDONLY PART ------------------------------------------------------------- + +TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(): TYPE_MESH_DRIVER() +{ +} + +TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(const string & fileName, + MESH * ptrMesh): + TYPE_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY) +{ + MESSAGE("TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); +} + +TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(const TYPE_MESH_RDONLY_DRIVER & driver): + TYPE_MESH_DRIVER(driver) +{ +} + +TYPE_MESH_RDONLY_DRIVER::~TYPE_MESH_RDONLY_DRIVER() +{ + //MESSAGE("TYPE_MESH_RDONLY_DRIVER::~TYPE_MESH_RDONLY_DRIVER() has been destroyed"); +} + +GENDRIVER * TYPE_MESH_RDONLY_DRIVER::copy(void) const +{ + return new TYPE_MESH_RDONLY_DRIVER(*this); +} + +void TYPE_MESH_RDONLY_DRIVER::read(void) + throw (MEDEXCEPTION) +{ + const char * LOC = "TYPE_MESH_RDONLY_DRIVER::read() : " ; + BEGIN_OF(LOC); + + if (_status!=MED_OPENED) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << " (the file is not opened)." )) ; + + _ptrMesh->_name = _meshName; + + + END_OF(LOC); +} + +void TYPE_MESH_RDONLY_DRIVER::write( void ) const + throw (MEDEXCEPTION) +{ + throw MEDEXCEPTION("TYPE_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !"); +} + + +/*--------------------- WRONLY PART -------------------------------*/ + +TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER():TYPE_MESH_DRIVER() +{ +} + +TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const string & fileName, + MESH * ptrMesh): + TYPE_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY) +{ + MESSAGE("TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); +} + +TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const TYPE_MESH_WRONLY_DRIVER & driver): + TYPE_MESH_DRIVER(driver) +{ +} + +TYPE_MESH_WRONLY_DRIVER::~TYPE_MESH_WRONLY_DRIVER() +{ + //MESSAGE("TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed"); +} + +GENDRIVER * TYPE_MESH_WRONLY_DRIVER::copy(void) const +{ + return new TYPE_MESH_WRONLY_DRIVER(*this); +} + +void TYPE_MESH_WRONLY_DRIVER::read (void) + throw (MEDEXCEPTION) +{ + throw MEDEXCEPTION("TYPE_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !"); +} + +void TYPE_MESH_WRONLY_DRIVER::write(void) const + throw (MEDEXCEPTION) +{ + const char * LOC = "void TYPE_MESH_WRONLY_DRIVER::write(void) const : "; + BEGIN_OF(LOC); + + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "Write Driver isn\'t implemented")); + + END_OF(LOC); +} + + + +/*--------------------- RDWR PART -------------------------------*/ + +TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER():TYPE_MESH_DRIVER() +{ +} + +TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const string & fileName, + MESH * ptrMesh): + TYPE_MESH_DRIVER(fileName,ptrMesh,MED_RDWR) +{ + MESSAGE("TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); +} + +TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const TYPE_MESH_RDWR_DRIVER & driver): + TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_DRIVER(driver) +{ +} + +TYPE_MESH_RDWR_DRIVER::~TYPE_MESH_RDWR_DRIVER() { + //MESSAGE("TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed"); +} + +GENDRIVER * TYPE_MESH_RDWR_DRIVER::copy(void) const +{ + return new TYPE_MESH_RDWR_DRIVER(*this); +} + +void TYPE_MESH_RDWR_DRIVER::write(void) const + throw (MEDEXCEPTION) +{ + TYPE_MESH_WRONLY_DRIVER::write(); +} +void TYPE_MESH_RDWR_DRIVER::read (void) + throw (MEDEXCEPTION) +{ + TYPE_MESH_RDONLY_DRIVER::read(); +} diff --git a/src/MEDMEM/MEDMEM_TypeMeshDriver.hxx b/src/MEDMEM/MEDMEM_TypeMeshDriver.hxx new file mode 100644 index 000000000..5e9fe230d --- /dev/null +++ b/src/MEDMEM/MEDMEM_TypeMeshDriver.hxx @@ -0,0 +1,218 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : MEDMEM_TypeMeshDriver.hxx +// Module : MED + +#ifndef TYPE_MESH_DRIVER_HXX +#define TYPE_MESH_DRIVER_HXX + +#include +#include + +#include "MEDMEM_define.hxx" +#include "MEDMEM_GenDriver.hxx" + +#include "MEDMEM_STRING.hxx" +#include "MEDMEM_Exception.hxx" +#include "utilities.h" + +class MESH; +class FAMILY; +class GROUP; +class CONNECTIVITY; + +/*! + + Driver TYPE for MESH. + + Generic part : implement the readopen and close methods. + +*/ + + +class TYPE_MESH_DRIVER : public GENDRIVER +{ +protected: + + MESH * _ptrMesh; + // A VOIR FILE DESCRIPTEUR ? MED_FR::med_idt _medIdt; + string _meshName; + +public : + + /*! + Constructor. + */ + TYPE_MESH_DRIVER() ; + /*! + Constructor. + */ + TYPE_MESH_DRIVER(const string & fileName, + MESH * ptrMesh, + med_mode_acces accessMode) ; + /*! + Copy constructor. + */ + TYPE_MESH_DRIVER(const TYPE_MESH_DRIVER & driver) ; + + /*! + Destructor. + */ + virtual ~TYPE_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 ; + +}; + + +class TYPE_MESH_RDONLY_DRIVER : public virtual TYPE_MESH_DRIVER +{ + +public : + + /*! + Constructor. + */ + TYPE_MESH_RDONLY_DRIVER() ; + /*! + Constructor. + */ + TYPE_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ; + /*! + Copy constructor. + */ + TYPE_MESH_RDONLY_DRIVER(const TYPE_MESH_RDONLY_DRIVER & driver) ; + + /*! + Destructor. + */ + virtual ~TYPE_MESH_RDONLY_DRIVER() ; + + /*! + 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: + + GENDRIVER * copy ( void ) const ; + +}; + +/*! + + Driver Med for MESH : Write only. + + Implement write method. + +*/ + +class TYPE_MESH_WRONLY_DRIVER : public virtual TYPE_MESH_DRIVER { + +public : + + /*! + Constructor. + */ + TYPE_MESH_WRONLY_DRIVER() ; + /*! + Constructor. + */ + TYPE_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) ; + /*! + Copy constructor. + */ + TYPE_MESH_WRONLY_DRIVER(const TYPE_MESH_WRONLY_DRIVER & driver) ; + + /*! + Destructor. + */ + virtual ~TYPE_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: + + GENDRIVER * copy ( void ) const ; +}; + + +/*! + + Driver TYPE for MESH : Read write. + - Use read method from TYPE_MESH_RDONLY_DRIVER + - Use write method from TYPE_MESH_WRONLY_DRIVER + +*/ + +class TYPE_MESH_RDWR_DRIVER : public TYPE_MESH_RDONLY_DRIVER, public TYPE_MESH_WRONLY_DRIVER { + +public : + + /*! + Constructor. + */ + TYPE_MESH_RDWR_DRIVER() ; + /*! + Constructor. + */ + TYPE_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ; + /*! + Copy constructor. + */ + TYPE_MESH_RDWR_DRIVER(const TYPE_MESH_RDWR_DRIVER & driver) ; + + /*! + Destructor. + */ + ~TYPE_MESH_RDWR_DRIVER() ; + + /*! + 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 /* TYPE_MESH_DRIVER_HXX */ diff --git a/src/MEDMEM/MEDMEM_Unit.cxx b/src/MEDMEM/MEDMEM_Unit.cxx index 84022ce96..7cd49a7e4 100644 --- a/src/MEDMEM/MEDMEM_Unit.cxx +++ b/src/MEDMEM/MEDMEM_Unit.cxx @@ -1,3 +1,30 @@ +// 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 $Header$ diff --git a/src/MEDMEM/MEDMEM_Unit.hxx b/src/MEDMEM/MEDMEM_Unit.hxx index 81a24f860..62f885760 100644 --- a/src/MEDMEM/MEDMEM_Unit.hxx +++ b/src/MEDMEM/MEDMEM_Unit.hxx @@ -1,3 +1,29 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_Unit.hxx +// Module : MED + /* File Unit.hxx $Header$ diff --git a/src/MEDMEM/MEDMEM_VtkMedDriver.cxx b/src/MEDMEM/MEDMEM_VtkMedDriver.cxx index c6d8c61ec..70df3ee59 100644 --- a/src/MEDMEM/MEDMEM_VtkMedDriver.cxx +++ b/src/MEDMEM/MEDMEM_VtkMedDriver.cxx @@ -1,198 +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() { +void VTK_MED_DRIVER::write() const { - const char * LOC = "MED_MED_DRIVER::write() : "; + 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; i + +using namespace std ; class MESH; +class SUPPORT; class FIELD_; class MED; // This driver pilots within a VTK class read/write accesses of fields/meshes -class VTK_VTK_DRIVER : public GENDRIVER +class VTK_MED_DRIVER : public GENDRIVER { protected: - MED * const _ptrMED ; // Store 'VTK_DRIVER (0..n)----(1) VTK' associations - ofstream _vtkFile ; // The _vtkFile used to write Meshes and Fields to _filename + MED * const _ptrMed ; // Store 'VTK_DRIVER (0..n)----(1) VTK' associations + ofstream * _vtkFile ; // The _vtkFile used to write Meshes and Fields to _filename private: VTK_MED_DRIVER(); + //writeField(FIELD * myField) ; + //writeMesh(MESH * myMesh) ; + + void open() ; + void close() ; + void openConst() const ; + void closeConst() const ; + public : VTK_MED_DRIVER(const string & fileName, MED * const ptrMed); + VTK_MED_DRIVER(const VTK_MED_DRIVER & driver); + ~VTK_MED_DRIVER(); // OPERATEUR DE RECOPIE AVEC _vtkFile ?? - void open(); - void close(); - - virtual void write ( void ) const ; + //virtual void write ( void ) ; + void write ( void ) const ; + virtual void read ( void ) {} ; // virtual void writeFrom ( void ) const ; // virtual void read ( void ) ; + GENDRIVER * copy (void ) const ; -protected : - void writeMesh(MESH * myMesh) ; - void writeField(FIELD_ * myField) ; +private : + void writeMesh(MESH * myMesh) const ; + void writeSupport(SUPPORT * mySupport) const ; + void writeField(FIELD_ * myField,string name) const ; }; diff --git a/src/MEDMEM/MEDMEM_define.hxx b/src/MEDMEM/MEDMEM_define.hxx index 41937a29b..92d578b0f 100644 --- a/src/MEDMEM/MEDMEM_define.hxx +++ b/src/MEDMEM/MEDMEM_define.hxx @@ -1,9 +1,35 @@ +// 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_define.hxx +// Module : MED + #ifndef DEFINE_HXX #define DEFINE_HXX #include -#include -#include +#include +#include #include // UTILE AUX DEUX NAMESPACES @@ -29,6 +55,8 @@ namespace MED_EN { #define MED_TAILLE_LNOM 80 #define MED_TAILLE_PNOM 8 +typedef enum {MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED} med_grid_type; + typedef enum {MED_FULL_INTERLACE, MED_NO_INTERLACE} medModeSwitch; diff --git a/src/MEDMEM/Makefile.in b/src/MEDMEM/Makefile.in index c6b84371c..270e84456 100644 --- a/src/MEDMEM/Makefile.in +++ b/src/MEDMEM/Makefile.in @@ -1,14 +1,34 @@ -#============================================================================== -# File : Makefile.in -# Author : Patrick GOLDBRONN (CEA/DEN/DM2S/SFME/LGLS) -# CVS : $Header$ -#============================================================================== +# MED MEDMEM : MED files in memory +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Patrick GOLDBRONN (CEA/DEN/DM2S/SFME/LGLS) +# Module : MED -# source path top_srcdir=@top_srcdir@ top_builddir=../../.. srcdir=@srcdir@ -VPATH=.:$(srcdir) +VPATH=.:$(srcdir):$(srcdir)/tests MACHINE=PCLINUX @@ -19,6 +39,7 @@ EXPORT_PYSCRIPTS = \ EXPORT_HEADERS = \ +MEDMEM_PointerOf.hxx \ MEDMEM_CellModel.hxx \ MEDMEM_Connectivity.hxx \ MEDMEM_Coordinate.hxx \ @@ -34,13 +55,16 @@ MEDMEM_MedFieldDriver.hxx \ MEDMEM_Med.hxx \ MEDMEM_MedMedDriver.hxx \ MEDMEM_MedMeshDriver.hxx \ +MEDMEM_GibiMeshDriver.hxx \ MEDMEM_ModulusArray.hxx \ MEDMEM_SkyLineArray.hxx \ MEDMEM_VtkMedDriver.hxx \ MEDMEM_Mesh.hxx \ +MEDMEM_Meshing.hxx \ MEDMEM_STRING.hxx \ MEDMEM_Support.hxx \ -MEDMEM_Unit.hxx +MEDMEM_Unit.hxx \ +MEDMEM_Grid.hxx # Libraries targets @@ -59,30 +83,33 @@ MEDMEM_Med.cxx \ MEDMEM_Exception.cxx \ MEDMEM_MedMedDriver.cxx \ MEDMEM_MedMeshDriver.cxx \ +MEDMEM_GibiMeshDriver.cxx \ MEDMEM_SkyLineArray.cxx \ MEDMEM_Mesh.cxx \ +MEDMEM_Meshing.cxx \ MEDMEM_Support.cxx \ MEDMEM_Unit.cxx \ - -#VtkMedDriver.cxx \ +MEDMEM_VtkMedDriver.cxx \ +MEDMEM_Grid.cxx # Executables targets -BIN = duplicateMED med_test duplicateMEDMESH +BIN = med2vtk duplicateMED med_test duplicateMEDMESH BIN_SRC = BIN_SERVER_IDL = BIN_CLIENT_IDL = -TEST_PROGS = test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray test_MEDMEM_CellModel +TEST_PROGS = test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray test_MEDMEM_CellModel testUPointerOf testUCoordinate testUUnit testUGeoNameMeshEntities testUMedException testUModulusArray testUSkyLineArray testUArray testUCellModel readEntete readCoordinate test_copie_field_ test_copie_fieldT test_copie_coordinate test_copie_medarray test_copie_connectivity test_copie_support test_copie_family test_copie_group test_copie_mesh test_affect_medarray test_MEDMEM_Meshing + +# testUCellModel -> a revoir car l'API a changee (plus de vector) -CPPFLAGS+=$(MED2_INCLUDES) $(HDF5_INCLUDES) -CXXFLAGS+=-ftemplate-depth-42 -LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lSalomeLoggerServer +CPPFLAGS+=$(MED2_INCLUDES) $(HDF5_INCLUDES) -I$(inc_builddir) -I$(srcdir) -I. +LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -L$(top_builddir)/lib -lstdc++ -lSalomeLoggerServer # build create_mesh : -bin: create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_mesh_c3h8q4_wrong create_mesh_c2q4s2_wrong +bin: create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_mesh_c3h8q4_wrong create_mesh_c2q4s2_wrong create_grid -create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4: %: %.c +create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_grid: %: %.c $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(MED2_LIBS) $(HDF5_LIBS) $(LDFLAGS) $< @CONCLUDE@ diff --git a/src/MEDMEM/create_grid.c b/src/MEDMEM/create_grid.c new file mode 100644 index 000000000..dd2cc7291 --- /dev/null +++ b/src/MEDMEM/create_grid.c @@ -0,0 +1,347 @@ +/*---------------------------------------------------------------------------- +MED MEDMEM : MED files in memory + + Copyright (C) 2003 CEA/DEN, EDF R&D + + + + File : create_grid.c +Module : MED +----------------------------------------------------------------------------*/ + +/****************************************************************************** + * - Nom du fichier : test19.c + * + * - Description : ecriture des objets MED relatifs aux grilles + * MED V2.0 + * + *****************************************************************************/ + +#include +#include + +/****************************************************************************** + * - creation d'un fichier MED + * - ecriture des noeuds : coordonnees en mode MED_FULL_INTERLACE, + * noms,numeros,numeros de familles + * - ecriture des familles d'un maillage MED + * 2.0 via les routines de bas niveau + * - fermeture du fichier + *****************************************************************************/ + +int main (int argc, char **argv) +{ + +/* Ecriture d'un premier maillage non structure (test14 + test8) + ************************************************************* */ + + med_err ret; + med_idt fid; + /* la dimension du maillage */ + med_int mdim = 2; + /* nom du maillage de longueur maxi MED_TAILLE_NOM */ + char maa[MED_TAILLE_NOM+1] = "maa1"; + /* le nombre de noeuds */ + med_int nnoe = 4; + /* table des coordonnees + profil : (dimension * nombre de noeuds) */ + med_float coo[8] = {0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0}; + med_int nbr[2] = {2, 2}; + /* tables des noms et des unites des coordonnees + profil : (dimension*MED_TAILLE_PNOM+1) */ + char nomcoo[2*MED_TAILLE_PNOM+1] = "x y "; + char unicoo[2*MED_TAILLE_PNOM+1] = "cm cm "; + /* tables des noms, numeros, numeros de familles des noeuds + autant d'elements que de noeuds - les noms ont pout longueur + MED_TAILLE_PNOM */ + char nomnoe[4*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4 "; + med_int numnoe[4] = {1,2,3,4}; + med_int nufano[4] = {0,1,2,2}; + char nomfam[MED_TAILLE_NOM+1]; + med_int numfam; + char attdes[MED_TAILLE_DESC+1]; + med_int natt; + med_int attide; + med_int attval; + med_int ngro; + char gro[MED_TAILLE_LNOM+1]; + int i; + int nfame = 1; + int nfamn = 2; + med_int fam[16]; + /* + les elements: + */ + med_int nquad4 = 1; + med_int quad4[4] = { + 1, 2, 4, 3 + }; + char nomquad4[MED_TAILLE_PNOM*1+1] = "quad1 "; + med_int numquad4[1] = {1}; + med_int nufaquad4[1] = {-1}; + + fid = MEDouvrir("test19.med",MED_REMP); + if (fid < 0) + ret = -1; + else + ret = 0; + printf("%d\n",ret); + + /* creation du maillage maa de dimension 2 */ + if (ret == 0) + ret = MEDmaaCr(fid,maa,mdim); + printf("%d\n",ret); + + /* ecriture des noeuds d'un maillage MED : + - des coo en mode MED_FULL_INTERLACE : (X1,Y1,X2,Y2,X3,Y3,...) + dans un repere cartesien + - des noms (optionnel dans un fichier MED) + - des numeros (optionnel dans un fichier MED) + - des numeros de familles des noeuds */ + if (ret == 0) + ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART, + nomcoo,unicoo,nomnoe,MED_VRAI,numnoe,MED_VRAI, + nufano,nnoe,MED_ECRI); + printf("%d\n",ret); + + /* ecriture des mailles MED_QUAD4 : + - connectivite + - noms (optionnel) + - numeros (optionnel) + - numeros des familles */ + if (ret == 0) + ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE, + nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4, + MED_MAILLE,MED_QUAD4,MED_NOD,MED_ECRI); + printf("%d \n",ret); + + /* ecriture des familles */ + /* Conventions : + - toujours creer une famille de numero 0 ne comportant aucun attribut + ni groupe (famille de reference pour les noeuds ou les elements + qui ne sont rattaches a aucun groupe ni attribut) + - les numeros de familles de noeuds sont > 0 + - les numeros de familles des elements sont < 0 + - rien d'imposer sur les noms de familles + */ + + /* la famille 0 */ + if (ret == 0) + { + strcpy(nomfam,"FAMILLE_0"); + numfam = 0; + ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0, + gro,0); + } + printf("%d \n",ret); + + /* on cree pour correspondre aux cas tests precedents, 3 familles + d'elements (-1,-2,-3) et deux familles de noeuds (1,2) */ + if (ret == 0) + { + nfame = 1; + for (i=0;i #include @@ -112,12 +140,19 @@ int main (int argc, char **argv) med_float fieldnodedouble1[19] = {1.,1.,1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.}; med_float fieldnodedouble2[19] = {1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.,7.,7.}; - char champ3[MED_TAILLE_NOM+1]="fieldcelldouble" ; + char champ3[MED_TAILLE_NOM+1]="fieldcelldoublevector" ; char champ3_comp[MED_TAILLE_PNOM*3+1]="comp1 comp2 comp3 " ; - char champ3_unit[MED_TAILLE_PNOM*3+1]="M/S M/s m/s " ; - med_float fieldcelldouble1[12*3] = {1,1,1,2,2,2,3,3,3,4,4,4,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0}; - med_float fieldcelldouble2[2*3] = {5,5,0,1,0,1}; - med_float fieldcelldouble3[2*3] = {6,6,1,0,1,0}; + char champ3_unit[MED_TAILLE_PNOM*3+1]="m/s m/s m/s " ; + med_float fieldcelldouble1[12*3] = {1.,1.,1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,0.,0.,0.,1.,1.,1.,0.,0.,0.,1.,1.,1.,1.,1.,1.,0.,0.,0.,1.,1.,1.,0.,0.,0.}; + med_float fieldcelldouble2[2*3] = {5.,5.,0.,1.,0.,1.}; + med_float fieldcelldouble3[2*3] = {6.,6.,1.,0.,1.,0.}; + + char champ4[MED_TAILLE_NOM+1]="fieldcelldoublescalar" ; + char champ4_comp[MED_TAILLE_PNOM+1]="comp1 " ; + char champ4_unit[MED_TAILLE_PNOM+1]="m/s " ; + med_float fieldcelldouble4[12] = {1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.}; + med_float fieldcelldouble5[2] = {2.,2.}; + med_float fieldcelldouble6[2] = {3.,3.}; /***************************************************************************/ fid = MEDouvrir("pointe.med",MED_REMP); @@ -346,16 +381,39 @@ int main (int argc, char **argv) MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE, MED_TETRA4, MED_NOPDT," ", 0., MED_NONOR); printf("MEDchampEcr : %d \n",ret); + ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble3, + MED_NO_INTERLACE, nhexa8, + MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE, + MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR); + printf("MEDchampEcr : %d \n",ret); ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble2, MED_NO_INTERLACE, npyra5, MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE, MED_PYRA5, MED_NOPDT," ", 0., MED_NONOR); printf("MEDchampEcr : %d \n",ret); - ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble3, + } + } + + if (ret == 0) + { + ret = MEDchampCr(fid,champ4,MED_REEL64,champ4_comp,champ4_unit,1); + printf("MEDchampCr : %d \n",ret); + if (ret == 0) { + ret = MEDchampEcr(fid, maa, champ4, (unsigned char *)fieldcelldouble4, + MED_NO_INTERLACE, ntet4, + MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE, + MED_TETRA4, MED_NOPDT," ", 0., MED_NONOR); + printf("MEDchampEcr : %d \n",ret); + ret = MEDchampEcr(fid, maa, champ4, (unsigned char *)fieldcelldouble6, MED_NO_INTERLACE, nhexa8, MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE, MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR); printf("MEDchampEcr : %d \n",ret); + ret = MEDchampEcr(fid, maa, champ4, (unsigned char *)fieldcelldouble5, + MED_NO_INTERLACE, npyra5, + MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE, + MED_PYRA5, MED_NOPDT," ", 0., MED_NONOR); + printf("MEDchampEcr : %d \n",ret); } } diff --git a/src/MEDMEM/create_mesh_c2q4s2.c b/src/MEDMEM/create_mesh_c2q4s2.c index 3896ae7e2..ceb89f4bb 100644 --- a/src/MEDMEM/create_mesh_c2q4s2.c +++ b/src/MEDMEM/create_mesh_c2q4s2.c @@ -1,3 +1,31 @@ +/*---------------------------------------------------------------------------- +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 : create_mesh_c2q4s2.c +Module : MED +----------------------------------------------------------------------------*/ + /* creation d'une geometrie 2d : un cube [0,1]^2 maillé uniformement en quadrangle reguliers; diff --git a/src/MEDMEM/create_mesh_c2q4s2_wrong.c b/src/MEDMEM/create_mesh_c2q4s2_wrong.c index a4d020de7..07dcf2a01 100644 --- a/src/MEDMEM/create_mesh_c2q4s2_wrong.c +++ b/src/MEDMEM/create_mesh_c2q4s2_wrong.c @@ -1,3 +1,31 @@ +/*---------------------------------------------------------------------------- +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 : create_mesh_c2q4s2_wrong.c +Module : MED +----------------------------------------------------------------------------*/ + /* creation d'une geometrie 2d : un cube [0,1]^2 maillé uniformement en quadrangle reguliers; diff --git a/src/MEDMEM/create_mesh_c3h8q4.c b/src/MEDMEM/create_mesh_c3h8q4.c index 19c3675c4..afc5a0a8a 100644 --- a/src/MEDMEM/create_mesh_c3h8q4.c +++ b/src/MEDMEM/create_mesh_c3h8q4.c @@ -1,3 +1,31 @@ +/*---------------------------------------------------------------------------- +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 : create_mesh_c3h8q4.c +Module : MED +----------------------------------------------------------------------------*/ + /* creation d'une geometrie 3d : un cube [0,1]^3 maillé uniformement en hexahedres reguliers; diff --git a/src/MEDMEM/create_mesh_c3h8q4_wrong.c b/src/MEDMEM/create_mesh_c3h8q4_wrong.c index 77db282f1..9e2404543 100644 --- a/src/MEDMEM/create_mesh_c3h8q4_wrong.c +++ b/src/MEDMEM/create_mesh_c3h8q4_wrong.c @@ -1,3 +1,31 @@ +/*---------------------------------------------------------------------------- +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 : create_mesh_c3h8q4_wrong.c +Module : MED +----------------------------------------------------------------------------*/ + /* creation d'une geometrie 3d : un cube [0,1]^3 maillé uniformement en hexahedres reguliers; diff --git a/src/MEDMEM/duplicateMED.cxx b/src/MEDMEM/duplicateMED.cxx index c115b6c15..ccbb810af 100644 --- a/src/MEDMEM/duplicateMED.cxx +++ b/src/MEDMEM/duplicateMED.cxx @@ -1,20 +1,34 @@ +// 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 : duplicateMED.cxx +// Module : MED + +using namespace std; #include -#include #include "MEDMEM_Exception.hxx" -#include "MEDMEM_define.hxx" - #include "MEDMEM_Med.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" - -#include "MEDMEM_GenDriver.hxx" -#include "MEDMEM_MedMedDriver.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" - void usage(char * name) { @@ -26,107 +40,23 @@ void usage(char * name) int main (int argc, char ** argv) { if (argc != 3) usage(argv[0]); - + string filenameIN = argv[1] ; string filenameOUT = argv[2] ; - MED * myMed = new MED() ; - MED_MED_DRIVER myMedDriver(filenameIN,myMed) ; - - // we read all meshes and fields in filenameIN try { - int read ; - myMedDriver.open(); - myMedDriver.readFileStruct(); - myMedDriver.close(); - - // read all mesh - MESSAGE("Read all meshes :") ; - int NumberOfMeshes = myMed->getNumberOfMeshes() ; - MESSAGE("Number of meshes : "< MeshName = myMed->getMeshNames() ; - map _meshes ; - for (int i=0; igetMesh(MeshName[i]) ; - _meshes[MeshName[i]]->read(); - MESSAGE(" - Mesh "<updateSupport() ; - - // read all field - MESSAGE("Read all fields :") ; - int NumberOfFields = myMed->getNumberOfFields() ; - MESSAGE("Number of fields : "< FieldName = myMed->getFieldNames() ; - map _fields ; - for (int i=0; i FieldIteration = myMed->getFieldIteration(FieldName[i]) ; - MESSAGE(" - Field "<getField(FieldName[i],FieldIteration[j].dt,FieldIteration[j].it) ; - - med_type_champ type = myField->getValueType() ; - switch (type) { - case MED_FR::MED_INT32: { - // if (type == MED_FR::MED_INT32) { - MESSAGE(" * Field named "<<((FIELD*)myField)->getName()); - ((FIELD*)myField)->read() ; - MESSAGE(" * Iteration "< myFieldDriver(filenameOUT,(FIELD*)myField); - myFieldDriver.setFieldName(FieldName[i]); - myFieldDriver.open() ; - myFieldDriver.write() ; - myFieldDriver.close() ; - break ; - } - // else - case MED_FR::MED_REEL64: { - // if (type == MED_FR::MED_REEL64) { - FIELD* myField2 = (FIELD*)myField ; - MESSAGE(" * Field named "<getName()); - myField2->read() ; - MESSAGE(" * Iteration "< myFieldDriver(filenameOUT,myField2); - myFieldDriver.setFieldName(FieldName[i]); - myFieldDriver.open() ; - myFieldDriver.write() ; - myFieldDriver.close() ; - break ; - } - // else { - default: { - MESSAGE(" * Iteration "< #include @@ -19,7 +46,7 @@ int main (int argc, char ** argv) { string filenameOUT = argv[2] ; MED * myMed = new MED() ; - MED_MED_DRIVER myMedDriver(filenameIN,myMed) ; + MED_MED_RDONLY_DRIVER myMedDriver(filenameIN,myMed) ; // we read all meshes in filenameIN try { diff --git a/src/MEDMEM/med2vtk.cxx b/src/MEDMEM/med2vtk.cxx new file mode 100644 index 000000000..877459412 --- /dev/null +++ b/src/MEDMEM/med2vtk.cxx @@ -0,0 +1,93 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : med2vtk.cxx +// Module : MED + +using namespace std; +#include +#include + +#include "MEDMEM_Exception.hxx" +#include "MEDMEM_define.hxx" + +#include "MEDMEM_Med.hxx" +#include "MEDMEM_Mesh.hxx" +#include "MEDMEM_Family.hxx" +#include "MEDMEM_Support.hxx" +#include "MEDMEM_Field.hxx" +#include "MEDMEM_VtkMedDriver.hxx" + +void usage(char * name) +{ + cout << " " << name << " " < MeshName = myMed.getMeshNames() ; + for (int i=0; iread() ; + cout << " - Mesh "< FieldName = myMed.getFieldNames() ; + for (int i=0; i FieldIteration = myMed.getFieldIteration(FieldName[i]) ; + cout << " - Field "<read() ; + cout << " * Iteration "< #include @@ -21,59 +48,59 @@ double dmin(double x, double y) { return (x>y)?y:x;} double infty = 1.e20; -void affiche_support(SUPPORT * mySupport) +void affiche_support(const SUPPORT * mySupport) { - MESSAGE( " - Name : "<getName().c_str()); - MESSAGE( " - Description : "<getDescription().c_str()); - MESSAGE( " - Entity : "<getEntity()); - MESSAGE( " - Entities list : "); + cout << " - Name : "<getName().c_str()<getDescription().c_str()<getEntity()<isOnAllElements())) { int NumberOfTypes = mySupport->getNumberOfTypes() ; - MESSAGE(" - NumberOfTypes : "<getTypes() ; + cout<<" - NumberOfTypes : "<getTypes() ; for (int j=0;jgetNumberOfElements(Types[j]) ; - int * Number = mySupport->getNumber(Types[j]) ; + const int * Number = mySupport->getNumber(Types[j]) ; for (int k=0; kgetNumberOfFamilies(Entity) ; - MESSAGE( "NumberOfFamilies : "<getFamily(Entity,i); + const FAMILY* myFamily = myMesh->getFamily(Entity,i); affiche_support(myFamily); - MESSAGE( " - Identifier : "<getIdentifier()); + cout << " - Identifier : "<getIdentifier()<getNumberOfAttributes() ; - MESSAGE( " - Attributes ("<getAttributeIdentifier(j)<<" : "<getAttributeValue(j)<<", "<getAttributeDescription(j).c_str()); + cout << " * "<getAttributeIdentifier(j)<<" : "<getAttributeValue(j)<<", "<getAttributeDescription(j).c_str()<getNumberOfGroups() ; - MESSAGE( " - Groups ("<getGroupName(j).c_str()); + cout << " * "<getGroupName(j).c_str()<getNumberOfGroups(Entity) ; - MESSAGE( "NumberOfGroups : "<getGroup(Entity,i); + const GROUP* myGroup = myMesh->getGroup(Entity,i); affiche_support(myGroup); int NumberOfFamillies = myGroup->getNumberOfFamilies() ; - MESSAGE( " - Families ("<getFamily(j)->getName().c_str()); + cout << " * "<getFamily(j)->getName().c_str()<getMeshDimension() ; int NumberOfNodes = myMesh->getNumberOfNodes() ; - MESSAGE( "Space Dimension : " << SpaceDimension << endl ); + cout << "Space Dimension : " << SpaceDimension << endl << endl ; - MESSAGE( "Mesh Dimension : " << MeshDimension << endl ); + cout << "Mesh Dimension : " << MeshDimension << endl << endl ; const double * Coordinates = myMesh->getCoordinates(MED_FULL_INTERLACE) ; - MESSAGE( "Show Nodes Coordinates : " ); + cout << "Show Nodes Coordinates : " << endl ; - MESSAGE( "Name :" ); - string * CoordinatesNames = myMesh->getCoordinatesNames() ; + cout << "Name :" << endl ; + const string * CoordinatesNames = myMesh->getCoordinatesNames() ; for(int i=0; igetCoordinatesUnits() ; + cout << "Unit :" << endl ; + const string * CoordinatesUnits = myMesh->getCoordinatesUnits() ; for(int i=0; igetNumberOfTypes(MED_CELL) ; - medGeometryElement * Types = myMesh->getTypes(MED_CELL) ; + const medGeometryElement * Types = myMesh->getTypes(MED_CELL) ; - MESSAGE( "Show Connectivity (Nodal) :" ); + cout << "Show Connectivity (Nodal) :" << endl ; for (int i=0; igetNumberOfElements(MED_CELL,Types[i]); - int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,Types[i]); + const int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,Types[i]); int NomberOfNodesPerCell = Types[i]%100 ; for (int j=0;jgetReverseConnectivity(MED_NODAL) ; - int * ReverseNodalConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_NODAL) ; + cout << "Show Reverse Nodal Connectivity :" << endl ; + const int * ReverseNodalConnectivity = myMesh->getReverseConnectivity(MED_NODAL) ; + const int * ReverseNodalConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_NODAL) ; for (int i=0; icalculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL); try { NumberOfElements = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); @@ -182,19 +209,19 @@ int main (int argc, char ** argv) { connectivity_index = myMesh->getConnectivityIndex(MED_DESCENDING,MED_CELL); } catch (MEDEXCEPTION m) { - MESSAGE( m.what() ); + cout << m.what() << endl ; exit (-1) ; } for (int j=0;jgetReverseConnectivity(MED_DESCENDING) ; - int * ReverseDescendingConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_DESCENDING) ; + cout << "Show Reverse Descending Connectivity :" << endl ; + const int * ReverseDescendingConnectivity = myMesh->getReverseConnectivity(MED_DESCENDING) ; + const int * ReverseDescendingConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_DESCENDING) ; int NumberOfConstituents = 0; string constituent ; @@ -211,44 +238,44 @@ int main (int argc, char ** argv) { } if (MeshDimension==1) { - MESSAGE("ERROR : MeshDimension = 1 !"); - MESSAGE("We could not see Reverse Descending Connectivity.") ; + INFOS("ERROR : MeshDimension = 1 !"); + INFOS("We could not see Reverse Descending Connectivity.") ; } else { NumberOfConstituents = myMesh->getNumberOfElements (constituentEntity,MED_ALL_ELEMENTS); for (int i=0; igetConnectivity(MED_FULL_INTERLACE,MED_NODAL,constituentEntity,MED_ALL_ELEMENTS); - int * face_connectivity_index = myMesh->getConnectivityIndex(MED_NODAL,constituentEntity); + cout << "Show "<getConnectivity(MED_FULL_INTERLACE,MED_NODAL,constituentEntity,MED_ALL_ELEMENTS); + const int * face_connectivity_index = myMesh->getConnectivityIndex(MED_NODAL,constituentEntity); for (int i=0; i* normal = new FIELD::FIELD(); - FIELD* length = new FIELD::FIELD(); - normal = NULL; - length = NULL; + //FIELD* normal = new FIELD::FIELD(); + //FIELD* length = new FIELD::FIELD(); + //normal = NULL; + //length = NULL; string support_name = "Support on all " ; support_name+=constituent; support1 = new SUPPORT(myMesh,support_name,constituentEntity); - MESSAGE( "Building of the Support on all cells dimensionned (Meshdim-1) of the mesh :"); - MESSAGE( "Face in 3D or Edge in 2D" ); + cout << "Building of the Support on all cells dimensionned (Meshdim-1) of the mesh :"<< endl ; + cout << "Face in 3D or Edge in 2D" << endl; - MESSAGE( "Getting the normal of each face of this support !" ); + cout << "Getting the normal of each face of this support !" << endl ; - normal = myMesh->getNormal(support1); + FIELD* normal = myMesh->getNormal(support1); double normal_square, norm ; double maxnorm=-infty; @@ -256,25 +283,26 @@ int main (int argc, char ** argv) { double tmp_value ; for (int i = 1; i<=NumberOfConstituents;i++) { normal_square = 0. ; - MESSAGE( "Normal " << i << " " ); + cout << "Normal " << i << " " ; for (int j=1; j<=SpaceDimension; j++) { tmp_value = normal->getValueIJ(i,j) ; normal_square += tmp_value*tmp_value ; - MESSAGE( tmp_value << " " ); + cout << tmp_value << " " ; } norm = sqrt(normal_square); maxnorm = dmax(maxnorm,norm); minnorm = dmin(minnorm,norm); - MESSAGE( ", Norm = " << norm ); + cout << ", Norm = " << norm << endl; } - MESSAGE( "Max Norm " << maxnorm << " Min Norm " << minnorm ); + cout << "Max Norm " << maxnorm << " Min Norm " << minnorm << endl; + delete normal ; if (SpaceDimension == 2) { - MESSAGE( "Getting the length of each edge !" ); + cout << "Getting the length of each edge !" << endl ; - length = myMesh->getLength(support1); + FIELD* length = myMesh->getLength(support1); double length_value,maxlength,minlength; maxlength = -infty; @@ -282,42 +310,48 @@ int main (int argc, char ** argv) { for (int i = 1; i<=NumberOfConstituents;i++) { length_value = length->getValueIJ(i,1) ; - MESSAGE( "Length " << i << " " << length_value ); + cout << "Length " << i << " " << length_value << endl; maxlength = dmax(maxlength,length_value); minlength = dmin(minlength,length_value); } - MESSAGE( "Max Length " << maxlength << " Min Length " << minlength ); + cout << "Max Length " << maxlength << " Min Length " << minlength << endl; + + delete length ; } - MESSAGE( "Building of the Support on all space-dimensionned cells of the mesh :"); + delete support1 ; + + cout << "Building of the Support on all space-dimensionned cells of the mesh :"<< endl ; SUPPORT * support = new SUPPORT(myMesh); - MESSAGE( "Getting the barycenter of each element of this support !" ); + cout << "Getting the barycenter of each element of this support !" << endl ; - FIELD* barycenter = new FIELD::FIELD(); + //FIELD* barycenter = new FIELD::FIELD(); - barycenter = myMesh->getBarycenter(support); + FIELD* barycenter = myMesh->getBarycenter(support); NumberOfElements = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); for (int i = 1; i<=NumberOfElements;i++) { if (SpaceDimension == 3) - MESSAGE( "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) << " " << barycenter->getValueIJ(i,3) ); + cout << "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) << " " << barycenter->getValueIJ(i,3) << endl; if (SpaceDimension == 2) - MESSAGE( "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) ); + cout << "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) << endl; } - FIELD* volume = new FIELD::FIELD(); - FIELD* area = new FIELD::FIELD(); - volume = NULL; - area = NULL; + delete barycenter ; + + //FIELD* volume = new FIELD::FIELD(); + //FIELD* area = new FIELD::FIELD(); + //volume = NULL; + //area = NULL; if (SpaceDimension == 3) { - MESSAGE( "Getting the Volume of each element of this support which is a 3D one !" ); + cout << "Getting the Volume of each element of this support which is a 3D one !" << endl; - volume = myMesh->getVolume(support); + FIELD* volume = myMesh->getVolume(support); double maxvol,minvol,voltot; maxvol = -infty; @@ -325,22 +359,24 @@ int main (int argc, char ** argv) { voltot = 0.0; for (int i = 1; i<=NumberOfElements;i++) { - MESSAGE( "Volume " << i << " " << volume->getValueIJ(i,1) ); + cout << "Volume " << i << " " << volume->getValueIJ(i,1) << endl; maxvol = dmax(maxvol,volume->getValueIJ(i,1)); minvol = dmin(minvol,volume->getValueIJ(i,1)); voltot = voltot + volume->getValueIJ(i,1); } - MESSAGE( "Max Volume " << maxvol << " Min Volume " << minvol ); - MESSAGE( "Support Volume " << voltot ); + cout << "Max Volume " << maxvol << " Min Volume " << minvol << endl; + cout << "Support Volume " << voltot << endl; + + delete volume ; } else if (SpaceDimension == 2) { - MESSAGE( "Getting the Area of each element of this support which is a 2D one !" ); + cout << "Getting the Area of each element of this support which is a 2D one !" << endl; - area = myMesh->getArea(support); + FIELD* area = myMesh->getArea(support); - // MESSAGE( "nb of comp "<< area->getNumberOfComponents() << " length " << area->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS) ); + // cout << "nb of comp "<< area->getNumberOfComponents() << " length " << area->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS) << endl; double maxarea,minarea,areatot; maxarea = -infty; @@ -348,19 +384,23 @@ int main (int argc, char ** argv) { areatot = 0.0; for (int i = 1; i<=NumberOfElements;i++) { - MESSAGE( "Area " << i << " " << area->getValueIJ(i,1) ); + cout << "Area " << i << " " << area->getValueIJ(i,1) << endl; maxarea = dmax(maxarea,area->getValueIJ(i,1)); minarea = dmin(minarea,area->getValueIJ(i,1)); areatot = areatot + area->getValueIJ(i,1); } - MESSAGE( "Max Area " << maxarea << " Min Area " << minarea ); - MESSAGE( "Support Area " << areatot ); + cout << "Max Area " << maxarea << " Min Area " << minarea << endl; + cout << "Support Area " << areatot << endl; + + delete area ; } - if (barycenter != NULL) delete barycenter; - if (volume != NULL ) delete volume; - if (area != NULL ) delete area; + delete support ; + + //if (barycenter != NULL) delete barycenter; + //if (volume != NULL ) delete volume; + //if (area != NULL ) delete area; if (argc < 4) return 0; @@ -398,35 +438,42 @@ int main (int argc, char ** argv) { myFieldDriver.close() ; - MESSAGE( "Field "<< myField->getName() << " : " <getDescription() ); + cout << "Field "<< myField->getName() << " : " <getDescription() << endl ; int NumberOfComponents = myField->getNumberOfComponents() ; - MESSAGE( "- Nombre de composantes : "<< NumberOfComponents ); + cout << "- Nombre de composantes : "<< NumberOfComponents << endl ; for (int i=1; igetComponentName(i)); - MESSAGE( " - description : "<getComponentDescription(i) ); - MESSAGE( " - units : "<getMEDComponentUnit(i) ); + cout << " - composante "<getComponentName(i)<< endl; + cout << " - description : "<getComponentDescription(i) << endl; + cout << " - units : "<getMEDComponentUnit(i) << endl; } - MESSAGE( "- iteration :" ); - MESSAGE( " - numero : " << myField->getIterationNumber()); - MESSAGE( " - ordre : " << myField->getOrderNumber()); - MESSAGE( " - temps : " << myField->getTime()); + cout << "- iteration :" << endl ; + cout << " - numero : " << myField->getIterationNumber()<< endl ; + cout << " - ordre : " << myField->getOrderNumber()<< endl ; + cout << " - temps : " << myField->getTime()<< endl ; - MESSAGE( "- Valeurs :"); + cout << "- Valeurs :"<getNumberOfElements(MED_ALL_ELEMENTS); // for (int i=1; igetValueI(MED_NO_INTERLACE,i) ; // for (int j=0; j * myvalue = myField->getvalue(); + const double * value ; for (int i=1; igetValueI(MED_FULL_INTERLACE,i) ; + value = myvalue->getRow(i) ; for (int j=0; j * myArray = new MEDARRAY(SpaceDimension,NumberOfNodes,MED_FULL_INTERLACE) ; - int * value = myArray->get(MED_FULL_INTERLACE) ; - for (int i=0; iget(MED_FULL_INTERLACE) ; + for (int i=1; i<=NumberOfNodes; i++) + for (int j=1; j<=SpaceDimension; j++) + myArray->setIJ(i,j,i) ; int numberof ; MESSAGE("Show all 1 :"); numberof = myArray->getLeadingValue() ; for (int i=1; i<=myArray->getLengthValue() ; i++) { - int * node = myArray->getI(MED_FULL_INTERLACE,i) ; - MESSAGE( " - " ); + //int * node = myArray->getI(MED_FULL_INTERLACE,i) ; + const int * node = myArray->getRow(i) ; + cout << " - " ; for (int j=0;jgetLengthValue() ; for (int i=1; i<=myArray->getLeadingValue() ; i++) { - int * node = myArray->getI(MED_NO_INTERLACE,i) ; - MESSAGE( " - " ); + //int * node = myArray->getJ(MED_NO_INTERLACE,i) ; + const int * node = myArray->getColumn(i) ; + cout << " - " ; for (int j=0;jgetLeadingValue() ; for (int i=1; i<=myArray->getLengthValue() ; i++) { - MESSAGE( " - " ); + cout << " - " ; for (int j=1;jgetIJ(i,j) << " " ); - MESSAGE(""); + cout << myArray->getIJ(i,j) << " " ; + cout << endl ; } MESSAGE("Show all 0 :"); numberof = myArray->getLeadingValue() ; int length = myArray->getLengthValue() ; - int * NoInterlaceArray = myArray->get(MED_NO_INTERLACE) ; + const int * NoInterlaceArray = myArray->get(MED_NO_INTERLACE) ; for (int i=0; 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; @@ -25,37 +51,42 @@ int main (int argc, char ** argv) { value[9]=6; // value[]=; // forth - MESSAGE( "Show all 1 :" ); + 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) ; - MESSAGE( " - " ); + cout << " - " ; for (int j=0;jgetNumberOfI(i) ; for (int j=1;jgetIJ(i,j) << " " ); - MESSAGE(""); + cout << myArray->getIJ(i,j) << " " ; + cout << endl ; } MEDSKYLINEARRAY * myArray2 = new MEDSKYLINEARRAY(*myArray) ; delete myArray ; - MESSAGE( "Show all 3 :" ); - for (int i=1; igetI(i) ; - int numberof = myArray2->getNumberOfI(i) ; - MESSAGE( " - " ); - for (int j=0;jgetIndex() ; + for (int i=1; i<=NumberOfCell ; i++) { + cout << " - " ; + for (int j=index2[i-1];jgetIndexValue(j) << " " ; + cout << endl ; } + delete myArray2 ; + delete[] index ; + delete[] value ; + return 0 ; } diff --git a/src/MEDMEM/test_affect_medarray.cxx b/src/MEDMEM/test_affect_medarray.cxx index b5043f1bb..cc9a79485 100644 --- a/src/MEDMEM/test_affect_medarray.cxx +++ b/src/MEDMEM/test_affect_medarray.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 : test_affect_medarray.cxx +// Module : MED + using namespace std; /* Programme de test du constructeur de copies de la classe MEDARRAY de MEDMEM jroy - 16/12/2002 */ @@ -25,7 +51,7 @@ void affiche_medarray(MEDARRAY & myMedArray) MESSAGE("Show all 1 :"); numberof = myMedArray.getLeadingValue() ; for (int i=1; i<=myMedArray.getLengthValue() ; i++) { - double * node = myMedArray.getI(MED_FULL_INTERLACE,i) ; + const double * node = myMedArray.getRow(i) ; cout << " - " ; for (int j=0;j & myMedArray) MESSAGE("Show all 2 :"); numberof = myMedArray.getLengthValue() ; for (int i=1; i<=myMedArray.getLeadingValue() ; i++) { - double * node = myMedArray.getI(MED_NO_INTERLACE,i) ; + const double * node = myMedArray.getColumn(i) ; cout << " - " ; for (int j=0;j & myMedArray) MESSAGE("Show all 0 :"); numberof = myMedArray.getLeadingValue() ; int length = myMedArray.getLengthValue() ; - double * NoInterlaceArray = myMedArray.get(MED_NO_INTERLACE) ; + const double * NoInterlaceArray = myMedArray.get(MED_NO_INTERLACE) ; for (int i=0; i * myMedArray2 = new MEDARRAY(); * myMedArray2 = * myMedArray; - delete myMedArray; + // delete myMedArray; // si on recopie les tableaux affiche_medarray(* myMedArray2); + delete myMedArray; // si on ne recopie pas les tableaux delete myMedArray2; return 0; diff --git a/src/MEDMEM/test_copie_connectivity.cxx b/src/MEDMEM/test_copie_connectivity.cxx index 4b94dcb17..b3442471a 100644 --- a/src/MEDMEM/test_copie_connectivity.cxx +++ b/src/MEDMEM/test_copie_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 : test_copie_connectivity.cxx +// Module : MED + using namespace std; /* Programme de test du constructeur de copies de la classe CONNECTIVITY de MEDMEM jroy - 19/12/2002 */ @@ -18,20 +44,20 @@ using namespace std; #include "MEDMEM_Field.hxx" #include "MEDMEM_define.hxx" -void affiche_connectivity(CONNECTIVITY * myConnectivity, MESH * myMesh) +void affiche_connectivity(const CONNECTIVITY * myConnectivity, MESH * myMesh) { int SpaceDimension = myMesh->getSpaceDimension() ; int MeshDimension = myMesh->getMeshDimension() ; int NumberOfNodes = myMesh->getNumberOfNodes() ; - int NumberOfTypes = myMesh->getNumberOfTypes(MED_CELL) ; - medGeometryElement * Types = myMesh->getTypes(MED_CELL) ; + int NumberOfTypes = myMesh->getNumberOfTypes(MED_CELL) ; + const medGeometryElement * Types = myMesh->getTypes(MED_CELL) ; cout << "Show Connectivity (Nodal) :" << endl ; for (int i=0; igetNumberOfElements(MED_CELL,Types[i]); - int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,Types[i]); + const int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,Types[i]); int NomberOfNodesPerCell = Types[i]%100 ; for (int j=0;jgetReverseConnectivity(MED_NODAL) ; - int * ReverseNodalConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_NODAL) ; + const int * ReverseNodalConnectivity = myMesh->getReverseConnectivity(MED_NODAL) ; + const int * ReverseNodalConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_NODAL) ; for (int i=0; icalculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL); try { NumberOfElements = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); @@ -73,8 +99,8 @@ void affiche_connectivity(CONNECTIVITY * myConnectivity, MESH * myMesh) } cout << "Show Reverse Descending Connectivity :" << endl ; - int * ReverseDescendingConnectivity = myMesh->getReverseConnectivity(MED_DESCENDING) ; - int * ReverseDescendingConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_DESCENDING) ; + const int * ReverseDescendingConnectivity = myMesh->getReverseConnectivity(MED_DESCENDING) ; + const int * ReverseDescendingConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_DESCENDING) ; int NumberOfConstituents = 0; string constituent ; @@ -103,8 +129,8 @@ void affiche_connectivity(CONNECTIVITY * myConnectivity, MESH * myMesh) } } cout << "Show "<getConnectivity(MED_FULL_INTERLACE,MED_NODAL,constituentEntity,MED_ALL_ELEMENTS); - int * face_connectivity_index = myMesh->getConnectivityIndex(MED_NODAL,constituentEntity); + const int * face_connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,constituentEntity,MED_ALL_ELEMENTS); + const int * face_connectivity_index = myMesh->getConnectivityIndex(MED_NODAL,constituentEntity); for (int i=0; igetConnectivityptr(); + const CONNECTIVITY * myConnectivity = myMesh->getConnectivityptr(); affiche_connectivity(myConnectivity, myMesh); + CONNECTIVITY * myConnectivity2 = new CONNECTIVITY(* myConnectivity); affiche_connectivity(myConnectivity2, myMesh); - delete myConnectivity;//myConnectivity utile pour afficher myConnectivity2 via myMesh! + + CONNECTIVITY * myConnectivity3 = new CONNECTIVITY(* myConnectivity2); + delete myConnectivity2; + affiche_connectivity(myConnectivity3, myMesh); + delete myConnectivity3; + + delete myMesh ; return 0; } diff --git a/src/MEDMEM/test_copie_coordinate.cxx b/src/MEDMEM/test_copie_coordinate.cxx index 56e2ea1e2..385b8ab0e 100644 --- a/src/MEDMEM/test_copie_coordinate.cxx +++ b/src/MEDMEM/test_copie_coordinate.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 : test_copie_coordinate.cxx +// Module : MED + using namespace std; /* Programme de test du constructeur de copies de la classe COORDINATE de MEDMEM jroy - 17/12/2002 */ @@ -101,10 +127,17 @@ int main (int argc, char ** argv) { // myCoordinate->setCoordinatesNames((string *)NULL); // myCoordinate->setNodesNumbers((int *) NULL); + delete myMedArray ; + delete[] myCoordinatesNames ; + delete[] myCoordinatesUnits ; + delete[] myNodeNumber ; + affiche_coordinate(* myCoordinate,numberofNodes,spaceDimension); COORDINATE * myCoordinate2 = new COORDINATE(* myCoordinate); - delete myCoordinate; + delete myCoordinate ; + affiche_coordinate(* myCoordinate2,numberofNodes,spaceDimension); + delete myCoordinate2 ; return 0; } diff --git a/src/MEDMEM/test_copie_family.cxx b/src/MEDMEM/test_copie_family.cxx index 047ef2c94..29fbcab8a 100644 --- a/src/MEDMEM/test_copie_family.cxx +++ b/src/MEDMEM/test_copie_family.cxx @@ -1,3 +1,29 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : test_copie_family.cxx +// Module : MED + using namespace std; #include @@ -16,7 +42,7 @@ using namespace std; #include "MEDMEM_define.hxx" -void affiche_support(SUPPORT * mySupport) +void affiche_support(const SUPPORT * mySupport) { cout << " - Name : "<getName().c_str()<getDescription().c_str()<isOnAllElements())) { int NumberOfTypes = mySupport->getNumberOfTypes() ; cout<<" - NumberOfTypes : "<getTypes() ; + const medGeometryElement * Types = mySupport->getTypes() ; for (int j=0;jgetNumberOfElements(Types[j]) ; - int * Number = mySupport->getNumber(Types[j]) ; + const int * Number = mySupport->getNumber(Types[j]) ; for (int k=0; kgetIdentifier()<getNumberOfGroups(Entity) ; cout << "NumberOfGroups : "<getGroup(Entity,i); + const GROUP* myGroup = myMesh->getGroup(Entity,i); affiche_support(myGroup); int NumberOfFamillies = myGroup->getNumberOfFamilies() ; cout << " - Families ("<getFamily(MED_NODE,1); + const FAMILY * myFamily = myMesh->getFamily(MED_NODE,1); //On renseigne les attributs spécifiques à FAMILY (p/r à SUPPORT) et non renseignés lors de la lecture du maillage - int NumberOfAttribute = 3; - int *AttributeIdentifier = new int[NumberOfAttribute]; - int *AttributeValue = new int[NumberOfAttribute]; - string *AttributeDescription = new string[NumberOfAttribute]; - char *tmp; - for (int i=0;isetNumberOfAttributes(NumberOfAttribute); - myFamily->setAttributesIdentifiers (AttributeIdentifier); - myFamily->setAttributesValues (AttributeValue); - myFamily->setAttributesDescriptions (AttributeDescription); +// int NumberOfAttribute = 3; +// int *AttributeIdentifier = new int[NumberOfAttribute]; +// int *AttributeValue = new int[NumberOfAttribute]; +// string *AttributeDescription = new string[NumberOfAttribute]; +// char *tmp; +// for (int i=0;isetNumberOfAttributes(NumberOfAttribute); +// myFamily->setAttributesIdentifiers (AttributeIdentifier); +// myFamily->setAttributesValues (AttributeValue); +// myFamily->setAttributesDescriptions (AttributeDescription); cout << "Show Family :"< * myField, const SUPPORT * mySupport) int NumberOfComponents = myField->getNumberOfComponents() ; for (int i=1; igetValueI(MED_FULL_INTERLACE,i) ; + const double * value = myField->getValueI(MED_FULL_INTERLACE,i) ; for (int j=0; jsetName(meshname); MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ; myMeshDriver.setMeshName(meshname); - myMeshDriver.open() ; - myMeshDriver.read() ; - myMeshDriver.close() ; + int current = myMesh->addDriver(myMeshDriver); + myMesh->read(current); // read field : if (argc != 4) exit(0) ; // else we have a field ! string fieldname = argv[3]; + FIELD * myField ; // SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE); SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_cell",MED_CELL); - FIELD * myField = new FIELD() ; - - myField->setName(fieldname); - myField->setSupport(mySupport); - MED_FIELD_RDONLY_DRIVER myFieldDriver(filename,myField) ; - myFieldDriver.setFieldName(fieldname); - myFieldDriver.open() ; - try { - myFieldDriver.read() ; + myField = new FIELD(mySupport,MED_DRIVER,filename,fieldname) ; + myField->setValueType(MED_REEL64); } catch (...) { delete mySupport ; mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE); - myField->setSupport(mySupport); try { - myFieldDriver.read() ; + myField = new FIELD(mySupport,MED_DRIVER,filename,fieldname) ; + myField->setValueType(MED_REEL64); } catch (...) { - cout << "Field " << fieldname << " not found !!!" << endl ; + cout << "Field double " << fieldname << " not found !!!" << endl ; exit (-1) ; } } - myFieldDriver.close() ; - affiche_fieldT(myField, mySupport); FIELD * myField2 = new FIELD(* myField); delete myField; affiche_fieldT(myField2, myField2->getSupport()); delete myField2; + delete mySupport ; + delete myMesh ; + return 0; } diff --git a/src/MEDMEM/test_copie_field_.cxx b/src/MEDMEM/test_copie_field_.cxx index ac68a0b25..08f8c9e93 100644 --- a/src/MEDMEM/test_copie_field_.cxx +++ b/src/MEDMEM/test_copie_field_.cxx @@ -1,4 +1,29 @@ -using namespace std; +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : test_copie_field_.cxx +// Module : MED + /* Programme de test du constructeur de copies de la classe FIELD_ de MEDMEM jroy - 12/12/2002 */ @@ -92,6 +117,7 @@ int main (int argc, char ** argv) { // SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE); SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_cell",MED_CELL); FIELD * myField = new FIELD() ; + myField->setValueType(MED_REEL64); myField->setName(fieldname); myField->setSupport(mySupport); @@ -120,6 +146,11 @@ int main (int argc, char ** argv) { FIELD_ * pt_field_2 = new FIELD_(* pt_field_); delete myField; affiche_field(pt_field_2, pt_field_2->getSupport()); + + delete pt_field_2 ; + + delete mySupport ; + delete myMesh ; return 0; } diff --git a/src/MEDMEM/test_copie_group.cxx b/src/MEDMEM/test_copie_group.cxx index 3238ea150..7bf53c8e2 100644 --- a/src/MEDMEM/test_copie_group.cxx +++ b/src/MEDMEM/test_copie_group.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 : test_copie_group.cxx +// Module : MED + using namespace std; #include @@ -16,7 +42,7 @@ using namespace std; #include "MEDMEM_define.hxx" -void affiche_support(SUPPORT * mySupport) +void affiche_support(const SUPPORT * mySupport) { cout << " - Name : "<getName().c_str()<getDescription().c_str()<isOnAllElements())) { int NumberOfTypes = mySupport->getNumberOfTypes() ; cout<<" - NumberOfTypes : "<getTypes() ; + const medGeometryElement * Types = mySupport->getTypes() ; for (int j=0;jgetNumberOfElements(Types[j]) ; - int * Number = mySupport->getNumber(Types[j]) ; + const int * Number = mySupport->getNumber(Types[j]) ; for (int k=0; kgetIdentifier()<getGroupName(j).c_str()<getNumberOfFamilies() ; @@ -66,7 +92,7 @@ int main (int argc, char ** argv) { int read; - if (argc !=3) { + if (argc <3) { // after 3, ignored ! cerr << "Usage : " << argv[0] << " filename meshname" << endl << endl; exit(-1); @@ -83,13 +109,18 @@ int main (int argc, char ** argv) { myMeshDriver.read() ; myMeshDriver.close() ; - GROUP * myGroup = myMesh->getGroup(MED_NODE,1); + const GROUP * myGroup = myMesh->getGroup(MED_NODE,1); cout << "Show Group :"< & myMedArray) MESSAGE("Show all 1 :"); numberof = myMedArray.getLeadingValue() ; for (int i=1; i<=myMedArray.getLengthValue() ; i++) { - double * node = myMedArray.getI(MED_FULL_INTERLACE,i) ; + const double * node = myMedArray.getRow(i) ; cout << " - " ; for (int j=0;j & myMedArray) MESSAGE("Show all 2 :"); numberof = myMedArray.getLengthValue() ; for (int i=1; i<=myMedArray.getLeadingValue() ; i++) { - double * node = myMedArray.getI(MED_NO_INTERLACE,i) ; + const double * node = myMedArray.getColumn(i) ; cout << " - " ; for (int j=0;j & myMedArray) MESSAGE("Show all 0 :"); numberof = myMedArray.getLeadingValue() ; int length = myMedArray.getLengthValue() ; - double * NoInterlaceArray = myMedArray.get(MED_NO_INTERLACE) ; + const double * NoInterlaceArray = myMedArray.get(MED_NO_INTERLACE) ; for (int i=0; i * myMedArray2 = new MEDARRAY(* myMedArray); + MEDARRAY * myMedArray2 = new MEDARRAY(* myMedArray,false); delete myMedArray; affiche_medarray(* myMedArray2); + MEDARRAY * myMedArray3 = new MEDARRAY(10,20); + (* myMedArray3) = (* myMedArray2) ; delete myMedArray2; + affiche_medarray(* myMedArray3); + delete myMedArray3; return 0; } diff --git a/src/MEDMEM/test_copie_mesh.cxx b/src/MEDMEM/test_copie_mesh.cxx new file mode 100644 index 000000000..53f794410 --- /dev/null +++ b/src/MEDMEM/test_copie_mesh.cxx @@ -0,0 +1,56 @@ +// MED MEDMEM : MED files in memory +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : test_copie_mesh.cxx +// Module : MED + +using namespace std; +#include + +#include +#include + +#include "MEDMEM_Exception.hxx" +#include "MEDMEM_Mesh.hxx" +#include "MEDMEM_Family.hxx" +#include "MEDMEM_Group.hxx" + +#include "MEDMEM_MedMeshDriver.hxx" +#include "MEDMEM_MedFieldDriver.hxx" +#include "MEDMEM_Support.hxx" +#include "MEDMEM_Field.hxx" +#include "MEDMEM_define.hxx" + + +int main (int argc, char ** argv) { + + int read; + + if (argc <3) { // after 3, ignored ! + cerr << "Usage : " << argv[0] + << " filename meshname" << endl << endl; + exit(-1); + } + + string filename = argv[1] ; + string meshname = argv[2] ; + + MESH * myMesh= new MESH() ; + myMesh->setName(meshname); + MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ; + myMeshDriver.setMeshName(meshname); + myMeshDriver.open() ; + myMeshDriver.read() ; + myMeshDriver.close() ; + + cout << * myMesh << endl; + MESH * myMesh2 = new MESH(* myMesh); + delete myMesh; + cout << * myMesh2 << endl; + delete myMesh2; + + return 0; +} diff --git a/src/MEDMEM/test_copie_support.cxx b/src/MEDMEM/test_copie_support.cxx index 7256e5e67..bc228814a 100644 --- a/src/MEDMEM/test_copie_support.cxx +++ b/src/MEDMEM/test_copie_support.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 : test_copie_support.cxx +// Module : MED + using namespace std; #include @@ -16,7 +42,7 @@ using namespace std; #include "MEDMEM_define.hxx" -void affiche_support(SUPPORT * mySupport) +void affiche_support(const SUPPORT * mySupport) { cout << " - Name : "<getName().c_str()<getDescription().c_str()<isOnAllElements())) { int NumberOfTypes = mySupport->getNumberOfTypes() ; cout<<" - NumberOfTypes : "<getTypes() ; + const medGeometryElement * Types = mySupport->getTypes() ; for (int j=0;jgetNumberOfElements(Types[j]) ; - int * Number = mySupport->getNumber(Types[j]) ; + const int * Number = mySupport->getNumber(Types[j]) ; for (int k=0; kgetNumberOfFamilies(Entity) ; cout << "NumberOfFamilies : "<getFamily(Entity,i); + const FAMILY* myFamily = myMesh->getFamily(Entity,i); affiche_support(myFamily); cout << " - Identifier : "<getIdentifier()<getNumberOfAttributes() ; @@ -63,7 +89,7 @@ void affiche_groupe(MESH *myMesh,medEntityMesh Entity) int NumberOfGroups = myMesh->getNumberOfGroups(Entity) ; cout << "NumberOfGroups : "<getGroup(Entity,i); + const GROUP* myGroup = myMesh->getGroup(Entity,i); affiche_support(myGroup); int NumberOfFamillies = myGroup->getNumberOfFamilies() ; cout << " - Families ("<getTypes(MED_CELL); - int TotalNumberOfEntity = 0; - int * NumberOfEntity = new int[myMesh->getNumberOfTypes(MED_CELL)]; + int TotalNumberOfElements = 0; + int * NumberOfElements = new int[myMesh->getNumberOfTypes(MED_CELL)]; // NumberOfEntity[0] = 2; // int * NumberValue = new int[TotalNumberOfEntity]; int * NumberValue = new int[myMesh->getGlobalNumberingIndex(MED_CELL)[myMesh->getNumberOfTypes(MED_CELL)]-1]; @@ -122,11 +147,12 @@ int main (int argc, char ** argv) { // NumberValue[1] = 15; int cmp = 0; medGeometryElement * GeometricTypePartial = new medGeometryElement[myMesh->getNumberOfTypes(MED_CELL)]; + const medGeometryElement * GeometricType = myMesh->getTypes(MED_CELL); for (int i=0;igetNumberOfTypes(MED_CELL);i=i+2) { NumberOfGeometricType=NumberOfGeometricType+1; - TotalNumberOfEntity=TotalNumberOfEntity+myMesh->getNumberOfElements(MED_CELL,GeometricType[i]); - NumberOfEntity[i/2]=myMesh->getNumberOfElements(MED_CELL,GeometricType[i]); + TotalNumberOfElements=TotalNumberOfElements+myMesh->getNumberOfElements(MED_CELL,GeometricType[i]); + NumberOfElements[i/2]=myMesh->getNumberOfElements(MED_CELL,GeometricType[i]); for (int j=0;jgetNumberOfElements(MED_CELL,GeometricType[i]);j++) { NumberValue[cmp]=myMesh->getGlobalNumberingIndex(MED_CELL)[i]+j; @@ -135,7 +161,11 @@ int main (int argc, char ** argv) { GeometricTypePartial[i/2]=GeometricType[i]; } - mySupport->setpartial("Support partiel",NumberOfGeometricType,TotalNumberOfEntity,GeometricTypePartial,NumberOfEntity,NumberValue); + mySupport->setpartial("Support partiel",NumberOfGeometricType,TotalNumberOfElements,GeometricTypePartial,NumberOfElements,NumberValue); + + delete[] NumberOfElements ; + delete[] NumberValue ; + delete[] GeometricTypePartial ; cout << "Show Partial Support :"< +#include "MEDMEM_Exception.hxx" +#include "MEDMEM_define.hxx" +#include "MEDMEM_Mesh.hxx" + +void usage(char * name) +{ + cout << " " << name <<" "<< " " << " " << endl; + cout << " " << "displays all Nodes Coordinates in mdump mode" << endl; + cout << endl; + cout << " " << "mesh name is mandatory. Try mdump if necessary" << endl; + cout << " " << "values for interlace mode are : " << endl; + cout << " " << "MED_FULL_INTERLACE (default value) or MED_NO_INTERLACE" << endl; + exit(-1); +} + +int main (int argc, char ** argv) { + + if (argc < 3) usage(argv[0]); + if (argc > 4) usage(argv[0]); + + string fileName = argv[1]; + string meshName = argv[2]; + + medModeSwitch Mode = MED_FULL_INTERLACE; + if (argc==4) + { + string comp=argv[3]; + if ( comp == "MED_NO_INTERLACE" ) Mode = MED_NO_INTERLACE; + else if ( comp != "MED_FULL_INTERLACE") usage(argv[0]); + } + + + MESH * myMesh= new MESH() ; + myMesh->setName(meshName); + MED_MESH_RDONLY_DRIVER myMeshDriver(fileName,myMesh); + try + { + myMeshDriver.setMeshName(meshName); + myMeshDriver.open(); + } + catch (const exception & ex) + { + MESSAGE("Catch Exception : "); + SCRUTE(ex.what()); + }; + MESSAGE("Open done"); + + try + { + myMeshDriver.read(); + } + catch (const exception & ex) + { + MESSAGE("Catch Exception : "); + SCRUTE(ex.what()); + }; + MESSAGE("Read done"); + + int SpaceDimension = myMesh->getSpaceDimension() ; + int MeshDimension = myMesh->getMeshDimension() ; + int NumberOfNodes = myMesh->getNumberOfNodes() ; + + cout << "(************************)"<getCoordinatesSystem(); + if ( typeRepere.size() == 0 ) typeRepere ="0"; + cout << "- Type de repere des coordonnees : " << typeRepere << endl; + + string chainevide(MED_TAILLE_PNOM+2,' '); + cout << "- Nom des coordonnees : " << endl ; + const string * CoordinatesNames = myMesh->getCoordinatesNames() ; + for (int i=0; i < SpaceDimension ; i++) + { + string bonnelongueur=chainevide; + bonnelongueur.replace(1,CoordinatesNames[i].size(),CoordinatesNames[i]); + cout << bonnelongueur; + } + cout <getCoordinatesUnits() ; + for ( int i=0; i < SpaceDimension ; i++) + { + string bonnelongueur=chainevide; + bonnelongueur.replace(1,CoordinatesUnits[i].size(),CoordinatesUnits[i]); + cout << bonnelongueur; + } + cout <getCoordinates(Mode) ; + cout << "- Coordonnees des noeuds : " << endl; + for (int i=0; i < SpaceDimension*NumberOfNodes; i++) + { + fprintf(stdout," %f ",Coordinates[i]); + } + cout < +#include "MEDMEM_Exception.hxx" +#include "MEDMEM_define.hxx" +#include "MEDMEM_Mesh.hxx" +#include "MEDMEM_DriversDef.hxx" + +void usage(char * name) +{ + cout << " " << name <<" "<< " " << " " << endl; + cout << " " << "displays all Nodes Coordinates in mdump mode" << endl; + cout << endl; + cout << " " << "mesh name is mandatory. Try mdump if necessary" << endl; + cout << " " << "values for interlace mode are : " << endl; + cout << " " << "MED_FULL_INTERLACE (default value) or MED_NO_INTERLACE" << endl; + exit(-1); +} + +int main (int argc, char ** argv) { + + if (argc < 3) usage(argv[0]); + if (argc > 4) usage(argv[0]); + + string fileName = argv[1]; + string meshName = argv[2]; + + medModeSwitch Mode = MED_FULL_INTERLACE; + if (argc==4) + { + string comp=argv[3]; + if ( comp == "MED_NO_INTERLACE" ) Mode = MED_NO_INTERLACE; + else if ( comp != "MED_FULL_INTERLACE") usage(argv[0]); + } + + + MESH * myMesh= new MESH() ; + myMesh->setName(meshName); + MED_MESH_RDONLY_DRIVER myMeshDriver(fileName,myMesh); + try + { + myMeshDriver.setMeshName(meshName); + myMeshDriver.open(); + } + catch (const exception & ex) + { + MESSAGE("Catch Exception : "); + SCRUTE(ex.what()); + }; + MESSAGE("Open done"); + + try + { + myMeshDriver.read(); + } + catch (const exception & ex) + { + MESSAGE("Catch Exception : "); + SCRUTE(ex.what()); + }; + MESSAGE("Read done"); + + int SpaceDimension = myMesh->getSpaceDimension(); + int MeshDimension = myMesh->getMeshDimension(); + int NumberOfNodes = myMesh->getNumberOfNodes(); + + cout << "(****************************)" << endl; + cout << "(* INFORMATIONS GENERALES : *)" << endl; + cout << "(****************************)" << endl; + + string chainevide(MED_TAILLE_PNOM+2,' '); + cout << "- Nom du maillage : <<" << meshName << ">>" << endl; + cout << "- Dimension du maillage : "<< SpaceDimension << endl; + cout << "- Pas de nom universel " << endl ; + cout << "- Nombre de noeuds : " << NumberOfNodes << " " << endl; + + int NumberOfTypes = myMesh->getNumberOfTypes(MED_CELL); + const medGeometryElement * Types = myMesh->getTypes(MED_CELL); + + + const list currentEntity = MED_FR::meshEntities[(MED_FR::med_entite_maillage)MED_CELL]; + list::const_iterator currentGeometry; + for (currentGeometry = currentEntity.begin(); + currentGeometry != currentEntity.end(); + currentGeometry++) + { + cout << "- Nombre de mailles de type "; + cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*currentGeometry)] << " : "; + cout << myMesh->getNumberOfElements(MED_CELL,(MED_EN::medGeometryElement)(*currentGeometry)); + cout << " " << endl; + } + + const list currentEntity2 = MED_FR::meshEntities[(MED_FR::med_entite_maillage)MED_FACE]; + for (currentGeometry = currentEntity2.begin(); + currentGeometry != currentEntity2.end(); + currentGeometry++) + { + cout << "- Nombre de faces de type "; + cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*currentGeometry)] << " : "; + cout << myMesh->getNumberOfElements(MED_FACE,(MED_EN::medGeometryElement)(*currentGeometry)); + cout << " " << endl; + } + + const list currentEntity3 = MED_FR::meshEntities[(MED_FR::med_entite_maillage)MED_EDGE]; + for (currentGeometry = currentEntity3.begin(); + currentGeometry != currentEntity3.end(); + currentGeometry++) + { + cout << "- Nombre d'aretes de type "; + cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*currentGeometry)] << " : "; + cout << myMesh->getNumberOfElements(MED_EDGE,(MED_EN::medGeometryElement)(*currentGeometry)); + cout << " " << endl; + } + + delete myMesh; +} diff --git a/src/MEDMEM/tests/testUArray.cxx b/src/MEDMEM/tests/testUArray.cxx new file mode 100755 index 000000000..7f9b534e8 --- /dev/null +++ b/src/MEDMEM/tests/testUArray.cxx @@ -0,0 +1,347 @@ +// 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 : testUArray.cxx +// Module : MED + +using namespace std; +#include // pour l'acces à EXIT_SUCCESS et EXIT_FAILURE +#include "utilities.h" +#include "MEDMEM_Array.hxx" + +void imprime(string titre,const int * myValues,const int * myOthers, int lignes, int colonnes) +{ + cout << " " <(int,int,mode) */ + /* - get sur le pointeur MED_FULL_INTERLACE */ + /* - initialisation des valeurs (coordonnées ieme elt = I+1) */ + /* - get sur le pointeur MED_NO_INTERLACE */ + /* ---------------------------------------------------------- */ + + int SpaceDimension = 3; + int NumberOfNodes = 4; + + + + MEDARRAY * myArrayfull= new MEDARRAY(SpaceDimension,NumberOfNodes,MED_FULL_INTERLACE); + ASSERT(myArrayfull != NULL); + + const int * myValues = myArrayfull->get(MED_FULL_INTERLACE); + ASSERT(myValues!= NULL); + + for (int i=0; isetIJ(i+1,k+1,i+1) ; + } + } + + const int * myOthers = myArrayfull->get(MED_NO_INTERLACE) ; + ASSERT(myOthers != NULL); + + imprime("Initialisation full interlace (xi=yi=zi=i+1)",myValues,myOthers,NumberOfNodes,SpaceDimension); + + MEDARRAY * myArrayno= new MEDARRAY(SpaceDimension,NumberOfNodes,MED_NO_INTERLACE); + ASSERT(myArrayno != NULL); + const int * myValuesno = myArrayno->get(MED_NO_INTERLACE); + ASSERT(myValuesno!= NULL); + + for (int k=0; ksetIJ(i+1,k+1,k+1) ; + } + } + + const int * myOthersno = myArrayno->get(MED_FULL_INTERLACE) ; + ASSERT(myOthersno != NULL); + + imprime("Initialisation no interlace (xi=yi=zi=i+1)",myOthersno,myValuesno,NumberOfNodes,SpaceDimension); + + + /* ---------------------------------------------------------- */ + /* */ + /* Tests des Fonctions Set */ + /* */ + /* - setI sur l'element 1 avec des coordonnees a 100 */ + /* - setJ sur l'element 1 avec des coordonnees a 100 */ + /* - setIJ sur (1,2) avec une coordonnee = 1992 */ + /* - set avec l ensemble des coordonnes remises à i */ + /* ---------------------------------------------------------- */ + + + int * myNewLine = new int[SpaceDimension]; + for (int i = 0; i < SpaceDimension; i++) + myNewLine[i] = myValues[i] * 100; + try + { + myArrayfull->setI(1, myNewLine); + } + catch ( const std::exception &e ) + { + cout << "--------------" << endl; + cout << " Pb au setI " << endl; + cout << "--------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "---------------" << endl; + cout << " Pb au setI " << endl; + cout << "---------------" << endl; + } + + delete [] myNewLine; + imprime("1er element : coordonnees à 100",myValues,myOthers,NumberOfNodes,SpaceDimension); + + int * myNewCol = new int[NumberOfNodes]; + for (int i = 0; i < NumberOfNodes; i++) + myNewCol[i] = 100; + try + { + myArrayno->setJ(1, myNewCol); + } + catch ( const std::exception &e ) + { + cout << "--------------" << endl; + cout << " Pb au setJ " << endl; + cout << "--------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "---------------" << endl; + cout << " Pb au setJ " << endl; + cout << "---------------" << endl; + } + + delete [] myNewCol; + imprime("1eres coordonnees à 100",myOthersno,myValuesno,NumberOfNodes,SpaceDimension); + + try + { + myArrayfull->setIJ(1,2,1992); + } + catch ( const std::exception &e ) + { + cout << "---------------------------" << endl; + cout << " Pb au setIJ() de 1 , 2 " << endl; + cout << "---------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-----------------------------" << endl; + cout << " Pb au setIJ() de 1 , 2 " << endl; + cout << "-----------------------------" << endl; + } + + imprime("1er element : 2ieme coordonnee = 1992",myValues,myOthers,NumberOfNodes,SpaceDimension); + + + try + { + myArrayno->setIJ(1,2,1992); + } + catch ( const std::exception &e ) + { + cout << "---------------------------" << endl; + cout << " Pb au setIJ() de 1 , 2 " << endl; + cout << "---------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-----------------------------" << endl; + cout << " Pb au setIJ() de 1 , 2 " << endl; + cout << "-----------------------------" << endl; + } + + imprime("1er element : 2ieme coordonnee = 1992",myValues,myOthers,NumberOfNodes,SpaceDimension); + + int * mynewvalues= new int [ NumberOfNodes*SpaceDimension ]; + for (int i=0; iset(MED_FULL_INTERLACE,mynewvalues); + myValues = myArrayfull->get(MED_FULL_INTERLACE); + myOthers = myArrayfull->get(MED_NO_INTERLACE); + } + catch ( const std::exception &e ) + { + cout << "-------------" << endl; + cout << " Pb au set " << endl; + cout << "-------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "--------------" << endl; + cout << " Pb au set " << endl; + cout << "--------------" << endl; + } + imprime("remise valeur a i sur myArrayfull med full interlace",myValues,myOthers,NumberOfNodes,SpaceDimension); + + try + { + myArrayno->set(MED_FULL_INTERLACE,mynewvalues); + myValuesno = myArrayfull->get(MED_FULL_INTERLACE); + myOthersno = NULL; + } + catch ( const std::exception &e ) + { + cout << "-------------" << endl; + cout << " Pb au set " << endl; + cout << "-------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "--------------" << endl; + cout << " Pb au setI " << endl; + cout << "--------------" << endl; + } + imprime("set full interlace de myArrayno",myValuesno,myOthersno,NumberOfNodes,SpaceDimension); + + /* ---------------------------------------------------------- */ + /* */ + /* Tests des constructeurs */ + /* Tests des Fonctions Get */ + /* */ + /* */ + /* ---------------------------------------------------------- */ + + MEDARRAY * myArrayShare = new MEDARRAY( *myArrayfull); + const int * sharevalues = myArrayShare->get(MED_FULL_INTERLACE); + const int * shareno = myArrayShare->get(MED_NO_INTERLACE); + imprime("test contructeur par recopie non profonde",sharevalues,shareno,NumberOfNodes,SpaceDimension); + + myArrayfull->setIJ(1,2,1992); + ASSERT(myArrayShare->getIJ(1,2) == 1992); + imprime("change valeur tableau source, impression tableau cible",sharevalues,shareno,NumberOfNodes,SpaceDimension); + + myArrayShare->setIJ(1,2,1995); + ASSERT(myArrayfull->getIJ(1,2) == 1995); + imprime("change valeur tableau cible, impression tableau source",myValues,myOthers,NumberOfNodes,SpaceDimension); + + delete myArrayShare; + imprime("tableau cible apres destruction tableau source",myValues,myOthers,NumberOfNodes,SpaceDimension); + + MEDARRAY * myArrayShare2 = new MEDARRAY( *myArrayfull,true); + sharevalues = myArrayShare2->get(MED_FULL_INTERLACE); + shareno = myArrayShare2->get(MED_NO_INTERLACE); + imprime("test contructeur par recopie profonde",sharevalues,shareno,NumberOfNodes,SpaceDimension); + + myArrayfull->setIJ(1,2,18); + imprime("change valeur tableau source, impression tableau cible",sharevalues,shareno,NumberOfNodes,SpaceDimension); + + myArrayShare2->setIJ(1,2,19); + imprime("change valeur tableau cible, impression tableau source",myValues,myOthers,NumberOfNodes,SpaceDimension); + + myArrayno->set(MED_NO_INTERLACE,mynewvalues); + myArrayno->setIJ(2,1,1); + myValuesno = myArrayno->get(MED_NO_INTERLACE); + myOthersno = myArrayno->get(MED_FULL_INTERLACE); + imprime("Initialisation no interlace (0...11)",myOthersno,myValuesno,NumberOfNodes,SpaceDimension); + + MEDARRAY * myArrayShare3 = new MEDARRAY( *myArrayno); + sharevalues = myArrayShare3->get(MED_FULL_INTERLACE); + shareno = myArrayShare3->get(MED_NO_INTERLACE); + imprime("test contructeur par recopie non profonde",sharevalues,shareno,NumberOfNodes,SpaceDimension); + + myArrayno->setIJ(1,2,1992); + ASSERT(myArrayShare3->getIJ(1,2) == 1992); + imprime("change valeur tableau source, impression tableau cible",sharevalues,shareno,NumberOfNodes,SpaceDimension); + + myArrayShare3->setIJ(1,2,1995); + ASSERT(myArrayno->getIJ(1,2) == 1995); + imprime("change valeur tableau cible, impression tableau source",myValuesno,myOthersno,NumberOfNodes,SpaceDimension); + + delete myArrayno; + delete [] mynewvalues; + delete myArrayfull; + delete myArrayShare2; + delete myArrayShare3; + MESSAGE("FIN NORMALE DU TRAITEMENT"); + return EXIT_SUCCESS ; +} +/* + inline medModeSwitch getMode() const ; +*/ diff --git a/src/MEDMEM/tests/testUArray.cxx.ok b/src/MEDMEM/tests/testUArray.cxx.ok new file mode 100755 index 000000000..73b0b894a --- /dev/null +++ b/src/MEDMEM/tests/testUArray.cxx.ok @@ -0,0 +1,312 @@ +#include // pour l'acces à EXIT_SUCCESS et EXIT_FAILURE +#include "utilities.h" +#include "MEDMEM_Array.hxx" + +int main (int argc, char ** argv) +{ + + int SpaceDimension = 3; + int NumberOfNodes = 4; + MEDARRAY * myArray = new MEDARRAY(SpaceDimension,NumberOfNodes,MED_FULL_INTERLACE) ; + ASSERT(myArray != NULL); + + int * value = myArray->get(MED_FULL_INTERLACE) ; + ASSERT(value!= NULL); + + for (int i=0; igetLeadingValue() ; + ASSERT (leadingValue == SpaceDimension); + } + catch ( const std::exception &e ) + { + cout << "-------------------------------" << endl; + cout << " Pb au getLeadingValue() " << endl; + cout << "-------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------------------" << endl; + cout << " Pb au getLeadingValue() " << endl; + cout << "-------------------------------" << endl; + return EXIT_FAILURE ; + } + + int lengthValue; + try + { + lengthValue = myArray->getLengthValue() ; + ASSERT(lengthValue == NumberOfNodes) + } + catch ( const std::exception &e ) + { + cout << "-------------------------------" << endl; + cout << " Pb au getLengthValue() " << endl; + cout << "-------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------------------" << endl; + cout << " Pb au getLengthValue() " << endl; + cout << "-------------------------------" << endl; + return EXIT_FAILURE ; + } + + cout << "Show all using getI and full interlace :" << endl; + for (int i=1; i<=lengthValue; i++) + { + try + { + int * node = myArray->getI(MED_FULL_INTERLACE,i) ; + cout << " - " ; + for (int j=0;jgetI(MED_NO_INTERLACE,i) ; + cout << " - " ; + for (int j=0;jgetIJ(i,j) << " " ; + cout << endl ; + } + catch ( const std::exception &e ) + { + cout << "-------------------------------" << endl; + cout << " Pb au getIJ() i " << i << " j " << j << endl; + cout << "-------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------------------" << endl; + cout << " Pb au getIJ() i " << i << " j " << j << endl; + cout << "-------------------------------" << endl; + return EXIT_FAILURE ; + } + } + + cout << "Show all using get and MED_NO_INTERLACE :" << endl; + try + { + int * NoInterlaceArray = myArray->get(MED_NO_INTERLACE) ; + for (int i=0; iset(MED_FULL_INTERLACE, myNewInt); + } + catch ( const std::exception &e ) + { + cout << "-------------------------------" << endl; + cout << " Pb au set " << endl; + cout << "-------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "---------------" << endl; + cout << " Pb au set " << endl; + cout << "---------------" << endl; + return EXIT_FAILURE ; + } + delete [] myNewInt; + + cout << "Nouvelles valeurs (x10) : get avec Full interlace : " << endl; + int * myNewValue; + try + { + myNewValue = myArray->get(MED_FULL_INTERLACE) ; + ASSERT(myNewValue!= NULL); + } + catch ( const std::exception &e ) + { + cout << "-----------------" << endl; + cout << " Pb au get " << endl; + cout << "-----------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "---------------" << endl; + cout << " Pb au get " << endl; + cout << "---------------" << endl; + } + + cout << " - "; + for (int i=0; isetI(MED_FULL_INTERLACE, 1, myNewLine); + } + catch ( const std::exception &e ) + { + cout << "-------------------------------" << endl; + cout << " Pb au getLengthValue() " << endl; + cout << "-------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "---------------" << endl; + cout << " Pb au setI " << endl; + cout << "---------------" << endl; + } + delete [] myNewLine; + + try + { + myNewValue = myArray->getI(MED_FULL_INTERLACE,1) ; + ASSERT(myNewValue!= NULL); + } + catch ( const std::exception &e ) + { + cout << "-------------------------------" << endl; + cout << " Pb au getLengthValue() " << endl; + cout << "-------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "---------------" << endl; + cout << " Pb au getI " << endl; + cout << "---------------" << endl; + } + + cout << endl << " Nouvelles valeurs (x100) sur la 1ere ligne: get avec Full interlace : "; + cout << endl << " - "; + for (int i=0; isetIJ(1,1,1992); + } + catch ( const std::exception &e ) + { + cout << "---------------------------" << endl; + cout << " Pb au setIJ() de 1 , 1 " << endl; + cout << "---------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-----------------------------" << endl; + cout << " Pb au setIJ() de 1 , 1 " << endl; + cout << "-----------------------------" << endl; + } + + cout << "Nouvelle valeur avec setIJ et getIJ" << endl; + cout << " - " << myArray->getIJ(1,1) << endl; + + delete myArray; + return EXIT_SUCCESS ; +} + +/* + inline medModeSwitch getMode() const ; + +*/ diff --git a/src/MEDMEM/tests/testUCellModel.cxx b/src/MEDMEM/tests/testUCellModel.cxx new file mode 100755 index 000000000..d8119e65c --- /dev/null +++ b/src/MEDMEM/tests/testUCellModel.cxx @@ -0,0 +1,367 @@ +// 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 : testUCellModel.cxx +// Module : MED + +using namespace std; +#include +#include +#include "utilities.h" + +#include "MEDMEM_CellModel.hxx" +#include "MEDMEM_define.hxx" +#include "MEDMEM_DriversDef.hxx" + +void usage(char * name) +{ + cout << " " << name << endl; +} + +int main (int argc, char ** argv) +{ + + if (argc < 1) usage(argv[0]); + + + cout << "CELLMODEL Test" << endl ; + cout << "--------------" << endl; + +/* ----------------------------------------------------- + Construction de tous les types de cellmodel possibles + ----------------------------------------------------- +*/ + + CELLMODEL * tous =new CELLMODEL[MED_NBR_GEOMETRIE_MAILLE ]; + const medGeometryElement allCellType[MED_NBR_GEOMETRIE_MAILLE ]= + {MED_POINT1, MED_SEG2, MED_SEG3, MED_TRIA3, + MED_QUAD4, MED_TRIA6, MED_QUAD8, MED_TETRA4, + MED_PYRA5, MED_PENTA6, MED_HEXA8, MED_TETRA10, + MED_PYRA13, MED_PENTA15, MED_HEXA20 }; + + for (int i=0; i setGeomElt; + medGeometryElement * vt; + int taille; + try + { + vt=tous[i].getConstituentsType(dim2); + taille=tous[i].getNumberOfConstituents(dim2); + } + catch ( const std::exception &e ) + { + cout << "-------------------------------" << endl; + cout << " Pb au getConstituentsType() " << endl; + cout << "-------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "--------------------------------" << endl; + cout << " Pb au getConstituentsType() " << endl; + cout << "--------------------------------" << endl; + return EXIT_FAILURE ; + }; + for (int k=0; k::iterator iter_s; + for (iter_s=setGeomElt.begin() ;iter_s!=setGeomElt.end();iter_s++) + { + cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*iter_s)] << endl; + } + + cout << "Impression des coordonnées du 1er Element de ce type" << endl; + try + { + vector v2=tous[i].getNodesConstituent(dim2,1); + for (int k=0; k 1 ) + { + try + { + cout << "Informations particulieres - dimension " << dimension - 1 << endl; + set ::iterator iter_s; + for (iter_s=tous[i].getAllConstituentsType().begin() ; + iter_s!=tous[i].getAllConstituentsType().end();iter_s++) + { + cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*iter_s)] << endl; + } + } + catch ( const std::exception &e ) + { + cout << "-------------------------------" << endl; + cout << " Pb au getAllConstituentsType() " << endl; + cout << "-------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "------------------------------------" << endl; + cout << " Pb au getAllConstituentsType() " << endl; + cout << "------------------------------------" << endl; + return EXIT_FAILURE ; + } + } +*/ + + } + + delete[] tous ; + + return EXIT_SUCCESS ; +/* +Reste a Tester + // Return number of constituents foreach type (which dimension is _dimension-1). + map getNumberOfConstituentsForeachType() const; +*/ +} diff --git a/src/MEDMEM/tests/testUCoordinate.cxx b/src/MEDMEM/tests/testUCoordinate.cxx new file mode 100755 index 000000000..b43749ee3 --- /dev/null +++ b/src/MEDMEM/tests/testUCoordinate.cxx @@ -0,0 +1,400 @@ +// 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 : testUCoordinate.cxx +// Module : MED + +using namespace std; +#include +#include +#include "utilities.h" + +#include "MEDMEM_define.hxx" +#include "MEDMEM_Array.hxx" +#include "MEDMEM_Coordinate.hxx" +#include + +void usage(char * name) +{ + cout << " " << name << endl; +} + +int main (int argc, char ** argv) +{ + + + if (argc < 1) usage(argv[0]); + + const double pouieme = 0.009; + + cout << "COORDINATE Test" << endl; + cout << "---------------" << endl; + + int SpaceDim = 3; + int NbOfNodes = 5; + + string * noms = new string[3]; + noms[0]=" X "; + noms[1]=" Y "; + noms[2]=" Z "; + + string units[3]; + units[0]=" m "; + units[1]=" m "; + units[2]=" m "; + + int * numbers=new int[5]; + for (int i=0; i< 5; i++) numbers[i] =10+i; + + MED_EN::medModeSwitch ModeFull=MED_EN::MED_FULL_INTERLACE; + MED_EN::medModeSwitch ModeNo=MED_EN::MED_NO_INTERLACE; + double coor[15] = {0,0,0,0,0,1,0,1,0,1,0,0,0.5,0.5,0.5} ; + ASSERT(SpaceDim*NbOfNodes == 15); + + + cout << " - mode : MED_FULL_INTERLACE" << endl; + cout << " - dimension de l espace : " << SpaceDim << endl; + cout << " - nombre de noeuds : " << NbOfNodes << endl; + + double * coor1 = new double[SpaceDim*NbOfNodes]; + for( int k=0 ; k* CoordinateArray = new MEDARRAY(coor1,SpaceDim,NbOfNodes,ModeFull); + COORDINATE mycoo; + try + { + mycoo.setCoordinates(CoordinateArray); + } + catch ( const std::exception &e ) + { + cout << "-------------------------------" << endl; + cout << "pb avec setCoordinates" << endl; + cout << "-------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------------------" << endl; + cout << "pb avec setCoordinates" << endl; + cout << "-------------------------------" << endl; + return EXIT_FAILURE ; + }; + + //--------------------------------------------------------------------// + // Tests des methodes // + // // + // - setCoordinatesNames // + // - setCoordinatesUnits // + // - setCoordinatesSystem // + // - setNodesNumbers // + // // + //--------------------------------------------------------------------// + try + { + mycoo.setCoordinatesNames(noms); + } + catch ( const std::exception &e ) + { + cout << "-------------------------------" << endl; + cout << "pb avec setCoordinatesNames" << endl; + cout << "-------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------------------" << endl; + cout << "pb avec setCoordinatesNames" << endl; + cout << "-------------------------------" << endl; + return EXIT_FAILURE ; + }; + + try + { + mycoo.setCoordinatesUnits(units); + } + catch ( const std::exception &e ) + { + cout << "-------------------------------" << endl; + cout << "pb avec setCoordinatesUnits" << endl; + cout << "-------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------------------" << endl; + cout << "pb avec setCoordinatesUnits" << endl; + cout << "-------------------------------" << endl; + return EXIT_FAILURE ; + }; + + try + { + mycoo.setCoordinatesSystem("cartesien"); + } + catch ( const std::exception &e ) + { + cout << "-------------------------------" << endl; + cout << "pb avec setCoordinatesSystem" << endl; + cout << "-------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------------------" << endl; + cout << "pb avec setCoordinatesSystem" << endl; + cout << "-------------------------------" << endl; + return EXIT_FAILURE ; + }; + + try + { + mycoo.setNodesNumbers(numbers); + } + catch ( const std::exception &e ) + { + cout << "-------------------------------" << endl; + cout << "pb avec setNodesNumbers" << endl; + cout << "-------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------------------" << endl; + cout << "pb avec setNodesNumbers" << endl; + cout << "-------------------------------" << endl; + return EXIT_FAILURE ; + }; + + //--------------------------------------------------------------------// + // Tests des methodes // + // // + // - getCoordinatesNames // + // - getCoordinatesUnits // + // - getCoordinatesUnit // + // - getCoordinatesSystem // + // - getNodesNumbers // + // // + //--------------------------------------------------------------------// + + cout << endl << " Relecture des Coordonnees" << endl << endl; + + try + { + cout << " Le systeme est : " << mycoo.getCoordinatesSystem() << endl; + } + catch ( const std::exception &e ) + { + cout << "-------------------------------" << endl; + cout << "pb avec getCoordinatesSystem" << endl; + cout << "-------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------------------" << endl; + cout << "pb avec getCoordinatesSystem" << endl; + cout << "-------------------------------" << endl; + return EXIT_FAILURE ; + }; + + const string * units2; + try + { + units2=mycoo.getCoordinatesUnits(); + for (int axe = 0; axe < SpaceDim; axe++) + { + try + { + string verif = mycoo.getCoordinateUnit(axe+1); + if (verif != units2[axe]) + cout << "Pb avec les noms des axes" << endl; + } + catch ( const std::exception &e ) + { + cout << "-------------------------" << endl; + cout << "pb avec getCoordinateUnit" << endl; + cout << "-------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------------" << endl; + cout << "pb avec getCoordinateUnit" << endl; + cout << "-------------------------" << endl; + return EXIT_FAILURE ; + }; + } + } + catch ( const std::exception &e ) + { + cout << "---------------------------" << endl; + cout << "pb avec getCoordinatesUnits" << endl; + cout << "---------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "---------------------------" << endl; + cout << "pb avec getCoordinatesUnits" << endl; + cout << "---------------------------" << endl; + return EXIT_FAILURE ; + }; + + const string * noms2; + try + { + noms2=mycoo.getCoordinatesNames(); + for (int axe = 0; axe < SpaceDim; axe++) + { + try + { + string verif = mycoo.getCoordinateName(axe+1); + if (verif != noms2[axe]) + cout << "Pb avec les noms des axes" << endl; + } + catch ( const std::exception &e ) + { + cout << "-------------------------" << endl; + cout << "pb avec getCoordinateName" << endl; + cout << "-------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------------" << endl; + cout << "pb avec getCoordinateName" << endl; + cout << "-------------------------" << endl; + return EXIT_FAILURE ; + }; + } + } + catch ( const std::exception &e ) + { + cout << "---------------------------" << endl; + cout << "pb avec getCoordinatesNames" << endl; + cout << "---------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "---------------------------" << endl; + cout << "pb avec getCoordinatesNames" << endl; + cout << "---------------------------" << endl; + return EXIT_FAILURE ; + }; + + + try + { + const double * coor2=mycoo.getCoordinates(ModeFull); + + for (int axe = 0; axe < SpaceDim; axe++) + { + + cout << "Coordonnees sur l'Axe : " << noms2[axe] ; + cout << " dont l unite est " << units2[axe] << endl; + + try + { + const double * coor3=mycoo.getCoordinateAxis(axe+1); + for (int num=0; num < NbOfNodes; num++) + { + try + { + double d = mycoo.getCoordinate(num + 1,axe+1); + cout << d <<" , "; + ASSERT(fabs(d - coor3[num]) < pouieme); + ASSERT(fabs(d - coor2[(num * SpaceDim)+axe]) < pouieme); + ASSERT(fabs(d - coor [(num * SpaceDim)+axe]) < pouieme); + } + catch ( const std::exception &e ) + { + cout << "----------------------" << endl; + cout << "pb avec getCoordinates" << endl; + cout << "----------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "----------------------" << endl; + cout << "pb avec getCoordinates" << endl; + cout << "----------------------" << endl; + return EXIT_FAILURE ; + }; + } + cout << endl; + } + catch ( const std::exception &e ) + { + cout << "-------------------------" << endl; + cout << "pb avec getCoordinateAxis" << endl; + cout << "-------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------------" << endl; + cout << "pb avec getCoordinateAxis" << endl; + cout << "-------------------------" << endl; + return EXIT_FAILURE ; + } + } + } + catch ( const std::exception &e ) + { + cout << "----------------------" << endl; + cout << "pb avec getCoordinates" << endl; + cout << "----------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "----------------------" << endl; + cout << "pb avec getCoordinates" << endl; + cout << "----------------------" << endl; + return EXIT_FAILURE ; + }; + + + delete [] noms ; + delete [] numbers; + delete [] coor1; + + delete CoordinateArray ; + + MESSAGE("FIN normale du traitement"); + return EXIT_SUCCESS ; +} + diff --git a/src/MEDMEM/tests/testUGeoNameMeshEntities.cxx b/src/MEDMEM/tests/testUGeoNameMeshEntities.cxx new file mode 100755 index 000000000..5fe253ffb --- /dev/null +++ b/src/MEDMEM/tests/testUGeoNameMeshEntities.cxx @@ -0,0 +1,74 @@ +// 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 : testUGeoNameMeshEntities.cxx +// Module : MED + +using namespace std; +#include "MEDMEM_DriversDef.hxx" + +void usage(char * name) +{ + cout << " " << name << endl; + cout << " " << "displays all avalaible geometry elements" << endl; + cout << " " << "display then all avalaible entities, and for each" << endl; + cout << " " << "all possible geomety element" << endl; + cout << endl; + exit(-1); +} + +int main (int argc, char ** argv) +{ + + if (argc < 1) usage(argv[0]); + + + cout << "GEO_NAME Test" << endl ; + cout << "-------------" << endl << endl; + MED_FR::GEO_NAME::const_iterator currentGeom; + for (currentGeom = MED_FR::geoNames.begin(); + currentGeom != MED_FR::geoNames.end(); + currentGeom++) + { + cout << (*currentGeom).second << endl; + }; + + MED_FR::MESH_ENTITIES::const_iterator currentEntity; + list::const_iterator currentGeometry; + + cout << endl; + cout << "MESH_ENTITIES Test" << endl ; + cout << "------------------" << endl << endl; + for (currentEntity = MED_FR::meshEntities.begin(); + currentEntity != MED_FR::meshEntities.end(); + currentEntity++) + { + cout << (*((MED_FR::entNames).find((*currentEntity).first))).second < +#include "MEDMEM_STRING.hxx" +#include "MEDMEM_Exception.hxx" + +int main (int argc, char ** argv) +{ + MEDEXCEPTION a = MEDEXCEPTION("test med exception"); + cout << a << endl;; + cout << a.what() << endl;; + + MEDEXCEPTION b(a); + cout << b << endl; + cout << b.what() << endl;; + + MEDEXCEPTION c("test med exception",argv[0],14); + cout << c << endl; + cout << c.what() << endl;; + + STRING msgErr; + msgErr << "ESSAI::ESSAI()! "<< 4 << "ieme essai "; + cout << MEDEXCEPTION (LOCALIZED(msgErr)).what() << endl ; + + const char * LOC = "toto" ; + cout << MEDEXCEPTION (LOCALIZED(STRING(LOC)<<" et titi")).what() << endl ; + + return EXIT_SUCCESS; + +}; diff --git a/src/MEDMEM/tests/testUModulusArray.cxx b/src/MEDMEM/tests/testUModulusArray.cxx new file mode 100644 index 000000000..bfa5890b4 --- /dev/null +++ b/src/MEDMEM/tests/testUModulusArray.cxx @@ -0,0 +1,425 @@ +// 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 : testUModulusArray.cxx +// Module : MED + +using namespace std; +#include +#include +#include "utilities.h" +#include "MEDMEM_ModulusArray.hxx" + +int main (int argc, char ** argv) +{ + + using namespace std ; + + int array[5]={0,1,2,1,4} ; + MEDMODULUSARRAY modulusArray(5,array); + + cout << " ModulusArray : " << endl; + cout << " _______________" << endl; + for(int i=-10;i<15;i++) + { + cout <<" - A[" << i <<"]="< P; + + // Creation d'un PointerOf de int + // et vérification de la methode set en essayant avec + // une taille nulle, négative puis positive + try + { + P.set(0); + ASSERT((int *)P == NULL); + } + catch ( const std::exception &e ) + { + cout << "-------------------------" << endl; + cout << " pb avec set(taille = 0) " << endl; + cout << "-------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + + try + { + P.set(-1 * size); + ASSERT((int *)P == NULL); + } + catch ( const std::exception &e ) + { + cout << "---------------------" << endl; + cout << " pb avec set(taille) " << endl; + cout << "---------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + + try + { + P.set(size); + ASSERT((int *)P != NULL); + } + catch ( const std::exception &e ) + { + cout << "---------------------" << endl; + cout << " pb avec set(taille) " << endl; + cout << "---------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + for (int i=0; i < size; i++) + { + P[i]=i; + } + + PointerOf P2(10); + + P2=P; + for (int i=0; i < size; i++) + { + SCRUTE(P2[i]); + } + + int * p=new int [size]; + for (int i=0; i < size; i++) + { + p[i]=i*10; + } + + P2.set(p); + PointerOf P3(p); + + for (int i=0; i < size; i++) + { + SCRUTE(P2[i]); + SCRUTE(P3[i]); + } + + const PointerOf P4(p); + const PointerOf P5(P4); + delete [] p; + +} diff --git a/src/MEDMEM/tests/testUSkyLineArray.cxx b/src/MEDMEM/tests/testUSkyLineArray.cxx new file mode 100644 index 000000000..c48cfae10 --- /dev/null +++ b/src/MEDMEM/tests/testUSkyLineArray.cxx @@ -0,0 +1,237 @@ +// 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 : testUSkyLineArray.cxx +// Module : MED + +using namespace std; +#include +#include "utilities.h" +#include "MEDMEM_SkyLineArray.hxx" + +int main (int argc, char ** argv) +{ + + int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle + int Size = 10 ; // 10 nodes + + int * index = new int[NumberOfCell+1]; + index[0]=1; + index[1]=4; + index[2]=8; + index[3]=11; + + int * value = new int[Size]; + value[0]=1; // first + value[1]=2; + value[2]=5; + value[3]=2; // second + value[4]=3; + value[5]=5; + value[6]=6; + value[7]=3; // thirst + value[8]=4; + value[9]=6; + + MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size,index,value) ; + + const int * ArrayIndex ; + try + { + ArrayIndex = myArray->getIndex() ; + } + catch ( const std::exception &e ) + { + cout << "----------------" << endl; + cout << "pb avec getIndex" << endl; + cout << "----------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "----------------" << endl; + cout << "pb avec getIndex" << endl; + cout << "----------------" << endl; + return EXIT_FAILURE ; + } + + const int * ArrayValue ; + try + { + ArrayValue = myArray->getValue() ; + } + catch ( const std::exception &e ) + { + cout << "----------------" << endl; + cout << "pb avec getValue" << endl; + cout << "----------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "----------------" << endl; + cout << "pb avec getValue" << endl; + cout << "----------------" << endl; + return EXIT_FAILURE ; + } + + + try + { + ASSERT(myArray->getNumberOf()==NumberOfCell); + cout << myArray->getNumberOf() << endl; + } + catch ( const std::exception &e ) + { + cout << "-------------------" << endl; + cout << "pb avec getNumberOf" << endl; + cout << "-------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------" << endl; + cout << "pb avec getNumberOf" << endl; + cout << "-------------------" << endl; + return EXIT_FAILURE ; + } + + try + { + ASSERT(myArray->getLength()==Size); + cout << myArray->getLength() << endl; + } + catch ( const std::exception &e ) + { + cout << "-------------------" << endl; + cout << "pb avec getLength" << endl; + cout << "-------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------" << endl; + cout << "pb avec getLength" << endl; + cout << "-------------------" << endl; + return EXIT_FAILURE ; + } + + cout << "Show all :" << endl ; + for (int i=1; i< NumberOfCell+1 ; i++) + { + const int * cell; + try + { + cell = myArray->getI(i) ; + } + catch ( const std::exception &e ) + { + cout << "-----------------------------" << endl; + cout << "pb avec getI, valeur de i : " << i << endl; + cout << "-----------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------" << endl; + cout << "pb avec getI, valeur de i : " << i << endl; + cout << "-------------------" << endl; + return EXIT_FAILURE ; + } + + int numberof; + try + { + numberof= myArray->getNumberOfI(i) ; + ASSERT(numberof==index[i]-index[i-1]); + } + catch ( const std::exception &e ) + { + cout << "----------------------------------" << endl; + cout << "pb avec getNumberOfI, valeur de i : " << i << endl; + cout << "----------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "----------------------------------" << endl; + cout << "pb avec getNumberOfI, valeur de i : " << i << endl; + cout << "----------------------------------" << endl; + return EXIT_FAILURE ; + } + + cout << " - " ; + for (int j=0;jgetIJ(i,j+1); + if (verif != cell[j]) + { + cout << "----------------------------------" << endl; + cout << " incoherence dans les valeurs : " << endl; + cout << " cell[" << j << "] : " << cell[j] << endl; + cout << " getIJ(" << i <<"," << j << ") : " << verif << endl; + cout << "----------------------------------" << endl; + return EXIT_FAILURE ; + } + } + catch ( const std::exception &e ) + { + cout << "----------------------------------" << endl; + cout << "pb avec getIJ, valeurs de i / j : " << i << " " << j<< endl; + cout << "----------------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "----------------------------------" << endl; + cout << "pb avec getIJ, valeurs de i / j : " << i << " " << j<< endl; + cout << "----------------------------------" << endl; + return EXIT_FAILURE ; + } + } + cout << endl ; + } + + delete[] index ; + delete[] value ; + + delete myArray; + MESSAGE("FIN normale du traitement"); + return EXIT_SUCCESS ; + + +/* + MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray ); + void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ; + + +*/ +} diff --git a/src/MEDMEM/tests/testUUnit.cxx b/src/MEDMEM/tests/testUUnit.cxx new file mode 100755 index 000000000..8cc40135f --- /dev/null +++ b/src/MEDMEM/tests/testUUnit.cxx @@ -0,0 +1,401 @@ +// 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 : testUUnit.cxx +// Module : MED + +using namespace std; +#include +#include + +#include "MEDMEM_Unit.hxx" + +int main (int argc, char ** argv) +{ + + cout << "UNIT Test" << endl ; + cout << "---------" << endl; + + UNIT testu; + try + { + testu.setName("ForTesting") ; + } + catch ( const std::exception &e ) + { + cout << "-----------------" << endl; + cout << " pb avec setName " << endl; + cout << "-----------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-----------------" << endl; + cout << " pb avec setName " << endl; + cout << "-----------------" << endl; + return EXIT_FAILURE ; + } + + try + { + testu.setDescription("all values are setted 10") ; + } + catch ( const std::exception &e ) + { + cout << "------------------------" << endl; + cout << " pb avec setDescription " << endl; + cout << "------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "------------------------" << endl; + cout << " pb avec setDescription " << endl; + cout << "------------------------" << endl; + return EXIT_FAILURE ; + } + + try + { + testu.setMasse(10); + } + catch ( const std::exception &e ) + { + cout << "------------------" << endl; + cout << " pb avec setMasse " << endl; + cout << "------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "------------------" << endl; + cout << " pb avec setMasse " << endl; + cout << "------------------" << endl; + return EXIT_FAILURE ; + } + + try + { + testu.setLength(10); + } + catch ( const std::exception &e ) + { + cout << "-------------------" << endl; + cout << " pb avec setLength " << endl; + cout << "-------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------" << endl; + cout << " pb avec setLength " << endl; + cout << "-------------------" << endl; + return EXIT_FAILURE ; + } + + try + { + testu.setTime(10); + } + catch ( const std::exception &e ) + { + cout << "-----------------" << endl; + cout << " pb avec setTime " << endl; + cout << "-----------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-----------------" << endl; + cout << " pb avec setTime " << endl; + cout << "-----------------" << endl; + return EXIT_FAILURE ; + } + + try + { + testu.setTemperature(10); + } + catch ( const std::exception &e ) + { + cout << "------------------------" << endl; + cout << " pb avec setTemperature " << endl; + cout << "------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "------------------------" << endl; + cout << " pb avec setTemperature " << endl; + cout << "------------------------" << endl; + return EXIT_FAILURE ; + } + + try + { + testu.setMatterQuantity(10); + } + catch ( const std::exception &e ) + { + cout << "---------------------------" << endl; + cout << " pb avec setMatterQuantity " << endl; + cout << "---------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "---------------------------" << endl; + cout << " pb avec setMatterQuantity " << endl; + cout << "---------------------------" << endl; + return EXIT_FAILURE ; + } + + try + { + testu.setCurrentStrength(10) ; + } + catch ( const std::exception &e ) + { + cout << "---------------------------" << endl; + cout << " pb avec setCurrentStrengt " << endl; + cout << "---------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "---------------------------" << endl; + cout << " pb avec setCurrentStrengt " << endl; + cout << "---------------------------" << endl; + return EXIT_FAILURE ; + } + + try + { + testu.setLightIntensity(10) ; + } + catch ( const std::exception &e ) + { + cout << "---------------------------" << endl; + cout << " pb avec setLightIntensity " << endl; + cout << "---------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "---------------------------" << endl; + cout << " pb avec setLightIntensity " << endl; + cout << "---------------------------" << endl; + return EXIT_FAILURE ; + } + + + try + { + cout << testu.getName() << endl ; + } + catch ( const std::exception &e ) + { + cout << "-----------------" << endl; + cout << " pb avec getName " << endl; + cout << "-----------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-----------------" << endl; + cout << " pb avec getName " << endl; + cout << "-----------------" << endl; + return EXIT_FAILURE ; + } + + try + { + cout << testu.getDescription() << endl ; + } + catch ( const std::exception &e ) + { + cout << "------------------------" << endl; + cout << " pb avec getDescription " << endl; + cout << "------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "------------------------" << endl; + cout << " pb avec getDescription " << endl; + cout << "------------------------" << endl; + return EXIT_FAILURE ; + } + + try + { + cout << testu.getMasse() << endl ; + } + catch ( const std::exception &e ) + { + cout << "------------------" << endl; + cout << " pb avec getMasse " << endl; + cout << "------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "------------------" << endl; + cout << " pb avec getMasse " << endl; + cout << "------------------" << endl; + return EXIT_FAILURE ; + } + + try + { + cout << testu.getLength() << endl ; + } + catch ( const std::exception &e ) + { + cout << "-------------------" << endl; + cout << " pb avec getLength " << endl; + cout << "-------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-------------------" << endl; + cout << " pb avec getLength " << endl; + cout << "-------------------" << endl; + return EXIT_FAILURE ; + } + + try + { + cout << testu.getTime() << endl ; + } + catch ( const std::exception &e ) + { + cout << "-----------------" << endl; + cout << " pb avec getTime " << endl; + cout << "-----------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "-----------------" << endl; + cout << " pb avec getTime " << endl; + cout << "-----------------" << endl; + return EXIT_FAILURE ; + } + + try + { + cout << testu.getTemperature() << endl ; + } + catch ( const std::exception &e ) + { + cout << "------------------------" << endl; + cout << " pb avec getTemperature " << endl; + cout << "------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "------------------------" << endl; + cout << " pb avec getTemperature " << endl; + cout << "------------------------" << endl; + return EXIT_FAILURE ; + } + + try + { + cout << testu.getMatterQuantity() << endl ; + } + catch ( const std::exception &e ) + { + cout << "---------------------------" << endl; + cout << " pb avec getMatterQuantity " << endl; + cout << "---------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "---------------------------" << endl; + cout << " pb avec getMatterQuantity " << endl; + cout << "---------------------------" << endl; + return EXIT_FAILURE ; + } + + try + { + cout << testu.getCurrentStrength() << endl ; + } + catch ( const std::exception &e ) + { + cout << "----------------------------" << endl; + cout << " pb avec getCurrentStrength " << endl; + cout << "----------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "----------------------------" << endl; + cout << " pb avec getCurrentStrength " << endl; + cout << "----------------------------" << endl; + return EXIT_FAILURE ; + } + + try + { + cout << testu.getLightIntensity() << endl ; + } + catch ( const std::exception &e ) + { + cout << "---------------------------" << endl; + cout << " pb avec getLightIntensity " << endl; + cout << "---------------------------" << endl; + MESSAGE( "catched exception : " << e.what() ) ; + return EXIT_FAILURE ; + } + catch (...) + { + cout << "---------------------------" << endl; + cout << " pb avec getLightIntensity " << endl; + cout << "---------------------------" << endl; + return EXIT_FAILURE ; + } + + return EXIT_SUCCESS ; + +} ; diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.cxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.cxx index 5fde249ed..fe011b004 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.cxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.cxx @@ -1,3 +1,30 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// 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_SWIG_FieldDouble.cxx +// Module : MED + +using namespace std; #include "MEDMEM_SWIG_FieldDouble.hxx" //============================================================================= @@ -26,17 +53,20 @@ FIELDDOUBLE::FIELDDOUBLE(const SUPPORT * Support, const int NumberOfComponents) END_OF("Constructor with arguments (for Python API) FIELDDOUBLE"); } -/* -FIELDDOUBLE::FIELDDOUBLE(FIELD_ *field) - : FIELD ( * (FIELD *)(field)) +//============================================================================= +/*! + * Another constructor with arguments + */ +//============================================================================= +FIELDDOUBLE::FIELDDOUBLE(const SUPPORT * Support, driverTypes driverType, + const string & fileName, + const string & fieldName) : + FIELD(Support, driverType, fileName, fieldName) { - BEGIN_OF("Constructor (for Python API) FIELDDOUBLE avec parametre"); - - SCRUTE(_value); + BEGIN_OF("Another constructor with arguments (for Python API) FIELDDOUBLE"); - END_OF("Constructor(for Python API) FIELDDOUBLE avec parametre"); + END_OF("Another constructor with arguments (for Python API) FIELDDOUBLE"); } -*/ //============================================================================= /*! * Destructor diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.hxx index 6565c0a24..c4e0a5d8d 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.hxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.hxx @@ -1,3 +1,29 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// 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_SWIG_FieldDouble.hxx +// Module : MED + #ifndef MEDMEM_SWIG_FIELDDOUBLE_HXX_ #define MEDMEM_SWIG_FIELDDOUBLE_HXX_ @@ -8,6 +34,8 @@ class FIELDDOUBLE : public FIELD public: FIELDDOUBLE(); FIELDDOUBLE(const SUPPORT * Support, const int NumberOfComponents); + FIELDDOUBLE(const SUPPORT * Support, driverTypes driverType, + const string & fileName="", const string & fieldName=""); ~FIELDDOUBLE(); }; diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.cxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.cxx index 23ce96aef..125948dbb 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.cxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.cxx @@ -1,3 +1,30 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// 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_SWIG_FieldInt.cxx +// Module : MED + +using namespace std; #include "MEDMEM_SWIG_FieldInt.hxx" //============================================================================= @@ -26,15 +53,20 @@ FIELDINT::FIELDINT(const SUPPORT * Support, const int NumberOfComponents) : FIEL END_OF("Constructor with arguments (for Python API) FIELDINT"); } -/* -FIELDINT::FIELDINT(FIELD_ * field) - : FIELD ( * (FIELD *) (field)) +//============================================================================= +/*! + * Another constructor with arguments + */ +//============================================================================= +FIELDINT::FIELDINT(const SUPPORT * Support, driverTypes driverType, + const string & fileName, + const string & fieldName) : + FIELD(Support, driverType, fileName, fieldName) { - BEGIN_OF("Constructor (for Python API) FIELDINT avec parametre"); + BEGIN_OF("Another constructor with arguments (for Python API) FIELDINT"); - END_OF("Constructor (for Python API) FIELDINT avec parametre"); + END_OF("Another constructor with arguments (for Python API) FIELDINT"); } -*/ //============================================================================= /*! * Destructor diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.hxx index 215578a2b..1393c9b78 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.hxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.hxx @@ -1,3 +1,29 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// 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_SWIG_FieldInt.hxx +// Module : MED + #ifndef MEDMEM_SWIG_FIELDINT_HXX_ #define MEDMEM_SWIG_FIELDINT_HXX_ @@ -8,6 +34,8 @@ class FIELDINT : public FIELD public: FIELDINT(); FIELDINT(const SUPPORT * Support, const int NumberOfComponents); + FIELDINT(const SUPPORT * Support, driverTypes driverType, + const string & fileName="", const string & fieldName=""); ~FIELDINT(); }; diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.cxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.cxx index 8b662aee8..69f1e777f 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.cxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.cxx @@ -1,3 +1,29 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// 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_SWIG_MedFieldDoubleDriver.cxx +// Module : MED + using namespace std; #include "MEDMEM_SWIG_MedFieldDoubleDriver.hxx" diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.hxx index 65e5d6573..8238c94e1 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.hxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.hxx @@ -1,3 +1,29 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// 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_SWIG_MedFieldDoubleDriver.hxx +// Module : MED + #ifndef MEDMEM_SWIG_MEDFIELDDOUBLEDRIVER_HXX_ #define MEDMEM_SWIG_MEDFIELDDOUBLEDRIVER_HXX_ diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.cxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.cxx index 87b25165d..8639d925f 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.cxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.cxx @@ -1,3 +1,29 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// 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_SWIG_MedFieldIntDriver.cxx +// Module : MED + using namespace std; #include "MEDMEM_SWIG_MedFieldIntDriver.hxx" diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.hxx index bb43c893f..5ba830817 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.hxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.hxx @@ -1,3 +1,29 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// 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_SWIG_MedFieldIntDriver.hxx +// Module : MED + #ifndef MEDMEM_SWIG_MEDFIELDINTDRIVER_HXX_ #define MEDMEM_SWIG_MEDFIELDINTDRIVER_HXX_ diff --git a/src/MEDMEM_SWIG/Makefile.in b/src/MEDMEM_SWIG/Makefile.in index f63f66dd0..660a00226 100644 --- a/src/MEDMEM_SWIG/Makefile.in +++ b/src/MEDMEM_SWIG/Makefile.in @@ -1,10 +1,30 @@ -#============================================================================== -# File : Makefile.in -# Author : Nadir BOUHAMOU (CEA/DEN/DM2S/SFME/LGLS) -# CVS : $Header$ -#============================================================================== +# MED MEDMEM_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Nadir BOUHAMOU (CEA/DEN/DM2S/SFME/LGLS) +# Module : MED -# source path top_srcdir=@top_srcdir@ top_builddir=../../.. srcdir=@srcdir@ @@ -16,22 +36,26 @@ EXPORT_HEADERS = \ libMEDMEM_Swig.i \ my_typemap.i \ MEDMEM_SWIG_FieldDouble.hxx \ - MEDMEM_SWIG_FieldInt.hxx + MEDMEM_SWIG_FieldInt.hxx \ + MEDMEM_SWIG_MedFieldDoubleDriver.hxx \ + MEDMEM_SWIG_MedFieldIntDriver.hxx # Libraries targets LIB = libMEDMEM_Swigcmodule.la LIB_SRC = MEDMEM_SWIG_FieldDouble.cxx \ - MEDMEM_SWIG_FieldInt.cxx + MEDMEM_SWIG_FieldInt.cxx \ + MEDMEM_SWIG_MedFieldDoubleDriver.cxx \ + MEDMEM_SWIG_MedFieldIntDriver.cxx SWIG_DEF = libMEDMEM_Swig.i -EXPORT_PYSCRIPTS = libMEDMEM_Swig.py med_test1.py med_test2.py med_test3.py +EXPORT_PYSCRIPTS = libMEDMEM_Swig.py med_test1.py med_test2.py med_test3.py med_test_grid.py med_test_skin.py medMeshing_test.py ############################################################################# -CPPFLAGS+= $(PYTHON_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) +CPPFLAGS= $(PYTHON_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I$(inc_builddir) -I$(srcdir) -I. $(CORBA_INCLUDES) CXXFLAGS=-g -D_DEBUG_ -D__x86__ -D__linux__ CXXFLAGS+=-ftemplate-depth-42 LIBS= $(PYTHON_LIBS) diff --git a/src/MEDMEM_SWIG/libMEDMEM_Swig.i b/src/MEDMEM_SWIG/libMEDMEM_Swig.i index 15550ed89..480d3a9cc 100644 --- a/src/MEDMEM_SWIG/libMEDMEM_Swig.i +++ b/src/MEDMEM_SWIG/libMEDMEM_Swig.i @@ -1,8 +1,31 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// 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 : libMEDMEM_Swig.i +// Module : MED + %module libMEDMEM_Swig -%include "typemaps.i" -%include "my_typemap.i" - %{ #include "MEDMEM_CellModel.hxx" #include "MEDMEM_GenDriver.hxx" @@ -24,17 +47,54 @@ #include "MEDMEM_Unit.hxx" #include "MEDMEM_Field.hxx" #include "MEDMEM_MedMedDriver.hxx" +#include "MEDMEM_Grid.hxx" #include "MEDMEM_SWIG_FieldDouble.hxx" #include "MEDMEM_SWIG_FieldInt.hxx" +#include "MEDMEM_SWIG_MedFieldDoubleDriver.hxx" +#include "MEDMEM_SWIG_MedFieldIntDriver.hxx" +#include "MEDMEM_Meshing.hxx" %} +%include "typemaps.i" +%include "my_typemap.i" + +/* + managing C++ exception in the Python API +*/ + +%exception +{ + try + { + $action ; + } + catch(MEDEXCEPTION& exception) + { + PyErr_SetString(PyExc_RuntimeError,exception.what()); + return NULL; + } +} + +/* + managing the use of operator= of any class by renaming it assign() + because assignment can't be overloaded in python. + + In python, you would then use + + a.assign(b) # a = b +*/ + +%rename(assign) *::operator=; + /* - enum du MED++ que l'on utilise dans l'API Python + enum of the C++ MED used in the Python API */ +typedef enum {MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED} med_grid_type; + typedef enum {MED_FULL_INTERLACE, MED_NO_INTERLACE} medModeSwitch; -typedef enum {MED_LECT,MED_ECRI,MED_REMP} med_mode_acces; +typedef enum {MED_LECT, MED_ECRI, MED_REMP} med_mode_acces; typedef enum {MED_CELL, MED_FACE, MED_EDGE, MED_NODE, MED_ALL_ENTITIES} medEntityMesh; @@ -70,13 +130,127 @@ typedef struct { int dt; int it; } DT_IT_; Class et methodes du MED++ que l'on utilise dans l'API Python */ -class CELLMODEL; +class CELLMODEL +{ + public: + CELLMODEL(); + + CELLMODEL(medGeometryElement t); + + CELLMODEL(const CELLMODEL &m); + + int getNumberOfVertexes(); + + int getNumberOfNodes(); + + int getDimension(); + + medGeometryElement getType(); + + int getNumberOfConstituents(int dim); + + int getNodeConstituent(int dim,int num,int nodes_index); + + medGeometryElement getConstituentType(int dim,int num); + + int getNumberOfConstituentsType(); + + + +/* int* getNodesConstituent(int dim,int num) const; */ + + + + + + + + + +/* medGeometryElement* getConstituentsType(int dim) const; */ + + + + + + + + + + + +/* set getAllConstituentsType() const; */ + + +/* map getNumberOfConstituentsForeachType() const; */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ~CELLMODEL(); + + %extend { + %newobject getName(); + char * getName() + { + string tmp_str = self->getName(); + char * tmp = new char[strlen(tmp_str.c_str())+1]; + strcpy(tmp,tmp_str.c_str()); + return tmp; + } + + %newobject __str__(); + const char* __str__() + { + ostrstream line; + line << "Python Printing CELLMODEL : " << *self << endl; + char * tmp = new char[strlen(line.str())+1]; + strcpy(tmp,line.str()); + return tmp; + } + } +}; class SUPPORT { public: - // SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL); - // ~SUPPORT(); + SUPPORT(); + + SUPPORT(const SUPPORT & m); + + ~SUPPORT(); void update ( void ); @@ -100,11 +274,11 @@ class SUPPORT void setGeometricType(medGeometryElement *GeometricType); - void setGeometricTypeNumber(int *GeometricTypeNumber); + void setNumberOfElements(int *NumberOfElements); - void setNumberOfEntities(int *NumberOfEntities); + void setTotalNumberOfElements(int TotalNumberOfElements); - void setTotalNumberOfEntities(int TotalNumberOfEntities); + void getBoundaryElements(); %extend { SUPPORT(MESH* Mesh, char * Name="", medEntityMesh Entity=MED_CELL) @@ -112,13 +286,23 @@ class SUPPORT return new SUPPORT(Mesh,string(Name),Entity); } + %newobject __str__(); + const char* __str__() + { + ostrstream line; + line << "Python Printing SUPPORT : " << *self << endl; + char * tmp = new char[strlen(line.str())+1]; + strcpy(tmp,line.str()); + return tmp; + } + void setpartial(char * Description, int NumberOfGeometricType, - int TotalNumberOfEntity, medGeometryElement *GeometricType, - int *NumberOfEntity, int *NumberValue) + int TotalNumberOfElements, medGeometryElement *GeometricType, + int *NumberOfElements, int *NumberValue) { self->setpartial(string(Description), NumberOfGeometricType, - TotalNumberOfEntity, GeometricType, - NumberOfEntity, NumberValue); + TotalNumberOfElements, GeometricType, + NumberOfElements, NumberValue); } void setName(char * Name) @@ -126,6 +310,7 @@ class SUPPORT self->setName(string(Name)); } + %newobject getName(); const char * getName() { string tmp_str = self->getName(); @@ -139,6 +324,7 @@ class SUPPORT self->setDescription(string(Description)); } + %newobject getDescription(); const char * getDescription() { string tmp_str = self->getDescription(); @@ -151,7 +337,7 @@ class SUPPORT { PyObject *py_list; - medGeometryElement * types = self->getTypes(); + const medGeometryElement * types = self->getTypes(); int size = self->getNumberOfTypes(); py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -165,36 +351,15 @@ class SUPPORT return NULL; } } - return Py_BuildValue("O", py_list); - } - - PyObject * getGeometricTypeNumber() - { - PyObject *py_list; - - int * GeometricTypeNumber = self->getGeometricTypeNumber(); - int size = self->getNumberOfTypes(); - py_list = PyList_New(size); - for (int i=0; i < size; i++) - { - int err = PyList_SetItem(py_list, i, - Py_BuildValue("i", - GeometricTypeNumber[i])); - if(err) - { - char * message = "Error in SUPPORT::getGeometricTypeNumber"; - PyErr_SetString(PyExc_RuntimeError, message); - return NULL; - } - } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getNumber(medGeometryElement GeometricType) { PyObject *py_list; - int * number = self->getNumber(GeometricType); + const int * number = self->getNumber(GeometricType); int size = self->getNumberOfElements(GeometricType); py_list = PyList_New(size); @@ -209,14 +374,15 @@ class SUPPORT return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getNumberIndex() { PyObject *py_list; - int * numberindex = self->getNumberIndex(); + const int * numberindex = self->getNumberIndex(); int size = (self->getNumberOfElements(MED_ALL_ELEMENTS))+1; py_list = PyList_New(size); @@ -231,7 +397,8 @@ class SUPPORT return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } } }; @@ -239,36 +406,60 @@ class SUPPORT class FAMILY : public SUPPORT { public: - // ~FAMILY(); + FAMILY(); + + FAMILY(const FAMILY & m); + + ~FAMILY(); + + FAMILY & operator=(const FAMILY &fam); void setIdentifier(int Identifier); + void setNumberOfAttributes(int NumberOfAttribute); + void setAttributesIdentifiers(int * AttributeIdentifier); + void setAttributesValues(int * AttributeValue); + void setAttributesDescriptions(string * AttributeDescription); + void setNumberOfGroups(int NumberOfGroups); + void setGroupsNames(string * GroupName); int getIdentifier() const; + int getNumberOfAttributes() const; - /* int * getAttributesIdentifiers() const;*/ - /* int * getAttributesValues() const;*/ - /* string * getAttributesDescriptions() const;*/ + int getNumberOfGroups() const; - /* string * getGroupsNames() const;*/ %extend { FAMILY(MESH* Mesh, int Identifier, char * Name, int NumberOfAttribute, int *AttributeIdentifier, int *AttributeValue, char * AttributeDescription, int NumberOfGroup, - char * GroupName) + char * GroupName, int * MEDArrayNodeFamily, + int ** MEDArrayCellFamily, int ** MEDArrayFaceFamily, + int ** MEDArrayEdgeFamily) { return new FAMILY(Mesh,Identifier,string(Name),NumberOfAttribute, AttributeIdentifier,AttributeValue, string(AttributeDescription),NumberOfGroup, - string(GroupName)); + string(GroupName), MEDArrayNodeFamily, + MEDArrayCellFamily, MEDArrayFaceFamily, + MEDArrayEdgeFamily); + } + + %newobject __str__(); + const char* __str__() + { + ostrstream line; + line << "Python Printing Family : " << *self << endl; + char * tmp = new char[strlen(line.str())+1]; + strcpy(tmp,line.str()); } + %newobject getAttributeDescription(int ); const char * getAttributeDescription(int i) { string tmp_str = self->getAttributeDescription(i); @@ -277,6 +468,7 @@ class FAMILY : public SUPPORT return tmp; } + %newobject getGroupName(int ); const char * getGroupName(int i) { string tmp_str = self->getGroupName(i); @@ -289,7 +481,7 @@ class FAMILY : public SUPPORT { PyObject *py_list; - int * attributesids = self->getAttributesIdentifiers(); + const int * attributesids = self->getAttributesIdentifiers(); int size = self->getNumberOfAttributes(); py_list = PyList_New(size); @@ -304,14 +496,15 @@ class FAMILY : public SUPPORT return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getAttributesValues() { PyObject *py_list; - int * attributesvals = self->getAttributesValues(); + const int * attributesvals = self->getAttributesValues(); int size = self->getNumberOfAttributes(); py_list = PyList_New(size); @@ -326,7 +519,8 @@ class FAMILY : public SUPPORT return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } } }; @@ -335,7 +529,8 @@ class FIELD_ { public: FIELD_(const SUPPORT * Support, const int NumberOfComponents); - // ~FIELD_(); + + ~FIELD_(); void rmDriver(int index=0); @@ -357,6 +552,9 @@ public: void setNumberOfComponents(int NumberOfComponents); int getNumberOfComponents() const; + void setNumberOfValues(int NumberOfValues); + int getNumberOfValues() const; + %extend { int addDriver(driverTypes driverType, char * fileName="Default File Name.med", @@ -371,6 +569,7 @@ public: self->setName(string(name)); } + %newobject getName(); const char * getName() { string tmp_str = self->getName(); @@ -384,14 +583,16 @@ public: self->setDescription(string(Description)); } - const char * getDescription() + %newobject getDescription(); + const char * getDescription() const { string tmp_str = self->getDescription(); char * tmp = new char[strlen(tmp_str.c_str())+1]; strcpy(tmp,tmp_str.c_str()); - return tmp; + return tmp; } + %newobject getComponentName(int ); const char * getComponentName(int i) { string tmp_str = self->getComponentName(i); @@ -405,6 +606,7 @@ public: self->setComponentName(i,string(ComponentName)); } + %newobject getComponentDescription(int ); const char * getComponentDescription(int i) { string tmp_str = self->getComponentDescription(i); @@ -418,12 +620,13 @@ public: self->setComponentDescription(i,string(ComponentDescription)); } + %newobject getMEDComponentUnit(int ); const char * getMEDComponentUnit(int i) { string tmp_str = self->getMEDComponentUnit(i); char * tmp = new char[strlen(tmp_str.c_str())+1]; strcpy(tmp,tmp_str.c_str()); - return tmp; + return tmp; } void setMEDComponentUnit(int i, char * MEDComponentUnit) @@ -436,10 +639,20 @@ public: class FIELDDOUBLE : public FIELD_ { public: - // ~FIELDDOUBLE(); + ~FIELDDOUBLE(); FIELDDOUBLE(const SUPPORT * Support, const int NumberOfComponents); + /* + WARNING: + other constructor of FIELDDOUBLE (C++ FIELD) object. + Only one constructor could be wrapped and + the others commented out when using + SWIG with a version lesser than 1.3 + */ + + FIELDDOUBLE(); + void read(int index=0); double getValueIJ(int i,int j) const; @@ -455,13 +668,12 @@ public: void deallocValue(); %extend { - /* - FIELDDOUBLE(FIELD_ * field) + FIELDDOUBLE (const SUPPORT * Support, driverTypes driverType, + char * fileName, char * fieldName) { - MESSAGE("Constructor (pour API Python) FIELDDOUBLE avec parameters"); - return (FIELDDOUBLE *) field; + return new FIELDDOUBLE(Support, driverType, string(fileName), + string(fieldName)); } - */ void write(int index=0, char * driverName="") { @@ -475,7 +687,7 @@ public: int size = (self->getNumberOfComponents())* ((self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS)); - double * value = self->getValue(Mode); + const double * value = self->getValue(Mode); py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -489,9 +701,11 @@ public: return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } + %newobject getValueI(medModeSwitch , int ); PyObject * getValueI(medModeSwitch Mode, int index) { PyObject *py_list; @@ -500,7 +714,7 @@ public: if ( Mode == MED_NO_INTERLACE ) size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS); - double * value = self->getValueI(Mode,index); + const double * value = self->getValueI(Mode,index); py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -514,7 +728,8 @@ public: return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } void allocValue2(int NumberOfComponents, int LengthValue) @@ -527,10 +742,21 @@ public: class FIELDINT : public FIELD_ { public: - // ~FIELDINT(); + ~FIELDINT(); FIELDINT(const SUPPORT * Support, const int NumberOfComponents); + /* + WARNING: + other constructor of FIELDINT (C++ FIELD) object. + other constructor of MED object. + Only one constructor could be wrapped and + the others commented out when using + SWIG with a version lesser than 1.3 + */ + + FIELDINT(); + void read(int index=0); int getValueIJ(int i,int j) const; @@ -546,13 +772,12 @@ public: void deallocValue(); %extend { - /* - FIELDINT(FIELD_ * field) + FIELDINT(const SUPPORT * Support, driverTypes driverType, + char * fileName, char * fieldName) { - MESSAGE("Constructor (pour API Python) FIELDINT avec parameters"); - return (FIELDINT *) field; + return new FIELDINT(Support, driverType, string(fileName), + string(fieldName)); } - */ void write(int index=0, char * driverName="") { @@ -566,7 +791,7 @@ public: int size = (self->getNumberOfComponents())* ((self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS)); - int * value = self->getValue(Mode); + const int * value = self->getValue(Mode); py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -580,7 +805,8 @@ public: return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getValueI(medModeSwitch Mode, int index) @@ -591,7 +817,7 @@ public: if ( Mode == MED_NO_INTERLACE ) size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS); - int * value = self->getValueI(Mode,index); + const int * value = self->getValueI(Mode,index); py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -605,7 +831,8 @@ public: return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } void allocValue2(int NumberOfComponents, int LengthValue) @@ -619,7 +846,8 @@ class GROUP : public SUPPORT { public: GROUP(); - // ~GROUP(); + + ~GROUP(); void setNumberOfFamilies(int numberOfFamilies); void setFamilies(vector Family); @@ -631,7 +859,19 @@ public: class MESH { - public : +public : + /* + WARNING: + other constructor of MESH object. + Only one constructor could be wrapped and + the others commented out when using + SWIG with a version lesser than 1.3 + */ + + MESH(); + + ~MESH(); + void rmDriver(int index=0); void read(int index=0); @@ -642,6 +882,8 @@ class MESH int getNumberOfNodes(); + bool getIsAGrid(); + const double getCoordinate(int Number, int Axis); int getNumberOfTypes(medEntityMesh Entity); @@ -654,6 +896,8 @@ class MESH int getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity); + CELLMODEL * getCellsTypes(medEntityMesh Entity); + FAMILY* getFamily(medEntityMesh Entity,int i); int getNumberOfGroups(medEntityMesh Entity); @@ -662,9 +906,29 @@ class MESH medGeometryElement getElementType(medEntityMesh Entity,int Number); - SUPPORT * getBoundaryElements(medEntityMesh Entity) ; - %extend { + %newobject getBoundaryElements(medEntityMesh ); + SUPPORT * getBoundaryElements(medEntityMesh Entity) + { + return self->getBoundaryElements(Entity); + } + + %newobject getSkin(const SUPPORT * ); + SUPPORT * getSkin(const SUPPORT * Support3D) + { + return self->getSkin(Support3D); + } + + CELLMODEL getCellType(medEntityMesh Entity,int i) + { + return self->getCellsTypes(Entity)[i]; + } + + MESH (driverTypes driverType, char * fileName, char * meshName) + { + return new MESH(driverType, string(fileName), string(meshName)); + } + int addDriver(driverTypes driverType, char * fileName="Default File Name.med", char * driverName="Default Mesh Name") @@ -683,6 +947,7 @@ class MESH self->setName(string(name)); } + %newobject getName(); const char * getName() { string tmp_str = self->getName(); @@ -691,6 +956,7 @@ class MESH return tmp; } + %newobject getCoordinatesSystem(); const char * getCoordinatesSystem() { string tmp_str = self->getCoordinatesSystem(); @@ -699,6 +965,7 @@ class MESH return tmp; } + %newobject getCoordinateName(int ); const char * getCoordinateName(int i) { string tmp_str = self->getCoordinatesNames()[i]; @@ -707,6 +974,7 @@ class MESH return tmp; } + %newobject getCoordinateUnit(int ); const char * getCoordinateUnit(int i) { string tmp_str = self->getCoordinatesUnits()[i]; @@ -714,6 +982,49 @@ class MESH strcpy(tmp,tmp_str.c_str()); return tmp; } + + PyObject * getCoordinatesNames() + { + PyObject *py_list; + const string * array = self->getCoordinatesNames(); + int size = self->getSpaceDimension(); + py_list = PyList_New(size); + for (int i=0; i < size; i++) + { + int err = PyList_SetItem(py_list, i, + Py_BuildValue("s", array[i].c_str())); + if(err) + { + char * message = "Error in MESH::getCoordinatesNames"; + PyErr_SetString(PyExc_RuntimeError, message); + return NULL; + } + } + PyObject * result = Py_BuildValue("O", py_list); + return result; + } + + PyObject * getCoordinatesUnits() + { + PyObject *py_list; + const string * array = self->getCoordinatesUnits(); + int size = self->getSpaceDimension(); + py_list = PyList_New(size); + for (int i=0; i < size; i++) + { + int err = PyList_SetItem(py_list, i, + Py_BuildValue("s", array[i].c_str())); + if(err) + { + char * message = "Error in MESH::getCoordinatesUnits"; + PyErr_SetString(PyExc_RuntimeError, message); + return NULL; + } + } + PyObject * result = Py_BuildValue("O", py_list); + return result; + } + PyObject * getCoordinates(medModeSwitch Mode) { PyObject *py_list; @@ -731,14 +1042,15 @@ class MESH return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getTypes(medEntityMesh Entity) { PyObject *py_list; - medGeometryElement * types = self->getTypes(Entity); + const medGeometryElement * types = self->getTypes(Entity); int size = self->getNumberOfTypes(Entity); py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -752,7 +1064,8 @@ class MESH return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getConnectivity(medModeSwitch Mode, @@ -761,14 +1074,14 @@ class MESH medGeometryElement Type) { PyObject *py_list; - int * connectivity = self->getConnectivity(Mode,ConnectivityType, + const int * connectivity = self->getConnectivity(Mode,ConnectivityType, Entity,Type); int nbOfElm = self->getNumberOfElements(Entity,Type); int size; if (Type == MED_ALL_ELEMENTS) { - size = self->getConnectivityIndex(ConnectivityType,Entity)[nbOfElm]; + size = self->getConnectivityIndex(ConnectivityType,Entity)[nbOfElm]-1; } else { @@ -787,14 +1100,15 @@ class MESH return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity) { PyObject *py_list; - int * connectivity_index = + const int * connectivity_index = self->getConnectivityIndex(ConnectivityType,Entity); int size = (self->getNumberOfElements(Entity,MED_ALL_ELEMENTS))+1; @@ -811,13 +1125,14 @@ class MESH return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getReverseConnectivity(medConnectivity ConnectivityType) { PyObject *py_list; - int * reverseconnectivity = + const int * reverseconnectivity = self->getReverseConnectivity(ConnectivityType); int spaceDim = self->getSpaceDimension(); int nb; @@ -836,7 +1151,7 @@ class MESH MED_ALL_ELEMENTS)); } - int size = self->getReverseConnectivityIndex(ConnectivityType)[nb]; + int size = self->getReverseConnectivityIndex(ConnectivityType)[nb]-1; py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -851,14 +1166,15 @@ class MESH return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getReverseConnectivityIndex(medConnectivity ConnectivityType) { PyObject *py_list; - int * reverseconnectivity_index = + const int * reverseconnectivity_index = self->getReverseConnectivityIndex(ConnectivityType); int size; @@ -890,70 +1206,236 @@ class MESH return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } - FIELDDOUBLE * getVolume(const SUPPORT * Support) - { - return (FIELDDOUBLE *) self->getVolume(Support); - } + %newobject getVolume(const SUPPORT * ); + FIELDDOUBLE * getVolume(const SUPPORT * Support) + { + return (FIELDDOUBLE *) self->getVolume(Support); + } - FIELDDOUBLE * getArea(const SUPPORT * Support) - { - return (FIELDDOUBLE *) self->getArea(Support); - } + %newobject getArea(const SUPPORT * ); + FIELDDOUBLE * getArea(const SUPPORT * Support) + { + return (FIELDDOUBLE *) self->getArea(Support); + } - FIELDDOUBLE * getLength(const SUPPORT * Support) - { - return (FIELDDOUBLE *) self->getLength(Support); - } + %newobject getLength(const SUPPORT * ); + FIELDDOUBLE * getLength(const SUPPORT * Support) + { + return (FIELDDOUBLE *) self->getLength(Support); + } - FIELDDOUBLE * getNormal(const SUPPORT * Support) - { - return (FIELDDOUBLE *) self->getNormal(Support); - } + %newobject getNormal(const SUPPORT * ); + FIELDDOUBLE * getNormal(const SUPPORT * Support) + { + return (FIELDDOUBLE *) self->getNormal(Support); + } - FIELDDOUBLE * getBarycenter(const SUPPORT * Support) - { - return (FIELDDOUBLE *) self->getBarycenter(Support); - } + %newobject getBarycenter(const SUPPORT * ); + FIELDDOUBLE * getBarycenter(const SUPPORT * Support) + { + return (FIELDDOUBLE *) self->getBarycenter(Support); + } } } ; -class MED +class MESHING: public MESH { - public: - MED(); +public : + MESHING(); + ~MESHING(); - ~MED(); + void setSpaceDimension (const int SpaceDimension) ; - int getNumberOfMeshes ( void ) const; + void setNumberOfNodes (const int NumberOfNodes) ; - int getNumberOfFields ( void ) const; + void setNumberOfTypes (const int NumberOfTypes, + const medEntityMesh Entity) ; + + void setTypes (const medGeometryElement * Types, + const medEntityMesh Entity) ; - void updateSupport ( void ) ; + void setNumberOfElements (const int * NumberOfElements, + const medEntityMesh Entity) ; + + void setConnectivity (const int * Connectivity, + const medEntityMesh Entity, + const medGeometryElement Type) ; + + void setConnectivities (const int * ConnectivityIndex, + const int * ConnectivityValue, + const medConnectivity ConnectivityType, + const medEntityMesh Entity) ; + + void addGroup (const GROUP & Group) ; %extend { - const char * getMeshName(int i) + void setCoordinates(const int SpaceDimension, const int NumberOfNodes, + const double * Coordinates, const char * System, + const medModeSwitch Mode) { - deque list_string = self->getMeshNames(); - char * tmp = new char[strlen(list_string[i].c_str())+1]; - strcpy(tmp,list_string[i].c_str()); - return tmp; + self->setCoordinates(SpaceDimension, NumberOfNodes, Coordinates, + string(System), Mode); } - const char * getFieldName(int i) + void setCoordinatesSystem(const char * System) { - deque list_string = self->getFieldNames(); - char * tmp = new char[strlen(list_string[i].c_str())+1]; - strcpy(tmp,list_string[i].c_str()); - return tmp; + self->setCoordinatesSystem(string(System)); } - MESH * getMesh(char * meshName) + void setCoordinateName (const char * name, const int i) { - MESH * myMesh = self->getMesh(string(meshName)); - return myMesh; + self->setCoordinateName(string(name), i); + } + + void setCoordinateUnit (const char* unit, const int i) + { + self->setCoordinateUnit (string(unit), i) ; + } + } +}; + +class GRID : public MESH +{ + public: + GRID(); + + GRID(const GRID &m); + + ~GRID(); + + int getNodeNumber(const int i, const int j=0, const int k=0); + + int getCellNumber(const int i, const int j=0, const int k=0) ; + + int getEdgeNumber(const int Axis, const int i, const int j=0, const int k=0); + + int getFaceNumber(const int Axis, const int i, const int j=0, const int k=0); + + med_grid_type getGridType(); + + int getArrayLength( const int Axis ); + + const double getArrayValue (const int Axis, const int i); + + void setGridType(med_grid_type gridType); + + %extend { + GRID(driverTypes driverType, const char * fileName="", const char * meshName="") + { + return new GRID(driverType, string(fileName), string(meshName)); + } + + PyObject * getEntityPosition(const medEntityMesh Entity, const int Number) + { + int ijk[3], Axis; + int i=0, size = self->getSpaceDimension(); + int j=0; + switch (Entity) { + case MED_CELL: + self->getCellPosition(Number, ijk[0], ijk[1], ijk[2]); + break; + case MED_NODE: + self->getNodePosition(Number, ijk[0], ijk[1], ijk[2]); + break; + case MED_FACE: + self->getFacePosition(Number, Axis, ijk[0], ijk[1], ijk[2]); + size++; + i++; + break; + case MED_EDGE: + self->getEdgePosition(Number, Axis, ijk[0], ijk[1], ijk[2]); + size++; + i++; + break; + default: + char * message = "Error in GRID::getEntityPosition: wrong Entity"; + PyErr_SetString(PyExc_RuntimeError, message); + return NULL; + } + PyObject *py_list = PyList_New( size ); + for (; i < size; ++i) + { + int err = PyList_SetItem(py_list, i, + Py_BuildValue("i", ijk[j++])); + if(err) + { + char * message = "Error in GRID::getNodePosition"; + PyErr_SetString(PyExc_RuntimeError, message); + return NULL; + } + } + if (Entity == MED_FACE || Entity == MED_EDGE) + PyList_SetItem(py_list, 0, Py_BuildValue("i", Axis)); + + PyObject * result = Py_BuildValue("O", py_list); + return result; + } + } +}; + +class MED +{ + public: + MED(); + + ~MED(); + + void rmDriver (int index=0); + + int getNumberOfMeshes ( void ) const; + + int getNumberOfFields ( void ) const; + + void updateSupport () ; + + void write (int index=0); + + %extend { + /* + WARNING: + other constructor of MED object. + Only one constructor could be wrapped and + the others commented out when using + SWIG with a version lesser than 1.3 + */ + + MED(driverTypes driverType, char * fileName) + { + return new MED(driverType,string(fileName)); + } + + int addDriver(driverTypes driverType, + char * fileName="Default File Name.med") + { + return self->addDriver(driverType,string(fileName)); + } + + %newobject getMeshName(int ); + const char * getMeshName(int i) + { + deque list_string = self->getMeshNames(); + char * tmp = new char[strlen(list_string[i].c_str())+1]; + strcpy(tmp,list_string[i].c_str()); + return tmp; + } + + %newobject getFieldName(int ); + const char * getFieldName(int i) + { + deque list_string = self->getFieldNames(); + char * tmp = new char[strlen(list_string[i].c_str())+1]; + strcpy(tmp,list_string[i].c_str()); + return tmp; + } + + MESH * getMesh(char * meshName) + { + MESH * myMesh = self->getMesh(string(meshName)); + return myMesh; } int getFieldNumberOfIteration(char * fieldName) @@ -978,29 +1460,10 @@ class MED }; /* - APPI du driver MED_MED + API de MED_MED_[RDONLY,WRONLY,RDWR]_DRIVER */ -class MED_MED_DRIVER -{ - public : - void open(); - void close(); - - virtual void write ( void ) const ; - virtual void writeFrom ( void ) const ; - virtual void read ( void ) ; - virtual void readFileStruct ( void ) ; - - %extend { - MED_MED_DRIVER(char * fileName, MED * ptrMed) - { - return new MED_MED_DRIVER(string(fileName), ptrMed); - } - } -}; - -class MED_MED_RDONLY_DRIVER : public virtual MED_MED_DRIVER +class MED_MED_RDONLY_DRIVER { public : void open(); @@ -1009,6 +1472,8 @@ class MED_MED_RDONLY_DRIVER : public virtual MED_MED_DRIVER void read ( void ) ; void readFileStruct ( void ) ; + virtual ~MED_MED_RDONLY_DRIVER(); + %extend { MED_MED_RDONLY_DRIVER(char * fileName, MED * ptrMed) { @@ -1017,7 +1482,7 @@ class MED_MED_RDONLY_DRIVER : public virtual MED_MED_DRIVER } }; -class MED_MED_WRONLY_DRIVER : public virtual MED_MED_DRIVER +class MED_MED_WRONLY_DRIVER { public : void open(); @@ -1026,6 +1491,8 @@ class MED_MED_WRONLY_DRIVER : public virtual MED_MED_DRIVER void write ( void ) const ; void writeFrom ( void ) const ; + virtual ~MED_MED_WRONLY_DRIVER(); + %extend { MED_MED_WRONLY_DRIVER(char * fileName, MED * ptrMed) { @@ -1035,8 +1502,7 @@ class MED_MED_WRONLY_DRIVER : public virtual MED_MED_DRIVER }; class MED_MED_RDWR_DRIVER : public virtual MED_MED_RDONLY_DRIVER, - public virtual MED_MED_WRONLY_DRIVER, - public virtual MED_MED_DRIVER + public virtual MED_MED_WRONLY_DRIVER { public : void open(); @@ -1047,6 +1513,8 @@ class MED_MED_RDWR_DRIVER : public virtual MED_MED_RDONLY_DRIVER, void read ( void ) ; void readFileStruct ( void ) ; + ~MED_MED_RDWR_DRIVER(); + %extend { MED_MED_RDWR_DRIVER(char * fileName, MED * ptrMed) { @@ -1056,31 +1524,27 @@ class MED_MED_RDWR_DRIVER : public virtual MED_MED_RDONLY_DRIVER, }; /* - API du driver MED_MESH + API de MED_MESH_[RDONLY,WRONLY,RDWR]_DRIVER */ -/* -class MED_MESH_DRIVER +class MED_MESH_RDONLY_DRIVER { public : - // MED_MESH_DRIVER(); - - // MED_MESH_DRIVER(const string & fileName, MESH * ptrMesh, med_mode_acces accessMode); + + ~MED_MESH_RDONLY_DRIVER(); void open(); + void close(); - // virtual void write( void ) const = 0; - // virtual void read ( void ) = 0; - - // void setMeshName(const string & meshName) ; - // string getMeshName() const ; + void write( void ) ; + + void read ( void ) ; %extend { - MED_MESH_DRIVER(char * fileName, MESH * ptrMesh, - med_mode_acces accessMode) + MED_MESH_RDONLY_DRIVER(char * fileName, MESH * ptrMesh) { - return new MED_MESH_DRIVER(string(fileName), ptrMesh, accessMode); + return new MED_MESH_RDONLY_DRIVER(string(fileName), ptrMesh); } void setMeshName(char * meshName) @@ -1088,6 +1552,7 @@ class MED_MESH_DRIVER self->setMeshName(string(meshName)); } + %newobject getMeshName(); char * getMeshName() { string tmp_str = self->getMeshName(); @@ -1097,81 +1562,299 @@ class MED_MESH_DRIVER } } }; -*/ -class MED_MESH_RDONLY_DRIVER -// : public virtual MED_MESH_DRIVER +class MED_MESH_WRONLY_DRIVER { public : - - // MED_MESH_RDONLY_DRIVER(); + ~MED_MESH_WRONLY_DRIVER(); + + void write( void ) const ; + + void read ( void ) ; + + void open(); - // MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh); + void close(); + + %extend { + MED_MESH_WRONLY_DRIVER(char * fileName, MESH * ptrMesh) + { + return new MED_MESH_WRONLY_DRIVER(string(fileName), ptrMesh); + } + + void setMeshName(char * meshName) + { + self->setMeshName(string(meshName)); + } + + %newobject getMeshName(); + char * getMeshName() + { + string tmp_str = self->getMeshName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; + } + } +}; + +class MED_MESH_RDWR_DRIVER : public virtual MED_MESH_RDONLY_DRIVER, + public virtual MED_MESH_WRONLY_DRIVER +{ + public : + + ~MED_MESH_RDWR_DRIVER(); - ~MED_MESH_RDONLY_DRIVER(); + void write(void) const ; + + void read (void) ; - int getCOORDINATE(); + void open(); - int getCONNECTIVITY(); + void close(); - int getFAMILY(); + %extend { + MED_MESH_RDWR_DRIVER(char * fileName, MESH * ptrMesh) + { + return new MED_MESH_RDWR_DRIVER(string(fileName), ptrMesh); + } - void write( void ) ; + void setMeshName(char * meshName) + { + self->setMeshName(string(meshName)); + } + + %newobject getMeshName(); + char * getMeshName() + { + string tmp_str = self->getMeshName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; + } + } +}; + +/* + API de MED_FIELDDOUBLE_[RDONLY,WRONLY,RDWR]_DRIVER +*/ + +class MED_FIELDDOUBLE_RDONLY_DRIVER +{ +public: + + ~MED_FIELDDOUBLE_RDONLY_DRIVER(); + + void open(); + + void close(); + + void write( void ) const ; void read ( void ) ; %extend { - MED_MESH_RDONLY_DRIVER(char * fileName, MESH * ptrMesh) + MED_FIELDDOUBLE_RDONLY_DRIVER(char * fileName, FIELDDOUBLE * ptrField) { - return new MED_MESH_RDONLY_DRIVER(string(fileName), ptrMesh); + return new MED_FIELDDOUBLE_RDONLY_DRIVER(string(fileName), ptrField); + } + + void setFieldName(char * fieldName) + { + self->setFieldName(string(fieldName)); + } + + %newobject getFieldName(); + char * getFieldName() + { + string tmp_str = self->getFieldName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; } } }; -class MED_MESH_WRONLY_DRIVER -// : public virtual MED_MESH_DRIVER +class MED_FIELDDOUBLE_WRONLY_DRIVER { - public : - - // MED_MESH_WRONLY_DRIVER():MED_MESH_DRIVER() {} - - // MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh); +public: - ~MED_MESH_WRONLY_DRIVER(); + ~MED_FIELDDOUBLE_WRONLY_DRIVER(); + + void open(); + + void close(); void write( void ) const ; + void read ( void ) ; - int writeCoordinates () const; - int writeConnectivities (medEntityMesh entity) const; - int writeFamilyNumbers () const; - int writeFamilies (vector & families) const; + %extend { + MED_FIELDDOUBLE_WRONLY_DRIVER(char * fileName, FIELDDOUBLE * ptrField) + { + return new MED_FIELDDOUBLE_WRONLY_DRIVER(string(fileName), ptrField); + } + + void setFieldName(char * fieldName) + { + self->setFieldName(string(fieldName)); + } + + %newobject getFieldName(); + char * getFieldName() + { + string tmp_str = self->getFieldName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; + } + } +}; + +class MED_FIELDDOUBLE_RDWR_DRIVER : public virtual MED_FIELDDOUBLE_RDONLY_DRIVER, public virtual MED_FIELDDOUBLE_WRONLY_DRIVER +{ +public: + + ~MED_FIELDDOUBLE_RDWR_DRIVER(); + + void open(); + + void close(); + + void write( void ) const ; + + void read ( void ) ; %extend { - MED_MESH_WRONLY_DRIVER(char * fileName, MESH * ptrMesh) + MED_FIELDDOUBLE_RDWR_DRIVER(char * fileName, FIELDDOUBLE * ptrField) { - return new MED_MESH_WRONLY_DRIVER(string(fileName), ptrMesh); + return new MED_FIELDDOUBLE_RDWR_DRIVER(string(fileName), ptrField); + } + + void setFieldName(char * fieldName) + { + self->setFieldName(string(fieldName)); + } + + %newobject getFieldName(); + char * getFieldName() + { + string tmp_str = self->getFieldName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; } } }; -class MED_MESH_RDWR_DRIVER : public MED_MESH_RDONLY_DRIVER, public MED_MESH_WRONLY_DRIVER +/* + API de MED_FIELDINT_[RDONLY,WRONLY,RDWR]_DRIVER +*/ + +class MED_FIELDINT_RDONLY_DRIVER { - public : +public: - // MED_MESH_RDWR_DRIVER(); + ~MED_FIELDINT_RDONLY_DRIVER(); - // MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh); + void open(); - ~MED_MESH_RDWR_DRIVER(); - - void write(void) const ; - void read (void) ; + void close(); + + void write( void ) const ; + + void read ( void ) ; %extend { - MED_MESH_RDWR_DRIVER(char * fileName, MESH * ptrMesh) + MED_FIELDINT_RDONLY_DRIVER(char * fileName, FIELDINT * ptrField) { - return new MED_MESH_RDWR_DRIVER(string(fileName), ptrMesh); + return new MED_FIELDINT_RDONLY_DRIVER(string(fileName), ptrField); + } + + void setFieldName(char * fieldName) + { + self->setFieldName(string(fieldName)); + } + + %newobject getFieldName(); + char * getFieldName() + { + string tmp_str = self->getFieldName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; + } + } +}; + +class MED_FIELDINT_WRONLY_DRIVER +{ +public: + + ~MED_FIELDINT_WRONLY_DRIVER(); + + void open(); + + void close(); + + void write( void ) const ; + + void read ( void ) ; + + %extend { + MED_FIELDINT_WRONLY_DRIVER(char * fileName, FIELDINT * ptrField) + { + return new MED_FIELDINT_WRONLY_DRIVER(string(fileName), ptrField); + } + + void setFieldName(char * fieldName) + { + self->setFieldName(string(fieldName)); + } + + %newobject getFieldName(); + char * getFieldName() + { + string tmp_str = self->getFieldName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; + } + } +}; + +class MED_FIELDINT_RDWR_DRIVER : public virtual MED_FIELDINT_RDONLY_DRIVER, public virtual MED_FIELDINT_WRONLY_DRIVER +{ +public: + + ~MED_FIELDINT_RDWR_DRIVER(); + + void open(); + + void close(); + + void write( void ) const ; + + void read ( void ) ; + + %extend { + MED_FIELDINT_RDWR_DRIVER(char * fileName, FIELDINT * ptrField) + { + return new MED_FIELDINT_RDWR_DRIVER(string(fileName), ptrField); + } + + void setFieldName(char * fieldName) + { + self->setFieldName(string(fieldName)); + } + + %newobject getFieldName(); + char * getFieldName() + { + string tmp_str = self->getFieldName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; } } }; @@ -1180,16 +1863,33 @@ FIELDDOUBLE * createFieldDoubleFromField(FIELD_ * field) ; FIELDINT * createFieldIntFromField(FIELD_ * field) ; +GRID * createGridFromMesh( MESH * aMesh ); + %{ FIELDDOUBLE * createFieldDoubleFromField(FIELD_ * field) { MESSAGE("creatFieldDoubleFromField : Constructor (for Python API) FIELDDOUBLE with parameter FIELD_"); + MESSAGE("Its returns a proper cast of the input pointer :: FIELD_ --> FIELDDOUBLE"); return (FIELDDOUBLE *) field; } FIELDINT * createFieldIntFromField(FIELD_ * field) { MESSAGE("creatFieldIntFromField : Constructor (for Python API) FIELDINT with parameter FIELD_"); + MESSAGE("Its returns a proper cast of the input pointer :: FIELD_ --> FIELDINT"); return (FIELDINT *) field; } + + GRID * createGridFromMesh( MESH * aMesh ) + { + MESSAGE("createGridFromMesh : Constructor (for Python API) GRID with parameter MESH *"); + MESSAGE("Its returns a proper cast of the input pointer :: MESH --> GRID"); + + if (aMesh->getIsAGrid()) + return (GRID *) aMesh; + + char * message = "Error in GRID(mesh): mesh is not a grid"; + PyErr_SetString(PyExc_RuntimeError, message); + return NULL; + } %} diff --git a/src/MEDMEM_SWIG/medMeshing_test.py b/src/MEDMEM_SWIG/medMeshing_test.py new file mode 100644 index 000000000..dac89e76a --- /dev/null +++ b/src/MEDMEM_SWIG/medMeshing_test.py @@ -0,0 +1,256 @@ +# MED MEDMEM_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : medMeshing_test.py +# Module : MED + +from libMEDMEM_Swig import * + +# file name to save the generated MESH(ING) + +medFileName = "toto.med" + +vtkFileName = "toto.vtk" + +myMeshing = MESHING() + +myMeshing.setName("meshing") + +# definition of the coordinates + +spaceDimension = 3 + +numberOfNodes = 19 + +coordinates = [] + +coordinate = [0.0, 0.0, 0.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [0.0, 0.0, 1.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [2.0, 0.0, 1.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [0.0, 2.0, 1.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [-2.0, 0.0, 1.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [0.0, -2.0, 1.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [1.0, 1.0, 2.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [-1.0, 1.0, 2.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [-1.0, -1.0, 2.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [1.0, -1.0, 2.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [1.0, 1.0, 3.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [-1.0, 1.0, 3.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [-1.0, -1.0, 3.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [1.0, -1.0, 3.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [1.0, 1.0, 4.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [-1.0, 1.0, 4.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [-1.0, -1.0, 4.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [1.0, -1.0, 4.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) +coordinate = [0.0, 0.0, 5.0] +coordinates.append(coordinate[0]) +coordinates.append(coordinate[1]) +coordinates.append(coordinate[2]) + +myMeshing.setCoordinates(spaceDimension,numberOfNodes,coordinates,"CARTESIAN",MED_FULL_INTERLACE) + +for i in range(spaceDimension): + unit = "cm " + if (i == 0): + name = "X " + elif (i == 1): + name = "Y " + elif (i == 2): + name = "Z " + + myMeshing.setCoordinateName(name,i) + myMeshing.setCoordinateUnit(unit,i) + +# definition of connectivities +# cell part + +numberOfTypes = 3 +entity = MED_CELL + +types = [] +numberOfElements = [] + +types.append(MED_TETRA4) +numberOfElements.append(12) + +types.append(MED_PYRA5) +numberOfElements.append(2) + +types.append(MED_HEXA8) +numberOfElements.append(2) + +myMeshing.setNumberOfTypes(numberOfTypes,entity) +myMeshing.setTypes(types,entity) +myMeshing.setNumberOfElements(numberOfElements,entity) + +connectivityTetra = [] + +connectivity = [1,2,3,6] +connectivityTetra.append(connectivity[0]) +connectivityTetra.append(connectivity[1]) +connectivityTetra.append(connectivity[2]) +connectivityTetra.append(connectivity[3]) +connectivity = [1,2,4,3] +connectivityTetra.append(connectivity[0]) +connectivityTetra.append(connectivity[1]) +connectivityTetra.append(connectivity[2]) +connectivityTetra.append(connectivity[3]) +connectivity = [1,2,5,4] +connectivityTetra.append(connectivity[0]) +connectivityTetra.append(connectivity[1]) +connectivityTetra.append(connectivity[2]) +connectivityTetra.append(connectivity[3]) +connectivity = [1,2,6,5] +connectivityTetra.append(connectivity[0]) +connectivityTetra.append(connectivity[1]) +connectivityTetra.append(connectivity[2]) +connectivityTetra.append(connectivity[3]) +connectivity = [2,7,4,3] +connectivityTetra.append(connectivity[0]) +connectivityTetra.append(connectivity[1]) +connectivityTetra.append(connectivity[2]) +connectivityTetra.append(connectivity[3]) +connectivity = [2,8,5,4] +connectivityTetra.append(connectivity[0]) +connectivityTetra.append(connectivity[1]) +connectivityTetra.append(connectivity[2]) +connectivityTetra.append(connectivity[3]) +connectivity = [2,9,6,5] +connectivityTetra.append(connectivity[0]) +connectivityTetra.append(connectivity[1]) +connectivityTetra.append(connectivity[2]) +connectivityTetra.append(connectivity[3]) +connectivity = [2,10,3,6] +connectivityTetra.append(connectivity[0]) +connectivityTetra.append(connectivity[1]) +connectivityTetra.append(connectivity[2]) +connectivityTetra.append(connectivity[3]) +connectivity = [2,7,3,10] +connectivityTetra.append(connectivity[0]) +connectivityTetra.append(connectivity[1]) +connectivityTetra.append(connectivity[2]) +connectivityTetra.append(connectivity[3]) +connectivity = [2,8,4,7] +connectivityTetra.append(connectivity[0]) +connectivityTetra.append(connectivity[1]) +connectivityTetra.append(connectivity[2]) +connectivityTetra.append(connectivity[3]) +connectivity = [2,9,5,8] +connectivityTetra.append(connectivity[0]) +connectivityTetra.append(connectivity[1]) +connectivityTetra.append(connectivity[2]) +connectivityTetra.append(connectivity[3]) +connectivity = [2,10,6,9] +connectivityTetra.append(connectivity[0]) +connectivityTetra.append(connectivity[1]) +connectivityTetra.append(connectivity[2]) +connectivityTetra.append(connectivity[3]) + +myMeshing.setConnectivity(connectivityTetra,entity,types[0]) + +connectivityPyra = [] +connectivity = [7,8,9,10,2] +connectivityPyra.append(connectivity[0]) +connectivityPyra.append(connectivity[1]) +connectivityPyra.append(connectivity[2]) +connectivityPyra.append(connectivity[3]) +connectivityPyra.append(connectivity[4]) +connectivity = [15,18,17,16,19] +connectivityPyra.append(connectivity[0]) +connectivityPyra.append(connectivity[1]) +connectivityPyra.append(connectivity[2]) +connectivityPyra.append(connectivity[3]) +connectivityPyra.append(connectivity[4]) + +myMeshing.setConnectivity(connectivityPyra,entity,types[1]) + +connectivityHexa = [] +connectivity = [11,12,13,14,7,8,9,10] +connectivityHexa.append(connectivity[0]) +connectivityHexa.append(connectivity[1]) +connectivityHexa.append(connectivity[2]) +connectivityHexa.append(connectivity[3]) +connectivityHexa.append(connectivity[4]) +connectivityHexa.append(connectivity[5]) +connectivityHexa.append(connectivity[6]) +connectivityHexa.append(connectivity[7]) +connectivity = [15,16,17,18,11,12,13,14] +connectivityHexa.append(connectivity[0]) +connectivityHexa.append(connectivity[1]) +connectivityHexa.append(connectivity[2]) +connectivityHexa.append(connectivity[3]) +connectivityHexa.append(connectivity[4]) +connectivityHexa.append(connectivity[5]) +connectivityHexa.append(connectivity[6]) +connectivityHexa.append(connectivity[7]) + +myMeshing.setConnectivity(connectivityHexa,entity,types[2]) + +# face part + +# edge part + +# saving of the generated mesh in MED and VTK format + +idMed = myMeshing.addDriver(MED_DRIVER,medFileName,myMeshing.getName()) +myMeshing.write(idMed) + +idVtk = myMeshing.addDriver(MED_DRIVER,vtkFileName,myMeshing.getName()) +myMeshing.write(idVtk) diff --git a/src/MEDMEM_SWIG/med_test1.py b/src/MEDMEM_SWIG/med_test1.py index 946f195c5..1525c9928 100644 --- a/src/MEDMEM_SWIG/med_test1.py +++ b/src/MEDMEM_SWIG/med_test1.py @@ -1,11 +1,28 @@ -################################################################################### +# MED MEDMEM_SWIG : binding of C++ implementation and Python # -# This Python script is parsing a MED file using MED Memory from SALOME platform: -# It analyses all meshes in the MED file (coordinates, connectivity of d-cells as -# well as (d-1)-cells, families). It analyses fields stored in the MED file (d is -# the space dimension). You can assume that it is a kind of MED file parser. +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org # -################################################################################### +# +# +# File : med_test1.py +# Module : MED from libMEDMEM_Swig import * from random import * @@ -392,27 +409,29 @@ if (nbMeshes>0): suppBound = mesh.getBoundaryElements(MED_FACE) nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS) print "Getting normal field on the boundary",nbElmBound - normalBound = mesh.getNormal(suppBound) - for j in range(nbElmBound): - normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1) - value1 = normalBoundJ[0] - value2 = normalBoundJ[1] - value3 = normalBoundJ[2] - norm = (value1*value1 + value2*value2 + value3*value3)**(0.5) - print " * ",normalBoundJ[:spaceDim],"norm:",norm +## normalBound = mesh.getNormal(suppBound) +## for j in range(nbElmBound): +## normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1) +## value1 = normalBoundJ[0] +## value2 = normalBoundJ[1] +## value3 = normalBoundJ[2] +## norm = (value1*value1 + value2*value2 + value3*value3)**(0.5) +## print " * ",normalBoundJ[:spaceDim],"norm:",norm elif spaceDim == 2: suppBound = mesh.getBoundaryElements(MED_EDGE) nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS) print "Getting normal field on the boundary",nbElmBound - normalBound = mesh.getNormal(suppBound) - for j in range(nbElmBound): - normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1) - value1 = normalBoundJ[0] - value2 = normalBoundJ[1] - norm = (value1*value1 + value2*value2)**(0.5) - print " * ",normalBoundJ[:spaceDim],"norm:",norm +## normalBound = mesh.getNormal(suppBound) +## for j in range(nbElmBound): +## normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1) +## value1 = normalBoundJ[0] +## value2 = normalBoundJ[1] +## norm = (value1*value1 + value2*value2)**(0.5) +## print " * ",normalBoundJ[:spaceDim],"norm:",norm print "" if (nbFields>0): + print "Updating supports in the Med Object" + md.updateSupport() print "Field(s) Analysis " for i in range(nbFields): field_name = md.getFieldName(i) diff --git a/src/MEDMEM_SWIG/med_test2.py b/src/MEDMEM_SWIG/med_test2.py index 73a5c23bb..0bbb48f81 100644 --- a/src/MEDMEM_SWIG/med_test2.py +++ b/src/MEDMEM_SWIG/med_test2.py @@ -1,12 +1,28 @@ -################################################################################### +# MED MEDMEM_SWIG : binding of C++ implementation and Python # -# This Python script is parsing a MED file using MED Memory from SALOME platform: -# It analyses all meshes in the MED file (coordinates, connectivity of d-cells as -# well as (d-1)-cells, families), it tests all fields generated ine the MESH class -# and write them in a new file , it gives only the number of fields stored in the -# MED file (d is the space dimension). +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org # -################################################################################### +# +# +# File : med_test2.py +# Module : MED from libMEDMEM_Swig import * from random import * diff --git a/src/MEDMEM_SWIG/med_test3.py b/src/MEDMEM_SWIG/med_test3.py index 9822fc08e..c179f07d8 100644 --- a/src/MEDMEM_SWIG/med_test3.py +++ b/src/MEDMEM_SWIG/med_test3.py @@ -1,9 +1,28 @@ -################################################################################### +# MED MEDMEM_SWIG : binding of C++ implementation and Python # -# This Python script is parsing a MED file using MED Memory from SALOME platform: -# It tests the setValue(I) function on MED fields +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org # -################################################################################### +# +# +# File : med_test3.py +# Module : MED from libMEDMEM_Swig import * from random import * diff --git a/src/MEDMEM_SWIG/med_test_grid.py b/src/MEDMEM_SWIG/med_test_grid.py new file mode 100755 index 000000000..0c4ecad4d --- /dev/null +++ b/src/MEDMEM_SWIG/med_test_grid.py @@ -0,0 +1,318 @@ +# MED MEDMEM_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : med_test_grid.py +# Module : MED + +#% Test structured mesh (GRID) reading from file test19.med +#% test19.med can be obtained by running test19_c.out executable + +from libMEDMEM_Swig import * + +medFile = "test19.med" +print "Read file", medFile + +md = MED() + +mdDriver = MED_MED_RDONLY_DRIVER(medFile,md) + +mdDriver.open() +mdDriver.readFileStruct() +mdDriver.close() + +nbMeshes = md.getNumberOfMeshes() +print "Nb meshes:", nbMeshes +if nbMeshes == 0: + raise RuntimeError, "Can't read med file" + +############################## +# test "CartGrid" +############################## + +mesh_name = md.getMeshName(0) +mesh = md.getMesh(mesh_name) +print "Read", mesh_name +mesh.read() + +if mesh.getIsAGrid() == 0: + raise RuntimeError, "Mesh 0 is not a grid" + +grid = createGridFromMesh(mesh) + +I = grid.getArrayLength(1) +print "_iArrayLength", I +if I != 4: + raise RuntimeError, "Error in grid.getArrayLength(1)" + +J = grid.getArrayLength(2) +print "_jArrayLength", J +if J != 4: + raise RuntimeError, "Error in grid.getArrayLength(2)" + +K = grid.getArrayLength(3) +print "_kArrayLength", K +if K != 0: + raise RuntimeError, "Error in grid.getArrayLength(3)" + +grid_type = grid.getGridType() +print "grid_type =", grid_type +if grid_type != MED_CARTESIAN: + raise RuntimeError, "Wrong grid type" + +spaceDim = grid.getSpaceDimension() +print "spaceDim =", spaceDim +if spaceDim != 2: + raise RuntimeError, "Wrong space dimention" + +meshDim = grid.getMeshDimension() +print "meshDim =", meshDim +if spaceDim != meshDim: + raise RuntimeError, "Wrong mesh dimention" + +nbNodes = grid.getNumberOfNodes() +print "nbNodes =", nbNodes +if nbNodes != 16: + raise RuntimeError, "Wrong nb of nodes" + +coordSyst = grid.getCoordinatesSystem() +print "coordSyst =", coordSyst +if coordSyst != "CARTESIAN": + raise RuntimeError, "Wrong coordinates system" + +coordinates = grid.getCoordinates(MED_FULL_INTERLACE) +print "coordinates =", coordinates +xy = [ grid.getArrayValue(1, I-1 ) , grid.getArrayValue(2, J-1 ) ] +xy2 = coordinates[(nbNodes-1)*spaceDim:(nbNodes*spaceDim)] +if xy != xy2: + raise RuntimeError, "Error in grid.getCoordinates(MED_FULL_INTERLACE)" + +nbTypesCell = grid.getNumberOfTypes(MED_CELL) +print "nbTypesCell =", nbTypesCell +if nbTypesCell != 1: + raise RuntimeError, "Wrong nbTypesCell" + +types = grid.getTypes(MED_CELL) +print "Cell types =", types +if types != [204]: + raise RuntimeError, "Wrong Cell types" + +nbElemType = grid.getNumberOfElements(MED_CELL,types[0]) +print "Nb cells =", nbElemType +if nbElemType != 9: + raise RuntimeError, "Wrong Nb cells" + +print "getEntityPosition : convert node number to i,j,k" + +n1 = grid.getEntityPosition(MED_NODE,10) +n2 = grid.getEntityPosition(MED_NODE,16) + +if n1 == [1,2]: o1 = "Ok" +else: o1 = "KO" +if n2 == [3,3]: o2 = "Ok" +else: o2 = "KO" + +print "Node 10 -> i,j = ", n1, " : ", o1 +print "Node 16 -> i,j = ", n2, " : ", o2 + +print "getEntityPosition : convert cell number to i,j,k" + +n1 = grid.getEntityPosition(MED_CELL,3) +n2 = grid.getEntityPosition(MED_CELL,4) + +if n1 == [2,0]: o1 = "Ok" +else: o1 = "KO" +if n2 == [0,1]: o2 = "Ok" +else: o2 = "KO" + +print "Cell 3 -> i,j = ", n1, " : ", o1 +print "Cell 4 -> i,j = ", n2, " : ", o2 + +print "getEntityPosition : convert face number to i,j,k" + +n1 = grid.getEntityPosition(MED_FACE,6) +n2 = grid.getEntityPosition(MED_FACE,8) + +if n1 == [1,2,1]: o1 = "Ok" +else: o1 = "KO" +if n2 == [1,1,2]: o2 = "Ok" +else: o2 = "KO" + +print "Face 6 -> i,j = ", n1, " : ", o1 +print "Face 8 -> i,j = ", n2, " : ", o2 + +print "getNodeNumber : convert i,j,k to node number" + +n1 = grid.getNodeNumber(2,1,0) +n2 = grid.getNodeNumber(1,2,0) + +if n1 == 7: o1 = "Ok" +else: o1 = "KO" +if n2 == 10: o2 = "Ok" +else: o2 = "KO" + +print "getNodeNumber 2,1,0 = ", n1, " : ", o1 +print "getNodeNumber 1,2,0 = ", n2, " : ", o2 + +print "getCellNumber : convert i,j,k to cell number" + +n1 = grid.getCellNumber(1,0,0) +n2 = grid.getCellNumber(2,1,0) + +if n1 == 2: o1 = "Ok" +else: o1 = "KO" +if n2 == 6: o2 = "Ok" +else: o2 = "KO" + +print "getCellNumber 1,0,0 = ", n1, " : ", o1 +print "getCellNumber 2,1,0 = ", n2, " : ", o2 + +print "getFaceNumber : convert i,j,k to face number" + +n1 = grid.getFaceNumber(0,0,2,0) +n2 = grid.getFaceNumber(0,1,1,0) + +if n1 == 7: o1 = "Ok" +else: o1 = "KO" +if n2 == 5: o2 = "Ok" +else: o2 = "KO" + +print "getFaceNumber 1,0,2,0 = ", n1, " : ", o1 +print "getFaceNumber 1,1,1,0 = ", n2, " : ", o2 + +print "Connectivity" +n1 = grid.getNodeNumber(0,0,0) +n2 = grid.getNodeNumber(1,0,0) +n3 = grid.getNodeNumber(1,1,0) +n4 = grid.getNodeNumber(0,1,0) + +conn1 = [n1,n2,n3,n4] + +Connectivity = grid.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,types[0]) +print "connectivity =", Connectivity + +print "Cell 1 nodes:", conn1, Connectivity[0:4] +if conn1 != Connectivity[0:4]: + raise RuntimeError, "Wrong nodal connectivity" + + +ReverseConnectivity = grid.getReverseConnectivity(MED_NODAL) +ReverseConnectivityIndex = grid.getReverseConnectivityIndex(MED_NODAL) +n = 6 +beg = ReverseConnectivityIndex[n-1]-1 +end = ReverseConnectivityIndex[n]-1 +print "Node",n,"rev connectivity =",ReverseConnectivity[beg:end] +if end-beg != 4: + raise RuntimeError, "Wrong reverse connectivity" +if ReverseConnectivity[beg] != 1: + raise RuntimeError, "Wrong reverse connectivity" + + +grid.calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL) +Connectivity = grid.getConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS) +ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,MED_CELL) +n = 1 +beg = ConnectivityIndex[n-1]-1 +end = ConnectivityIndex[n]-1 +print "Element",n,"descending connectivity -->",Connectivity[beg:end] +if Connectivity[beg:end] != [1, 4, 13, 14]: + raise RuntimeError, "Wrong descending connectivity" + +print "getReverseConnectivity(MED_DESCENDING)", grid.getReverseConnectivity(MED_DESCENDING) +print "grid.getReverseConnectivityIndex(MED_DESCENDING)",grid.getReverseConnectivityIndex(MED_DESCENDING) + +############################## +# test "bodyfitted" +############################## + +mesh_name = md.getMeshName(1) +mesh = md.getMesh(mesh_name) +print "Read", mesh_name +mesh.read() + +if mesh.getIsAGrid() == 0: + raise RuntimeError, "Mesh 1 is not a grid" + +grid = createGridFromMesh(mesh) + +I = grid.getArrayLength(1) +print "_iArrayLength", I +if I != 2: + raise RuntimeError, "Error in grid.getArrayLength(1)" + +J = grid.getArrayLength(2) +print "_jArrayLength", J +if J != 2: + raise RuntimeError, "Error in grid.getArrayLength(2)" + +K = grid.getArrayLength(3) +print "_kArrayLength", K +if K != 0: + raise RuntimeError, "Error in grid.getArrayLength(3)" + +grid_type = grid.getGridType() +print "grid_type =", grid_type +if grid_type != MED_BODY_FITTED: + raise RuntimeError, "Wrong grid type" + +spaceDim = grid.getSpaceDimension() +print "spaceDim =", spaceDim +if spaceDim != 2: + raise RuntimeError, "Wrong space dimention" + +meshDim = grid.getMeshDimension() +print "meshDim =", meshDim +if spaceDim != meshDim: + raise RuntimeError, "Wrong mesh dimention" + +nbNodes = grid.getNumberOfNodes() +print "nbNodes =", nbNodes +if nbNodes != 4: + raise RuntimeError, "Wrong nb of nodes" + +coordSyst = grid.getCoordinatesSystem() +print "coordSyst =", coordSyst +if coordSyst != "CARTESIAN": + raise RuntimeError, "Wrong coordinates system" + +nbTypesCell = grid.getNumberOfTypes(MED_CELL) +print "nbTypesCell =", nbTypesCell +if nbTypesCell != 1: + raise RuntimeError, "Wrong nbTypesCell" + +types = grid.getTypes(MED_CELL) +print "Cell types =", types +if types != [204]: + raise RuntimeError, "Wrong Cell types" + +nbElemType = grid.getNumberOfElements(MED_CELL,types[0]) +print "Nb cells =", nbElemType +if nbElemType != 1: + raise RuntimeError, "Wrong Nb cells" + +Connectivity = grid.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,types[0]) +print "connectivity =", Connectivity +n1 = grid.getNodeNumber(0,0,0) +n2 = grid.getNodeNumber(1,0,0) +n3 = grid.getNodeNumber(1,1,0) +n4 = grid.getNodeNumber(0,1,0) +conn1 = [n1,n2,n3,n4] +print "Cell 1 nodes:", conn1, Connectivity[0:4] +if conn1 != Connectivity[0:4]: + raise RuntimeError, "Wrong nodal connectivity" + +############################################## +# test "maa1" which in fact is not a pure GRID +############################################## + +mesh_name = md.getMeshName(2) +mesh = md.getMesh(mesh_name) +print "Read", mesh_name +mesh.read() + +if mesh.getIsAGrid() == 0: + print "Mesh ",mesh_name," is not a grid" + +print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/med_test_skin.py b/src/MEDMEM_SWIG/med_test_skin.py new file mode 100644 index 000000000..df3864b29 --- /dev/null +++ b/src/MEDMEM_SWIG/med_test_skin.py @@ -0,0 +1,75 @@ +# MED MEDMEM_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : med_test_skin.py +# Module : MED + +#% Test function MESH::getSkin() on mesh from file cube_hexa8_quad4.med +#% The med file can be obtained by running create_mesh_c3h8q4 executable + +from libMEDMEM_Swig import * + +medFile = "cube_hexa8_quad4.med" + +md = MED() + +mdDriver = MED_MED_RDONLY_DRIVER(medFile,md) + +print "" +print "Read file", medFile +print "" + +mdDriver.open() +mdDriver.readFileStruct() +mdDriver.close() + +mesh_name = md.getMeshName(0) +mesh = md.getMesh(mesh_name) +mesh.read() + +print "Building the support on all (8) Cells of the mesh." +supportCell = SUPPORT(mesh) +supportCell.update() + +print "Getting skin of an all cell support" + +supportSkin = mesh.getSkin(supportCell) +faceNumbers = supportSkin.getNumber( supportSkin.getTypes()[0] ) +print "--------", faceNumbers +if faceNumbers != [2, 3, 6, 8, 10, 11, 12, 13, 16, 17, 19, 20, 22, 23, 24, 27, 28, 29, 30, 31, 32, 34, 35, 36]: + raise RuntimeError, "Wrong skin of an all cell support" + +print "Build the support on 1 Cell (#8) of the mesh." +supportCell.setAll( 0 ) +nbGeomTypes = 1 +nbTotalEntity = 1 +GeometricType = mesh.getTypes(MED_CELL) +nbEntityList = [1, 2] +EntityNbs = [8] +supportCell.setpartial("1 Cell support",nbGeomTypes,nbTotalEntity,GeometricType,nbEntityList,EntityNbs) + +print "Getting skin of 1 cell support" +supportSkin = mesh.getSkin(supportCell) +faceNumbers = supportSkin.getNumber( supportSkin.getTypes()[0] ) +print "Skin Support FACE numbers:" +print "--------", faceNumbers +if faceNumbers != [18, 26, 33, 34, 35, 36]: + raise RuntimeError, "Wrong skin of 1 cell support" + + + +print "Building the support on 2 Cells (#1 #2) of the mesh." +nbTotalEntity = 2 +nbEntityList = [1, 3] +EntityNbs = [1, 2] +supportCell.setpartial("2 Cell support",nbGeomTypes,nbTotalEntity,GeometricType,nbEntityList,EntityNbs) + +print "Getting skin of 2 cell support" +supportSkin = mesh.getSkin(supportCell) +faceNumbers = supportSkin.getNumber( supportSkin.getTypes()[0] ) +print "Skin Support FACE numbers:", faceNumbers +if faceNumbers != [1, 2, 3, 4, 6, 7, 8, 9, 10, 11]: + raise RuntimeError, "Wrong skin of 2 cells support" diff --git a/src/MEDMEM_SWIG/my_typemap.i b/src/MEDMEM_SWIG/my_typemap.i index c183ed863..a9a1b07e6 100644 --- a/src/MEDMEM_SWIG/my_typemap.i +++ b/src/MEDMEM_SWIG/my_typemap.i @@ -1,9 +1,59 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// 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 : my_typemap.i +// Module : MED + %{ #include %} +%typemap(python,in) string * { + /* Check if is a list */ + if (PyList_Check($source)) { + int size = PyList_Size($source); + int i = 0; + $target = new string[size]; + for (i = 0; i < size; i++) { + PyObject *o = PyList_GetItem($source,i); + if (PyString_Check(o)) + $target[i] = string(PyString_AsString(PyList_GetItem($source,i))); + else { + PyErr_SetString(PyExc_TypeError,"list must contain strings"); + free($target); + return NULL; + } + } + // $target[i] = 0; + } else { + PyErr_SetString(PyExc_TypeError,"not a list"); + return NULL; + } +} + %typemap(python,in) double * { + /* typemap in for double * */ /* Check if is a list */ if (PyList_Check($input)) { int size = PyList_Size($input); @@ -29,6 +79,7 @@ %typemap(python,in) int * { + /* typemap in for int * */ /* Check if is a list */ if (PyList_Check($input)) { int size = PyList_Size($input); @@ -55,6 +106,7 @@ %typemap(python,in) medGeometryElement * { + /* typemap in for medGeometryElement * */ /* Check if is a list */ if (PyList_Check($input)) { int size = PyList_Size($input); @@ -78,7 +130,6 @@ } } - %typemap(python,out) list { int i; list::iterator iL; @@ -87,3 +138,18 @@ for (i=0, iL=$1->begin(); iL!=$1->end(); i++, iL++) PyList_SetItem($result,i,PyString_FromString((*iL).c_str())); } + +%typemap(freearg) int * { + /* free the memory allocated in the typemap in for int * */ + free($1); +} + +%typemap(freearg) double * { + /* free the memory allocated in the typemap in for double * */ + free($1); +} + +%typemap(freearg) medGeometryElement * { + /* free the memory allocated in the typemap in for medGeometryElement * */ + free($1); +} diff --git a/src/Makefile.in b/src/Makefile.in index 177d2d102..f7e8fc446 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,13 +1,29 @@ -#============================================================================== -# File : Makefile.in -# Created : ven déc 7 13:32:20 CET 2001 -# Author : Paul RASCLE, EDF -# Project : SALOME -# Copyright : EDF 2001 +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Paul RASCLE, EDF +# Module : MED # $Header$ -#============================================================================== -# source path top_srcdir=@top_srcdir@ top_builddir=../.. srcdir=@srcdir@ diff --git a/src/MedCorba_Swig/Makefile.in b/src/MedCorba_Swig/Makefile.in index 981b2377f..5a128a940 100644 --- a/src/MedCorba_Swig/Makefile.in +++ b/src/MedCorba_Swig/Makefile.in @@ -1,10 +1,30 @@ -#============================================================================== -# File : Makefile.in -# Author : Nadir BOUHAMOU (CEA/DEN/DM2S/SFME/LGLS) -# CVS : $Header$ -#============================================================================== +# MED MedCorba_Swig : binding of MED CORBA objects woth Python +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Nadir BOUHAMOU (CEA/DEN/DM2S/SFME/LGLS) +# Module : MED -# source path top_srcdir=@top_srcdir@ top_builddir=../../.. srcdir=@srcdir@ diff --git a/src/MedCorba_Swig/batchmode_medcorba_test.py b/src/MedCorba_Swig/batchmode_medcorba_test.py index 8d08b2a34..9fd16c2e9 100755 --- a/src/MedCorba_Swig/batchmode_medcorba_test.py +++ b/src/MedCorba_Swig/batchmode_medcorba_test.py @@ -1,3 +1,12 @@ +# MED MedCorba_Swig : binding of MED CORBA objects woth Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : batchmode_medcorba_test.py +# Module : MED + import batchmode_salome import SALOME_MED diff --git a/src/MedCorba_Swig/libMedCorba_Swig.i b/src/MedCorba_Swig/libMedCorba_Swig.i index 9f4ff66ad..756fddeb6 100644 --- a/src/MedCorba_Swig/libMedCorba_Swig.i +++ b/src/MedCorba_Swig/libMedCorba_Swig.i @@ -1,3 +1,29 @@ +// MED MedCorba_Swig : binding of MED CORBA objects woth Python +// +// 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 : libMedCorba_Swig.i +// Module : MED + %module libMedCorba_Swig %include "libMEDMEM_Swig.i" diff --git a/src/MedCorba_Swig/medcorba_test.py b/src/MedCorba_Swig/medcorba_test.py index bbbe8c0a9..2bf6fd6a6 100644 --- a/src/MedCorba_Swig/medcorba_test.py +++ b/src/MedCorba_Swig/medcorba_test.py @@ -1,3 +1,29 @@ +# MED MedCorba_Swig : binding of MED CORBA objects woth Python +# +# 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 : medcorba_test.py +# Module : MED + import salome import SALOME_MED diff --git a/src/MedMem/Family_i.cxx b/src/MedMem/Family_i.cxx index 90449209c..81d51782a 100644 --- a/src/MedMem/Family_i.cxx +++ b/src/MedMem/Family_i.cxx @@ -1,11 +1,32 @@ -//============================================================================= -// File : Family_i.cxx -// Project : SALOME -// Copyright : EDF 2002 -// Author : EDF -// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Family_i.cxx -//============================================================================= +// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM +// +// 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 : Family_i.cxx +// Author : EDF +// Module : MED +// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Family_i.cxx +using namespace std; #include "Family_i.hxx" #include "utilities.h" diff --git a/src/MedMem/Family_i.hxx b/src/MedMem/Family_i.hxx index 11a9b3e7c..8a1ae3153 100644 --- a/src/MedMem/Family_i.hxx +++ b/src/MedMem/Family_i.hxx @@ -1,10 +1,31 @@ -//============================================================================= -// File : Family_i.hxx -// Project : SALOME -// Copyright : EDF 2002 -// Author : EDF -// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Family_i.hxx -//============================================================================= +// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM +// +// 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 : Family_i.hxx +// Author : EDF +// Module : MED +// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Family_i.hxx + #ifndef MED_FAMILY_I_HXX_ #define MED_FAMILY_I_HXX_ diff --git a/src/MedMem/FieldDouble_i.cxx b/src/MedMem/FieldDouble_i.cxx index 535094feb..d44257488 100644 --- a/src/MedMem/FieldDouble_i.cxx +++ b/src/MedMem/FieldDouble_i.cxx @@ -1,11 +1,32 @@ -//============================================================================= -// File : Fielddouble_i.hxx -// Project : SALOME -// Author : EDF -// Copyright : EDF 2002 -// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fielddouble_i.hxx -//============================================================================= +// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM +// +// 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 : Fielddouble_i.hxx +// Author : EDF +// Module : MED +// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fielddouble_i.hxx +using namespace std; #include "FieldDouble_i.hxx" #include "utilities.h" #include "convert.hxx" @@ -84,7 +105,7 @@ throw (SALOME::SALOME_Exception) } medModeSwitch modemed=convertIdlModeToMedMode(mode); - double * values =_fieldTptr->getValue(modemed); + const double * values =_fieldTptr->getValue(modemed); myseq->length(nbval); for (int i=0; igetValue(modemed); + const int * values =_fieldTptr->getValue(modemed); myseq->length(nbval); for (int i=0; igetNumberOfComponents(); myseq->length(nbcom); - string * namecom=_fieldTptr->getComponentsNames(); + const string * namecom=_fieldTptr->getComponentsNames(); for (int i=0;igetNumberOfComponents(); myseq->length(nbcom); - string * unitcom=_fieldTptr->getMEDComponentsUnits(); + const string * unitcom=_fieldTptr->getMEDComponentsUnits(); for (int i=0;i #include "utilities.h" diff --git a/src/MedMem/Group_i.hxx b/src/MedMem/Group_i.hxx index 12419693b..35dc8828c 100644 --- a/src/MedMem/Group_i.hxx +++ b/src/MedMem/Group_i.hxx @@ -1,10 +1,31 @@ -//============================================================================= -// File : Group_i.hxx -// Project : SALOME -// Author : EDF -// Copyright : EDF 2002 -// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Group_i.hxx -//============================================================================= +// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM +// +// 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 : Group_i.hxx +// Author : EDF +// Module : MED +// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Group_i.hxx + #ifndef MED_GROUP_I_HXX_ #define MED_GROUP_I_HXX_ diff --git a/src/MedMem/Makefile.in b/src/MedMem/Makefile.in index c0a9b3400..76bc6afec 100644 --- a/src/MedMem/Makefile.in +++ b/src/MedMem/Makefile.in @@ -1,11 +1,31 @@ -#============================================================================== -// File : Field_i.hxx -// Author : Marc Tajchman -// Project : SALOME -// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Makefile.in -//============================================================================= - -# source path +# MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM +# +# 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 : Field_i.hxx +# Author : Marc Tajchman +# Module : MED +# $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Makefile.in + top_srcdir=@top_srcdir@ top_builddir=../../.. srcdir=@srcdir@ @@ -46,7 +66,7 @@ BIN_CLIENT_IDL = CPPFLAGS+= $(MED2_INCLUDES) $(HDF5_INCLUDES) CXXFLAGS=-g -D_DEBUG_ -D__x86__ -D__linux__ -LDFLAGS+=-lmedmem -lOpUtil +LDFLAGS+= $(MED2_LIBS) -lmedmem -lOpUtil #LDFLAGS+=-lmedmem -L. -lSalomeContainer -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification # does we put only -lSalomeContainer and compiler retrieves -lSalomeNS -lRegistry -lOpUtil ???? diff --git a/src/MedMem/Med_i.cxx b/src/MedMem/Med_i.cxx index 1ed42bc64..aad46e39a 100644 --- a/src/MedMem/Med_i.cxx +++ b/src/MedMem/Med_i.cxx @@ -1,11 +1,32 @@ -//============================================================================= -// File : Med_i.cxx -// Project : SALOME -// Author : EDF -// Copyright : EDF 2002 -// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Med_i.cxx -//============================================================================= - +// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : Med_i.cxx +// Author : EDF +// Module : MED +// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Med_i.cxx + +using namespace std; #include //#include "MEDMEM_Field.hxx" @@ -201,6 +222,36 @@ void MED_i::initWithFieldType(SALOMEDS::Study_ptr myStudy,driverTypes driverType // SUPPORT : _med->updateSupport() ; + + // we add all group and family in study : + // we add all families + vector familyVector ; + vector::iterator familyVectorIt ; + // we add all groups + vector groupVector ; + vector::iterator groupVectorIt ; + + MED_FR::MESH_ENTITIES::const_iterator currentEntity; + for (int i=0; igetMesh(meshesNames[i]) ; + for (currentEntity=MED_FR::meshEntities.begin();currentEntity != MED_FR::meshEntities.end(); currentEntity++) { + // family : + familyVector = ptrMesh->getFamilies((MED_EN::medEntityMesh)(*currentEntity).first) ; + for(familyVectorIt=familyVector.begin();familyVectorIt!=familyVector.end();familyVectorIt++) { + FAMILY_i * myFamilyI = new FAMILY_i(*familyVectorIt); + SALOME_MED::FAMILY_ptr myFamilyIOR = myFamilyI->POA_SALOME_MED::FAMILY::_this() ; + myFamilyI->addInStudy(myStudy,myFamilyIOR) ; + } + // group : + groupVector = ptrMesh->getGroups((MED_EN::medEntityMesh)(*currentEntity).first) ; + for(groupVectorIt=groupVector.begin();groupVectorIt!=groupVector.end();groupVectorIt++) { + GROUP_i * myGroupI = new GROUP_i(*groupVectorIt); + SALOME_MED::GROUP_ptr myGroupIOR = myGroupI->POA_SALOME_MED::GROUP::_this() ; + myGroupI->addInStudy(myStudy,myGroupIOR) ; + } + } + } + for (int i=0; i mySupports = _med->getSupports(meshesNames[i]) ; map::const_iterator itSupport ; diff --git a/src/MedMem/Med_i.hxx b/src/MedMem/Med_i.hxx index 73ada6153..fb006e63e 100644 --- a/src/MedMem/Med_i.hxx +++ b/src/MedMem/Med_i.hxx @@ -1,10 +1,30 @@ -//============================================================================= -// File : Med_i.hxx -// Project : SALOME -// Author : EDF -// Copyright : EDF 2002 -// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Med_i.hxx -//============================================================================= +// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : Med_i.hxx +// Author : EDF +// Module : MED +// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Med_i.hxx #ifndef _MED_MED_I_HXX_ #define _MED_MED_I_HXX_ diff --git a/src/MedMem/Mesh_i.cxx b/src/MedMem/Mesh_i.cxx index c77bfc3f4..b188ea65b 100644 --- a/src/MedMem/Mesh_i.cxx +++ b/src/MedMem/Mesh_i.cxx @@ -1,11 +1,32 @@ -//============================================================================= -// File : Mesh_i.cxx -// Project : SALOME -// Author : EDF -// Copyright : EDF 2002 -// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Mesh_i.cxx -//============================================================================= +// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM +// +// 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 : Mesh_i.cxx +// Author : EDF +// Module : MED +// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Mesh_i.cxx +using namespace std; #include #include "utilities.h" @@ -243,7 +264,7 @@ throw (SALOME::SALOME_Exception) try { int spaceDimension=_mesh->getSpaceDimension(); - string * coordinatesName =_mesh->getCoordinatesNames(); + const string * coordinatesName =_mesh->getCoordinatesNames(); myseq->length(spaceDimension); for (int i=0; igetSpaceDimension(); - string * coordinatesUnits =_mesh->getCoordinatesUnits(); + const string * coordinatesUnits =_mesh->getCoordinatesUnits(); myseq->length(spaceDimension); for (int i=0; igetNumberOfTypes(convertIdlEntToMedEnt(entity)); - medGeometryElement * elemts =_mesh->getTypes( + const medGeometryElement * elemts =_mesh->getTypes( convertIdlEntToMedEnt(entity)); myseq->length(nbTypes); for (int i=0; igetConnectivityIndex( + const int * tab=_mesh->getConnectivityIndex( convertIdlConnToMedConn(mode), convertIdlEntToMedEnt(entity)); - nbelements = tab[elt1 ] - 1 ; + nbelements = elt1*(convertIdlEltToMedElt(geomElement)%100); + //nbelements = tab[elt1 ] - 1 ; } SCRUTE(entity); SCRUTE(geomElement); SCRUTE(nbelements); myseq->length(nbelements); - int * numbers=_mesh->getConnectivity(convertIdlModeToMedMode(typeSwitch), + const int * numbers=_mesh->getConnectivity(convertIdlModeToMedMode(typeSwitch), convertIdlConnToMedConn(mode), convertIdlEntToMedEnt(entity), convertIdlEltToMedElt(geomElement)); @@ -481,7 +503,7 @@ throw (SALOME::SALOME_Exception) convertIdlEntToMedEnt(entity), MED_ALL_ELEMENTS); myseq->length(nbelements); - int * numbers=_mesh->getConnectivityIndex(convertIdlConnToMedConn(mode), + const int * numbers=_mesh->getConnectivityIndex(convertIdlConnToMedConn(mode), convertIdlEntToMedEnt(entity)); for (int i=0;ilength(nbelements); - int * numbers=_mesh->getReverseConnectivity(convertIdlConnToMedConn(mode)); + const int * numbers=_mesh->getReverseConnectivity(convertIdlConnToMedConn(mode)); for (int i=0;ilength(nbelements); - int * numbers=_mesh->getReverseConnectivityIndex(convertIdlConnToMedConn(mode)); + const int * numbers=_mesh->getReverseConnectivityIndex(convertIdlConnToMedConn(mode)); for (int i=0;igetFamily(convertIdlEntToMedEnt(entity),i); + const FAMILY * fam = _mesh->getFamily(convertIdlEntToMedEnt(entity),i); FAMILY_i * f1=new FAMILY_i(fam); SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this(); f1->_remove_ref(); @@ -771,7 +793,7 @@ throw (SALOME::SALOME_Exception) SALOME::INTERNAL_ERROR); try { - GROUP * grou = _mesh->getGroup(convertIdlEntToMedEnt(entity),i); + const GROUP * grou = _mesh->getGroup(convertIdlEntToMedEnt(entity),i); GROUP_i * f1=new GROUP_i(grou); SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this(); f1->_remove_ref(); diff --git a/src/MedMem/Mesh_i.hxx b/src/MedMem/Mesh_i.hxx index 1b074294b..68429440e 100644 --- a/src/MedMem/Mesh_i.hxx +++ b/src/MedMem/Mesh_i.hxx @@ -1,10 +1,30 @@ -//============================================================================= -// File : Mesh_i.hxx -// Project : SALOME -// Author : EDF -// Copyright : EDF 2002 -// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Mesh_i.hxx -//============================================================================= +// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM +// +// 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 : Mesh_i.hxx +// Author : EDF +// Module : MED +// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Mesh_i.hxx #ifndef _MED_MESH_I_HXX_ #define _MED_MESH_I_HXX_ diff --git a/src/MedMem/Support_i.cxx b/src/MedMem/Support_i.cxx index e13784592..f76176f29 100644 --- a/src/MedMem/Support_i.cxx +++ b/src/MedMem/Support_i.cxx @@ -1,11 +1,32 @@ -//============================================================================= -// File : Support_i.cxx -// Project : SALOME -// Author : EDF -// Copyright : EDF 2002 -// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Support_i.cxx -//============================================================================= - +// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM +// +// 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 : Support_i.cxx +// Author : EDF +// Module : MED +// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Support_i.cxx + +using namespace std; #include "utilities.h" #include "Utils_CorbaException.hxx" #include "Utils_ORB_INIT.hxx" @@ -247,7 +268,7 @@ throw (SALOME::SALOME_Exception) { int mySeqLength=_support->getNumberOfTypes(); myseq->length(mySeqLength); - medGeometryElement * elemts = _support->getTypes(); + const medGeometryElement * elemts = _support->getTypes(); for (int i=0;igetName()); SCRUTE(nbelements); SCRUTE(convertIdlEltToMedElt(geomElement)); - int * numbers=_support->getNumber(convertIdlEltToMedElt(geomElement)); + const int * numbers=_support->getNumber(convertIdlEltToMedElt(geomElement)); for (int i=0;igetNumberOfElements(::MED_ALL_ELEMENTS); myseq->length(nbelements); - int * numbers=_support->getNumberIndex(); + const int * numbers=_support->getNumberIndex(); for (int i=0;i