From bc10f4836149793fd59a112ee25e888be5648f11 Mon Sep 17 00:00:00 2001 From: nri Date: Thu, 10 Jul 2003 14:48:40 +0000 Subject: [PATCH] sources v1.2 --- src/MED/MED_test1.py | 33 +- src/MED/MED_test2.py | 33 +- src/MED/Makefile.in | 36 +- src/MED/Med_Gen_i.cxx | 494 ++++- src/MED/Med_Gen_i.hxx | 74 +- src/MEDGUI/Makefile.in | 34 +- src/MEDGUI/MedGUI.cxx | 36 +- src/MEDGUI/MedGUI.h | 13 +- src/MEDGUI/MedGUI_icons.po | 30 +- src/MEDGUI/MedGUI_msg_en.po | 30 +- src/MEDGUI/MedGUI_msg_fr.po | 30 +- src/MEDMEM/DataTest/Data/maill.0.med | Bin 0 -> 100352 bytes src/MEDMEM/DataTest/Data/mesh.med | Bin 0 -> 57536 bytes src/MEDMEM/DataTest/Data/pointe.med | Bin 0 -> 80011 bytes src/MEDMEM/DataTest/Data/zzzz121b.med | Bin 0 -> 172160 bytes src/MEDMEM/DataTest/Maillages.txt | 5 + src/MEDMEM/DataTest/README | 54 + src/MEDMEM/DataTest/Ref/RtestUCellModel | 244 +++ .../DataTest/Ref/RtestUGeoNameMeshEntities | 53 + src/MEDMEM/DataTest/constituedump.sh | 80 + src/MEDMEM/DataTest/testreadCoordinate.sh | 86 + src/MEDMEM/DataTest/testreadEntete.sh | 85 + src/MEDMEM/DataTest/tous.sh | 54 + src/MEDMEM/Doxyfile_med_devel.in | 172 ++ src/MEDMEM/Doxyfile_med_user.in | 179 ++ src/MEDMEM/MEDMEM_Array.hxx | 932 ++++++--- src/MEDMEM/MEDMEM_CellModel.cxx | 1794 ++++++++++++----- src/MEDMEM/MEDMEM_CellModel.hxx | 242 ++- src/MEDMEM/MEDMEM_Connectivity.cxx | 1078 ++++++---- src/MEDMEM/MEDMEM_Connectivity.hxx | 325 ++- src/MEDMEM/MEDMEM_Coordinate.cxx | 245 ++- src/MEDMEM/MEDMEM_Coordinate.hxx | 108 +- src/MEDMEM/MEDMEM_DriversDef.cxx | 34 +- src/MEDMEM/MEDMEM_DriversDef.hxx | 75 +- src/MEDMEM/MEDMEM_Exception.cxx | 113 +- src/MEDMEM/MEDMEM_Exception.hxx | 37 +- src/MEDMEM/MEDMEM_Family.cxx | 515 +++-- src/MEDMEM/MEDMEM_Family.hxx | 146 +- src/MEDMEM/MEDMEM_Field.cxx | 101 +- src/MEDMEM/MEDMEM_Field.hxx | 1083 +++++++--- src/MEDMEM/MEDMEM_GenDriver.cxx | 114 +- src/MEDMEM/MEDMEM_GenDriver.hxx | 83 +- src/MEDMEM/MEDMEM_GibiMeshDriver.cxx | 230 +++ src/MEDMEM/MEDMEM_GibiMeshDriver.hxx | 218 ++ src/MEDMEM/MEDMEM_Grid.cxx | 951 +++++++++ src/MEDMEM/MEDMEM_Grid.hxx | 260 +++ src/MEDMEM/MEDMEM_Group.cxx | 155 +- src/MEDMEM/MEDMEM_Group.hxx | 61 +- src/MEDMEM/MEDMEM_Med.cxx | 446 +++- src/MEDMEM/MEDMEM_Med.hxx | 101 +- src/MEDMEM/MEDMEM_MedFieldDriver.hxx | 302 ++- src/MEDMEM/MEDMEM_MedMedDriver.cxx | 483 +++-- src/MEDMEM/MEDMEM_MedMedDriver.hxx | 231 ++- src/MEDMEM/MEDMEM_MedMeshDriver.cxx | 1652 +++++++++++---- src/MEDMEM/MEDMEM_MedMeshDriver.hxx | 279 ++- src/MEDMEM/MEDMEM_Mesh.cxx | 968 ++++++--- src/MEDMEM/MEDMEM_Mesh.hxx | 560 +++-- src/MEDMEM/MEDMEM_Meshing.cxx | 321 +++ src/MEDMEM/MEDMEM_Meshing.hxx | 76 + src/MEDMEM/MEDMEM_ModulusArray.hxx | 41 +- src/MEDMEM/MEDMEM_PointerOf.hxx | 193 +- src/MEDMEM/MEDMEM_STRING.hxx | 110 +- src/MEDMEM/MEDMEM_SkyLineArray.cxx | 84 +- src/MEDMEM/MEDMEM_SkyLineArray.hxx | 124 +- src/MEDMEM/MEDMEM_Support.cxx | 461 ++++- src/MEDMEM/MEDMEM_Support.hxx | 603 +++--- src/MEDMEM/MEDMEM_TypeMeshDriver.cxx | 229 +++ src/MEDMEM/MEDMEM_TypeMeshDriver.hxx | 218 ++ src/MEDMEM/MEDMEM_Unit.cxx | 27 + src/MEDMEM/MEDMEM_Unit.hxx | 26 + src/MEDMEM/MEDMEM_VtkMedDriver.cxx | 389 ++-- src/MEDMEM/MEDMEM_VtkMedDriver.hxx | 61 +- src/MEDMEM/MEDMEM_define.hxx | 32 +- src/MEDMEM/Makefile.in | 61 +- src/MEDMEM/create_grid.c | 347 ++++ src/MEDMEM/create_mesh.c | 70 +- src/MEDMEM/create_mesh_c2q4s2.c | 28 + src/MEDMEM/create_mesh_c2q4s2_wrong.c | 28 + src/MEDMEM/create_mesh_c3h8q4.c | 28 + src/MEDMEM/create_mesh_c3h8q4_wrong.c | 28 + src/MEDMEM/duplicateMED.cxx | 144 +- src/MEDMEM/duplicateMEDMESH.cxx | 29 +- src/MEDMEM/med2vtk.cxx | 93 + src/MEDMEM/med_test.cxx | 301 +-- src/MEDMEM/test_MEDMEM_Array.cxx | 70 +- src/MEDMEM/test_MEDMEM_CellModel.cxx | 37 + src/MEDMEM/test_MEDMEM_Meshing.cxx | 270 +++ src/MEDMEM/test_MEDMEM_ModulusArray.cxx | 103 +- src/MEDMEM/test_MEDMEM_SkyLineArray.cxx | 71 +- src/MEDMEM/test_affect_medarray.cxx | 35 +- src/MEDMEM/test_copie_connectivity.cxx | 63 +- src/MEDMEM/test_copie_coordinate.cxx | 35 +- src/MEDMEM/test_copie_family.cxx | 86 +- src/MEDMEM/test_copie_fieldT.cxx | 56 +- src/MEDMEM/test_copie_field_.cxx | 33 +- src/MEDMEM/test_copie_group.cxx | 47 +- src/MEDMEM/test_copie_medarray.cxx | 38 +- src/MEDMEM/test_copie_mesh.cxx | 56 + src/MEDMEM/test_copie_support.cxx | 57 +- src/MEDMEM/tests/readCoordinate.cxx | 128 ++ src/MEDMEM/tests/readEntete.cxx | 139 ++ src/MEDMEM/tests/testUArray.cxx | 347 ++++ src/MEDMEM/tests/testUArray.cxx.ok | 312 +++ src/MEDMEM/tests/testUCellModel.cxx | 367 ++++ src/MEDMEM/tests/testUCoordinate.cxx | 400 ++++ src/MEDMEM/tests/testUGeoNameMeshEntities.cxx | 74 + src/MEDMEM/tests/testUMedException.cxx | 53 + src/MEDMEM/tests/testUModulusArray.cxx | 425 ++++ src/MEDMEM/tests/testUPointerOf.cxx | 98 + src/MEDMEM/tests/testUSkyLineArray.cxx | 237 +++ src/MEDMEM/tests/testUUnit.cxx | 401 ++++ src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.cxx | 46 +- src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.hxx | 28 + src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.cxx | 44 +- src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.hxx | 28 + .../MEDMEM_SWIG_MedFieldDoubleDriver.cxx | 26 + .../MEDMEM_SWIG_MedFieldDoubleDriver.hxx | 26 + .../MEDMEM_SWIG_MedFieldIntDriver.cxx | 26 + .../MEDMEM_SWIG_MedFieldIntDriver.hxx | 26 + src/MEDMEM_SWIG/Makefile.in | 44 +- src/MEDMEM_SWIG/libMEDMEM_Swig.i | 1120 ++++++++-- src/MEDMEM_SWIG/medMeshing_test.py | 256 +++ src/MEDMEM_SWIG/med_test1.py | 61 +- src/MEDMEM_SWIG/med_test2.py | 30 +- src/MEDMEM_SWIG/med_test3.py | 27 +- src/MEDMEM_SWIG/med_test_grid.py | 318 +++ src/MEDMEM_SWIG/med_test_skin.py | 75 + src/MEDMEM_SWIG/my_typemap.i | 68 +- src/Makefile.in | 32 +- src/MedCorba_Swig/Makefile.in | 32 +- src/MedCorba_Swig/batchmode_medcorba_test.py | 9 + src/MedCorba_Swig/libMedCorba_Swig.i | 26 + src/MedCorba_Swig/medcorba_test.py | 26 + src/MedMem/Family_i.cxx | 35 +- src/MedMem/Family_i.hxx | 35 +- src/MedMem/FieldDouble_i.cxx | 37 +- src/MedMem/FieldDouble_i.hxx | 34 +- src/MedMem/FieldInt_i.cxx | 37 +- src/MedMem/FieldInt_i.hxx | 34 +- src/MedMem/FieldOf_i.hxx | 39 +- src/MedMem/Field_i.cxx | 37 +- src/MedMem/Field_i.hxx | 36 +- src/MedMem/Group_i.cxx | 35 +- src/MedMem/Group_i.hxx | 35 +- src/MedMem/Makefile.in | 38 +- src/MedMem/Med_i.cxx | 67 +- src/MedMem/Med_i.hxx | 34 +- src/MedMem/Mesh_i.cxx | 58 +- src/MedMem/Mesh_i.hxx | 34 +- src/MedMem/Support_i.cxx | 43 +- src/MedMem/Support_i.hxx | 34 +- src/MedMem/convert.cxx | 36 +- src/MedMem/convert.hxx | 36 +- 153 files changed, 22206 insertions(+), 4909 deletions(-) create mode 100644 src/MEDMEM/DataTest/Data/maill.0.med create mode 100755 src/MEDMEM/DataTest/Data/mesh.med create mode 100644 src/MEDMEM/DataTest/Data/pointe.med create mode 100644 src/MEDMEM/DataTest/Data/zzzz121b.med create mode 100644 src/MEDMEM/DataTest/Maillages.txt create mode 100644 src/MEDMEM/DataTest/README create mode 100644 src/MEDMEM/DataTest/Ref/RtestUCellModel create mode 100644 src/MEDMEM/DataTest/Ref/RtestUGeoNameMeshEntities create mode 100644 src/MEDMEM/DataTest/constituedump.sh create mode 100755 src/MEDMEM/DataTest/testreadCoordinate.sh create mode 100755 src/MEDMEM/DataTest/testreadEntete.sh create mode 100755 src/MEDMEM/DataTest/tous.sh create mode 100644 src/MEDMEM/Doxyfile_med_devel.in create mode 100644 src/MEDMEM/Doxyfile_med_user.in create mode 100644 src/MEDMEM/MEDMEM_GibiMeshDriver.cxx create mode 100644 src/MEDMEM/MEDMEM_GibiMeshDriver.hxx create mode 100644 src/MEDMEM/MEDMEM_Grid.cxx create mode 100644 src/MEDMEM/MEDMEM_Grid.hxx create mode 100644 src/MEDMEM/MEDMEM_Meshing.cxx create mode 100644 src/MEDMEM/MEDMEM_Meshing.hxx create mode 100644 src/MEDMEM/MEDMEM_TypeMeshDriver.cxx create mode 100644 src/MEDMEM/MEDMEM_TypeMeshDriver.hxx create mode 100644 src/MEDMEM/create_grid.c create mode 100644 src/MEDMEM/med2vtk.cxx create mode 100644 src/MEDMEM/test_MEDMEM_Meshing.cxx create mode 100644 src/MEDMEM/test_copie_mesh.cxx create mode 100755 src/MEDMEM/tests/readCoordinate.cxx create mode 100755 src/MEDMEM/tests/readEntete.cxx create mode 100755 src/MEDMEM/tests/testUArray.cxx create mode 100755 src/MEDMEM/tests/testUArray.cxx.ok create mode 100755 src/MEDMEM/tests/testUCellModel.cxx create mode 100755 src/MEDMEM/tests/testUCoordinate.cxx create mode 100755 src/MEDMEM/tests/testUGeoNameMeshEntities.cxx create mode 100644 src/MEDMEM/tests/testUMedException.cxx create mode 100644 src/MEDMEM/tests/testUModulusArray.cxx create mode 100644 src/MEDMEM/tests/testUPointerOf.cxx create mode 100644 src/MEDMEM/tests/testUSkyLineArray.cxx create mode 100755 src/MEDMEM/tests/testUUnit.cxx create mode 100644 src/MEDMEM_SWIG/medMeshing_test.py create mode 100755 src/MEDMEM_SWIG/med_test_grid.py create mode 100644 src/MEDMEM_SWIG/med_test_skin.py 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 0000000000000000000000000000000000000000..e5a7b130dddf5374413ab2d40e08b6b258f4c524 GIT binary patch literal 100352 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 JsCT&Z{{fo~BwYXi literal 0 HcmV?d00001 diff --git a/src/MEDMEM/DataTest/Data/mesh.med b/src/MEDMEM/DataTest/Data/mesh.med new file mode 100755 index 0000000000000000000000000000000000000000..5f7a25c55d0e9415ffe1bd013072c2d93b355060 GIT binary patch literal 57536 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 Qd%*U9?E%{Z-spk<2U*7_NB{r; literal 0 HcmV?d00001 diff --git a/src/MEDMEM/DataTest/Data/pointe.med b/src/MEDMEM/DataTest/Data/pointe.med new file mode 100644 index 0000000000000000000000000000000000000000..430a74bd66aa41aa72035b1b3c284dbc81c04ec4 GIT binary patch literal 80011 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 literal 0 HcmV?d00001 diff --git a/src/MEDMEM/DataTest/Data/zzzz121b.med b/src/MEDMEM/DataTest/Data/zzzz121b.med new file mode 100644 index 0000000000000000000000000000000000000000..b28cebd2d513ed5b4bee08928a464f070db3d787 GIT binary patch literal 172160 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 literal 0 HcmV?d00001 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