From: nadir Date: Mon, 5 Sep 2005 07:28:41 +0000 (+0000) Subject: updating in the main trunk (only from NB and AG) for a pre building of X-Git-Tag: V3_0_3a1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c7fe50a3575e5ac05f2d6b6f9c5bfd7bc2b309a5;p=modules%2Fmed.git updating in the main trunk (only from NB and AG) for a pre building of CEA_V3_0_2 version. This will include CEA devellopment and features from the V3_0_2 version. For the moment only NB and AG are authorised to commit any thing. Future devellopement will be done on a branch from the new tag CEA_V3_0_2. --- diff --git a/INSTALL b/INSTALL index 6998b170f..f283a3e00 100644 --- a/INSTALL +++ b/INSTALL @@ -1,4 +1,4 @@ -This is the version 3.0.1 of MED +This is the version 3.0.2 of MED Compatible with : - - KERNEL 3.0.0 - - SALOMEGUI 3.0.0 + - KERNEL 3.0.2 + - SALOMEGUI 3.0.2 diff --git a/adm_local/unix/config_files/check_Med.m4 b/adm_local/unix/config_files/check_Med.m4 new file mode 100644 index 000000000..727bf4381 --- /dev/null +++ b/adm_local/unix/config_files/check_Med.m4 @@ -0,0 +1,45 @@ +# Check availability of Med binary distribution +# +# Author : Nicolas REJNERI (OPEN CASCADE, 2003) +# + +AC_DEFUN([CHECK_MED],[ + +AC_CHECKING(for Med) + +Med_ok=no + +AC_ARG_WITH(med, + [ --with-med=DIR root directory path of MED installation ], + MED_DIR="$withval",MED_DIR="") + +if test "x$MED_DIR" == "x" ; then + +# no --with-med-dir option used + + if test "x$MED_ROOT_DIR" != "x" ; then + + # MED_ROOT_DIR environment variable defined + MED_DIR=$MED_ROOT_DIR + + fi +# +fi + +if test -f ${MED_DIR}/idl/salome/MED.idl ; then + Med_ok=yes + AC_MSG_RESULT(Using Med module distribution in ${MED_DIR}) + + if test "x$MED_ROOT_DIR" == "x" ; then + MED_ROOT_DIR=${MED_DIR} + fi + AC_SUBST(MED_ROOT_DIR) + +else + AC_MSG_WARN("Cannot find Med module sources") +fi + +AC_MSG_RESULT(for Med: $Med_ok) + +])dnl + diff --git a/adm_local/unix/config_files/check_Med2.m4 b/adm_local/unix/config_files/check_Med2.m4 new file mode 100644 index 000000000..82b107880 --- /dev/null +++ b/adm_local/unix/config_files/check_Med2.m4 @@ -0,0 +1,114 @@ +dnl Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +dnl +dnl See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +dnl +dnl +dnl + +AC_DEFUN([CHECK_MED2],[ +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_REQUIRE([CHECK_HDF5])dnl + +AC_CHECKING(for MED2) + +AC_ARG_WITH(med2, + [ --with-med2=DIR root directory path to med2 installation ], + [MED2HOME="$withval" + AC_MSG_RESULT("select $withval as path to med2") + ]) + +AC_SUBST(MED2_INCLUDES) +AC_SUBST(MED2_LIBS) +AC_SUBST(MED2_MT_LIBS) + +MED2_INCLUDES="" +MED2_LIBS="" +MED2_MT_LIBS="" + +med2_ok=no + +LOCAL_INCLUDES="$HDF5_INCLUDES" +LOCAL_LIBS="-lmed $HDF5_LIBS" + +if test -z $MED2HOME +then + AC_MSG_WARN(undefined MED2HOME variable which specify med2 installation directory) + AC_PATH_PROG(MDUMP, mdump) + if test "xMDUMP" != "x" ; then + MED2HOME=$MDUMP + MED2HOME=`echo ${MED2HOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + MED2HOME=`echo ${MED2HOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + fi +fi +if test ! -z $MED2HOME +then + LOCAL_INCLUDES="$LOCAL_INCLUDES -I$MED2HOME/include" + if test "x$MED2HOME" = "x/usr" + then + LOCAL_LIBS="-lmed $LOCAL_LIBS" + else + LOCAL_LIBS="-L$MED2HOME/lib $LOCAL_LIBS" + fi +fi + +dnl check med2 header + +CPPFLAGS_old="$CPPFLAGS" +dnl we must test system : linux = -DPCLINUX +dnl we must test system : Alpha-OSF = -DOSF1 +case $host_os in + linux*) + CPPFLAGS="$CPPFLAGS -DPCLINUX $LOCAL_INCLUDES" + ;; + osf*) + CPPFLAGS="$CPPFLAGS -DOSF1 $LOCAL_INCLUDES" + ;; +esac +AC_CHECK_HEADER(med.h,med2_ok=yes ,med2_ok=no) +CPPFLAGS="$CPPFLAGS_old" + +if test "x$med2_ok" = "xyes" +then + +dnl check med2 library + + LIBS_old="$LIBS" + LIBS="$LIBS $LOCAL_LIBS" + AC_CHECK_LIB(med,MEDouvrir,med2_ok=yes,med2_ok=no) + LIBS="$LIBS_old" + +fi + +if test "x$med2_ok" = "xyes" +then +case $host_os in + linux*) + MED2_INCLUDES="-DPCLINUX $LOCAL_INCLUDES" + ;; + osf*) + MED2_INCLUDES="-DOSF1 $LOCAL_INCLUDES" + ;; +esac + MED2_LIBS="$LOCAL_LIBS" + MED2_MT_LIBS="$LOCAL_LIBS" +fi + +AC_MSG_RESULT(for med2: $med2_ok) + +])dnl diff --git a/adm_local/unix/make_commence.in b/adm_local/unix/make_commence.in index ccd4d35de..433fcc3a6 100644 --- a/adm_local/unix/make_commence.in +++ b/adm_local/unix/make_commence.in @@ -37,6 +37,10 @@ CXX = @CXX@ CXXFLAGS = @CXXFLAGS@ CXX_DEPEND_FLAG = @CXX_DEPEND_FLAG@ +# BOOST Library + +BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ + # JAVA JAVA_INCLUDES = @JAVA_INCLUDES@ @@ -257,8 +261,7 @@ ac_cxx_mutable.m4 check_mico.m4 libtool.m4 \ ac_cxx_namespaces.m4 check_omniorb.m4 pyembed.m4 \ ac_cxx_partial_specialization.m4 check_opengl.m4 python.m4 \ ac_cxx_typename.m4 check_pthreads.m4 check_cas.m4 \ -ac_cc_warnings.m4 check_qt.m4 check_med2.m4 \ -check_swig.m4 +ac_cc_warnings.m4 check_qt.m4 check_swig.m4 $(top_srcdir)/aclocal.m4: $(ACLOCAL_SRC:%=@KERNEL_ROOT_DIR@/salome_adm/unix/config_files/%) cd $(top_srcdir) ; aclocal --acdir=adm_local/unix/config_files -I @KERNEL_ROOT_DIR@/salome_adm/unix/config_files diff --git a/bin/VERSION b/bin/VERSION index 0e9903420..e9a90323f 100755 --- a/bin/VERSION +++ b/bin/VERSION @@ -1 +1 @@ -THIS IS SALOME - MED VERSION: 3.0.1 +THIS IS SALOME - MED VERSION: 3.0.2 diff --git a/configure.in.base b/configure.in.base index 412737634..e49447e8d 100644 --- a/configure.in.base +++ b/configure.in.base @@ -154,6 +154,14 @@ dnl CHECK_WITHIHM +echo +echo --------------------------------------------- +echo BOOST Library +echo --------------------------------------------- +echo + +CHECK_BOOST + echo echo --------------------------------------------- echo testing LEX \& YACC @@ -305,7 +313,7 @@ echo --------------------------------------------- echo echo Configure -variables="cc_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok med2_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok" +variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok med2_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok" for var in $variables do diff --git a/idl/MED.idl b/idl/MED.idl index 5b580ddb7..7b499d87b 100644 --- a/idl/MED.idl +++ b/idl/MED.idl @@ -2,11 +2,14 @@ // Project: SALOME // Copyright : CEA/DEN/DMSS/LGLS // $Header$ -/*! + +/*! This file contains the main IDL definitions of the %MED component in %SALOME application. */ + #ifndef MED_IDL #define MED_IDL + /*! \defgroup MED SALOME MED component @@ -40,7 +43,7 @@ module SALOME_MED { /*! \ingroup MED This package contains a set of interfaces used for %SALOME %MED component. -*/ +*/ interface FIELD; @@ -49,8 +52,8 @@ This package contains a set of interfaces used for %SALOME %MED component. interface MESH; interface SUPPORT; -/*! -This enumeration contains a set of elements defining the type of geometrical elements which constitue +/*! +This enumeration contains a set of elements defining the type of geometrical elements which constitue a %Mesh. */ typedef long medGeometryElement; @@ -73,8 +76,8 @@ a %Mesh. const medGeometryElement MED_ALL_ELEMENTS = 999; -/*! -This enumeration contains a set of elements defining the structural elements (entities) which constitue +/*! +This enumeration contains a set of elements defining the structural elements (entities) which constitue a %Mesh. */ typedef long medEntityMesh; @@ -84,7 +87,7 @@ a %Mesh. const medEntityMesh MED_NODE = 3; const medEntityMesh MED_ALL_ENTITIES = 4; -/*! +/*! This enumeration contains a set of modes to store data in an array. For example an array of coordinates in 3D; tow storage may be considered: @@ -95,7 +98,7 @@ For example an array of coordinates in 3D; tow storage may be considered: const medModeSwitch MED_FULL_INTERLACE = 0; const medModeSwitch MED_NO_INTERLACE = 1; -/*! +/*! This enumeration contains a set of elements defining the type of connectivity. */ typedef long medConnectivity; @@ -103,7 +106,7 @@ This enumeration contains a set of elements defining the type of connectivity. const medConnectivity MED_DESCENDING = 1; -/*! +/*! enumeration contains a set of elements defining the type of driver. */ typedef long medDriverTypes; @@ -126,7 +129,7 @@ This enumeration contains a set of elements defining the type of connectivity. An array of %GROUP */ typedef sequence Group_array; - + // ---------------------- // mesh interface // ---------------------- @@ -141,7 +144,7 @@ This enumeration contains a set of elements defining the type of connectivity. Returns the name of the mesh . */ string getName() raises (SALOME::SALOME_Exception); - + /*! Returns space dimension. */ @@ -149,7 +152,7 @@ This enumeration contains a set of elements defining the type of connectivity. /*! Returns mesh dimension. - + Example : - we have only MED_TETRA4 in MED_CELL : MeshDimension = 3D - we have only MED_QUAD4 in MED_CELL : MeshDimension = 2D @@ -178,7 +181,7 @@ This enumeration contains a set of elements defining the type of connectivity. - "CYLINDRICAL" - "SPHERICAL" */ - string getCoordinatesSystem() raises (SALOME::SALOME_Exception); + string getCoordinatesSystem() raises (SALOME::SALOME_Exception); /*! Returns the number of nodes defined in the mesh. @@ -190,7 +193,7 @@ This enumeration contains a set of elements defining the type of connectivity. */ SALOME_MED::double_array getCoordinates(in medModeSwitch typeSwitch) raises (SALOME::SALOME_Exception); - + /*! Returns an array (Sender) of coordinates stored in any type.\n It could be used in a Client code using the MED Client classes. @@ -198,20 +201,20 @@ This enumeration contains a set of elements defining the type of connectivity. SALOME::SenderDouble getSenderForCoordinates(in medModeSwitch typeSwitch) raises (SALOME::SALOME_Exception); /*! - Returns coordinate n° Number on axis n° Axis + Returns coordinate n° Number on axis n° Axis */ double getCoordinate(in long Number, in long Axis) raises (SALOME::SALOME_Exception); - + /*! Returns an array containing the names of coordinates. - + Example : - x,y,z - r,teta,phi - ... - + It could be empty. */ SALOME_MED::string_array getCoordinatesNames() @@ -255,20 +258,20 @@ This enumeration contains a set of elements defining the type of connectivity. // ------------ /*! - Returns the number of defferent %medGeometryElement types existing + Returns the number of defferent %medGeometryElement types existing in the specified entity. - \note + \note Not implemented for MED_ALL_ENTITIES. */ long getNumberOfTypes(in medEntityMesh entity) raises (SALOME::SALOME_Exception); /*! - Returns an array of all %medGeometryElement types existing + Returns an array of all %medGeometryElement types existing in the mesh. - \note + \note Not implemented for MED_ALL_ENTITIES. */ medGeometryElement_array getTypes(in medEntityMesh entity) @@ -277,7 +280,7 @@ This enumeration contains a set of elements defining the type of connectivity. /*! Returns the number of elements of type %medGeometryElement. - Note : + Note : - Implemented for MED_ALL_ELEMENTS - Not implemented for MED_ALL_ENTITIES */ @@ -289,7 +292,7 @@ This enumeration contains a set of elements defining the type of connectivity. Give, in full or no interlace mode (for nodal connectivity), descending or nodal connectivity. - You must give a %medEntityMesh (ie:MED_EDGE) and a + You must give a %medEntityMesh (ie:MED_EDGE) and a %medGeometryElement (ie:MED_SEG3). */ SALOME_MED::long_array getConnectivity(in medModeSwitch typeSwitch, @@ -309,10 +312,10 @@ This enumeration contains a set of elements defining the type of connectivity. raises (SALOME::SALOME_Exception); /*! - Give morse index array to use with + Give morse index array to use with getConnectivity(MED_FULL_INTERLACE,mode,entity,MED_ALL_ELEMENTS). - Each value give start index for corresponding entity in + Each value give start index for corresponding entity in connectivity array. Example : i-th element, j-th node of it : @@ -324,26 +327,26 @@ This enumeration contains a set of elements defining the type of connectivity. raises (SALOME::SALOME_Exception); /*! - Gets a global number of the element which have the same connectivity as the + Gets a global number of the element which have the same connectivity as the connectivity argument. */ - long getElementNumber(in medConnectivity mode, - in medEntityMesh entity, - in medGeometryElement type, - in SALOME_MED::long_array connectivity) + long getElementNumber(in medConnectivity mode, + in medEntityMesh entity, + in medGeometryElement type, + in SALOME_MED::long_array connectivity) raises (SALOME::SALOME_Exception); - medGeometryElement getElementType (in medEntityMesh entity, + medGeometryElement getElementType (in medEntityMesh entity, in long number) raises (SALOME::SALOME_Exception); /*! Returns a reverse connectivity to MED_CELL. - If mode=MED_NODAL, the array contains, for each node, all cells + If mode=MED_NODAL, the array contains, for each node, all cells arround it. - If mode=MED_DESCENDING, the array contains, for each face (or edge), + If mode=MED_DESCENDING, the array contains, for each face (or edge), the 2 cells of each side. First is cell which face normal is outgoing. */ SALOME_MED::long_array getReverseConnectivity(in medConnectivity mode) @@ -352,7 +355,7 @@ This enumeration contains a set of elements defining the type of connectivity. /*! Give index array to use with getReverseConnectivity(MED_NODAL). - This method is not used with MED_DESCENDING mode, + This method is not used with MED_DESCENDING mode, because we have allways two cells. See getConnectivityIndex for details. @@ -367,7 +370,7 @@ This enumeration contains a set of elements defining the type of connectivity. SALOME_MED::long_array numberOfElements; long entityDimension; }; - connectivityInfos getConnectGlobal(in medEntityMesh entity) + connectivityInfos getConnectGlobal(in medEntityMesh entity) raises (SALOME::SALOME_Exception); // Families and Groups @@ -394,7 +397,7 @@ This enumeration contains a set of elements defining the type of connectivity. /*! Returns the reference to i-th family. - \note + \note i is bounded by 1 and NumberOfFamilies. */ FAMILY getFamily(in medEntityMesh entity,in long familyNumber) @@ -409,7 +412,7 @@ This enumeration contains a set of elements defining the type of connectivity. /*! Returns the reference to i-th group. - \note + \note i is bounded by 1 and NumberOfGroups. */ GROUP getGroup(in medEntityMesh entity,in long groupNumber) @@ -421,7 +424,7 @@ This enumeration contains a set of elements defining the type of connectivity. /*! Returns a field on mySupport containing volume. - \note + \note mySupport must be on MED_CELL entity and MeshDimension must be 3D. */ FIELD getVolume(in SUPPORT mySupport) @@ -430,7 +433,7 @@ This enumeration contains a set of elements defining the type of connectivity. /*! Returns a field on mySupport containing area. - \note + \note mySupport must be on MED_FACE entity. */ FIELD getArea(in SUPPORT mySupport) @@ -449,7 +452,7 @@ This enumeration contains a set of elements defining the type of connectivity. Returns a field on mySupport containing normal. \note - mySupport must be on MED_FACE entity if MeshDimension and + mySupport must be on MED_FACE entity if MeshDimension and SpaceDimension=3D and on MED_EDGE if MeshDimension and SpaceDimension=2D. */ FIELD getNormal(in SUPPORT mySupport) @@ -478,19 +481,19 @@ This enumeration contains a set of elements defining the type of connectivity. // Add a MED/VTK/... driver // Multiple drivers can be added whatever the type - long addDriver (in medDriverTypes driverType, in string fileName, in string meshName) + long addDriver (in medDriverTypes driverType, in string fileName, in string meshName) raises (SALOME::SALOME_Exception); // Remove a driver void rmDriver (in long i) raises (SALOME::SALOME_Exception); // void read (in long i) raises (SALOME::SALOME_Exception); - void write (in long i, in string driverMeshName) + void write (in long i, in string driverMeshName) raises (SALOME::SALOME_Exception); - + /*! -Internal Corba method. -*/ +Internal Corba method. +*/ long getCorbaIndex() raises (SALOME::SALOME_Exception); struct meshInfos { @@ -512,13 +515,13 @@ Internal Corba method. boolean areEquals(in MESH other); }; - + // ---------------------- // Support interface // ---------------------- - + interface SUPPORT : SALOME::MultiCommClass, SALOME::ServantLifeCycle { - + /*! Returns the name of the support. */ @@ -535,10 +538,10 @@ Internal Corba method. MESH getMesh() raises (SALOME::SALOME_Exception); /*! - Returns the type of %medEntityMesh used by the support. + Returns the type of %medEntityMesh used by the support. - \note - A support deals only with one entity's type + \note + A support deals only with one entity's type (for example : MED_FACE or MED_NODE) */ medEntityMesh getEntity() raises (SALOME::SALOME_Exception); @@ -552,13 +555,13 @@ Internal Corba method. boolean isOnAllElements() raises (SALOME::SALOME_Exception); /*! - If the method %isOnAllElements() returns False, this method + If the method %isOnAllElements() returns False, this method returns the number of elements in the support. - Example : number of MED_TRIA3 or MED_ALL_ELEMETNS elements + Example : number of MED_TRIA3 or MED_ALL_ELEMETNS elements in entity of support. - \note + \note If %SUPPORT is defined on MED_NODE, use MED_NONE %medGeometryElement type. */ @@ -576,11 +579,11 @@ Internal Corba method. /*! - If the method %isOnAllElements() returns False, this method returns an array which + If the method %isOnAllElements() returns False, this method returns an array which contains all numbers of given %medGeometryElement. - Numbering is global, ie numbers are bounded by 1 and - MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and + 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 @@ -596,14 +599,14 @@ Internal Corba method. SALOME::SenderInt getSenderForNumber(in medGeometryElement geomElement) raises (SALOME::SALOME_Exception); - + /*! - If the method %isOnAllElements() returns False, this method returns the index + If the method %isOnAllElements() returns False, this method returns the index of element number. - - Use it with getNumber(MED_ALL_ELEMENTS). - - \note + + Use it with getNumber(MED_ALL_ELEMENTS). + + \note See the method %getConnectivityIndex for more details. */ SALOME_MED::long_array getNumberIndex() @@ -619,7 +622,7 @@ Internal Corba method. /*! Returns the number of Gauss points for this %medGeometryElement. - \note + \note - Not defined if %SUPPORT is on MED_NODE. - Not defined for MED_ALL_ELEMENTS %medGeometryElement type. */ @@ -632,8 +635,8 @@ Internal Corba method. void getBoundaryElements() raises (SALOME::SALOME_Exception); /*! -Internal Corba method. -*/ +Internal Corba method. +*/ long getCorbaIndex() raises (SALOME::SALOME_Exception); struct supportInfos { @@ -641,9 +644,9 @@ Internal Corba method. string description; boolean isOnAllElements; medEntityMesh entity; - long numberOfGeometricType; + long numberOfGeometricType; medGeometryElement_array types; - SALOME_MED::long_array nbEltTypes; + SALOME_MED::long_array nbEltTypes; }; supportInfos getSupportGlobal() raises (SALOME::SALOME_Exception); @@ -654,12 +657,12 @@ Internal Corba method. // Family interface //----------------- - interface FAMILY : SUPPORT + interface FAMILY : SUPPORT { /*! Returns Family identifier (Identifier - of the family in the mesh). + of the family in the mesh). \note There is precisely only one indentifier for each family. @@ -675,13 +678,13 @@ Internal Corba method. Returns an array of all attributes' identifiers. There is one for each attribute. */ - SALOME_MED::long_array getAttributesIdentifiers() + SALOME_MED::long_array getAttributesIdentifiers() raises (SALOME::SALOME_Exception); /*! Returns identifier of i-th attribute. - \note + \note i is bounded by 1 and NumberOfAttributes. */ long getAttributeIdentifier(in long i) raises (SALOME::SALOME_Exception); @@ -690,13 +693,13 @@ Internal Corba method. Returns an array of all values of the attributes . There is one value for each attribute. */ - SALOME_MED::long_array getAttributesValues() + SALOME_MED::long_array getAttributesValues() raises (SALOME::SALOME_Exception); /*! Returns the value of i-th attribute. - \note + \note i is bounded by 1 and NumberOfAttributes. */ long getAttributeValue(in long i) raises (SALOME::SALOME_Exception); @@ -705,16 +708,16 @@ Internal Corba method. Returns an array of all descriptions of the attributes . There is one description for each attribute. */ - SALOME_MED::string_array getAttributesDescriptions() + SALOME_MED::string_array getAttributesDescriptions() raises (SALOME::SALOME_Exception); /*! Returns the description of i-th attribute. - \note + \note i is bounded by 1 and NumberOfAttributes. */ - string getAttributeDescription(in long i) + string getAttributeDescription(in long i) raises (SALOME::SALOME_Exception); /*! @@ -727,16 +730,16 @@ Internal Corba method. Returns an array of names of groups the family belongs to . There is one name for each group. */ - SALOME_MED::string_array getGroupsNames() + SALOME_MED::string_array getGroupsNames() raises (SALOME::SALOME_Exception); /*! Returns the name of i-th group. - \note + \note i is bounded by 1 and NumberOfAttributes. */ - string getGroupName(in long i) + string getGroupName(in long i) raises (SALOME::SALOME_Exception); @@ -746,7 +749,7 @@ Internal Corba method. //---------------- // Group interface //---------------- - interface GROUP : SUPPORT + interface GROUP : SUPPORT { /*! @@ -762,7 +765,7 @@ Internal Corba method. /*! Returns a reference to the i-th family. - \note + \note i is bounded by 1 and NumberOfFamilies. */ FAMILY getFamily(in long i) raises (SALOME::SALOME_Exception); @@ -801,13 +804,13 @@ Internal Corba method. /*! Returns an array containing components names. */ - SALOME_MED::string_array getComponentsNames() + SALOME_MED::string_array getComponentsNames() raises (SALOME::SALOME_Exception); /*! Returns the name of i-th component. - \note + \note - i is bounded by 1 and NumberOfComponents. - Name is mandatory for each field's component. */ @@ -822,7 +825,7 @@ Internal Corba method. /*! Returns the unit of i-th component. - \note + \note i is bounded by 1 and NumberOfComponents. */ string getComponentUnit(in long i) raises (SALOME::SALOME_Exception); @@ -830,13 +833,13 @@ Internal Corba method. /*! Returns an array containing components descriptions. */ - SALOME_MED::string_array getComponentsDescriptions() + SALOME_MED::string_array getComponentsDescriptions() raises (SALOME::SALOME_Exception); /*! Returns the description of i-th component. - \note + \note - i is bounded by 1 and NumberOfComponents. - Name is mandatory for each field's component. */ @@ -853,23 +856,23 @@ Internal Corba method. double getTime() raises (SALOME::SALOME_Exception); /*! - Returns order number use for + Returns order number use for internal step in this iteration. */ long getOrderNumber() raises (SALOME::SALOME_Exception); // Read & Write // ----------- - - long addDriver (in medDriverTypes driverType, in string fileName, in string fieldName) + + long addDriver (in medDriverTypes driverType, in string fileName, in string fieldName) raises (SALOME::SALOME_Exception); - + /*! Removes a driver */ void rmDriver (in long i) raises (SALOME::SALOME_Exception); - + // void read (in long i) raises (SALOME::SALOME_Exception); @@ -877,9 +880,9 @@ Internal Corba method. /*! Writes a field. */ - void write (in long i, in string driverFieldName) + void write (in long i, in string driverFieldName) raises (SALOME::SALOME_Exception); - + /*! Adds the Field in the StudyManager. */ @@ -898,7 +901,7 @@ Internal Corba method. interface FIELDDOUBLE : FIELD , SALOME::MultiCommClass { /*! - Returns an array of values of the field + Returns an array of values of the field */ SALOME_MED::double_array getValue(in medModeSwitch mode) raises (SALOME::SALOME_Exception); @@ -914,7 +917,7 @@ Internal Corba method. interface FIELDINT : FIELD , SALOME::MultiCommClass { /*! - Returns an array of values of the field + Returns an array of values of the field */ SALOME_MED::long_array getValue(in medModeSwitch mode) raises (SALOME::SALOME_Exception); @@ -933,7 +936,7 @@ Internal Corba method. /*! returns the number of meshes in the %MED object. */ - long getNumberOfMeshes () raises (SALOME::SALOME_Exception); + long getNumberOfMeshes () raises (SALOME::SALOME_Exception); /*! returns the number of fields in the %MED object. */ @@ -974,22 +977,22 @@ Internal Corba method. /*! giving a field name, a time iteration and an order number, it returns the corresponding %FIELD oject. */ - FIELD getField ( in string fieldName, + FIELD getField ( in string fieldName, in long pasTemps, in long numOrdre ) raises (SALOME::SALOME_Exception); - // Add a MED/VTK/... driver to a MED'GEN' object to + // Add a MED/VTK/... driver to a MED'GEN' object to // be able to read/write files preserving meshes<-->fields association // Multiple drivers can be added whatever the type. // The access point in the returned - long addDriver (in medDriverTypes driverType, in string fileName) + long addDriver (in medDriverTypes driverType, in string fileName) raises (SALOME::SALOME_Exception); - /*! + /*! Removes the driver - */ + */ void rmDriver (in long i) raises (SALOME::SALOME_Exception); - /*! + /*! Reads the structure of the %MED file */ void readFileStruct(in long i) raises (SALOME::SALOME_Exception); @@ -998,7 +1001,7 @@ Internal Corba method. void addMesh (in MESH ptrMesh ) raises (SALOME::SALOME_Exception); void addField (in FIELD ptrField ) raises (SALOME::SALOME_Exception); - + void addInStudy (in SALOMEDS::Study myStudy, in MED medPtr) raises (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection); }; }; diff --git a/src/MED/Makefile.in b/src/MED/Makefile.in index 0a578bc42..5d06ea4f2 100644 --- a/src/MED/Makefile.in +++ b/src/MED/Makefile.in @@ -1,23 +1,23 @@ # 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 +# 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 # # # @@ -39,17 +39,17 @@ EXPORT_PYSCRIPTS = MED_test1.py MED_test2.py Med_Gen_test.py LIB = libMEDEngine.la -LIB_SRC = Med_Gen_i.cxx +LIB_SRC = Med_Gen_i.cxx LIB_SERVER_IDL = MED_Gen.idl SALOME_Component.idl \ - SALOME_Exception.idl MED.idl + SALOME_Exception.idl MED.idl LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_ModuleCatalog.idl SALOME_Comm.idl SALOME_GenericObj.idl # Executables targets -BIN = -BIN_SRC = +BIN = +BIN_SRC = -LDFLAGS= -L$(top_builddir)/lib/salome +LDFLAGS= -L$(top_builddir)/lib/salome LDFLAGSFORBIN= -L$(top_builddir)/lib/salome # additionnal information to compil and link file diff --git a/src/MED/Med_Gen_i.cxx b/src/MED/Med_Gen_i.cxx index 91e9b7cfc..0d4bb3060 100755 --- a/src/MED/Med_Gen_i.cxx +++ b/src/MED/Med_Gen_i.cxx @@ -1,23 +1,23 @@ // 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 +// 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 // // // @@ -85,8 +85,8 @@ Med_Gen_i::Med_Gen_i() Med_Gen_i:: Med_Gen_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, - PortableServer::ObjectId * contId, - const char *instanceName, + PortableServer::ObjectId * contId, + const char *instanceName, const char *interfaceName) : Engines_Component_i(orb, poa, contId, instanceName, interfaceName) { @@ -116,14 +116,14 @@ SALOMEDS::Study_var Med_Gen_i::studyName2Study(const char* studyName) SALOME::BAD_PARAM); // Get StudyManager Reference, current study, - + CORBA::Object_var obj = _NS->Resolve("/myStudyManager"); SALOMEDS::StudyManager_var myStudyManager = SALOMEDS::StudyManager::_narrow(obj); if(CORBA::is_nil(myStudyManager)) THROW_SALOME_CORBA_EXCEPTION("No StudyManager Found in NameService", \ SALOME::BAD_PARAM); - + SALOMEDS::Study_var myStudy = myStudyManager->GetStudyByName(myStudyName.c_str()); if (CORBA::is_nil(myStudy)) @@ -143,7 +143,6 @@ void Med_Gen_i::addInStudy(SALOMEDS::Study_var myStudy) throw(SALOME::SALOME_Exception) { SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder(); - // Create SComponent labelled 'Med' if it doesn't already exit SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED"); if ( CORBA::is_nil(medfather) ) @@ -152,7 +151,7 @@ void Med_Gen_i::addInStudy(SALOMEDS::Study_var myStudy) // mpv: component label must be created in spite of "Locked" study flag state bool aLocked = myStudy->GetProperties()->IsLocked(); if (aLocked) myStudy->GetProperties()->SetLocked(false); - + MESSAGE("Add Component Med"); medfather = myBuilder->NewComponent("MED"); SALOMEDS::GenericAttribute_var anAttr = myBuilder->FindOrCreateAttribute(medfather, "AttributeName"); @@ -164,18 +163,18 @@ void Med_Gen_i::addInStudy(SALOMEDS::Study_var myStudy) SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "MED" ); if ( !Comp->_is_nil() ) { aName->SetValue( Comp->componentusername() ); - } - + } + // Utilisation de this deconseillee par Paul ?? // myBuilder->DefineComponentInstance(medfather,POA_Engines::MED_Gen::_this()); CORBA::Object_var myO = _poa->id_to_reference(*_id); // this ior... myBuilder->DefineComponentInstance(medfather,myO); - + if (aLocked) myStudy->GetProperties()->SetLocked(true); myBuilder->CommitCommand(); - } - - + } + + } //============================================================================= @@ -194,13 +193,13 @@ SALOME_MED::MED_ptr Med_Gen_i::readStructFile (const char* fileName, // if (!_duringLoad) addInStudy(myStudy) ; SALOME_MED::MED_ptr myMedIOR ; - try + try { // we create a new MED_i and add in study MED_i * myMedI = new MED_i(); myMedIOR = myMedI->_this() ; // if (!_duringLoad) myMedI->addInStudy(myStudy,myMedIOR) ; -// if (!_duringLoad) myMedI->addInStudy(myStudy,myMedIOR,fileName) ; +// if (!_duringLoad) myMedI->addInStudy(myStudy,myMedIOR,fileName) ; // create ::MED object, read all and add in study ! myMedI->init(myStudy,MED_DRIVER,fileName) ; } @@ -232,15 +231,14 @@ throw (SALOME::SALOME_Exception) SCRUTE(fileName); SALOMEDS::Study_var myStudy = studyName2Study(studyName) ; - if (!_duringLoad) addInStudy(myStudy) ; - try + try { // we create a new MED_i and add in study MED_i * myMedI = new MED_i(); SALOME_MED::MED_ptr myMedIOR = myMedI->_this() ; - if (!_duringLoad) myMedI->addInStudy(myStudy,myMedIOR,fileName) ; + if (!_duringLoad) myMedI->addInStudy(myStudy,myMedIOR,fileName) ; // create ::MED object, read all and add in study ! myMedI->initWithFieldType(myStudy,MED_DRIVER,fileName) ; } @@ -337,7 +335,7 @@ throw (SALOME::SALOME_Exception) SALOME::BAD_PARAM); // Get StudyManager Reference, current study, - + CORBA::Object_var obj = _NS->Resolve("/myStudyManager"); SALOMEDS::StudyManager_var myStudyManager = SALOMEDS::StudyManager::_narrow(obj); @@ -367,8 +365,8 @@ throw (SALOME::SALOME_Exception) SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "MED" ); if ( !Comp->_is_nil() ) { aName->SetValue( Comp->componentusername() ); - } - + } + CORBA::Object_var myO = _poa->id_to_reference(*_id); // this ior... myBuilder->DefineComponentInstance(medfather,myO); @@ -416,7 +414,7 @@ throw (SALOME::SALOME_Exception) SCRUTE(ex.what()); THROW_SALOME_CORBA_EXCEPTION("Unable to find this field in this file",SALOME::BAD_PARAM); }; - + SUPPORT * fieldSupport; try { @@ -436,11 +434,11 @@ throw (SALOME::SALOME_Exception) }; med_type_champ type = myField->getValueType() ; - switch (type) + switch (type) { - case MED_EN::MED_INT32: + case MED_EN::MED_INT32: { - try + try { ((FIELD*)myField)->read() ; FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD*)myField); @@ -458,9 +456,9 @@ throw (SALOME::SALOME_Exception) }; break; } - case MED_EN::MED_REEL64: + case MED_EN::MED_REEL64: { - try + try { ((FIELD*)myField)->read() ; FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD*)myField); @@ -480,7 +478,7 @@ throw (SALOME::SALOME_Exception) } } - + } @@ -543,7 +541,7 @@ SALOMEDS::TMPFile* Med_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent, SALOMEDS::SObject_var aMedFieldFather = theComponent->GetStudy()->FindObject("MEDFIELD"); if (!CORBA::is_nil(aMedFieldFather)) { SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedFieldFather); - anIter->InitEx(1); + anIter->InitEx(1); for(; anIter->More(); anIter->Next()) { SALOMEDS::SObject_var aSO = anIter->Value(); SALOMEDS::GenericAttribute_var anAttr; @@ -581,7 +579,7 @@ SALOMEDS::TMPFile* Med_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent, if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true); // Return the created byte stream return aStreamFile._retn(); - + END_OF(LOC); } @@ -590,21 +588,21 @@ SALOMEDS::TMPFile* Med_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent, 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):(char*)SALOMEDS_Tool::GetTmpDir().c_str(); // Create a list to store names of created files SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; TColStd_SequenceOfAsciiString aFileNames; - + CORBA::String_var aSaveStudyName(""); if (isMultiFile) aSaveStudyName = CORBA::string_dup(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL()).c_str()); - + SALOMEDS::SObject_var aMedMeshFather = theComponent->GetStudy()->FindObject("MEDMESH"); if (!CORBA::is_nil(aMedMeshFather)) { SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedMeshFather); - anIter->InitEx(1); + anIter->InitEx(1); for(; anIter->More(); anIter->Next()) { SALOMEDS::SObject_var aSO = anIter->Value(); SALOMEDS::GenericAttribute_var anAttr; @@ -629,7 +627,7 @@ SALOMEDS::TMPFile* Med_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent, SALOMEDS::SObject_var aMedFieldFather = theComponent->GetStudy()->FindObject("MEDFIELD"); if (!CORBA::is_nil(aMedFieldFather)) { SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedFieldFather); - anIter->InitEx(1); + anIter->InitEx(1); for(; anIter->More(); anIter->Next()) { SALOMEDS::SObject_var aSO = anIter->Value(); SALOMEDS::GenericAttribute_var anAttr; @@ -701,7 +699,7 @@ CORBA::Boolean Med_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent, //============================================================================= /*! - * CORBA: + * CORBA: */ //============================================================================= @@ -734,10 +732,10 @@ char* Med_Gen_i::ComponentDataType() MESSAGE("Med_Gen_i::ComponentDataType"); return CORBA::string_dup("MED") ; /* What is this type ? */ } - + //============================================================================= /*! - * CORBA: give a persistent reference of a transient object (for study save) + * CORBA: give a persistent reference of a transient object (for study save) */ //============================================================================= @@ -757,24 +755,24 @@ char* Med_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, // MED SALOME_MED::MED_var myMed = SALOME_MED::MED::_narrow(myIOR); - if (! CORBA::is_nil(myMed)) + if (! CORBA::is_nil(myMed)) { // nothing to save : Support will be saved inside the mesh string str_MedName="_MED Objet Med + /OBJ_MED/"; - return CORBA::string_dup(str_MedName.c_str()) ; + return CORBA::string_dup(str_MedName.c_str()) ; } - + // MESH SALOME_MED::MESH_var myMesh = SALOME_MED::MESH::_narrow(myIOR); - if (! CORBA::is_nil(myMesh)) + if (! CORBA::is_nil(myMesh)) { CORBA::String_var aName((string("_MEDMESH_")+ myMesh->getName() + ".med").c_str()); return aName._retn() ; } - + // SUPPORT SALOME_MED::SUPPORT_var mySupport = SALOME_MED::SUPPORT::_narrow(myIOR); - if (! CORBA::is_nil(mySupport)) + if (! CORBA::is_nil(mySupport)) { // nothing to save : Support will be saved inside the mesh string str_SupportName; @@ -792,9 +790,9 @@ char* Med_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, } return CORBA::string_dup(("_MED"+str_SupportName).c_str()); } - + SALOME_MED::FIELD_var myField = SALOME_MED::FIELD::_narrow(myIOR); - if (! CORBA::is_nil(myField)) + if (! CORBA::is_nil(myField)) { string str_FieldName; ostringstream a,b; @@ -936,7 +934,7 @@ SALOMEDS::SObject_ptr Med_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "MED" ); if ( !Comp->_is_nil() ) { aName->SetValue( Comp->componentusername() ); - } + } aBuilder->DefineComponentInstance(aFather, MED_Gen::_this()); } @@ -945,7 +943,7 @@ SALOMEDS::SObject_ptr Med_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, aMesh->addInStudy(theStudy, aMesh); SALOMEDS::SObject_var aResultSO = theStudy->FindObjectIOR(_orb->object_to_string(theObject)); } else { - if (!theSObject->ReferencedObject(aResultSO)) + if (!theSObject->ReferencedObject(aResultSO)) THROW_SALOME_CORBA_EXCEPTION("Publish in study MED object error",SALOME::BAD_PARAM); } // aBuilder->Addreference(theObject, aResultSO); @@ -1000,17 +998,17 @@ SALOMEDS::TMPFile* Med_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::L strcpy(aFullName+strlen(aTmpDir), aSeq[0]); long driverId = aMesh->addDriver(SALOME_MED::MED_DRIVER,aFullName , aMesh->getName()); aMesh->write(driverId,""); - + // aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), false); char* aFullName1 = new char[strlen(aTmpDir)+1]; strcpy(aFullName1, aTmpDir); aStreamFile = SALOMEDS_Tool::PutFilesToStream(aFullName1, aSeq.in(), false); // SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true); SALOMEDS_Tool::RemoveTemporaryFiles(aFullName1, aSeq.in(), true); - + // Assign an ID = 1 the the type SALOME_MED::MESH theObjectID = 1; - + return aStreamFile._retn(); } @@ -1036,7 +1034,7 @@ SALOMEDS::SObject_ptr Med_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream, 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 = CORBA::string_dup(SALOMEDS_Tool::GetTmpDir().c_str()); @@ -1099,8 +1097,8 @@ SALOMEDS::SObject_ptr Med_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream, //============================================================================= -/*! - * C factory, accessible with dlsym, after dlopen +/*! + * C factory, accessible with dlsym, after dlopen */ //============================================================================= @@ -1108,14 +1106,14 @@ extern "C" { PortableServer::ObjectId * MEDEngine_factory( CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, + PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, - const char *instanceName, + const char *instanceName, const char *interfaceName) { MESSAGE("PortableServer::ObjectId * MedEngine_factory()"); SCRUTE(interfaceName); - Med_Gen_i * myMed_Gen + Med_Gen_i * myMed_Gen = new Med_Gen_i(orb, poa, contId, instanceName, interfaceName); return myMed_Gen->getId() ; } diff --git a/src/MEDGUI/Makefile.in b/src/MEDGUI/Makefile.in index 747f07c2b..94abc038e 100644 --- a/src/MEDGUI/Makefile.in +++ b/src/MEDGUI/Makefile.in @@ -1,22 +1,22 @@ # 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 -# +# 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 # # @@ -33,7 +33,7 @@ VPATH=.:$(srcdir):$(top_srcdir)/idl:$(top_builddir)/idl @COMMENCE@ -# header files +# header files EXPORT_HEADERS= # .po files to transform in .qm @@ -54,7 +54,7 @@ LIB_CLIENT_IDL = SALOMEDS.idl SALOME_Exception.idl SALOME_Component.idl \ # SMESH_Mesh.idl SMESH_Hypothesis.idl SMESH_BasicHypothesis.idl \ # GEOM_Shape.idl SALOMEDS_Attributes.idl -LIB_SERVER_IDL = +LIB_SERVER_IDL = # additionnal information to compil and link file diff --git a/src/MEDGUI/MedGUI.cxx b/src/MEDGUI/MedGUI.cxx index 22404a683..910e1a56c 100644 --- a/src/MEDGUI/MedGUI.cxx +++ b/src/MEDGUI/MedGUI.cxx @@ -96,7 +96,7 @@ void MedGUI::createPopupItem( const int id, QChar lc = QtxPopupMgr::Selection::defEquality(); QString rule = "(%1)"; - if( !types.isEmpty() ) + if( !types.isEmpty() ) rule += " and (%2) and (%3)"; rule = rule.arg( QString( "client in {%1}" ).arg( clients ) ); @@ -134,7 +134,7 @@ void MedGUI::createMedAction( const int id, const QString& po_id, const QString& void MedGUI::initialize( CAM_Application* app ) { SalomeApp_Module::initialize( app ); - + QWidget* parent = application()->desktop(); createMedAction( 931, "MESHSEL" ); @@ -426,24 +426,20 @@ bool MedGUI::OnGUIEvent (int theCommandID) // medgen->readStructFile(file.latin1(),myStudyName); medgen->readStructFileWithFieldType(file.latin1(),myStudyName); - MESSAGE("Ouais on est la !!!!"); if (myActiveStudy->studyDS()->GetProperties()->IsLocked()) { - - MESSAGE("Ouais on est la 1 !!!!"); - + MESSAGE("Ouais on est la 1 !!!!"); SUIT_MessageBox::warn1 (application()->desktop(), - QObject::tr("WRN_WARNING"), - QObject::tr("WRN_STUDY_LOCKED"), - QObject::tr("BUT_OK")); + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK")); } } catch (const SALOME::SALOME_Exception & S_ex) { - MESSAGE("Ouais on est la 2 !!!!"); SalomeApp_Tools::QtCatchCorbaException(S_ex); @@ -585,10 +581,13 @@ bool MedGUI::OnGUIEvent (int theCommandID) } } } - } + } break; } } + + app->updateActions(); //SRN: To update a Save button in the toolbar + return true; } @@ -781,7 +780,7 @@ bool MedGUI::DumpSubMesh( SALOME_MED::FAMILY_var Fam ) SALOME_MED::long_array_var tabnoeuds=Fam->getNumber(SALOME_MED::MED_NONE); for (int l=0;llength();l++) - SCRUTE(tabnoeuds[l]); + SCRUTE(tabnoeuds[l]); return true; } diff --git a/src/MEDMEM/MEDMEM_Array.hxx b/src/MEDMEM/MEDMEM_Array.hxx index 7dad7b3b5..c47a2914a 100644 --- a/src/MEDMEM/MEDMEM_Array.hxx +++ b/src/MEDMEM/MEDMEM_Array.hxx @@ -41,7 +41,7 @@ namespace MEDMEM { template class MEDARRAY { private : - + /*! leading dimension of value (example : space dimension for coordinates) */ int _ldValues; /*! length of values (example : number of nodes for coordinates) */ @@ -139,7 +139,7 @@ template MEDARRAY::MEDARRAY(const int ld_values, _valuesFull(), _valuesNo(), _valuesDefault(),_valuesOther() { - BEGIN_OF("constructor MEDARRAY::MEDARRAY(const int, const int, const medModeSwitch)"); + // BEGIN_OF("constructor MEDARRAY::MEDARRAY(const int, const int, const medModeSwitch)"); // if ld_values < 1 or length_values < 1 // throws an exception @@ -163,18 +163,18 @@ template MEDARRAY::MEDARRAY(const int ld_values, } ASSERT( (T*)_valuesDefault != NULL); - SCRUTE((T*)_valuesDefault); - SCRUTE((T*)_valuesOther); - SCRUTE((T*)_valuesNo); - SCRUTE((T*)_valuesFull); +// SCRUTE((T*)_valuesDefault); +// SCRUTE((T*)_valuesOther); +// SCRUTE((T*)_valuesNo); +// SCRUTE((T*)_valuesFull); - END_OF("constructor MEDARRAY::MEDARRAY(const int, const int, const medModeSwitch ()"); + // END_OF("constructor MEDARRAY::MEDARRAY(const int, const int, const medModeSwitch ()"); } // ------------------ /*! This constructor duplicate T*values.\n - + Throws MEDEXCEPTION if the lenght of T is < 1*/ template MEDARRAY::MEDARRAY( T*values, const int ld_values, @@ -188,7 +188,7 @@ template MEDARRAY::MEDARRAY( T*values, _valuesFull(),_valuesNo(), _valuesDefault(),_valuesOther() { - BEGIN_OF("constructor MEDARRAY::MEDARRAY(T* values, const int, const int, const medModeSwitch)"); + // BEGIN_OF("constructor MEDARRAY::MEDARRAY(T* values, const int, const int, const medModeSwitch)"); // if ld_values < 1 or length_values < 1, we could not allocate // throws an exception @@ -235,12 +235,12 @@ template MEDARRAY::MEDARRAY( T*values, _valuesDefault.set((T*)_valuesNo); } ASSERT( (T*)_valuesDefault != NULL); - SCRUTE((T*)_valuesDefault); - SCRUTE((T*)_valuesOther); - SCRUTE((T*)_valuesNo); - SCRUTE((T*)_valuesFull); +// SCRUTE((T*)_valuesDefault); +// SCRUTE((T*)_valuesOther); +// SCRUTE((T*)_valuesNo); +// SCRUTE((T*)_valuesFull); - END_OF("constructor MEDARRAY::MEDARRAY(T* values, const int, const int, const medModeSwitch)"); + // END_OF("constructor MEDARRAY::MEDARRAY(T* values, const int, const int, const medModeSwitch)"); } // ------------------ @@ -257,13 +257,13 @@ template MEDARRAY::MEDARRAY(MEDARRAY const & m ): _valuesDefault((const T*)m._valuesDefault), _valuesOther((const T*)m._valuesOther) { - BEGIN_OF("constructor MEDARRAY::MEDARRAY(MEDARRAY const & m)"); + // 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)"); +// SCRUTE((T*)_valuesDefault); +// SCRUTE((T*)_valuesOther); +// SCRUTE((T*)_valuesNo); +// SCRUTE((T*)_valuesFull); + // END_OF("constructor MEDARRAY::MEDARRAY(MEDARRAY const & m)"); } /*! This constructor allocates a new array and does a copy of values @@ -282,7 +282,7 @@ template MEDARRAY::MEDARRAY(MEDARRAY const & p,bool copyOther ): _valuesDefault(), _valuesOther() { - BEGIN_OF("Constructeur deepCopy MEDARRAY::MEDARRAY(MEDARRAY const & m,bool copyOther"); + // 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 ! @@ -290,7 +290,7 @@ template MEDARRAY::MEDARRAY(MEDARRAY const & p,bool copyOther ): // { // throw MEDEXCEPTION("MEDARRAY MEDARRAY const &m,bool copyOther : No Other values defined and bool = true !"); // } - + if ( _mode == MED_EN::MED_FULL_INTERLACE) { _valuesFull.set(p._ldValues*p._lengthValues,(const T*)p._valuesFull); @@ -325,20 +325,20 @@ template MEDARRAY::MEDARRAY(MEDARRAY const & p,bool copyOther ): template MEDARRAY & MEDARRAY::operator = (const MEDARRAY & m) { - BEGIN_OF("Operator = MEDARRAY"); + // BEGIN_OF("Operator = MEDARRAY"); _ldValues=m._ldValues; _lengthValues=m._lengthValues; _mode=m._mode; - - SCRUTE(_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_EN::MED_FULL_INTERLACE) { //PN : pour enlever les warning compilateur //_valuesDefault.set((const T*) _valuesFull); @@ -354,12 +354,12 @@ template MEDARRAY & MEDARRAY::operator = (const MEDARRAY & m) _valuesOther.set((T*) _valuesFull); } - SCRUTE((T*)_valuesDefault); - SCRUTE((T*)_valuesOther); - SCRUTE((T*)_valuesNo); - SCRUTE((T*)_valuesFull); +// SCRUTE((T*)_valuesDefault); +// SCRUTE((T*)_valuesOther); +// SCRUTE((T*)_valuesNo); +// SCRUTE((T*)_valuesFull); - END_OF("Operator = MEDARRAY"); + // END_OF("Operator = MEDARRAY"); return *this; } @@ -409,7 +409,7 @@ template inline int MEDARRAY::getLengthValue() const The pointer can be used to set values */ template const T* MEDARRAY::get(const MED_EN::medModeSwitch mode) { - BEGIN_OF("MEDARRAY::get(const medModeSwitch mode)"); + // BEGIN_OF("MEDARRAY::get(const medModeSwitch mode)"); if ((T*)_valuesDefault == NULL) { throw MEDEXCEPTION("MEDARRAY::get(mode) : No values defined !"); @@ -438,7 +438,7 @@ template const T* MEDARRAY::get(const MED_EN::medModeSwitch mode) (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 int i) { if ((T*)_valuesDefault == NULL) @@ -538,7 +538,7 @@ template const T MEDARRAY::getIJ(const int i,const int j) const { return _valuesDefault[(j-1)*_lengthValues+i-1]; } - + } // ------------------ @@ -579,11 +579,11 @@ template inline MED_EN::medModeSwitch MEDARRAY::getMode() const // END_OF("MEDARRAY::set(mode,i,value)"); // } -// set with duplication because we don't know were value come and +// set with duplication because we don't know were value come and // MEDARRAY must have properties on it !!!! template void MEDARRAY::set(const MED_EN::medModeSwitch mode, const T* value) { - BEGIN_OF("MEDARRAY::set(mode,value)"); + // BEGIN_OF("MEDARRAY::set(mode,value)"); _mode = mode; if ( _mode == MED_EN::MED_FULL_INTERLACE) @@ -601,12 +601,12 @@ template void MEDARRAY::set(const MED_EN::medModeSwitch mode, const } _valuesOther.set(0); - END_OF("MEDARRAY::set(mode,i,value)"); + // END_OF("MEDARRAY::set(mode,i,value)"); } /*! This function clears the other mode of representation if it exists * It is usefull for people who needs for optimisation reasons to work directly - * on the inside array without using set-functions + * on the inside array without using set-functions */ template void MEDARRAY::clearOtherMode() { @@ -628,7 +628,7 @@ template void MEDARRAY::clearOtherMode() Throws exception if i < 1 or i > _lengthValues */ template void MEDARRAY::setI(const int i, const T* value) { - BEGIN_OF("MEDARRAY::setI(i,value)"); + // BEGIN_OF("MEDARRAY::setI(i,value)"); if ((T*)_valuesDefault == NULL) { @@ -659,7 +659,7 @@ template void MEDARRAY::setI(const int i, const T* value) } } - END_OF("MEDARRAY::setI(i,value)"); + // END_OF("MEDARRAY::setI(i,value)"); } // ------------------ @@ -668,7 +668,7 @@ template void MEDARRAY::setI(const int i, const T* value) Throws exception if i < 1 or i > _lengthValues */ template void MEDARRAY::setJ(const int j, const T* value) { - BEGIN_OF("MEDARRAY::setJ(j,value)"); + // BEGIN_OF("MEDARRAY::setJ(j,value)"); if (( T*)_valuesDefault == NULL) { throw MEDEXCEPTION("MEDARRAY::setJ(j) : No values defined !"); @@ -696,7 +696,7 @@ template void MEDARRAY::setJ(const int j, const T* value) _valuesNo[k+_lengthValues*(j-1)] = value[k]; } } - END_OF("MEDARRAY::setJ(j,value)"); + // END_OF("MEDARRAY::setJ(j,value)"); } // ------------------ @@ -739,7 +739,7 @@ template void MEDARRAY::setIJ(const int i, const int j, const T val Throws exception if no value are setted */ template void MEDARRAY::calculateOther() { - BEGIN_OF("MEDARRAY::calculateOther()"); + // BEGIN_OF("MEDARRAY::calculateOther()"); if ((T*)_valuesDefault == NULL) { throw MEDEXCEPTION("MEDARRAY::calculateOther() : No values defined !"); @@ -773,7 +773,7 @@ template void MEDARRAY::calculateOther() } } } - END_OF("MEDARRAY::calculateOther()"); + // END_OF("MEDARRAY::calculateOther()"); } } //End of namespace MEDMEM diff --git a/src/MEDMEM/MEDMEM_Connectivity.cxx b/src/MEDMEM/MEDMEM_Connectivity.cxx index ab06ea653..2c8917e54 100644 --- a/src/MEDMEM/MEDMEM_Connectivity.cxx +++ b/src/MEDMEM/MEDMEM_Connectivity.cxx @@ -101,7 +101,7 @@ CONNECTIVITY::CONNECTIVITY (const CONNECTIVITY & m): else _geometricTypes = (medGeometryElement *) NULL; - if (m._type != NULL) + if (m._type != NULL) { _type = new CELLMODEL[_numberOfTypes]; for (int i=0;i<_numberOfTypes;i++) @@ -219,7 +219,7 @@ void CONNECTIVITY::setConstituent(CONNECTIVITY * Constituent) if (Entity == MED_CELL) throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setConstituent : could not set constituent on MED_CELL !")); - if ((Entity == MED_EDGE)&(_entityDimension == 3)) + if ((Entity == MED_EDGE)&(_entityDimension == 3)) { if (_constituent == NULL) throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setConstituent : Entity not found !")); @@ -237,13 +237,13 @@ void CONNECTIVITY::setGeometricTypes(const medGeometryElement * Types, //--------------------------------------------------------------------// { if (Entity == _entity) - for (int i=0; i<_numberOfTypes; i++) + for (int i=0; i<_numberOfTypes; i++) { _geometricTypes[i] = Types[i]; _type[i] = CELLMODEL(_geometricTypes[i]); } - else - { + else + { if (_constituent == NULL) throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setGeometricTypes : Entity not found !")); _constituent->setGeometricTypes(Types,Entity); @@ -256,7 +256,7 @@ void CONNECTIVITY::setCount(const int * Count, const medEntityMesh Entity) throw (MEDEXCEPTION) //--------------------------------------------------------------------// { - if (Entity == _entity) + if (Entity == _entity) { int * index = new int[Count[_numberOfTypes]]; index[0]=1; @@ -288,7 +288,7 @@ void CONNECTIVITY::setNodal(const int * Connectivity, throw (MEDEXCEPTION) //--------------------------------------------------------------------// { - if (_entity == Entity) + if (_entity == Entity) { // find geometric type bool find = false; @@ -302,7 +302,7 @@ void CONNECTIVITY::setNodal(const int * Connectivity, } if (!find) throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setNodal : geometric type not found")); - } else + } else { if (_constituent == NULL) throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setNodal : Entity not found !")); @@ -388,11 +388,11 @@ void CONNECTIVITY::calculateConnectivity(medConnectivity ConnectivityType, medEn // a temporary limitation due to calculteDescendingConnectivity function !!! if ((_entityDimension==3) & (Entity==MED_EDGE)) throw MEDEXCEPTION("CONNECTIVITY::calculateConnectivity : Could not build EDGE !"); - + if (Entity==_entity) if (ConnectivityType==MED_NODAL) calculateNodalConnectivity(); - else + else if (Entity==MED_CELL) calculateDescendingConnectivity(); else @@ -407,11 +407,11 @@ void CONNECTIVITY::calculateConnectivity(medConnectivity ConnectivityType, medEn /*! Give, in full or no interlace mode (for nodal connectivity), descending or nodal connectivity. - You must give a %medEntityMesh (ie:MED_EDGE) + You must give a %medEntityMesh (ie:MED_EDGE) and a %medGeometryElement (ie:MED_SEG3). */ //------------------------------------------------------------// -void CONNECTIVITY::updateFamily(const vector& myFamilies) +void CONNECTIVITY::updateFamily(const vector& myFamilies) //------------------------------------------------------------// { const char * LOC = "CONNECTIVITY::updateFamily(vector) "; @@ -438,12 +438,12 @@ void CONNECTIVITY::updateFamily(const vector& myFamilies) const int * oldConstituentValue = oldConstituent->_nodal->getValue(); oldConstituentValueTab[0]=oldConstituentValue; const int * oldConstituentIndex = oldConstituent->_nodal->getIndex(); oldConstituentIndexTab[0]=oldConstituentIndex; int * renumberingFromOldToNew= new int [oldNumberOfFace]; renumberingFromOldToNewTab[0]=renumberingFromOldToNew; - + int oldNumberOfFacePoly = oldConstituent->getNumberOfPolygons(); const int * oldConstituentValuePoly=0; const int * oldConstituentIndexPoly=0; int * renumberingFromOldToNewPoly=0; - + int nbOfTurnInGlobalLoop=1;//Defined to know if a second search on polygons is needed. if(oldNumberOfFacePoly>0) { @@ -453,10 +453,10 @@ void CONNECTIVITY::updateFamily(const vector& myFamilies) renumberingFromOldToNewPoly=new int[oldNumberOfFacePoly]; renumberingFromOldToNewTab[1]=renumberingFromOldToNewPoly; nbOfTurnInGlobalLoop++; } - - calculateDescendingConnectivity();//perform calculation of descending connectivity to update all connectivities after having taken into account of direction of faces... - _constituent->calculateReverseNodalConnectivity();//getting d-1 nodal connectivity to find get new face numbers from nodes numbers... - + + calculateDescendingConnectivity();//perform calculation of descending connectivity to update all connectivities after having taken into account of direction of faces... + _constituent->calculateReverseNodalConnectivity();//getting d-1 nodal connectivity to find get new face numbers from nodes numbers... + const int * reverseFaceNodal = _constituent->getReverseNodalConnectivity(); //Common to polygons and classic geometric types const int * reverseFaceNodalIndex = _constituent->getReverseNodalConnectivityIndex(); //Common to polygons and classic geometric types @@ -521,7 +521,7 @@ void CONNECTIVITY::updateFamily(const vector& myFamilies) } //------------------------------------------------------------------------------------------------------------------// -const int * MEDMEM::CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type) +const int * MEDMEM::CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type) //------------------------------------------------------------------------------------------------------------------// { const char * LOC = "CONNECTIVITY::getConnectivity"; @@ -529,7 +529,7 @@ const int * MEDMEM::CONNECTIVITY::getConnectivity(medConnectivity ConnectivityTy MEDSKYLINEARRAY * Connectivity; if (Entity==_entity) { - + if (ConnectivityType==MED_NODAL) { calculateNodalConnectivity(); @@ -540,7 +540,7 @@ const int * MEDMEM::CONNECTIVITY::getConnectivity(medConnectivity ConnectivityTy calculateDescendingConnectivity(); Connectivity=_descending; } - + if (Connectivity!=NULL) if (Type==MED_ALL_ELEMENTS) return Connectivity->getValue(); @@ -553,12 +553,12 @@ const int * MEDMEM::CONNECTIVITY::getConnectivity(medConnectivity ConnectivityTy } else throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")); - } else + } else if (_constituent != NULL) return _constituent->getConnectivity(ConnectivityType,Entity,Type); - + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")); -} +} //------------------------------------------------------------------------------------------------------------------// int CONNECTIVITY::getConnectivityLength(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type) @@ -569,7 +569,7 @@ int CONNECTIVITY::getConnectivityLength(medConnectivity ConnectivityType, medEnt MEDSKYLINEARRAY * Connectivity; if (Entity==_entity) { - + if (ConnectivityType==MED_NODAL) { calculateNodalConnectivity(); @@ -580,7 +580,7 @@ int CONNECTIVITY::getConnectivityLength(medConnectivity ConnectivityType, medEnt calculateDescendingConnectivity(); Connectivity=_descending; } - + if (Connectivity!=NULL) if (Type==MED_ALL_ELEMENTS) return Connectivity->getLength(); @@ -592,13 +592,13 @@ int CONNECTIVITY::getConnectivityLength(medConnectivity ConnectivityType, medEnt } else throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")); - } - else + } + else if (_constituent != NULL) return _constituent->getConnectivityLength(ConnectivityType,Entity,Type); - + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")); -} +} /*! Give morse index array to use with getConnectivity(MED_FULL_INTERLACE,mode,entity,MED_ALL_ELEMENTS). @@ -609,26 +609,26 @@ int CONNECTIVITY::getConnectivityLength(medConnectivity ConnectivityType, medEnt - In C mode : Connectivity[ConnectivityIndex[i]-1+j-1] - In fortran mode : Connectivity[ConnectivityIndex[i]+j] */ //-----------------------------------------------------------------------------------------------// -const int * CONNECTIVITY::getConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity) -//----0000000--------------------------------------------------------------------------------------------// +const int * CONNECTIVITY::getConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity) +//-----------------------------------------------------------------------------------------------// { const char * LOC = "CONNECTIVITY::getConnectivityIndex"; BEGIN_OF(LOC); MEDSKYLINEARRAY * Connectivity; if (Entity==_entity) { - + if (ConnectivityType==MED_NODAL) Connectivity=_nodal; else Connectivity=_descending; - + if (Connectivity!=NULL) return Connectivity->getIndex(); - else + else throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")); - } else + } else if (_constituent != NULL) return _constituent->getConnectivityIndex(ConnectivityType,Entity); @@ -881,7 +881,7 @@ int CONNECTIVITY::getNumberOfSubCellInType(medGeometryElement Type) const int CONNECTIVITY::getNumberOf(medEntityMesh Entity, medGeometryElement Type) const //-----------------------------------------------------------------------------------// { - const char * LOC = "CONNECTIVITY::getNumberOf"; + //const char * LOC = "CONNECTIVITY::getNumberOf"; if (Entity==_entity) { if (Type==MED_NONE) return 0; // not defined ! @@ -893,7 +893,7 @@ int CONNECTIVITY::getNumberOf(medEntityMesh Entity, medGeometryElement Type) con if (_geometricTypes[i]==Type) return (_count[i+1] - _count[i]); //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !")); - } else + } else if (_constituent != NULL) return _constituent->getNumberOf(Entity,Type); @@ -903,11 +903,11 @@ int CONNECTIVITY::getNumberOf(medEntityMesh Entity, medGeometryElement Type) con /*! A DOCUMENTER */ //--------------------------------------------------------------// -const int* CONNECTIVITY::getValue(medConnectivity TypeConnectivity, +const int* CONNECTIVITY::getValue(medConnectivity TypeConnectivity, medGeometryElement Type) //--------------------------------------------------------------// { - if (TypeConnectivity == MED_NODAL) + if (TypeConnectivity == MED_NODAL) { calculateNodalConnectivity(); if (Type==MED_ALL_ELEMENTS) @@ -915,8 +915,8 @@ const int* CONNECTIVITY::getValue(medConnectivity TypeConnectivity, for (int i=0; i<_numberOfTypes; i++) if (_geometricTypes[i]==Type) return _nodal->getI(_count[i]); - } - else + } + else { calculateDescendingConnectivity(); if (Type==MED_ALL_ELEMENTS) @@ -930,15 +930,15 @@ const int* CONNECTIVITY::getValue(medConnectivity TypeConnectivity, /*! A DOCUMENTER */ //---------------------------------------------------------------------// -const int* CONNECTIVITY:: getValueIndex(medConnectivity TypeConnectivity) +const int* CONNECTIVITY:: getValueIndex(medConnectivity TypeConnectivity) //---------------------------------------------------------------------// { - if (TypeConnectivity == MED_NODAL) + if (TypeConnectivity == MED_NODAL) { calculateNodalConnectivity(); return _nodal->getIndex(); } - else + else { calculateDescendingConnectivity(); return _descending->getIndex(); @@ -956,7 +956,7 @@ const int* CONNECTIVITY:: getNeighbourhood() const /*! Returns an array which contains, for each node, all cells arround it. */ //-------------------------------------------------// -const int* CONNECTIVITY::getReverseNodalConnectivity() +const int* CONNECTIVITY::getReverseNodalConnectivity() //-------------------------------------------------// { calculateReverseNodalConnectivity(); @@ -966,7 +966,7 @@ const 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. */ //-------------------------------------------------------// -const int* CONNECTIVITY::getReverseNodalConnectivityIndex() +const int* CONNECTIVITY::getReverseNodalConnectivityIndex() //-------------------------------------------------------// { calculateReverseNodalConnectivity(); @@ -977,30 +977,30 @@ const int* CONNECTIVITY::getReverseNodalConnectivityIndex() the 2 cells of each side. First is cell which face normal is outgoing. arround it. */ //------------------------------------------------------// -const int* CONNECTIVITY::getReverseDescendingConnectivity() +const int* CONNECTIVITY::getReverseDescendingConnectivity() //------------------------------------------------------// { - // it is in _constituent connectivity only if we are in MED_CELL + // 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 + // we need descending connectivity calculateDescendingConnectivity(); return _reverseDescendingConnectivity->getValue(); } -/*! calculate the reverse descending Connectivity +/*! calculate the reverse descending Connectivity and returns the index ( A DOCUMENTER MIEUX)*/ //-----------------------------------------------------------// -const int* CONNECTIVITY::getReverseDescendingConnectivityIndex() +const int* CONNECTIVITY::getReverseDescendingConnectivityIndex() //-----------------------------------------------------------// { // it is in _constituent connectivity only if we are in MED_CELL - if (_entity!=MED_CELL) + if (_entity!=MED_CELL) throw MEDEXCEPTION("CONNECTIVITY::getReverseDescendingConnectivityIndex : Error Only in MED_CELL connectivity"); - // we need descending connectivity + // we need descending connectivity calculateDescendingConnectivity(); return _reverseDescendingConnectivity->getIndex(); } @@ -1010,7 +1010,7 @@ const int* CONNECTIVITY::getReverseDescendingConnectivityIndex() void CONNECTIVITY::calculateNodalConnectivity() //--------------------------------------------// { - if (_nodal==NULL && _polygonsNodal==NULL && _polyhedronNodal==NULL) + if (_nodal==NULL && _polygonsNodal==NULL && _polyhedronNodal==NULL) { if (_descending==NULL && _polygonsDescending==NULL && _polyhedronDescending==NULL) throw MEDEXCEPTION("CONNECTIVITY::calculateNodalConnectivity : No connectivity found !"); @@ -1018,7 +1018,7 @@ void CONNECTIVITY::calculateNodalConnectivity() } } -/*! If not yet done, calculate the nodal Connectivity +/*! If not yet done, calculate the nodal Connectivity and the reverse nodal Connectivity*/ //---------------------------------------------------// void CONNECTIVITY::calculateReverseNodalConnectivity() @@ -1030,17 +1030,17 @@ void CONNECTIVITY::calculateReverseNodalConnectivity() SCRUTE(_nodal); SCRUTE(_reverseNodalConnectivity); - if (_nodal==NULL) + if (_nodal==NULL) calculateNodalConnectivity(); - + if(_reverseNodalConnectivity==NULL) { int node_number = 0; - vector > reverse_connectivity; + vector > reverse_connectivity; reverse_connectivity.resize(_numberOfNodes+1); - + // Treat all cells types - + for (int j = 0; j < _numberOfTypes; j++) { // node number of the cell type @@ -1082,7 +1082,7 @@ void CONNECTIVITY::calculateReverseNodalConnectivity() delete [] nodes; } } - + // Full reverse_nodal_connectivity and reverse_nodal_connectivity_index //calculate size of reverse_nodal_connectivity array @@ -1096,7 +1096,7 @@ void CONNECTIVITY::calculateReverseNodalConnectivity() reverse_nodal_connectivity_index[0] = 1; for (int i = 1; i < _numberOfNodes+1; i++) { - int size = reverse_connectivity[i].size(); + int size = reverse_connectivity[i].size(); reverse_nodal_connectivity_index[i] = reverse_nodal_connectivity_index[i-1] + size; for (int j = 0; j < size; j++) reverse_nodal_connectivity[reverse_nodal_connectivity_index[i-1]-1+j]= reverse_connectivity[i][j]; @@ -1116,7 +1116,7 @@ void CONNECTIVITY::calculateDescendingConnectivity() { const char * LOC = "CONNECTIVITY::calculateDescendingConnectivity() : "; BEGIN_OF(LOC); - + if (_descending==NULL && _polygonsDescending==NULL && _polyhedronDescending==NULL) { if (_nodal==NULL) @@ -1126,8 +1126,8 @@ void CONNECTIVITY::calculateDescendingConnectivity() } // calcul _descending from _nodal // we need CONNECTIVITY for constituent - - if (_constituent != NULL) + + if (_constituent != NULL) // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"ERROR : No descending connectivity defined, but constituent exist !")); MESSAGE(LOC<<": No descending connectivity defined, but constituent exist !"); @@ -1145,7 +1145,7 @@ void CONNECTIVITY::calculateDescendingConnectivity() _constituent->_numberOfNodes = _numberOfNodes; // foreach cells, we built array of constituent int DescendingSize = 0; - for(int i=0; i<_numberOfTypes; i++) + for(int i=0; i<_numberOfTypes; i++) DescendingSize+=(_count[i+1]-_count[i])*_type[i].getNumberOfConstituents(1); //_descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,DescendingSize); //const int * descend_connectivity = _descending->getValue(); @@ -1193,10 +1193,10 @@ void CONNECTIVITY::calculateDescendingConnectivity() // we could built _constituent ! 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 + // we use _constituent->_nodal //const int * ConstituentNodalConnectivity = _constituent->_nodal->getValue(); //const int * ConstituentNodalConnectivityIndex = _constituent->_nodal->getIndex(); int * ConstituentNodalConnectivity = new int[TotalNumberOfNodes]; @@ -1225,7 +1225,7 @@ void CONNECTIVITY::calculateDescendingConnectivity() } delete [] ConstituentsTypes; delete [] NumberOfConstituentsForeachType; - + // we need reverse nodal connectivity if (! _reverseNodalConnectivity) calculateReverseNodalConnectivity(); @@ -1234,7 +1234,7 @@ void CONNECTIVITY::calculateDescendingConnectivity() // array to keep reverse descending connectivity int * ReverseDescendingConnectivityValue = new int[TotalNumberOfConstituents*2]; - + int TotalNumberOfSubCell = 0; for (int i=0; i<_numberOfTypes; i++) { // loop on all cell type @@ -1256,11 +1256,11 @@ void CONNECTIVITY::calculateDescendingConnectivity() TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[1]; } //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; - + int * NodesLists = new int[NumberOfNodesPerConstituent]; for (int l=0; lgetIJ(j,Type.getNodeConstituent(1,k,l+1)); @@ -1279,7 +1279,7 @@ void CONNECTIVITY::calculateDescendingConnectivity() int * CellsList = new int[NumberOfCellsInList]; for (int l=ReverseNodalConnectivityIndex_0; l 0) { // We have found some elements ! int CellNumber = CellsList[0]; //delete [] CellsList; @@ -1315,7 +1315,7 @@ void CONNECTIVITY::calculateDescendingConnectivity() if (NumberOfCellsInList==1) { ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=CellNumber; - + // we search sub cell number in this cell to not calculate it another time // which type ? CELLMODEL Type2; @@ -1331,7 +1331,7 @@ void CONNECTIVITY::calculateDescendingConnectivity() int counter = 0; for (int m=1; m<=Type2.getConstituentType(1,l)%100; m++) for (int n=1; n<=Type.getConstituentType(1,k)%100; n++) - { + { if (_nodal->getIJ(CellNumber,Type2.getNodeConstituent(1,l,m)) == NodesLists[n-1]) counter++; } @@ -1345,7 +1345,7 @@ void CONNECTIVITY::calculateDescendingConnectivity() } if (!find2) MESSAGE(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!"); // exception ? - } + } } else { ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0; } @@ -1370,7 +1370,7 @@ void CONNECTIVITY::calculateDescendingConnectivity() int *ConstituentNodalValue = new int[SizeOfConstituentNodal]; int *ConstituentNodalIndex = new int[NumberOfConstituent+1]; ConstituentNodalIndex[0]=1; - // we build _reverseDescendingConnectivity + // we build _reverseDescendingConnectivity //_reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,2*NumberOfConstituent); //const int *reverseDescendingConnectivityValue = _reverseDescendingConnectivity->getValue(); //const int *reverseDescendingConnectivityIndex = _reverseDescendingConnectivity->getIndex(); @@ -1620,7 +1620,7 @@ void CONNECTIVITY::calculateNeighbourhood(CONNECTIVITY &myConnectivity) } -/*! +/*! Returns the geometry of an element given by its entity type & its global number. Example : medGeometryElement myType = myConnectivity.getElementType(MED_CELL,35); @@ -1642,7 +1642,7 @@ medGeometryElement CONNECTIVITY::getElementType(medEntityMesh Entity,int globalN // The globalNumber must verify : 1 <= globalNumber < _count[_numberOfTypes] (== totalNumberOfElement+1) if ( (globalNumber < globalNumberMin) || (globalNumber > globalNumberMax-1 ) ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "globalNumber must be between >= |" + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "globalNumber must be between >= |" << globalNumberMin <<"| and <= |" << globalNumberMax-1 )); if (_entity==Entity) { @@ -1659,7 +1659,7 @@ medGeometryElement CONNECTIVITY::getElementType(medEntityMesh Entity,int globalN END_OF(LOC); } -/*! +/*! Idem as getElementType method except that it manages polygon and polyhedron. */ //--------------------------------------------------------------------// @@ -1724,7 +1724,7 @@ ostream & MEDMEM::operator<<(ostream &os, CONNECTIVITY &co) default: os << "Unknown"; break; - } + } os << " -------------\n\nMedConnectivity : "; switch (co._typeConnectivity) { @@ -1736,17 +1736,17 @@ ostream & MEDMEM::operator<<(ostream &os, CONNECTIVITY &co) break; default: break; - } + } os << "Entity dimension : " << co._entityDimension << endl; os << "Number of nodes : " << co._numberOfNodes << endl; os << "Number of types : " << co._numberOfTypes << endl; for (int i=0; i!=co._numberOfTypes ; ++i) - os << " -> Type " << co._geometricTypes[i] << " (" << co._type[i].getName() << ") : " + os << " -> Type " << co._geometricTypes[i] << " (" << co._type[i].getName() << ") : " << co._count[i+1]-co._count[i] << " elements" << endl; if (co._typeConnectivity == MED_NODAL ) { - for (int i=0; igetNumberOfTypesWithPoly(Entity); else @@ -1980,7 +1980,7 @@ MED_EN::medGeometryElement * CONNECTIVITY::getGeometricTypesWithPoly(MED_EN::med /* Method used in CalculateDescendingConnectivity. So it's typically a private method. - The aim of this method is to hide to CalculateDescendingConnectivity algorithm the fact that in reverse connectivity polygons and polyhedrons + The aim of this method is to hide to CalculateDescendingConnectivity algorithm the fact that in reverse connectivity polygons and polyhedrons are not in separate data structure, contrary to not reverse connectivities. */ int CONNECTIVITY::getIndexOfEndClassicElementInReverseNodal(const int *reverseNodalValue, const int *reverseNodalIndex, int rk) const @@ -2005,9 +2005,9 @@ void CONNECTIVITY::invertConnectivityForAFace(int faceId, const int *nodalConnFo // we have always 2 neighbourings int cell1 = _reverseDescendingConnectivity->getIJ(faceId,1); int cell2 = _reverseDescendingConnectivity->getIJ(faceId,2); - + if (cell2 != 0) { // we are not on border, update compulsary. If we aren't on border no update necessary so WARNING because user specified a bad oriented face - // Updating _reverseDescendingConnectivity + // Updating _reverseDescendingConnectivity _reverseDescendingConnectivity->setIJ(faceId,1,cell2); _reverseDescendingConnectivity->setIJ(faceId,2,cell1); // Updating _constituent->_nodal because of reversity @@ -2017,20 +2017,20 @@ void CONNECTIVITY::invertConnectivityForAFace(int faceId, const int *nodalConnFo const int *newDescendingIndex=(!polygonFace)?_descending->getIndex():_polygonsDescending->getIndex(); for(int iarray=1;iarray<=(descendingNodalIndex[faceId]-descendingNodalIndex[faceId-1]);iarray++) currentNodal->setIJ(faceId,iarray,nodalConnForFace[iarray-1]); - + // Updating _descending for cell1 and cell2 for(int iface=newDescendingIndex[cell1-1];iface<=newDescendingIndex[cell1];iface++) if (currentDescending->getIndexValue(iface)==faceId) currentDescending->setIndexValue(iface,-faceId); else if (currentDescending->getIndexValue(iface)==-faceId) currentDescending->setIndexValue(iface,faceId); - + for(int iface=newDescendingIndex[cell2-1];ifacegetIndexValue(iface)==faceId) currentDescending->setIndexValue(iface,-faceId); else if (_descending->getIndexValue(iface)==-faceId) currentDescending->setIndexValue(iface,faceId); - } + } } /* @@ -2125,7 +2125,7 @@ int CONNECTIVITY::getNumberOfElementsWithPoly(MED_EN::medEntityMesh Entity, MED_ if(Type==MED_POLYGON || Type==MED_POLYHEDRA) return getNumberOfElementOfPolyType(_entity); else - return getNumberOf(_entity,Type); + return getNumberOf(_entity,Type); } else { @@ -2136,7 +2136,7 @@ int CONNECTIVITY::getNumberOfElementsWithPoly(MED_EN::medEntityMesh Entity, MED_ } } -/*! +/*! Perform a deep comparison of the 2 connectivities in NODAL mode and on all elements. */ bool CONNECTIVITY::deepCompare(const CONNECTIVITY& other) const diff --git a/src/MEDMEM/MEDMEM_Connectivity.hxx b/src/MEDMEM/MEDMEM_Connectivity.hxx index 3e568055e..3aad25c69 100644 --- a/src/MEDMEM/MEDMEM_Connectivity.hxx +++ b/src/MEDMEM/MEDMEM_Connectivity.hxx @@ -16,7 +16,7 @@ class GROUP; /*! This class deals with all type of connectivity .\n - it a recursive class. + it a recursive class. */ /* ------------------------------------------- */ @@ -29,32 +29,32 @@ class CONNECTIVITY protected: /*! contains MED_CELL MED_FACE or MED_EDGE */ - MED_EN::medEntityMesh _entity; + MED_EN::medEntityMesh _entity; /*! contains MED_NODAL or MED_DESCEND */ MED_EN::medConnectivity _typeConnectivity; - /*! count of differents cells types - used by the mesh */ - int _numberOfTypes; + /*! count of differents cells types + used by the mesh */ + int _numberOfTypes; /*! array of all med_geometric_type used by MESH. */ MED_EN::medGeometryElement* _geometricTypes; - /*! map indexed by med_geometric_type - which contains the different + /*! map indexed by med_geometric_type + which contains the different 'CellModel' used by MESH. */ - CELLMODEL * _type; + CELLMODEL * _type; /*! contains the dimension of the entity */ int _entityDimension; /*! needed by calculateReverseNodalConnectivity */ int _numberOfNodes; - /*! array of size _numberOfTypes+1 which - gives for each cell type the first + /*! array of size _numberOfTypes+1 which + gives for each cell type the first cell number in _nodal or _descending - array (depends on _typeConnectivity) - To get cells count for one type, we + array (depends on _typeConnectivity) + To get cells count for one type, we must minus _count[i+1] and _count[i] - ( 0 <= i < _numberOfTypes ). + ( 0 <= i < _numberOfTypes ). Note that _count[_numberOfTypes] returns total cells count + 1 */ int * _count; @@ -65,29 +65,29 @@ protected: MEDSKYLINEARRAY* _polygonsNodal; /*! pointer to an array which stores the nodal connectivity only for polyhedron */ POLYHEDRONARRAY* _polyhedronNodal; - /*! pointer to an array which stores + /*! pointer to an array which stores the descending connectivity */ MEDSKYLINEARRAY* _descending; /*! pointer to an array which stores the descending connectivity only for polygons */ MEDSKYLINEARRAY* _polygonsDescending; /*! pointer to an array which stores the descending connectivity only for polyhedron */ MEDSKYLINEARRAY* _polyhedronDescending; - /*! pointer to an array which stores + /*! pointer to an array which stores the reverse nodal connectivity */ MEDSKYLINEARRAY* _reverseNodalConnectivity; - /*! pointer to an array which stores + /*! pointer to an array which stores the reverse descending connectivity */ MEDSKYLINEARRAY* _reverseDescendingConnectivity; - /*! if face or edge, list of 2 cells or + /*! 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 + 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; - /*! connectivity of sub cell if + /*! connectivity of sub cell if descendant connectivity is calculated */ - CONNECTIVITY * _constituent; + CONNECTIVITY * _constituent; /* -------------------- */ /* Class Methods */ @@ -95,17 +95,17 @@ protected: private: /*! private method :\n - does nothing if already exists, else + does nothing if already exists, else evaluates _nodal from _descending */ - void calculateNodalConnectivity(); + void calculateNodalConnectivity(); /*! private method :\n does nothing if already exists, else - evaluates from _nodal */ - void calculateReverseNodalConnectivity(); + evaluates from _nodal */ + void calculateReverseNodalConnectivity(); /*! private method :\n does nothing if already exists, else - evaluates _descending from _nodal */ - void calculateDescendingConnectivity(); + evaluates _descending from _nodal */ + void calculateDescendingConnectivity(); /*! private method :\n does nothing if already exists, else evaluates from _descending */ @@ -159,7 +159,7 @@ public: throw (MEDEXCEPTION); inline void setNumberOfNodes(int NumberOfNodes); - + inline int getEntityDimension() const; inline void setEntityDimension(int EntityDimension); @@ -210,12 +210,13 @@ public: virtual inline const int * getGlobalNumberingIndex (MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION); - virtual const int * getConnectivity (MED_EN::medConnectivity ConnectivityType, + virtual const int * getConnectivity (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity, MED_EN::medGeometryElement Type); - virtual int getConnectivityLength (MED_EN::medConnectivity ConnectivityType, + virtual int getConnectivityLength (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity, MED_EN::medGeometryElement Type); + virtual const int * getConnectivityIndex (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity); @@ -231,22 +232,22 @@ public: int getNumberOfPolyhedron() const; int *getNodesOfPolyhedron(int polyhedronId, int& lgthOfTab) const; int **getNodesPerFaceOfPolyhedron(int polyhedronId, int& nbOfFaces, int* & nbOfNodesPerFaces) const; - const CELLMODEL & getType (MED_EN::medGeometryElement Type) const; - const CELLMODEL * getCellsTypes (MED_EN::medEntityMesh Entity) const + const CELLMODEL & getType (MED_EN::medGeometryElement Type) const; + const CELLMODEL * getCellsTypes (MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION); - - int getNumberOfNodesInType (MED_EN::medGeometryElement Type) const; - int getNumberOfSubCellInType (MED_EN::medGeometryElement Type) const; - virtual int getNumberOf (MED_EN::medEntityMesh Entity, + + int getNumberOfNodesInType (MED_EN::medGeometryElement Type) const; + int getNumberOfSubCellInType (MED_EN::medGeometryElement Type) const; + virtual int getNumberOf (MED_EN::medEntityMesh Entity, MED_EN::medGeometryElement Type) const; - virtual const int* getValue (MED_EN::medConnectivity TypeConnectivity, - MED_EN::medGeometryElement Type); + virtual const int* getValue (MED_EN::medConnectivity TypeConnectivity, + MED_EN::medGeometryElement Type); virtual const int* getValueIndex (MED_EN::medConnectivity TypeConnectivity); - virtual inline const int* getReverseConnectivity (MED_EN::medConnectivity ConnectivityType, + virtual inline const int* getReverseConnectivity (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) throw (MEDEXCEPTION); - virtual inline const int* getReverseConnectivityIndex (MED_EN::medConnectivity ConnectivityType, + virtual inline const int* getReverseConnectivityIndex (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) throw (MEDEXCEPTION); @@ -260,13 +261,13 @@ public: /*! Returns the medEntityMesh */ //--------------------------------------------------// -inline MED_EN::medEntityMesh CONNECTIVITY::getEntity() const +inline MED_EN::medEntityMesh CONNECTIVITY::getEntity() const //--------------------------------------------------// -{ - return _entity; +{ + return _entity; } -/*! Returns the number of different %medGeometryElement types +/*! Returns the number of different %medGeometryElement types existing in the specified entity. \n Note : Not implemented for MED_ALL_ENTITIES. */ //-----------------------------------------------------------------------// @@ -275,7 +276,7 @@ inline int CONNECTIVITY::getNumberOfTypes(MED_EN::medEntityMesh Entity) const { MESSAGE("CONNECTIVITY::getNumberOfTypes : Entity = "<addReference(); } FIELD_::FIELD_(const FIELD_ &m) @@ -46,6 +48,8 @@ FIELD_::FIELD_(const FIELD_ &m) _name = m._name; _description = m._description; _support = m._support; + if(_support) + _support->addReference(); _numberOfComponents = m._numberOfComponents; _numberOfValues = m._numberOfValues; copyGlobalInfo(m); @@ -66,7 +70,6 @@ FIELD_::~FIELD_() delete[] _componentsUnits ; if ( _MEDComponentsUnits !=NULL) delete[] _MEDComponentsUnits ; - // delete driver // vector::const_iterator it ; // SCRUTE(_drivers.size()); @@ -284,11 +287,13 @@ int FIELD_::addDriver (driverTypes driverType, MESSAGE("int FIELD_::addDriver(driverTypes driverType, const string & fileName, const string & driverFieldName) : adding the driver " << driverType << " fileName = " << fileName.c_str() << " driverFieldName = " << driverFieldName.c_str()); return 0; }; + int FIELD_::addDriver (GENDRIVER & driver) { MESSAGE("int FIELD_::addDriver(GENDRIVER & driver) : driver " << driver); return 0; }; + void FIELD_::openAppend ( void ) {}; void FIELD_::write (const GENDRIVER &) {}; void FIELD_::writeAppend (const GENDRIVER &) {}; diff --git a/src/MEDMEM/MEDMEM_Field.hxx b/src/MEDMEM/MEDMEM_Field.hxx index 0665ed84e..1e39eae57 100644 --- a/src/MEDMEM/MEDMEM_Field.hxx +++ b/src/MEDMEM/MEDMEM_Field.hxx @@ -8,6 +8,7 @@ #include #include +#include #include #include "utilities.h" @@ -91,7 +92,7 @@ protected: storing components names if any. \endif */ - string * _componentsNames; + string * _componentsNames; /*! \if developper Array of size _numberOfComponents @@ -117,7 +118,7 @@ protected: double _time; int _orderNumber ; - // _valueType should be a static const. Here is an initialization exemple + // _valueType should be a static const. Here is an initialization exemple // template < classType T > struct SET_VALUE_TYPE { static const med_type_champ _valueType = 0; } // template < > struct SET_VALUE_TYPE { static const med_type_champ _valueType = MED_EN::MED_REEL64; } // template < > struct SET_VALUE_TYPE { static const med_type_champ _valueType = MED_EN::MED_INT32; } @@ -126,7 +127,7 @@ protected: vector _drivers; // Storage of the drivers currently in use static void _checkFieldCompatibility(const FIELD_& m, const FIELD_& n, bool checkUnit=true) throw (MEDEXCEPTION); - static void _deepCheckFieldCompatibility(const FIELD_& m, const FIELD_& n, bool checkUnit=true ) throw (MEDEXCEPTION); + static void _deepCheckFieldCompatibility(const FIELD_& m, const FIELD_& n, bool checkUnit=true) throw (MEDEXCEPTION); void _checkNormCompatibility(const FIELD* p_field_volume=NULL) const throw (MEDEXCEPTION); FIELD* _getFieldSize() const; @@ -343,7 +344,7 @@ inline string FIELD_::getComponentName(int i) const /*! Set FIELD components descriptions. - Duplicate the ComponentsDescriptions string array to put components + Duplicate the ComponentsDescriptions string array to put components descriptions in FIELD. ComponentsDescriptions size must be equal to number of components. */ @@ -384,7 +385,7 @@ inline string FIELD_::getComponentDescription(int i) const \todo Set FIELD components UNIT. - Duplicate the ComponentsUnits UNIT array to put components + Duplicate the ComponentsUnits UNIT array to put components units in FIELD. ComponentsUnits size must be equal to number of components. */ @@ -414,10 +415,10 @@ inline const UNIT * FIELD_::getComponentUnit(int i) const /*! Set FIELD components unit. - Duplicate the MEDComponentsUnits string array to put components + Duplicate the MEDComponentsUnits string array to put components units in FIELD. MEDComponentsUnits size must be equal to number of components. - + */ inline void FIELD_::setMEDComponentsUnits(const string * MEDComponentsUnits) { @@ -509,7 +510,12 @@ inline const SUPPORT * FIELD_::getSupport() const */ inline void FIELD_::setSupport(const SUPPORT * support) { + //A.G. Addings for RC + if(_support) + _support->removeReference(); _support = support ; + if(_support) + _support->addReference(); } /*! Get the FIELD med value type (MED_INT32 or MED_REEL64). @@ -546,7 +552,7 @@ namespace MEDMEM { template class MED_FIELD_RDONLY_DRIVER22; template class MED_FIELD_WRONLY_DRIVER22; template class VTK_FIELD_DRIVER; - + template class FIELD : public FIELD_ { protected: @@ -554,8 +560,10 @@ protected: // array of value of type T MEDARRAY *_value ; + static T _scalarForPow; static T pow(T x); + private: void _operation(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode, char* Op); void _operationInitialize(const FIELD& m,const FIELD& n, char* Op); @@ -798,7 +806,7 @@ template FIELD & FIELD::operator=(const FIELD &m) - _componentsTypes - _MEDComponentsUnits. - The data members of the returned field are initialized, based on the first field, except for the name, + The data members of the returned field are initialized, based on the first field, except for the name, which is the combination of the two field's names and the operator. Advised Utilisation in C++ : FIELD c = a + b; \n In this case, the (recent) compilators perform optimisation and don't call the copy constructor. @@ -820,7 +828,7 @@ const FIELD FIELD::operator+(const FIELD & m) const mode=m.getvalue()->getMode(); else mode=this->getvalue()->getMode(); - + // Creation of the result - memory is allocated by FIELD constructor FIELD result(this->getSupport(),this->getNumberOfComponents(),mode); //result._operation(*this,m,mode,"+"); // perform Atribute's initialization & addition @@ -875,7 +883,7 @@ FIELD* FIELD::add(const FIELD& m, const FIELD& n) mode=m.getvalue()->getMode(); else mode=n.getvalue()->getMode(); - + // Creation of a new field FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); result->_operationInitialize(m,n,"+"); // perform Atribute's initialization @@ -899,7 +907,7 @@ FIELD* FIELD::addDeep(const FIELD& m, const FIELD& n) mode=m.getvalue()->getMode(); else mode=n.getvalue()->getMode(); - + // Creation of a new field FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); result->_operationInitialize(m,n,"+"); // perform Atribute's initialization @@ -919,7 +927,7 @@ FIELD* FIELD::addDeep(const FIELD& m, const FIELD& n) - _componentsTypes - _MEDComponentsUnits. - The data members of the returned field are initialized, based on the first field, except for the name, + The data members of the returned field are initialized, based on the first field, except for the name, which is the combination of the two field's names and the operator. Advised Utilisation in C++ : FIELD c = a - b; \n In this case, the (recent) compilators perform optimisation and don't call the copy constructor. @@ -940,7 +948,7 @@ const FIELD FIELD::operator-(const FIELD & m) const mode=m.getvalue()->getMode(); else mode=this->getvalue()->getMode(); - + // Creation of the result - memory is allocated by FIELD constructor FIELD result(this->getSupport(),this->getNumberOfComponents(),mode); //result._operation(*this,m,mode,"-"); // perform Atribute's initialization & substraction @@ -959,7 +967,7 @@ const FIELD FIELD::operator-() const MED_EN::medModeSwitch mode=this->getvalue()->getMode(); // Creation of the result - memory is allocated by FIELD constructor FIELD result(this->getSupport(),this->getNumberOfComponents(),mode); - // Atribute's initialization + // Atribute's initialization result.setName("- "+getName()); result.setComponentsNames(getComponentsNames()); // not yet implemented setComponentType(getComponentType()); @@ -971,7 +979,7 @@ const FIELD FIELD::operator-() const result.setOrderNumber(getOrderNumber()); result.setValueType(getValueType()); - const T* value1=getValue(mode); + const T* value1=getValue(mode); // get a non const pointer to the inside array of values and perform operation T * value=const_cast (result.getValue(mode)); const int size=getNumberOfValues()*getNumberOfComponents(); // size of array @@ -1028,7 +1036,7 @@ FIELD* FIELD::sub(const FIELD& m, const FIELD& n) mode=m.getvalue()->getMode(); else mode=n.getvalue()->getMode(); - + // Creation of a new field FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); result->_operationInitialize(m,n,"-"); // perform Atribute's initialization @@ -1052,7 +1060,7 @@ FIELD* FIELD::subDeep(const FIELD& m, const FIELD& n) mode=m.getvalue()->getMode(); else mode=n.getvalue()->getMode(); - + // Creation of a new field FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); result->_operationInitialize(m,n,"-"); // perform Atribute's initialization @@ -1072,7 +1080,7 @@ FIELD* FIELD::subDeep(const FIELD& m, const FIELD& n) - _componentsTypes - _MEDComponentsUnits. - The data members of the returned field are initialized, based on the first field, except for the name, + The data members of the returned field are initialized, based on the first field, except for the name, which is the combination of the two field's names and the operator. Advised Utilisation in C++ : FIELD c = a * b; \n In this case, the (recent) compilators perform optimisation and don't call the copy constructor. @@ -1094,7 +1102,7 @@ const FIELD FIELD::operator*(const FIELD & m) const mode=m.getvalue()->getMode(); else mode=this->getvalue()->getMode(); - + // Creation of the result - memory is allocated by FIELD constructor FIELD result(this->getSupport(),this->getNumberOfComponents(),mode); //result._operation(*this,m,mode,"*"); // perform Atribute's initialization & multiplication @@ -1150,7 +1158,7 @@ FIELD* FIELD::mul(const FIELD& m, const FIELD& n) mode=m.getvalue()->getMode(); else mode=n.getvalue()->getMode(); - + // Creation of a new field FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); result->_operationInitialize(m,n,"*"); // perform Atribute's initialization @@ -1174,7 +1182,7 @@ FIELD* FIELD::mulDeep(const FIELD& m, const FIELD& n) mode=m.getvalue()->getMode(); else mode=n.getvalue()->getMode(); - + // Creation of a new field FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); result->_operationInitialize(m,n,"*"); // perform Atribute's initialization @@ -1194,7 +1202,7 @@ FIELD* FIELD::mulDeep(const FIELD& m, const FIELD& n) - _componentsTypes - _MEDComponentsUnits. - The data members of the returned field are initialized, based on the first field, except for the name, + The data members of the returned field are initialized, based on the first field, except for the name, which is the combination of the two field's names and the operator. Advised Utilisation in C++ : FIELD c = a / b; \n In this case, the (recent) compilators perform optimisation and don't call the copy constructor. @@ -1216,7 +1224,7 @@ const FIELD FIELD::operator/(const FIELD & m) const mode=m.getvalue()->getMode(); else mode=this->getvalue()->getMode(); - + // Creation of the result - memory is allocated by FIELD constructor FIELD result(this->getSupport(),this->getNumberOfComponents(),mode); //result._operation(*this,m,mode,"/"); // perform Atribute's initialization & division @@ -1273,7 +1281,7 @@ FIELD* FIELD::div(const FIELD& m, const FIELD& n) mode=m.getvalue()->getMode(); else mode=n.getvalue()->getMode(); - + // Creation of a new field FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); result->_operationInitialize(m,n,"/"); // perform Atribute's initialization @@ -1297,7 +1305,7 @@ FIELD* FIELD::divDeep(const FIELD& m, const FIELD& n) mode=m.getvalue()->getMode(); else mode=n.getvalue()->getMode(); - + // Creation of a new field FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); result->_operationInitialize(m,n,"/"); // perform Atribute's initialization @@ -1329,7 +1337,12 @@ void FIELD::_operationInitialize(const FIELD& m,const FIELD& n, char* Op) // The following data member may differ from field m to n. // The initialization is done based on the first field. - setComponentsUnits(m.getComponentsUnits()); + + if(m.getComponentsUnits() != NULL) + setComponentsUnits(m.getComponentsUnits()); + else + _componentsUnits = (UNIT *) NULL; + setIterationNumber(m.getIterationNumber()); setTime(m.getTime()); setOrderNumber(m.getOrderNumber()); @@ -1341,7 +1354,7 @@ void FIELD::_operationInitialize(const FIELD& m,const FIELD& n, char* Op) \if developper Internal method called by FIELD::operator+ and FIELD::add to perform addition "in place". This method is applied to a just created field with medModeSwitch mode. - For this reason, the alternate mode doesn't need to be set to 0 after performing operation : + For this reason, the alternate mode doesn't need to be set to 0 after performing operation : it doesn't exist! \endif */ @@ -1365,7 +1378,7 @@ void FIELD::_add_in_place(const FIELD& m,const FIELD& n, const MED_EN::medMod \if developper Internal method called by FIELD::operator- and FIELD::sub to perform substraction "in place". This method is applied to a just created field with medModeSwitch mode. - For this reason, the alternate mode doesn't need to be set to 0 after performing operation : + For this reason, the alternate mode doesn't need to be set to 0 after performing operation : it doesn't exist! \endif */ @@ -1389,7 +1402,7 @@ void FIELD::_sub_in_place(const FIELD& m,const FIELD& n, const MED_EN::medMod \if developper Internal method called by FIELD::operator* and FIELD::mul to perform multiplication "in place". This method is applied to a just created field with medModeSwitch mode. - For this reason, the alternate mode doesn't need to be set to 0 after performing operation : + For this reason, the alternate mode doesn't need to be set to 0 after performing operation : it doesn't exist! \endif */ @@ -1413,7 +1426,7 @@ void FIELD::_mul_in_place(const FIELD& m,const FIELD& n, const MED_EN::medMod \if developper Internal method called by FIELD::operator/ and FIELD::div to perform division "in place". This method is applied to a just created field with medModeSwitch mode. - For this reason, the alternate mode doesn't need to be set to 0 after performing operation : + For this reason, the alternate mode doesn't need to be set to 0 after performing operation : it doesn't exist! \endif */ @@ -1439,7 +1452,7 @@ void FIELD::_div_in_place(const FIELD& m,const FIELD& n, const MED_EN::medMod } } -/*! Return Max Norm +/*! Return Max Norm */ template double FIELD::normMax() const throw (MEDEXCEPTION) { @@ -1471,7 +1484,7 @@ template double FIELD::normMax() const throw (MEDEXCEPTION) return Max>Min ? static_cast(Max) : static_cast(Min); } -/*! Return Euclidien norm +/*! Return Euclidien norm */ template double FIELD::norm2() const throw (MEDEXCEPTION) { @@ -1485,25 +1498,25 @@ template double FIELD::norm2() const throw (MEDEXCEPTION) throw MEDEXCEPTION(diagnosis.c_str()); } const T* lastvalue=value+size; // point just after last value - + T result((T)0); // init for( ; value!=lastvalue ; ++value) result += (*value) * (*value); - + return std::sqrt(static_cast (result)); } -/*! Apply to each (scalar) field component the template parameter T_function, +/*! Apply to each (scalar) field component the template parameter T_function, * which is a pointer to function. * Since the pointer is known at compile time, the function is inlined into the inner loop! * calculation is done "in place". - * Use examples : - * + * Use examples : + * * \code myField.applyFunc(); // apply sqare root function \endcode * \code myField.applyFunc(); // apply your own created function \endcode */ -template template +template template void FIELD::applyFunc() { MED_EN::medModeSwitch mode=getvalue()->getMode(); @@ -1529,8 +1542,8 @@ template T FIELD::pow(T x) /*! Apply to each (scalar) field component the math function pow. * calculation is done "in place". - * Use examples : - * + * Use examples : + * * \code myField.applyFunc(); // apply sqare root function \endcode * \code myField.applyFunc(); // apply your own created function \endcode */ @@ -1539,7 +1552,7 @@ template void FIELD::applyPow(T scalar) FIELD::_scalarForPow=scalar; applyFunc::pow>(); } - + /*! Apply to each (scalar) field component the linear function x -> ax+b. * calculation is done "in place". */ @@ -1578,12 +1591,13 @@ template void FIELD::applyLin(T a, T b) */ template FIELD* FIELD::scalarProduct(const FIELD & m, const FIELD & n, bool deepCheck) { - if(!deepCheck) - FIELD_::_checkFieldCompatibility( m, n, false); // may throw exception - else - FIELD_::_deepCheckFieldCompatibility(m, n, false); - // we need a MED_FULL_INTERLACE representation of m & n to compute the scalar product - const MED_EN::medModeSwitch mode=MED_EN::MED_FULL_INTERLACE; + if(!deepCheck) + FIELD_::_checkFieldCompatibility( m, n, false); // may throw exception + else + FIELD_::_deepCheckFieldCompatibility(m, n, false); + + // we need a MED_FULL_INTERLACE representation of m & n to compute the scalar product + const MED_EN::medModeSwitch mode=MED_EN::MED_FULL_INTERLACE; const int numberOfElements=m.getNumberOfValues(); // strictly positive const int NumberOfComponents=m.getNumberOfComponents(); // strictly positive @@ -1600,7 +1614,7 @@ template FIELD* FIELD::scalarProduct(const FIELD & m, const FIEL const T* value2=n.getValue(mode); // get const pointer to the values // get a non const pointer to the inside array of values and perform operation T * value=const_cast (result->getValue(mode)); - + const T* lastvalue=value+numberOfElements; // pointing just after last value of result for ( ; value!=lastvalue ; ++value ) // loop on all elements { @@ -1627,13 +1641,13 @@ template double FIELD::normL2(int component, const FIELD * p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh] // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size - const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE); + const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE); const T* value=getValueI( MED_EN::MED_NO_INTERLACE, component); // get pointer to the component's values const T* lastvalue=value+getNumberOfValues(); // pointing just after the end of column double integrale=0.0; double totVol=0.0; - for (; value!=lastvalue ; ++value ,++vol) + for (; value!=lastvalue ; ++value ,++vol) { integrale += static_cast((*value) * (*value)) * (*vol); totVol+=*vol; @@ -1659,7 +1673,7 @@ template double FIELD::normL2(const FIELD * p_field_volume) p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh] // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size - const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE); + const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE); const double* lastvol=vol+getNumberOfValues(); // pointing just after the end of vol const T* value=getValue( MED_EN::MED_NO_INTERLACE); // get pointer to the field's values @@ -1667,10 +1681,10 @@ template double FIELD::normL2(const FIELD * p_field_volume) const double* p_vol=vol; for (p_vol=vol; p_vol!=lastvol ; ++p_vol) // calculate total volume totVol+=*p_vol; - + double integrale=0.0; for (int i=1; i<=getNumberOfComponents(); ++i) // compute integral on all components - for (p_vol=vol; p_vol!=lastvol ; ++value ,++p_vol) + for (p_vol=vol; p_vol!=lastvol ; ++value ,++p_vol) integrale += static_cast((*value) * (*value)) * (*p_vol); if(!p_field_volume) // if the user didn't supply the volume @@ -1696,13 +1710,13 @@ template double FIELD::normL1(int component, const FIELD * p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh] // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size - const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE); + const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE); const T* value=getValueI( MED_EN::MED_NO_INTERLACE, component); // get pointer to the component's values const T* lastvalue=value+getNumberOfValues(); // pointing just after the end of column double integrale=0.0; double totVol=0.0; - for (; value!=lastvalue ; ++value ,++vol) + for (; value!=lastvalue ; ++value ,++vol) { integrale += std::abs( static_cast(*value) ) * (*vol); totVol+=*vol; @@ -1728,7 +1742,7 @@ template double FIELD::normL1(const FIELD * p_field_volume) p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh] // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size - const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE); + const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE); const double* lastvol=vol+getNumberOfValues(); // pointing just after the end of vol const T* value=getValue( MED_EN::MED_NO_INTERLACE); // get pointer to the field's values @@ -1736,10 +1750,10 @@ template double FIELD::normL1(const FIELD * p_field_volume) const double* p_vol=vol; for (p_vol=vol; p_vol!=lastvol ; ++p_vol) // calculate total volume totVol+=*p_vol; - + double integrale=0.0; for (int i=1; i<=getNumberOfComponents(); ++i) // compute integral on all components - for (p_vol=vol; p_vol!=lastvol ; ++value ,++p_vol) + for (p_vol=vol; p_vol!=lastvol ; ++value ,++p_vol) integrale += std::abs( static_cast(*value) ) * (*p_vol); if(!p_field_volume) // if the user didn't supply the volume @@ -1804,6 +1818,9 @@ template FIELD::FIELD(const SUPPORT * Support, init(); _support = Support; + //A.G. Addings for RC + if(_support) + _support->addReference(); _value = (MEDARRAY*)NULL; _iterationNumber = iterationNumber; @@ -1856,7 +1873,7 @@ template FIELD::~FIELD() } /*! - + */ template void FIELD::allocValue(const int NumberOfComponents) { @@ -1896,7 +1913,7 @@ template void FIELD::allocValue(const int NumberOfComponents) } /*! - + */ template void FIELD::allocValue(const int NumberOfComponents, const int LengthValue) { @@ -1927,7 +1944,7 @@ template void FIELD::allocValue(const int NumberOfComponents, const } /*! - + */ template void FIELD::deallocValue() { @@ -1945,7 +1962,7 @@ template void FIELD::deallocValue() // ----------------- /*! - Create the specified driver and return its index reference to path to + Create the specified driver and return its index reference to path to read or write methods. */ @@ -1954,7 +1971,8 @@ template int FIELD::addDriver(driverTypes driverType, const string & driverName/*="Default Field Name"*/, MED_EN::med_mode_acces access) { - const char * LOC = "FIELD::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Field Name,MED_EN::med_mode_acces access) : "; + //jfa tmp (as last argument has no default value):const char * LOC = "FIELD::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Field Name\",MED_EN::med_mode_acces access) : "; + const char * LOC = "FIELD::addDriver(driverTypes driverType, const string & fileName,const string & driverName,MED_EN::med_mode_acces access) :";//jfa tmp GENDRIVER * driver; @@ -1977,7 +1995,7 @@ template int FIELD::addDriver(driverTypes driverType, /*! - Duplicate the given driver and return its index reference to path to + Duplicate the given driver and return its index reference to path to read or write methods. */ template inline int FIELD::addDriver (GENDRIVER & driver ) @@ -1994,7 +2012,7 @@ template inline int FIELD::addDriver (GENDRIVER & driver ) current = _drivers.size()-1; SCRUTE(current); - driver.setId(current); + driver.setId(current); MESSAGE(LOC << " je suis la 1"); END_OF(LOC); @@ -2213,7 +2231,7 @@ template inline void FIELD::setValue(MEDARRAY *Value) /*! \if developper Return a reference to the MEDARRAY in FIELD. - \endif + \endif */ template inline MEDARRAY* FIELD::getvalue() const { @@ -2394,11 +2412,11 @@ template void FIELD::getBarycenter() const throw (MEDEXCEPTION) } /*! - Fill array by using T_Analytic. + Fill array by using T_Analytic. WARNING : "this" must have allocated its array by setting this->_support and this->_numberOfComponents properly. Typically you should use it on a field built with constructor FIELD::FIELD(SUPPORT *,int nbOfComponents) */ -template +template template void FIELD::fillFromAnalytic() { @@ -2415,7 +2433,7 @@ void FIELD::fillFromAnalytic() { coord=mesh->getCoordinates(MED_EN::MED_NO_INTERLACE); for(i=0; i& support_ids, _intermediateMED* medi) @@ -118,7 +118,7 @@ static int getGroupId(const vector& support_ids, _intermediateMED* medi) //======================================================================= //function : read -//purpose : +//purpose : //======================================================================= #define GIBI_EQUAL(var_str, stat_str) \ @@ -253,8 +253,8 @@ bool GIBI_MESH_RDONLY_DRIVER::readFile (_intermediateMED* medi, bool readFields medi->groupes.push_back(_groupe()); _groupe & groupe = medi->groupes.back(); - // si le groupe se compose de sous-maillages (ie groupe composite) - if (type_geom_castem==0 && nb_sous_maillage>0) + // si le groupe se compose de sous-maillages (ie groupe composite) + if (type_geom_castem==0 && nb_sous_maillage>0) { // lecture des indices des sous-maillages, stockage. // les mailles correspondant a ces sous_maillages seront inserees a la fin du case @@ -274,7 +274,7 @@ bool GIBI_MESH_RDONLY_DRIVER::readFile (_intermediateMED* medi, bool readFields getNextLine(ligne); } // not a composit group - if (type_geom_castem>0 && nb_sous_maillage==0) + if (type_geom_castem>0 && nb_sous_maillage==0) { medGeometryElement medType = gibi2medGeom(type_geom_castem); bool goodType = ( medType!=MED_NONE ); @@ -371,7 +371,7 @@ bool GIBI_MESH_RDONLY_DRIVER::readFile (_intermediateMED* medi, bool readFields { getNextLine( ligne ); unsigned nb_reels = atoi( ligne ); - // PROVISOIRE : certains fichier gibi n`ont + // PROVISOIRE : certains fichier gibi n`ont if (nb_reels < numero_noeuds.size()*(space_dimension)) { INFOS("Erreur de lecture dans enregistrement de pile " << PILE_COORDONNEES); return false; @@ -453,7 +453,7 @@ bool GIBI_MESH_RDONLY_DRIVER::readFile (_intermediateMED* medi, bool readFields fdouble->comp_names[ i_comp ] = getName();// component names } } - + for ( initIntReading( nb_sub ); more(); next() )// nb harmonics ( ignored ) ; @@ -489,7 +489,7 @@ bool GIBI_MESH_RDONLY_DRIVER::readFile (_intermediateMED* medi, bool readFields } } // Fin numero_pile == PILE_NODES_FIELD - + // ------------------------------------------------- // FIELDS // ------------------------------------------------- @@ -648,10 +648,10 @@ GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(): GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(const string & fileName, MESH * ptrMesh, - MED_EN::med_mode_acces accessMode): + MED_EN::med_mode_acces accessMode): GENDRIVER(fileName,accessMode), _ptrMesh(ptrMesh) - // A VOIR _medIdt(MED_INVALID), + // A VOIR _medIdt(MED_INVALID), { MESSAGE( "GIBI_MESH_DRIVER(" << fileName <<","<= 0) { @@ -780,7 +780,7 @@ void GIBI_MESH_RDONLY_DRIVER::close() //======================================================================= //function : getLine -//purpose : +//purpose : //======================================================================= bool GIBI_MESH_RDONLY_DRIVER::getLine(char* & aLine) @@ -836,7 +836,7 @@ bool GIBI_MESH_RDONLY_DRIVER::getLine(char* & aLine) //======================================================================= //function : init -//purpose : +//purpose : //======================================================================= void GIBI_MESH_RDONLY_DRIVER::init( int nbToRead, int nbPosInLine, int width, int shift ) @@ -900,7 +900,7 @@ void GIBI_MESH_RDONLY_DRIVER::read(void) throw (MEDEXCEPTION) const char * LOC = "_GIBI_RDONLY_DRIVER::read() : " ; if (_status!=MED_OPENED) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << " (the file is not opened)." )) ; if ( ! _ptrMesh->isEmpty() ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Mesh object not empty : can't fill it!")); @@ -924,7 +924,7 @@ void GIBI_MESH_RDONLY_DRIVER::read(void) throw (MEDEXCEPTION) //======================================================================= //function : getReverseVector -//purpose : +//purpose : //======================================================================= static void getReverseVector (const medGeometryElement type, @@ -988,7 +988,7 @@ static void getReverseVector (const medGeometryElement type, //======================================================================= //function : orientElements -//purpose : +//purpose : //======================================================================= static void orientElements( _intermediateMED& medi ) @@ -1005,7 +1005,7 @@ static void orientElements( _intermediateMED& medi ) for ( ; elemIt != medi.maillage.end(); elemIt++ ) if ( elemIt->dimension() == 2 ) { - // look for index of the most left node + // look for index of the most left node int iLeft = 0, iNode, nbNodes = elemIt->sommets.size(); double minX = elemIt->sommets[0]->second.coord[0]; for ( iNode = 1; iNode < nbNodes; ++iNode ) @@ -1139,7 +1139,7 @@ static void orientElements( _intermediateMED& medi ) } } // dimension() == 3 } // loop on maillage - + // -------------------------------------- // orient equally all connected 3D faces // -------------------------------------- @@ -1297,7 +1297,7 @@ void GIBI_MESH_RDONLY_DRIVER::fillMesh(_intermediateMED* _ptrMedi) _ptrMesh->_groupEdge, _ptrMesh->_groupNode, _ptrMesh); - _ptrMesh->_connectivity = _ptrMedi->getConnectivity(); + _ptrMesh->_connectivity = _ptrMedi->getConnectivity(); // calcul de la connectivite d-1 complete, avec renumerotation des groupes //if (_ptrMesh->_spaceDimension==3) @@ -1374,7 +1374,7 @@ GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName, { 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_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const GIBI_MESH_WRONLY_DRIVER & driver): GIBI_MESH_DRIVER(driver) { } @@ -1394,7 +1394,7 @@ void GIBI_MESH_WRONLY_DRIVER::read (void) //======================================================================= //function : open -//purpose : +//purpose : //======================================================================= void GIBI_MESH_WRONLY_DRIVER::open() @@ -1405,7 +1405,7 @@ void GIBI_MESH_WRONLY_DRIVER::open() MED_EN::med_mode_acces aMode = getAccessMode(); switch (aMode) { - case MED_EN::MED_REMP: + case MED_EN::MED_REMP: case MED_EN::MED_ECRI: // should never append !! _gibi.open(_fileName.c_str(), ios::out); break; @@ -1430,7 +1430,7 @@ void GIBI_MESH_WRONLY_DRIVER::open() //======================================================================= //function : close -//purpose : +//purpose : //======================================================================= void GIBI_MESH_WRONLY_DRIVER::close() @@ -1438,7 +1438,7 @@ void GIBI_MESH_WRONLY_DRIVER::close() { const char * LOC = "GIBI_MESH_DRIVER::close() " ; BEGIN_OF(LOC); - if ( _status == MED_OPENED) + if ( _status == MED_OPENED) { _gibi.close(); _status = MED_CLOSED; @@ -1448,12 +1448,12 @@ void GIBI_MESH_WRONLY_DRIVER::close() //======================================================================= //function : write -//purpose : +//purpose : //======================================================================= void GIBI_MESH_WRONLY_DRIVER::write(void) const throw (MEDEXCEPTION) -{ +{ const char * LOC = "void GIBI_MESH_WRONLY_DRIVER::write(void) const : "; BEGIN_OF(LOC); @@ -1499,7 +1499,7 @@ static string cleanName( const string& theName ) //======================================================================= //function : addSupport -//purpose : +//purpose : //======================================================================= bool GIBI_MESH_WRONLY_DRIVER::addSupport( const SUPPORT * support ) @@ -1594,7 +1594,7 @@ bool GIBI_MESH_WRONLY_DRIVER::addSupport( const SUPPORT * support ) //======================================================================= //function : getSupportIndex -//purpose : +//purpose : //======================================================================= int GIBI_MESH_WRONLY_DRIVER::getSubMeshIdAndSize(const SUPPORT * support, @@ -1664,7 +1664,7 @@ void GIBI_MESH_WRONLY_DRIVER::writeElements (medGeometryElement geomType, int castemType = GIBI_MESH_DRIVER::med2gibiGeom( geomType ); char* zeroI8 = " 0"; // FORMAT(I8) int nbElemNodes = geomType % 100; - + // count total nb of elements int nbElements = 0; list< typeData >::iterator td = typeDataList.begin(); @@ -1712,7 +1712,7 @@ void GIBI_MESH_WRONLY_DRIVER::writeElements (medGeometryElement geomType, } } } - + fcount.stop(); } @@ -1759,7 +1759,7 @@ void GIBI_MESH_WRONLY_DRIVER::addName(map& nameMap, //======================================================================= //function : writeNames -//purpose : +//purpose : //======================================================================= void GIBI_MESH_WRONLY_DRIVER::writeNames( map& nameNbMap ) @@ -1789,7 +1789,7 @@ void GIBI_MESH_WRONLY_DRIVER::writeNames( map& nameNbMap ) //======================================================================= //function : writeSupportsAndMesh -//purpose : +//purpose : //======================================================================= void GIBI_MESH_WRONLY_DRIVER::writeSupportsAndMesh() @@ -1879,7 +1879,7 @@ void GIBI_MESH_WRONLY_DRIVER::writeSupportsAndMesh() } // ------------ - // Write file + // Write file // ------------ // Premier paquet dont le nombre de lignes ne varie pas. @@ -1979,7 +1979,7 @@ void GIBI_MESH_WRONLY_DRIVER::writeSupportsAndMesh() for ( int iType = 1; iType <= nbTypes; ++iType ) { int nbElements = nbIndex[ iType ] - nbIndex[ iType - 1 ]; - medGeometryElement geomType = types[ iType - 1 ]; + medGeometryElement geomType = types[ iType - 1 ]; if ( nbSuppElemsByType[ geomType ] >= nbElements ) continue; // all elements are written with _supports @@ -2042,7 +2042,7 @@ void GIBI_MESH_WRONLY_DRIVER::writeSupportsAndMesh() //======================================================================= //function : writeLastRecord -//purpose : +//purpose : //======================================================================= void GIBI_MESH_WRONLY_DRIVER::writeLastRecord() @@ -2062,14 +2062,14 @@ GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName, { 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_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const GIBI_MESH_RDWR_DRIVER & driver): GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_DRIVER(driver) { MESSAGE("GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(driver) has been created"); } 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 { BEGIN_OF( "GIBI_MESH_RDWR_DRIVER::copy()"); @@ -2117,20 +2117,20 @@ GIBI_MED_RDONLY_DRIVER::GIBI_MED_RDONLY_DRIVER(const string & fileName, MED * pt _fileName = fileName; _accessMode = MED_RDONLY; } -GIBI_MED_RDONLY_DRIVER::GIBI_MED_RDONLY_DRIVER(const GIBI_MED_RDONLY_DRIVER & driver) +GIBI_MED_RDONLY_DRIVER::GIBI_MED_RDONLY_DRIVER(const GIBI_MED_RDONLY_DRIVER & driver) { } - GIBI_MED_RDONLY_DRIVER::~GIBI_MED_RDONLY_DRIVER() + GIBI_MED_RDONLY_DRIVER::~GIBI_MED_RDONLY_DRIVER() { } -GENDRIVER * GIBI_MED_RDONLY_DRIVER::copy ( void ) const +GENDRIVER * GIBI_MED_RDONLY_DRIVER::copy ( void ) const { return new GIBI_MED_RDONLY_DRIVER(*this); } //======================================================================= //function : read -//purpose : +//purpose : //======================================================================= void GIBI_MED_RDONLY_DRIVER::read ( void ) throw (MEDEXCEPTION) @@ -2208,7 +2208,7 @@ GIBI_MED_WRONLY_DRIVER::GIBI_MED_WRONLY_DRIVER(const string & fileName, const char * LOC = "GIBI_MED_WRONLY_DRIVER(const string & fileName, MED * ptrMed, MESH * ptrMesh)" ; BEGIN_OF(LOC); - + _fileName = fileName; _accessMode = MED_WRONLY; _ptrMesh = ptrMesh; @@ -2228,7 +2228,7 @@ GENDRIVER * GIBI_MED_WRONLY_DRIVER::copy ( void ) const //======================================================================= //function : writeDataSection -//purpose : +//purpose : //======================================================================= template< class T > @@ -2261,7 +2261,7 @@ template< class T > //======================================================================= //function : getSupports -//purpose : +//purpose : //======================================================================= // int GIBI_MED_WRONLY_DRIVER::getSupports(const FIELD_* field, @@ -2289,7 +2289,7 @@ template< class T > //======================================================================= //function : write -//purpose : +//purpose : //======================================================================= void GIBI_MED_WRONLY_DRIVER::write( void ) const throw (MEDEXCEPTION) @@ -2322,7 +2322,7 @@ void GIBI_MED_WRONLY_DRIVER::write( void ) const throw (MEDEXCEPTION) FIELD_ * f = _med->getField( names[ iField ], fIt->dt, fIt->it ); if ( !dynamic_cast< FIELD* >( f )) { - MESSAGE("GIBI_MED_WRONLY_DRIVER::write( FIELD< int > ) not implemented"); + MESSAGE("GIBI_MED_WRONLY_DRIVER::write( FIELD< int > ) not implemented"); continue; } const SUPPORT * sup = f->getSupport(); diff --git a/src/MEDMEM/MEDMEM_Med.cxx b/src/MEDMEM/MEDMEM_Med.cxx index c1a3264bf..eb3394f48 100644 --- a/src/MEDMEM/MEDMEM_Med.cxx +++ b/src/MEDMEM/MEDMEM_Med.cxx @@ -1,4 +1,5 @@ # include +# include # include "MEDMEM_Med.hxx" # include "MEDMEM_DriverFactory.hxx" @@ -7,6 +8,8 @@ # include "MEDMEM_Mesh.hxx" # include "MEDMEM_Grid.hxx" # include "MEDMEM_Field.hxx" +# include "MEDMEM_Group.hxx" +# include "MEDMEM_Family.hxx" # include "MEDMEM_Exception.hxx" # include "utilities.h" @@ -117,6 +120,8 @@ MED::~MED() for ( itSupportOnMesh=_support.begin();itSupportOnMesh != _support.end(); itSupportOnMesh++ ) { map::iterator itSupport ; for ( itSupport=(*itSupportOnMesh).second.begin();itSupport!=(*itSupportOnMesh).second.end();itSupport++) + if (! dynamic_cast( (*itSupport).second ) && + ! dynamic_cast( (*itSupport).second ) ) delete (*itSupport).second ; } @@ -490,15 +495,15 @@ void MED::getFieldNames ( string * fieldNames ) const const char * LOC = "MED::getFieldNames ( string * ) const : "; BEGIN_OF(LOC); - unsigned int fieldNamesSize = sizeof(fieldNames) / sizeof(string *); +// unsigned int fieldNamesSize = sizeof(fieldNames) / sizeof(string *); - if ( fieldNamesSize != _fields.size() ) - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "Size of parameter fieldNames is |" - << fieldNamesSize << "| and should be |" - << _fields.size() << "| and should be |" - ) - ); +// if ( fieldNamesSize != _fields.size() ) +// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) +// << "Size of parameter fieldNames is |" +// << fieldNamesSize << "| and should be |" +// << _fields.size() << "| and should be |" +// ) +// ); // REM : ALLOCATION D'UN TABLEAU DE POINTEURS SUR STRING FAITE PAR LE CLIENT map::const_iterator currentField; diff --git a/src/MEDMEM/MEDMEM_Med.hxx b/src/MEDMEM/MEDMEM_Med.hxx index 428c01d09..0de96b0c1 100644 --- a/src/MEDMEM/MEDMEM_Med.hxx +++ b/src/MEDMEM/MEDMEM_Med.hxx @@ -31,11 +31,11 @@ struct LT_DT_IT_ return p1.dt < p2.dt ; } }; -typedef map MAP_DT_IT_; +typedef map MAP_DT_IT_; -// - IN THE FIRST CASE THE USER WANTS TO DISCOVER MESHES & FIELD_S +// - IN THE FIRST CASE THE USER WANTS TO DISCOVER MESHES & FIELD_S // 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, +// - 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 ?? // @@ -58,13 +58,13 @@ class MED private: - map _meshes; // We can't have two MESHes with the same meshName. + map _meshes; // We can't have two MESHes with the same meshName. // The string key is a meshName. - 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 _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 // POURQUOI MED_FR::med_entite_maillage ? devrait être MED_EN ! map < MESH_NAME_, map < MED_EN::medEntityMesh, SUPPORT * > > _support ; @@ -77,10 +77,10 @@ public: MED(); MED (driverTypes driverType, const string & fileName); // Analyse the file by calling readFileStruct ~MED(); - + // 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 ( FIELD_ * const ptrField ) throw (MED_EXCEPTION) ; void addMesh ( MESH * const ptrMesh ) throw (MED_EXCEPTION) ; int addDriver (driverTypes driverType, @@ -91,13 +91,13 @@ public: 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) ; - + 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; + int getNumberOfMeshes ( void ) const; + int getNumberOfFields ( void ) const; void getMeshNames ( string * meshNames ) const throw (MEDEXCEPTION) ; deque getMeshNames () const; MESH * getMesh ( const string & meshName ) const throw (MEDEXCEPTION) ; @@ -118,7 +118,7 @@ public: void updateSupport () ; // GERER LE CAS DE L'APPARITION DES MEMES NOMS DS DES FICHIERS <> !!!!! - + //friend ostream & operator<<(ostream &os,const MED & med); }; diff --git a/src/MEDMEM/MEDMEM_MedFieldDriver.hxx b/src/MEDMEM/MEDMEM_MedFieldDriver.hxx index 8d628d28c..48e852791 100644 --- a/src/MEDMEM/MEDMEM_MedFieldDriver.hxx +++ b/src/MEDMEM/MEDMEM_MedFieldDriver.hxx @@ -29,14 +29,14 @@ protected: string _fieldName; int _fieldNum; void search_field() ; - + public : - // all MED cell type ?? Classe de Définition ?? + // all MED cell type ?? Classe de Définition ?? // static const medGeometryElement all_cell_type[MED_NBR_GEOMETRIE_MAILLE]; - + // static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE]; - + /*! Constructor. */ @@ -46,10 +46,10 @@ public : /*! Constructor. */ - MED_FIELD_DRIVER(const string & fileName, FIELD * ptrField, + MED_FIELD_DRIVER(const string & fileName, FIELD * ptrField, MED_EN::med_mode_acces accessMode) : GENDRIVER(fileName,accessMode), - _ptrField((FIELD *) ptrField), + _ptrField((FIELD *) ptrField), _fieldName(fileName),_fieldNum(MED_INVALID) { } @@ -69,7 +69,7 @@ public : Destructor. */ virtual ~MED_FIELD_DRIVER() - { + { MESSAGE("MED_FIELD_DRIVER::~MED_FIELD_DRIVER() has been destroyed"); } @@ -86,7 +86,7 @@ public : /*! Get the name of the FIELD asked in file. */ - virtual string getFieldName() const { return _fieldName; } + virtual string getFieldName() const { return _fieldName; } protected: virtual GENDRIVER * copy ( void ) const = 0 ; friend class MED_FIELD_RDWR_DRIVER; @@ -104,29 +104,29 @@ protected: template class IMED_FIELD_RDONLY_DRIVER : public virtual MED_FIELD_DRIVER { - + public : - + /*! Constructor. */ IMED_FIELD_RDONLY_DRIVER() {} - + /*! Constructor. */ IMED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD * ptrField): - MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_RDONLY) { + MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_RDONLY) { BEGIN_OF("IMED_FIELD_RDONLY_DRIVER::IMED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD * ptrField)"); END_OF("IMED_FIELD_RDONLY_DRIVER::IMED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD * ptrField)"); } - + /*! Copy constructor. */ IMED_FIELD_RDONLY_DRIVER(const IMED_FIELD_RDONLY_DRIVER & fieldDriver): MED_FIELD_DRIVER(fieldDriver) {} - + /*! Destructor. */ @@ -151,14 +151,14 @@ public : */ template class IMED_FIELD_WRONLY_DRIVER : public virtual MED_FIELD_DRIVER { - + public : - + /*! Constructor. */ IMED_FIELD_WRONLY_DRIVER() {} - + /*! Constructor. */ @@ -174,7 +174,7 @@ public : */ IMED_FIELD_WRONLY_DRIVER(const IMED_FIELD_WRONLY_DRIVER & fieldDriver): MED_FIELD_DRIVER(fieldDriver) {} - + /*! Destructor. */ @@ -197,14 +197,14 @@ public : */ template class IMED_FIELD_RDWR_DRIVER : public virtual IMED_FIELD_RDONLY_DRIVER, public virtual IMED_FIELD_WRONLY_DRIVER { - + public : - + /*! Constructor. */ IMED_FIELD_RDWR_DRIVER() {} - + /*! Constructor. */ @@ -221,7 +221,7 @@ public : */ IMED_FIELD_RDWR_DRIVER(const IMED_FIELD_RDWR_DRIVER & fieldDriver): IMED_FIELD_RDONLY_DRIVER(fieldDriver),IMED_FIELD_WRONLY_DRIVER(fieldDriver),MED_FIELD_DRIVER(fieldDriver) {} - + /*! Destructor. */ @@ -236,7 +236,7 @@ namespace MEDMEM { template class MED_FIELD_RDONLY_DRIVER : public virtual IMED_FIELD_RDONLY_DRIVER { - + public : MED_FIELD_RDONLY_DRIVER(); MED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD * ptrField); @@ -255,7 +255,7 @@ protected: GENDRIVER * _concreteFieldDrv; }; -template class MED_FIELD_WRONLY_DRIVER : public virtual IMED_FIELD_WRONLY_DRIVER { +template class MED_FIELD_WRONLY_DRIVER : public virtual IMED_FIELD_WRONLY_DRIVER { public : MED_FIELD_WRONLY_DRIVER(); MED_FIELD_WRONLY_DRIVER(const string & fileName, FIELD * ptrField); @@ -306,15 +306,15 @@ protected: // template void MED_FIELD_DRIVER::setFieldName(const string & fieldName) // { -// _fieldName = fieldName; +// _fieldName = fieldName; // } // template string MED_FIELD_DRIVER::getFieldName() const // { // return _fieldName; // } - -#include "MEDMEM_DriverFactory.hxx" + +#include "MEDMEM_DriverFactory.hxx" #include "MEDMEM_MedFieldDriver21.hxx" #include "MEDMEM_MedFieldDriver22.hxx" @@ -330,11 +330,11 @@ template void IMED_FIELD_RDONLY_DRIVER::write( void ) const template MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER() { MESSAGE("You are using the default constructor of the Field read only Driver and it is 2.1 one"); - _concreteFieldDrv=new MED_FIELD_RDONLY_DRIVER21(); + _concreteFieldDrv=new MED_FIELD_RDONLY_DRIVER21(); } template MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD * ptrField) - { +{ BEGIN_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD * ptrField)"); _concreteFieldDrv = DRIVERFACTORY::buildFieldDriverFromFile(fileName,ptrField,MED_EN::MED_LECT); @@ -387,4 +387,3 @@ template MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string /*-----------------------------------------------------------------*/ #endif /* MED_FIELD_DRIVER_HXX */ - diff --git a/src/MEDMEM/MEDMEM_MedFieldDriver21.hxx b/src/MEDMEM/MEDMEM_MedFieldDriver21.hxx index b8908b9bb..5f172c8c6 100644 --- a/src/MEDMEM/MEDMEM_MedFieldDriver21.hxx +++ b/src/MEDMEM/MEDMEM_MedFieldDriver21.hxx @@ -553,8 +553,8 @@ template void MED_FIELD_RDONLY_DRIVER21::read(void) for (int k=0 ; ksetIJ(Count,i+1,myValue[k+offset]); - SCRUTE(Count); - SCRUTE(Values->getIJ(Count,i+1)); + //jfa 22.07.2005:SCRUTE(Count); + //jfa 22.07.2005:SCRUTE(Values->getIJ(Count,i+1)); Count++; } } diff --git a/src/MEDMEM/MEDMEM_MedMeshDriver22.cxx b/src/MEDMEM/MEDMEM_MedMeshDriver22.cxx index 1319ec7a4..6088176a1 100644 --- a/src/MEDMEM/MEDMEM_MedMeshDriver22.cxx +++ b/src/MEDMEM/MEDMEM_MedMeshDriver22.cxx @@ -1404,11 +1404,12 @@ int MED_MESH_RDONLY_DRIVER22::getNodalConnectivity(CONNECTIVITY * Connectivity) // If there is no nodal connectivity, we return MED_ERROR ! if (Connectivity->_numberOfTypes == 0 && NumberOfPolygons == 0 && NumberOfPolyhedron == 0) - return MED_ERROR ; + return MED_ERROR; else return MED_VALID; } + return MED_ERROR; } int MED_MESH_RDONLY_DRIVER22::getFAMILY() diff --git a/src/MEDMEM/MEDMEM_Mesh.cxx b/src/MEDMEM/MEDMEM_Mesh.cxx index 16dde5fbb..323ab7a52 100644 --- a/src/MEDMEM/MEDMEM_Mesh.cxx +++ b/src/MEDMEM/MEDMEM_Mesh.cxx @@ -32,17 +32,17 @@ using namespace MED_EN; /*! Add a %MESH driver of type %driverTypes (MED_DRIVER, ....) associated with file fileName. The meshname used in the file is driverName. addDriver returns an integer handler. */ -int MESH::addDriver(driverTypes driverType, +int MESH::addDriver(driverTypes driverType, const string & fileName/*="Default File Name.med"*/, const string & driverName/*="Default Mesh Name"*/, med_mode_acces access) { const char * LOC = "MESH::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Mesh Name\",MED_EN::med_mode_acces access) : "; - + GENDRIVER * driver; BEGIN_OF(LOC); - + SCRUTE(driverType); driver = DRIVERFACTORY::buildDriverForMesh(driverType,fileName,this, @@ -51,8 +51,8 @@ int MESH::addDriver(driverTypes driverType, _drivers.push_back(driver); int current = _drivers.size()-1; - - _drivers[current]->setMeshName(driverName); + + _drivers[current]->setMeshName(driverName); END_OF(LOC); @@ -64,7 +64,7 @@ int MESH::addDriver(GENDRIVER & driver) { const char * LOC = "MESH::addDriver(GENDRIVER &) : "; BEGIN_OF(LOC); - // A faire : Vérifier que le driver est de type MESH. + // A faire : Vérifier que le driver est de type MESH. GENDRIVER * newDriver = driver.copy() ; _drivers.push_back(newDriver); @@ -79,20 +79,20 @@ void MESH::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); -}; +}; // ------ End of Drivers Management Part @@ -113,7 +113,7 @@ void MESH::init() { _numberOfNodes = MED_INVALID; _isAGrid = false; - + _arePresentOptionnalNodesNumbers = 0; END_OF(LOC); @@ -335,20 +335,20 @@ bool MESH::operator==(const MESH& other) const return this==&other; } -/*! Create a %MESH object using a %MESH driver of type %driverTypes (MED_DRIVER, ....) associated with file fileName. +/*! Create a %MESH object using a %MESH driver of type %driverTypes (MED_DRIVER, ....) associated with file fileName. The meshname driverName must already exists in the file.*/ MESH::MESH(driverTypes driverType, const string & fileName/*=""*/, const string & driverName/*=""*/) throw (MEDEXCEPTION) { const char * LOC ="MESH::MESH(driverTypes driverType, const string & fileName="", const string & driverName="") : "; int current; - + BEGIN_OF(LOC); init(); GENDRIVER *myDriver=DRIVERFACTORY::buildDriverForMesh(driverType,fileName,this,driverName,MED_LECT); current = addDriver(*myDriver); delete myDriver; - _drivers[current]->open(); + _drivers[current]->open(); _drivers[current]->read(); _drivers[current]->close(); @@ -384,9 +384,9 @@ ostream & ::MEDMEM::operator<<(ostream &os, const MESH &myMesh) int meshdimension = myMesh.getMeshDimension(); int numberofnodes = myMesh.getNumberOfNodes(); - os << "Space Dimension : " << spacedimension << endl << endl; + os << "Space Dimension : " << spacedimension << endl << endl; - os << "Mesh Dimension : " << meshdimension << endl << endl; + os << "Mesh Dimension : " << meshdimension << endl << endl; const double * coordinates = myMesh.getCoordinates(MED_FULL_INTERLACE); os << "SHOW NODES COORDINATES : " << endl; @@ -425,7 +425,7 @@ ostream & ::MEDMEM::operator<<(ostream &os, const MESH &myMesh) int numberoffamilies = myMesh.getNumberOfFamilies(entity); os << "NumberOfFamilies on "<< entNames[entity] <<" : "< cellsList ; list::iterator itList ; - for (int i=indexBegin; i1) // we have more than one cell throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Found more than one element !")) ; @@ -515,10 +515,10 @@ int MESH::getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entit /*! Return a support which reference all elements on the boundary of mesh. - + For instance, we could get only face in 3D and edge in 2D. */ -SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity) +SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION) { const char * LOC = "MESH::getBoundaryElements : " ; @@ -526,7 +526,7 @@ SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity) // some test : // actually we could only get face (in 3D) and edge (in 2D) medEntityMesh entityToParse=Entity; - if(_spaceDimension == 3) + if(_spaceDimension == 3) if (Entity != MED_FACE) if(Entity==MED_NODE) entityToParse=MED_FACE; @@ -538,7 +538,7 @@ SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity) entityToParse=MED_EDGE; else throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 2D mesh for entity "<& listOfElt,MED_ } /*! - Method created to factorize code. This method creates a new support on entity 'entity' (to deallocate) containing all the entities contained in + Method created to factorize code. This method creates a new support on entity 'entity' (to deallocate) containing all the entities contained in elements 'listOfElt' of entity 'entity'. */ SUPPORT *MESH::buildSupportOnElementsFromElementList(const list& listOfElt, MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION) @@ -604,7 +604,7 @@ SUPPORT *MESH::buildSupportOnElementsFromElementList(const list& listOfElt, return mySupport ; } -FIELD* MESH::getVolume(const SUPPORT * Support) const throw (MEDEXCEPTION) +FIELD* MESH::getVolume(const SUPPORT *Support) const throw (MEDEXCEPTION) { const char * LOC = "MESH::getVolume(SUPPORT*) : "; BEGIN_OF(LOC); @@ -669,7 +669,7 @@ FIELD* MESH::getVolume(const SUPPORT * Support) const throw (MEDEXCEPTIO 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) const throw (MEDEXCEPTIO for(iFaces=0;iFacessetIJ(index,1,xvolume) ; + volume->setIJ(index,1,xvolume) ; index++; } } @@ -823,7 +823,7 @@ FIELD* MESH::getVolume(const SUPPORT * Support) const throw (MEDEXCEPTIO break; } - if (!onAll && type!=MED_EN::MED_POLYHEDRA) + if (!onAll && type!=MED_EN::MED_POLYHEDRA) delete [] global_connectivity ; } @@ -890,17 +890,17 @@ FIELD* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) nb_entity_type = Support->getNumberOfElements(type); const int *global_connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); if(type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA) - { + { if (onAll) { global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type); } else - { + { const int * supp_number = Support->getNumber(type); const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS); int * global_connectivity_tmp = new int[(type%100)*nb_entity_type]; - + for (int k_type = 0; k_type* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) int N2 = global_connectivity[quad_index+1]-1; int N3 = global_connectivity[quad_index+2]-1; int N4 = global_connectivity[quad_index+3]-1; - + area[index]=CalculateAreaForQuad(coord+dim_space*N1, coord+dim_space*N2, coord+dim_space*N3, @@ -988,7 +988,7 @@ FIELD* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) break; } - if (!onAll) + if (!onAll) if(type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA) delete [] global_connectivity ; } @@ -1155,7 +1155,7 @@ FIELD* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTIO { medGeometryElement type = types[i] ; nb_entity_type = Support->getNumberOfElements(type); - + // Make sure we trying to get Normals on // TRIA3 or TRIA6 or QUAD4 QUAD8 (2D) cells on a 3D mesh // or on SEG2 or SEG3 (1D) cells on a 2D mesh @@ -1172,18 +1172,18 @@ FIELD* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTIO global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type); } else - { + { 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) const throw (MEDEXCEPTIO throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Normals on it !")); break; } - if (!onAll && type!=MED_EN::MED_POLYGON) + if (!onAll && type!=MED_EN::MED_POLYGON) delete [] global_connectivity ; } END_OF(LOC); @@ -1598,42 +1598,42 @@ FIELD* MESH::getBarycenter(const SUPPORT * Support) const throw (MEDEXCE return Barycenter; } -bool MESH::isEmpty() const +bool MESH::isEmpty() const { bool notempty = _name != "NOT DEFINED" || _coordinate != NULL || _connectivity != NULL || - _spaceDimension !=MED_INVALID || _meshDimension !=MED_INVALID || - _numberOfNodes !=MED_INVALID || _groupNode.size() != 0 || - _familyNode.size() != 0 || _groupCell.size() != 0 || - _familyCell.size() != 0 || _groupFace.size() != 0 || - _familyFace.size() != 0 || _groupEdge.size() != 0 || + _spaceDimension !=MED_INVALID || _meshDimension !=MED_INVALID || + _numberOfNodes !=MED_INVALID || _groupNode.size() != 0 || + _familyNode.size() != 0 || _groupCell.size() != 0 || + _familyCell.size() != 0 || _groupFace.size() != 0 || + _familyFace.size() != 0 || _groupEdge.size() != 0 || _familyEdge.size() != 0 || _isAGrid != 0 ; return !notempty; } -void MESH::read(int index) -{ +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(); + _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); } //======================================================================= //function : getSkin -//purpose : +//purpose : //======================================================================= -SUPPORT * MESH::getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION) +SUPPORT * MESH::getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION) { const char * LOC = "MESH::getSkin : " ; BEGIN_OF(LOC) ; @@ -1642,11 +1642,11 @@ SUPPORT * MESH::getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION) 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 ; @@ -1670,7 +1670,7 @@ SUPPORT * MESH::getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION) else { map FaceNbEncounterNb; - + int * myConnectivityValue = const_cast (getConnectivity(MED_FULL_INTERLACE, MED_DESCENDING, MED_CELL, MED_ALL_ELEMENTS)); @@ -1701,7 +1701,7 @@ SUPPORT * MESH::getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION) 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 ; @@ -1784,7 +1784,7 @@ SUPPORT * MESH::getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION) END_OF(LOC) ; return mySupport ; - + } /*! @@ -1977,7 +1977,6 @@ SUPPORT * MESH::intersectSupports(const vector Supports) throw (MEDEX strlen((Supports[i]->getDescription()).c_str()); } } - if(returnedSupport != (SUPPORT *) NULL) { returnedSupportNameChar = new char[lenName]; @@ -2050,7 +2049,7 @@ struct _cell }; // Create families from groups -void MESH::createFamilies() +void MESH::createFamilies() { int idFamNode = 0; // identifier for node families int idFamElement = 0; // identifier for cell, face or edge families @@ -2061,7 +2060,7 @@ void MESH::createFamilies() int numberofgroups = getNumberOfGroups(entity); if(!numberofgroups) continue; // no groups for this entity - + vector< vector > whichFamilyInGroup(numberofgroups); // this container is used to update groups at the end // make myFamilies points to the member corresponding to entity @@ -2081,10 +2080,10 @@ void MESH::createFamilies() myFamilies = & _familyNode; break; } - + vector myGroups=getGroups(entity); // get a copy of the groups ptr for the entity // get a copy of the (old) family ptrs before clearing - vector myOldFamilies=getFamilies(entity); + vector myOldFamilies=getFamilies(entity); myFamilies->clear(); @@ -2102,9 +2101,9 @@ void MESH::createFamilies() for(int n=index[t]-1; n!=index[t+1]-1; ++n) tab_cell[n].geometricType=geometricTypes[t]; - + // 2 - Scan cells in groups and update in tab_cell the container of groups a cell belong to - + for (unsigned g=0; g!=myGroups.size(); ++g) { // scan cells that belongs to the group @@ -2115,9 +2114,9 @@ void MESH::createFamilies() } - // 3 - Scan the cells vector, genarate family name, and create a map associating the family names + // 3 - Scan the cells vector, genarate family name, and create a map associating the family names // whith the vector of contained cells - + map< string,vector > tab_families; map< string,vector >::iterator fam; for(int n=0; n!=numberOfCells; ++n) @@ -2126,7 +2125,7 @@ void MESH::createFamilies() key << "FAM"; if(tab_cell[n].groups.empty()) // this cell don't belong to any group key << "_NONE" << entity; - + for(vector::const_iterator it=tab_cell[n].groups.begin(); it!=tab_cell[n].groups.end(); ++it) { string groupName=myGroups[*it]->getName(); @@ -2135,13 +2134,13 @@ void MESH::createFamilies() else key << "_" << groupName; } - + tab_families[key.str()].push_back(n+1); // fill the vector of contained cells associated whith the family } // 4 - Scan the family map, create MED Families, check if it already exist. - + for( fam=tab_families.begin(); fam!=tab_families.end(); ++fam) { vector tab_types_geometriques; @@ -2150,9 +2149,9 @@ void MESH::createFamilies() vector tab_nombres_elements; // scan family cells and fill the tab that are needed by the create a MED FAMILY - for( int i=0; i!=fam->second.size(); ++i) + for( int i=0; i!=fam->second.size(); ++i) { - int ncell=fam->second[i]-1; + int ncell=fam->second[i]-1; if(tab_cell[ncell].geometricType != geometrictype) { // new geometric type -> we store it and complete index tabs diff --git a/src/MEDMEM/MEDMEM_Mesh.hxx b/src/MEDMEM/MEDMEM_Mesh.hxx index a0d229b03..abdb5e2cc 100644 --- a/src/MEDMEM/MEDMEM_Mesh.hxx +++ b/src/MEDMEM/MEDMEM_Mesh.hxx @@ -36,8 +36,8 @@ class CELLMODEL; class FAMILY; class GROUP; class SUPPORT; -class MESH : public RCBASE +class MESH : public RCBASE { //-----------------------// // Attributes @@ -54,20 +54,20 @@ protected : int _spaceDimension; int _meshDimension; int _numberOfNodes; - - + + ////////////////////////////////////////////////////////////////////////////////////// /// Modification pour prise en compte de la numérotation optionnelle des noeuds /// ////////////////////////////////////////////////////////////////////////////////////// /// /// La map suivante donne le lien numérotation optionnelle => numérotation cannonique - /// Elle sera calculée apres l'appel de MEDnumLire(...) + /// Elle sera calculée apres l'appel de MEDnumLire(...) /// Et sera utilisée avant chaque appel a MEDconnLire(...) pour renuméroter toutes les mailles de façon canonique [1...n] /// _coordinate->NodeNumber sera utilisé avant chaque appel à MEDconnEcri pour démunéroter les mailles en leur numérotation originelle /// Ce traitement devrait prévenir tout plantage du aux numérotations optionnelles DES NOEUDS /// Et ne ralentira que tres peu les traitements sans numéros optionnels - - int _arePresentOptionnalNodesNumbers; + + int _arePresentOptionnalNodesNumbers; map _optionnalToCanonicNodesNumbers; vector _familyNode; @@ -186,11 +186,11 @@ public : MED_EN::medEntityMesh Entity) const ; virtual inline int getConnectivityLength(MED_EN::medModeSwitch Mode, MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity, + MED_EN::medEntityMesh Entity, MED_EN::medGeometryElement Type) const; virtual inline const int * getConnectivity(MED_EN::medModeSwitch Mode, MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity, + MED_EN::medEntityMesh Entity, MED_EN::medGeometryElement Type) const; virtual inline const int * getConnectivityIndex(MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity) const; @@ -206,9 +206,9 @@ public : inline int getNumberOfPolyhedronFaces() const; inline int getNumberOfPolyhedron() const; - virtual int getElementNumber(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity, - MED_EN::medGeometryElement Type, + virtual int getElementNumber(MED_EN::medConnectivity ConnectivityType, + MED_EN::medEntityMesh Entity, + MED_EN::medGeometryElement Type, int * connectivity) const; virtual inline int getReverseConnectivityLength(MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const; @@ -226,30 +226,30 @@ public : virtual inline const vector getGroups(MED_EN::medEntityMesh Entity) const; virtual inline const GROUP* getGroup(MED_EN::medEntityMesh Entity,int i) const; virtual inline const CONNECTIVITY* getConnectivityptr() const; - virtual SUPPORT * getBoundaryElements(MED_EN::medEntityMesh Entity) + virtual SUPPORT * getBoundaryElements(MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION); - // problème avec le maillage dans le support : + // 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) + SUPPORT * getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION); // Node DonneBarycentre(const Cell &m) const; - virtual FIELD* getVolume (const SUPPORT * Support) const - throw (MEDEXCEPTION); + virtual FIELD* getVolume (const SUPPORT * Support) const + throw (MEDEXCEPTION); // Support must be on 3D elements - virtual FIELD* getArea (const SUPPORT * Support) const - throw (MEDEXCEPTION); + virtual FIELD* getArea (const SUPPORT * Support) const + throw (MEDEXCEPTION); // Support must be on 2D elements - virtual FIELD* getLength (const SUPPORT * Support) const - throw (MEDEXCEPTION); + virtual FIELD* getLength (const SUPPORT * Support) const + throw (MEDEXCEPTION); // Support must be on 1D elements - virtual FIELD* getNormal (const SUPPORT * Support) const - throw (MEDEXCEPTION); + virtual FIELD* getNormal (const SUPPORT * Support) const + throw (MEDEXCEPTION); // Support must be on 2D elements - virtual FIELD* getBarycenter (const SUPPORT * Support) const + virtual FIELD* getBarycenter (const SUPPORT * Support) const throw (MEDEXCEPTION); - // FIELD* getNeighbourhood(SUPPORT * Support) const + // FIELD* getNeighbourhood(SUPPORT * Support) const // throw (MEDEXCEPTION); // Il faut preciser ! /*! @@ -641,7 +641,7 @@ inline int MESH::getConnectivityLength(MED_EN::medModeSwitch Mode,MED_EN::medCon { int nbOfElm = getNumberOfElements(entity,Type); int size; - + if (Type == MED_EN::MED_ALL_ELEMENTS) { size = getConnectivityIndex(ConnectivityType,entity)[nbOfElm]-1; @@ -758,7 +758,7 @@ inline int MESH::getReverseConnectivityLength(MED_EN::medConnectivity Connectivi { int spaceDim = getSpaceDimension(); int nb; - + if (ConnectivityType == MED_EN::MED_NODAL) { nb = getNumberOfNodes(); diff --git a/src/MEDMEM/MEDMEM_PorflowMeshDriver.cxx b/src/MEDMEM/MEDMEM_PorflowMeshDriver.cxx index c93ea9393..0a38028ed 100644 --- a/src/MEDMEM/MEDMEM_PorflowMeshDriver.cxx +++ b/src/MEDMEM/MEDMEM_PorflowMeshDriver.cxx @@ -203,7 +203,8 @@ inline static medGeometryElement get2DMedGeomType(int nbSommets) case 4: return MED_QUAD4; break; - } + } + return MED_NONE; } // helper function to read a porflow file name (enclosed in single or double quotes) in line diff --git a/src/MEDMEM/MEDMEM_Support.cxx b/src/MEDMEM/MEDMEM_Support.cxx index a739cafe8..120d5f7cb 100644 --- a/src/MEDMEM/MEDMEM_Support.cxx +++ b/src/MEDMEM/MEDMEM_Support.cxx @@ -34,7 +34,7 @@ SUPPORT::SUPPORT(): _name(""), _description("None"), _mesh((MESH*)NULL), //-------------------------------------------------------------------------- { MESSAGE("SUPPORT::SUPPORT()"); -}; +}; /*! Constructor. @@ -45,7 +45,7 @@ SUPPORT::SUPPORT(MESH* Mesh, string Name/*=""*/, medEntityMesh Entity/*=MED_CELL _numberOfGeometricType(0), _geometricType((medGeometryElement*)NULL), _numberOfGaussPoint((int*)NULL), - _isOnAllElts(true), + _isOnAllElts(true), _numberOfElements((int*)NULL), _totalNumberOfElements(0), _number((MEDSKYLINEARRAY*)NULL) @@ -106,7 +106,7 @@ SUPPORT::SUPPORT(const SUPPORT & m) Destructor. */ //----------------- -SUPPORT::~SUPPORT() +SUPPORT::~SUPPORT() //----------------- { MESSAGE("Destructeur ~SUPPORT()"); @@ -145,13 +145,13 @@ ostream & MEDMEM::operator<<(ostream &os, const SUPPORT &my) } } else os << "Is on all entities !"<< endl; - + return os ; } /*! Updade the SUPPORT attributs with rigth MESH information. - + It has an effect only if SUPPORT is on all elements. No more need in future release. @@ -251,7 +251,7 @@ void SUPPORT::blending(SUPPORT * mySupport) throw (MEDEXCEPTION) void SUPPORT::setpartial(string Description, int NumberOfGeometricType, int TotalNumberOfElements, medGeometryElement *GeometricType, - int *NumberOfElements, int *NumberValue) + int *NumberOfElements, int *NumberValue) //------------------- { const char * LOC = "SUPPORT::setpartial(string , int , int , medGeometryElement * , int * , int *) : " ; @@ -284,7 +284,7 @@ void SUPPORT::setpartial(string Description, int NumberOfGeometricType, _numberOfGaussPoint[i] = 1 ; index[i+1] = index[i]+NumberOfElements[i] ; } - + if (_number!=NULL) delete _number ; _number = new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,NumberValue); @@ -314,7 +314,7 @@ void SUPPORT::getBoundaryElements() throw (MEDEXCEPTION) if (spaceDimension == 3) if (_entity != MED_FACE) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 3D mesh for entity "<<_entity<<" !")); - if (spaceDimension == 2) + if (spaceDimension == 2) if (_entity != MED_EDGE) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 2D mesh for entity "<<_entity<<" !")); @@ -437,7 +437,6 @@ void SUPPORT::getBoundaryElements() throw (MEDEXCEPTION) */ //------------------- void SUPPORT::intersecting(SUPPORT * mySupport) throw (MEDEXCEPTION) -//------------------- { const char * LOC="SUPPORT::intersecting(SUPPORT *) : "; BEGIN_OF(LOC); @@ -867,13 +866,13 @@ SUPPORT *MEDMEM::SUPPORT::getBoundaryElements(MED_EN::medEntityMesh Entity) cons BEGIN_OF(LOC); int spaceDimension=_mesh->getSpaceDimension(); MED_EN::medEntityMesh baseEntity=Entity; - if (spaceDimension == 3) + if (spaceDimension == 3) if (Entity!=MED_FACE) if(Entity==MED_NODE) baseEntity=MED_FACE; else throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 3D mesh for entity "<& listOfNode) throw (MEDEX setNumberOfElements(numberOfElements); setTotalNumberOfElements(numberOfElements[0]); setNumber(mySkyLineArray); - + delete[] numberOfElements; delete[] numberOfGaussPoint; delete[] geometricType; } /* - Method created to factorize code. This method fills the current SUPPORT on entity 'entity' containing all the entities contained in + Method created to factorize code. This method fills the current SUPPORT on entity 'entity' containing all the entities contained in elements 'listOfElt' of entity 'entity'. Warning this method should be called after both the attributes this->_mesh and this->_entity are correctly set. */ void MEDMEM::SUPPORT::fillFromElementList(const list& listOfElt) throw (MEDEXCEPTION) diff --git a/src/MEDMEM/MEDMEM_Support.hxx b/src/MEDMEM/MEDMEM_Support.hxx index ef322fa84..42f1be4b1 100644 --- a/src/MEDMEM/MEDMEM_Support.hxx +++ b/src/MEDMEM/MEDMEM_Support.hxx @@ -6,6 +6,7 @@ #ifndef SUPPORT_HXX #define SUPPORT_HXX +#include #include #include #include @@ -21,13 +22,14 @@ 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, + It contains the list of meshes elements for an entity (MED_NODE, MED_CELL, MED_FACE or MED_EDGE). */ namespace MEDMEM { class MESH ; + class SUPPORT : public RCBASE { protected: @@ -98,7 +100,7 @@ protected: If true, we consider all entities of type _entity. \endif */ - bool _isOnAllElts; + bool _isOnAllElts; /*! \if developper @@ -380,7 +382,7 @@ inline void SUPPORT::setNumberOfGaussPoint(const int *NumberOfGaussPoint) } /*! - Set the attribute _numberOfElements to NumberOfElements and + Set the attribute _numberOfElements to NumberOfElements and calculate the total number of elements. */ //---------------------------------------------------------- diff --git a/src/MEDMEM/MEDMEM_define.hxx b/src/MEDMEM/MEDMEM_define.hxx index b91e9ca29..20f6b2d48 100644 --- a/src/MEDMEM/MEDMEM_define.hxx +++ b/src/MEDMEM/MEDMEM_define.hxx @@ -1,5 +1,5 @@ #ifndef DEFINE_HXX -#define DEFINE_HXX +#define DEFINE_HXX #include #include @@ -13,15 +13,15 @@ extern "C"{ namespace MED_EN { - extern "C" { // on est la - + extern "C" { // on est la + // #define MED_NULL (void *) NULL // #define MED_MAX_PARA 20 // #define MED_TAILLE_DESC 200 // #define MED_TAILLE_IDENT 8 // #define MED_TAILLE_NOM 32 -// #define MED_TAILLE_LNOM 80 +// #define MED_TAILLE_LNOM 80 // #define MED_TAILLE_PNOM 8 @@ -52,43 +52,43 @@ namespace MED_EN { const medEntityMesh MED_EDGE = 2; const medEntityMesh MED_NODE = 3; const medEntityMesh MED_ALL_ENTITIES = 4; - + typedef long medModeSwitch; const medModeSwitch MED_FULL_INTERLACE = 0; const medModeSwitch MED_NO_INTERLACE = 1; - + typedef long medConnectivity; const medConnectivity MED_NODAL = 0; const medConnectivity MED_DESCENDING = 1; - + typedef enum {MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED} med_grid_type; - + typedef enum {MED_LECT,MED_ECRI,MED_REMP} med_mode_acces; typedef enum {ASCENDING=7,DESCENDING=77} med_sort_direc; - + typedef enum {MED_REEL64=6, MED_INT32=24,MED_INT64=26} med_type_champ; // #define MED_NBR_GEOMETRIE_MAILLE 15 // #define MED_NBR_GEOMETRIE_FACE 4 // #define MED_NBR_GEOMETRIE_ARETE 2 -typedef enum {MED_CART, MED_CYL, MED_SPHER} med_repere; +typedef enum {MED_CART, MED_CYL, MED_SPHER} med_repere; -typedef enum {MED_FAUX, MED_VRAI} med_booleen ; +typedef enum {MED_FAUX, MED_VRAI} med_booleen ; -typedef enum {MED_GROUPE, MED_ATTR, MED_FAMILLE} med_dim_famille; +typedef enum {MED_GROUPE, MED_ATTR, MED_FAMILLE} med_dim_famille; -typedef enum {MED_COMP, MED_DTYPE} med_dim_champ; +typedef enum {MED_COMP, MED_DTYPE} med_dim_champ; -typedef enum {MED_HDF_VERSION, MED_VERSION, MED_FICH_DES} med_fich_info; +typedef enum {MED_HDF_VERSION, MED_VERSION, MED_FICH_DES} med_fich_info; // #define MED_NOPG 1 /* -> pas de point de Gauss */ // #define MED_NOPFL "" /* -> pas de profils utilisateur */ // #define MED_NOPFLi " " /* Variable Interne */ // #define MED_NOPF 0 /* -> pas de profils pour _MEDdataseNnumEcrire */ // #define MED_NOPDT -1 /* rem: pas de pas de temps negatifs */ -// #define MED_NONOR -1 /* rem: pas de n°ordre negatif */ +// #define MED_NONOR -1 /* rem: pas de n°ordre negatif */ // #define MED_DIM1 1 /* PAS */ // //#define MED_ALL 0 !!!!! NB: WARNING MED_ALL deja utilise dans l'enum medGeometryElement !!!!!!!! // #define MED_ALL 0 @@ -96,7 +96,7 @@ typedef enum {MED_HDF_VERSION, MED_VERSION, MED_FICH_DES} med_fich_info; #if defined(SUN4SOL2) || defined(PCLINUX) || defined(OSF1_32) || defined(IRIX64_32) || defined(RS6000) /* interface C/FORTRAN */ /* this true only with g77 and gcc : we must change it to use directly NOMF_... and INT32 or INT64 - it will be more simple to understand and to use ! */ -// #define NOMF_POST_UNDERSCORE +// #define NOMF_POST_UNDERSCORE /* correspondance des types avec HDF 5 */ typedef hsize_t med_size; @@ -136,7 +136,7 @@ typedef double med_float; #endif -#if defined(PPRO_NT) +#if defined(PPRO_NT) /* correspondance des types avec HDF 5 */ typedef hsize_t med_size; typedef hssize_t med_ssize; @@ -184,11 +184,11 @@ typedef double med_float; //#define MED_NULL NULL #define MED_RDONLY MED_LECT - // rem: MED_WRONLY=MED_ECR n'empêche malheureusement pas de lire le fichier - // mais permet de conserver l'existant. Attention à la création d'objet - // ne prenant pas de paramètre de type mode d'accès il faut tester si il - // est déjà présent dans le fichier. Si MED_WRONLY=MED_REMP le fichier est - // réinitialisé. Cf une évolution de MED. + // rem: MED_WRONLY=MED_ECR n'empêche malheureusement pas de lire le fichier + // mais permet de conserver l'existant. Attention à la création d'objet + // ne prenant pas de paramètre de type mode d'accès il faut tester si il + // est déjà présent dans le fichier. Si MED_WRONLY=MED_REMP le fichier est + // réinitialisé. Cf une évolution de MED. #define MED_WRONLY MED_ECRI #define MED_RDWR MED_ECRI // Fin @@ -234,6 +234,4 @@ typedef double med_float; } // End Of NameSpace MED_EN - #endif /* DEFINE_HXX */ - diff --git a/src/MEDMEM/Makefile.in b/src/MEDMEM/Makefile.in index 2f313739e..9c251029f 100644 --- a/src/MEDMEM/Makefile.in +++ b/src/MEDMEM/Makefile.in @@ -135,9 +135,9 @@ TEST_PROGS = test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray LDFLAGS+= -L$(top_builddir)/lib/salome LDFLAGSFORBIN+= -L$(top_builddir)/lib/salome -CPPFLAGS+=$(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CPPFLAGS+=$(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${MED_ROOT_DIR}/include/salome -CXXFLAGS+=@CXXTMPDPTHFLAGS@ -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS+=@CXXTMPDPTHFLAGS@ -I${KERNEL_ROOT_DIR}/include/salome -I${MED_ROOT_DIR}/include/salome #LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lSalomeLoggerServer -L${KERNEL_ROOT_DIR}/lib/salome # change motivated by the bug KERNEL4778. LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -lSALOMELocalTrace -lMEDWrapper_V2_1 $(STDLIB) @@ -151,9 +151,9 @@ LIBSFORBIN= LIBS= # build create_mesh : -bin: create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_mesh_c3h8q4_wrong create_mesh_c2q4s2_wrong create_grid create_mesh_c2q4 create_mesh_c3h8 +bin: create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_mesh_c3h8q4_wrong create_mesh_c2q4s2_wrong create_grid create_mesh_c2q4 create_mesh_c3h8 create_poly3D -create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_grid create_mesh_c2q4 create_mesh_c3h8 create_mesh_c3h8q4_wrong create_mesh_c2q4s2_wrong: %: %.c +create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_grid create_mesh_c2q4 create_mesh_c3h8 create_mesh_c3h8q4_wrong create_mesh_c2q4s2_wrong create_poly3D: %: %.c $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(MED2_LIBS) $(HDF5_LIBS) $< @CONCLUDE@ diff --git a/src/MEDMEM_I/MEDMEM_Support_i.cxx b/src/MEDMEM_I/MEDMEM_Support_i.cxx index f2d113f44..e3b90c61a 100644 --- a/src/MEDMEM_I/MEDMEM_Support_i.cxx +++ b/src/MEDMEM_I/MEDMEM_Support_i.cxx @@ -617,7 +617,7 @@ void SUPPORT_i::addInStudy (SALOMEDS::Study_ptr myStudy, SALOME_MED::SUPPORT_ptr THROW_SALOME_CORBA_EXCEPTION("SObject Mesh in Support not Found",SALOME::INTERNAL_ERROR); // perhaps add MESH automatically ? - MESSAGE("Add a support Object under /Med/MESH/MESHNAME"); + MESSAGE("Add a support Object under /MED/MESH/MESHNAME"); char * medsupfatherName; int lenName = 15 + strlen(meshName.c_str()) + 1; diff --git a/src/MEDMEM_SWIG/libMEDMEM_Swig.i b/src/MEDMEM_SWIG/libMEDMEM_Swig.i index 65204a0eb..348b3bbba 100644 --- a/src/MEDMEM_SWIG/libMEDMEM_Swig.i +++ b/src/MEDMEM_SWIG/libMEDMEM_Swig.i @@ -80,7 +80,7 @@ /* typemap in for vector */ /* Check if is a list */ - if (PyList_Check($input)) { + if (PyList_Check($input)) { int size = PyList_Size($input); $1.resize(size); @@ -102,13 +102,13 @@ // $1[i] = f; $1.at(i) = f; } - } + } else - { + { PyErr_SetString(PyExc_TypeError,"not a list"); return NULL; } -} +} %typemap(python,out) vector { @@ -135,7 +135,7 @@ /* typemap in for vector */ /* Check if is a list */ - if (PyList_Check($input)) { + if (PyList_Check($input)) { int size = PyList_Size($input); $1.resize(size); @@ -157,13 +157,13 @@ //$1[i] = s; $1.at(i) = s; } - } + } else - { + { PyErr_SetString(PyExc_TypeError,"not a list"); return NULL; } -} +} %typemap(python,out) vector { @@ -186,7 +186,7 @@ /* typemap in for vector *> */ /* Check if is a list */ - if (PyList_Check($input)) { + if (PyList_Check($input)) { int size = PyList_Size($input); $1.resize(size); @@ -209,9 +209,9 @@ //$1[i] = s; $1.at(i) = s; } - } + } else - { + { PyErr_SetString(PyExc_TypeError,"not a list"); return NULL; } @@ -238,7 +238,7 @@ /* typemap in for vector *> */ /* Check if is a list */ - if (PyList_Check($input)) { + if (PyList_Check($input)) { int size = PyList_Size($input); $1.resize(size); @@ -261,9 +261,9 @@ //$1[i] = s; $1.at(i) = s; } - } + } else - { + { PyErr_SetString(PyExc_TypeError,"not a list"); return NULL; } @@ -324,16 +324,16 @@ 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_CARTESIAN, MED_POLAR, MED_BODY_FITTED} med_grid_type; -typedef enum {MED_FULL_INTERLACE, MED_NO_INTERLACE} medModeSwitch; +typedef enum {MED_FULL_INTERLACE, MED_NO_INTERLACE} medModeSwitch; typedef enum {MED_LECT, MED_ECRI, MED_REMP} med_mode_acces; typedef enum {ASCENDING=7,DESCENDING=77} med_sort_direc; typedef enum {MED_CELL, MED_FACE, MED_EDGE, MED_NODE, - MED_ALL_ENTITIES} medEntityMesh; + MED_ALL_ENTITIES} medEntityMesh; typedef enum {MED_NONE=0, MED_POINT1=1, MED_SEG2=102, MED_SEG3=103, MED_TRIA3=203, MED_QUAD4=204, MED_TRIA6=206, MED_QUAD8=208, @@ -342,7 +342,7 @@ typedef enum {MED_NONE=0, MED_POINT1=1, MED_SEG2=102, MED_SEG3=103, MED_PENTA15=315, MED_HEXA20=320, MED_ALL_ELEMENTS=999} medGeometryElement; -typedef enum {MED_NODAL, MED_DESCENDING} medConnectivity ; +typedef enum {MED_NODAL, MED_DESCENDING} medConnectivity ; typedef enum {MED_DRIVER=0, GIBI_DRIVER=1, PORFLOW_DRIVER = 2, VTK_DRIVER=254, NO_DRIVER=255, ASCII_DRIVER = 3} driverTypes; @@ -528,7 +528,7 @@ class SUPPORT PyObject * getTypes() { PyObject *py_list; - + const medGeometryElement * types = self->getTypes(); int size = self->getNumberOfTypes(); py_list = PyList_New(size); @@ -626,7 +626,7 @@ class FAMILY : public SUPPORT FAMILY & operator=(const FAMILY &fam); - void setIdentifier(int Identifier); + void setIdentifier(int Identifier); void setNumberOfAttributes(int NumberOfAttribute); @@ -634,7 +634,7 @@ class FAMILY : public SUPPORT void setAttributesValues(int * AttributeValue); - void setAttributesDescriptions(string * AttributeDescription); + void setAttributesDescriptions(string * AttributeDescription); void setNumberOfGroups(int NumberOfGroups); @@ -736,7 +736,7 @@ class FAMILY : public SUPPORT return result; } } -}; +}; @@ -747,7 +747,7 @@ public: FIELD_(const SUPPORT * Support, const int NumberOfComponents); ~FIELD_(); - + void rmDriver(int index=0); void setIterationNumber (int IterationNumber); @@ -756,7 +756,7 @@ public: void setTime(double Time); double getTime() const; - void setOrderNumber (int OrderNumber); + void setOrderNumber (int OrderNumber); int getOrderNumber() const; void setValueType(med_type_champ ValueType) ; @@ -797,7 +797,7 @@ public: return (SUPPORT *)self->getSupport(); } } -}; +}; class FIELDDOUBLE : public FIELD_ @@ -811,11 +811,11 @@ public: WARNING: other constructor of FIELDDOUBLE (C++ FIELD) object. Only one constructor could be wrapped and - the others commented out when using + the others commented out when using SWIG with a version lesser than 1.3 */ - FIELDDOUBLE(); + FIELDDOUBLE(); FIELDDOUBLE(const FIELDDOUBLE & m); @@ -1032,7 +1032,7 @@ public: 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 + the others commented out when using SWIG with a version lesser than 1.3 */ @@ -1248,7 +1248,7 @@ public: int getNumberOfFamilies() const ; vector getFamilies() const ; FAMILY * getFamily(int i) const ; -}; +}; class MESH { @@ -1257,13 +1257,13 @@ public : WARNING: other constructor of MESH object. Only one constructor could be wrapped and - the others commented out when using + the others commented out when using SWIG with a version lesser than 1.3 */ - MESH(); + MESH(); - ~MESH(); + ~MESH(); void rmDriver(int index=0); @@ -1480,7 +1480,7 @@ public : PyObject * getTypes(medEntityMesh Entity) { PyObject *py_list; - + const medGeometryElement * types = self->getTypes(Entity); int size = self->getNumberOfTypes(Entity); py_list = PyList_New(size); @@ -1742,9 +1742,9 @@ class GRID : public MESH int getEdgeNumber(const int Axis, const int i, const int j=0, const int k=0) const ; int getFaceNumber(const int Axis, const int i, const int j=0, const int k=0) const ; - + med_grid_type getGridType(); - + int getArrayLength( const int Axis ); const double getArrayValue (const int Axis, const int i); @@ -1798,7 +1798,7 @@ class GRID : public MESH } if (Entity == MED_FACE || Entity == MED_EDGE) PyList_SetItem(py_list, 0, Py_BuildValue("i", Axis)); - + PyObject * result = Py_BuildValue("O", py_list); Py_DECREF(py_list); return result; @@ -1815,7 +1815,7 @@ class MED void rmDriver (int index=0); - int getNumberOfMeshes ( void ) const; + int getNumberOfMeshes ( void ) const; int getNumberOfFields ( void ) const; @@ -1832,7 +1832,7 @@ class MED WARNING: other constructor of MED object. Only one constructor could be wrapped and - the others commented out when using + the others commented out when using SWIG with a version lesser than 1.3 */ @@ -2358,7 +2358,7 @@ public : class MED_MESH_RDONLY_DRIVER { public : - + ~MED_MESH_RDONLY_DRIVER(); void open(); @@ -2448,7 +2448,7 @@ class MED_MESH_RDWR_DRIVER : public virtual MED_MESH_RDONLY_DRIVER, public : ~MED_MESH_RDWR_DRIVER(); - + void write(void) const ; void read (void) ; @@ -2826,26 +2826,26 @@ FIELDINT * createFieldIntFromAnalytic(SUPPORT * Support, GRID * createGridFromMesh( MESH * aMesh ); %{ - FIELDDOUBLE * createFieldDoubleScalarProduct(FIELDDOUBLE * field1, FIELDDOUBLE * field2) + FIELDDOUBLE * createFieldDoubleScalarProduct(FIELDDOUBLE * field1, FIELDDOUBLE * field2) { return (FIELDDOUBLE *) FIELD::scalarProduct( (FIELD)*field1, (FIELD)*field2); } - - FIELDINT * createFieldIntScalarProduct(FIELDINT * field1, FIELDINT * field2) + + FIELDINT * createFieldIntScalarProduct(FIELDINT * field1, FIELDINT * field2) { return (FIELDINT *) FIELD::scalarProduct( (FIELD)*field1, (FIELD)*field2); } - FIELDDOUBLE * createFieldDoubleScalarProductDeep(FIELDDOUBLE * field1, FIELDDOUBLE * field2) + FIELDDOUBLE * createFieldDoubleScalarProductDeep(FIELDDOUBLE * field1, FIELDDOUBLE * field2) { return (FIELDDOUBLE *) FIELD::scalarProduct( (FIELD)*field1, (FIELD)*field2, true); } - - FIELDINT * createFieldIntScalarProductDeep(FIELDINT * field1, FIELDINT * field2) + + FIELDINT * createFieldIntScalarProductDeep(FIELDINT * field1, FIELDINT * field2) { return (FIELDINT *) FIELD::scalarProduct( (FIELD)*field1, (FIELD)*field2, true); } - + FIELDDOUBLE * createFieldDoubleFromField(FIELD_ * field) { MESSAGE("createFieldDoubleFromField : Constructor (for Python API) FIELDDOUBLE with parameter FIELD_"); diff --git a/src/MEDWrapper/Base/MED_Algorithm.cxx b/src/MEDWrapper/Base/MED_Algorithm.cxx new file mode 100644 index 000000000..59dd4e54e --- /dev/null +++ b/src/MEDWrapper/Base/MED_Algorithm.cxx @@ -0,0 +1,249 @@ +// +// +// 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 : +// Author : +// Module : +// $Header$ + +#include "MED_Algorithm.hxx" +#include "MED_Utilities.hxx" + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +namespace MED{ + //--------------------------------------------------------------- + TElemGroup + GetElemsByEntity(TWrapper& theWrapper, + const PMeshInfo& theMeshInfo, + const MED::TEntityInfo& theEntityInfo) + { + MSG(MYDEBUG,"GetElemsByEntity(...)"); + TElemGroup aGroup; + MED::TEntityInfo::const_iterator anIter = theEntityInfo.begin(); + for(; anIter != theEntityInfo.end(); anIter++){ + const EEntiteMaillage& anEntity = anIter->first; + const MED::TGeom& aGeom = anIter->second; + TElemMap& anElemMap = aGroup[anEntity]; + + if(anEntity == eNOEUD){ + anElemMap[ePOINT1] = theWrapper.GetPNodeInfo(theMeshInfo); + continue; + } + + MED::TGeom::const_iterator anGeomIter = aGeom.begin(); + for(; anGeomIter != aGeom.end(); anGeomIter++){ + const EGeometrieElement& aGeo = anGeomIter->first; + switch(aGeo){ + case ePOLYGONE: { + anElemMap[ePOLYGONE] = theWrapper.GetPPolygoneInfo(theMeshInfo,anEntity,aGeo); + break; + } + case ePOLYEDRE: { + anElemMap[ePOLYEDRE] = theWrapper.GetPPolyedreInfo(theMeshInfo,anEntity,aGeo); + break; + } + default: { + anElemMap[aGeo] = theWrapper.GetPCellInfo(theMeshInfo,anEntity,aGeo); + }} + + } + } + ADDMSG(MYDEBUG,"\n"); + return aGroup; + } + + + //--------------------------------------------------------------- + TFamilyGroup + GetFamilies(TWrapper& theWrapper, + const PMeshInfo& theMeshInfo) + { + MSG(MYDEBUG,"GetFamilies(...)"); + TErr anErr; + TFamilyGroup aGroup; + TInt aNbFam = theWrapper.GetNbFamilies(*theMeshInfo); + INITMSG(MYDEBUG,"GetNbFamilies() = "<= 0) + aGroup.insert(aFamilyInfo); + } + ADDMSG(MYDEBUG,"\n"); + return aGroup; + } + + + TGroupInfo + GetFamiliesByGroup(const TFamilyGroup& theGroupInfo) + { + MSG(MYDEBUG,"GetFamiliesByGroup(...)"); + TGroupInfo aGroup; + TFamilyGroup::const_iterator anIter = theGroupInfo.begin(); + for(; anIter != theGroupInfo.end(); anIter++){ + const PFamilyInfo& aFamilyInfo = *anIter; + TInt aNbGroup = aFamilyInfo->GetNbGroup(); + for(TInt iGroup = 0; iGroup < aNbGroup; iGroup++){ + aGroup[aFamilyInfo->GetGroupName(iGroup)].insert(aFamilyInfo); + } + } + +#ifdef _DEBUG_ + if(MYDEBUG){ + TGroupInfo::const_iterator anIter = aGroup.begin(); + for(; anIter != aGroup.end(); anIter++){ + string aName = anIter->first; + INITMSG(MYDEBUG,"aGroupName = '"<second; + TFamilyGroup::const_iterator anFamIter = aFamilyGroup.begin(); + for(; anFamIter != aFamilyGroup.end(); anFamIter++){ + const PFamilyInfo& aFamilyInfo = *anFamIter; + INITMSG(MYDEBUG,"aFamilyName = '"<GetName()<<"'\n"); + } + } + ADDMSG(MYDEBUG,"\n"); + } +#endif + + return aGroup; + } + + + //--------------------------------------------------------------- + TTimeStampGroup + GetFieldsByEntity(TWrapper& theWrapper, + const PMeshInfo& theMeshInfo, + const MED::TEntityInfo& theEntityInfo) + { + MSG(MYDEBUG,"GetFieldsByEntity(...)"); + TTimeStampGroup aGroup; + TInt aNbFields = theWrapper.GetNbFields(); + INITMSG(MYDEBUG,"GetNbFields() = "<GetUnitDt() + <<"\', aNbGauss = "<GetNbGauss()<<"\n"); + } + } + ADDMSG(MYDEBUG,"\n"); + return aGroup; + } + + + TFieldGroup + GetFieldsByEntity(const TTimeStampGroup& theTimeStampGroup) + { + TFieldGroup aGroup; + TTimeStampGroup::const_iterator anIter = theTimeStampGroup.begin(); + for(; anIter != theTimeStampGroup.end(); anIter++){ + //const PFieldInfo& aFieldInfo = anIter->first; + const TTimeStampSet& aTimeStampSet = anIter->second; + if(aTimeStampSet.empty()) continue; + const PTimeStampInfo& aTimeStampInfo = *aTimeStampSet.begin(); + aGroup[aTimeStampInfo->GetEntity()].insert(*anIter); + } + return aGroup; + } + + + TFamilyByEntity + GetFamiliesByEntity(TWrapper& theWrapper, + const TElemGroup& theElemGroup, + const TFamilyGroup& theFamilyGroup) + { + MSG(MYDEBUG,"GetFamiliesByEntity(...)"); + TFamilyByEntity aFamilyByEntity; + + typedef map TFamilyByIdMap; + TFamilyByIdMap aFamilyByIdMap; + TFamilyGroup::const_iterator anIter = theFamilyGroup.begin(); + for(; anIter != theFamilyGroup.end(); anIter++){ + const PFamilyInfo& aFamilyInfo = *anIter; + aFamilyByIdMap.insert(TFamilyByIdMap::value_type(aFamilyInfo->GetId(),aFamilyInfo)); + } + + if(!aFamilyByIdMap.empty()){ + typedef set TFamilyIdSet; + typedef map TFamilyIdByEntity; + TFamilyIdByEntity aFamilyIdByEntity; + + if(!theElemGroup.empty()){ + TElemGroup::const_iterator anIter = theElemGroup.begin(); + for(; anIter != theElemGroup.end(); anIter++){ + const EEntiteMaillage& anEntity = anIter->first; + TFamilyIdSet& aFamilyIdSet = aFamilyIdByEntity[anEntity]; + const TElemMap& anElemMap = anIter->second; + TElemMap::const_iterator anElemIter = anElemMap.begin(); + for(; anElemIter != anElemMap.end(); anElemIter++){ + const PElemInfo& aElemInfo = anElemIter->second; + if(TInt aNbElem = aElemInfo->GetNbElem()){ + for(TInt i = 0; i < aNbElem; i++){ + aFamilyIdSet.insert(aElemInfo->GetFamNum(i)); + } + } + } + } + } + + if(!aFamilyIdByEntity.empty()){ + TFamilyIdByEntity::const_iterator anIter = aFamilyIdByEntity.begin(); + for(; anIter != aFamilyIdByEntity.end(); anIter++){ + const EEntiteMaillage& anEntity = anIter->first; + INITMSG(MYDEBUG,"anEntity = "<second; + TFamilyIdSet::const_iterator anFamilyIdIter = aFamilyIdSet.begin(); + for(; anFamilyIdIter != aFamilyIdSet.end(); anFamilyIdIter++){ + const TInt& aFamilyId = *anFamilyIdIter; + TFamilyByIdMap::const_iterator + anFamilyByIdMapIter = aFamilyByIdMap.find(aFamilyId); + if(anFamilyByIdMapIter != aFamilyByIdMap.end()){ + const PFamilyInfo& aFamilyInfo = anFamilyByIdMapIter->second; + aFamilyByEntity[anEntity].insert(aFamilyInfo); + INITMSG(MYDEBUG, + "aFamilyName = '"<GetName()<< + "' anId = "<GetId()<<"\n"); + } + } + } + } + } + ADDMSG(MYDEBUG,"\n"); + return aFamilyByEntity; + } + +} diff --git a/src/MEDWrapper/Base/MED_Algorithm.hxx b/src/MEDWrapper/Base/MED_Algorithm.hxx new file mode 100644 index 000000000..d688f5135 --- /dev/null +++ b/src/MEDWrapper/Base/MED_Algorithm.hxx @@ -0,0 +1,84 @@ +// +// +// 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 : +// Author : +// Module : +// $Header$ + +#ifndef MED_Algorithm_HeaderFile +#define MED_Algorithm_HeaderFile + +#include "MED_Structures.hxx" +#include "MED_Wrapper.hxx" + +#include + +namespace MED{ + //--------------------------------------------------------------- + typedef std::map TElemMap; + typedef std::map TElemGroup; + + TElemGroup GetElemsByEntity(TWrapper& theWrapper, + const PMeshInfo& theMeshInfo, + const MED::TEntityInfo& theEntityInfo); + + + //--------------------------------------------------------------- + typedef std::set TFamilyGroup; + + TFamilyGroup GetFamilies(TWrapper& theWrapper, + const PMeshInfo& theMeshInfo); + + + //--------------------------------------------------------------- + typedef std::map TFamilyByEntity; + + TFamilyByEntity GetFamiliesByEntity(TWrapper& theWrapper, + const TElemGroup& theElemGroup, + const TFamilyGroup& theFamilyGroup); + + + //--------------------------------------------------------------- + typedef std::map TGroupInfo; + + TGroupInfo GetFamiliesByGroup(const TFamilyGroup& theGroupInfo); + + + //--------------------------------------------------------------- + typedef std::set TTimeStampSet; + typedef std::map TTimeStampGroup; + + TTimeStampGroup GetFieldsByEntity(TWrapper& theWrapper, + const PMeshInfo& theMeshInfo, + const MED::TEntityInfo& theEntityInfo); + + + //--------------------------------------------------------------- + typedef std::map TFieldGroup; + + TFieldGroup GetFieldsByEntity(const TTimeStampGroup& theTimeStampGroup); + +} + +#endif diff --git a/src/MEDWrapper/Base/MED_Common.hxx b/src/MEDWrapper/Base/MED_Common.hxx new file mode 100644 index 000000000..279489642 --- /dev/null +++ b/src/MEDWrapper/Base/MED_Common.hxx @@ -0,0 +1,249 @@ +// +// +// 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 : +// Author : +// Module : +// $Header$ + +#ifndef MED_Common_HeaderFile +#define MED_Common_HeaderFile + +#include +#include +#include +#include +#include +#include + +extern "C"{ +#include +} + +#include + +#include "SALOMEconfig.h" + +namespace MED{ + + enum EVersion {eVUnknown = -1, eV2_1, eV2_2}; + + + template class SharedPtr: public boost::shared_ptr + { + public: + SharedPtr() {} + + template + explicit SharedPtr(Y * p): + boost::shared_ptr(p) + {} + + template + SharedPtr(SharedPtr const & r): + boost::shared_ptr(r,boost::detail::polymorphic_cast_tag()) + {} + + template + SharedPtr& operator=(SharedPtr const & r) + { + boost::shared_ptr(r,boost::detail::polymorphic_cast_tag()).swap(*this); + return *this; + } + + template SharedPtr& operator()(Y * p) // Y must be complete + { + return operator=(SharedPtr(p)); + } + + operator const T& () const + { + return *(this->get()); + } + + operator T& () + { + return *(this->get()); + } + }; + + + template + class ConstSliceArray + { + const TContainer& myConstContainer; + std::slice mySlice; + protected: + size_t GetID(size_t theId) const + { + if(theId < mySlice.size()){ + size_t anId = mySlice.start() + theId*mySlice.stride(); + if(anId < myConstContainer.size()) + return anId; + } + throw std::out_of_range(); + return -1; + } + + public: + typedef typename TContainer::value_type TValue; + + ConstSliceArray(const TContainer& theContainer, + const std::slice& theSlice): + myConstContainer(theContainer), + mySlice(theSlice) + { + } + + const TValue& operator[](size_t theId) const + { + return myConstContainer[GetID(theId)]; + } + + size_t size() const + { + return mySlice.size(); + } + }; + + + template + class SliceArray: public ConstSliceArray + { + TContainer& myContainer; + + public: + typedef ConstSliceArray TSupperClass; + SliceArray(TContainer& theContainer, + const std::slice& theSlice): + TSupperClass(theContainer,theSlice), + myContainer(theContainer) + { + } + + typename TSupperClass::TValue& operator[](size_t theId) + { + return myContainer[this->GetID(theId)]; + } + }; + + + typedef enum {eFAUX, eVRAI} EBooleen ; + typedef double TFloat; +#if defined(SUN4SOL2) || defined(PCLINUX) || defined(OSF1_32) || defined(IRIX64_32) || defined(RS6000) || defined(HP9000) + typedef int TInt; +#endif +#if defined(IRIX64) || defined(OSF1) + typedef long TInt; +#endif + typedef hid_t TIdt; + typedef herr_t TErr; + + typedef enum {eFLOAT64=6, eINT=26} ETypeChamp; + + typedef enum {eNON_STRUCTURE, eSTRUCTURE} EMaillage; + + typedef enum {eCART, eCYL, eSPHER} ERepere; + + typedef enum {eNOD, eDESC} EConnectivite ; + + typedef enum {ePOINT1=1, eSEG2=102, eSEG3=103, eTRIA3=203, + eQUAD4=204, eTRIA6=206,eQUAD8=208, eTETRA4=304, + ePYRA5=305, ePENTA6=306, eHEXA8=308, eTETRA10=310, + ePYRA13=313, ePENTA15=315, eHEXA20=320, + ePOLYGONE=400, ePOLYEDRE=500, eNONE=0} EGeometrieElement; + + typedef enum {eMAILLE, eFACE, eARETE, eNOEUD} EEntiteMaillage; + + typedef enum {eNO_PFLMOD, eGLOBAL, eCOMPACT} EModeProfil; + + typedef std::vector TFloatVector; + typedef std::vector TStringVector; + typedef std::vector TIntVector; + typedef std::set TStringSet; + + typedef std::map TGeom; + typedef std::map TEntityInfo; + + typedef std::set TGeomSet; + typedef std::map TEntity2GeomSet; + + const TEntity2GeomSet& GetEntity2GeomSet(); + + template + + TInt GetNbConn(EGeometrieElement typmai, + EEntiteMaillage typent, + TInt mdim); + + template<> + TInt GetNbConn(EGeometrieElement typmai, + EEntiteMaillage typent, + TInt mdim); + + template<> + TInt GetNbConn(EGeometrieElement typmai, + EEntiteMaillage typent, + TInt mdim); + + TInt GetNbNodes(EGeometrieElement typmai); + + struct TNameInfo; + typedef SharedPtr PNameInfo; + + struct TMeshInfo; + typedef SharedPtr PMeshInfo; + + struct TFamilyInfo; + typedef SharedPtr PFamilyInfo; + + struct TElemInfo; + typedef SharedPtr PElemInfo; + + struct TNodeInfo; + typedef SharedPtr PNodeInfo; + + struct TPolygoneInfo; + typedef SharedPtr PPolygoneInfo; + + struct TPolyedreInfo; + typedef SharedPtr PPolyedreInfo; + + struct TCellInfo; + typedef SharedPtr PCellInfo; + + struct TFieldInfo; + typedef SharedPtr PFieldInfo; + + struct TTimeStampInfo; + typedef SharedPtr PTimeStampInfo; + + struct TTimeStampVal; + typedef SharedPtr PTimeStampVal; + + class TWrapper; + typedef SharedPtr PWrapper; +}; + + +#endif diff --git a/src/MEDWrapper/Base/MED_Structures.cxx b/src/MEDWrapper/Base/MED_Structures.cxx new file mode 100644 index 000000000..c193acce8 --- /dev/null +++ b/src/MEDWrapper/Base/MED_Structures.cxx @@ -0,0 +1,181 @@ +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_Structure.cxx +// Author : Eugeny NIKOLAEV +// Module : VISU + +#include "MED_Structures.hxx" +#include "MED_Utilities.hxx" +using namespace MED; + +#if defined __GNUC__ + #if __GNUC__ == 2 + #define __GNUC_2__ + #endif +#endif + +#if defined __GNUC_2__ +#define GETINDEX(anArray,ind) anArray[ind] +#else +#define GETINDEX(anArray,ind) anArray.at(ind) +#endif + +namespace MED{ + + TInt GetNbNodes(EGeometrieElement typmai) + { + return typmai%100; + } + + template<> + TInt GetNbConn(EGeometrieElement typmai, + EEntiteMaillage typent, + TInt mdim) + { + TInt nsup = 0; + + if(typent == eMAILLE){ + TInt edim = typmai / 100; + if(mdim == 2 || mdim == 3) + if(edim == 1) + nsup = 1; + + if(mdim == 3) + if (edim == 2) + nsup = 1; + } + + return nsup + typmai%100; + } + + template<> + TInt GetNbConn(EGeometrieElement typmai, + EEntiteMaillage typent, + TInt mdim) + { + return typmai%100; + } + + std::string GetString(TInt theId, TInt theStep, + const TString& theString) + { + const char* aPos = &GETINDEX(theString,theId*theStep); + TInt aSize = std::min(TInt(strlen(aPos)),theStep); + return std::string(aPos,aSize); + } + + void SetString(TInt theId, TInt theStep, + TString& theString, + const std::string& theValue) + { + TInt aSize = std::min(TInt(theValue.size()+1),theStep); + char* aPos = &GETINDEX(theString,theId*theStep); + strncpy(aPos,theValue.c_str(),aSize); + } + +} + +//--------------------------------------------------------------- +TInt TFamilyInfo::GetAttrId(TInt theId) const { + return GETINDEX(myAttrId,theId); +} + +TInt TFamilyInfo::GetAttrVal(TInt theId) const { + return GETINDEX(myAttrVal,theId); +} + +void TFamilyInfo::SetAttrId(TInt theId,TInt theVal) { + GETINDEX(myAttrId,theId) = theVal; +} + +void TFamilyInfo::SetAttrVal(TInt theId,TInt theVal) { + GETINDEX(myAttrVal,theId) = theVal; +} + +//--------------------------------------------------------------- +TInt TElemInfo::GetFamNum(TInt theId) const { + return GETINDEX(myFamNum,theId); +} + +TInt TElemInfo::GetElemNum(TInt theId) const { + return GETINDEX(myElemNum,theId); +} + +void TElemInfo::SetFamNum(TInt theId,TInt theVal) { + GETINDEX(myFamNum,theId) = theVal; +} + +//--------------------------------------------------------------- +TFloat TNodeInfo::GetNodeCoord(TInt theId,TInt theComp) const { + return GETINDEX(myCoord,myMeshInfo->myDim*theId + theComp); +} + +void TNodeInfo::SetNodeCoord(TInt theId,TInt theComp,TFloat theVal) { + GETINDEX(myCoord,myMeshInfo->myDim*theId + theComp) = theVal; +} + +//--------------------------------------------------------------- +TInt TCellInfo::GetConn(TInt theElemId, TInt theConnId) const { + return GETINDEX(myConn,GetConnDim()*theElemId + theConnId); +} + +void TCellInfo::SetConn(TInt theElemId, TInt theConnId, TInt theVal){ + GETINDEX(myConn,GetConnDim()*theElemId + theConnId) = theVal; +} + +TConstConnSlice +TCellInfo::GetConnSlice(TInt theElemId) const +{ + return TConstConnSlice(myConn,std::slice(GetConnDim()*theElemId,GetNbNodes(myTGeom),1)); +} + +TConnSlice +TCellInfo::GetConnSlice(TInt theElemId) +{ + return TConnSlice(myConn,std::slice(GetConnDim()*theElemId,GetNbNodes(myTGeom),1)); +} + +//--------------------------------------------------------------- +TInt TPolygoneInfo::GetNbConn(TInt theElemId) const { + TInt i1 = GETINDEX(myIndex,theElemId); + TInt i2 = GETINDEX(myIndex,theElemId+1); + TInt ret = i2 - i1; + return ret; +} + +//--------------------------------------------------------------- +TInt TPolyedreInfo::GetNbConn(TInt theElemId) const { + TInt ind1 = GETINDEX(myIndex,theElemId); + TInt ind2 = GETINDEX(myIndex,theElemId+1); + + TInt inf1 = GETINDEX(myFacesIndex,ind1-1); + TInt inf2 = GETINDEX(myFacesIndex,ind2-1); + + TInt ret = inf2-inf1; + return ret; +} + +//--------------------------------------------------------------- +TFloat TTimeStampVal::GetVal(EGeometrieElement theGeom, TInt theId, + TInt theComp, TInt theGauss) const { + TInt aNbComp = myTimeStampInfo->myFieldInfo->myNbComp; + TInt aNbGauss = myTimeStampInfo->myNbGauss; + TInt aStep = aNbComp*aNbGauss; + TMeshValue::const_iterator anIter = myMeshValue.find(theGeom); + if(anIter != myMeshValue.end()){ + TFloat aRet=GETINDEX(anIter->second,theId*aStep + theComp*aNbGauss + theGauss); + return aRet; + } + return TFloat(); +} + +void TTimeStampVal::SetVal(EGeometrieElement theGeom, TInt theId, + TInt theComp, TFloat theVal, TInt theGauss) +{ + TInt aNbComp = myTimeStampInfo->myFieldInfo->myNbComp; + TInt aNbGauss = myTimeStampInfo->myNbGauss; + TInt aStep = aNbComp*aNbGauss; + GETINDEX(myMeshValue[theGeom],theId*aStep + theComp*aNbGauss + theGauss) = theVal; +} diff --git a/src/MEDWrapper/Base/MED_Structures.hxx b/src/MEDWrapper/Base/MED_Structures.hxx new file mode 100644 index 000000000..560410eeb --- /dev/null +++ b/src/MEDWrapper/Base/MED_Structures.hxx @@ -0,0 +1,328 @@ +// +// +// 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 : +// Author : +// Module : +// $Header$ + +#ifndef MED_Structures_HeaderFile +#define MED_Structures_HeaderFile + +#include "MED_Common.hxx" + +namespace MED{ + + //--------------------------------------------------------------- + typedef std::vector TString; + + std::string GetString(TInt theId, TInt theStep, + const TString& theString); + + void SetString(TInt theId, TInt theStep, + TString& theString, + const std::string& theValue); + + //--------------------------------------------------------------- + struct TBase + { + virtual ~TBase() {} + }; + + + //--------------------------------------------------------------- + struct TNameInfo: virtual TBase + { + TString myName; + virtual std::string GetName() const = 0; + virtual void SetName(const std::string& theValue) = 0; + }; + + + //--------------------------------------------------------------- + struct TMeshInfo: virtual TNameInfo + { + TInt myDim; + TInt GetDim() const { return myDim;} + + EMaillage myType; + EMaillage GetType() const { return myType;} + + TString myDesc; + virtual std::string GetDesc() const = 0; + virtual void SetDesc(const std::string& theValue) = 0; + }; + + + //--------------------------------------------------------------- + typedef std::vector TFamAttr; + + struct TFamilyInfo: virtual TNameInfo + { + PMeshInfo myMeshInfo; + const PMeshInfo& GetMeshInfo() const { return myMeshInfo;} + + TInt myId; + TInt GetId() const { return myId;} + void SetId(TInt theId) { myId = theId;} + + TInt myNbGroup; + TInt GetNbGroup() const { return myNbGroup;} + + TString myGroupNames; + virtual std::string GetGroupName(TInt theId) const = 0; + virtual void SetGroupName(TInt theId, const std::string& theValue) = 0; + + TInt myNbAttr; + TInt GetNbAttr() const { return myNbAttr;} + + TFamAttr myAttrId; + TInt GetAttrId(TInt theId) const; + void SetAttrId(TInt theId, TInt theVal); + + TFamAttr myAttrVal; + TInt GetAttrVal(TInt theId) const; + void SetAttrVal(TInt theId, TInt theVal); + + TString myAttrDesc; + virtual std::string GetAttrDesc(TInt theId) const = 0; + virtual void SetAttrDesc(TInt theId, const std::string& theValue) = 0; + }; + + + //--------------------------------------------------------------- + typedef std::vector TElemNum; + + struct TElemInfo: virtual TBase + { + PMeshInfo myMeshInfo; + const PMeshInfo& GetMeshInfo() const { return myMeshInfo;} + + TInt myNbElem; + TInt GetNbElem() const { return myNbElem;} + + TElemNum myFamNum; + TInt GetFamNum(TInt theId) const; + void SetFamNum(TInt theId, TInt theVal); + + EBooleen myIsElemNum; + EBooleen IsElemNum() const { return myIsElemNum;} + + TElemNum myElemNum; + TInt GetElemNum(TInt theId) const; + void SetElemNum(TInt theId, TInt theVal); + + EBooleen myIsElemNames; + EBooleen IsElemNames() const { return myIsElemNames;} + + TString myElemNames; + virtual std::string GetElemName(TInt theId) const = 0; + virtual void SetElemName(TInt theId, const std::string& theValue) = 0; + }; + + + //--------------------------------------------------------------- + typedef std::vector TNodeCoord; + + struct TNodeInfo: virtual TElemInfo + { + TNodeCoord myCoord; + TFloat GetNodeCoord(TInt theId, TInt theComp) const; + void SetNodeCoord(TInt theId, TInt theComp, TFloat theVal); + + ERepere mySystem; + ERepere GetSystem() const { return mySystem;} + void SetSystem(ERepere theSystem) { mySystem = theSystem;} + + TString myCoordNames; + virtual std::string GetCoordName(TInt theId) const = 0; + virtual void SetCoordName(TInt theId, const std::string& theValue) = 0; + + TString myCoordUnits; + virtual std::string GetCoordUnit(TInt theId) const = 0; + virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0; + }; + + + //--------------------------------------------------------------- + typedef SliceArray TConnSlice; + typedef ConstSliceArray TConstConnSlice; + + struct TCellInfo: virtual TElemInfo + { + EEntiteMaillage myTEntity; + EEntiteMaillage GetEntity() const { return myTEntity;} + + EGeometrieElement myTGeom; + EGeometrieElement GetGeom() const { return myTGeom;} + + EConnectivite myTConn; + EConnectivite GetConn() const { return myTConn;} + + virtual TInt GetConnDim() const = 0; + + TElemNum myConn; + TConstConnSlice GetConnSlice(TInt theElemId) const; + TConnSlice GetConnSlice(TInt theElemId); + + TInt GetConn(TInt theElemId, TInt theConnId) const; + void SetConn(TInt theElemId, TInt theConnId, TInt theVal); + }; + + //--------------------------------------------------------------- + struct TPolygoneInfo: virtual TElemInfo + { + EEntiteMaillage myTEntity; // MED_FACE|MED_MAILLE + EEntiteMaillage GetEntity() const { return myTEntity;} + + EGeometrieElement myTGeom; // ePOLYGONE + EGeometrieElement GetGeom() const { return ePOLYGONE;} + + EConnectivite myTConn; // eNOD|eDESC(eDESC not used) + EConnectivite GetConn() const { return myTConn;} + + TInt myConnDim; + TInt GetConnDim() const { return myConnDim;} + + TElemNum myConn; // Table de connectivities + TElemNum GetConnectivite() const { return myConn;} + + TElemNum myIndex; // Table de indexes + TElemNum GetIndex() {return myIndex;} + TInt GetNbConn(TInt theElemId) const; + }; + + //--------------------------------------------------------------- + struct TPolyedreInfo: virtual TElemInfo + { + EEntiteMaillage myTEntity; // MED_FACE|MED_MAILLE + EEntiteMaillage GetEntity() const { return myTEntity;} + + EGeometrieElement myTGeom; // ePOLYEDRE + EGeometrieElement GetGeom() const { return ePOLYEDRE;} + + EConnectivite myTConn; // eNOD|eDESC(eDESC not used) + EConnectivite GetConn() const { return myTConn;} + + TInt myNbConn; + TInt GetNbConn() const { return myNbConn;} + + TElemNum myConn; // Table de connectivities + TElemNum GetConnectivite() const { return myConn;} + + TInt myNbFacesIndex; + TInt GetNbFacesIndex() const { return myNbFacesIndex;} + + TElemNum myFacesIndex; // Table de faces indexes + TElemNum GetFacesIndex() {return myFacesIndex;} + + TElemNum myIndex; // Table de indexes + TElemNum GetIndex() {return myIndex;} + TInt GetNbConn(TInt theElemId) const; + }; + + //--------------------------------------------------------------- + struct TFieldInfo: virtual TNameInfo + { + PMeshInfo myMeshInfo; + const PMeshInfo& GetMeshInfo() const { return myMeshInfo;} + + ETypeChamp myType; + ETypeChamp GetType() const { return myType;} + + TInt myNbComp; + TInt GetNbComp() const { return myNbComp;} + + EBooleen myIsLocal; + EBooleen GetIsLocal() const { return myIsLocal;} + + TInt myNbRef; + TInt GetNbRef() const { return myNbRef;} + + TString myCompNames; + virtual std::string GetCompName(TInt theId) const = 0; + virtual void SetCompName(TInt theId, const std::string& theValue) = 0; + + TString myUnitNames; + virtual std::string GetUnitName(TInt theId) const = 0; + virtual void SetUnitName(TInt theId, const std::string& theValue) = 0; + }; + + + //--------------------------------------------------------------- + struct TTimeStampInfo: virtual TBase + { + PFieldInfo myFieldInfo; + const PFieldInfo& GetFieldInfo() const { return myFieldInfo;} + + EEntiteMaillage myEntity; + EEntiteMaillage GetEntity() const { return myEntity;} + + TGeom myGeom; + const TGeom& GetGeom() const { return myGeom;} + + TInt myNbGauss, myNumDt, myNumOrd; + TInt GetNbGauss() const { return myNbGauss;} + TInt GetNumDt() const { return myNumDt;} + TInt GetNumOrd() const { return myNumOrd;} + + TFloat myDt; + TFloat GetDt() const { return myDt;} + + TString myGaussName; + virtual std::string GetGaussName() const = 0; + virtual void SetGaussName(const std::string& theValue) = 0; + + TString myUnitDt; + virtual std::string GetUnitDt() const = 0; + virtual void SetUnitDt(const std::string& theValue) = 0; + }; + + + //--------------------------------------------------------------- + typedef std::vector TValue; + typedef std::map TMeshValue; + + struct TTimeStampVal: virtual TBase + { + PTimeStampInfo myTimeStampInfo; + const PTimeStampInfo& GetTimeStampInfo() const { return myTimeStampInfo;} + + TMeshValue myMeshValue; + TFloat GetVal(EGeometrieElement theGeom, TInt theId, + TInt theComp, TInt theGauss = 0) const; + + void SetVal(EGeometrieElement theGeom, TInt theId, + TInt theComp, TFloat theVal, TInt theGauss = 0); + EModeProfil myPflMode; + EModeProfil GetPflMode() const { return myPflMode;} + void GetPflMode(EModeProfil theVal) { myPflMode = theVal;} + + TString myPflName; + virtual std::string GetPflName() const = 0; + virtual void SetPflName(const std::string& theValue) = 0; + }; + +} + +#endif diff --git a/src/MEDWrapper/Base/MED_TStructures.hxx b/src/MEDWrapper/Base/MED_TStructures.hxx new file mode 100644 index 000000000..ed9d00d69 --- /dev/null +++ b/src/MEDWrapper/Base/MED_TStructures.hxx @@ -0,0 +1,820 @@ +// +// +// 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 : +// Author : +// Module : +// $Header$ + +#ifndef MED_TStructures_HeaderFile +#define MED_TStructures_HeaderFile + +#include "MED_Structures.hxx" + +namespace MED{ + + const TInt DESC = 200; + const TInt IDENT = 8; + const TInt NOM = 32; + const TInt LNOM = 80; + + //--------------------------------------------------------------- + template + struct TTNameInfo: virtual TNameInfo + { + TTNameInfo(const std::string& theValue = "") + { + myName.resize(nNOM+1); + SetName(theValue); + } + + virtual std::string GetName() const { + return GetString(0,nNOM,myName); + } + + virtual void SetName(const std::string& theValue){ + SetString(0,nNOM,myName,theValue); + } + }; + + + //--------------------------------------------------------------- + template + struct TTMeshInfo: + virtual TMeshInfo, + virtual TTNameInfo + { + typedef TTNameInfo TNameInfoBase; + + TTMeshInfo(const PMeshInfo& theInfo): + TNameInfoBase(theInfo->GetName()) + { + myDim = theInfo->GetDim(); + myType = theInfo->GetType(); + + myDesc.resize(nDESC+1); + SetDesc(theInfo->GetDesc()); + } + + TTMeshInfo(TInt theDim = 0, + const std::string& theValue = "", + EMaillage theType = eNON_STRUCTURE, + const std::string& theDesc = ""): + TNameInfoBase(theValue) + { + myDim = theDim; + myType = theType; + + myDesc.resize(nDESC+1); + SetDesc(theDesc); + } + + virtual std::string GetDesc() const { + return GetString(0,nDESC,myDesc); + } + + virtual void SetDesc(const std::string& theValue){ + SetString(0,nDESC,myDesc,theValue); + } + }; + + + //--------------------------------------------------------------- + template + struct TTFamilyInfo: + virtual TFamilyInfo, + virtual TTNameInfo + { + typedef TTNameInfo TNameInfoBase; + + TTFamilyInfo(const PMeshInfo& theMeshInfo, const PFamilyInfo& theInfo): + TNameInfoBase(theInfo->GetName()) + { + myMeshInfo = theMeshInfo; + + myId = theInfo->GetId(); + + myNbGroup = theInfo->GetNbGroup(); + myGroupNames.resize(myNbGroup*nLNOM+1); + if(myNbGroup){ + for(TInt anId = 0; anId < myNbGroup; anId++){ + SetGroupName(anId,theInfo->GetGroupName(anId)); + } + } + + myNbAttr = theInfo->GetNbAttr(); + myAttrId.resize(myNbAttr); + myAttrVal.resize(myNbAttr); + myAttrDesc.resize(myNbAttr*nDESC+1); + if(myNbAttr){ + for(TInt anId = 0; anId < myNbAttr; anId++){ + SetAttrDesc(anId,theInfo->GetAttrDesc(anId)); + myAttrVal[anId] = theInfo->GetAttrVal(anId); + myAttrId[anId] = theInfo->GetAttrId(anId); + } + } + } + + TTFamilyInfo(const PMeshInfo& theMeshInfo, + TInt theNbGroup = 0, + TInt theNbAttr = 0, + TInt theId = 0, + const std::string& theValue = ""): + TNameInfoBase(theValue) + { + myMeshInfo = theMeshInfo; + + myId = theId; + + myNbGroup = theNbGroup; + myGroupNames.resize(theNbGroup*nLNOM+1); + + myNbAttr = theNbAttr; + myAttrId.resize(theNbAttr); + myAttrVal.resize(theNbAttr); + myAttrDesc.resize(theNbAttr*nDESC+1); + } + + TTFamilyInfo(const PMeshInfo& theMeshInfo, + const std::string& theValue, + TInt theId, + const TStringSet& theGroupNames, + const TStringVector& theAttrDescs = TStringVector(), + const TIntVector& theAttrIds = TIntVector(), + const TIntVector& theAttrVals = TIntVector()): + TNameInfoBase(theValue) + { + myMeshInfo = theMeshInfo; + + myId = theId; + + myNbGroup = theGroupNames.size(); + myGroupNames.resize(myNbGroup*nLNOM+1); + if(myNbGroup){ + TStringSet::const_iterator anIter = theGroupNames.begin(); + for(TInt anId = 0; anIter != theGroupNames.end(); anIter++, anId++){ + const std::string& aVal = *anIter; + SetGroupName(anId,aVal); + } + } + + myNbAttr = theAttrDescs.size(); + myAttrId.resize(myNbAttr); + myAttrVal.resize(myNbAttr); + myAttrDesc.resize(myNbAttr*nDESC+1); + if(myNbAttr){ + for(TInt anId = 0, anEnd = theAttrDescs.size(); anId < anEnd; anId++){ + SetAttrDesc(anId,theAttrDescs[anId]); + myAttrVal[anId] = theAttrVals[anId]; + myAttrId[anId] = theAttrIds[anId]; + } + } + } + + virtual std::string GetGroupName(TInt theId) const { + return GetString(theId,nLNOM,myGroupNames); + } + + virtual void SetGroupName(TInt theId, const std::string& theValue){ + SetString(theId,nLNOM,myGroupNames,theValue); + } + + virtual std::string GetAttrDesc(TInt theId) const { + return GetString(theId,nDESC,myAttrDesc); + } + + virtual void SetAttrDesc(TInt theId, const std::string& theValue){ + SetString(theId,nDESC,myAttrDesc,theValue); + } + }; + + + //--------------------------------------------------------------- + template + struct TTElemInfo: virtual TElemInfo + { + TTElemInfo(const PMeshInfo& theMeshInfo, const PElemInfo& theInfo) + { + myMeshInfo = theMeshInfo; + + myNbElem = theInfo->GetNbElem(); + myFamNum.resize(myNbElem); + + myIsElemNum = theInfo->IsElemNum(); + myElemNum.resize(myIsElemNum == eFAUX? 0: myNbElem); + + myIsElemNames = theInfo->IsElemNames(); + myElemNames.resize(myNbElem*nPNOM+1); + + if(myNbElem){ + for(TInt anId = 0; anId < myNbElem; anId++){ + myFamNum[anId] = theInfo->GetFamNum(anId); + } + if(myIsElemNum == eVRAI){ + for(TInt anId = 0; anId < myNbElem; anId++){ + myElemNum[anId] = theInfo->GetElemNum(anId); + } + } + if(myIsElemNames == eVRAI){ + for(TInt anId = 0; anId < myNbElem; anId++){ + SetElemName(anId,theInfo->GetElemName(anId)); + } + } + } + } + + TTElemInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + myMeshInfo = theMeshInfo; + + myNbElem = theNbElem; + myFamNum.resize(theNbElem); + + myIsElemNum = theIsElemNum; + myElemNum.resize(theIsElemNum == eFAUX? 0: theNbElem); + + myIsElemNames = theIsElemNames; + myElemNames.resize(theNbElem*nPNOM+1); + } + + TTElemInfo(const PMeshInfo& theMeshInfo, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()) + { + myMeshInfo = theMeshInfo; + + myNbElem = theFamilyNums.size(); + myFamNum.resize(myNbElem); + + myIsElemNum = theElemNums.size()? eVRAI: eFAUX; + myElemNum.resize(theElemNums.size()); + + myIsElemNames = theElemNames.size()? eVRAI: eFAUX; + myElemNames.resize(theElemNames.size()*nPNOM+1); + + if(myNbElem){ + for(TInt anId = 0; anId < myNbElem; anId++){ + myFamNum[anId] = theFamilyNums[anId]; + } + if(myIsElemNum == eVRAI){ + for(TInt anId = 0; anId < myNbElem; anId++){ + myElemNum[anId] = theElemNums[anId]; + } + } + if(myIsElemNames == eVRAI){ + for(TInt anId = 0; anId < myNbElem; anId++){ + const std::string& aVal = theElemNames[anId]; + SetElemName(anId,aVal); + } + } + } + } + + virtual std::string GetElemName(TInt theId) const { + return GetString(theId,nPNOM,myElemNames); + } + + virtual void SetElemName(TInt theId, const std::string& theValue){ + SetString(theId,nPNOM,myElemNames,theValue); + } + }; + + + //--------------------------------------------------------------- + template + struct TTNodeInfo: + virtual TNodeInfo, + virtual TTElemInfo + { + typedef TTElemInfo TElemInfoBase; + + TTNodeInfo(const PMeshInfo& theMeshInfo, const PNodeInfo& theInfo): + TElemInfoBase(theMeshInfo,theInfo) + { + mySystem = theInfo->GetSystem(); + + TInt aDim = theMeshInfo->GetDim(); + TInt aNbElem = theInfo->GetNbElem(); + myCoord.resize(aNbElem*aDim); + + for(TInt anElemId = 0; anElemId < aNbElem; anElemId++){ + for(TInt anDimId = 0; anDimId < aDim; anDimId++){ + SetNodeCoord(anElemId,anDimId,theInfo->GetNodeCoord(anElemId,anDimId)); + } + } + + myCoordNames.resize(aDim*nPNOM+1); + for(TInt anId = 0; anId < aDim; anId++){ + SetCoordName(anId,theInfo->GetCoordName(anId)); + } + + myCoordUnits.resize(aDim*nPNOM+1); + for(TInt anId = 0; anId < aDim; anId++){ + SetCoordUnit(anId,theInfo->GetCoordUnit(anId)); + } + } + + TTNodeInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + ERepere theSystem = eCART, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI): + TElemInfoBase(theMeshInfo, + theNbElem, + theIsElemNum, + theIsElemNames) + { + mySystem = theSystem; + myCoord.resize(theNbElem*theMeshInfo->myDim); + myCoordNames.resize(theMeshInfo->myDim*nPNOM+1); + myCoordUnits.resize(theMeshInfo->myDim*nPNOM+1); + } + + + TTNodeInfo(const PMeshInfo& theMeshInfo, + ERepere theSystem, + const TFloatVector& theNodeCoords, + const TStringVector& theCoordNames, + const TStringVector& theCoordUnits, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()): + TElemInfoBase(theMeshInfo, + theFamilyNums, + theElemNums, + theElemNames) + { + mySystem = theSystem; + myCoord.resize(theNodeCoords.size()); + + for(TInt anId = 0, anEnd = myCoord.size(); anId < anEnd; anId++){ + myCoord[anId] = theNodeCoords[anId]; + } + + TInt aDim = theMeshInfo->GetDim(); + myCoordNames.resize(aDim*nPNOM+1); + for(TInt anId = 0; anId < aDim; anId++){ + SetCoordName(anId,theCoordNames[anId]); + } + + myCoordUnits.resize(aDim*nPNOM+1); + for(TInt anId = 0; anId < aDim; anId++){ + SetCoordUnit(anId,theCoordUnits[anId]); + } + } + + virtual std::string GetCoordName(TInt theId) const { + return GetString(theId,nPNOM,myCoordNames); + } + + virtual void SetCoordName(TInt theId, const std::string& theValue){ + SetString(theId,nPNOM,myCoordNames,theValue); + } + + virtual std::string GetCoordUnit(TInt theId) const { + return GetString(theId,nPNOM,myCoordUnits); + } + + virtual void SetCoordUnit(TInt theId, const std::string& theValue){ + SetString(theId,nPNOM,myCoordUnits,theValue); + } + }; + + //--------------------------------------------------------------- + template + struct TTPolygoneInfo: + virtual TPolygoneInfo, + virtual TTElemInfo + { + typedef TTElemInfo TElemInfoBase; + + TTPolygoneInfo(const PMeshInfo& theMeshInfo, const PPolygoneInfo& theInfo): + TElemInfoBase(theMeshInfo,theInfo) + { + myTEntity = theInfo->GetEntity(); + myTGeom = theInfo->GetGeom(); + myTConn = theInfo->GetConn(); + myConnDim = theInfo->GetConnDim(); + myConn = theInfo->GetConnectivite(); + myIndex = theInfo->GetIndex(); + } + + TTPolygoneInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + TInt theNbConn, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI): + TElemInfoBase(theMeshInfo, + theNbElem, + theIsElemNum, + theIsElemNames) + { + myTEntity = theTEntity; + myTGeom = theTGeom; + myTConn = theTConn; + myConnDim = theNbConn; + myConn.resize(myConnDim); + myIndex.resize(theNbElem+1); + } + + TTPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + const TIntVector& theConnectivities, + const TIntVector& theIndexes, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()): + TElemInfoBase(theMeshInfo, + theFamilyNums, + theElemNums, + theElemNames) + { + myTEntity = theTEntity; + myTGeom = theTGeom; + myTConn = theTConn; + myConnDim = theConnectivities.size(); + myConn = theConnectivities; + myIndex = theIndexes; + } + }; + + //--------------------------------------------------------------- + template + struct TTPolyedreInfo: + virtual TPolyedreInfo, + virtual TTElemInfo + { + typedef TTElemInfo TElemInfoBase; + + TTPolyedreInfo(const PMeshInfo& theMeshInfo, const PPolyedreInfo& theInfo): + TElemInfoBase(theMeshInfo,theInfo) + { + myTEntity = theInfo->GetEntity(); + myTGeom = theInfo->GetGeom(); + myTConn = theInfo->GetConn(); + myNbConn = theInfo->GetNbConn(); + myNbFacesIndex = theInfo->GetNbFacesIndex(); + myConn = theInfo->GetConnectivite(); + myFacesIndex = theInfo->GetFacesIndex(); + myIndex = theInfo->GetIndex(); + } + + TTPolyedreInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + TInt theNbConn, + TInt theNbFacesIndex, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI): + TElemInfoBase(theMeshInfo, + theNbElem, + theIsElemNum, + theIsElemNames) + { + myTEntity = theTEntity; + myTGeom = theTGeom; + myTConn = theTConn; + myNbConn = theNbConn; + myNbFacesIndex = theNbFacesIndex; + myConn.resize(myNbConn); + myFacesIndex.resize(myNbFacesIndex); + myIndex.resize(theNbElem+1); + } + + TTPolyedreInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + const TIntVector& theConnectivities, + const TIntVector& theFacesIndexes, + const TIntVector& theIndexes, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()): + TElemInfoBase(theMeshInfo, + theFamilyNums, + theElemNums, + theElemNames) + { + myTEntity = theTEntity; + myTGeom = theTGeom; + myTConn = theTConn; + myNbConn = theConnectivities.size(); + myNbFacesIndex = theFacesIndexes.size(); + myConn = theConnectivities; + myFacesIndex = theFacesIndexes; + myIndex = theIndexes; + } + }; + + //--------------------------------------------------------------- + template + struct TTCellInfo: + virtual TCellInfo, + virtual TTElemInfo + { + typedef TTElemInfo TElemInfoBase; + + TTCellInfo(const PMeshInfo& theMeshInfo, const PCellInfo& theInfo): + TElemInfoBase(theMeshInfo,theInfo) + { + myTEntity = theInfo->GetEntity(); + myTGeom = theInfo->GetGeom(); + myTConn = theInfo->GetConn(); + + TInt aConnDim = GetNbNodes(myTGeom); + myConn.resize(myNbElem*GetNbConn(myTGeom,myTEntity,myMeshInfo->myDim)); + for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){ + for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){ + SetConn(anElemId,anConnId,theInfo->GetConn(anElemId,anConnId)); + } + } + } + + TTCellInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI): + TElemInfoBase(theMeshInfo, + theNbElem, + theIsElemNum, + theIsElemNames) + { + myTEntity = theTEntity; + myTGeom = theTGeom; + myTConn = theTConn; + myConn.resize(theNbElem*GetNbConn(theTGeom,myTEntity,theMeshInfo->myDim)); + } + + TTCellInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + const TIntVector& theConnectivities, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()): + TElemInfoBase(theMeshInfo, + theFamilyNums, + theElemNums, + theElemNames) + { + myTEntity = theTEntity; + myTGeom = theTGeom; + myTConn = theTConn; + + TInt aConnDim = GetNbNodes(myTGeom); + myNbElem = theConnectivities.size() / aConnDim; + myConn.resize(myNbElem*GetNbConn(myTGeom,myTEntity,myMeshInfo->myDim)); + for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){ + for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){ + SetConn(anElemId,anConnId,theConnectivities[anElemId*aConnDim+anConnId]); + } + } + + } + + virtual TInt GetConnDim() const { + return GetNbConn(myTGeom,myTEntity,myMeshInfo->myDim); + } + + }; + + + //--------------------------------------------------------------- + template + struct TTFieldInfo: + virtual TFieldInfo, + virtual TTNameInfo + { + typedef TTNameInfo TNameInfoBase; + + TTFieldInfo(const PMeshInfo& theMeshInfo, const PFieldInfo& theInfo): + TNameInfoBase(theInfo->GetName()) + { + myMeshInfo = theMeshInfo; + + myNbComp = theInfo->GetNbComp(); + myCompNames.resize(myNbComp*nPNOM+1); + for(TInt anId = 0; anId < myNbComp; anId++){ + SetCompName(anId,theInfo->GetCompName(anId)); + } + + myUnitNames.resize(myNbComp*nPNOM+1); + for(TInt anId = 0; anId < myNbComp; anId++){ + SetUnitName(anId,theInfo->GetUnitName(anId)); + } + + myType = theInfo->GetType(); + + myIsLocal = theInfo->GetIsLocal(); + myNbRef = theInfo->GetNbRef(); + } + + TTFieldInfo(const PMeshInfo& theMeshInfo, + TInt theNbComp = 0, + ETypeChamp theType = eFLOAT64, + const std::string& theValue = "", + EBooleen theIsLocal = eVRAI, + TInt theNbRef = 1): + TNameInfoBase(theValue) + { + myMeshInfo = theMeshInfo; + + myNbComp = theNbComp; + myCompNames.resize(theNbComp*nPNOM+1); + myUnitNames.resize(theNbComp*nPNOM+1); + + myType = theType; + + myIsLocal = theIsLocal; + myNbRef = theNbRef; + } + + virtual std::string GetCompName(TInt theId) const { + return GetString(theId,nPNOM,myCompNames); + } + + virtual void SetCompName(TInt theId, const std::string& theValue){ + SetString(theId,nPNOM,myCompNames,theValue); + } + + virtual std::string GetUnitName(TInt theId) const { + return GetString(theId,nPNOM,myUnitNames); + } + + virtual void SetUnitName(TInt theId, const std::string& theValue){ + SetString(theId,nPNOM,myUnitNames,theValue); + } + }; + + + //--------------------------------------------------------------- + template + struct TTTimeStampInfo: virtual TTimeStampInfo + { + TTTimeStampInfo(const PFieldInfo& theFieldInfo, const PTimeStampInfo& theInfo) + { + myFieldInfo = theFieldInfo; + + myEntity = theInfo->GetEntity(); + myGeom = theInfo->GetGeom(); + + myNbGauss = theInfo->GetNbGauss(); + myNumDt = theInfo->GetNumDt(); + myNumOrd = theInfo->GetNumOrd(); + myDt = theInfo->GetDt(); + + myUnitDt.resize(nPNOM+1); + SetUnitDt(theInfo->GetUnitDt()); + + myGaussName.resize(nNOM+1); + SetGaussName(theInfo->GetGaussName()); + } + + TTTimeStampInfo(const PFieldInfo& theFieldInfo, + EEntiteMaillage theEntity, + const TGeom& theGeom, + TInt theNbGauss = 0, + TInt theNumDt = 0, + TInt theNumOrd = 0, + TFloat theDt = 0, + const std::string& theUnitDt = "", + const std::string& theGaussName = "") + { + myFieldInfo = theFieldInfo; + + myEntity = theEntity; + myGeom = theGeom; + + myNbGauss = theNbGauss; + myNumDt = theNumDt; + myNumOrd = theNumDt; + myDt = theDt; + + myUnitDt.resize(nPNOM+1); + SetUnitDt(theUnitDt); + + myGaussName.resize(nNOM+1); + SetGaussName(theGaussName); + } + + virtual std::string GetGaussName() const { + return GetString(0,nNOM,myGaussName); + } + + virtual void SetGaussName(const std::string& theValue){ + SetString(0,nNOM,myGaussName,theValue); + } + + virtual std::string GetUnitDt() const { + return GetString(0,nPNOM,myUnitDt); + } + + virtual void SetUnitDt(const std::string& theValue){ + SetString(0,nPNOM,myUnitDt,theValue); + } + }; + + + //--------------------------------------------------------------- + template + struct TTTimeStampVal: virtual TTimeStampVal + { + TTTimeStampVal(const PTimeStampInfo& theTimeStampInfo, const PTimeStampVal& theInfo) + { + myTimeStampInfo = theTimeStampInfo; + + myPflMode = theInfo->GetPflMode(); + + myPflName.resize(nNOM+1); + SetPflName(theInfo->GetPflName()); + + TInt aNbComp = theTimeStampInfo->GetFieldInfo()->GetNbComp(); + const TGeom& aTGeom = theTimeStampInfo->GetGeom(); + TInt aNbGauss = theTimeStampInfo->GetNbGauss(); + TGeom::const_iterator anIter = aTGeom.begin(); + for(; anIter != aTGeom.end(); anIter++){ + const EGeometrieElement& aGeom = anIter->first; + TInt aNbElem = anIter->second; + TInt aSize = aNbElem*aNbComp*aNbGauss; + TValue& aValue = myMeshValue[aGeom]; + aValue.resize(aSize); + for(TInt anElemId = 0; anElemId < aNbElem; anElemId++){ + for(TInt aCompId = 0; aCompId < aNbComp; aCompId++){ + for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){ + SetVal(aGeom,anElemId,aCompId,theInfo->GetVal(aGeom,anElemId,aCompId,aGaussId),aGaussId); + } + } + } + } + } + + TTTimeStampVal(const PTimeStampInfo& theTimeStampInfo, + const std::string& thePflName = "", + EModeProfil thePflMode = eCOMPACT) + { + myTimeStampInfo = theTimeStampInfo; + + myPflMode = thePflMode; + + myPflName.resize(nNOM+1); + SetPflName(thePflName); + + TInt aNbComp = theTimeStampInfo->myFieldInfo->myNbComp; + TInt aNbGauss = theTimeStampInfo->myNbGauss; + const TGeom& aTGeom = theTimeStampInfo->myGeom; + TGeom::const_iterator anIter = aTGeom.begin(); + for(; anIter != aTGeom.end(); anIter++){ + const EGeometrieElement& aGeom = anIter->first; + TInt aNb = anIter->second*aNbComp*aNbGauss; + myMeshValue[aGeom].resize(aNb); + } + } + + virtual std::string GetPflName() const { + return GetString(0,nNOM,myPflName); + } + + virtual void SetPflName(const std::string& theValue){ + SetString(0,nNOM,myPflName,theValue); + } + }; + +} + +#endif diff --git a/src/MEDWrapper/Base/MED_TWrapper.hxx b/src/MEDWrapper/Base/MED_TWrapper.hxx new file mode 100644 index 000000000..e07ae30f8 --- /dev/null +++ b/src/MEDWrapper/Base/MED_TWrapper.hxx @@ -0,0 +1,426 @@ +// +// +// 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 : +// Author : +// Module : +// $Header$ + +#ifndef MED_TWrapper_HeaderFile +#define MED_TWrapper_HeaderFile + +#include "MED_TStructures.hxx" +#include "MED_Wrapper.hxx" + +namespace MED{ + + template + class TTWrapper: public TWrapper{ + public: + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + PMeshInfo + CrMeshInfo(TInt theDim = 0, + const std::string& theValue = "", + EMaillage theType = eNON_STRUCTURE, + const std::string& theDesc = "") + { + return PMeshInfo(new TTMeshInfo + (theDim, + theValue, + theType, + theDesc)); + } + + virtual + PMeshInfo + CrMeshInfo(const PMeshInfo& theInfo) + { + return PMeshInfo(new TTMeshInfo(theInfo)); + } + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + PFamilyInfo + CrFamilyInfo(const PMeshInfo& theMeshInfo, + TInt theNbGroup = 0, + TInt theNbAttr = 0, + TInt theId = 0, + const std::string& theValue = "") + { + return PFamilyInfo(new TTFamilyInfo + (theMeshInfo, + theNbGroup, + theNbAttr, + theId, + theValue)); + } + + virtual + PFamilyInfo + CrFamilyInfo(const PMeshInfo& theMeshInfo, + const std::string& theValue, + TInt theId, + const MED::TStringSet& theGroupNames, + const MED::TStringVector& theAttrDescs = MED::TStringVector(), + const MED::TIntVector& theAttrIds = MED::TIntVector(), + const MED::TIntVector& theAttrVals = MED::TIntVector()) + { + return PFamilyInfo(new TTFamilyInfo + (theMeshInfo, + theValue, + theId, + theGroupNames, + theAttrDescs, + theAttrIds, + theAttrVals)); + } + + virtual + PFamilyInfo + CrFamilyInfo(const PMeshInfo& theMeshInfo, + const PFamilyInfo& theInfo) + { + return PFamilyInfo(new TTFamilyInfo + (theMeshInfo, + theInfo)); + } + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + PNodeInfo + CrNodeInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + ERepere theSystem = eCART, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + return PNodeInfo(new TTNodeInfo + (theMeshInfo, + theNbElem, + theSystem, + theIsElemNum, + theIsElemNames)); + } + + virtual + PNodeInfo + CrNodeInfo(const PMeshInfo& theMeshInfo, + ERepere theSystem, + const TFloatVector& theNodeCoords, + const TStringVector& theCoordNames, + const TStringVector& theCoordUnits, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()) + { + return PNodeInfo(new TTNodeInfo + (theMeshInfo, + theSystem, + theNodeCoords, + theCoordNames, + theCoordUnits, + theFamilyNums, + theElemNums, + theElemNames)); + } + + virtual + PNodeInfo + CrNodeInfo(const PMeshInfo& theMeshInfo, + const PNodeInfo& theInfo) + { + return PNodeInfo(new TTNodeInfo + (theMeshInfo, + theInfo)); + } + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + PPolygoneInfo + CrPolygoneInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + TInt theNbConn, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + return PPolygoneInfo(new TTPolygoneInfo + (theMeshInfo, + theNbElem, + theNbConn, + theTEntity, + theTGeom, + theTConn, + theIsElemNum, + theIsElemNames)); + } + + virtual + PPolygoneInfo + CrPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + const TIntVector& theConnectivities, + const TIntVector& theIndexes, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()) + { + return PPolygoneInfo(new TTPolygoneInfo + (theMeshInfo, + theTEntity, + theTGeom, + theTConn, + theConnectivities, + theIndexes, + theFamilyNums, + theElemNums, + theElemNames)); + } + + virtual + PPolygoneInfo + CrPolygoneInfo(const PMeshInfo& theMeshInfo, + const PPolygoneInfo& theInfo) + { + return PPolygoneInfo(new TTPolygoneInfo + (theMeshInfo, + theInfo)); + } + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + PPolyedreInfo + CrPolyedreInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + TInt theNbConn, + TInt theNbFaces, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + return PPolyedreInfo(new TTPolyedreInfo + (theMeshInfo, + theNbElem, + theNbConn, + theNbFaces, + theTEntity, + theTGeom, + theTConn, + theIsElemNum, + theIsElemNames)); + } + + virtual + PPolyedreInfo + CrPolyedreInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + const TIntVector& theConnectivities, + const TIntVector& theFacesIndexes, + const TIntVector& theIndexes, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()) + { + return PPolyedreInfo(new TTPolyedreInfo + (theMeshInfo, + theTEntity, + theTGeom, + theTConn, + theConnectivities, + theFacesIndexes, + theIndexes, + theFamilyNums, + theElemNums, + theElemNames)); + } + + virtual + PPolyedreInfo + CrPolyedreInfo(const PMeshInfo& theMeshInfo, + const PPolyedreInfo& theInfo) + { + return PPolyedreInfo(new TTPolyedreInfo + (theMeshInfo, + theInfo)); + } + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + PCellInfo + CrCellInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + return PCellInfo(new TTCellInfo + (theMeshInfo, + theNbElem, + theTEntity, + theTGeom, + theTConn, + theIsElemNum, + theIsElemNames)); + } + + virtual + PCellInfo + CrCellInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + const TIntVector& theConnectivities, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()) + { + return PCellInfo(new TTCellInfo + (theMeshInfo, + theTEntity, + theTGeom, + theTConn, + theConnectivities, + theFamilyNums, + theElemNums, + theElemNames)); + } + + virtual + PCellInfo + CrCellInfo(const PMeshInfo& theMeshInfo, + const PCellInfo& theInfo) + { + return PCellInfo(new TTCellInfo + (theMeshInfo, + theInfo)); + } + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + PFieldInfo + CrFieldInfo(const PMeshInfo& theMeshInfo, + TInt theNbComp = 0, + ETypeChamp theType = eFLOAT64, + const std::string& theValue = "", + EBooleen theIsLocal = eVRAI, + TInt theNbRef = 1) + { + return PFieldInfo(new TTFieldInfo + (theMeshInfo, + theNbComp, + theType, + theValue, + theIsLocal, + theNbRef)); + } + + virtual + PFieldInfo + CrFieldInfo(const PMeshInfo& theMeshInfo, + const PFieldInfo& theInfo) + { + return PFieldInfo(new TTFieldInfo + (theMeshInfo, + theInfo)); + } + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + PTimeStampInfo + CrTimeStampInfo(const PFieldInfo& theFieldInfo, + EEntiteMaillage theEntity, + const TGeom& theGeom, + TInt theNbGauss = 0, + TInt theNumDt = 0, + TInt theNumOrd = 0, + TFloat theDt = 0, + const std::string& theUnitDt = "", + const std::string& theGaussName = "") + { + return PTimeStampInfo(new TTTimeStampInfo + (theFieldInfo, + theEntity, + theGeom, + theNbGauss, + theNumDt, + theNumOrd, + theDt, + theUnitDt, + theGaussName)); + } + + virtual + PTimeStampInfo + CrTimeStampInfo(const PFieldInfo& theFieldInfo, + const PTimeStampInfo& theInfo) + { + return PTimeStampInfo(new TTTimeStampInfo + (theFieldInfo, + theInfo)); + } + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + PTimeStampVal + CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo, + const std::string& thePflName = "", + EModeProfil thePflMode = eCOMPACT) + { + return PTimeStampVal(new TTTimeStampVal + (theTimeStampInfo, + thePflName, + thePflMode)); + } + + virtual + PTimeStampVal + CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo, + const PTimeStampVal& theInfo) + { + return PTimeStampVal(new TTTimeStampVal + (theTimeStampInfo, + theInfo)); + } + + }; + +} + + +#endif diff --git a/src/MEDWrapper/Base/MED_Utilities.cxx b/src/MEDWrapper/Base/MED_Utilities.cxx new file mode 100644 index 000000000..5c53a4df2 --- /dev/null +++ b/src/MEDWrapper/Base/MED_Utilities.cxx @@ -0,0 +1,106 @@ +// +// +// 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 : +// Author : +// Module : +// $Header$ + +#include "MED_Utilities.hxx" +#include "MED_Common.hxx" + +using namespace std; + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + + +int MED::PrefixPrinter::myCounter = 0; + +MED::PrefixPrinter::PrefixPrinter(bool theIsActive): + myIsActive(theIsActive) +{ + if(myIsActive) + myCounter++; + MSG(MYDEBUG,"MED::PrefixPrinter::PrefixPrinter(...)- "< +#include +#include +#include + + +namespace MED{ + using namespace std; + class PrefixPrinter{ + static int myCounter; + bool myIsActive; + public: + PrefixPrinter(bool theIsActive = true); + ~PrefixPrinter(); + + static string GetPrefix(); + }; +}; + +//#define _DEBUG_ +#ifdef _DEBUG_ + #define MSG(deb,msg) if(deb) std::cout<GetName(); + INITMSG(MYDEBUG,"GetPFamilyInfo - aFamilyName = '"<GetGroupName(iGroup); + INITMSG(MYDEBUG,"aGroupName = '"<myDim; + TInt aNbElem = anInfo->GetNbElem(); + INITMSG(MYDEBUG,"GetPNodeInfo - aCoords: "<myCoord; + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + for(TInt iDim = 0, anId = iElem*aDim; iDim < aDim; iDim++, anId++){ + ADDMSG(MYVALUEDEBUG,aCoord[anId]<<","); + } + ADDMSG(MYVALUEDEBUG," "); + } + ADDMSG(MYDEBUG,endl); + + BEGMSG(MYDEBUG,"GetPNodeInfo - GetFamNum: "); + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetFamNum(iElem)<<", "); + } + ADDMSG(MYDEBUG,endl); + + if(anInfo->IsElemNum()){ + BEGMSG(MYDEBUG,"GetPNodeInfo - GetElemNum: "); + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetElemNum(iElem)<<", "); + } + ADDMSG(MYDEBUG,endl); + } + + ADDMSG(MYDEBUG,endl); +#endif + + return anInfo; + } + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + PPolygoneInfo TWrapper::GetPPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConn) + { + TInt aNbElem = GetNbPolygones(*theMeshInfo,theEntity,theGeom,theConn); + TInt aNbConn = GetNbPolygoneConn(*theMeshInfo,theEntity,theGeom,theConn); + PPolygoneInfo anInfo = CrPolygoneInfo(theMeshInfo,aNbElem,aNbConn,theEntity,theGeom,theConn); + GetPolygoneInfo(*anInfo); + +#ifdef _DEBUG_ + TElemNum aConn = anInfo->GetConnectivite(); + TElemNum aIndex = anInfo->GetIndex(); + TInt aNbIndex = aIndex.size(); + TInt aIndex0 = aIndex[0]; + INITMSG(MYDEBUG,"theGeom = "<GetConnectivite(); + TElemNum aFacesIndex = anInfo->GetFacesIndex(); + TElemNum aIndex = anInfo->GetIndex(); + + TInt aNbIndex = aIndex.size(); + + for (int aNp = 0; aNp < aNbIndex-1;aNp++){ + if (anInfo->IsElemNames()) + ADDMSG(MYDEBUG,anInfo->GetElemName(aNp)<GetConnDim(); + INITMSG(MYDEBUG,"GetPCellInfo - theEntity = "<GetConn(iElem,iConn)<<","); + } + ADDMSG(MYVALUEDEBUG," "); + } + ADDMSG(MYDEBUG,endl); + + BEGMSG(MYDEBUG,"GetPCellInfo - GetFamNum: "); + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetFamNum(iElem)<<", "); + } + ADDMSG(MYDEBUG,endl); + + if(anInfo->IsElemNum()){ + BEGMSG(MYDEBUG,"GetPCellInfo - GetElemNum: "); + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetElemNum(iElem)<<", "); + } + ADDMSG(MYDEBUG,endl); + } + ADDMSG(MYDEBUG,endl); +#endif + + return anInfo; + } + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + PFieldInfo TWrapper::GetPFieldInfo(const PMeshInfo& theMeshInfo, + TInt theId, + TErr* theErr) + { + TInt aNbComp = GetNbComp(theId); + PFieldInfo anInfo = CrFieldInfo(theMeshInfo,aNbComp); + GetFieldInfo(theId,*anInfo,theErr); + +#ifdef _DEBUG_ + INITMSG(MYDEBUG, + "GetPFieldInfo - aNbComp = "<GetNbGauss(); + PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo(); + TInt aNbComp = aFieldInfo->GetNbComp(); + INITMSG(MYDEBUG,"GetPTimeStampVal\n"); + TMeshValue& aMeshValue = anInfo->myMeshValue; + TMeshValue::const_iterator aMeshValueIter = aMeshValue.begin(); + for(; aMeshValueIter != aMeshValue.end(); aMeshValueIter++){ + const EGeometrieElement& aGeom = aMeshValueIter->first; + const TValue& aValue = aMeshValueIter->second; + TInt iElemEnd = aValue.size() / aNbComp / aNbGauss; + INITMSG(MYDEBUG,"aGeom = "< + +extern "C"{ +#include +} + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +namespace MED{ + + EVersion GetVersionId(const std::string& theFileName) + { + EVersion aVersion = eVUnknown; + char* aFileName = const_cast(theFileName.c_str()); + med_idt aFid = MEDouvrir(aFileName,MED_LECTURE); + MSG(MYDEBUG,"GetVersionId - theFileName = '"<GetNbMeshes(); + INITMSG(MYDEBUG,"GetNbMeshes() = "<GetPMeshInfo(iMesh); + INITMSG(MYDEBUG,"aMeshInfo->GetName() = "<GetName()<GetEntityInfo(aMeshInfo); + + TElemGroup aElemGroup = GetElemsByEntity(aMed,aMeshInfo,aEntityInfo); + + TFamilyGroup aFamilyGroup = GetFamilies(aMed,aMeshInfo); + + TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,aElemGroup,aFamilyGroup); + + TGroupInfo aGroupInfo = GetFamiliesByGroup(aFamilyGroup); + + TTimeStampGroup aTimeStampGroup = GetFieldsByEntity(aMed,aMeshInfo,aEntityInfo); + + TFieldGroup aFieldGroup = GetFieldsByEntity(aTimeStampGroup); + + TFieldGroup::const_iterator aFieldGroupIter = aFieldGroup.begin(); + for(; aFieldGroupIter != aFieldGroup.end(); aFieldGroupIter++){ + const TTimeStampGroup& aTTimeStampGroup = aFieldGroupIter->second; + TTimeStampGroup::const_iterator aTTimeStampGroupIter = aTTimeStampGroup.begin(); + for(; aTTimeStampGroupIter != aTTimeStampGroup.end(); aTTimeStampGroupIter++){ + PFieldInfo aFieldInfo = aTTimeStampGroupIter->first; + const TTimeStampSet& aTimeStampSet = aTTimeStampGroupIter->second; + TTimeStampSet::const_iterator aTTimeStampSetIter = aTimeStampSet.begin(); + for(; aTTimeStampSetIter != aTimeStampSet.end(); aTTimeStampSetIter++){ + PTimeStampInfo aTimeStampInfo = *aTTimeStampSetIter; + TErr anErr; + PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStampInfo,&anErr); + } + } + } + + } + } + MSG(MYDEBUG,"OK"); +} + + +void CopyMed(const PWrapper& theMed, + const PWrapper& theMed2, + int theIncr) +{ + TInt aNbMeshes = theMed->GetNbMeshes(); + MSG(MYDEBUG,"aNbMeshes = "<GetPMeshInfo(iMesh+1); + TInt aDim = aMeshInfo->myDim; + aName = aMeshInfo->GetName(); + INITMSG(MYDEBUG,"GetMeshInfo - aName = '"<CrMeshInfo(aMeshInfo); + if(MYWRITEDEBUG){ + aName = aMeshInfo2->GetName(); + + aName[0] += theIncr; + aMeshInfo2->SetName(aName); + theMed2->SetMeshInfo(aMeshInfo2); + BEGMSG(MYDEBUG,"aNbMeshes2 = "<GetNbMeshes()<<"\n"); + } + + TEntityInfo aEntityInfo = theMed->GetEntityInfo(aMeshInfo); + + //continue; + + TInt aNbFields = theMed->GetNbFields(); + MSG(MYDEBUG,"GetNbFields() = "<GetPFieldInfo(aMeshInfo,iField+1); + TInt aNbComp = aFieldInfo->GetNbComp(); + INITMSG(MYDEBUG,"aName = '"<GetName()<<"'; aNbComp = "<CrFieldInfo(aMeshInfo2,aFieldInfo); + + if(MYWRITEDEBUG){ + aName = aFieldInfo->GetName(); + aName[0] += theIncr; + aFieldInfo2->SetName(aName); + theMed2->SetFieldInfo(aFieldInfo2); + } + + EEntiteMaillage anEntity; + TGeom aTGeom; + TInt aNbTimeStamps = + theMed->GetNbTimeStamps(aFieldInfo,aEntityInfo,anEntity,aTGeom); + { + INITMSG(MYDEBUG,"GetNbTimeStamps = "<GetPTimeStampInfo(aFieldInfo,anEntity,aTGeom,iTimeStamp+1); + TInt aNumDt = aTimeStampInfo->GetNumDt(); + TInt aNbGauss = aTimeStampInfo->GetNbGauss(); + INITMSG(MYDEBUG,"aNbGauss = "<CrTimeStampInfo(aFieldInfo2,aTimeStampInfo); + + PTimeStampVal aTimeStampVal = theMed->GetPTimeStampVal(aTimeStampInfo); + + PTimeStampVal aTimeStampVal2 = theMed->CrTimeStampVal(aTimeStampInfo2,aTimeStampVal); + + if(MYWRITEDEBUG) theMed2->SetTimeStamp(aTimeStampVal2); + + TMeshValue& aMeshValue = aTimeStampVal->myMeshValue; + TMeshValue::iterator aMeshValueIter = aMeshValue.begin(); + for(; aMeshValueIter != aMeshValue.end(); aMeshValueIter++){ + EGeometrieElement aGeom = aMeshValueIter->first; + TValue aValue = aMeshValueIter->second; + INITMSG(MYDEBUG,"aGeom = "<GetNbFamilies(aMeshInfo); + MSG(MYDEBUG,"GetNbFamilies() = "<GetPFamilyInfo(aMeshInfo,iFam+1); + TInt aNbGroup = aFamilyInfo->GetNbGroup(); + TInt aNbAttr = aFamilyInfo->GetNbAttr(); + TInt anId = aFamilyInfo->GetId(); + if(anId == 0) + continue; + + aName = aFamilyInfo->GetName(); + INITMSG(MYDEBUG,"aName = '"<CrFamilyInfo(aMeshInfo2,aFamilyInfo); + for(TInt iGroup = 0; iGroup < aNbGroup; iGroup++){ + aName = aFamilyInfo->GetGroupName(iGroup); + INITMSG(MYDEBUG,"aGroupName = '"<SetGroupName(iGroup,aName); + } + + if(MYWRITEDEBUG){ + aName = aFamilyInfo->GetName(); + aName[0] += theIncr; + aFamilyInfo2->SetName(aName); + theMed2->SetFamilyInfo(aFamilyInfo2); + INITMSG(MYDEBUG,"GetNbFamilies = "<GetNbFamilies(aMeshInfo2)<GetPNodeInfo(aMeshInfo); + PNodeInfo aNodeInfo2 = theMed->CrNodeInfo(aMeshInfo2,aNodeInfo); + if(MYWRITEDEBUG) theMed2->SetNodeInfo(aNodeInfo2); + continue; + } + TGeom& aTGeom = anEntityInfoIter->second; + TGeom::iterator anTGeomIter = aTGeom.begin(); + for(; anTGeomIter != aTGeom.end(); anTGeomIter++){ + const EGeometrieElement& aGeom = anTGeomIter->first; + const TInt& aNbElem = anTGeomIter->second; + INITMSG(MYDEBUG,"aGeom = "<GetPPolygoneInfo(aMeshInfo,anEntity,aGeom); + TElemNum aConn = aPolygoneInfo->GetConnectivite(); + TElemNum aIndex = aPolygoneInfo->GetIndex(); + TInt aNbIndex = aIndex.size(); + TInt aIndex0 = aIndex[0]; + for(TInt iElem = 1; iElem < aNbIndex; iElem++){ + for (TInt i = aIndex0; i < aIndex[iElem];i++) + ADDMSG(MYVALUEDEBUG,aConn[i-1]<<","); + ADDMSG(MYDEBUG," "); + aIndex0 = aIndex[iElem]; + } + ADDMSG(MYDEBUG,endl); + INITMSG(MYDEBUG,"Indexes :"); + for(TInt iElem = 0; iElem < aIndex.size(); iElem++){ + ADDMSG(MYVALUEDEBUG,aIndex[iElem]<<","); + } + ADDMSG(MYDEBUG,endl); + PPolygoneInfo aPolygoneInfo2 = theMed->CrPolygoneInfo(aMeshInfo2,aPolygoneInfo); + if(MYWRITEDEBUG) theMed2->SetPolygoneInfo(aPolygoneInfo2); + break; + } + case ePOLYEDRE: + { + PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,anEntity,aGeom); + TElemNum aConn = aPolyedreInfo->GetConnectivite(); + TElemNum aFacesIndex = aPolyedreInfo->GetFacesIndex(); + TElemNum aIndex = aPolyedreInfo->GetIndex(); + + TInt aNbIndex = aIndex.size(); + + for (int aNp = 0; aNp < aNbIndex-1;aNp++){ + if (aPolyedreInfo->IsElemNames()) + ADDMSG(MYDEBUG,aPolyedreInfo->GetElemName(aNp)<CrPolyedreInfo(aMeshInfo2,aPolyedreInfo); + if(MYWRITEDEBUG) theMed2->SetPolyedreInfo(aPolyedreInfo2); + break; + } + default: + PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,anEntity,aGeom); + PCellInfo aCellInfo2 = theMed2->CrCellInfo(aMeshInfo2,aCellInfo); + if(MYWRITEDEBUG) theMed2->SetCellInfo(aCellInfo2); + } + } + } + + } + MSG(MYDEBUG,"OK"); +} + + +void CopyMed(const std::string& theFileName, + const std::string& theFileName2, + MED::EVersion theVersion, + int theNbCopy) +{ + MSG(MYDEBUG,"CopyMed - theFileName = '"< +#include "med_misc.hxx" + +/* + * - Nom de la fonction : _MED1cstring + * - Description : convertit une chaine de caracteres FORTRAN + * en une nouvelle chaine de caracteres C + * dont la longueur est passee en parametre. + * Les caracteres completes sont des blancs + * - Parametres : + * - chaine (IN) : la chaine FORTRAN + * - longueur_reelle (IN) : la longueur de la chaine FORTRAN + * - longueur_fixee (IN) : longueur de la chaine C a construire + * - Resultat : la nouvelle chaine C en cas de succes, NULL sinon + */ + +namespace med_2_1{ + +char * +_MED1cstring(char *chaine,int longueur_reelle,int longueur_fixee) +{ + char *nouvelle; + int i; + + if (longueur_reelle > longueur_fixee) + return NULL; + + if ((nouvelle = (char *) malloc(sizeof(char)*(longueur_fixee+1))) == NULL) + return NULL; + + for (i=0;i +#include "med_misc.hxx" + +/* + * - Nom de la fonction _MED2cstring + * - Description : convertit une chaine de caracteres FORTRAN en + * nouvelle chaine de caracteres C + * - Parametres : + * - chaine (IN) : la chaine FORTRAN + * - longueur (IN) : longueur de la chaine + * - Resultat : la nouvelle chaine C en cas de succes, NULL sinon + */ + +namespace med_2_1{ + +char * +_MED2cstring(char *chaine, int longueur) +{ + char *nouvelle; + char *temoin; + int long_reelle = longueur; + int i; + + if ( longueur < 0 ) return NULL; + + temoin = chaine+longueur-1; + while (*temoin == ' ' && (temoin != chaine) ) + { + temoin --; + long_reelle--; + } + if ( *temoin == ' ') long_reelle = 0; + + if ((nouvelle = (char *) malloc(sizeof(char)*(long_reelle+1))) == NULL) + return NULL; + + for (i=0;i(myFileName.c_str()); + myFid = MEDouvrir(aFileName,med_mode_acces(theMode)); + } + if(theErr){ + *theErr = TErr(myFid); + INITMSG(MYDEBUG && myFid < 0,"TFile::Open - MED_MODE_ACCES = "<Open(theMode,theErr); + } + + ~TFileWrapper(){ + myFile->Close(); + } + }; + + + //--------------------------------------------------------------- + TVWrapper::TVWrapper(const std::string& theFileName): + myFile(new TFile(theFileName)) + {} + + + TInt TVWrapper::GetNbMeshes(TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECT,theErr); + + if(theErr && *theErr < 0) + return -1; + + return MEDnMaa(myFile->Id()); + } + + + void TVWrapper::GetMeshInfo(TInt theMeshId, + MED::TMeshInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECT,theErr); + + if(theErr && *theErr < 0) + return; + + TErr aRet = MEDmaaInfo(myFile->Id(), + theMeshId, + &theInfo.myName[0], + (med_2_1::med_int *)&theInfo.myDim); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetMeshInfo - MEDmaaInfo(...)"); + } + + + void TVWrapper::SetMeshInfo(const MED::TMeshInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TMeshInfo& anInfo = const_cast(theInfo); + + TErr aRet = MEDmaaCr(myFile->Id(), + &anInfo.myName[0], + anInfo.myDim); + + INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<(theInfo); + return MEDnFam(myFile->Id(), + &anInfo.myName[0], + 0, + MED_FAMILLE); + } + + + TInt TVWrapper::GetNbFamAttr(TInt theFamId, + const MED::TMeshInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECT,theErr); + + if(theErr && *theErr < 0) + return -1; + + MED::TMeshInfo& anInfo = const_cast(theInfo); + return MEDnFam(myFile->Id(), + &anInfo.myName[0], + theFamId, + MED_ATTR); + } + + + TInt TVWrapper::GetNbFamGroup(TInt theFamId, + const MED::TMeshInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECT,theErr); + + if(theErr && *theErr < 0) + return -1; + + MED::TMeshInfo& anInfo = const_cast(theInfo); + return MEDnFam(myFile->Id(), + &anInfo.myName[0], + theFamId, + MED_GROUPE); + } + + + void TVWrapper::GetFamilyInfo(TInt theFamId, + MED::TFamilyInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECT,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + + TErr aRet = MEDfamInfo(myFile->Id(), + &aMeshInfo.myName[0], + theFamId, + &theInfo.myName[0], + (med_2_1::med_int *)&theInfo.myId, + (med_2_1::med_int *)&theInfo.myAttrId[0], + (med_2_1::med_int *)&theInfo.myAttrVal[0], + &theInfo.myAttrDesc[0], + (med_2_1::med_int *)&theInfo.myNbAttr, + &theInfo.myGroupNames[0], + (med_2_1::med_int *)&theInfo.myNbGroup); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetFamilyInfo - MEDfamInfo - "<< + "&aMeshInfo.myName[0] = '"<<&aMeshInfo.myName[0]<<"'; "<< + "theFamId = "<(theMeshInfo); + + TInt aRet = MEDnEntMaa(myFile->Id(), + &aMeshInfo.myName[0], + MED_COOR, + MED_NOEUD, + med_geometrie_element(0), + med_connectivite(0)); + + ADDMSG(MYDEBUG," nbnodes="<Id(), + &aMeshInfo.myName[0], + aMeshInfo.myDim, + &theInfo.myCoord[0], + MED_FULL_INTERLACE, + &aRepere, + &theInfo.myCoordNames[0], + &theInfo.myCoordUnits[0], + &theInfo.myElemNames[0], + &anIsElemNames, + (med_2_1::med_int *)&theInfo.myElemNum[0], + &anIsElemNum, + (med_2_1::med_int *)&theInfo.myFamNum[0], + theInfo.myNbElem); + + ADDMSG(MYDEBUG," myDim="<(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + med_repere& aRepere = (med_repere&)(theInfo.mySystem); + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); + + TErr aRet = MEDnoeudsEcr(myFile->Id(), + &aMeshInfo.myName[0], + aMeshInfo.myDim, + &anInfo.myCoord[0], + MED_FULL_INTERLACE, + aRepere, + &anInfo.myCoordNames[0], + &anInfo.myCoordUnits[0], + &anInfo.myElemNames[0], + anIsElemNames, + (med_2_1::med_int *)&anInfo.myElemNum[0], + anIsElemNum, + (med_2_1::med_int *)&anInfo.myFamNum[0], + anInfo.myNbElem, + MED_REMP); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetNodeInfo - MEDnoeudsEcr(...)"); + } + + + void TVWrapper::SetNodeInfo(const MED::TNodeInfo& theInfo, + TErr* theErr) + { + TErr aRet; + SetNodeInfo(theInfo,eECRI,&aRet); + + if(aRet < 0) + SetNodeInfo(theInfo,eREMP,theErr); + } + + + TEntityInfo TVWrapper::GetEntityInfo(const MED::TMeshInfo& theMeshInfo, + EConnectivite theTConn, + TErr* theErr) + { + TEntityInfo anInfo; + + TFileWrapper aFileWrapper(myFile,eLECT,theErr); + + if(theErr && *theErr < 0) + return anInfo; + + TInt aNbElem = GetNbNodes(theMeshInfo); + if(aNbElem > 0){ + anInfo[eNOEUD][ePOINT1] = aNbElem; + const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet(); + TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin(); + TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end(); + for(; anIter != anIterEnd; anIter++){ + const EEntiteMaillage& anEntity = anIter->first; + const TGeomSet& aGeomSet = anIter->second; + TGeomSet::const_iterator anIter2 = aGeomSet.begin(); + TGeomSet::const_iterator anIterEnd2 = aGeomSet.end(); + for(; anIter2 != anIterEnd2; anIter2++){ + const EGeometrieElement& aGeom = *anIter2; + aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theTConn,theErr); + if(aNbElem > 0) + anInfo[anEntity][aGeom] = aNbElem; + } + } + } + return anInfo; + } + + + TInt TVWrapper::GetNbCells(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECT,theErr); + + if(theErr && *theErr < 0) + return -1; + + MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); + + med_entite_maillage anEntity = med_entite_maillage(theTEntity); + med_geometrie_element aGeom = med_geometrie_element(theTGeom); + med_connectivite aConn = med_connectivite(theTConn); + + return MEDnEntMaa(myFile->Id(), + &aMeshInfo.myName[0], + MED_CONN, + anEntity, + aGeom, + aConn); + } + + + void TVWrapper::GetCellInfo(MED::TCellInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECT,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + TInt aNbElem = theInfo.myElemNum.size(); + + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theInfo.myTGeom); + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); + + TErr aRet = MEDelementsLire(myFile->Id(), + &aMeshInfo.myName[0], + aMeshInfo.myDim, + (med_2_1::med_int *)&theInfo.myConn[0], + MED_FULL_INTERLACE, + &theInfo.myElemNames[0], + &anIsElemNames, + (med_2_1::med_int *)&theInfo.myElemNum[0], + &anIsElemNum, + (med_2_1::med_int *)&theInfo.myFamNum[0], + aNbElem, + anEntity, + aGeom, + aConn); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetCellInfo - MEDelementsLire(...)"); + } + + + void TVWrapper::SetCellInfo(const MED::TCellInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TCellInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theInfo.myTGeom); + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); + + TErr aRet = MEDelementsEcr(myFile->Id(), + &aMeshInfo.myName[0], + aMeshInfo.myDim, + (med_2_1::med_int *)&anInfo.myConn[0], + MED_FULL_INTERLACE, + &anInfo.myElemNames[0], + anIsElemNames, + (med_2_1::med_int *)&anInfo.myElemNum[0], + anIsElemNum, + (med_2_1::med_int *)&anInfo.myFamNum[0], + anInfo.myNbElem, + anEntity, + aGeom, + aConn, + MED_REMP); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetCellInfo - MEDelementsLire(...)"); + } + + + void TVWrapper::SetCellInfo(const MED::TCellInfo& theInfo, + TErr* theErr) + { + TErr aRet; + SetCellInfo(theInfo,eECRI,&aRet); + + if(aRet < 0) + SetCellInfo(theInfo,eREMP,theErr); + } + + + TInt TVWrapper::GetNbFields(TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECT,theErr); + + if(theErr && *theErr < 0) + return -1; + + return MEDnChamp(myFile->Id(),0); + } + + + TInt TVWrapper::GetNbComp(TInt theFieldId, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECT,theErr); + + if(theErr && *theErr < 0) + return -1; + + return MEDnChamp(myFile->Id(),theFieldId); + } + + + void TVWrapper::GetFieldInfo(TInt theFieldId, + MED::TFieldInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECT,theErr); + + if(theErr && *theErr < 0) + return; + + med_type_champ& aType = (med_type_champ&)(theInfo.myType); + + TErr aRet = MEDchampInfo(myFile->Id(), + theFieldId, + &theInfo.myName[0], + &aType, + &theInfo.myCompNames[0], + &theInfo.myUnitNames[0], + theInfo.myNbComp); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetFieldInfo - MEDchampInfo(...)"); + } + + + void TVWrapper::SetFieldInfo(const MED::TFieldInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TFieldInfo& anInfo = const_cast(theInfo); + + med_type_champ& aType = (med_type_champ&)(theInfo.myType); + + TErr aRet = MEDchampCr(myFile->Id(), + &anInfo.myName[0], + aType, + &anInfo.myCompNames[0], + &anInfo.myUnitNames[0], + anInfo.myNbComp); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetFieldInfo - MEDchampCr(...)"); + } + + + void TVWrapper::SetFieldInfo(const MED::TFieldInfo& theInfo, + TErr* theErr) + { + try{ + + TErr aRet; + SetFieldInfo(theInfo,eECRI,&aRet); + + if(aRet < 0) + SetFieldInfo(theInfo,eREMP,theErr); + + }catch(const std::exception& theExc){ + EXCEPTION(runtime_error,"SetFieldInfo(...)"<(theInfo); + TEntityInfo::const_iterator anIter = theEntityInfo.begin(); + for(; anIter != theEntityInfo.end(); anIter++){ + const med_entite_maillage& anEntity = (const med_entite_maillage&)(anIter->first); + const TGeom& aTGeom = anIter->second; + TGeom::const_iterator anGeomIter = aTGeom.begin(); + for(; anGeomIter != aTGeom.end(); anGeomIter++){ + const med_geometrie_element& aGeom = (const med_geometrie_element&)(anGeomIter->first); + aNbTimeStamps = MEDnPasdetemps(myFile->Id(),&anInfo.myName[0],anEntity,aGeom); + if(aNbTimeStamps){ + theEntity = EEntiteMaillage(anEntity); + theGeom[EGeometrieElement(aGeom)] = anGeomIter->second; + } + } + if(aNbTimeStamps) + break; + } + return aNbTimeStamps; + } + + + void TVWrapper::GetTimeStampInfo(TInt theTimeStampId, + MED::TTimeStampInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECT,theErr); + + TGeom& aTGeom = theInfo.myGeom; + + if(theErr){ + if(aTGeom.empty()) + *theErr = -1; + if(*theErr < 0) + return; + }else if(aTGeom.empty()) + EXCEPTION(runtime_error,"GetTimeStampInfo - There is no any cell"); + + MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo; + MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo; + + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myEntity); + + TGeom::iterator anIter = aTGeom.begin(); + med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first); + + TErr aRet = MEDpasdetempsInfo(myFile->Id(), + &aFieldInfo.myName[0], + anEntity, + aGeom, + theTimeStampId, + &aMeshInfo.myName[0], + (med_2_1::med_int *)&theInfo.myNbGauss, + (med_2_1::med_int *)&theInfo.myNumDt, + &theInfo.myUnitDt[0], + &theInfo.myDt, + (med_2_1::med_int *)&theInfo.myNumOrd); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetTimeStampInfo - MEDpasdetempsInfo(...)"); + + static TInt MAX_NB_GAUSS_POINTS = 32; + if(theInfo.myNbGauss <= 0 || theInfo.myNbGauss > MAX_NB_GAUSS_POINTS) + theInfo.myNbGauss = 1; + } + + + void TVWrapper::GetTimeStampVal(MED::TTimeStampVal& theVal, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECT,theErr); + + if(theErr && *theErr < 0) + return; + + TIdt anId = myFile->Id(); + + MED::TTimeStampInfo& aTimeStampInfo = *theVal.myTimeStampInfo; + MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo; + MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo; + + med_entite_maillage& anEntity = (med_entite_maillage&)(aTimeStampInfo.myEntity); + TGeom& aTGeom = aTimeStampInfo.myGeom; + TGeom::iterator anIter = aTGeom.begin(); + for(; anIter != aTGeom.end(); anIter++){ + med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first); + TInt aNbVal = MEDnVal(anId, + &aFieldInfo.myName[0], + anEntity, + aGeom, + aTimeStampInfo.myNumDt, + aTimeStampInfo.myNumOrd); + if(aNbVal <= 0){ + if(theErr){ + *theErr = -1; + return; + } + EXCEPTION(runtime_error,"GetTimeStampInfo - MEDnVal(...) - aNbVal == "<Id(); + + MED::TTimeStampVal& aVal = const_cast(theVal); + MED::TTimeStampInfo& aTimeStampInfo = *aVal.myTimeStampInfo; + MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo; + MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo; + MED::TMeshValue& aMeshValue = aVal.myMeshValue; + + med_entite_maillage& anEntity = (med_entite_maillage&)(aTimeStampInfo.myEntity); + TMeshValue::iterator anIter = aMeshValue.begin(); + for(; anIter != aMeshValue.end(); anIter++){ + med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first); + TValue& aValue = aVal.myMeshValue[EGeometrieElement(aGeom)]; + med_int iEnd = aValue.size(); + med_int aNbVal = iEnd / aFieldInfo.myNbComp; + + switch(aFieldInfo.myType){ + case eFLOAT64: { + std::vector& anArray = aValue; + + aRet = MEDchampEcr(anId, + &aMeshInfo.myName[0], + &aFieldInfo.myName[0], + (unsigned char*)&anArray[0], + MED_FULL_INTERLACE, + aNbVal, + aTimeStampInfo.myNbGauss, + MED_ALL, + &aVal.myPflName[0], + MED_ECRI, + anEntity, + aGeom, + aTimeStampInfo.myNumDt, + &aTimeStampInfo.myUnitDt[0], + aTimeStampInfo.myDt, + aTimeStampInfo.myNumOrd); + break; + } + default: { + vector anArray(iEnd); + for(TInt i = 0; i< iEnd; i++) anArray[i] = TInt(aValue[i]); + + aRet = MEDchampEcr(anId, + &aMeshInfo.myName[0], + &aFieldInfo.myName[0], + (unsigned char*)&anArray[0], + MED_FULL_INTERLACE, + aNbVal, + aTimeStampInfo.myNbGauss, + MED_ALL, + &aVal.myPflName[0], + MED_ECRI, + anEntity, + aGeom, + aTimeStampInfo.myNumDt, + &aTimeStampInfo.myUnitDt[0], + aTimeStampInfo.myDt, + aTimeStampInfo.myNumOrd); + break; + }} + + if(aRet < 0){ + if(theErr){ + *theErr = aRet; + break; + } + EXCEPTION(runtime_error,"SetTimeStamp - MEDchampEcr(...)"); + } + + } + + INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "< TVMeshInfo; + + typedef MED::TTFamilyInfo TVFamilyInfo; + + typedef MED::TTNodeInfo TVNodeInfo; + + typedef MED::TTCellInfo TVCellInfo; + + typedef MED::TTFieldInfo TVFieldInfo; + + typedef MED::TTTimeStampInfo TVTimeStampInfo; + + typedef MED::TTTimeStampVal TVTimeStampVal; + + //--------------------------------------------------------------- + class TFile; + typedef boost::shared_ptr PFile; + + typedef enum {eLECT, eECRI, eREMP} EModeAcces; + + //--------------------------------------------------------------- + class TVWrapper: public MED::TTWrapper + { + TVWrapper(); + TVWrapper(const TVWrapper&); + TVWrapper& operator=(const TVWrapper&); + + public: + TVWrapper(const std::string& theFileName); + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual TInt GetNbMeshes(TErr* theErr = NULL); + + virtual void GetMeshInfo(TInt theMeshId, MED::TMeshInfo&, + TErr* theErr = NULL); + + virtual void SetMeshInfo(const MED::TMeshInfo& theInfo, + TErr* theErr = NULL); + + void SetMeshInfo(const MED::TMeshInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual TInt GetNbFamilies(const MED::TMeshInfo& theMeshInfo, + TErr* theErr = NULL); + virtual TInt GetNbFamAttr(TInt theFamId, + const MED::TMeshInfo& theInfo, + TErr* theErr = NULL); + virtual TInt GetNbFamGroup(TInt theFamId, + const MED::TMeshInfo& theInfo, + TErr* theErr = NULL); + + virtual void GetFamilyInfo(TInt theFamId, + MED::TFamilyInfo& theInfo, + TErr* theErr = NULL); + + virtual void SetFamilyInfo(const MED::TFamilyInfo& theInfo, + TErr* theErr = NULL); + + void SetFamilyInfo(const MED::TFamilyInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual TInt GetNbNodes(const MED::TMeshInfo& theMeshInfo, + TErr* theErr = NULL); + + virtual void GetNodeInfo(MED::TNodeInfo& theInfo, + TErr* theErr = NULL); + + virtual void SetNodeInfo(const MED::TNodeInfo& theInfo, + TErr* theErr = NULL); + + void SetNodeInfo(const MED::TNodeInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual TEntityInfo GetEntityInfo(const MED::TMeshInfo& theMeshInfo, + EConnectivite theTConn = eNOD, + TErr* theErr = NULL); + + virtual TInt GetNbCells(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage, + EGeometrieElement, + EConnectivite theTConn = eNOD, + TErr* theErr = NULL); + + virtual void GetCellInfo(MED::TCellInfo& theInfo, + TErr* theErr = NULL); + + virtual void SetCellInfo(const MED::TCellInfo& theInfo, + TErr* theErr = NULL); + + void SetCellInfo(const MED::TCellInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual TInt GetNbFields(TErr* theErr = NULL); + + virtual TInt GetNbComp(TInt theFieldId, + TErr* theErr = NULL); + + virtual void GetFieldInfo(TInt theFieldId, + MED::TFieldInfo& theInfo, + TErr* theErr = NULL); + + virtual void SetFieldInfo(const MED::TFieldInfo& theInfo, + TErr* theErr = NULL); + + void SetFieldInfo(const MED::TFieldInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual TInt GetNbTimeStamps(const MED::TFieldInfo& theInfo, + const MED::TEntityInfo& theEntityInfo, + EEntiteMaillage& theEntity, + TGeom& theGeom, + TErr* theErr = NULL); + + virtual void GetTimeStampInfo(TInt theTimeStampId, + MED::TTimeStampInfo& theInfo, + TErr* theErr = NULL); + + virtual void GetTimeStampVal(MED::TTimeStampVal& theVal, + TErr* theErr = NULL); + + virtual void SetTimeStamp(const MED::TTimeStampVal& theTimeStampVal, + TErr* theErr = NULL); + + void SetTimeStamp(const MED::TTimeStampVal& theTimeStampVal, + EModeAcces theMode, + TErr* theErr = NULL); + + protected: + PFile myFile; + }; + } +} + +#endif diff --git a/src/MEDWrapper/V2_1/MEDattrFermer.cxx b/src/MEDWrapper/V2_1/MEDattrFermer.cxx new file mode 100644 index 000000000..6a7b708e0 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDattrFermer.cxx @@ -0,0 +1,44 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDattrFermer + * - Description : fermeture de l'acces a l'attribut dont l'ID est passe en + * parametre + * - Parametres : + * - pid (IN) : l'ID de l'objet HDF pere ou placer l'attribut + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDattrFermer(med_idt id) +{ + med_err ret; + + if ((ret = H5Aclose(id)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDattrNumEcrire.cxx b/src/MEDWrapper/V2_1/MEDattrNumEcrire.cxx new file mode 100644 index 000000000..51ae76e11 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDattrNumEcrire.cxx @@ -0,0 +1,107 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDattrNumEcrire + * - Description : ecriture d'un attribut entier + * - Parametres : + * - pere (IN) : l'ID de l'objet HDF pere ou placer l'attribut + * - type (IN) : le type du champ {MED_REEL64,MED_INT} + * - nom (IN) : le nom de l'attribut + * - val (IN) : la valeur de l'attribut + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDattrNumEcrire(med_idt pere,med_type_champ type,char *nom,unsigned char *val, + med_mode_acces mode) +{ + med_idt aid,attr; + med_err ret; + int type_hdf; + + switch(type) + { + case MED_REEL64 : + /* 1) IA32 is LE but due to an (?HDF convertion BUG?) when using H5T_NATIVE_DOUBLE/MED_REEL64? under PCLINUX + the file read under SGI is incorrect + 2) Compaq OSF/1 is LE, since we force SGI64,SUN4SOL2,HP to write double in LE even if they are BE, mips OSF/1 must be BE + REM : Be careful of compatibility between MED files when changing this (med2.2) */ +#if defined(PCLINUX) || defined(OSF1) + type_hdf = H5T_IEEE_F64BE; +#else + type_hdf = H5T_IEEE_F64LE; +#endif + break; + + case MED_INT : +#if defined(IRIX64) || defined(OSF1) + type_hdf = H5T_NATIVE_LONG; +#elif defined(PCLINUX) + /* This explicit convertion avoid a core dump between in HDF&ASTER when reading on SGI + a file written under a PCLINUX system (in founction H5Tconvert), + we don't know yet if it is an HDF bug or an ASTER one */ + /* The problem seems to be in convertion process between INT32LE->INT32BE ? */ + type_hdf = H5T_STD_I32BE; + if ((H5Tconvert(H5T_NATIVE_INT,H5T_STD_I32BE,1,(void *)val,NULL,NULL)) < 0) + return -1; +#else + type_hdf = H5T_NATIVE_INT; +#endif + break; + + default : + return -1; + } + + if ((aid = H5Screate(H5S_SCALAR)) < 0) + return -1; + + if ( ((attr = H5Aopen_name(pere,nom)) > 0) && (mode != MED_REMP) ) + return -1; + else + if ( attr < 0) + if ((attr = H5Acreate(pere,nom,type_hdf,aid,H5P_DEFAULT)) < 0) return -1; + + if ((ret = H5Awrite(attr,type_hdf,val)) < 0) + return -1; + + + if ((ret = H5Sclose(aid)) < 0) + return -1; + if ((ret = H5Aclose(attr)) < 0) + return -1; + +#if defined(PCLINUX) + /* This explicit convertion cancel the previous on which avoid a mysterious bug between HDF&ASTER when reading + a file written under a PCLINUX system, we don't know yet if it is an HDF bug or an ASTER one */ + if (type == MED_INT) + if ((H5Tconvert(H5T_STD_I32BE,H5T_NATIVE_INT,1,(void *)val,NULL,NULL)) < 0) + return -1; +#endif + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDattrNumLire.cxx b/src/MEDWrapper/V2_1/MEDattrNumLire.cxx new file mode 100644 index 000000000..12299c5a7 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDattrNumLire.cxx @@ -0,0 +1,77 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDattrNumLire + * - Description : lecture d'un attribut entier + * - Parametres : + * - pere (IN) : l'ID de l'objet HDF pere ou placer l'attribut + * - type (IN) : le type du champ {MED_REEL64,MED_INT} + * - nom (IN) : le nom de l'attribut + * - val (OUT) : la valeur de l'attribut + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDattrNumLire(med_idt pere,med_type_champ type,char *nom,unsigned char *val) +{ + med_idt attid; + med_err ret; + int type_hdf; + + if ((attid = H5Aopen_name(pere,nom)) < 0) + return -1; + + switch(type) + { + case MED_REEL64 : +#if defined(PCLINUX) || defined(OSF1) + type_hdf = H5T_IEEE_F64BE; +#else + type_hdf = H5T_IEEE_F64LE; +#endif + break; + + case MED_INT : +#if defined(IRIX64) || defined(OSF1) + type_hdf = H5T_NATIVE_LONG; +#else + type_hdf = H5T_NATIVE_INT; +#endif + break; + + default : + return -1; + } + + if ((ret = H5Aread(attid,type_hdf,val)) < 0) + return -1; + + if ((ret = H5Aclose(attid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDattrOuvrir.cxx b/src/MEDWrapper/V2_1/MEDattrOuvrir.cxx new file mode 100644 index 000000000..bcf6be527 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDattrOuvrir.cxx @@ -0,0 +1,45 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDattrOuvrir + * - Description : acces a l'attribut dont le nom est passe en parametre + * - Parametres : + * - pid (IN) : l'ID de l'objet HDF pere ou placer l'attribut + * - nom (IN) : le nom de l'attribut + * - Resultat : ID de l'attribut en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_idt +_MEDattrOuvrir(med_idt pid,char * nom) +{ + med_idt aid; + + if ((aid = H5Aopen_name(pid,nom)) < 0) + return -1; + + return aid; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDattrStringEcrire.cxx b/src/MEDWrapper/V2_1/MEDattrStringEcrire.cxx new file mode 100644 index 000000000..128336808 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDattrStringEcrire.cxx @@ -0,0 +1,68 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDattrStringEcrire + * - Description : ecriture d'un attribut chaine de caracteres + * - Parametres : + * - pere (IN) : l'ID de l'objet HDF pere ou placer l'attribut + * - nom (IN) : le nom de l'attribut + * - longueur (IN) : strlen(val) + * - val (IN) : la valeur de l'attribut + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDattrStringEcrire(med_idt pere,char *nom,int longueur,char *val, med_mode_acces mode) +{ + med_idt aid,attr, datatype; + med_err ret; + + if ((aid = H5Screate(H5S_SCALAR)) < 0) + return -1; + if((datatype = H5Tcopy(H5T_C_S1)) < 0) + return -1; + if((ret = H5Tset_size(datatype,longueur+1)) < 0) + return -1; + + if ( ((attr = H5Aopen_name(pere,nom)) > 0) + && (mode != MED_REMP) ) + return -1; + else + if ( attr < 0) + if ((attr = H5Acreate(pere,nom,datatype,aid,H5P_DEFAULT)) < 0) return -1; + + if ((ret = H5Awrite(attr, datatype, val)) < 0) + return -1; + + if ((ret = H5Sclose(aid)) < 0) + return -1; + if ((ret = H5Tclose(datatype)) < 0) + return -1; + if ((ret = H5Aclose(attr)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDattrStringLire.cxx b/src/MEDWrapper/V2_1/MEDattrStringLire.cxx new file mode 100644 index 000000000..764b9e2f6 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDattrStringLire.cxx @@ -0,0 +1,57 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDattrStringLire + * - Description : lecture d'un attribut chaine de caracteres + * - Parametres : + * - pere (IN) : l'ID de l'objet HDF pere ou placer l'attribut + * - nom (IN) : le nom de l'attribut + * - longueur (IN) : strlen(val) + * - val (OUT) : la valeur de l'attribut + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDattrStringLire(med_idt pere,char *nom,int longueur,char *val) +{ + med_idt attid,datatype; + med_err ret; + + if ((datatype = H5Tcopy(H5T_C_S1)) < 0) + return -1; + if ((ret = H5Tset_size(datatype,longueur+1)) < 0) + return -1; + if ((attid = H5Aopen_name(pere,nom)) < 0) + return -1; + if ((ret = H5Aread(attid,datatype,val)) < 0) + return -1; + if ((ret = H5Tclose(datatype)) < 0) + return -1; + if ((ret = H5Aclose(attid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDbodyFittedEcr.cxx b/src/MEDWrapper/V2_1/MEDbodyFittedEcr.cxx new file mode 100644 index 000000000..c7d84f46a --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDbodyFittedEcr.cxx @@ -0,0 +1,142 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med_outils.hxx" +#include "med.hxx" + +#if defined(IRIX64) +#define MED_INTEGER MED_INT64 +#else +#define MED_INTEGER MED_INT32 +#endif + +namespace med_2_1{ + +med_err +MEDbodyFittedEcr(med_idt fid, char *maa, med_int mdim, med_float *coo, med_int *nbr, med_mode_switch mode_coo, + med_repere repere, char *nomcoo, char *unicoo, med_int *fam, med_int nnoeuds, med_mode_acces mode ) +{ + /* ecriture des coordonnees */ + med_idt maaid, noeid, dataset; + med_size dimd[1]; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + med_int type_rep_int; + int d; + char *ds; + + /* On inhibe le gestionnaire d'erreur HDF */ + _MEDmodeErreurVerrouiller(); + + /* Si le maillage n'existe pas => erreur */ + strcpy(chemin, MED_MAA); + strcat(chemin, maa); + if ((maaid = _MEDdatagroupOuvrir(fid, chemin)) < 0) { + return(-1); + }; + + /* Si le Data Group "NOE" n'existe pas on le cree */ + if ((noeid = _MEDdatagroupOuvrir(maaid, MED_NOM_NOE)) < 0) { + if ((noeid = _MEDdatagroupCreer(maaid, MED_NOM_NOE)) < 0) { + return(-1); + }; + }; + + /* Creation du Data Set "BOF" */ + dimd[0] = nnoeuds*mdim; + if (_MEDdatasetNumEcrire(noeid, MED_NOM_BOF, MED_REEL64, mode_coo, mdim, MED_ALL, MED_NOPF, 0, 0, dimd, (unsigned char*)coo, mode) < 0) { + return(-1); + }; + + /* On re-ouvre le Data Set "BOF" pour y placer des attributs */ + if ((dataset = _MEDdatasetOuvrir(noeid, MED_NOM_BOF)) < 0) { + return(-1); + }; + + /* Attribut NBR (nombre de noeuds) */ + if (_MEDattrEntierEcrire(dataset, MED_NOM_NBR, &nnoeuds, mode) < 0) { + return(-1); + }; + + /* L'attribut "REP" */ + type_rep_int = (med_int)repere; + if (_MEDattrEntierEcrire(dataset, MED_NOM_REP, &type_rep_int, mode) < 0) { + return(-1); + }; + + /* Attribut "NOM" */ + if (_MEDattrStringEcrire(dataset, MED_NOM_NOM, mdim*MED_TAILLE_PNOM, nomcoo, mode) < 0) { + return(-1); + }; + + /* Attribut "UNI" */ + if (_MEDattrStringEcrire(dataset, MED_NOM_UNI, mdim*MED_TAILLE_PNOM, unicoo, mode) < 0) { + return(-1); + }; + + if (_MEDdatasetFermer(dataset) < 0) return(-1); + + dimd[0] = 1; + for (d=0; d erreur */ + strcpy(chemin, MED_MAA); + strcat(chemin, maa); + maaid = _MEDdatagroupOuvrir(fid, chemin); + if (maaid < 0) return(-1); + + /* Si le Data Group "NOE" n'existe pas => erreur */ + noeid = _MEDdatagroupOuvrir(maaid, MED_NOM_NOE); + if (noeid < 0) return(-1); + + /* Lecture du Data Set "BOF" */ + if (_MEDdatasetNumLire(noeid, MED_NOM_BOF, MED_REEL64, mode_coo, mdim, MED_ALL, MED_NOPF, 0, 1, (unsigned char*)coo) < 0) { + return(-1); + }; + + /* On re-ouvre le Data Set "BOF" pour y lire des attributs */ + dataset = _MEDdatasetOuvrir(noeid, MED_NOM_BOF); + if (dataset < 0) return(-1); + + /* L'attribut "REP" */ + if (_MEDattrEntierLire(dataset, MED_NOM_REP, &type_rep_int) < 0) { + return(-1); + } else { + *repere = (med_repere)type_rep_int; + }; + + /* Attribut "NOM" */ + if (_MEDattrStringLire(dataset, MED_NOM_NOM, mdim*MED_TAILLE_PNOM, nomcoo) < 0) { + return(-1); + }; + + /* Attribut "UNI" */ + if (_MEDattrStringLire(dataset, MED_NOM_UNI, mdim*MED_TAILLE_PNOM, unicoo) < 0) { + return(-1); + }; + + /* lecture des numeros de familles */ + if (MEDfamLire(fid, maa, fam, nnoeuds, MED_NOEUD, MED_POINT1) < 0) { + return(-1); + }; + + /* On ferme tout */ + if (_MEDdatasetFermer(dataset) < 0) { + return(-1); + }; + if (_MEDdatagroupFermer(noeid) < 0) { + return(-1); + }; + if (_MEDdatagroupFermer(maaid) < 0) { + return(-1); + }; + return(0); +} + +} diff --git a/src/MEDWrapper/V2_1/MEDchampCr.cxx b/src/MEDWrapper/V2_1/MEDchampCr.cxx new file mode 100644 index 000000000..13fe5520a --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDchampCr.cxx @@ -0,0 +1,83 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDchampCr(med_idt fid, char *champ, med_type_champ type, char *comp, + char *unit,med_int ncomp) +{ + med_err ret = 0; + med_idt root,gid; + char chemin[MED_TAILLE_CHA+1]; + med_size dimd[1]; + med_int _type = (med_int) type; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le Data Group "/CHA/" n'existe pas, on le cree + */ + strncpy(chemin,MED_CHA,MED_TAILLE_CHA-1); + chemin[MED_TAILLE_CHA-1] = '\0'; + if ((root = _MEDdatagroupOuvrir(fid,chemin)) < 0) + if ((root = _MEDdatagroupCreer(fid,chemin)) < 0) + return -1; + + /* + * Si le Data Group cha n'existe pas, on le cree + * Sinon => erreur + */ + if ((gid = _MEDdatagroupOuvrir(root,champ)) >= 0) + return -1; + if ((gid = _MEDdatagroupCreer(root,champ)) < 0) + return -1; + + /* + * Les infos sur les composants du champ + */ + if ((ret = _MEDattrEntierEcrire(gid,MED_NOM_NCO,&ncomp,MED_REMP)) < 0) + return -1; + if ((ret = _MEDattrEntierEcrire(gid,MED_NOM_TYP,&_type,MED_REMP)) < 0) + return -1; + if ((ret = _MEDattrStringEcrire(gid,MED_NOM_NOM,MED_TAILLE_PNOM*ncomp,comp,MED_REMP)) < 0) + return -1; + if ((ret = _MEDattrStringEcrire(gid,MED_NOM_UNI,MED_TAILLE_PNOM*ncomp,unit,MED_REMP)) < 0) + return -1; + + /* + * On ferme tout + */ + if ((ret = _MEDdatagroupFermer(gid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(root)) < 0) + return -1; + + return ret; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDchampEcr.cxx b/src/MEDWrapper/V2_1/MEDchampEcr.cxx new file mode 100644 index 000000000..14f5090bc --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDchampEcr.cxx @@ -0,0 +1,246 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +/* + * - Nom de la fonction : MEDchampEcr + * - Description : ecriture d'un Champ Résultat + * - Parametres : + * - fid (IN) : ID du fichier HDF courant + * - maa (IN) : le nom du maillage sur lequel s'applique le champ + * - cha (IN) : le nom du champ + * - val (IN) : valeurs du champ à stocker + * - interlace(IN) : entrelacement utilisé en mémoire {MED_FULL_INTERLACE,MED_NO_INTERLACE} + * - nbelem (IN) : nombre d'éléments (prend en compte le nbre + * de points de Gauss (c'est demandé à l'utilisateur ds la doc) mais pas le nbre de composantes) + * - ngauss (IN) : nbre de point de gauss utilisé (MED_NOPG si aucun) + * - numco (IN) : n° de la composante à stocker (MED_ALL si toutes) + * - profil (IN) : nom du profil utilisé (MED_NOPFL si inutilisé) + * - mode (IN) : mode d'ecriture MED (MED_ECRI | MED_REMP) + * - type_ent (IN) : entité concerné par le champ {MED_NOEUD,MED_ARETE,MED_FACE,MED_MAILLE} + * - type_geo (IN) : type géométrique de l'entité concerné {MED_POINT,MED_SEG2 ......} + * - numdt (IN) : n° du pas de temps (MED_NOPDT si aucun) + * - dt_unit (IN) : chaine de taille MED_NOMP indiquant l'unité du champ + * - dt (IN) : valeur du pas de temps + * - numo (IN) : n° d'ordre utilisé MED_NONOR si inutile + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +MEDchampEcr(med_idt fid, char *maa, char *cha,unsigned char *val,med_mode_switch interlace,med_int nbelem,med_int ngauss, + med_int numco, char * profil, med_mode_acces mode, med_entite_maillage type_ent, + med_geometrie_element type_geo, med_int numdt,char * dt_unit, med_float dt, med_int numo) +{ + med_err ret; + med_idt chid,datagroup1,datagroup2; + med_int ncomp, chtype, i, locnumdt,pfluse; + char pflname [MED_TAILLE_NOM+1]; + char maillage[MED_TAILLE_NOM+1]; + char nomdatagroup1[2*MED_TAILLE_NOM_ENTITE+2],nomdatagroup2[2*MED_MAX_PARA+1]; + char tmp1[MED_TAILLE_NOM_ENTITE+1]; + med_size dimd[1],psize; + med_int *pfltabtmp=0; + med_ssize *pfltab=0; + char chemin[MED_TAILLE_CHA+MED_TAILLE_NOM+1]; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + + /* + * Si le Data Group cha n'existe pas => erreur + */ + strcpy(chemin,MED_CHA); + strcat(chemin,cha); + if ((chid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * Creation du datagroup de niveau 1 [.] + */ + + if ((ret = _MEDnomEntite(nomdatagroup1,type_ent)) < 0) + return -1; + if ((type_ent != MED_NOEUD)) + { + if ((ret = _MEDnomGeometrie(tmp1,type_geo)) < 0) + return -1; + strcat(nomdatagroup1,"."); + strcat(nomdatagroup1,tmp1); + } + datagroup1 = 0; + if ( (datagroup1 = _MEDdatagroupOuvrir(chid,nomdatagroup1)) < 0) + if ((datagroup1 = _MEDdatagroupCreer(chid,nomdatagroup1)) < 0) + return -1; + + /* Creation du datagroup de niveau 2 . */ + if ( numdt == MED_NOPDT) locnumdt = MED_NOPDT; else locnumdt = numdt; + sprintf(nomdatagroup2,"%*li%*li",MED_MAX_PARA,(long ) locnumdt,MED_MAX_PARA,(long ) numo); + + + /*Cree ou ouvre (en mode MED_REMP) le datagroup nomdatagroup2 */ + datagroup2 = 0; + if (((datagroup2 = _MEDdatagroupOuvrir(datagroup1,nomdatagroup2)) > 0) + && (mode != MED_REMP)) + return -1; + else + if (datagroup2 < 0) + if ((datagroup2 = _MEDdatagroupCreer(datagroup1,nomdatagroup2)) < 0) + return -1; + + /*Cree ou ouvre (en mode MED_REMP) l'attribut MED_NOM_NDT */ + if ((ret = _MEDattrEntierEcrire(datagroup2,MED_NOM_NDT,&numdt,mode)) < 0) + return -1; + + /*Cree ou ouvre (en mode MED_REMP) l'attribut MED_NOM_PDT */ + if ((ret = _MEDattrFloatEcrire(datagroup2,MED_NOM_PDT,&dt,mode)) < 0) + return -1; + + /*Cree ou ouvre (en mode MED_REMP) l'attribut MED_NOM_NOR */ + if ((ret = _MEDattrEntierEcrire(datagroup2,MED_NOM_NOR,&numo,mode)) < 0) + return -1; + + /*Cree ou ouvre (en mode MED_REMP) l'attribut MED_NOM_NBR */ + if ((ret = _MEDattrEntierEcrire(datagroup2,MED_NOM_NBR,&nbelem,mode)) < 0) + return -1; + + /*Cree ou ouvre (en mode MED_REMP) l'attribut MED_MAA */ + /* rem : Aucune verification de l'existence du maillage */ + strncpy(maillage,maa,MED_TAILLE_NOM); + maillage[MED_TAILLE_NOM]='\0'; + if ((ret = _MEDattrStringEcrire(datagroup2,MED_NOM_MAI,MED_TAILLE_NOM,maillage,mode)) < 0) + return -1; + + /*Cree ou ouvre (en mode MED_REMP) l'attribut MED_NOM_PFL */ + pfluse = 0; + if ( strlen(profil) == 0) /* idem MED_NOPFL*/ + strncpy(pflname,MED_NOPFLi,MED_TAILLE_NOM+1); + else { + strncpy(pflname,profil,MED_TAILLE_NOM); + pflname[MED_TAILLE_NOM]='\0'; + pfluse = 1; + } + if ((ret = _MEDattrStringEcrire(datagroup2,MED_NOM_PFL,MED_TAILLE_NOM,pflname,mode)) < 0) + return -1; + + /*Cree ou ouvre (en mode MED_REMP) l'attribut MED_NOM_UNI */ + if ( strlen(dt_unit) == 0) { + if ((ret = _MEDattrStringEcrire(datagroup2,MED_NOM_UNI,MED_TAILLE_PNOM," ",mode)) < 0) + return -1; + } else + if ((ret = _MEDattrStringEcrire(datagroup2,MED_NOM_UNI,MED_TAILLE_PNOM,dt_unit,mode)) < 0) + return -1; + + + /* Cree ou ouvre (en mode MED_REMP) l'attribut MED_NOM_NGAU */ + /* Ecriture du nombre de pts de gauss propre au [.] */ + /* On n'utilise pas ngauss=MED_NOPG mais ngauss=1 si aucun pt de gauss */ + if ((ret = _MEDattrEntierEcrire(datagroup2,MED_NOM_NGA,&ngauss,mode)) < 0) + return -1; + + /*Lecture de l'attribut MED_NOM_NCO */ + if ((ret = _MEDattrEntierLire(chid,MED_NOM_NCO,&ncomp)) < 0) + return -1; + + /*Determination de la taille dimd[0] du dataset à stocker*/ + dimd[0] = nbelem*ncomp; + + /* Gestion des profils*/ + if ( pfluse ) { + + if ( ( i = MEDnValProfil(fid,pflname) ) < 0 ) + return -1; + else + psize = i; + + pfltabtmp = (med_int *) malloc (sizeof(med_int)*psize); + pfltab = (med_ssize *) malloc (sizeof(med_ssize)*psize); + if ((ret = MEDprofilLire(fid,pfltabtmp,pflname)) < 0) + return -1; + for (i=0;i erreur + */ + strcat(chemin,champ); + if ((gid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + + /* + * La liste des attributs + */ + if ((ret = _MEDattrEntierLire(gid,MED_NOM_TYP,(med_int*) type)) < 0) + return -1; + if ((ret = _MEDattrStringLire(gid,MED_NOM_NOM,ncomp*MED_TAILLE_PNOM, + comp)) < 0) + return -1; + if ((ret = _MEDattrStringLire(gid,MED_NOM_UNI,ncomp*MED_TAILLE_PNOM, + unit)) < 0) + return -1; + + /* + * On ferme tout + */ + if ((ret = _MEDdatagroupFermer(gid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDchampLire.cxx b/src/MEDWrapper/V2_1/MEDchampLire.cxx new file mode 100644 index 000000000..ad21a6840 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDchampLire.cxx @@ -0,0 +1,194 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + + /*La taille de val allouée par l'utilisateur doit prendre en compte le nbre de points de gauss et le nbre de composantes*/ + +namespace med_2_1{ + +med_err +MEDchampLire(med_idt fid,char *maa, char *cha, unsigned char *val,med_mode_switch interlace,med_int numco, + char *profil,med_entite_maillage type_ent, med_geometrie_element type_geo, + med_int numdt, med_int numo) + /* VERIFIER LA POSSIBILITE DE RELIRE L'UNITE DE PAS DE TEMPS (DS CHAMPINFO) */ +{ + med_err ret; + med_idt chid, datagroup1, datagroup2; + med_int ncomp, chtype, ngauss, i, locnumdt, pfluse; + char nomdatagroup1[2*MED_TAILLE_NOM_ENTITE+2],nomdatagroup2[2*MED_MAX_PARA+1]; + char tmp1[MED_TAILLE_NOM_ENTITE+1], pfltmp[MED_TAILLE_NOM+1]; + char chemin[MED_TAILLE_CHA+MED_TAILLE_NOM+1]; + med_size psize; + med_int *pfltabtmp=0; + med_ssize *pfltab=0; + char maatmp[MED_TAILLE_NOM+1]; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le Data Group cha n'existe pas => erreur + */ + strcpy(chemin,MED_CHA); + strcat(chemin,cha); + if ((chid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * Si le Data Group de niveau 1 [.] n'existe pas => erreur + */ + if ((ret = _MEDnomEntite(nomdatagroup1,type_ent)) < 0) + return -1; + if ((type_ent != MED_NOEUD)) + { + if ((ret = _MEDnomGeometrie(tmp1,type_geo)) < 0) + return -1; + strcat(nomdatagroup1,"."); + strcat(nomdatagroup1,tmp1); + } + datagroup1 = 0; + if ( (datagroup1 = _MEDdatagroupOuvrir(chid,nomdatagroup1)) < 0 ) + return -1; + + /* + * Si le Data Group de niveau 2 . n'existe pas => erreur + */ + if ( numdt == MED_NOPDT) locnumdt = MED_NOPDT; else locnumdt = numdt; + sprintf(nomdatagroup2,"%*li%*li",MED_MAX_PARA,(long ) locnumdt,MED_MAX_PARA,(long ) numo); + + datagroup2 = 0; + if ( (datagroup2 = _MEDdatagroupOuvrir(datagroup1,nomdatagroup2)) < 0) + return -1; + + /* Lecture du nbre de composantes du champ */ + + if ((ret = _MEDattrEntierLire(chid,MED_NOM_NCO,&ncomp)) < 0) + return -1; + + /* Gestion des profils*/ + + /* + * Lire le profil demandé + */ + + if ((ret = _MEDattrStringLire(datagroup2,MED_NOM_PFL,MED_TAILLE_NOM,pfltmp)) < 0) + return -1; + + if ( pfluse = (strcmp(pfltmp,MED_NOPFLi) && strcmp(pfltmp,"")) ) /* le test "" pour des raisons de compatibilité */ + { + strcpy(profil,pfltmp); + if ( (i = MEDnValProfil(fid,profil)) < 0 ) + return -1; + else + psize = i; + + pfltabtmp = (med_int *) malloc (sizeof(med_int)*psize); + pfltab = (med_ssize *) malloc (sizeof(med_ssize)*psize); + if ((ret = MEDprofilLire(fid,pfltabtmp,profil)) < 0) + return -1; + for (i=0;i[.] pour simplifier la relecture */ + if ( (ret = _MEDattrEntierLire(datagroup2,MED_NOM_NGA,&ngauss)) < 0 ) + return -1; + + /* + * Lecture du champ + */ + + if ((ret = _MEDattrEntierLire(chid,MED_NOM_TYP,&chtype)) < 0) + return -1; + + switch(chtype) + { + case MED_REEL64 : + if ((ret = _MEDdatasetNumLire(datagroup2,MED_NOM_CO,MED_REEL64, + interlace,ncomp,numco, + psize,pfltab,ngauss,val))< 0) + return -1; + break; + + case MED_INT32 : +#if defined(IRIX64)||defined(OSF1) + if ((ret = _MEDdatasetNumLire(datagroup2,MED_NOM_CO,MED_INT64, + interlace,ncomp,numco, + psize,pfltab,ngauss,val))< 0) + return -1; +#else + if ((ret = _MEDdatasetNumLire(datagroup2,MED_NOM_CO,MED_INT32, + interlace,ncomp,numco, + psize, pfltab,ngauss,val))< 0) + return -1; +#endif + break; + + case MED_INT64 : +#if defined(IRIX64)||defined(OSF1) + if ((ret = _MEDdatasetNumLire(datagroup2,MED_NOM_CO,MED_INT64, + interlace,ncomp,numco, + psize,pfltab,ngauss,val))< 0) + return -1; +#else + return -1; +#endif + break; + + default : + return -1; + } + + /* + * On ferme tout + */ + if ( pfluse ) { free(pfltab); free(pfltabtmp);} + + if ((ret = _MEDdatagroupFermer(datagroup2)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(datagroup1)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(chid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDconnEcr.cxx b/src/MEDWrapper/V2_1/MEDconnEcr.cxx new file mode 100644 index 000000000..a8395b5c2 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDconnEcr.cxx @@ -0,0 +1,142 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +extern int mode_interlace; + +namespace med_2_1{ + +med_err +MEDconnEcr(med_idt fid,char *maa, med_int mdim, med_int *connectivite,med_mode_switch mode_switch, + med_int nbre,med_mode_acces mode,med_entite_maillage type_ent, + med_geometrie_element type_geo,med_connectivite type_conn) +{ + med_idt maaid, entid, geoid, dataset; + med_err ret; + med_size dimd[1]; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + char nom_ent[MED_TAILLE_NOM_ENTITE+1]; + char nom_geo[MED_TAILLE_NOM_ENTITE+1]; + char nom_dataset[MED_TAILLE_NOM_ENTITE+1]; + int dim, nnoe, ndes; + int nsup = 0; + int taille; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * On met a jour le nom du Data Group representant + * le type des entites + */ + if ((ret = _MEDnomEntite(nom_ent,type_ent)) < 0) + return -1; + /* + * Si le Data Group des entites n'existe pas on le cree + */ + /*EF Gerer le mode */ + if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0) + if ((entid = _MEDdatagroupCreer(maaid,nom_ent)) < 0) + return -1; + + /* + * On cree s'il n'existe pas le Data Group du type geometrique + */ + /*EF Gerer le mode */ + if ((ret = _MEDnomGeometrie(nom_geo,type_geo)) < 0) + return -1; + if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0) + if ((geoid = _MEDdatagroupCreer(entid,nom_geo)) < 0) + return -1; + + /* + * On regarde si le Data Set existe et on le cree sinon + */ + if ((ret=_MEDparametresGeometrie(type_ent,type_geo,&dim,&nnoe,&ndes))<0) + return -1; + if (mdim == 2 || mdim == 3) + if (type_ent == MED_MAILLE && dim == 1) + nsup = 1; + if (mdim == 3) + if (type_ent == MED_MAILLE && dim == 2) + nsup = 1; + switch(type_conn) + { + case MED_NOD : + strcpy(nom_dataset,MED_NOM_NOD); + taille = nsup + nnoe; + break; + + case MED_DESC : + strcpy(nom_dataset,MED_NOM_DES); + taille = nsup + ndes; + break; + + default : + return -1; + } + dimd[0] = nbre*taille; +#if defined(IRIX64)||defined(OSF1) + if ((ret = _MEDdatasetNumEcrire(geoid,nom_dataset,MED_INT64,mode_switch,(med_size)taille,MED_ALL,MED_NOPF,0,MED_NOPG,dimd, + (unsigned char*) connectivite,mode)) < 0) + return -1; +#else + if ((ret = _MEDdatasetNumEcrire(geoid,nom_dataset,MED_INT32,mode_switch,(med_size)taille,MED_ALL,MED_NOPF,0,MED_NOPG,dimd, + (unsigned char*) connectivite,mode)) < 0) + return -1; +#endif + + /* + * Attribut NBR (nombre de noeuds ou d'elements) + */ + if ((dataset = _MEDdatasetOuvrir(geoid,nom_dataset)) < 0) + return -1; + if ((ret = _MEDattrEntierEcrire(dataset,MED_NOM_NBR,&nbre,mode)) < 0) + return -1; + + /* + * On ferme tout + */ + if ((ret = _MEDdatasetFermer(dataset)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(geoid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(entid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDconnLire.cxx b/src/MEDWrapper/V2_1/MEDconnLire.cxx new file mode 100644 index 000000000..9e6c29f48 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDconnLire.cxx @@ -0,0 +1,149 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +extern int mode_interlace; + +namespace med_2_1{ + +med_err +MEDconnLire(med_idt fid,char *maa,med_int mdim,med_int *connectivite,med_mode_switch mode_switch, + med_int * pfltabtmp, med_size psizetmp, + med_entite_maillage type_ent, med_geometrie_element type_geo,med_connectivite type_conn) +{ + med_idt maaid,entid,geoid; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + char nom_ent[MED_TAILLE_NOM_ENTITE+1]; + char nom_geo[MED_TAILLE_NOM_ENTITE+1]; + char nom_dataset[MED_TAILLE_NOM_ENTITE+1]; + med_ssize * pfltab; + med_size psize; + int dim,nnoe,ndes; + int nsup = 0; + int taille; + int i,j; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * On met a jour le nom du Data Group representant + * le type des entites + */ + if ((ret = _MEDnomEntite(nom_ent,type_ent)) < 0) + return -1; + /* + * Si le Data Group des entites n'existe pas => erreur + */ + if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0) + return -1; + + /* + * si le Data Group du type geometrique n'existe pas => erreur + */ + if ((ret = _MEDnomGeometrie(nom_geo,type_geo)) < 0) + return -1; + if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0) + return -1; + + /* + * Si le Data Set de la connectivite n'existe pas => erreur + * Si oui => on le lit + */ + if ((ret=_MEDparametresGeometrie(type_ent,type_geo,&dim,&nnoe,&ndes))<0) + return -1; + if (mdim == 2 || mdim == 3) + if (type_ent == MED_MAILLE && dim == 1) + nsup = 1; + if (mdim == 3) + if (type_ent == MED_MAILLE && dim == 2) + nsup = 1; + + + psize = psizetmp; + switch(type_conn) + { + case MED_NOD : + strcpy(nom_dataset,MED_NOM_NOD); + taille = nsup + nnoe; + break; + + case MED_DESC : + strcpy(nom_dataset,MED_NOM_DES); + taille = nsup + ndes; + if ( psizetmp != MED_NOPF ) { + psize = psizetmp; + pfltab = (med_ssize *) malloc (sizeof(med_ssize)*psize); + for (i=0;i +#include + +namespace med_2_1{ + +med_err +MEDcoordEcr(med_idt fid, char *maa, med_int mdim, med_float *coo, + med_mode_switch mode_coo,med_int n, + med_mode_acces mode, med_repere type_rep, char *nom, char *unit) +{ + med_idt maaid, noeid, dataset; + med_err ret; + med_size dimd[1]; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + med_int type_rep_int; + /* + * On inhibe le gestionnaire d'erreur HDF + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * Si le Data Group "NOE" n'existe pas + * on le cree + */ + /* EF : A faire : gerer le mode MED_REMP*/ + if ((noeid = _MEDdatagroupOuvrir(maaid,MED_NOM_NOE)) < 0) + if ((noeid = _MEDdatagroupCreer(maaid,MED_NOM_NOE)) < 0) + return -1; + + /* + * Creation du Data Set "COO" + */ + dimd[0] = n*mdim; + if ((ret = _MEDdatasetNumEcrire(noeid,MED_NOM_COO,MED_REEL64,mode_coo,mdim,MED_ALL,MED_NOPF,0,MED_NOPG,dimd, + (unsigned char*) coo,mode)) < 0) + return -1; + + /* + * On re-ouvre le Data Set "COO" pour y placer des attributs + */ + if ((dataset = _MEDdatasetOuvrir(noeid,MED_NOM_COO)) < 0) + return -1; + + /* + * Attribut NBR (nombre de noeuds) + */ + if ((ret = _MEDattrEntierEcrire(dataset,MED_NOM_NBR,&n,mode)) < 0) + return -1; + + /* + * L'attribut "REP" + */ + type_rep_int = (med_int) type_rep; + if ((ret = _MEDattrEntierEcrire(dataset,MED_NOM_REP,&type_rep_int,mode)) < 0) + return -1; + + /* + * Attribut "NOM" + */ + if ((ret = _MEDattrStringEcrire(dataset,MED_NOM_NOM,mdim*MED_TAILLE_PNOM,nom,mode)) < 0) + return -1; + + /* + * Attribut "UNI" + */ + if ((ret = _MEDattrStringEcrire(dataset,MED_NOM_UNI,mdim*MED_TAILLE_PNOM,unit,mode)) < 0) + return -1; + + /* + * On ferme tout + */ + if ((ret = _MEDdatasetFermer(dataset)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(noeid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDcoordLire.cxx b/src/MEDWrapper/V2_1/MEDcoordLire.cxx new file mode 100644 index 000000000..1335f1a1b --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDcoordLire.cxx @@ -0,0 +1,125 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med_outils.hxx" +#include "med.hxx" + +#include +#include + +extern int mode_interlace; + +namespace med_2_1{ + +med_err +MEDcoordLire(med_idt fid, char *maa, med_int mdim, med_float *coo, + med_mode_switch mode_coo,med_int numco, + med_int * pfltabtmp, med_size psize, med_repere *type_rep, char *nom, char *unit) +{ + med_idt maaid, noeid, dataset; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + int i,j; + med_float *new_coo; + med_int type_rep_int; + med_ssize * pfltab; + + /* + * On inhibe le gestionnaire d'erreur + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + * Sinon on recupere sa dimension au passage + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * Si le Data Group "NOE" n'existe pas => erreur + */ + if ((noeid = _MEDdatagroupOuvrir(maaid,MED_NOM_NOE)) < 0) + return -1; + + /* + * Convertion de med_int en med_ssize + */ + if ( psize != MED_NOPF ) { + pfltab = (med_ssize *) malloc (sizeof(med_ssize)*psize); + for (i=0;i +#include "med_misc.hxx" + +/* + * - Nom de la fonction _MEDcstringFree + * - Description : libere la chaine de caracteres creee par + * les routines _MEDXcstring + * - Parametres : + * - chaine (IN/OUT) : la chaine de caracteres a detruire + * - Resultat : 0 si succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDcstringFree(char *chaine) +{ + + free(chaine); + return 0; + +} + +} diff --git a/src/MEDWrapper/V2_1/MEDdatagroupCreer.cxx b/src/MEDWrapper/V2_1/MEDdatagroupCreer.cxx new file mode 100644 index 000000000..4b9170479 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDdatagroupCreer.cxx @@ -0,0 +1,45 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDdatagroupCreer + * - Description : creation et ouverture d'un Datagroup HDF + * - Parametres : + * - pid (IN) : l'ID de l'objet pere + * - nom (IN) : le nom de l'objet fils + * - Resultat : l'ID du fils en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_idt +_MEDdatagroupCreer(med_idt pid, char *nom) +{ + med_idt id; + + if ((id = H5Gcreate(pid,nom,0)) < 0) + return -1; + + return id; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDdatagroupFermer.cxx b/src/MEDWrapper/V2_1/MEDdatagroupFermer.cxx new file mode 100644 index 000000000..b48ea41c9 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDdatagroupFermer.cxx @@ -0,0 +1,44 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDdatagroupFermer + * - Description : fermeture d'un datagroup HDF + * - Parametres : + * - id (IN) : l'ID du datagroup + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDdatagroupFermer(med_idt id) +{ + med_err ret; + + if ((ret = H5Gclose(id)) < 0) + return -1; + else + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDdatagroupOuvrir.cxx b/src/MEDWrapper/V2_1/MEDdatagroupOuvrir.cxx new file mode 100644 index 000000000..89cdbe4f7 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDdatagroupOuvrir.cxx @@ -0,0 +1,45 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDdatagroupOuvrir + * - Description : ouverture d'un datagroup HDF + * - Parametres : + * - pid (IN) : l'ID de l'objet pere + * - nom (IN) : le nom de l'objet fils + * - Resultat : l'ID du fils en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_idt +_MEDdatagroupOuvrir(med_idt pid, char *nom) +{ + med_idt id; + + if ((id = H5Gopen(pid,nom)) < 0) + return -1; + + return id; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDdatasetFermer.cxx b/src/MEDWrapper/V2_1/MEDdatasetFermer.cxx new file mode 100644 index 000000000..7694e052e --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDdatasetFermer.cxx @@ -0,0 +1,43 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDdatasetFermer + * - Description : fermeture d'un objet HDF dataset + * - Parametres : + * - id (IN) : l'ID de l'objet HDF dataset + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDdatasetFermer(med_idt id) +{ + med_err ret; + + if ((ret = H5Dclose(id)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDdatasetNumEcrire.cxx b/src/MEDWrapper/V2_1/MEDdatasetNumEcrire.cxx new file mode 100644 index 000000000..846ea206a --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDdatasetNumEcrire.cxx @@ -0,0 +1,374 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" +#include + +/* + * - Nom de la fonction : _MEDdatasetNumEcrire + * - Description : ecriture d'un dataset tableau numerique + * - Parametres : + * - pere (IN) : l'ID de l'objet HDF pere ou placer l'attribut + * - nom (IN) : le nom du dataset + * - type (IN) : type numerique MED { MED_REEL64 , MED_INT32 , MED_INT64 } + * - interlace (IN) : Choix du type d'entrelacement utilisé par l'appelant { MED_FULL_INTERLACE(x1,y1,z1,x2,...)) , MED_NO_INTERLACE(x1,x2,y1,y2,z1,z2) } + * - nbdim (IN) : Dimension des éléments + * - fixdim (IN) : MED_ALL ou n° de la dimension a enregistrer + * - psize (IN) : Taille du profil à utiliser, MED_NOPF si pas de profil + * (référence les élements, cette taille ne prend pas en compte le nombre de pts de gauss ni la dimension ) + * - pfltab (IN) : Tableau contenant les n° déléments à traiter (1....oo) + * - pflmod (IN) : PARAMETRE A AJOUTER : Indique comment lire les informations en mémoire { MED_COMPACT, MED_GLOBALE }. + * - ngauss (IN) : Nombre de points de GAUSS par élément + * - size (IN) : Taille du tableau de valeurs + * (référence tous les élements, cette taille prend en compte le nombre de pts de gauss et la dimension ) + * - val (IN) : valeurs du tableau + * - mode (IN) : mode d'ecriture MED (MED_ECRI | MED_REMP) + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDdatasetNumEcrire(med_idt pere,char *nom, med_type_champ type, + med_mode_switch interlace, med_size nbdim, med_size fixdim, + med_size psize, med_ssize * pfltab, med_int ngauss, + med_size *size, unsigned char *val, med_mode_acces mode) +{ + med_idt dataset, dataspace = 0, memspace = 0; + med_ssize start_mem[1],start_data[1],*pflmem,*pfldsk; + med_size stride[1],count[1],pcount[1],pflsize[1]; + med_err ret; + int i,j,index,type_hdf; + int dim, firstdim, dimutil, lastdim ; + med_mode_profil pflmod; + + /* Verify fixdim is between [0, nbdim] ( 0 is MED_ALL ) */ + if ( ( fixdim < 0 ) || ( fixdim > nbdim ) ) + return -1; + + /* block pflmod to MED_COMPACT (until med2.2) */ + pflmod = MED_COMPACT; + + switch(type) + { + case MED_REEL64 : + /* 1) IA32 is LE but due to an (?HDF convertion BUG?) when using H5T_NATIVE_DOUBLE/MED_REEL64? under PCLINUX + the file read under SGI is incorrect + 2) Compaq OSF/1 is LE, since we force SGI64,SUN4SOL2,HP to write double in LE even if they are BE, mips OSF/1 must be BE + REM : Be careful of compatibility between MED files when changing this (med2.2) */ +#if defined(PCLINUX) || defined(OSF1) + type_hdf = H5T_IEEE_F64BE; +#else + type_hdf = H5T_IEEE_F64LE; +#endif + break; + + case MED_INT32 : +#if defined(PCLINUX) + type_hdf = H5T_STD_I32BE; + if ((H5Tconvert(H5T_NATIVE_INT,H5T_STD_I32BE,(hsize_t)*size,(void *)val,NULL,NULL)) < 0) + return -1; +#else + type_hdf = H5T_NATIVE_INT; +#endif + break; + + case MED_INT64 : + type_hdf = H5T_NATIVE_LONG; + break; + + default : + return -1; + } + + + if ((dataset = H5Dopen(pere,nom)) < 0) + { + /* Whatever the size of the profil is we create a dataset with the size of the value array */ + /* Then if we used the MED_REMP mode we can append a new dimension to a previous one in the dataset */ + /* When we'll use the compression mode, the space used by unused values would be easily compressed */ + + if ((dataspace = H5Screate_simple(1,size,NULL)) < 0) + return -1; + if ((dataset = H5Dcreate(pere,nom,type_hdf,dataspace, + H5P_DEFAULT)) < 0) + return -1; + } + else + if (mode != MED_REMP) + { + H5Dclose(dataset); + return -1; + } + else + if ((dataspace = H5Dget_space(dataset)) <0) + return -1; + + + switch(interlace) + { /* switch Interlace */ + case MED_FULL_INTERLACE : + + /*Initialisation des indices de boucle du traitement de l'entrelacement en fonction de la dimension fixee*/ + if ( fixdim != MED_ALL) + { + firstdim = fixdim-1; + lastdim = fixdim; + dimutil = 1; + } else { + firstdim = 0; + lastdim = nbdim; + dimutil = nbdim; + } + + count [0] = (*size)/(nbdim); + + + if ( psize == MED_NOPF ) { + + /* Creation d'un data space mémoire de dimension 1, de longeur size, et de longeur maxi size */ + if ( (memspace = H5Screate_simple (1, size, NULL)) <0) + return -1; + + stride[0] = nbdim; + + for (dim=firstdim; dim < lastdim; dim++) { + + start_mem[0] = dim; + if ( (ret = H5Sselect_hyperslab (memspace, H5S_SELECT_SET, start_mem, stride, + count, NULL)) <0) + return -1; + + start_data[0] = dim*count[0]; + if ( (ret = H5Sselect_hyperslab (dataspace, H5S_SELECT_SET, start_data, NULL, + count, NULL)) <0) + return -1; + + if ((ret = H5Dwrite(dataset,type_hdf,memspace,dataspace, + H5P_DEFAULT, val)) < 0) + return -1; + } + + } else { /* psize != MED_NOPF */ + + pflsize [0] = psize*ngauss*nbdim; + pcount [0] = psize*ngauss*dimutil; + pflmem = (med_ssize *) malloc (sizeof(med_ssize)*pcount[0]); + pfldsk = (med_ssize *) malloc (sizeof(med_ssize)*pcount[0]); + + switch(pflmod) + { /* switch pflmod pout FULL_INTERLACE*/ + case MED_GLOBALE : + + /* Creation d'un data space mémoire de dimension 1, de longeur size, et de longeur maxi size */ + if ( (memspace = H5Screate_simple (1, size, NULL)) <0) + return -1; + + for (dim=firstdim; dim < lastdim; dim++) { + + for (i=0; i < psize; i++) /* i balaye les élements du profil */ + for (j=0; j < ngauss; j++) { + index = i*ngauss+j + (dim-firstdim)*(psize*ngauss); + pflmem[index] = (pfltab[i]-1)*ngauss*nbdim + j*nbdim+dim; + pfldsk[index] = dim*count[0] + (pfltab[i]-1)*ngauss+j; + } + } + + if ( (ret = H5Sselect_elements(memspace,H5S_SELECT_SET, pcount[0], (const hssize_t **) pflmem ) ) <0) + return -1; + + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET, pcount[0], (const hssize_t **) pfldsk ) ) <0) + return -1; + + break; + + case MED_COMPACT : + + /* Creation d'un data space mémoire de dimension 1, de la longeur du profil */ + /* La dimension utilisée est ici nbdim, même pour un profil compact on suppose */ + /* que l'utilisateur a toutes les coordonées stockées, même si il en demande qu'une */ + + if ( (memspace = H5Screate_simple (1, pflsize, NULL)) <0) + return -1; + + for (dim=firstdim; dim < lastdim; dim++) { + + for (i=0; i < psize; i++) /* i balaye les élements du profil */ + for (j=0; j < ngauss; j++) { + index = i*ngauss+j + (dim-firstdim)*(psize*ngauss); + pflmem[index] = i*ngauss*nbdim + j*nbdim+dim; + pfldsk[index] = dim*count[0] + (pfltab[i]-1)*ngauss+j; + } + } + + if ( (ret = H5Sselect_elements(memspace,H5S_SELECT_SET, pcount[0], (const hssize_t **) pflmem ) ) <0) + return -1; + + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET, pcount[0], (const hssize_t **) pfldsk ) ) <0) + return -1; + + break; + + default : + return -1; + } + + if ((ret = H5Dwrite(dataset,type_hdf,memspace,dataspace,H5P_DEFAULT, val)) < 0) + return -1; + + free(pflmem); + free(pfldsk); + } + + + break; + + case MED_NO_INTERLACE : + + /*Initialisation des indices de boucle du traitement de l'entrelacement en fonction de la dimension fixee*/ + + count[0] = (*size)/nbdim; + + if ( psize == MED_NOPF ) { + + if ( fixdim != MED_ALL) + start_data[0] = (fixdim-1)*count[0]; + else { + count[0] = *size; + start_data[0] = 0; + }; + + if ( (ret = H5Sselect_hyperslab (dataspace, H5S_SELECT_SET, start_data, NULL, + count, NULL)) <0) + return -1; + + if ((ret = H5Dwrite(dataset,type_hdf,dataspace,dataspace, + H5P_DEFAULT, val)) < 0) + return -1; + + } else { + + if ( fixdim != MED_ALL) + { + firstdim = fixdim-1; + lastdim = fixdim; + dimutil = 1; + } else { + firstdim = 0; + lastdim = nbdim; + dimutil = nbdim; + } + + pflsize [0] = psize*ngauss*nbdim; + pcount [0] = psize*ngauss*dimutil; /* nom pas très coherent avec count !!! A revoir */ + pfldsk = (med_ssize *) malloc(sizeof(med_ssize)*pcount[0]); + + switch(pflmod) + { /*switch plfmod pour NO_INTERLACE */ + case MED_GLOBALE : + + for (dim=firstdim; dim < lastdim; dim++) { + + for (i=0; i < psize; i++) /* i balaye le nbre d'élements du profil */ + for (j=0; j < ngauss; j++) { + index = i*ngauss+j + (dim-firstdim)*(psize*ngauss); + pfldsk[index] = dim*count[0]+(pfltab[i]-1)*ngauss+j; + } + } + + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET,pcount[0], (const hssize_t **) pfldsk ) ) <0) + return -1; + + if ((ret = H5Dwrite(dataset,type_hdf,dataspace,dataspace,H5P_DEFAULT, val)) < 0) + return -1; + + break; + + case MED_COMPACT : + + /* Creation d'un data space mémoire de dimension 1, de la longeur du profil */ + /* La dimension utilisée est ici nbdim, même pour un profil compact on suppose */ + /* que l'utilisateur a toutes les coordonées stockées, même si il en demande qu'une */ + + if ( (memspace = H5Screate_simple (1, pflsize, NULL)) <0) + return -1; + + pflmem = (med_ssize *) malloc (sizeof(med_ssize)*pcount[0]); + + /* Le profil COMPACT est contigüe, mais il est possible que l'on selectionne uniquemenent une dimension*/ + + for (dim=firstdim; dim < lastdim; dim++) { + + for (i=0; i < psize; i++) /* i balaye le nbre d'élements du profil */ + for (j=0; j < ngauss; j++) { + index = i*ngauss+j + (dim-firstdim)*(psize*ngauss); + pflmem[index] = dim*(psize*ngauss) + (pfltab[i]-1)*ngauss+j; + pfldsk[index] = dim*count[0] + (pfltab[i]-1)*ngauss+j; + } + } + + if ( (ret = H5Sselect_elements(memspace ,H5S_SELECT_SET,pcount[0], (const hssize_t **) pflmem ) ) <0) + return -1; + + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET,pcount[0], (const hssize_t **) pfldsk ) ) <0) + return -1; + + if ((ret = H5Dwrite(dataset,type_hdf,memspace,dataspace,H5P_DEFAULT, val)) < 0) + return -1; + + free(pflmem); + + break; + + default : + return -1; + + } + + free(pfldsk); + + }; + + break; + + default : + return -1; + } + + + if (memspace) + if ((ret = H5Sclose(memspace)) < 0) + return -1; + + if ((ret = H5Sclose(dataspace)) < 0) + return -1; + + if ((ret = H5Dclose(dataset)) < 0) + return -1; + +#if defined(PCLINUX) + if (type == MED_INT32) + if ((H5Tconvert(H5T_STD_I32BE,H5T_NATIVE_INT,(hsize_t)*size,(void *)val,NULL,NULL)) < 0) + return -1; +#endif + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDdatasetNumLire.cxx b/src/MEDWrapper/V2_1/MEDdatasetNumLire.cxx new file mode 100644 index 000000000..8eef19f6c --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDdatasetNumLire.cxx @@ -0,0 +1,350 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" +#include + +/* + * - Nom de la fonction : _MEDdatasetNumLire + * - Description : lecture d'un dataset tableau numerique + * - Parametres : + * - pere (IN) : l'ID de l'objet HDF pere ou placer l'attribut + * - nom (IN) : le nom du dataset + * - type (IN) : type numerique MED + * - interlace (IN) : Choix du type d'entrelacement demandé par l'appelant { MED_FULL_INTERLACE(x1,y1,z1,x2,...)) , MED_NO_INTERLACE(x1,x2,y1,y2,z1,z2) } + * - nbdim (IN) : Dimension des éléments + * - fixdim (IN) : MED_ALL ou n° de la dimension a enregistrer à partir de 1..oo + * - psize (IN) : Taille du profil à utiliser, MED_NOPF si pas de profil + * - pfltab (IN) : Tableau contenant les n° déléments à traiter (1....oo) + * - pflmod (IN) : PARAMETRE A AJOUTER : Indique comment lire les informations en mémoire { MED_COMPACT, MED_GLOBALE }. + * - ngauss (IN) : Nombre de points de GAUSS par élément + * - val (OUT) : valeurs du tableau + * - Resultat : 0 en cas de succes, -1 sinon + * Equivalent à l'ancienne routine si .....,MED_NO_INTERLACE,1,MED_ALL,MED_NOPF,0,1 (peu importe),.... + */ + +namespace med_2_1{ + +med_err +_MEDdatasetNumLire(med_idt pere,char *nom,med_type_champ type, + med_mode_switch interlace, med_size nbdim, med_size fixdim, + med_size psize, med_ssize * pfltab, med_int ngauss, + unsigned char *val) +{ + med_idt dataset, dataspace = 0, memspace = 0; + med_ssize start_mem[1],start_data[1],*pflmem=0,*pfldsk=0; + med_size stride[1],count[1],pcount[1],size[1],pflsize[1]; + med_err ret; + int i,j,index,type_hdf; + hid_t datatype; + size_t typesize; + int dim, firstdim, dimutil, lastdim; + med_mode_profil pflmod; + + /* Verify fixdim is between [0, nbdim] ( 0 is MED_ALL ) */ + if ( ( fixdim < 0 ) || ( fixdim > nbdim ) ) + return -1; + + /* block pflmod to MED_COMPACT (until med2.2) */ + pflmod = MED_COMPACT; + + switch(type) + { + case MED_REEL64 : + /* 1) IA32 is LE but due to an (?HDF convertion BUG?) when using H5T_NATIVE_DOUBLE/MED_REEL64? under PCLINUX + the file read under SGI is incorrect + 2) Compaq OSF/1 is LE, since we force SGI64,SUN4SOL2,HP to write double in LE even if they are BE, mips OSF/1 must be BE + REM : Be careful of compatibility between MED files when changing this (med2.2) */ +#if defined(PCLINUX) || defined(OSF1) + type_hdf = H5T_IEEE_F64BE; +#else + type_hdf = H5T_IEEE_F64LE; +#endif + break; + + case MED_INT32 : + type_hdf = H5T_NATIVE_INT; + break; + + case MED_INT64 : + type_hdf = H5T_NATIVE_LONG; + break; + + default : + return -1; + } + + /* Ouverture du Dataset à lire */ + if ((dataset = H5Dopen(pere,nom)) < 0) + return -1; + + /* Interrogation de la taille du dataset */ + if ( (datatype = H5Dget_type(dataset )) < 0) return -1; + if ( (typesize = H5Tget_size(datatype)) < 0) return -1; + size[0] = H5Dget_storage_size(dataset) / typesize; + if ( H5Tclose(datatype) < 0) return -1; + + /* Create dataspace */ + if ((dataspace = H5Screate_simple(1,size,NULL)) < 0) + return -1; + + switch(interlace) + { + case MED_FULL_INTERLACE : + + /*Initialisation des indices de boucle du traitement de l'entrelacement en fonction de la dimension fixee*/ + if ( fixdim != MED_ALL) + { + firstdim = fixdim-1; + lastdim = fixdim; + dimutil = 1; + } else { + firstdim = 0; + lastdim = nbdim; + dimutil = nbdim; + } + + count [0] = (*size)/(nbdim); + + + /*rem: Pas de vérification de l'assertion (*size)=n*nbdim */ + if ( psize == MED_NOPF ) { + + /* Creation d'un data space mémoire de dimension 1, de longeur size, et de longeur maxi size */ + if ( (memspace = H5Screate_simple (1, size, NULL)) <0) + return -1; + + stride[0] = nbdim; + + for (dim=firstdim; dim < lastdim; dim++) { + + start_mem[0] = dim; + if ( (ret = H5Sselect_hyperslab (memspace, H5S_SELECT_SET, start_mem, stride, + count, NULL)) <0) + return -1; + + start_data[0] = dim*count[0]; + if ( (ret = H5Sselect_hyperslab (dataspace, H5S_SELECT_SET, start_data, NULL, + count, NULL)) <0) + return -1; + + if ((ret = H5Dread(dataset,type_hdf,memspace,dataspace, + H5P_DEFAULT, val)) < 0) + return -1; + } + + } else { + + pflsize [0] = psize*ngauss*nbdim; + pcount [0] = psize*ngauss*dimutil; + pflmem = (med_ssize *) malloc (sizeof(med_ssize)*pcount[0]); + pfldsk = (med_ssize *) malloc (sizeof(med_ssize)*pcount[0]); + + switch(pflmod) + { /* switch pflmod pour FULL_INTERLACE*/ + case MED_GLOBALE : + + /* Creation d'un data space mémoire de dimension 1, de longeur size, et de longeur maxi size */ + if ( (memspace = H5Screate_simple (1, size, NULL)) <0) + return -1; + + for (dim=firstdim; dim < lastdim; dim++) { + + for (i=0; i < psize; i++) /* i balaye les élements du profil */ + for (j=0; j < ngauss; j++) { + index = i*ngauss+j + (dim-firstdim)*(psize*ngauss); + pflmem[index] = (pfltab[i]-1)*ngauss*nbdim + j*nbdim+dim; + pfldsk[index] = dim*count[0] + (pfltab[i]-1)*ngauss+j; + } + } + + if ( (ret = H5Sselect_elements(memspace ,H5S_SELECT_SET, pcount[0], (const hssize_t **) pflmem ) ) <0) + return -1; + + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET, pcount[0], (const hssize_t **) pfldsk ) ) <0) + return -1; + + break; + + case MED_COMPACT : + + /* Creation d'un data space mémoire de dimension 1, de la longeur du profil */ + /* La dimension utilisée est ici nbdim, même pour un profil compact on suppose */ + /* que l'utilisateur a toutes les coordonées stockées, même si il en demande qu'une */ + + if ( (memspace = H5Screate_simple (1, pflsize, NULL)) <0) + return -1; + + for (dim=firstdim; dim < lastdim; dim++) { + + for (i=0; i < psize; i++) /* i balaye les élements du profil */ + for (j=0; j < ngauss; j++) { + index = i*ngauss+j + (dim-firstdim)*(psize*ngauss); + pflmem[index] = i*ngauss*nbdim + j*nbdim+dim; + pfldsk[index] = dim*count[0] + (pfltab[i]-1)*ngauss+j; + } + } + + if ( (ret = H5Sselect_elements(memspace ,H5S_SELECT_SET, pcount[0], (const hssize_t **) pflmem ) ) <0) + return -1; + + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET, pcount[0], (const hssize_t **) pfldsk ) ) <0) + return -1; + + break; + + default : + return -1; + } + + if ((ret = H5Dread(dataset,type_hdf,memspace,dataspace,H5P_DEFAULT, val)) < 0) + return -1; + + free(pflmem); + free(pfldsk); + } + + break; + + case MED_NO_INTERLACE : + + /*Initialisation des indices de boucle du traitement de l'entrelacement en fonction de la dimension fixee*/ + + count[0] = (*size)/nbdim; + + if ( psize == MED_NOPF ) { + + if ( fixdim != MED_ALL) + start_data[0] = (fixdim-1)*count[0]; + else { + count[0] = *size; + start_data[0] = 0; + }; + + if ( (ret = H5Sselect_hyperslab (dataspace, H5S_SELECT_SET, start_data, NULL, + count, NULL)) <0) + return -1; + + if ((ret = H5Dread(dataset,type_hdf,dataspace,dataspace, + H5P_DEFAULT, val)) < 0) + return -1; + + } else { + + if ( fixdim != MED_ALL) + { + firstdim = fixdim-1; + lastdim = fixdim; + dimutil = 1; + } else { + firstdim = 0; + lastdim = nbdim; + dimutil = nbdim; + } + + pflsize [0] = psize*ngauss*nbdim; + pcount [0] = psize*ngauss*dimutil; /* nom pas très coherent avec count !!! A revoir */ + pfldsk = (med_ssize *) malloc(sizeof(med_ssize)*pcount[0]); + + switch(pflmod) + { /*switch plfmod pour NO_INTERLACE */ + case MED_GLOBALE : + + for (dim=firstdim; dim < lastdim; dim++) { + + for (i=0; i < psize; i++) /* i balaye le nbre d'élements du profil */ + for (j=0; j < ngauss; j++) { + index = i*ngauss+j + (dim-firstdim)*(psize*ngauss); + pfldsk[index] = dim*count[0]+(pfltab[i]-1)*ngauss+j; + } + } + + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET,pcount[0], (const hssize_t **) pfldsk ) ) <0) + return -1; + + if ((ret = H5Dread(dataset,type_hdf,dataspace,dataspace,H5P_DEFAULT, val)) < 0) + return -1; + + break; + + case MED_COMPACT : + + /* Creation d'un data space mémoire de dimension 1, de la longeur du profil */ + /* La dimension utilisée est ici nbdim, même pour un profil compact on suppose */ + /* que l'utilisateur a toutes les coordonées stockées, même si il en demande qu'une */ + + if ( (memspace = H5Screate_simple (1, pflsize, NULL)) <0) + return -1; + + pflmem = (med_ssize *) malloc (sizeof(med_ssize)*pcount[0]); + + /* Le profil COMPACT est contigüe, mais il est possible que l'on selectionne uniquemenent une dimension*/ + + for (dim=firstdim; dim < lastdim; dim++) { + + for (i=0; i < psize; i++) /* i balaye le nbre d'élements du profil */ + for (j=0; j < ngauss; j++) { + index = i*ngauss+j + (dim-firstdim)*(psize*ngauss); + pflmem[index] = dim*(psize*ngauss) + (pfltab[i]-1)*ngauss+j; + pfldsk[index] = dim*count[0] + (pfltab[i]-1)*ngauss+j; + } + } + + if ( (ret = H5Sselect_elements(memspace ,H5S_SELECT_SET, pcount[0], (const hssize_t **) pflmem ) ) <0) + return -1; + + if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET,pcount[0], (const hssize_t **) pfldsk ) ) <0) + return -1; + + if ((ret = H5Dread(dataset,type_hdf,memspace,dataspace,H5P_DEFAULT, val)) < 0) + return -1; + + break; + + default : + return -1; + + } + + free(pfldsk); + + }; + + break; + + default : + return -1; + } + + + + if (memspace) + if ((ret = H5Sclose(memspace)) < 0) + return -1; + + if ((ret = H5Sclose(dataspace)) < 0) + return -1; + + if ((ret = H5Dclose(dataset)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDdatasetOuvrir.cxx b/src/MEDWrapper/V2_1/MEDdatasetOuvrir.cxx new file mode 100644 index 000000000..b3e852cd1 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDdatasetOuvrir.cxx @@ -0,0 +1,44 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDdatasetOuvrir + * - Description : ouverture d'un objet HDF dataset + * - Parametres : + * - pid (IN) : l'ID de l'objet HDF pere + * - nom (IN) : le nom du dataset + * - Resultat : ID du dataset en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_idt +_MEDdatasetOuvrir(med_idt pid,char *nom) +{ + med_idt id; + + if ((id = H5Dopen(pid,nom)) < 0) + return -1; + + return id; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDdatasetStringEcrire.cxx b/src/MEDWrapper/V2_1/MEDdatasetStringEcrire.cxx new file mode 100644 index 000000000..651f5a84d --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDdatasetStringEcrire.cxx @@ -0,0 +1,87 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDdatasetStringEcrire + * - Description : ecriture d'un dataset tableau de caracteres + * - Parametres : + * - pere (IN) : l'ID de l'objet HDF pere ou placer l'attribut + * - nom (IN) : le nom de l'attribut + * - dimd (IN) : profil du tableau + * - val (IN) : valeurs du tableau + * - mode (IN) : mode d'ecriture MED + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDdatasetStringEcrire(med_idt pere,char *nom,med_size *dimd, + char *val, med_mode_acces mode) +{ + med_idt dataset; + med_idt datatype = 0; + med_idt dataspace = 0; + med_err ret; + + if ((dataset = H5Dopen(pere,nom)) < 0) + { + if ((dataspace = H5Screate_simple(1,dimd,NULL)) < 0) + return -1; + if((datatype = H5Tcopy(H5T_C_S1)) < 0) + return -1; + if((ret = H5Tset_size(datatype,1)) < 0) + return -1; + if ((dataset = H5Dcreate(pere,nom,datatype,dataspace, + H5P_DEFAULT)) < 0) + return -1; + } + else + if (mode != MED_REMP) + { + H5Dclose(dataset); + return -1; + } + else + { + if ((dataspace = H5Screate_simple(1,dimd,NULL)) < 0) + return -1; + if((datatype = H5Tcopy(H5T_C_S1)) < 0) + return -1; + if((ret = H5Tset_size(datatype,1)) < 0) + return -1; + } + if ((ret = H5Dwrite(dataset,datatype,H5S_ALL,H5S_ALL, + H5P_DEFAULT, val)) < 0) + return -1; + if (dataspace) + if((ret = H5Sclose(dataspace)) < 0) + return -1; + if (datatype) + if ((ret = H5Tclose(datatype)) < 0) + return -1; + if ((ret = H5Dclose(dataset)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDdatasetStringLire.cxx b/src/MEDWrapper/V2_1/MEDdatasetStringLire.cxx new file mode 100644 index 000000000..017ccbf7b --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDdatasetStringLire.cxx @@ -0,0 +1,56 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDdatasetStringLire + * - Description : lecture d'un dataset tableau de caracteres + * - Parametres : + * - pere (IN) : l'ID de l'objet HDF pere ou placer l'attribut + * - nom (IN) : le nom de l'attribut + * - val (IN) : valeurs du tableau + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDdatasetStringLire(med_idt pere,char *nom,char *val) +{ + med_idt dataset,datatype; + med_err ret; + + if ((dataset = H5Dopen(pere,nom)) < 0) + return -1; + if ((datatype = H5Tcopy(H5T_C_S1)) < 0) + return -1; + if ((ret = H5Tset_size(datatype,1)) < 0) + return -1; + if ((ret = H5Dread(dataset,datatype,H5S_ALL,H5S_ALL,H5P_DEFAULT,val)) < 0) + return -1; + if ((ret = H5Tclose(datatype)) < 0) + return -1; + if ((ret = H5Dclose(dataset)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDdimLire.cxx b/src/MEDWrapper/V2_1/MEDdimLire.cxx new file mode 100644 index 000000000..3ca50c61f --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDdimLire.cxx @@ -0,0 +1,62 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ +med_int +MEDdimLire(med_idt fid, char *maillage) +{ + med_idt maaid; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + med_int dim; + + /* + * On inhibe le gestionnaire d'erreur + */ + _MEDmodeErreurVerrouiller(); + + /* + * On regarde si le groupe existe => erreur si non + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maillage); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * On va lire l'attribut dimension + */ + if ((ret = _MEDattrEntierLire(maaid,MED_NOM_DIM,&dim)) < 0) + return -1; + + /* + * Fermetures des objets HDF + */ + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return dim; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDelementsEcr.cxx b/src/MEDWrapper/V2_1/MEDelementsEcr.cxx new file mode 100644 index 000000000..e67b44d38 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDelementsEcr.cxx @@ -0,0 +1,54 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" + +namespace med_2_1{ + +med_err +MEDelementsEcr(med_idt fid,char *maa,med_int mdim,med_int *connectivite,med_mode_switch mode_switch, + char *nom,med_booleen inom,med_int *num,med_booleen inum, + med_int *fam,med_int nele,med_entite_maillage typ_ent, + med_geometrie_element typ_geo,med_connectivite typ_conn, + med_mode_acces mode) +{ + med_err ret; + + /* Ecriture de la connectivite */ + if ((ret = MEDconnEcr(fid,maa,mdim,connectivite,mode_switch,nele,mode,typ_ent,typ_geo, + typ_conn)) < 0) + return -1; + + /* Ecriture des noms */ + if (inom == MED_VRAI) + if ((ret = MEDnomEcr(fid,maa,nom,nele,mode,typ_ent,typ_geo)) < 0) + return -1; + + /* Ecriture des numeros */ + if (inum == MED_VRAI) + if ((ret = MEDnumEcr(fid,maa,num,nele,mode,typ_ent,typ_geo)) < 0) + return -1; + + /* Ecriture des numeros de familles */ + if ((ret = MEDfamEcr(fid,maa,fam,nele,mode,typ_ent,typ_geo)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDelementsLire.cxx b/src/MEDWrapper/V2_1/MEDelementsLire.cxx new file mode 100644 index 000000000..bdd85909e --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDelementsLire.cxx @@ -0,0 +1,55 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" + +namespace med_2_1{ + +med_err +MEDelementsLire(med_idt fid,char *maa,med_int mdim,med_int *connectivite,med_mode_switch mode_switch, + char *nom,med_booleen *inom,med_int *num,med_booleen *inum, + med_int *fam,med_int nele,med_entite_maillage typ_ent, + med_geometrie_element typ_geo,med_connectivite typ_conn) +{ + med_err ret; + + /* Lecure de la connectivite */ + if ((ret = MEDconnLire(fid,maa,mdim,connectivite,mode_switch,0,MED_NOPF, + typ_ent,typ_geo,typ_conn)) < 0) + return -1; + + /* Lecture des noms */ + if ((ret = MEDnomLire(fid,maa,nom,nele,typ_ent,typ_geo)) < 0) + *inom = MED_FAUX; + else + *inom = MED_VRAI; + + /* Lecture des numeros */ + if ((ret = MEDnumLire(fid,maa,num,nele,typ_ent,typ_geo)) < 0) + *inum = MED_FAUX; + else + *inum = MED_VRAI; + + /* Lecture des numeros de familles */ + if ((ret = MEDfamLire(fid,maa,fam,nele,typ_ent,typ_geo)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDequivCr.cxx b/src/MEDWrapper/V2_1/MEDequivCr.cxx new file mode 100644 index 000000000..a5a3b816d --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDequivCr.cxx @@ -0,0 +1,78 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDequivCr(med_idt fid,char *maa, char *eq, char *desc) +{ + med_idt root,eqid; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_EQS+MED_TAILLE_NOM+1]; + char tmp[MED_TAILLE_EQS+1]; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le Data Group "EQS" n'existe pas, on le cree + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + strncpy(tmp,MED_EQS,MED_TAILLE_EQS-1); + tmp[MED_TAILLE_EQS-1] = '\0'; + strcat(chemin,tmp); + if ((root = _MEDdatagroupOuvrir(fid,chemin)) < 0) + if ((root = _MEDdatagroupCreer(fid,chemin)) < 0) + return -1; + + /* + * Si une equivalence du meme nom existe => erreur + * Sinon on la cree + */ + if ((eqid = _MEDdatagroupOuvrir(root,eq)) >= 0) + return -1; + if ((eqid = _MEDdatagroupCreer(root,eq)) < 0) + return -1; + + /* + * L'attribut "DES" + */ + if ((ret = _MEDattrStringEcrire(eqid,MED_NOM_DES,MED_TAILLE_DESC,desc,MED_REMP)) < 0) + return -1; + + /* + * On ferme tout + */ + if ((ret = _MEDdatagroupFermer(eqid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(root)) < 0) + return -1; + + return 0 ; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDequivEcr.cxx b/src/MEDWrapper/V2_1/MEDequivEcr.cxx new file mode 100644 index 000000000..dfa3f72b1 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDequivEcr.cxx @@ -0,0 +1,111 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +extern int mode_interlace; + +namespace med_2_1{ + +med_err +MEDequivEcr(med_idt fid, char *maa, char *eq, med_int *corr, med_int n, + med_mode_acces mode, med_entite_maillage typ_ent, med_geometrie_element typ_geo) +{ + med_idt eqid, datagroup; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_EQS+2*MED_TAILLE_NOM+1]; + char nomdatagroup[MED_TAILLE_NOM+1]; + char tmp[MED_TAILLE_NOM_ENTITE+1]; + med_size dimd[1]; + + if (typ_geo == MED_TETRA4 || typ_geo == MED_TETRA10 || + typ_geo == MED_HEXA8 || typ_geo == MED_HEXA20 || + typ_geo == MED_PENTA6 || typ_geo == MED_PENTA15 || + typ_geo == MED_PYRA5 || typ_geo == MED_PYRA13) + return -1; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le Data Group de "eq" n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + strcat(chemin,MED_EQS); + strcat(chemin,eq); + if ((eqid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * Ecriture de l'equivalence + */ + if ((ret = _MEDnomEntite(nomdatagroup,typ_ent)) < 0) + return -1; + if ((typ_ent != MED_NOEUD)) + { + if ((ret = _MEDnomGeometrie(tmp,typ_geo)) < 0) + return -1; + strcat(nomdatagroup,"."); + strcat(nomdatagroup,tmp); + } + datagroup = 0; + if (((datagroup = _MEDdatagroupOuvrir(eqid,nomdatagroup)) > 0) && + (mode != MED_REMP)) + return -1; + else + if (datagroup > 0) + _MEDdatagroupFermer(datagroup); + + /* EF : verifier que çà marche si le data groupe existe déjà */ + if ((datagroup = _MEDdatagroupCreer(eqid,nomdatagroup)) < 0) + return -1; + + if ((ret = _MEDattrEntierEcrire(datagroup,MED_NOM_NBR,&n,mode)) < 0) + return -1; + + dimd[0] = 2*n; + +#if defined(IRIX64)||defined(OSF1) + if ((ret = _MEDdatasetNumEcrire(datagroup,MED_NOM_COR,MED_INT64,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,0,MED_NOPG,dimd, + (unsigned char*) corr,mode)) < 0) + return -1; +#else + if ((ret = _MEDdatasetNumEcrire(datagroup,MED_NOM_COR,MED_INT32,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,0,MED_NOPG,dimd, + (unsigned char*) corr,mode)) < 0) + return -1; +#endif + + /* + * On ferme tout + */ + if ((ret = _MEDdatagroupFermer(datagroup)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(eqid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDequivInfo.cxx b/src/MEDWrapper/V2_1/MEDequivInfo.cxx new file mode 100644 index 000000000..e031dec8a --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDequivInfo.cxx @@ -0,0 +1,73 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDequivInfo(int fid, char *maa, int ind, char *eq, char *des) +{ + med_idt eqid; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_EQS+2*MED_TAILLE_NOM+1]; + int num; + int idx; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * On recupere le nom de l'equivalence + */ + num = ind - 1; + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + strcat(chemin,MED_EQS); + if ((idx = _MEDobjetIdentifier(fid,chemin,num,eq)) < 0) + return -1; + + /* + * Si le Data Group eq n'existe pas => erreur + */ + strcat(chemin,eq); + if ((eqid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * L'attribut "DES" + */ + if ((ret = _MEDattrStringLire(eqid,MED_NOM_DES,MED_TAILLE_DESC,des)) < 0) + return -1; + + /* + * On ferme tout + */ + if ((ret = _MEDdatagroupFermer(eqid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDequivLire.cxx b/src/MEDWrapper/V2_1/MEDequivLire.cxx new file mode 100644 index 000000000..824e21c99 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDequivLire.cxx @@ -0,0 +1,99 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +extern int mode_interlace; + +namespace med_2_1{ + +med_err +MEDequivLire(med_idt fid, char *maa, char *eq, med_int *corr, med_int n, + med_entite_maillage typ_ent,med_geometrie_element typ_geo) +{ + med_idt eqid, datagroup; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_EQS+2*MED_TAILLE_NOM+1]; + char nomdatagroup[MED_TAILLE_NOM+1]; + char tmp[MED_TAILLE_NOM_ENTITE+1]; + + if (typ_geo == MED_TETRA4 || typ_geo == MED_TETRA10 || + typ_geo == MED_HEXA8 || typ_geo == MED_HEXA20 || + typ_geo == MED_PENTA6 || typ_geo == MED_PENTA15 || + typ_geo == MED_PYRA5 || typ_geo == MED_PYRA13) + return -1; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le Data Group de "eq" n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + strcat(chemin,MED_EQS); + strcat(chemin,eq); + if ((eqid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * Lecture de l'equivalence + */ + if ((ret = _MEDnomEntite(nomdatagroup,typ_ent)) < 0) + return -1; + if ((typ_ent != MED_NOEUD)) + { + if ((ret = _MEDnomGeometrie(tmp,typ_geo)) < 0) + return -1; + strcat(nomdatagroup,"."); + strcat(nomdatagroup,tmp); + } + if ((datagroup = _MEDdatagroupOuvrir(eqid,nomdatagroup)) < 0) + return -1; +#if defined(IRIX64)||defined(OSF1) + if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_COR,MED_INT64, + MED_NO_INTERLACE,1,MED_ALL, + MED_NOPF,0,MED_NOPG, + (unsigned char *) corr)) < 0) + return -1; +#else + if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_COR,MED_INT32, + MED_NO_INTERLACE,1,MED_ALL, + MED_NOPF,0,MED_NOPG, + (unsigned char *) corr)) < 0) + return -1; +#endif + + /* + * On ferme tout + */ + if ((ret = _MEDdatagroupFermer(datagroup)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(eqid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDfam2groA.cxx b/src/MEDWrapper/V2_1/MEDfam2groA.cxx new file mode 100644 index 000000000..b964f813a --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDfam2groA.cxx @@ -0,0 +1,208 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include +#include +#include +#include "med.hxx" + + +/*********************************************************************** + * FONCTION MEDfam2groA + * + * - DESCRIPTION : 1ere etape dans la conversion des familles de groupes + * MED en goupes de noeuds et d'elements. + * Calcul des tailles des tableaux a allouer pour stocker les + * groupes que l'on veut creer. + * Les parametres renvoyes sont : + * 1 - le nombre de groupes de noeuds a creer (ngn) + * 2 - le nombre de groupes d'elements (nge) + * 3 - le nombre total de noeuds composant l'ensemble des groupes + * de noeuds (nindn) + * 4 - le nombre total d'elements composant l'ensemble des groupes + * d'elements (ninde) + * Ces parametres doivent permettre de creer les tables suivantes : + * 1 - une table de taille (nindn) contenant pour chaque groupe + * de noeuds la liste des noeuds le composant. Cette table + * sera indexee par une table de taille (ngn) qui contiendra + * pour chaque noeud un numero d'indice. Une table de taille + * (ngn) qui contiendra la liste des noms des differents + * groupes de noeuds. + * 2 - idem pour les elements + * Le remplissage de ces tables est realise par la fonction + * MEDfam2groB(). + * + * - PARAMETRES : + * NOM .E/S. TYPE . DESCRIPTION + * ------------------------------------------------------------------- + * nfam .E . med_int . nombre de familles + * numfam .E . med_int*. table des numeros de familles + * numfamnoe .E . med_int*. table des numeros de familles + * . . . des noeuds + * nnoeuds .E . med_int . nombre de noeuds + * numfamele .E . med_int*. table des numeros de familles + * . . . des elements + * nelememts .E . . nombre total d'elements + * grofam .E . char* . liste des groupes de familles + * indfamgro .E . int* . liste des indices des groupes + * . . . de familles dans grofam + * ngn . S. med_int*. nombre de groupes de noeuds a + * . . creer + * nge . S. med_int*. nombre de groupes d'elements a + * . . creer + * nindn . S. med_int*. taille de la table + * . . des groupes de noeuds a creer + * ninde . S. med_int*. taille de la table + * . . des groupes d'elements + * + * - RESULTAT : 0 si succes et -1 sinon + * + ***********************************************************************/ + +namespace med_2_1{ + +med_err +MEDfam2groA (med_int nfam,med_int *numfam,med_int *numfamnoe, + med_int nnoeuds,med_int *numfamele,med_int nelements, + char *grofam,int *indfamgro, + med_int *ngn,med_int *nge,med_int *nindn,med_int *ninde) +{ + int i,j,k; + char groupe[MED_TAILLE_LNOM]; + char *nomgronoe,*nomgroele,*tmp; + med_int numc; + int nnoe = 0,nele = 0; + int flag = 0; + + *ngn = 0; + *nge = 0; + *nindn = 0; + *ninde = 0; + + tmp = NULL; + nomgronoe = NULL; + nomgroele = NULL; + + /* Pour chaque famille, on regarde s'il y a de nouveaux groupes + de noeuds ou d'elements a creer. Pour chaque nouveau groupe, + on compte le nombre de noeuds ou d'elements qui devront lui etre + rataches */ + for (i=1;i<=nfam;i++) + if ((*(indfamgro+i)-*(indfamgro+i-1))/MED_TAILLE_LNOM > 0) + { + /* on releve le numero de la famille courante */ + numc = *(numfam+i-1); + nnoe = 0; + nele = 0; + /* si c'est une famille de noeuds, on compte le nombre de + noeuds qui y sont rattaches */ + if (numc > 0) + for (j=0;j 0) + { + *nindn = *nindn+nnoe; + if (*ngn == 0) + { + *ngn = 1; + if ((nomgronoe=(char*)malloc(sizeof(char)*MED_TAILLE_LNOM)) + == NULL) + return -1; + strncpy(nomgronoe,groupe,MED_TAILLE_LNOM); + } + else + { + flag = 0; + for (k=0;k<(*ngn);k++) + if (strncmp(groupe,nomgronoe+k*MED_TAILLE_LNOM, + MED_TAILLE_LNOM) == 0) + flag = 1; + if (flag == 0) + { + *ngn = *ngn + 1; + if ((tmp=(char*)malloc(sizeof(char)* + MED_TAILLE_LNOM**ngn)) == NULL) + return -1; + strncpy(tmp,nomgronoe,MED_TAILLE_LNOM*(*ngn-1)); + strncpy(tmp+MED_TAILLE_LNOM*(*ngn-1),groupe, + MED_TAILLE_LNOM); + free(nomgronoe); + nomgronoe = tmp; + } + } + } + if (numc < 0) + { + *ninde = *ninde+nele; + if (*nge == 0) + { + *nge = 1; + if ((nomgroele=(char *)malloc(sizeof(char)* + MED_TAILLE_LNOM)) == NULL) + return -1; + strncpy(nomgroele,groupe,MED_TAILLE_LNOM); + } + else + { + flag = 0; + for (k=0;k<(*nge);k++) + if (strncmp(groupe,nomgroele+k*MED_TAILLE_LNOM, + MED_TAILLE_LNOM) == 0) + flag = 1; + if (flag == 0) + { + *nge = *nge + 1; + if ((tmp = (char*) malloc(sizeof(char)*MED_TAILLE_LNOM* + *nge)) == NULL) + return -1; + strncpy(tmp,nomgroele,MED_TAILLE_LNOM*(*nge-1)); + strncpy(tmp+MED_TAILLE_LNOM*(*nge-1), groupe, + MED_TAILLE_LNOM); + free(nomgroele); + nomgroele = tmp; + } + } + } + } + } + + /* nettoyage memoire */ + free(nomgronoe); + free(nomgroele); + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDfam2groB.cxx b/src/MEDWrapper/V2_1/MEDfam2groB.cxx new file mode 100644 index 000000000..3dbea6071 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDfam2groB.cxx @@ -0,0 +1,245 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + + +#include +#include +#include +#include "med.hxx" + +/*********************************************************************** + * FONCTION MEDfam2groB + * + * - DESCRIPTION : 2e etape dans la conversion des familles MED en + * groupes de noeuds et d'elements. Les tables allouees a partir + * des parametres calcules par MEDfam2groA() sont passees en argument + * a MEDfam2groB et remplies par cette derniere fonction. + * Il s'agit de : + * 1 - la table des noms de groupes de noeuds, chaque nom ayant + * une taille de MED_TAILLE_LNOM + * 2 - la table des noms des groupes d'elements + * 3 - la table des groupes de noeuds -i.e. pour chaque groupe + * la liste des numeros des noeuds qui le composent + * 4 - la table d'indexation de la table des groupes de noeuds + * 5 - la table des groupes d'elements + * 6 - la table d'indexation de la table des groupes d'elements + * + * - PARAMETRES : + * NOM .E/S. TYPE . DESCRIPTION + * ------------------------------------------------------------------- + * nfam .E . med_int . nombre de familles + * numfam .E . med_int*. table des numeros de familles + * numfamnoe .E . med_int*. table des numeros de familles + * . . . des noeuds + * nnoeuds .E . med_int . nombre de noeuds + * numfamele .E . med_int*. table des numeros de familles + * . . . des elements + * nelememts .E . med_int . nombre total d'elements + * grofam .E . char* . liste des groupes de familles + * indfamgro .E . int* . liste des indices des groupes + * . . . de familles dans indfamgro + * numnoeuds .E . med_int*. numeros des noeuds + * numele .E . med_int*. numeros des elements + * ngn .E . med_int . nombre de groupes de noeuds + * nge .E . med_int . nombre de groupes d'elements + * nindn .E . med_int . nombre d'indices dans la table + * . . des groupes de noeuds a creer + * ninde .E . med_int . nombre d'indices dans la table + * . . des groupes d'elements + * nomgronoe . S. char* . noms des groupes de noeuds + * nomgroele . S. char* . noms des groupes d'elements + * indgronoe . S. int* . indices des groupes de noeuds + * indgroele . S. int* . indices des groupes d'elements + * tabgronoe . S. med_int*. table des groupes de noeuds + * tabgroele . S. med_int*. table des groupes d'elements + * + * - RESULTAT : 0 + * + ***********************************************************************/ + +namespace med_2_1{ + +med_err +MEDfam2groB(med_int nfam,med_int *numfam,med_int *numfamnoe, + med_int nnoeuds,med_int *numfamele,med_int nelements, + char *grofam,int *indfamgro,med_int *numnoeuds, + med_int *numele,med_int ngn,med_int nge,med_int nindn, + med_int ninde,char *nomgronoe,char *nomgroele, + int *indgronoe,int *indgroele, + med_int *tabgronoe,med_int *tabgroele) +{ + int i,j,k; + char groupe[MED_TAILLE_LNOM]; + med_int numc; + int nnoe = 0, nele = 0; + int flag = 0; + int nn = 0, ne = 0; + int pos, cpt; + + /* initialisations */ + for (i=0;i<=ngn;i++) + *(indgronoe+i) = 0; + for (i=0;i<=nge;i++) + *(indgroele+i) = 0; + + /* 1ere passe : on passe en revue toutes les familles : + 1 - on etablit dans (nomgronoe) et dans (nomgroele) les listes + des noms de groupes de noeuds et d'elements + 2 - on place dans les tables d'index (indgronoe) et (indgroele) + le nombre de noeuds ou d'elements que chaque groupe se verra + attribuer */ + for (i=1;i<=nfam;i++) + { + numc = *(numfam+i-1); + nnoe = 0; + nele = 0; + if (numc > 0) + for (j=0;j 0) + { + if (nn == 0) + { + strncpy(nomgronoe,groupe,MED_TAILLE_LNOM); + nn = 1; + pos = 1; + } + else + { + flag = 0; + for (k=0; k 0) + { + flag = 0; + for (k=0;k<(*(indfamgro+j)-*(indfamgro+j-1))/MED_TAILLE_LNOM; + k++) + if (! strncmp(groupe, + grofam+*(indfamgro+j-1)+k*MED_TAILLE_LNOM, + MED_TAILLE_LNOM)) + flag = 1; + if (flag == 1) + for (k=0;k +#include + +namespace med_2_1{ + +med_err +MEDfamCr(med_idt fid,char* maa,char *famille,med_int numero, + med_int *attr_ident, med_int *attr_val, char *attr_desc, + med_int n_attr,char *groupe, med_int n_groupe) +{ + med_idt root, datagroup, famid; + med_err ret; + med_size dimd[1]; + char chemin[MED_TAILLE_MAA+MED_TAILLE_FAS+MED_TAILLE_NOM+1]; + char tmp[MED_TAILLE_FAS+1]; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le Data Group FAS n'existe pas, on le cree + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + strncpy(tmp,MED_FAS,MED_TAILLE_FAS-1); + tmp[MED_TAILLE_FAS-1] = '\0'; + strcat(chemin,tmp); + if ((root = _MEDdatagroupOuvrir(fid,chemin)) < 0) + if ((root = _MEDdatagroupCreer(fid,chemin)) < 0) + return -1; + + /* + * Si le Data Group de meme nom que famille existe => erreur + * Sinon on le cree + */ + if ((famid = _MEDdatagroupOuvrir(root,famille)) >= 0) + return -1; + if ((famid = _MEDdatagroupCreer(root,famille)) < 0) + return -1; + + /* + * L'attribut NUM + */ + if ((ret = _MEDattrEntierEcrire(famid,MED_NOM_NUM,&numero,MED_REMP)) < 0) + return -1; + + /* + * Le Data Group "GRO" + */ + if (n_groupe > 0) + { + /* + * On cree le Data Group + */ + if ((datagroup = _MEDdatagroupCreer(famid,MED_NOM_GRO)) < 0) + return -1; + + /* + * L'attribut "NBR" + */ + if ((ret = _MEDattrEntierEcrire(datagroup,MED_NOM_NBR,&n_groupe,MED_REMP)) < 0) + return -1; + + /* + * Data Set des noms des groupes "NOM" + */ + dimd[0] = n_groupe*MED_TAILLE_LNOM+1; + if ((ret = _MEDdatasetStringEcrire(datagroup,MED_NOM_NOM,dimd,groupe, + MED_REMP))<0) + return -1; + + /* + * On ferme le Data Group + */ + if ((ret = _MEDdatagroupFermer(datagroup)) < 0) + return -1; + } + + /* + * Le Data Group "ATT" + */ + + if (n_attr > 0) + { + if ((datagroup = _MEDdatagroupCreer(famid,MED_NOM_ATT)) < 0) + return -1; + + /* + * L'attribut "NBR" + */ + if ((ret = _MEDattrEntierEcrire(datagroup,MED_NOM_NBR,&n_attr,MED_REMP)) < 0) + return -1; + + /* + * Le Data Set "IDE" + */ + dimd[0] = n_attr; +#if defined(IRIX64)||defined(OSF1) + if ((ret = _MEDdatasetNumEcrire(datagroup,MED_NOM_IDE,MED_INT64,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,0,MED_NOPG,dimd, + (unsigned char *)attr_ident,MED_REMP)) < 0) + return -1; +#else + if ((ret = _MEDdatasetNumEcrire(datagroup,MED_NOM_IDE,MED_INT32,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,0,MED_NOPG,dimd, + (unsigned char *)attr_ident,MED_REMP)) < 0) + return -1; +#endif + + /* + * Le Data Set "VAL" + */ + dimd[0] = n_attr; +#if defined(IRIX64)||defined(OSF1) + if ((ret = _MEDdatasetNumEcrire(datagroup,MED_NOM_VAL,MED_INT64,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,0,MED_NOPG,dimd, + (unsigned char*)attr_val,MED_REMP)) < 0) + return -1; +#else + if ((ret = _MEDdatasetNumEcrire(datagroup,MED_NOM_VAL,MED_INT32,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,0,MED_NOPG,dimd, + (unsigned char*)attr_val,MED_REMP)) < 0) + return -1; +#endif + + /* + * Le Data Set "DES" + */ + dimd[0] = n_attr*MED_TAILLE_DESC+1; + if ((ret = _MEDdatasetStringEcrire(datagroup,MED_NOM_DES,dimd,attr_desc, + MED_REMP)) < 0) + return -1; + + /* + * On ferme le Data Group + */ + if ((ret = _MEDdatagroupFermer(datagroup)) < 0) + return -1; + } + + /* + * On ferme tout + */ + if ((ret = _MEDdatagroupFermer(famid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(root)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDfamEcr.cxx b/src/MEDWrapper/V2_1/MEDfamEcr.cxx new file mode 100644 index 000000000..e6beb4bf9 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDfamEcr.cxx @@ -0,0 +1,123 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDfamEcr(med_idt fid,char *maa, med_int *fam, med_int n, med_mode_acces mode, + med_entite_maillage type_ent, med_geometrie_element type_geo) +{ + med_idt root, maaid, entid, geoid, dataset; + med_err ret; + med_size dimd[1]; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + char nom_ent[MED_TAILLE_NOM_ENTITE+1]; + char nom_geo[MED_TAILLE_NOM_ENTITE+1]; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * On met a jour le nom du Data Group representant + * le type des entites + */ + if ((ret = _MEDnomEntite(nom_ent,type_ent)) < 0) + return -1; + + /* + * Si le Data Group des entites n'existe pas on le cree + */ + if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0) + if ((entid = _MEDdatagroupCreer(maaid,nom_ent)) < 0) + return -1; + + /* + * Pour les mailles, les faces et le aretes, on cree + * s'il n'existe pas le Data Group du type geometrique + */ + if ((type_ent==MED_MAILLE)||(type_ent==MED_FACE)||(type_ent==MED_ARETE)) + { + if ((ret = _MEDnomGeometrie(nom_geo,type_geo)) < 0) + return -1; + + if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0) + if ((geoid = _MEDdatagroupCreer(entid,nom_geo)) < 0) + return -1; + } + else + geoid = -1; + + /* + * Creation du Data Set "FAM" + */ + if (geoid == -1) + root = entid; + else + root = geoid; + dimd[0] = n; +#if defined(IRIX64) || defined(OSF1) + if ((ret = _MEDdatasetNumEcrire(root,MED_NOM_FAM,MED_INT64,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,0,MED_NOPG,dimd, + (unsigned char*)fam,mode)) < 0) + return -1; +#else + if ((ret = _MEDdatasetNumEcrire(root,MED_NOM_FAM,MED_INT32,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,0,MED_NOPG,dimd, + (unsigned char*)fam,mode)) < 0) + return -1; +#endif + + /* + * Attribut NBR (nombre de noeuds) + */ + if ((dataset = _MEDdatasetOuvrir(root,MED_NOM_FAM)) < 0) + return -1; + if ((ret = _MEDattrEntierEcrire(dataset,MED_NOM_NBR,&n,mode)) < 0) + return -1; + + /* + * On ferme tout + */ + if ((ret = _MEDdatasetFermer(dataset)) < 0) + return -1; + if (geoid != -1) + if ((ret = _MEDdatagroupFermer(geoid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(entid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDfamGridEcr.cxx b/src/MEDWrapper/V2_1/MEDfamGridEcr.cxx new file mode 100644 index 000000000..be590c651 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDfamGridEcr.cxx @@ -0,0 +1,58 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" + +namespace med_2_1{ + +med_err +MEDfamGridEcr(med_idt fid, char *maa, med_int *fam, med_int n, med_mode_acces mode, med_entite_maillage type_ent) { + /* Ecrire des numeros de familles pour les grilles cartesiennes ou polaires : + - pour les noeuds + - pour les aretes + - pour les faces + - pour les mailles */ + + med_geometrie_element type_geo; + + switch(type_ent) { + case MED_NOEUD : { + type_geo = MED_POINT1; + break; + }; + case MED_ARETE : { + type_geo = MED_SEG2; + break; + }; + case MED_FACE : { + type_geo = MED_QUAD4; + break; + }; + case MED_MAILLE : { + type_geo = MED_HEXA8; + break; + }; + default : { + return(-1); + }; + }; + + return(MEDfamEcr(fid, maa, fam, n, mode, type_ent, type_geo)); +} + +} diff --git a/src/MEDWrapper/V2_1/MEDfamGridLire.cxx b/src/MEDWrapper/V2_1/MEDfamGridLire.cxx new file mode 100644 index 000000000..2f89144e9 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDfamGridLire.cxx @@ -0,0 +1,58 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" + +namespace med_2_1{ + +med_err +MEDfamGridLire(med_idt fid, char *maa, med_int *fam, med_int n, med_entite_maillage type_ent) { + /* lecture des numeros de familles pour les grilles cartesiennes ou polaires : + - pour les noeuds + - pour les aretes + - pour les faces + - pour les mailles */ + + med_geometrie_element type_geo; + + switch(type_ent) { + case MED_NOEUD : { + type_geo = MED_POINT1; + break; + }; + case MED_ARETE : { + type_geo = MED_SEG2; + break; + }; + case MED_FACE : { + type_geo = MED_QUAD4; + break; + }; + case MED_MAILLE : { + type_geo = MED_HEXA8; + break; + }; + default : { + return(-1); + }; + }; + + return(MEDfamLire(fid, maa, fam, n, type_ent, type_geo)); +} + +} diff --git a/src/MEDWrapper/V2_1/MEDfamInfo.cxx b/src/MEDWrapper/V2_1/MEDfamInfo.cxx new file mode 100644 index 000000000..b4527b122 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDfamInfo.cxx @@ -0,0 +1,160 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDfamInfo(med_idt fid,char *maa,int indice, char *famille, + med_int *numero, + med_int *attr_ident, med_int *attr_val, char *attr_desc, + med_int *n_attr, char *groupe ,med_int *n_groupe) +{ + med_idt famid,datagroup; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_FAS+2*MED_TAILLE_NOM+1]; + int num; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * On recupere le nom de la famille + */ + num = indice - 1; + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + strcat(chemin,MED_FAS); + if ((ret = _MEDobjetIdentifier(fid,chemin,num,famille)) < 0) + return -1; + + /* + * Si le Data Group de la famille n'existe pas => erreur + */ + strcat(chemin,famille); + if ((famid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * L'attribut NUM + */ + if ((ret = _MEDattrEntierLire(famid,MED_NOM_NUM,numero)) < 0) + return -1; + + /* + * Le Data Group "GRO" + */ + if ((datagroup = _MEDdatagroupOuvrir(famid,MED_NOM_GRO)) >= 0) + { + /* + * L'attribut "NBR" + */ + if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NBR,n_groupe)) < 0) + return -1; + + /* + * Data Set des noms des groupes "NOM" + */ + if ((ret = _MEDdatasetStringLire(datagroup,MED_NOM_NOM,groupe)) < 0) + return -1; + + /* + * On ferme le Data Group + */ + if ((ret = _MEDdatagroupFermer(datagroup)) < 0) + return -1; + } + else + *n_groupe = 0; + + /* + * Le Data Group "ATT" + */ + if ((datagroup = _MEDdatagroupOuvrir(famid,MED_NOM_ATT)) >= 0) + { + /* + * L'attribut "NBR" + */ + if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NBR,n_attr)) < 0) + return -1; + + /* + * Le Data Set "IDE" + */ +#if defined(IRIX64)||defined(OSF1) + if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_IDE,MED_INT64, + MED_NO_INTERLACE,1,MED_ALL, + MED_NOPF,0,MED_NOPG, + (unsigned char*) attr_ident)) < 0) + return -1; +#else + if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_IDE,MED_INT32, + MED_NO_INTERLACE,1,MED_ALL, + MED_NOPF,0,MED_NOPG, + (unsigned char*) attr_ident)) < 0) + return -1; +#endif + + /* + * Le Data Set "VAL" + */ +#if defined(IRIX64)||defined(OSF1) + if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_VAL,MED_INT64, + MED_NO_INTERLACE,1,MED_ALL, + MED_NOPF,0,MED_NOPG, + (unsigned char *) attr_val)) < 0) + return -1; +#else + if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_VAL,MED_INT32, + MED_NO_INTERLACE,1,MED_ALL, + MED_NOPF,0,MED_NOPG, + (unsigned char *) attr_val)) < 0) + return -1; +#endif + + /* + * Le Data Set "DES" + */ + ret = _MEDdatasetStringLire(datagroup,MED_NOM_DES,attr_desc); + + /* + * On ferme le Data Group + */ + if ((ret = _MEDdatagroupFermer(datagroup)) < 0) + return -1; + } + else + *n_attr = 0; + + /* + * On ferme tout + */ + if ((ret = _MEDdatagroupFermer(famid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDfamLire.cxx b/src/MEDWrapper/V2_1/MEDfamLire.cxx new file mode 100644 index 000000000..501b98f7c --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDfamLire.cxx @@ -0,0 +1,112 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDfamLire(med_idt fid,char *maa, med_int *fam, med_int n, + med_entite_maillage type_ent,med_geometrie_element type_geo) +{ + med_idt root,maaid, entid, geoid; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + char nom_ent[MED_TAILLE_NOM_ENTITE+1]; + char nom_geo[MED_TAILLE_NOM_ENTITE+1]; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * On met a jour le nom du Data Group representant + * le type des entites + */ + if ((ret = _MEDnomEntite(nom_ent,type_ent)) < 0) + return -1; + + /* + * Si le Data Group des entites n'existe pas => erreur + */ + if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0) + return -1; + + /* + * Pour les mailles, les faces et le aretes, on cree + * si le Data Group du type geometrique => erreur + */ + if ((type_ent==MED_MAILLE)||(type_ent==MED_FACE)||(type_ent==MED_ARETE)) + { + if ((ret = _MEDnomGeometrie(nom_geo,type_geo)) < 0) + return -1; + if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0) + return -1; + } + else + geoid = -1; + + /* + * lecture du Data Set "FAM" + */ + if (geoid == -1) + root = entid; + else + root = geoid; +#if defined(IRIX64)||defined(OSF1) + if ((ret = _MEDdatasetNumLire(root,MED_NOM_FAM,MED_INT64, + MED_NO_INTERLACE,1,MED_ALL, + MED_NOPF,0,MED_NOPG, + (unsigned char *)fam)) < 0) + return -1; +#else + if ((ret = _MEDdatasetNumLire(root,MED_NOM_FAM,MED_INT32, + MED_NO_INTERLACE,1,MED_ALL, + MED_NOPF,0,MED_NOPG, + (unsigned char *)fam)) < 0) + return -1; +#endif + + /* + * On ferme tout + */ + if (geoid != -1) + if ((ret = _MEDdatagroupFermer(geoid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(entid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDfamMaaCr.cxx b/src/MEDWrapper/V2_1/MEDfamMaaCr.cxx new file mode 100644 index 000000000..f7dc6d2b4 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDfamMaaCr.cxx @@ -0,0 +1,71 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include + +namespace med_2_1{ + +med_err +MEDfamMaaCr(med_idt fid,char *maa, + med_int *numfam,med_int *attide, + med_int *attval,char *attdes,int *indatt,char *gro,int *indgro, + med_int nfamilles) +{ + med_err ret; + med_int i; + med_int natt,ngro; + med_int numf; + char nomfam[MED_TAILLE_NOM+1]; + + /* La famille de numero 0 n'a aucun attribut, ni aucun groupe + Les familles de numero > 0 sont des familles de noeuds + Les familles de numero < 0 sont des familles d'elements */ + for (i=0;i 0) + { + strcpy(nomfam,"FAMILLE_NOEUD_"); + sprintf(nomfam,"%s%d",nomfam,numf); + nomfam[MED_TAILLE_NOM] = '\0'; + } + if (numf < 0) + { + strcpy(nomfam,"FAMILLE_ELEMENT_"); + sprintf(nomfam,"%s%d",nomfam,-numf); + nomfam[MED_TAILLE_NOM] = '\0'; + } + natt = *(indatt+i+1) - *(indatt+i); + ngro = (*(indgro+i+1) - *(indgro+i))/MED_TAILLE_LNOM; + if ((ret = MEDfamCr(fid,maa,nomfam,numf, + attide+*(indatt+i), + attval+*(indatt+i), + attdes+*(indatt+i)*MED_TAILLE_DESC,natt, + gro+*(indgro+i),ngro)) < 0) + return -1; + } + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDfamMaaInfo.cxx b/src/MEDWrapper/V2_1/MEDfamMaaInfo.cxx new file mode 100644 index 000000000..9868abfbd --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDfamMaaInfo.cxx @@ -0,0 +1,52 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + + +#include "med.hxx" + +namespace med_2_1{ + +med_err +MEDfamMaaInfo(med_idt fid,char *maa,med_int *nfam,med_int *nattc, + med_int *ngroc) +{ + med_int ret; + med_int i; + + /* Lecture du nombre de familles */ + if ((*nfam = MEDnFam(fid,maa,0,(med_dim_famille)0)) < 0) + return -1; + + /* Lecture des nombres cumules de groupes et d'attributs dans toutes + les familles du maillage */ + *nattc = 0; + *ngroc = 0; + for (i=0;i<*nfam;i++) + { + if ((ret = MEDnFam(fid,maa,i+1,MED_ATTR)) < 0) + return -1; + *nattc += ret; + if ((ret = MEDnFam(fid,maa,i+1,MED_GROUPE)) < 0) + return -1; + *ngroc += ret; + } + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDfamMaaLire.cxx b/src/MEDWrapper/V2_1/MEDfamMaaLire.cxx new file mode 100644 index 000000000..ed3401a9b --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDfamMaaLire.cxx @@ -0,0 +1,50 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +namespace med_2_1{ + +med_err +MEDfamMaaLire(med_idt fid,char *maa,med_int *numfam,med_int *attide, + med_int *attval,char *attdes,int *indatt,char *gro,int *indgro, + med_int nfamilles) +{ + med_err ret; + med_int natt,ngro; + med_int i; + char nom[MED_TAILLE_NOM+1]; + + *indatt = 0; + *indgro = 0; + for (i=0;i + +namespace med_2_1{ + +med_err +MEDfichDesEcr(med_idt fid, char *des, med_mode_acces mode) +{ + med_idt attr; + med_idt root; + med_err ret; + char nom[] = MED_NOM_DESCRIPTEUR; + char chemin[MED_TAILLE_MAA+1]; + + /* + * On inhibe le gestionnaire d'erreur + */ + _MEDmodeErreurVerrouiller(); + + /* + * On ouvre le Data Group racine + * s'il n'existe pas on le cree + */ + strncpy(chemin,MED_MAA,MED_TAILLE_MAA-1); + chemin[MED_TAILLE_MAA-1] = '\0'; + if ((root = _MEDdatagroupOuvrir(fid,chemin)) < 0) + if ((root = _MEDdatagroupCreer(fid,chemin)) < 0) + return -1; + + /* + * On regarde si l'attribut existe + * Si oui on le met a jour en fonction + * du mode d'ouverture, sinon on le cree + */ + + if ((ret = _MEDattrStringEcrire(root,nom,MED_TAILLE_DESC,des,mode)) < 0) + return -1; + + /* + * Fermetures + */ + + if ((ret = _MEDdatagroupFermer(root)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDfichEntete.cxx b/src/MEDWrapper/V2_1/MEDfichEntete.cxx new file mode 100644 index 000000000..b191d3a4a --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDfichEntete.cxx @@ -0,0 +1,79 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include + +namespace med_2_1{ + +med_err +MEDfichEntete(med_idt fid, med_fich_info quoi, char str[]) +{ + med_idt atid, root; + med_err ret; + char locale[MED_TAILLE_DESC+1]; + char chemin[MED_TAILLE_MAA+1]; + + switch (quoi) + { + case MED_HDF_VERSION : + strcpy(str,HDF_VERSION_ACTUELLE); + break; + + case MED_VERSION : + strcpy(str,MED_VERSION_ACTUELLE); + break; + + case MED_FICH_DES : + /* + * On inhibe le gestionnaire d'erreur HDF + */ + _MEDmodeErreurVerrouiller(); + + /* + * On ouvre le Data Group racine + */ + strncpy(chemin,MED_MAA,strlen(MED_MAA)-1); + chemin[MED_TAILLE_MAA-1] = '\0'; + if ((root = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * On regarde si l'attribut existe + * Si non => erreur + * Si oui => on le copie dans str + */ + if ((ret = _MEDattrStringLire(root,MED_NOM_DESCRIPTEUR, + MED_TAILLE_DESC,locale)) < 0) + return -1; + strcpy(str,locale); + + if ((ret == _MEDdatagroupFermer(root)) < 0) + return -1; + + break; + + default : + return -1; + } + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDfichierCreer.cxx b/src/MEDWrapper/V2_1/MEDfichierCreer.cxx new file mode 100644 index 000000000..dd72e8b4b --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDfichierCreer.cxx @@ -0,0 +1,71 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDfichierCreer + * - Description : creation d'un fichier HDF + * - Parametres : + * - nom (IN) : le nom du fichier + * - Resultat : ID du fichier en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_idt +_MEDfichierCreer(char *nom) +{ + med_idt fid,gid; + med_err ret; + med_int majeur = MED_NUM_MAJEUR; + med_int mineur = MED_NUM_MINEUR; + med_int release = MED_NUM_RELEASE; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + if ((fid = H5Fcreate(nom,H5F_ACC_TRUNC, + H5P_DEFAULT,H5P_DEFAULT)) < 0) + return -1; + + if ((gid = _MEDdatagroupCreer(fid,MED_NOM_INFOS)) < 0) + return -1; + + /* Numero de versions de MED */ + if ((ret = _MEDattrEntierEcrire(gid,MED_NOM_MAJEUR,&majeur,MED_REMP)) < 0) + return -1; + + if ((ret = _MEDattrEntierEcrire(gid,MED_NOM_MINEUR,&mineur,MED_REMP)) < 0) + return -1; + + if ((ret = _MEDattrEntierEcrire(gid,MED_NOM_RELEASE,&release,MED_REMP)) < 0) + return -1; + + /* On ferme tout */ + if ((ret = _MEDdatagroupFermer(gid)) < 0) + return -1; + + return fid; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDfichierFermer.cxx b/src/MEDWrapper/V2_1/MEDfichierFermer.cxx new file mode 100644 index 000000000..c0024e544 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDfichierFermer.cxx @@ -0,0 +1,43 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDfichierFermer + * - Description : fermeture d'un fichier HDF + * - Parametres : + * - fid (IN) : ID du fichier + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDfichierFermer(med_idt fid) +{ + med_err ret; + + if ((ret = H5Fclose(fid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDfichierOuvrir.cxx b/src/MEDWrapper/V2_1/MEDfichierOuvrir.cxx new file mode 100644 index 000000000..593fbd675 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDfichierOuvrir.cxx @@ -0,0 +1,60 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDfichierOuvrir + * - Description : ouverture d'un fichier HDF en fonction du mode passe + * en parametre + * - Parametres : + * - nom (IN) : le nom du fichier + * - mode (IN) : mode d'ouverture + * - Resultat : ID du fichier en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_idt +_MEDfichierOuvrir(char *nom,med_mode_acces mode) +{ + med_idt fid; + int hdf_mode; + + switch(mode) + { + case MED_ECRI : + hdf_mode = H5F_ACC_RDWR; + break; + + case MED_LECT : + hdf_mode = H5F_ACC_RDONLY; + break; + + default : + return -1; + } + + if ((fid = H5Fopen(nom,hdf_mode,H5P_DEFAULT)) < 0) + return -1; + + return fid; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDformatConforme.cxx b/src/MEDWrapper/V2_1/MEDformatConforme.cxx new file mode 100644 index 000000000..d5ddea8b3 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDformatConforme.cxx @@ -0,0 +1,40 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +namespace med_2_1{ + +med_err +MEDformatConforme(const char * nomfich) +{ + + /* + * On inhibe le gestionnaire d'erreur + */ + _MEDmodeErreurVerrouiller(); + + + if ( H5Fis_hdf5(nomfich) > 0 ) + return 0; + else + return -1; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDfstring.cxx b/src/MEDWrapper/V2_1/MEDfstring.cxx new file mode 100644 index 000000000..e1bc4faae --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDfstring.cxx @@ -0,0 +1,47 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include + +/* + * Chaine C -> chaine FORTRAN completee par des blancs + */ + +namespace med_2_1{ + +med_err +_MEDfstring(char *chaine, med_int longueur_fixee) +{ + int longueur_reelle, i; + + if (longueur_fixee == 0 ) return 0; + + longueur_reelle = strlen(chaine); + if (longueur_fixee < longueur_reelle) + return -1; + + /* on supprime le caractere de fin de chaine C '\0' + et complete par des blancs */ + for (i=longueur_reelle;i erreur */ + if (_MEDdatagroupOuvrir(root, maillage) > 0) { + return(-1); + }; + + /* Creation du Data Group */ + maaid = _MEDdatagroupCreer(root, maillage); + if (maaid < 0) return(-1); + + /* Creation de l'attribut dimension */ + if (_MEDattrEntierEcrire(maaid, MED_NOM_DIM, &dim, MED_REMP) < 0) { + return(-1); + }; + + /* Creation de l'attribut grille */ + if (_MEDattrEntierEcrire(maaid, MED_NOM_GRD, &typ, MED_REMP) < 0) { + return(-1); + }; + + /* Nettoyages divers */ + if ( _MEDdatagroupFermer(maaid) < 0) return(-1); + if (_MEDdatagroupFermer(root) < 0) return(-1); + return(0); +} + +} diff --git a/src/MEDWrapper/V2_1/MEDgridEcr.cxx b/src/MEDWrapper/V2_1/MEDgridEcr.cxx new file mode 100644 index 000000000..3acc181ee --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDgridEcr.cxx @@ -0,0 +1,109 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med_outils.hxx" +#include "med.hxx" + +namespace med_2_1{ + +med_err +MEDgridEcr(med_idt fid, char *maa, med_int mdim, med_float *coo, med_int nb, med_int dim, med_mode_switch mode_coo, + med_repere repere, char *nomcoo, char *unicoo, med_mode_acces mode ) +{ + /* ecriture des indices */ + + med_idt maaid, noeid, ds; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + med_size dimd[1]; + char *dataset; + med_int type_rep_int; + + /* On inhibe le gestionnaire d'erreur HDF */ + _MEDmodeErreurVerrouiller(); + + /* Si le maillage n'existe pas => erreur */ + strcpy(chemin, MED_MAA); + strcat(chemin, maa); + maaid = _MEDdatagroupOuvrir(fid, chemin); + if (maaid < 0) return(-1); + + /* Si le Data Group "NOE" n'existe pas on le cree */ + if ((noeid = _MEDdatagroupOuvrir(maaid, MED_NOM_NOE)) < 0) { + if ((noeid = _MEDdatagroupCreer(maaid, MED_NOM_NOE)) < 0) { + return(-1); + }; + }; + + switch (dim) { + case 0 : { + dataset = MED_NOM_IN1; + break; + }; + case 1 : { + dataset = MED_NOM_IN2; + break; + }; + case 2 : { + dataset = MED_NOM_IN3; + break; + }; + default : { + return(-1); + }; + }; + + /* Creation du Data Set "IN1" ou "IN2" ou "IN3" */ + dimd[0] = nb; + if (_MEDdatasetNumEcrire(noeid, dataset, MED_REEL64, mode_coo, 1, MED_ALL, MED_NOPF, 0, 0, dimd, (unsigned char*)coo, mode) < 0) { + return(-1); + }; + + /* On re-ouvre le Data Set "IN1" ou "IN2" ou "IN3" pour y placer des attributs */ + if ((ds = _MEDdatasetOuvrir(noeid, dataset)) < 0) { + return(-1); + }; + + /* Attribut NBR (nombre de noeuds) */ + if (_MEDattrEntierEcrire(ds, MED_NOM_NBR, &nb, mode) < 0) { + return(-1); + }; + + /* L'attribut "REP" */ + type_rep_int = (med_int)repere; + if (_MEDattrEntierEcrire(ds, MED_NOM_REP, &type_rep_int, mode) < 0) { + return(-1); + }; + + /* Attribut "NOM" */ + if (_MEDattrStringEcrire(ds, MED_NOM_NOM, mdim*MED_TAILLE_PNOM, nomcoo, mode) < 0) { + return(-1); + }; + + /* Attribut "UNI" */ + if (_MEDattrStringEcrire(ds, MED_NOM_UNI, mdim*MED_TAILLE_PNOM, unicoo, mode) < 0) { + return(-1); + }; + + /* On ferme tout */ + if (_MEDdatasetFermer(ds) < 0) return(-1); + if (_MEDdatagroupFermer(noeid) < 0) return(-1); + if (_MEDdatagroupFermer(maaid) < 0) return(-1); + return(0); +} + +} diff --git a/src/MEDWrapper/V2_1/MEDgridInfo.cxx b/src/MEDWrapper/V2_1/MEDgridInfo.cxx new file mode 100644 index 000000000..43de1b2dd --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDgridInfo.cxx @@ -0,0 +1,60 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDgridInfo(med_idt fid, int indice, med_int *isAGrid, med_grid_type *typ) +{ + int numero; + med_idt maaid; + char maillage[MED_TAILLE_NOM+1]; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + + /* On inhibe le gestionnaire d'erreur */ + _MEDmodeErreurVerrouiller(); + + /* On recupere le nom du groupe de rang "indice" */ + numero = indice-1; + if (_MEDobjetIdentifier(fid, MED_MAA, numero, maillage) < 0) { + return(-1); + }; + + /* On va chercher l'attribut dimension */ + strcpy(chemin, MED_MAA); + strcat(chemin, maillage); + maaid = _MEDdatagroupOuvrir(fid, chemin); + if (maaid < 0) return(-1); + + if (_MEDattrEntierLire(maaid, MED_NOM_GRD, typ) < 0) { + *isAGrid = 0; + } else { + *isAGrid = 1; + }; + + if (_MEDdatagroupFermer(maaid) < 0) return(-1); + return(0); +} + +} diff --git a/src/MEDWrapper/V2_1/MEDgridLire.cxx b/src/MEDWrapper/V2_1/MEDgridLire.cxx new file mode 100644 index 000000000..032266335 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDgridLire.cxx @@ -0,0 +1,85 @@ +#include "med_outils.hxx" +#include "med.hxx" + +namespace med_2_1{ + +med_err +MEDgridLire(med_idt fid, char *maa, med_int mdim, med_float *coo, med_int dim, med_mode_switch mode_coo, + med_repere *repere, char *nomcoo, char *unicoo ) +{ + med_idt maaid, noeid, ds; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + char *dataset; + med_int type_rep_int; + + /* On inhibe le gestionnaire d'erreur */ + _MEDmodeErreurVerrouiller(); + + /* Si le maillage n'existe pas => erreur */ + strcpy(chemin, MED_MAA); + strcat(chemin, maa); + maaid = _MEDdatagroupOuvrir(fid, chemin); + if (maaid < 0) return(-1); + + /* Si le Data Group "NOE" n'existe pas => erreur */ + noeid = _MEDdatagroupOuvrir(maaid, MED_NOM_NOE); + if (noeid < 0) return(-1); + + switch (dim) { + case 0 : { + dataset = MED_NOM_IN1; + break; + }; + case 1 : { + dataset = MED_NOM_IN2; + break; + }; + case 2 : { + dataset = MED_NOM_IN3; + break; + }; + default : { + return(-1); + }; + }; + + /* Lecture du Data Set "IN1" ou "IN2" ou "IN3" */ + if (_MEDdatasetNumLire(noeid, dataset, MED_REEL64, mode_coo, 1, MED_ALL, MED_NOPF, 0, 1, (unsigned char*)coo) < 0) { + return(-1); + }; + + /* On re-ouvre le Data Set precedant pour y lire des attributs */ + ds = _MEDdatasetOuvrir(noeid, dataset); + if (ds < 0) return(-1); + + /* L'attribut "REP" */ + if (_MEDattrEntierLire(ds, MED_NOM_REP, &type_rep_int) < 0) { + return(-1); + } else { + *repere = (med_repere)type_rep_int; + }; + + /* Attribut "NOM" */ + if (_MEDattrStringLire(ds, MED_NOM_NOM, mdim*MED_TAILLE_PNOM, nomcoo) < 0) { + return(-1); + }; + + /* Attribut "UNI" */ + if (_MEDattrStringLire(ds, MED_NOM_UNI, mdim*MED_TAILLE_PNOM, unicoo) < 0) { + return(-1); + }; + + /* On ferme tout */ + if (_MEDdatasetFermer(ds) < 0) { + return(-1); + }; + if (_MEDdatagroupFermer(noeid) < 0) { + return(-1); + }; + if (_MEDdatagroupFermer(maaid) < 0) { + return(-1); + }; + return(0); +} + +} diff --git a/src/MEDWrapper/V2_1/MEDgro2famA.cxx b/src/MEDWrapper/V2_1/MEDgro2famA.cxx new file mode 100644 index 000000000..5838900ea --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDgro2famA.cxx @@ -0,0 +1,291 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + + +#include +#include + +#include "med.hxx" + +/*********************************************************************** + * FONCTION MEDgro2famA + * + * - DESCRIPTION : 1ere etape dans la conversion des groupes de noeuds + * et d'elements en familles MED. + * Calcul des tailles des tableaux que l'on devra allouer pour + * stocker les familles qui seront construites par MEDgro2famB(). + * Les parametres renvoyes sont : + * 1 - le nombre de familles MED a creer (nfamg) + * 2 - le nombre de noms groupes associes a l'ensemble des familles + * MED (nindf) + * Ces parametres doivent permettre a l'appelant de creer les tables + * suivantes : + * 1 - une table des noms des groupes propres a chaque famille, + * de taille : nindf*MED_TAILLE_LNOM+1 + * 2 - une table d'index donnant pour chaque famille son numero d'indice + * dans la table des noms, de taille : nfamg+1 + * 3 - une table destinee a contenir la liste des numeros de familles + * a creer, de taille : nfamg + * + * - PARAMETRES : + * NOM .E/S. TYPE . DESCRIPTION + * ------------------------------------------------------------------- + * nnoe .E . med_int . nombre de noeuds + * nele .E . med_int . nombre d'elements + * numnoe .E . med_int*. numeros des noeuds + * numele .E . med_int*. numeros des elements + * ngn .E . med_int . nombre de groupes de noeuds + * nge .E . med_int . nombre de groupes d'elements + * nindn .E . med_int . nombre d'indices dans la table + * . . . des groupes de noeuds + * ninde .E . med_int . nombre d'indices dans la table + * . . . de groupes d'elements + * indgronoe .E . int* . table index de la table des groupes + * . . . de noeuds + * indgroele .E . int* . table index de la table des groupes + * . . . d'elements + * tabgronoe .E . med_int*. table des groupes de noeuds + * tabgroele .E . med_int*. table des groupes d'elements + * nfamg . S. med_int*. nombre de familles MED a creer + * nidnf . S. med_int*. nombre de noms groupes associes a + * . . . l'ensemble des familles MED + * + * - RESULTAT : 0 si succes, -1 sinon + * + ***********************************************************************/ + +namespace med_2_1{ + +med_err +MEDgro2famA (med_int nnoe,med_int nele,med_int *numnoe,med_int *numele, + med_int ngn,med_int nge,med_int nindn, + med_int ninde,int *indgronoe,int *indgroele,med_int *tabgronoe, + med_int *tabgroele,med_int *nfamg,med_int *nindf) +{ + int i,j,k; + int *famnoe,*famele,*tmp; + int *p; + int flag, num,exist; + int nfamn, nfame; + int fam01 = 0; + int fam02 = 0; + + /* initialisations */ + famnoe = NULL; + famele = NULL; + + *nfamg = 0; + *nindf = 0; + nfamn = 0; + nfame = 0; + + if ((ngn > 0) || (nge > 0)) + { + /* pour chaque noeud : + 1 - on dresse la liste des groupes de noeuds auquel il appartient + 2 - en la comparant avec les listes pre-existantes, on + estime s'il est necessaire de creer une nouvelle famille de noeuds. + Si oui => on incremente le compteur local nfamn (nombre de familles + de noeuds) + on incremente le parametre nindf du nombre de groupes + que devra compter cette famille de noeuds + Si non => on ne fait rien */ + for (i=0;i +#include +#include +#include "med.hxx" + +/*********************************************************************** + * FONCTION MEDgro2famB + * + * - DESCRIPTION : 2eme etape dans la conversion des groupes de noeuds + * et d'elements en familles MED + * Mise a jour des tables suivantes passees en parametres : + * 1 - les nouveaux numeros des familles a creer + * 2 - les nouveaux numeros des familles des elements + * 3 - les nouveaux numeros des familles des noeuds + * 4 - les noms des groupes composant ces familles + * 5 - les index de la table des groupes + * + * - PARAMETRES : + * NOM .E/S. TYPE . DESCRIPTION + * ------------------------------------------------------------------- + * nnoe .E . med_int . nombre de noeuds + * nele .E . med_int . nombre d'elements + * numnoe .E . med_int*. numeros des noeuds + * numele .E . med_int*. numeros des elements + * ngn .E . med_int . nombre de groupes de noeuds + * nge .E . med_int . nombre de groupes d'elements + * nindn .E . med_int . nombre d'indices dans la table + * . . . des groupes de noeuds + * ninde .E . med_int . nombre d'indices dans la table + * . . . de groupes d'elements + * nomgronoe .E . char* . noms des groupes de noeuds + * nomgroele .E . char* . noms des groupes d'elements + * indgronoe .E . int* . table index de la table des groupes + * . . . de noeuds + * indgroele .E . int* . table index de la table des groupes + * . . . d'elements + * tabgronoe .E . int* . table des groupes de noeuds + * tabgroele .E . int* . table des groupes d'elements + * nfamg .E . med_int . nombre de familles MED a creer + * nidnf .E . med_int . nombre de noms groupes associes a + * . . . l'ensemble des familles MED + * newnumfam . S. med_int*. nouveaux numeros de familles + * newnumfamele . S. med_int*. nouveaux numeros de familles des + * . . . elements + * newnumfamnoe . S. med_int*. nouveaux numeros de familles des + * . . . noeuds + * newindfamgro . S. int* . table des index de la table des + * . . . noms de groupes associes aux familles + * newfamgro . . char* . table des noms des groupes des + * . . . familles + * + * - RESULTAT : 0 + * + ***********************************************************************/ + +namespace med_2_1{ + +med_err +MEDgro2famB (med_int nnoe,med_int nele,med_int *numnoe,med_int *numele, + med_int ngn,med_int nge,med_int nindn, + med_int ninde, char *nomgronoe,char *nomgroele, + int *indgronoe,int *indgroele,med_int *tabgronoe, + med_int *tabgroele,med_int nfamg,med_int nindf, + med_int *newnumfam,med_int *newnumfamele, + med_int *newnumfamnoe,int *newindfamgro, + char *newfamgro) +{ + int i,j,k; + + med_int *famnoe, *famele, *tmp; + med_int *p; + med_int num; + int flag,exist; + int nfamn, nfame; + int estfam0 = 1; + int newnumnoe, newnumele; + int tmp1; + int existfam0 = 0; + int ind = 0; + + famnoe = NULL; + famele = NULL; + + nfamn = 0; + nfame = 0; + newnumnoe = 0; + newnumele = 0; + + *newindfamgro = 0; + + if (nfamg > 1) + { + /* pour chaque noeud : + 1 - on dresse la liste des groupes de noeuds auquel il appartient + 2 - en la comparant avec les listes pre-existantes, on + estime s'il est necessaire de creer une nouvelle famille de noeuds. + Si oui => - on cree le numero de famille que l'on reporte + dans newnumfam + - on reporte ce numero dans newnumnoe + - on met a jour la table des noms des groupes des familles + ainsi que sa table d'index + Si non => on ne fait rien + ATTENTION : pour la famille 0, on ne met a jour que les numeros */ + for (i=0;i - on cree le numero de famille que l'on reporte + dans newnumfam + - on reporte ce numero dans newnumele + - on met a jour la table des noms des groupes des familles + ainsi que sa table d'index + Si non => on ne fait rien + ATTENTION : pour la famille 0, on ne met a jour que les numeros */ + for (i=0;i + +namespace med_2_1{ + +med_int +MEDlFichDes(med_idt fid) +{ + med_idt attr, root; + med_err ret=0; + char des[MED_TAILLE_DESC+1]; + med_int longueur=0; + char nom[MED_TAILLE_NOM+1]; + char chemin[MED_TAILLE_MAA+1]; + + /* + * On inhibe le gestionnaire d'erreur HDF + */ + _MEDmodeErreurVerrouiller(); + + /* + * On ouvre le Data Group racine + */ + strncpy(chemin,MED_MAA,MED_TAILLE_MAA-1); + chemin[MED_TAILLE_MAA-1] = '\0'; + if ((root = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * On regarde si l'attribut existe + * Si non => erreur + * Si oui => on retourne sa longueur + */ + strcpy(nom,MED_NOM_DESCRIPTEUR); + + if ((attr = _MEDattrOuvrir(root,nom)) < 0) { + _MEDdatagroupFermer(root); + longueur=0; + return 0; + } + + if ((ret = _MEDattrFermer(attr)) < 0) { + _MEDdatagroupFermer(root); + return -1; + } + + if ((ret = _MEDattrStringLire(root,nom,MED_TAILLE_DESC,des)) < 0) { + _MEDdatagroupFermer(root); + return -1; + } + + longueur = strlen(des); + + /* + * fermetures + */ + if ((ret == _MEDdatagroupFermer(root)) < 0) + return -1; + + return longueur; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDmaaCr.cxx b/src/MEDWrapper/V2_1/MEDmaaCr.cxx new file mode 100644 index 000000000..c4b50b717 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDmaaCr.cxx @@ -0,0 +1,77 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDmaaCr(med_idt fid, char *maillage, med_int dim) +{ + med_idt maaid, root; + char chemin[MED_TAILLE_MAA+1]; + med_err ret; + + /* + * On inhibe le gestionnaire d'erreur + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si la racine n'existe pas on la cree + */ + strncpy(chemin,MED_MAA,strlen(MED_MAA)-1); + chemin[MED_TAILLE_MAA-1] = '\0'; + if ((root = _MEDdatagroupOuvrir(fid,chemin)) < 0) + if ((root = _MEDdatagroupCreer(fid,chemin)) < 0) + return -1; + + /* + * si le maillage existe deja => erreur + */ + if ((maaid = _MEDdatagroupOuvrir(root,maillage)) > 0) + return -1; + + /* + * Creation du Data Group + */ + if ((maaid = _MEDdatagroupCreer(root,maillage)) < 0) + return -1; + + /* + * Creation de l'attribut dimension + */ + if ((ret = _MEDattrEntierEcrire(maaid,MED_NOM_DIM,&dim,MED_REMP)) < 0) + return -1; + + /* + * Nettoyages divers + */ + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(root)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDmaaInfo.cxx b/src/MEDWrapper/V2_1/MEDmaaInfo.cxx new file mode 100644 index 000000000..e2b48a7cb --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDmaaInfo.cxx @@ -0,0 +1,62 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDmaaInfo(med_idt fid, int indice, char *maillage, med_int *dim) +{ + int numero; + med_idt maaid; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + + /* + * On inhibe le gestionnaire d'erreur + */ + _MEDmodeErreurVerrouiller(); + + /* + * On recupere le nom du groupe de rang "indice" + */ + numero = indice-1; + if ((ret = _MEDobjetIdentifier(fid,MED_MAA,numero,maillage)) < 0) + return -1; + + /* + * On va chercher l'attribut dimension + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maillage); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + if ((ret = _MEDattrEntierLire(maaid,MED_NOM_DIM,dim)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDmodeErreurVerrouiller.cxx b/src/MEDWrapper/V2_1/MEDmodeErreurVerrouiller.cxx new file mode 100644 index 000000000..aa4eb0882 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDmodeErreurVerrouiller.cxx @@ -0,0 +1,37 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDmodeErreurVerrouiller + * - Description : inhibe le mode erreur HDF5 + * - Parametres : aucun + * - Resultat : aucun + */ + +namespace med_2_1{ + +void +_MEDmodeErreurVerrouiller() +{ + H5Eset_auto(NULL,NULL); +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnChamp.cxx b/src/MEDWrapper/V2_1/MEDnChamp.cxx new file mode 100644 index 000000000..55347ba5f --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnChamp.cxx @@ -0,0 +1,87 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include +#include +#include "med_outils.hxx" + +namespace med_2_1{ + +med_int +MEDnChamp(med_idt fid, int indice) +{ + int n1; + med_int n2; + med_idt datagroup; + med_err ret; + char nomdatagroup[MED_TAILLE_NOM+1]; + int num; + char chemin[MED_TAILLE_CHA+MED_TAILLE_NOM+1]; + + if (indice < 0) + return -1; + + /* + * On inhibe le gestionnaire d'erreur HDF + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le Data Group cha n'existe pas et indice == 0 => 0 + * sinon erreur => erreur + */ + strcpy(chemin,MED_CHA); + + /* + * Si indice == 0 => nombre de champs + */ + if (indice == 0) + { + n1 = 0; + _MEDnObjets(fid,chemin,&n1); + n2 = n1; + } + + /* + * Si indice > 0 => nbre de composants + */ + if (indice > 0) + { + /* + * On recupere le nom du champ + */ + num = indice-1; + if ((ret = _MEDobjetIdentifier(fid,chemin,num,nomdatagroup)) < 0) + return -1; + strcat(chemin,nomdatagroup); + /* + * On recupere le nombre de composants + */ + if ((datagroup = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NCO,&n2)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(datagroup)) < 0) + return -1; + } + + return n2; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnCorres.cxx b/src/MEDWrapper/V2_1/MEDnCorres.cxx new file mode 100644 index 000000000..10b583021 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnCorres.cxx @@ -0,0 +1,83 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_int +MEDnCorres(med_idt fid,char *maa,char *eq,med_entite_maillage typ_ent, + med_geometrie_element typ_geo) +{ + med_idt eqid, datagroup; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_EQS+2*MED_TAILLE_NOM+1]; + char nomdatagroup[MED_TAILLE_NOM+1]; + char tmp[MED_TAILLE_NOM_ENTITE+1]; + med_int n; + + if (typ_geo == MED_TETRA4 || typ_geo == MED_TETRA10 || + typ_geo == MED_HEXA8 || typ_geo == MED_HEXA20 || + typ_geo == MED_PENTA6 || typ_geo == MED_PENTA15 || + typ_geo == MED_PYRA5 || typ_geo == MED_PYRA13) + return -1; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le Data Group de "eq" n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + strcat(chemin,MED_EQS); + strcat(chemin,eq); + if ((eqid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + if ((ret = _MEDnomEntite(nomdatagroup,typ_ent)) < 0) + return -1; + if ((typ_ent != MED_NOEUD)) + { + if ((ret = _MEDnomGeometrie(tmp,typ_geo)) < 0) + return -1; + strcat(nomdatagroup,"."); + strcat(nomdatagroup,tmp); + } + if ((datagroup = _MEDdatagroupOuvrir(eqid,nomdatagroup)) < 0) + return 0; + if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NBR,&n)) < 0) + return -1; + + /* + * On ferme tout + */ + if ((ret = _MEDdatagroupFermer(datagroup)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(eqid)) < 0) + return -1; + + return n; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnEntMaa.cxx b/src/MEDWrapper/V2_1/MEDnEntMaa.cxx new file mode 100644 index 000000000..7f9cfbdc4 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnEntMaa.cxx @@ -0,0 +1,111 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_int +MEDnEntMaa(med_idt fid, char *maa, med_table quoi, med_entite_maillage type_ent, + med_geometrie_element type_geo, med_connectivite type_conn) +{ + med_idt root, maaid, entid,geoid, dataset=0; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + char nom_ent[MED_TAILLE_NOM_ENTITE+1]; + char nom_geo[MED_TAILLE_NOM_ENTITE+1]; + char nom_dataset[MED_TAILLE_NOM_ENTITE+1]; + med_int res = 0; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * On met a jour le nom du Data Group representant + * le type des entites + */ + if ((ret = _MEDnomEntite(nom_ent,type_ent)) < 0) + return -1; + + /* + * Si le Data Group des entites n'existe pas => res = 0 + */ + entid = _MEDdatagroupOuvrir(maaid,nom_ent); + + /* + * Pour les mailles, les faces et le aretes + * si le Data Group du type geometrique n'existe pas => res = 0 + */ + if ((type_ent==MED_MAILLE)||(type_ent==MED_FACE)||(type_ent==MED_ARETE)) + { + if ((ret = _MEDnomGeometrie(nom_geo,type_geo)) < 0) + return -1; + geoid = _MEDdatagroupOuvrir(entid,nom_geo); + } + else + geoid = -1; + + /* + * Ouverture du Data Set renvoye par _MEDnomDataset() + * S'il n'existe pas => erreur + * Sinon lecture de l'attribut NBR + */ + if (geoid == -1) + root = entid; + else + root = geoid; + if ((ret = _MEDnomDataset(nom_dataset,quoi,type_conn)) < 0) + return -1; + dataset = _MEDdatasetOuvrir(root,nom_dataset); + if (dataset > 0) + if ((ret = _MEDattrEntierLire(dataset,MED_NOM_NBR,&res)) < 0) + return -1; + + /* + * On ferme tout + */ + if (dataset > 0) + if ((ret = _MEDdatasetFermer(dataset)) < 0) + return -1; + if (geoid > 0) + if ((ret = _MEDdatagroupFermer(geoid)) < 0) + return -1; + if (entid > 0) + if ((ret = _MEDdatagroupFermer(entid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return res; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnEntites.cxx b/src/MEDWrapper/V2_1/MEDnEntites.cxx new file mode 100644 index 000000000..b5b32c468 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnEntites.cxx @@ -0,0 +1,69 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" + +namespace med_2_1{ + +med_int +MEDnEntites(med_idt fid,char *maa,med_entite_maillage typ_ent, + med_connectivite typ_con) +{ + med_int total = 0; + int i; + med_geometrie_element typ_mai[MED_NBR_GEOMETRIE_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_geometrie_element typ_fac[MED_NBR_GEOMETRIE_FACE] = {MED_TRIA3,MED_TRIA6, + MED_QUAD4,MED_QUAD8}; + med_geometrie_element typ_are[MED_NBR_GEOMETRIE_ARETE] = {MED_SEG2,MED_SEG3}; + + switch (typ_ent) + { + case MED_MAILLE : + for (i=0;i +#include + +namespace med_2_1{ + +med_int +MEDnEquiv(med_idt fid, char *maa) +{ + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+MED_TAILLE_EQS+1]; + int n; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + strcat(chemin,MED_EQS); + n = 0; + _MEDnObjets(fid,chemin,&n); + + return (med_int) n; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnFam.cxx b/src/MEDWrapper/V2_1/MEDnFam.cxx new file mode 100644 index 000000000..3ac75795f --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnFam.cxx @@ -0,0 +1,108 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_int +MEDnFam(med_idt fid,char *maa, int indice, med_dim_famille quoi) +{ + med_idt datagroup,famid; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_FAS+2*MED_TAILLE_NOM+1]; + med_int n; + int n_tmp; + int num; + char famille[MED_TAILLE_NOM+1]; + + + /* + * On inhibe le gestionnaire d'erreur HDF + */ + _MEDmodeErreurVerrouiller(); + + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + strcat(chemin,MED_FAS); + if (indice == 0) + { + n_tmp = 0; + _MEDnObjets(fid,chemin,&n_tmp); + n = (med_int ) n_tmp; + } + else + { + /* + * On recupere le nom de la famille + */ + num = indice - 1; + if ((ret = _MEDobjetIdentifier(fid,chemin,num, + famille)) < 0) + return -1; + + /* + * Si le Data Group de la famille n'existe pas => erreur + */ + strcat(chemin,famille); + if ((famid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + switch (quoi) + { + case MED_GROUPE : + if ((datagroup = _MEDdatagroupOuvrir(famid,MED_NOM_GRO)) < 0) + n = 0; + else + { + if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NBR,&n)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(datagroup)) < 0) + return -1; + } + break; + + case MED_ATTR : + if ((datagroup = _MEDdatagroupOuvrir(famid,MED_NOM_ATT)) < 0) + n = 0; + else + { + if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NBR,&n)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(datagroup)) < 0) + return -1; + } + break; + + default : + return -1; + } + + if ((ret = _MEDdatagroupFermer(famid)) < 0) + return -1; + + } + + return (med_int) n; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnGrid.cxx b/src/MEDWrapper/V2_1/MEDnGrid.cxx new file mode 100644 index 000000000..607888cf2 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnGrid.cxx @@ -0,0 +1,114 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +namespace med_2_1{ + +med_int +MEDnGrid(med_idt fid, char *maa, med_grid n) +{ + med_idt maaid, entid, geoid, dataset; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + char nom_ent[MED_TAILLE_NOM_ENTITE+1]; + char *nom_dataset; + med_int res = (-1); + + /* On inhibe le gestionnaire d'erreur HDF 5 */ + _MEDmodeErreurVerrouiller(); + + /* Si le maillage n'existe pas => erreur */ + strcpy(chemin, MED_MAA); + strcat(chemin, maa); + maaid = _MEDdatagroupOuvrir(fid, chemin); + if (maaid < 0) return(-1); + + switch (n) { + case MED_FAM_NOEUD : { + nom_dataset = MED_NOM_FAM; + if (_MEDnomEntite(nom_ent, MED_NOEUD) < 0) return(-1); + entid = _MEDdatagroupOuvrir(maaid, nom_ent); + break; + }; + case MED_FAM_ARETE : { + nom_dataset = MED_NOM_FAM; + if (_MEDnomEntite(nom_ent, MED_ARETE) < 0) return(-1); + geoid = _MEDdatagroupOuvrir(maaid, nom_ent); + if (geoid < 0) return(-1); + if (_MEDnomGeometrie(nom_ent, MED_SEG2) < 0) return(-1); + entid = _MEDdatagroupOuvrir(geoid, nom_ent); + break; + }; + case MED_FAM_FACE : { + nom_dataset = MED_NOM_FAM; + if (_MEDnomEntite(nom_ent, MED_FACE) < 0) return(-1); + geoid = _MEDdatagroupOuvrir(maaid, nom_ent); + if (geoid < 0) return(-1); + if (_MEDnomGeometrie(nom_ent, MED_QUAD4) < 0) return(-1); + entid = _MEDdatagroupOuvrir(geoid, nom_ent); + break; + }; + case MED_FAM_MAILLE : { + nom_dataset = MED_NOM_FAM; + if (_MEDnomEntite(nom_ent, MED_MAILLE) < 0) return(-1); + geoid = _MEDdatagroupOuvrir(maaid, nom_ent); + if (geoid < 0) return(-1); + if (_MEDnomGeometrie(nom_ent, MED_HEXA8) < 0) return(-1); + entid = _MEDdatagroupOuvrir(geoid, nom_ent); + break; + }; + case MED_GRID_NOEUD : { + nom_dataset = MED_NOM_BOF; + entid = _MEDdatagroupOuvrir(maaid, MED_NOM_NOE); + break; + }; + case MED_GRID_D1 : { + nom_dataset = MED_NOM_IN1; + entid = _MEDdatagroupOuvrir(maaid, MED_NOM_NOE); + break; + }; + case MED_GRID_D2 : { + nom_dataset = MED_NOM_IN2; + entid = _MEDdatagroupOuvrir(maaid, MED_NOM_NOE); + break; + }; + case MED_GRID_D3 : { + nom_dataset = MED_NOM_IN3; + entid = _MEDdatagroupOuvrir(maaid, MED_NOM_NOE); + break; + }; + default : { + return(-1); + }; + }; + + if (entid < 0) return(-1); + dataset = _MEDdatasetOuvrir(entid, nom_dataset); + if (dataset < 0) return(-1); + if (_MEDattrEntierLire(dataset, MED_NOM_NBR, &res) < 0) return(-1); + + /* On ferme tout */ + if (_MEDdatasetFermer(dataset) < 0) return(-1); + if (_MEDdatagroupFermer(entid) < 0) return(-1); + if (_MEDdatagroupFermer(maaid) < 0) return(-1); + + return(res); +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnMaa.cxx b/src/MEDWrapper/V2_1/MEDnMaa.cxx new file mode 100644 index 000000000..a7a8124b6 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnMaa.cxx @@ -0,0 +1,39 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include + +namespace med_2_1{ + +med_int +MEDnMaa(med_idt fid) +{ + int n; + + _MEDmodeErreurVerrouiller(); + + n = 0; + _MEDnObjets(fid,MED_MAA,&n); + + return (med_int) n; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnObjets.cxx b/src/MEDWrapper/V2_1/MEDnObjets.cxx new file mode 100644 index 000000000..6720f95f3 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnObjets.cxx @@ -0,0 +1,46 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDnObjets + * - Description : indique le nombre d'objets HDF contenu dans le + * datagroup passe en argument + * - Parametres : + * - fid (IN) : l'ID du fichier HDF + * - chemin (IN) : chemin d'acces au datagroup + * - n (OUT) : le nombre recherche + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDnObjets(med_idt fid,char *chemin,int *n) +{ + int idx; + + if ((idx = H5Giterate(fid,chemin,NULL,_MEDindiceNum,(void *)n)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnPasdetemps.cxx b/src/MEDWrapper/V2_1/MEDnPasdetemps.cxx new file mode 100644 index 000000000..6cad0ba8e --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnPasdetemps.cxx @@ -0,0 +1,73 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +/* + * Nombre de Couple (PDT,NOR) pour le champ + */ + +namespace med_2_1{ + +med_int +MEDnPasdetemps(med_idt fid,char *cha,med_entite_maillage type_ent, + med_geometrie_element type_geo) + +{ + med_err ret; + int n1; + char nomdatagroup1[MED_TAILLE_NOM+1]; + char tmp1 [MED_TAILLE_NOM_ENTITE+1]; + char chemin [MED_TAILLE_CHA+(MED_TAILLE_NOM+1)+MED_TAILLE_NOM+1]; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Creation du chemin d'accès aux différents (PDT,NOR) pour les différents [.] + */ + strcpy(chemin,MED_CHA); + strcat(chemin,cha); + strcat(chemin,"/"); + + if ((ret = _MEDnomEntite(nomdatagroup1,type_ent)) < 0) + return -1; + if ((type_ent != MED_NOEUD)) + { + if ((ret = _MEDnomGeometrie(tmp1,type_geo)) < 0) + return -1; + strcat(nomdatagroup1,"."); + strcat(nomdatagroup1,tmp1); + } + strcat(chemin,nomdatagroup1); + + n1 =0; + _MEDnObjets(fid,chemin,&n1); + + return (med_int) n1; + +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnProfil.cxx b/src/MEDWrapper/V2_1/MEDnProfil.cxx new file mode 100644 index 000000000..5dcb6482f --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnProfil.cxx @@ -0,0 +1,38 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +namespace med_2_1{ + +med_int +MEDnProfil(med_idt fid) +{ + int n; + med_err ret; + + _MEDmodeErreurVerrouiller(); + + n = 0; + _MEDnObjets(fid,MED_PROFILS,&n); + + return (med_int) n; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnVal.cxx b/src/MEDWrapper/V2_1/MEDnVal.cxx new file mode 100644 index 000000000..010c82636 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnVal.cxx @@ -0,0 +1,83 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include +#include +#include "med_outils.hxx" + +namespace med_2_1{ + +med_int +MEDnVal(med_idt fid, char *champ, med_entite_maillage type_ent, + med_geometrie_element type_geo,med_int numdt, med_int numo) +{ + med_int n; + med_idt datagroup; + med_err ret; + char nomdatagroup1[2*MED_TAILLE_NOM_ENTITE+2],nomdatagroup2[2*MED_MAX_PARA+1]; + char tmp1 [MED_TAILLE_NOM_ENTITE+1]; + char chemin [MED_TAILLE_CHA+(MED_TAILLE_NOM+1)+(2*MED_TAILLE_NOM_ENTITE+2)+(2*MED_MAX_PARA)+1+100]; + + /* + * On inhibe le gestionnaire d'erreur HDF + */ + _MEDmodeErreurVerrouiller(); + + /* + * On cree le chemin d'accès + */ + strcpy(chemin,MED_CHA); + strcat(chemin,champ); + strcat(chemin,"/"); + + /* On cree le nom du datagroup de niveau 1 */ + if ((ret = _MEDnomEntite(nomdatagroup1,type_ent)) < 0) + return -1; + if ((type_ent != MED_NOEUD)) + { + if ((ret = _MEDnomGeometrie(tmp1,type_geo)) < 0) + return -1; + strcat(nomdatagroup1,"."); + strcat(nomdatagroup1,tmp1); + } + strcat(chemin,nomdatagroup1); + strcat(chemin,"/"); + + /* Creation du datagroup de niveau 2 . */ + sprintf(nomdatagroup2,"%*li%*li",MED_MAX_PARA,(long ) numdt,MED_MAX_PARA,(long ) numo); + strcat(chemin,nomdatagroup2); + + /* + * Acces au champ + */ + if ((datagroup = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return 0; + if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NBR,&n)) < 0) + return -1; + + /* + * fermetures + */ + if ((ret = _MEDdatagroupFermer(datagroup)) < 0) + return -1; + + return n; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnValProfil.cxx b/src/MEDWrapper/V2_1/MEDnValProfil.cxx new file mode 100644 index 000000000..7c14cf2ed --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnValProfil.cxx @@ -0,0 +1,60 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_int +MEDnValProfil(med_idt fid, char *nom) +{ + med_int n = 0; + med_idt pid; + char chemin[MED_TAILLE_PROFILS+MED_TAILLE_NOM+1]; + med_err ret; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * ouverture du groupe /PROFILS/"nom" + */ + strcpy(chemin,MED_PROFILS); + strcat(chemin,nom); + if ((pid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + if ((ret = _MEDattrEntierLire(pid,MED_NOM_N,&n)) < 0) + return ret; + + /* + * On ferme tout + */ + if ((ret = _MEDdatagroupFermer(pid)) < 0) + return -1; + + return n; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnbnoisEcr.cxx b/src/MEDWrapper/V2_1/MEDnbnoisEcr.cxx new file mode 100644 index 000000000..3c287ce7f --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnbnoisEcr.cxx @@ -0,0 +1,62 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDnbnoisEcr(med_idt fid, char *nom_maillage,med_int n) +{ + med_idt maaid; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + med_err ret; + + /* + * On inhibe le gestionnaire d'erreur HDF + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,nom_maillage); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * Creation de l'attribut "Nombre de Noeuds Isoles" + */ + if ((ret = _MEDattrEntierEcrire(maaid,MED_NOM_NNI,&n,MED_REMP)) < 0) + return -1; + + /* + * Fermetures des objets + */ + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnbnoisLire.cxx b/src/MEDWrapper/V2_1/MEDnbnoisLire.cxx new file mode 100644 index 000000000..363d66ffe --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnbnoisLire.cxx @@ -0,0 +1,63 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_int +MEDnbnoisLire(med_idt fid,char *nom_maillage) +{ + med_idt maaid; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + med_int n; + + /* + * On inhibe le gestionnaire d'erreur + */ + _MEDmodeErreurVerrouiller(); + + /* + * On regarde si le maillage existe => erreur si non + */ + strcpy(chemin,MED_MAA); + strcat(chemin,nom_maillage); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * On va lire l'attribut "NNI" + */ + if ((ret = _MEDattrEntierLire(maaid,MED_NOM_NNI,&n)) < 0) + return -1; + + /* + * Fermetures des objets HDF + */ + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return n; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnbnomaEcr.cxx b/src/MEDWrapper/V2_1/MEDnbnomaEcr.cxx new file mode 100644 index 000000000..2d635253f --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnbnomaEcr.cxx @@ -0,0 +1,62 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDnbnomaEcr(med_idt fid, char *nom_maillage,med_int n) +{ + med_idt maaid; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + med_err ret; + + /* + * On inhibe le gestionnaire d'erreur + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,nom_maillage); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * Creation de l'attribut "Nombre de Noeuds Max par maille" + */ + if ((ret = _MEDattrEntierEcrire(maaid,MED_NOM_NNM,&n,MED_REMP)) < 0) + return -1; + + /* + * Nettoyages divers + */ + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnbnomaLire.cxx b/src/MEDWrapper/V2_1/MEDnbnomaLire.cxx new file mode 100644 index 000000000..b018a0aa5 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnbnomaLire.cxx @@ -0,0 +1,63 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_int +MEDnbnomaLire(med_idt fid,char *nom_maillage) +{ + med_idt maaid; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + med_int n; + + /* + * On inhibe le gestionnaire d'erreur HDF + */ + _MEDmodeErreurVerrouiller(); + + /* + * On regarde si le maillage existe => erreur si non + */ + strcpy(chemin,MED_MAA); + strcat(chemin,nom_maillage); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * On va lire l'attribut "NNM" + */ + if ((ret = _MEDattrEntierLire(maaid,MED_NOM_NNM,&n)) < 0) + return -1; + + /* + * Fermetures des objets HDF + */ + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return n; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnbnosoEcr.cxx b/src/MEDWrapper/V2_1/MEDnbnosoEcr.cxx new file mode 100644 index 000000000..453ebe29f --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnbnosoEcr.cxx @@ -0,0 +1,62 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDnbnosoEcr(med_idt fid, char *nom_maillage,med_int n) +{ + med_idt maaid; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + med_err ret; + + /* + * On inhibe le gestionnaire d'erreur HDF + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,nom_maillage); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * Creation de l'attribut "Nombre de Noeuds Sommets" + */ + if ((ret = _MEDattrEntierEcrire(maaid,MED_NOM_NNS,&n,MED_REMP)) < 0) + return -1; + + /* + * Fermetures + */ + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnbnosoLire.cxx b/src/MEDWrapper/V2_1/MEDnbnosoLire.cxx new file mode 100644 index 000000000..7a1b67270 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnbnosoLire.cxx @@ -0,0 +1,63 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med_outils.hxx" +#include "med.hxx" + +#include +#include + +namespace med_2_1{ + +med_int +MEDnbnosoLire(med_idt fid,char *nom_maillage) +{ + med_idt maaid; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + med_int n; + + /* + * On inhibe le gestionnaire d'erreur + */ + _MEDmodeErreurVerrouiller(); + + /* + * On regarde si le maillage existe => erreur si non + */ + strcpy(chemin,MED_MAA); + strcat(chemin,nom_maillage); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * On va lire l'attribut "NNS" + */ + if ((ret = _MEDattrEntierLire(maaid,MED_NOM_NNS,&n)) < 0) + return -1; + + /* + * Fermetures des objets HDF + */ + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return n; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnoeudsEcr.cxx b/src/MEDWrapper/V2_1/MEDnoeudsEcr.cxx new file mode 100644 index 000000000..808d25864 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnoeudsEcr.cxx @@ -0,0 +1,55 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" + +namespace med_2_1{ + +med_err +MEDnoeudsEcr(med_idt fid,char *maa,med_int mdim,med_float *coord, + med_mode_switch mode_coo, + med_repere repere,char *nomcoo, char *unicoo,char *nom, + med_booleen inom,med_int *num,med_booleen inum,med_int *fam, + med_int nnoeuds,med_mode_acces mode) +{ + med_err ret; + + /* ecriture des coordonnees */ + if ((ret = MEDcoordEcr(fid,maa,mdim,coord,mode_coo, + nnoeuds,mode,repere,nomcoo, + unicoo)) < 0) + return -1; + + /* ecriture des noms (facultatifs) */ + if (inom == MED_VRAI) + if ((ret = MEDnomEcr(fid,maa,nom,nnoeuds,mode,MED_NOEUD,MED_POINT1)) < 0) + return -1; + + /* ecriture des numeros (facultatifs) */ + if (inum == MED_VRAI) + if ((ret = MEDnumEcr(fid,maa,num,nnoeuds,mode,MED_NOEUD,MED_POINT1)) < 0) + return -1; + + /* ecriture des numeros de familles */ + if ((ret = MEDfamEcr(fid,maa,fam,nnoeuds,mode,MED_NOEUD,MED_POINT1)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnoeudsLire.cxx b/src/MEDWrapper/V2_1/MEDnoeudsLire.cxx new file mode 100644 index 000000000..68014ba9a --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnoeudsLire.cxx @@ -0,0 +1,57 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + + +#include "med.hxx" + +namespace med_2_1{ + +med_err +MEDnoeudsLire(med_idt fid,char *maa,med_int mdim, med_float *coord, + med_mode_switch mode_coo, + med_repere *repere,char *nomcoo, char *unicoo,char *nom, + med_booleen *inom,med_int *num,med_booleen *inum,med_int *fam, + med_int nnoeuds) +{ + med_err ret; + + /* lecture des coordonnees */ + if ((ret = MEDcoordLire(fid,maa,mdim,coord,mode_coo,MED_ALL,0,MED_NOPF,repere,nomcoo, + unicoo)) < 0) + return -1; + + /* lecture des noms (facultatifs) */ + if ((ret = MEDnomLire(fid,maa,nom,nnoeuds,MED_NOEUD,MED_POINT1)) < 0) + *inom = MED_FAUX; + else + *inom = MED_VRAI; + + /* lecture des numeros (facultatifs) */ + if ((ret = MEDnumLire(fid,maa,num,nnoeuds,MED_NOEUD,MED_POINT1)) < 0) + *inum = MED_FAUX; + else + *inum = MED_VRAI; + + /* lecture des numeros de familles */ + if ((ret = MEDfamLire(fid,maa,fam,nnoeuds,MED_NOEUD,MED_POINT1)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnomDataset.cxx b/src/MEDWrapper/V2_1/MEDnomDataset.cxx new file mode 100644 index 000000000..fe72b24bb --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnomDataset.cxx @@ -0,0 +1,79 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDnomDataset + * - Description : fournit un nom de dataset + * - Parametres : + * - nom_dataset (OUT) : le nom du data set + * - quoi (IN) : le type de table MED + * - type_conn (IN) : le type de connectivite + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDnomDataset(char *nom_dataset,med_table quoi,med_connectivite type_conn) +{ + switch(quoi) + { + case MED_COOR : + strcpy(nom_dataset,MED_NOM_COO); + break; + + case MED_CONN : + switch(type_conn) + { + case MED_NOD : + strcpy(nom_dataset,MED_NOM_NOD); + break; + + case MED_DESC : + strcpy(nom_dataset,MED_NOM_DES); + break; + + default : + return -1; + } + break; + + case MED_NOM : + strcpy(nom_dataset,MED_NOM_NOM); + break; + + case MED_NUM : + strcpy(nom_dataset,MED_NOM_NUM); + break; + + case MED_FAM : + strcpy(nom_dataset,MED_NOM_FAM); + break; + + default : + return -1; + } + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnomEcr.cxx b/src/MEDWrapper/V2_1/MEDnomEcr.cxx new file mode 100644 index 000000000..a71cf4757 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnomEcr.cxx @@ -0,0 +1,116 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDnomEcr(med_idt fid,char *maa, char *nom, med_int n, med_mode_acces mode, + med_entite_maillage type_ent,med_geometrie_element type_geo) +{ + med_idt root, maaid, entid, geoid, dataset; + med_err ret; + med_size dimd[1]; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + char nom_ent[MED_TAILLE_NOM_ENTITE+1]; + char nom_geo[MED_TAILLE_NOM_ENTITE+1]; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * On met a jour le nom du Data Group representant + * le type des entites + */ + if ((ret = _MEDnomEntite(nom_ent,type_ent)) < 0) + return -1; + + /* + * Si le Data Group des entites n'existe pas on le cree + */ + if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0) + if ((entid = _MEDdatagroupCreer(maaid,nom_ent)) < 0) + return -1; + + /* + * Pour les mailles, les faces et le aretes, on cree + * s'il n'existe pas le Data Group du type geometrique + */ + if ((type_ent==MED_MAILLE)||(type_ent==MED_FACE)||(type_ent==MED_ARETE)) + { + if ((ret = _MEDnomGeometrie(nom_geo,type_geo)) < 0) + return -1; + + if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0) + if ((geoid = _MEDdatagroupCreer(entid,nom_geo)) < 0) + return -1; + } + else + geoid = -1; + + /* + * Creation du Data Set "NOM" + */ + if (geoid == -1) + root = entid; + else + root = geoid; + dimd[0] = n*MED_TAILLE_PNOM+1; + if ((ret = _MEDdatasetStringEcrire(root,MED_NOM_NOM,dimd,nom,mode)) < 0) + return -1; + + /* + * Attribut NBR (nombre de noeuds) + */ + if ((dataset = _MEDdatasetOuvrir(root,MED_NOM_NOM)) < 0) + return -1; + if ((ret = _MEDattrEntierEcrire(dataset,MED_NOM_NBR,&n,mode)) < 0) + return -1; + + /* + * On ferme tout + */ + if ((ret = _MEDdatasetFermer(dataset)) < 0) + return -1; + if (geoid > 0) + if ((ret = _MEDdatagroupFermer(geoid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(entid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnomEntite.cxx b/src/MEDWrapper/V2_1/MEDnomEntite.cxx new file mode 100644 index 000000000..b5b4350fb --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnomEntite.cxx @@ -0,0 +1,60 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDnomEntite + * - Description : fournit le nom associe a un type d'entite MED + * - Parametres : + * - nom_ent (OUT) : le nom de l'entite + * - type_ent (IN) : le type de l'entite + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDnomEntite(char *nom_ent,med_entite_maillage type_ent) +{ + switch(type_ent) + { + case MED_NOEUD : + strcpy(nom_ent,MED_NOM_NOE); + break; + + case MED_MAILLE : + strcpy(nom_ent,MED_NOM_MAI); + break; + + case MED_FACE : + strcpy(nom_ent,MED_NOM_FAC); + break; + + case MED_ARETE : + strcpy(nom_ent,MED_NOM_ARE); + break; + + default : + return -1; + } + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnomGeometrie.cxx b/src/MEDWrapper/V2_1/MEDnomGeometrie.cxx new file mode 100644 index 000000000..3cbc6bbe0 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnomGeometrie.cxx @@ -0,0 +1,106 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDnomGeometrie + * - Description : fournit le nom de l'element geometrique associe + * au type geometrique MED + * - Parametres : + * - nom_geo (OUT) : le nom de l'element + * - type_geo (IN) : le type de l'element + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDnomGeometrie(char *nom_geo,med_geometrie_element type_geo) +{ + switch (type_geo) + { + case MED_POINT1 : + strcpy(nom_geo,MED_NOM_PO1); + break; + + case MED_SEG2 : + strcpy(nom_geo,MED_NOM_SE2); + break; + + case MED_SEG3 : + strcpy(nom_geo,MED_NOM_SE3); + break; + + case MED_TRIA3 : + strcpy(nom_geo,MED_NOM_TR3); + break; + + case MED_TRIA6 : + strcpy(nom_geo,MED_NOM_TR6); + break; + + case MED_QUAD4 : + strcpy(nom_geo,MED_NOM_QU4); + break; + + case MED_QUAD8 : + strcpy(nom_geo,MED_NOM_QU8); + break; + + case MED_TETRA4 : + strcpy(nom_geo,MED_NOM_TE4); + break; + + case MED_TETRA10 : + strcpy(nom_geo,MED_NOM_T10); + break; + + case MED_HEXA8 : + strcpy(nom_geo,MED_NOM_HE8); + break; + + case MED_HEXA20 : + strcpy(nom_geo,MED_NOM_H20); + break; + + case MED_PENTA6 : + strcpy(nom_geo,MED_NOM_PE6); + break; + + case MED_PENTA15 : + strcpy(nom_geo,MED_NOM_P15); + break; + + case MED_PYRA5 : + strcpy(nom_geo,MED_NOM_PY5); + break; + + case MED_PYRA13 : + strcpy(nom_geo,MED_NOM_P13); + break; + + default : + return -1; + } + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnomLire.cxx b/src/MEDWrapper/V2_1/MEDnomLire.cxx new file mode 100644 index 000000000..4ec85b304 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnomLire.cxx @@ -0,0 +1,101 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDnomLire(med_idt fid,char *maa, char *nom, med_int n, + med_entite_maillage type_ent,med_geometrie_element type_geo) +{ + med_idt root, maaid, entid, geoid; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + char nom_ent[MED_TAILLE_NOM_ENTITE+1]; + char nom_geo[MED_TAILLE_NOM_ENTITE+1]; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * On met a jour le nom du Data Group representant + * le type des entites + */ + if ((ret = _MEDnomEntite(nom_ent,type_ent)) < 0) + return -1; + + /* + * Si le Data Group des entites n'existe pas => erreur + */ + if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0) + return -1; + + /* + * Pour les mailles, les faces et le aretes, + * on ouvre le Data Group du type geometrique + */ + if ((type_ent==MED_MAILLE)||(type_ent==MED_FACE)||(type_ent==MED_ARETE)) + { + if ((ret = _MEDnomGeometrie(nom_geo,type_geo)) < 0) + return -1; + if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0) + return -1; + } + else + geoid = -1; + + /* + * lecture du Data Set "NOM" + */ + if (geoid == -1) + root = entid; + else + root = geoid; + if ((ret = _MEDdatasetStringLire(root,MED_NOM_NOM,nom)) < 0) + return -1; + + /* + * On ferme tout + */ + if (geoid > 0) + if ((ret = _MEDdatagroupFermer(geoid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(entid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnumEcr.cxx b/src/MEDWrapper/V2_1/MEDnumEcr.cxx new file mode 100644 index 000000000..d72b6ce9f --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnumEcr.cxx @@ -0,0 +1,123 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDnumEcr(med_idt fid,char *maa, med_int *num, med_int n, med_mode_acces mode, + med_entite_maillage type_ent,med_geometrie_element type_geo) +{ + med_idt root, maaid, entid, geoid, dataset; + med_err ret; + med_size dimd[1]; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + char nom_ent[MED_TAILLE_NOM_ENTITE+1]; + char nom_geo[MED_TAILLE_NOM_ENTITE+1]; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * On met a jour le nom du Data Group representant + * le type des entites + */ + if ((ret = _MEDnomEntite(nom_ent,type_ent)) < 0) + return -1; + + /* + * Si le Data Group des entites n'existe pas on le cree + */ + if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0) + if ((root = _MEDdatagroupCreer(maaid,nom_ent)) < 0) + return -1; + + /* + * Pour les mailles, les faces et le aretes, on cree + * s'il n'existe pas le Data Group du type geometrique + */ + if ((type_ent==MED_MAILLE)||(type_ent==MED_FACE)||(type_ent==MED_ARETE)) + { + if ((ret = _MEDnomGeometrie(nom_geo,type_geo)) < 0) + return -1; + + if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0) + if ((geoid = _MEDdatagroupCreer(entid,nom_geo)) < 0) + return -1; + } + else + geoid = -1; + + /* + * Creation du Data Set "NUM" + */ + if (geoid == -1) + root = entid; + else + root = geoid; + dimd[0] = n; +#if defined(IRIX64)||defined(OSF1) + if ((ret = _MEDdatasetNumEcrire(root,MED_NOM_NUM,MED_INT64,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,0,MED_NOPG,dimd, + (unsigned char*) num,mode)) < 0) + return -1; +#else + if ((ret = _MEDdatasetNumEcrire(root,MED_NOM_NUM,MED_INT32,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,0,MED_NOPG,dimd, + (unsigned char*) num,mode)) < 0) + return -1; +#endif + + /* + * Attribut NBR (nombre de noeuds) + */ + if ((dataset = _MEDdatasetOuvrir(root,MED_NOM_NUM)) < 0) + return -1; + if ((ret = _MEDattrEntierEcrire(dataset,MED_NOM_NBR,&n,mode)) < 0) + return -1; + + /* + * On ferme tout + */ + if ((ret = _MEDdatasetFermer(dataset)) < 0) + return -1; + if (geoid != -1) + if ((ret = _MEDdatagroupFermer(geoid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(entid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDnumLire.cxx b/src/MEDWrapper/V2_1/MEDnumLire.cxx new file mode 100644 index 000000000..938964060 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDnumLire.cxx @@ -0,0 +1,112 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDnumLire(med_idt fid,char *maa, med_int *num, med_int n, + med_entite_maillage type_ent,med_geometrie_element type_geo) +{ + med_idt root,maaid,entid,geoid; + med_err ret; + char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + char nom_ent[MED_TAILLE_NOM_ENTITE+1]; + char nom_geo[MED_TAILLE_NOM_ENTITE+1]; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * On met a jour le nom du Data Group representant + * le type des entites + */ + if ((ret = _MEDnomEntite(nom_ent,type_ent)) < 0) + return -1; + + /* + * Si le Data Group des entites n'existe pas => erreur + */ + if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0) + return -1; + + /* + * Pour les mailles, les faces et le aretes, + * si le Data Group du type geometrique => erreur + */ + if ((type_ent==MED_MAILLE)||(type_ent==MED_FACE)||(type_ent==MED_ARETE)) + { + if ((ret = _MEDnomGeometrie(nom_geo,type_geo)) < 0) + return -1; + if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0) + return -1; + } + else + geoid = -1; + + /* + * lecture du Data Set "NUM" + */ + if (geoid == -1) + root = entid; + else + root = geoid; +#if defined(IRIX64)||defined(OSF1) + if ((ret = _MEDdatasetNumLire(root,MED_NOM_NUM,MED_INT64, + MED_NO_INTERLACE,1,MED_ALL, + MED_NOPF,0,MED_NOPG, + (unsigned char*) num)) < 0) + return -1; +#else + if ((ret = _MEDdatasetNumLire(root,MED_NOM_NUM,MED_INT32, + MED_NO_INTERLACE,1,MED_ALL, + MED_NOPF,0,MED_NOPG, + (unsigned char*) num)) < 0) + return -1; +#endif + + /* + * On ferme tout + */ + if (geoid != -1) + if ((ret = _MEDdatagroupFermer(geoid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(entid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDobjetIdentifer.cxx b/src/MEDWrapper/V2_1/MEDobjetIdentifer.cxx new file mode 100644 index 000000000..14361bee5 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDobjetIdentifer.cxx @@ -0,0 +1,49 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDobjetIdentifier + * - Description : retrouve le nom de l'objet de rang "indice" + * se trouvant dans le datagroup "chemin" + * - Parametres : + * - fid (IN) : l'ID du fichier ou se trouve le datagroup + * - chemin (IN) : chemin d'acces au datagroup + * - indice (IN) : indice de l'objet du datagroup dont on veut + * le nom + * - nom (OUT) : le nom + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDobjetIdentifier(med_idt fid,char *chemin,int indice,void *nom) +{ + int idx; + + if ((idx = H5Giterate(fid,chemin,&indice,_MEDindiceInfo, + nom)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDouvrir.cxx b/src/MEDWrapper/V2_1/MEDouvrir.cxx new file mode 100644 index 000000000..0d259deb6 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDouvrir.cxx @@ -0,0 +1,76 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#ifdef PPRO_NT +#define F_OK 0 +#else +#include +#endif + +namespace med_2_1{ + +med_idt +MEDouvrir(char *nom, med_mode_acces mode_acces) +{ + med_idt fid; + + /* + * On inhibe le gestionnaire d'erreur HDF + */ + _MEDmodeErreurVerrouiller(); + + /* + * On ouvre le fichier MED sous HDF + */ + switch(mode_acces) + { + case MED_LECT : + if (access(nom,F_OK)) + return -1; + else + if ((fid = _MEDfichierOuvrir(nom,mode_acces)) < 0) + return -1; + break; + + case MED_ECRI : + if (access(nom,F_OK)) + { + if ((fid = _MEDfichierCreer(nom)) < 0) + return -1; + } + else + if ((fid = _MEDfichierOuvrir(nom,mode_acces)) < 0) + return -1; + break; + + case MED_REMP : + if ((fid = _MEDfichierCreer(nom)) < 0) + return -1; + break; + + default : + return -1; + } + + return fid; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDparametresGeometrie.cxx b/src/MEDWrapper/V2_1/MEDparametresGeometrie.cxx new file mode 100644 index 000000000..02a722f05 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDparametresGeometrie.cxx @@ -0,0 +1,164 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* + * - Nom de la fonction : _MEDparametresGeometrie + * - Description : fournit les parametres geometriques des differents + * entites et elements MED + * - Parametres : + * - typ_ent (IN) : type d'entite de l'element + * - type_geo (IN) : le type geometrique de l'element + * - dim (OUT) : dimension de l'element + * - nnoe (OUT) : nombre de noeuds composant l'element (connectivite + * nodale) + * - ndes (OUT) : nombre de composants dans l'elements (connectivite + * descendante) + * - Resultat : 0 en cas de succes, -1 sinon + */ + +namespace med_2_1{ + +med_err +_MEDparametresGeometrie(med_entite_maillage type_ent, + med_geometrie_element type_geo, int *dim, + int *nnoe,int *ndes) +{ + *nnoe = type_geo % 100; + *dim = type_geo / 100; + + switch(type_ent) + { + case MED_MAILLE : + switch (type_geo) + { + case MED_POINT1 : + *ndes = 0; + break; + + case MED_SEG2 : + *ndes = 2; + break; + + case MED_SEG3 : + *ndes = 3; + break; + + case MED_TRIA3 : + *ndes = 3; + break; + + case MED_TRIA6 : + *ndes = 3; + break; + + case MED_QUAD4 : + *ndes = 4; + break; + + case MED_QUAD8 : + *ndes = 4; + break; + + case MED_TETRA4 : + *ndes = 4; + break; + + case MED_TETRA10 : + *ndes = 4; + break; + + case MED_HEXA8 : + *ndes = 6; + break; + + case MED_HEXA20 : + *ndes = 6; + break; + + case MED_PENTA6 : + *ndes = 5; + break; + + case MED_PENTA15 : + *ndes = 5; + break; + + case MED_PYRA5 : + *ndes = 5; + break; + + case MED_PYRA13 : + *ndes = 5; + break; + + default : + return -1; + } + break; + + case MED_FACE : + switch(type_geo) + { + case MED_TRIA3 : + *ndes = 3; + break; + + case MED_TRIA6 : + *ndes = 3; + break; + + case MED_QUAD4 : + *ndes = 4; + break; + + case MED_QUAD8 : + *ndes = 4; + break; + + default : + return -1; + } + break; + + case MED_ARETE : + switch(type_geo) + { + case MED_SEG2 : + *ndes = 2; + break; + + case MED_SEG3 : + *ndes = 3; + break; + + default : + return -1; + } + break; + + default : + return -1; + } + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDpasdetempsInfo.cxx b/src/MEDWrapper/V2_1/MEDpasdetempsInfo.cxx new file mode 100644 index 000000000..e95f6019c --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDpasdetempsInfo.cxx @@ -0,0 +1,100 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +/* Le nom de cette fonction n'est pas très bien choisie */ + +namespace med_2_1{ + +med_err +MEDpasdetempsInfo(med_idt fid,char *champ + ,med_entite_maillage type_ent, med_geometrie_element type_geo, + int indice, char *maa, med_int * ngauss, med_int * numdt, char * dt_unit, med_float * dt, + med_int * numo) +{ + + med_err ret=0; + med_int gauss_size; + med_idt gid; + char chemin[(MED_TAILLE_CHA+MED_TAILLE_NOM+1)+(2*MED_TAILLE_NOM_ENTITE+2)+2*MED_MAX_PARA+1]; + int num; + char nomdatagroup1[2*MED_TAILLE_NOM_ENTITE+2],nomdatagroup2[2*MED_MAX_PARA+1]; + char tmp1 [MED_TAILLE_NOM_ENTITE+1]; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * On recupere le nom du datagroup . + */ + strcpy(chemin,MED_CHA); + strcat(chemin,champ); + strcat(chemin,"/"); + + if ((ret = _MEDnomEntite(nomdatagroup1,type_ent)) < 0) + return -1; + if ((type_ent != MED_NOEUD)) + { + if ((ret = _MEDnomGeometrie(tmp1,type_geo)) < 0) + return -1; + strcat(nomdatagroup1,"."); + strcat(nomdatagroup1,tmp1); + } + strcat(chemin,nomdatagroup1); + strcat(chemin,"/"); + + num = indice - 1; + if ((ret = _MEDobjetIdentifier(fid,chemin,num,nomdatagroup2)) < 0) + return -1; + strcat(chemin,nomdatagroup2); + if ((gid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * La liste des attributs + */ + if ((ret = _MEDattrStringLire(gid,MED_NOM_MAI,MED_TAILLE_NOM,maa)) < 0) + return -1; + + if ((ret = _MEDattrEntierLire(gid,MED_NOM_NDT,(med_int*) numdt)) < 0) + return -1; + + if ((ret = _MEDattrFloatLire(gid,MED_NOM_PDT,(med_float*) dt)) < 0) + return -1; + + if ((ret = _MEDattrStringLire(gid,MED_NOM_UNI,MED_TAILLE_PNOM,dt_unit)) < 0) + return -1; + + if ((ret = _MEDattrEntierLire(gid,MED_NOM_NOR,(med_int*) numo)) < 0) + return -1; + + if ( (ret = _MEDattrEntierLire(gid,MED_NOM_NGA,ngauss)) < 0 ) + return -1; + + + if ((ret = _MEDdatagroupFermer(gid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDprofilEcr.cxx b/src/MEDWrapper/V2_1/MEDprofilEcr.cxx new file mode 100644 index 000000000..b2d1e97b8 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDprofilEcr.cxx @@ -0,0 +1,89 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDprofilEcr(med_idt fid,med_int *pflval,med_int n,char *nom) +{ + med_idt root, pid, did; + med_size dimd[1]; + med_err ret; + char chemin[MED_TAILLE_PROFILS+1]; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le groupe "PROFILS" n'existe pas, on le cree + */ + strncpy(chemin,MED_PROFILS,MED_TAILLE_PROFILS-1); + chemin[MED_TAILLE_PROFILS-1] = '\0'; + if ((root = _MEDdatagroupOuvrir(fid,chemin)) < 0) + if ((root = _MEDdatagroupCreer(fid,chemin)) < 0) + return -1; + + /* + * Si le groupe "nom" n'existe pas, on le cree + * Sinon => erreur + */ + if ((pid = _MEDdatagroupOuvrir(root,nom)) >= 0) + return -1; + if ((pid = _MEDdatagroupCreer(root,nom)) < 0) + return -1; + + /* + * On stocke "n" sous forme d'attribut + */ + if ((ret = _MEDattrEntierEcrire(pid,MED_NOM_N,&n,MED_REMP)) < 0) + return -1; + + /* + * On stocke le profil dans un dataset + */ + dimd[0] = n; +#if defined(IRIX64)||defined(OSF1) + if ((ret = _MEDdatasetNumEcrire(pid,MED_NOM_PFL,MED_INT64,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,0,MED_NOPG,dimd, + (unsigned char*) pflval,MED_REMP)) < 0) + return -1; +#else + if ((ret = _MEDdatasetNumEcrire(pid,MED_NOM_PFL,MED_INT32,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,0,MED_NOPG,dimd, + (unsigned char*) pflval,MED_REMP)) < 0) + return -1; +#endif + + /* + * On ferme tout + */ + if ((ret = _MEDdatagroupFermer(pid)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(root)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDprofilInfo.cxx b/src/MEDWrapper/V2_1/MEDprofilInfo.cxx new file mode 100644 index 000000000..77f29687f --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDprofilInfo.cxx @@ -0,0 +1,62 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDprofilInfo(med_idt fid, int indice, char *profil, med_int *n) +{ + int numero; + med_idt proid; + med_err ret; + char chemin[MED_TAILLE_PROFILS+MED_TAILLE_NOM+1]; + + /* + * On inhibe le gestionnaire d'erreur + */ + _MEDmodeErreurVerrouiller(); + + /* + * On recupere le nom du groupe de rang "indice" + */ + numero = indice-1; + if ((ret = _MEDobjetIdentifier(fid,MED_PROFILS,numero,profil)) < 0) + return -1; + + /* + * On va chercher l'attribut taille du profil + */ + strcpy(chemin,MED_PROFILS); + strcat(chemin,profil); + if ((proid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + if ((ret = _MEDattrEntierLire(proid,MED_NOM_N,n)) < 0) + return -1; + if ((ret = _MEDdatagroupFermer(proid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDprofilLire.cxx b/src/MEDWrapper/V2_1/MEDprofilLire.cxx new file mode 100644 index 000000000..7621f82d8 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDprofilLire.cxx @@ -0,0 +1,73 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +namespace med_2_1{ + +med_err +MEDprofilLire(med_idt fid,med_int *pflval, char *nom) +{ + med_err ret = 0; + med_idt pid,did; + char chemin[MED_TAILLE_PROFILS+MED_TAILLE_NOM+1]; + + /* + * On inhibe le gestionnaire d'erreur HDF 5 + */ + _MEDmodeErreurVerrouiller(); + + /* + * ouverture du groupe /PROFILS/"nom" + */ + strcpy(chemin,MED_PROFILS); + strcat(chemin,nom); + if ((pid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * Lecture du profil + */ +#if defined(IRIX64)||defined(OSF1) + if ((ret = _MEDdatasetNumLire(pid,MED_NOM_PFL,MED_INT64, + MED_NO_INTERLACE,1,MED_ALL, + MED_NOPF,0,MED_NOPG, + (unsigned char *) pflval)) < 0) + return -1; +#else + if ((ret = _MEDdatasetNumLire(pid,MED_NOM_PFL,MED_INT32, + MED_NO_INTERLACE,1,MED_ALL, + MED_NOPF,0,MED_NOPG, + (unsigned char *) pflval)) < 0) + return -1; +#endif + + /* + * On ferme tout + */ + if ((ret = _MEDdatagroupFermer(pid)) < 0) + return -1; + + return ret; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDunvCr.cxx b/src/MEDWrapper/V2_1/MEDunvCr.cxx new file mode 100644 index 000000000..a1bcd9843 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDunvCr.cxx @@ -0,0 +1,102 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +#include +#include + +#ifdef PPRO_NT +// Windows Header Files: +#include +#include +#include +#else +#include +#endif + +namespace med_2_1{ + +med_err +MEDunvCr(med_idt fid, char *maa) +{ + med_idt maaid; + char chemin [MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + char nomu [MED_TAILLE_LNOM+1]; + time_t temps; +#ifdef PPRO_NT + struct timeb tp; + char lpBuffer [UNLEN+1]; + long nSize = UNLEN+1; +#else + struct timeval tp; +#endif + med_err ret; + + /* + * On inhibe le gestionnaire d'erreur + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * Creation/Ecriture de l'attribut nom universel + */ + +#ifdef PPRO_NT + if ( GetUserName(lpBuffer,&nSize) == 0 ) return -1; + if ( nSize > MED_TAILLE_NOM ) nSize = MED_TAILLE_NOM; + strncpy(nomu,lpBuffer,nSize); + strcat(nomu," "); + temps=time(&temps); + strcat(nomu,ctime(&temps)); + ftime(&tp); + nSize = strlen(nomu)-1; + if ( sprintf(&nomu[nSize]," %hu",tp.millitm) < 0 ) return -1; +#else + if (cuserid(nomu) == (void*) NULL) return -1; + strcat(nomu," "); + temps=time(&temps); + strcat(nomu,ctime(&temps)); + if ( gettimeofday(&tp,NULL) < 0 ) return -1; + if ( sprintf(&nomu[strlen(nomu)-1]," %li",tp.tv_usec) < 0 ) return -1; +#endif + if ((ret = _MEDattrStringEcrire(maaid,MED_NOM_UNV,MED_TAILLE_LNOM,nomu,MED_REMP)) < 0) + return -1; + + /* + * Nettoyages divers + */ + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDunvLire.cxx b/src/MEDWrapper/V2_1/MEDunvLire.cxx new file mode 100644 index 000000000..f6ddc5f6b --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDunvLire.cxx @@ -0,0 +1,66 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +#include +#include + +#include +#include + +namespace med_2_1{ + +med_err +MEDunvLire(med_idt fid, char *maa,char *nomu) +{ + med_idt maaid; + char chemin [MED_TAILLE_MAA+MED_TAILLE_NOM+1]; + med_err ret; + + /* + * On inhibe le gestionnaire d'erreur + */ + _MEDmodeErreurVerrouiller(); + + /* + * Si le maillage n'existe pas => erreur + */ + strcpy(chemin,MED_MAA); + strcat(chemin,maa); + if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) + return -1; + + /* + * Creation/Ecriture de l'attribut nom universel + */ + if ((ret = _MEDattrStringLire(maaid,MED_NOM_UNV,MED_TAILLE_LNOM, + nomu )) < 0) + return -1; + + /* + * Nettoyages divers + */ + if ((ret = _MEDdatagroupFermer(maaid)) < 0) + return -1; + + return 0; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDversionConforme.cxx b/src/MEDWrapper/V2_1/MEDversionConforme.cxx new file mode 100644 index 000000000..764a9a83a --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDversionConforme.cxx @@ -0,0 +1,68 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +namespace med_2_1{ + +med_err +MEDversionConforme(const char *nom) { + med_int majeur, mineur; + med_idt fid, gid; + med_err ret; + + /* + * On inhibe le gestionnaire d'erreur HDF + */ + _MEDmodeErreurVerrouiller(); + + /* + * On ouvre le fichier MED en mode MED_LECT + */ + if ((fid = _MEDfichierOuvrir((char *)nom,MED_LECT)) < 0) + return -1; + + /* + * Lecture du numero de version + */ + if ((gid = _MEDdatagroupOuvrir(fid,MED_NOM_INFOS)) < 0) + return -1; + + if ((ret = _MEDattrEntierLire(gid,MED_NOM_MAJEUR,&majeur)) < 0) + return -1; + + if ((ret = _MEDattrEntierLire(gid,MED_NOM_MINEUR,&mineur)) < 0) + return -1; + + /* + * On ferme tout + */ + if ((ret = _MEDdatagroupFermer(gid)) < 0) + return -1; + + if ((ret = _MEDfichierFermer(fid)) < 0) + return -1; + + if ((majeur == MED_NUM_MAJEUR) && (mineur == MED_NUM_MINEUR)) + return 0; + else + return -1; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDversionDonner.cxx b/src/MEDWrapper/V2_1/MEDversionDonner.cxx new file mode 100644 index 000000000..33a57726a --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDversionDonner.cxx @@ -0,0 +1,31 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +namespace med_2_1{ + +void +MEDversionDonner(med_int *majeur, med_int *mineur, med_int *release) { + *majeur = MED_NUM_MAJEUR; + *mineur = MED_NUM_MINEUR; + *release = MED_NUM_RELEASE; +} + +} diff --git a/src/MEDWrapper/V2_1/MEDversionLire.cxx b/src/MEDWrapper/V2_1/MEDversionLire.cxx new file mode 100644 index 000000000..b358d8357 --- /dev/null +++ b/src/MEDWrapper/V2_1/MEDversionLire.cxx @@ -0,0 +1,55 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#include "med.hxx" +#include "med_outils.hxx" + +namespace med_2_1{ + +med_err +MEDversionLire(med_idt fid, med_int *majeur, med_int *mineur, med_int *release) +{ + med_err ret = 0; + med_idt gid; + + /* On ouvre le group ou se trouvent les infos */ + if ((gid = _MEDdatagroupOuvrir(fid,MED_NOM_INFOS)) < 0) { + *majeur = 2; + *mineur = -1; + *release = -1; + ret = 0; + } + else { + if ((ret = _MEDattrEntierLire(gid,MED_NOM_MAJEUR,majeur)) < 0) + return -1; + + if ((ret = _MEDattrEntierLire(gid,MED_NOM_MINEUR,mineur)) < 0) + return -1; + + if ((ret = _MEDattrEntierLire(gid,MED_NOM_RELEASE,release)) < 0) + return -1; + + /* On ferme tout */ + if ((ret = _MEDdatagroupFermer(gid)) < 0) + return -1; + } + + return ret; +} + +} diff --git a/src/MEDWrapper/V2_1/Makefile.in b/src/MEDWrapper/V2_1/Makefile.in new file mode 100644 index 000000000..778b27267 --- /dev/null +++ b/src/MEDWrapper/V2_1/Makefile.in @@ -0,0 +1,170 @@ +# +# +# 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 : +# Author : +# Module : +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +LIB_SRC_TOOLS_HDFI= \ +MEDattrFermer.cxx \ +MEDattrNumEcrire.cxx \ +MEDattrNumLire.cxx \ +MEDattrOuvrir.cxx \ +MEDattrStringEcrire.cxx \ +MEDattrStringLire.cxx \ +MEDdatagroupCreer.cxx \ +MEDdatagroupFermer.cxx \ +MEDdatagroupOuvrir.cxx \ +MEDdatasetFermer.cxx \ +MEDdatasetNumEcrire.cxx \ +MEDdatasetNumLire.cxx \ +MEDdatasetOuvrir.cxx \ +MEDdatasetStringEcrire.cxx \ +MEDdatasetStringLire.cxx \ +MEDfichierCreer.cxx \ +MEDfichierFermer.cxx \ +MEDfichierOuvrir.cxx \ +MEDindiceInfo.cxx \ +MEDindiceNum.cxx \ +MEDmodeErreurVerrouiller.cxx \ +MEDnObjets.cxx \ +MEDobjetIdentifer.cxx + +LIB_SRC_TOOLS_MISC= \ +MED1cstring.cxx MEDnomDataset.cxx \ +MED2cstring.cxx MEDnomEntite.cxx \ +MEDGeometrieElement.cxx MEDnomGeometrie.cxx \ +MEDcstringFree.cxx MEDparametresGeometrie.cxx \ +MEDfstring.cxx + +LIB_SRC_API_CI= \ +MEDchampCr.cxx \ +MEDchampEcr.cxx \ +MEDchampInfo.cxx \ +MEDchampLire.cxx \ +MEDconnEcr.cxx \ +MEDconnLire.cxx \ +MEDcoordEcr.cxx \ +MEDcoordLire.cxx \ +MEDdimLire.cxx \ +MEDelementsEcr.cxx \ +MEDelementsLire.cxx \ +MEDequivCr.cxx \ +MEDequivEcr.cxx \ +MEDequivInfo.cxx \ +MEDequivLire.cxx \ +MEDfam2groA.cxx \ +MEDfam2groB.cxx \ +MEDfamCr.cxx \ +MEDfamEcr.cxx \ +MEDfamInfo.cxx \ +MEDfamLire.cxx \ +MEDfamMaaCr.cxx \ +MEDfamMaaInfo.cxx \ +MEDfamMaaLire.cxx \ +MEDfermer.cxx \ +MEDfichDesEcr.cxx \ +MEDfichEntete.cxx \ +MEDgro2famA.cxx \ +MEDgro2famB.cxx \ +MEDlFichDes.cxx \ +MEDmaaCr.cxx \ +MEDmaaInfo.cxx \ +MEDnChamp.cxx \ +MEDnCorres.cxx \ +MEDnEntMaa.cxx \ +MEDnEntites.cxx \ +MEDnEquiv.cxx \ +MEDnFam.cxx \ +MEDnMaa.cxx \ +MEDnPasdetemps.cxx \ +MEDnProfil.cxx \ +MEDnVal.cxx \ +MEDnValProfil.cxx \ +MEDnbnoisEcr.cxx \ +MEDnbnoisLire.cxx \ +MEDnbnomaEcr.cxx \ +MEDnbnomaLire.cxx \ +MEDnbnosoEcr.cxx \ +MEDnbnosoLire.cxx \ +MEDnoeudsEcr.cxx \ +MEDnoeudsLire.cxx \ +MEDnomEcr.cxx \ +MEDnomLire.cxx \ +MEDnumEcr.cxx \ +MEDnumLire.cxx \ +MEDouvrir.cxx \ +MEDpasdetempsInfo.cxx \ +MEDprofilEcr.cxx \ +MEDprofilLire.cxx \ +MEDprofilInfo.cxx \ +MEDunvCr.cxx \ +MEDunvLire.cxx \ +MEDformatConforme.cxx \ +MEDversionConforme.cxx \ +MEDversionDonner.cxx \ +MEDversionLire.cxx \ +MEDbodyFittedEcr.cxx \ +MEDbodyFittedLire.cxx \ +MEDfamGridEcr.cxx \ +MEDfamGridLire.cxx \ +MEDgridCr.cxx \ +MEDgridEcr.cxx \ +MEDgridInfo.cxx \ +MEDgridLire.cxx \ +MEDnGrid.cxx + +# Libraries targets + +LIB = libMEDWrapper_V2_1.la +LIB_SRC = \ + $(LIB_SRC_TOOLS_HDFI) \ + $(LIB_SRC_TOOLS_MISC) \ + $(LIB_SRC_API_CI) \ + MED_V2_1_Wrapper.cxx + +EXPORT_HEADERS = \ + MED_V2_1_Wrapper.hxx \ + med.hxx \ + med_proto.hxx + +# Executables targets +BIN = mdump_V2_1 test1_V2_1 +BIN_SRC = + +CPPFLAGS+= -D@MACHINE@ $(BOOST_CPPFLAGS) $(HDF5_INCLUDES) + +LDFLAGS+= $(HDF5_LIBS) -lMEDWrapperBase + +LDFLAGSFORBIN=$(LDFLAGS) + +@CONCLUDE@ diff --git a/src/MEDWrapper/V2_1/mdump_V2_1.cxx b/src/MEDWrapper/V2_1/mdump_V2_1.cxx new file mode 100644 index 000000000..6c959fde4 --- /dev/null +++ b/src/MEDWrapper/V2_1/mdump_V2_1.cxx @@ -0,0 +1,1626 @@ +/****************************************************************************** + * - Nom du fichier : mdump.c + * + * - Description : utilitaire de dump pour fichier MED V2.1 + * + *****************************************************************************/ +#define NBR_MAILLE_EQU 7 + +#include +#include +#include + +#include "med.hxx" +using namespace med_2_1; + +/******************************************************************* + * DUMP D'UN FICHIER MED STRUCTURE EN GRILLE : * + * NOEUDS, ELEMENTS, FAMILLES, EQUIVALENCES, CHAMPS DE RESULTATS * + *******************************************************************/ + +int grid_cartesian_or_polar(med_idt fid, int numero, med_mode_switch mode_coo) { + med_int mdim, nnoe, nfam, i, j; + char nommaa[MED_TAILLE_NOM+1]; + char nom_universel[MED_TAILLE_LNOM+1]; + med_float *coo; + med_int *fam; + char nomcoo[3*MED_TAILLE_PNOM+1]; + char unicoo[3*MED_TAILLE_PNOM+1]; + med_repere rep; + char str[MED_TAILLE_PNOM+1]; + + fprintf(stdout,"\n(****************************)\n"); + fprintf(stdout,"(* INFORMATIONS GENERALES : *)\n"); + fprintf(stdout,"(****************************)\n"); + + /* lecture du nom et de la dimension de la grille */ + if (MEDmaaInfo(fid, numero, nommaa, &mdim) < 0) { + fprintf(stderr, ">> ERREUR : lecture du nom de la grille\n"); + return(EXIT_FAILURE); + }; + fprintf(stdout, "- Nom de la grille : <<%s>>\n", nommaa); + fprintf(stdout, "- Dimension de la grille : %d\n", mdim); + + /* lecture du nom universel (presence optionnelle) */ + if (MEDunvLire(fid, nommaa, nom_universel) > 0) { + fprintf(stdout, "- Nom universel de la grille : %s \n", nom_universel); + } else { + fprintf(stdout, "- Pas de nom universel \n"); + }; + + /* nombre de familles */ + nfam = MEDnFam(fid, nommaa, 0, (med_dim_famille)0); + if (nfam < 0) { + fprintf(stderr, ">> ERREUR : lecture du nombre de familles\n"); + return(EXIT_FAILURE); + }; + fprintf(stdout, "- Nombre de familles : %d \n", nfam); + + fprintf(stdout, "\n- Lecture des indices : \n"); + for (i=0; i> ERREUR : lecture des indices \n"); + return(EXIT_FAILURE); + }; + + fprintf(stdout, "- Type de repere des coordonnees : %d \n", rep); + + fprintf(stdout, "- Nom des coordonnees : \n"); + for (j=0; j 0) { + fam = (med_int*)malloc(sizeof(med_int)*nfam); + if (MEDfamGridLire(fid, nommaa, fam, nfam,MED_NOEUD) < 0) { + fprintf(stderr, ">> ERREUR : lecture des familles\n"); + return(EXIT_FAILURE); + }; + + fprintf(stdout, "\n- Numeros des familles des noeuds :\n"); + for (i=0; i> ERREUR : lecture du nom du maillage body fitted\n"); + return(EXIT_FAILURE); + }; + fprintf(stdout, "- Nom du maillage body fitted : <<%s>>\n", nommaa); + fprintf(stdout, "- Dimension du maillage body fitted : %d\n", mdim); + + /* lecture du nom universel (presence optionnelle) */ + if (MEDunvLire(fid, nommaa, nom_universel) > 0) { + fprintf(stdout, "- Nom universel du maillage body fitted : %s \n", nom_universel); + } else { + fprintf(stdout, "- Pas de nom universel \n"); + }; + + /* Combien de noeuds ? */ + /* nnoe = MEDnGrid(fid, nommaa, -1);*/ + nnoe = MEDnGrid(fid, nommaa, MED_GRID_NOEUD); + if (nnoe < 0) { + fprintf(stderr, ">> ERREUR : lecture du nombre de noeuds (via MEDnGrid) \n"); + return(EXIT_FAILURE); + }; + fprintf(stdout, "- Nombre de noeuds : %d \n", nnoe); + + /* Combien de noeuds dans la dimension 1 ? */ + i = MEDnGrid(fid, nommaa, (med_grid)0); + if (i < 0) { + fprintf(stderr, ">> ERREUR : lecture du nombre de noeuds (via MEDnGrid) dans la dimension 1 \n"); + return(EXIT_FAILURE); + }; + fprintf(stdout, "- Nombre de noeuds dans la dimension 1 : %d \n", i); + + /* Combien de noeuds dans la dimension 2 ? */ + i = MEDnGrid(fid, nommaa, (med_grid)1); + if (i < 0) { + fprintf(stderr, ">> ERREUR : lecture du nombre de noeuds (via MEDnGrid) dans la dimension 2 \n"); + return(EXIT_FAILURE); + }; + fprintf(stdout, "- Nombre de noeuds dans la dimension 2 : %d \n", i); + + /* nombre de familles */ + nfam = MEDnFam(fid, nommaa, 0,(med_dim_famille)0); + if (nfam < 0) { + fprintf(stderr, ">> ERREUR : lecture du nombre de familles \n"); + return(EXIT_FAILURE); + }; + fprintf(stdout, "- Nombre de familles : %d \n", nfam); + + coo = (med_float*)malloc(sizeof(med_float)*nnoe*mdim); + fam = (med_int*)malloc(sizeof(med_int)*nnoe); + + if (MEDbodyFittedLire(fid, nommaa, mdim, coo, mode_coo, &rep, nomcoo, unicoo, fam, nnoe) < 0) { + fprintf(stderr, ">> ERREUR : lecture des noeuds \n"); + return(EXIT_FAILURE); + }; + + fprintf(stdout, "- Type de repere des coordonnees : %d \n", rep); + + fprintf(stdout, "- Nom des coordonnees : \n"); + for (i=0; i> ERREUR : type de maillage inconnu\n"); + return(EXIT_FAILURE); + }; + }; +} + +/****************************************************************************** + * DUMP D'UN FICHIER MED : NOEUDS, + * ELEMENTS, FAMILLES, EQUIVALENCES, CHAMPS DE RESULTATS + *****************************************************************************/ + +int main (int argc, char **argv) +{ + med_err ret = 0; + med_idt fid; + int i,j,k,l,kp; + int numero; + char message[200]; + /* nombre d'objets MED */ + char nom_universel[MED_TAILLE_LNOM+1]; + med_int long_fichier_en_tete; + char *fichier_en_tete; + char version_hdf[10]; + char version_med[10]; + med_int nmaa,mdim,nnoe; + med_int nmai[MED_NBR_GEOMETRIE_MAILLE],nfac[MED_NBR_GEOMETRIE_FACE]; + med_int nare[MED_NBR_GEOMETRIE_ARETE]; + /* nom du maillage */ + char nommaa[MED_TAILLE_NOM+1]; + /* noeuds */ + med_float *coo; + char nomcoo[3*MED_TAILLE_PNOM+1]; + char unicoo[3*MED_TAILLE_PNOM+1]; + char *nomnoe; + med_int *numnoe; + med_int *nufano; + med_repere rep; + med_booleen inonoe,inunoe; + med_mode_switch mode_coo; + char str[MED_TAILLE_PNOM+1]; + /* elements */ + med_int nsup; + med_int edim; + med_int taille; + med_int *connectivite; + char *nomele; + med_int *numele; + med_int *nufael; + med_booleen inoele, inuele; + med_connectivite typ_con; + med_geometrie_element typgeo; + med_geometrie_element typmai[MED_NBR_GEOMETRIE_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_int desmai[MED_NBR_GEOMETRIE_MAILLE] = {0,2,3,3,3,4,4,4,4,6,6,5,5,5,5}; + med_int nmailles[MED_NBR_GEOMETRIE_MAILLE]; + char nommai[MED_NBR_GEOMETRIE_MAILLE] [MED_TAILLE_NOM+1] = {"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_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] = {MED_TRIA3,MED_TRIA6, + MED_QUAD4,MED_QUAD8}; + med_int desfac[MED_NBR_GEOMETRIE_FACE] = {3,3,4,4}; + med_int nfaces[MED_NBR_GEOMETRIE_FACE]; + char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM+1] = {"MED_TRIA3","MED_TRIA6", + "MED_QUAD4","MED_QUAD8"}; + med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] = {MED_SEG2,MED_SEG3}; + med_int desare[MED_NBR_GEOMETRIE_ARETE] = {2,3}; + med_int naretes[MED_NBR_GEOMETRIE_ARETE]; + char nomare[MED_NBR_GEOMETRIE_ARETE] [MED_TAILLE_NOM+1] = {"MED_SEG2","MED_SEG3"}; + /* familles */ + med_int nfam; + med_int natt,ngro; + char *attdes,*gro; + med_int *attval,*attide; + char nomfam[MED_TAILLE_NOM+1]; + med_int numfam; + char str1[MED_TAILLE_DESC+1]; + char str2[MED_TAILLE_LNOM+1]; + /* equivalences */ + med_int nequ,ncor; + med_int *cor; + char equ[MED_TAILLE_NOM+1]; + char des[MED_TAILLE_DESC+1]; + /* champs de resultats */ + char *comp; + char *unit; + char nomcha[MED_TAILLE_NOM+1]; + char maillage_champ[MED_TAILLE_NOM+1]; + med_int ncomp; + med_float *valr; + med_int *vale; + med_type_champ typcha; + med_int ncha; + med_int nval; + int reponse; + int lecture_en_tete_seulement = 0; + med_int npdt; + med_int ngauss,numdt,numo; + med_float dt; + char dtunit[MED_TAILLE_PNOM+1]; + char pflnom[MED_TAILLE_NOM+1]; + med_int pflsize; + med_int *pflval; + med_int isGrid; + med_grid_type theType; + + /**************************************************************************** + * TEST DU NOMBRE D'ARGUMENTS * + * argument 1 = nom du fichier MED * + ****************************************************************************/ + if (argc != 2 && argc != 5) + { + fprintf(stderr,">> ERREUR : nombre de parametres incorrects \n"); + exit(EXIT_FAILURE); + } + + /**************************************************************************** + * OUVERTURE DU FICHIER EN LECTURE * + ****************************************************************************/ + fid = MEDouvrir(argv[1],MED_LECT); + if (fid < 0) + { + fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",argv[1]); + exit(EXIT_FAILURE); + } + + + /**************************************************************************** + * QUESTIONS PRELIMINAIRES * + * 1. Mode d'affichage des coordonnees (entrelace ou non) ? * + * 2. Connectivite des elements (nodale ou descendante) * + ****************************************************************************/ + fprintf(stdout,"\n >>>>>> DUMP DU FICHIER %s >>>>>>\n",argv[1]); + + /* en-tete du fichier (presence optionnelle) */ + long_fichier_en_tete = MEDlFichDes(fid); + if (long_fichier_en_tete > 0) + { + fichier_en_tete = (char *) malloc(sizeof(char)*(long_fichier_en_tete+1)); + ret = MEDfichEntete(fid,MED_FICH_DES,fichier_en_tete); + if (ret < 0) + { + fprintf(stderr,">> ERREUR : lecture de l'en-tete du fichier \n"); + exit(EXIT_FAILURE); + } + fprintf(stdout,"- En-tete du fichier : %s \n",fichier_en_tete); + free(fichier_en_tete); + } + /* versions hdf et med */ + ret = MEDfichEntete(fid,MED_HDF_VERSION,version_hdf); + if (ret < 0) + { + fprintf(stderr,">> ERREUR : lecture du numero de version de HDF \n"); + exit(EXIT_FAILURE); + } + ret = MEDfichEntete(fid,MED_VERSION,version_med); + if (ret < 0) + { + fprintf(stderr,">> ERREUR : lecture du numero de version de MED \n"); + exit(EXIT_FAILURE); + } + fprintf(stdout,"- Version de HDF utilisee : %s \n",version_hdf); + fprintf(stdout,"- Version de MED utilisee : %s \n",version_med); + + if (argc == 2) + { + fprintf(stdout,"(*****************)\n"); + fprintf(stdout,"(* PARAMETRAGE : *)\n"); + fprintf(stdout,"(*****************)\n"); + fprintf(stdout,"- Mode d'affichage des coordonnées des noeuds ? \n"); + fprintf(stdout," 1. Mode entrelacé : taper 1 \n"); + fprintf(stdout," 2. Mode non entrelacé : taper 2 \n"); + reponse = 0; + do + { + fprintf(stdout," Reponse : "); + scanf("%d",&reponse); + } + while (reponse != 1 && reponse != 2); + if (reponse == 1) + mode_coo = MED_FULL_INTERLACE; + else + mode_coo = MED_NO_INTERLACE; + + fprintf(stdout,"- Connectivité des éléments ? \n"); + fprintf(stdout," 1. Nodale : taper 1 \n"); + fprintf(stdout," 2. Descendante : taper 2 \n"); + reponse = 0; + do + { + fprintf(stdout," Reponse : "); + scanf("%d",&reponse); + } + while (reponse != 1 && reponse != 2); + if (reponse == 1) + typ_con = MED_NOD; + else + typ_con = MED_DESC; + } + else + { + if (! strcmp(argv[3],"NODALE")) + typ_con = MED_NOD; + if (! strcmp(argv[3],"DESCENDANTE")) + typ_con = MED_DESC; + + if (!strcmp(argv[4],"NO_INTERLACE")) + mode_coo = MED_NO_INTERLACE; + if (!strcmp(argv[4],"FULL_INTERLACE")) + mode_coo = MED_FULL_INTERLACE; + if (! strcmp(argv[4],"LECTURE_EN_TETE_SEULEMENT")) + lecture_en_tete_seulement = 1; + + } + + /**************************************************************************** + * QUEL MAILLAGE LIRE * + ****************************************************************************/ + nmaa = MEDnMaa(fid); + if (nmaa < 0) + { + fprintf(stderr,">> ERREUR : lecture du nombre de maillages \n"); + exit(EXIT_FAILURE); + } + + /* Quel maillage lire ? */ + if (argc == 2) + { + fprintf(stdout,"- Il y a %d maillages dans ce fichier \n",nmaa); + fprintf(stdout," Lequel voulez-vous lire (1|2|3|...|n) ?\n"); + do + { + fprintf(stdout," Reponse : "); + scanf("%d",&numero); + } + while (numero > nmaa || numero <= 0); + } + else + { + numero = atoi(argv[2]); + if (numero > nmaa || numero <= 0) + { + fprintf(stderr,">> ERREUR : il y a %d maillages dans ce fichier \n", + nmaa); + exit(EXIT_FAILURE); + } + } + +/***************************************************************************** + * QUELLE SORTE DE MAILLAGE : GRILLE OU PAS * + *****************************************************************************/ + + fprintf(stdout,"\n(**************************************************)\n"); + fprintf(stdout,"(* MAILLAGE STRUCTURE (GRILLE) OU NON STRUCTURE : *)\n"); + fprintf(stdout,"(**************************************************)\n"); + + /* lecture de la sorte de maillage : structure ou pas */ + ret = MEDgridInfo(fid, numero, &isGrid, &theType); + if (ret < 0) { + fprintf(stderr, ">> ERREUR : lecture de la sorte de maillage (structure ou pas)\n"); + exit(EXIT_FAILURE); + }; + fprintf(stdout, "- Sorte de maillage : %s\n", isGrid? "structure (grille)": "non structure"); + if (isGrid) { + ret = grid(fid, numero, theType, mode_coo); + if (ret == 0) { + ret = MEDfermer(fid); + if (ret == 0) { + fprintf(stdout, "\n >>>>>> FIN DU DUMP DU FICHIER %s >>>>>>\n", argv[1]); + } else { + fprintf(stderr, ">> ERREUR : erreur a la fermeture du fichier %s\n", argv[1]); + }; + }; + if (ret == 0) { + return(0); + } else { + exit(EXIT_FAILURE); + }; + }; + + /**************************************************************************** + * NOMBRES D'OBJETS MED * + ****************************************************************************/ + fprintf(stdout,"\n(****************************)\n"); + fprintf(stdout,"(* INFORMATIONS GENERALES : *)\n"); + fprintf(stdout,"(****************************)\n"); + + /* lecture du nom et de la dimension du maillage */ + ret = MEDmaaInfo(fid,numero,nommaa,&mdim); + if (ret < 0) + { + fprintf(stderr,">> ERREUR : lecture du nom du maillage \n"); + exit(EXIT_FAILURE); + } + fprintf(stdout,"- Nom du maillage : <<%s>>\n",nommaa); + fprintf(stdout,"- Dimension du maillage : %d\n",mdim); + + /* lecture du nom universel (presence optionnelle) */ + ret = MEDunvLire(fid,nommaa,nom_universel); + if (ret > 0) + fprintf(stdout,"- Nom universel du maillage : %s \n",nom_universel); + else + fprintf(stdout,"- Pas de nom universel \n"); + + + /* Combien de noeuds ? */ + nnoe = MEDnEntMaa(fid,nommaa,MED_COOR,MED_NOEUD,(med_geometrie_element)0,(med_connectivite)0); + if (nnoe < 0) + { + fprintf(stderr,">> ERREUR : lecture du nombre de noeuds (via MEDnEntMaa) \n"); + exit(EXIT_FAILURE); + } + fprintf(stdout,"- Nombre de noeuds : %d \n",nnoe); + + /* Combien de mailles, faces ou aretes ? */ + for (i=0;i> ERREUR : lecture du nombre de mailles \n"); + exit(EXIT_FAILURE); + } + fprintf (stdout,"- Nombre de mailles de type %s : %d \n",nommai[i],nmailles[i]); + } + + for (i=0;i> ERREUR : lecture du nombre de faces \n"); + exit(EXIT_FAILURE); + } + fprintf (stdout,"- Nombre de faces de type %s : %d \n",nomfac[i],nfaces[i]); + } + + for (i=0;i> ERREUR : lecture du nombre d'aretes \n"); + exit(EXIT_FAILURE); + } + fprintf (stdout,"- Nombre d'aretes de type %s : %d \n",nomare[i],naretes[i]); + } + + /* nombre de familles */ + nfam = MEDnFam(fid,nommaa,0,(med_dim_famille)0); + if (nfam < 0) + { + fprintf(stderr,">> ERREUR : lecture du nombre de familles \n"); + exit(EXIT_FAILURE); + } + fprintf(stdout,"- Nombre de familles : %d \n",nfam); + + /* combien d'equivalences dans le fichier */ + nequ = MEDnEquiv(fid,nommaa); + if (nequ < 0) + { + fprintf(stderr,">> ERREUR : lecture du nombre d'equivalences \n"); + exit(EXIT_FAILURE); + } + fprintf(stdout,"- Nombre d'equivalences : %d \n",nequ); + + /* combien de champs dans le fichier */ + ncha = MEDnChamp(fid,0); + if (ncha < 0) + { + fprintf(stderr,">> ERREUR : lecture du nombre de champs \n"); + exit(EXIT_FAILURE); + } + fprintf(stdout,"- Nombre de champs : %d \n",ncha); + + /* Doit-on s'arreter ? */ + if (lecture_en_tete_seulement) + { + ret = MEDfermer(fid); + if (ret == 0) + { + fprintf(stdout,"\n >>>>>> FIN DU DUMP DU FICHIER %s >>>>>>\n",argv[1]); + return 0; + } + else + { + fprintf(stderr,">> ERREUR : fermeture du fichier %s \n",argv[1]); + exit(EXIT_FAILURE); + } + } + + /**************************************************************************** + * LECTURE DES NOEUDS * + ****************************************************************************/ + fprintf(stdout,"\n(************************)\n"); + fprintf(stdout,"(* NOEUDS DU MAILLAGE : *)\n"); + fprintf(stdout,"(************************)\n"); + + /* Allocations memoires */ + /* table des coordonnees + profil : (dimension * nombre de noeuds ) */ + coo = (med_float*) malloc(sizeof(med_float)*nnoe*mdim); + /* table des numeros, des numeros de familles des noeuds + profil : (nombre de noeuds) */ + numnoe = (med_int*) malloc(sizeof(med_int)*nnoe); + nufano = (med_int*) malloc(sizeof(med_int)*nnoe); + /* table des noms des noeuds + profil : (nnoe*MED_TAILLE_PNOM+1) */ + nomnoe = (char*) malloc(MED_TAILLE_PNOM*nnoe+1); + + /* lecture des noeuds : + - coordonnees + - noms (optionnel dans un fichier MED) + - numeros (optionnel dans un fichier MED) + - numeros des familles */ + ret = MEDnoeudsLire(fid,nommaa,mdim,coo,mode_coo,&rep, + nomcoo,unicoo,nomnoe,&inonoe,numnoe,&inunoe, + nufano,nnoe); + if (ret < 0) + strcpy(message,">> ERREUR : lecture des noeuds \n"); + + /* affichage des resultats */ + if (ret == 0) + { + fprintf(stdout,"- Type de repere des coordonnees : %d \n",rep); + fprintf(stdout,"- Nom des coordonnees : \n"); + for (i=0;i 0 && ret == 0) + { + /* dimension de la maille */ + edim = typmai[i] / 100; + nsup = 0; + if (mdim == 2 || mdim == 3) + if (edim == 1) + nsup = 1; + if (mdim == 3) + if (edim == 2) + nsup = 1; + switch(typ_con) + { + case MED_NOD : + taille = nsup+typmai[i]%100; + break; + + case MED_DESC : + taille = nsup+desmai[i]; + break; + + default : + ret = -1; + } + + /* allocation memoire */ + connectivite = (med_int*)malloc(sizeof(med_int)* + taille*nmailles[i]); + nomele = (char*)malloc(sizeof(char)*MED_TAILLE_PNOM* + nmailles[i]+1); + numele = (med_int*)malloc(sizeof(med_int)* + nmailles[i]); + nufael = (med_int*)malloc(sizeof(med_int)* + nmailles[i]); + + /* lecture des données */ + ret = MEDelementsLire(fid,nommaa,mdim,connectivite,mode_coo, + nomele,&inoele,numele,&inuele,nufael, + nmailles[i],MED_MAILLE,typmai[i], + typ_con); + if (ret < 0) + strcpy(message,">> ERREUR : lecture des mailles \n"); + + /* affichage des resultats */ + if (ret == 0) + { + fprintf(stdout,"\n\n- Mailles de type %s : ", nommai[i]); + fprintf(stdout,"\n - Connectivité : \n"); + for (j=0;j 0 && ret == 0) + { + /* dimension de la face */ + edim = typfac[i] / 100; + nsup = 0; + if (mdim == 2 || mdim == 3) + if (edim == 1) + nsup = 1; + if (mdim == 3) + if (edim == 2) + nsup = 1; + switch(typ_con) + { + case MED_NOD : + taille = nsup+typfac[i]%100; + break; + + case MED_DESC : + taille = nsup+desfac[i]; + break; + + default : + ret = -1; + } + + /* allocation memoire */ + connectivite = (med_int*)malloc(sizeof(med_int)* + taille*nfaces[i]); + nomele = (char*)malloc(sizeof(char)*MED_TAILLE_PNOM* + nfaces[i]+1); + numele = (med_int*)malloc(sizeof(med_int)* + nfaces[i]); + nufael = (med_int*)malloc(sizeof(med_int)* + nfaces[i]); + + /* lecture des données */ + ret = MEDelementsLire(fid,nommaa,mdim,connectivite,mode_coo, + nomele,&inoele,numele,&inuele,nufael, + nfaces[i],MED_FACE,typfac[i], + typ_con); + if (ret < 0) + strcpy(message,">> ERREUR : lecture des faces \n"); + + /* affichage des resultats */ + if (ret == 0) + { + fprintf(stdout,"\n- Faces de type %s : ", nomfac[i]); + fprintf(stdout,"\n - Connectivité : \n"); + for (j=0;j 0 && ret == 0) + { + /* dimension de l'arete */ + edim = typare[i] / 100; + nsup = 0; + if (mdim == 2 || mdim == 3) + if (edim == 1) + nsup = 1; + if (mdim == 3) + if (edim == 2) + nsup = 1; + switch(typ_con) + { + case MED_NOD : + taille = nsup+typare[i]%100; + break; + + case MED_DESC : + taille = nsup+desare[i]; + break; + + default : + ret = -1; + } + + /* allocation memoire */ + connectivite = (med_int*)malloc(sizeof(med_int)* + taille*naretes[i]); + nomele = (char*)malloc(sizeof(char)*MED_TAILLE_PNOM* + naretes[i]+1); + numele = (med_int*)malloc(sizeof(med_int)* + naretes[i]); + nufael = (med_int*)malloc(sizeof(med_int)* + naretes[i]); + + /* lecture des données */ + ret = MEDelementsLire(fid,nommaa,mdim,connectivite,mode_coo, + nomele,&inoele,numele,&inuele,nufael, + naretes[i],MED_ARETE,typare[i], + typ_con); + if (ret < 0) + strcpy(message,">> ERREUR : lecture des aretes \n"); + + /* affichage des resultats */ + if (ret == 0) + { + fprintf(stdout,"\n- Aretes de type %d : ", nomare[i]); + fprintf(stdout,"\n - Connectivité : \n"); + for (j=0;j> ERREUR : lecture du nombre de groupes d'une famille \n"); + } + + /* nombre d'attributs */ + if (ret == 0) + { + natt = MEDnFam(fid,nommaa,i+1,MED_ATTR); + if (natt < 0) + { + ret = -1; + strcpy(message, + ">> ERREUR : lecture du nombre d'attributs d'une famille\n"); + } + } + + if (ret == 0) + fprintf(stdout,"- Famille %d a %d attributs et %d groupes \n",i+1,natt,ngro); + + /* nom,numero,attributs,groupes */ + if (ret == 0) + { + attide = (med_int*) malloc(sizeof(med_int)*natt); + attval = (med_int*) malloc(sizeof(med_int)*natt); + attdes = (char *) malloc(MED_TAILLE_DESC*natt+1); + gro = (char*) malloc(MED_TAILLE_LNOM*ngro+1); + ret = MEDfamInfo(fid,nommaa,i+1,nomfam,&numfam,attide,attval, + attdes,&natt,gro,&ngro); + fprintf(stdout," - Famille de nom %s et de numero %d : \n",nomfam,numfam); + fprintf(stdout," - Attributs : \n"); + for (j=0;j> ERREUR : lecture informations sur equivalence\n"); + + /* lecture des correspondances sur les differents types d'entites */ + if (ret == 0) + { + /* les noeuds */ + if ((ncor = MEDnCorres(fid,nommaa,equ,MED_NOEUD,(med_geometrie_element)0)) < 0) + { + ret = -1; + strcpy(message,">> ERREUR : lecture nombre de correspondances\n"); + } + else + fprintf(stdout,"\n - Il y a %d correspondances sur les noeuds \n",ncor); + if (ncor > 0) + { + cor = (med_int*) malloc(sizeof(med_int)*ncor*2); + ret = MEDequivLire(fid,nommaa,equ,cor,ncor,MED_NOEUD,(med_geometrie_element)0); + if (ret == 0) + for (j=0;j> ERREUR : lecture des correspondances\n"); + free(cor); + } + + /* sur les mailles : on ne prend pas en compte les mailles 3D */ + if (ret ==0) + for (j=0;j> ERREUR : lecture informations sur nombre de correspondances \n"); + } + else + fprintf(stdout,"\n - Il y a %d correspondances sur les mailles %s \n",ncor, + nommai[j]); + if (ncor > 0) + { + cor = (med_int*) malloc(sizeof(med_int)*ncor*2); + ret = MEDequivLire(fid,nommaa,equ,cor,ncor,MED_MAILLE, + typmai[j]); + if (ret == 0) + for (k=0;k> ERREUR : correspondances\n"); + free(cor); + } + } + + /* sur les faces */ + if (ret == 0) + for (j=0;j> ERREUR : informations sur correspondances \n"); + } + else + fprintf(stdout,"\n - Il y a %d correspondances sur les faces %s\n",ncor, + nomfac[j]); + if (ncor > 0) + { + cor = (med_int*) malloc(sizeof(med_int)*ncor*2); + ret = MEDequivLire(fid,nommaa,equ,cor,ncor,MED_FACE, + typfac[j]); + if (ret < 0) + strcpy(message,"ERREUR : lecture des equivalences \n"); + else + for (k=0;k> ERREUR : nombre de correspondances \n"); + } + else + fprintf(stdout,"\n - Il y a %d correspondances sur les aretes %s \n", + ncor,nomare[j]); + if (ncor > 0) + { + cor = (med_int*) malloc(sizeof(med_int)*ncor*2); + ret = MEDequivLire(fid,nommaa,equ,cor,ncor,MED_ARETE, + typare[j]); + if (ret < 0) + strcpy(message,">> ERREUR : equivalences \n"); + else + for (k=0;k> ERREUR : nombre de composants d'un champ\n"); + } + + /* allocation memoire de comp et unit*/ + if (ret == 0) + { + comp = (char*) malloc(ncomp*MED_TAILLE_PNOM+1); + unit = (char*) malloc(ncomp*MED_TAILLE_PNOM+1); + } + + /* infos sur les champs */ + if (ret == 0) + ret = MEDchampInfo(fid,i+1,nomcha,&typcha,comp,unit,ncomp); + if (ret < 0) + strcpy(message,">> ERREUR : information sur les champs \n"); + + if (ret == 0) { + fprintf(stdout," - Nom du champ : %s de type %d\n",nomcha,typcha); + fprintf(stdout," - Nom des composantes : %s\n",comp); + fprintf(stdout," - Unites des composantes : %s \n",unit); + free(comp); + free(unit); + } + + + if (ret == 0) /* Valeurs sur les noeuds */ + { + /* Combien de pas de temps ? */ + npdt = MEDnPasdetemps(fid,nomcha,MED_NOEUD,(med_geometrie_element)0); + if (npdt < 0) + ret = -1; + if (ret == -1) + strcpy(message,">> ERREUR : la lecture du nombe de pas de temps"); + else + fprintf(stdout,"\n - Il y a %d pas de temps sur les noeuds \n",npdt); + + /* Lecture des valeurs pour tous les pas de temps */ + if (ret == 0) + for (j=0;j \tPas de Temps n° %4i (%f), N°d'ordre %4i, avec %i pts de gauss\n", + numdt,dt,numo,ngauss); + else + strcpy(message,">> ERREUR : information sur les pas de temps \n"); + + /* Combien de valeurs a lire ? */ + if (ret == 0 && (! strcmp(maillage_champ,nommaa))) + { + if ((nval = MEDnVal(fid,nomcha,MED_NOEUD,(med_geometrie_element)0,numdt,numo)) < 0) + { + ret = -1; + strcpy(message,">> ERREUR : nombre de valeurs d'un champ\n"); + } + else + fprintf(stdout,"\n - Il y a %d valeurs sur les noeuds \n",nval); + } + + if (ret == 0 && (! strcmp(maillage_champ,nommaa))) + { + if (typcha == MED_REEL64) + { + valr = (med_float*) malloc(sizeof(med_float)*ncomp*nval); + ret = MEDchampLire(fid,nommaa,nomcha,(unsigned char*)valr,mode_coo,MED_ALL, + pflnom,MED_NOEUD,(med_geometrie_element)0,numdt,numo); + + if (ret < 0) + strcpy(message,">> ERREUR : lecture des champs \n"); + else + for (k=0;k> ERREUR : lecture des champs \n"); + else + for (k=0;k> ERREUR : lecture de la taille du profil \n"); + } + else + { + fprintf(stdout,"\n \t- Profil : %s de taille %i\n",pflnom,pflsize); + pflval = (med_int*) malloc(sizeof(med_int)*pflsize); + + if ( (ret = MEDprofilLire(fid,pflval,pflnom)) <0) + strcpy(message,">> ERREUR : lecture du profil \n"); + else + for (l=0;l> ERREUR : la lecture du nombe de pas de temps"); + else + fprintf(stdout,"\n - Il y a %d pas de temps sur les mailles de type %d \n",npdt,typgeo); + + /* Lecture des valeurs pour tous les pas de temps */ + if (ret == 0) + for (j=0;j \tPas de Temps n° %4i (%f), N°d'ordre %4i, avec %i pts de gauss\n", + numdt,dt,numo,ngauss); + else + strcpy(message,">> ERREUR : information sur les pas de temps \n"); + + /* Combien de valeurs a lire ? */ + if (ret == 0 && (! strcmp(maillage_champ,nommaa))) + { + if ((nval = MEDnVal(fid,nomcha,MED_MAILLE,typgeo,numdt,numo)) < 0) + { + ret = -1; + strcpy(message,">> ERREUR : nombre de valeurs d'un champ\n"); + } + else + fprintf(stdout,"\n - Il y a %d valeurs sur les noeuds \n",nval); + } + + if (ret == 0 && (! strcmp(maillage_champ,nommaa))) + { + if (typcha == MED_REEL64) + { + valr = (med_float*) malloc(sizeof(med_float)*ncomp*nval); + ret = MEDchampLire(fid,nommaa,nomcha,(unsigned char*)valr,mode_coo,MED_ALL, + pflnom,MED_MAILLE,typgeo,numdt,numo); + if (ret < 0) + strcpy(message,">> ERREUR : lecture des champs \n"); + else + for (kp=0;kp> ERREUR : lecture des champs \n"); + else + for (kp=0;kp> ERREUR : lecture de la taille du profil \n"); + } + else + { + fprintf(stdout,"\n \t- Profil : %s de taille %i\n",pflnom,pflsize); + pflval = (med_int*) malloc(sizeof(med_int)*pflsize); + + if ( (ret = MEDprofilLire(fid,pflval,pflnom)) <0) + strcpy(message,">> ERREUR : lecture du profil \n"); + else + for (l=0;l> ERREUR : la lecture du nombe de pas de temps"); + else + fprintf(stdout,"\n - Il y a %d pas de temps sur les faces de type %d \n",npdt,typgeo); + + /* Lecture des valeurs pour tous les pas de temps */ + if (ret == 0) + for (j=0;j \tPas de Temps n° %4i (%f), N°d'ordre %4i, avec %i pts de gauss\n", + numdt,dt,numo,ngauss); + else + strcpy(message,">> ERREUR : information sur les pas de temps \n"); + + /* Combien de valeurs a lire ? */ + if (ret == 0 && (! strcmp(maillage_champ,nommaa))) + { + if ((nval = MEDnVal(fid,nomcha,MED_FACE,typgeo,numdt,numo)) < 0) + { + ret = -1; + strcpy(message,">> ERREUR : nombre de valeurs d'un champ\n"); + } + else + fprintf(stdout,"\n - Il y a %d valeurs sur les noeuds \n",nval); + } + + if (ret == 0 && (! strcmp(maillage_champ,nommaa))) + { + if (typcha == MED_REEL64) + { + valr = (med_float*) malloc(sizeof(med_float)*ncomp*nval); + ret = MEDchampLire(fid,nommaa,nomcha,(unsigned char*)valr,mode_coo,MED_ALL, + pflnom,MED_FACE,typgeo,numdt,numo); + if (ret < 0) + strcpy(message,">> ERREUR : lecture des champs \n"); + else + for (kp=0;kp> ERREUR : lecture des champs \n"); + else + for (kp=0;kp> ERREUR : lecture de la taille du profil \n"); + } + else + { + fprintf(stdout,"\n \t- Profil : %s de taille %i\n",pflnom,pflsize); + pflval = (med_int*) malloc(sizeof(med_int)*pflsize); + + if ( (ret = MEDprofilLire(fid,pflval,pflnom)) <0) + strcpy(message,">> ERREUR : lecture du profil \n"); + else + for (l=0;l> ERREUR : la lecture du nombe de pas de temps"); + else + fprintf(stdout,"\n - Il y a %d pas de temps sur les aretes de type %d \n",npdt,typgeo); + + /* Lecture des valeurs pour tous les pas de temps */ + if (ret == 0) + for (j=0;j \tPas de Temps n° %4i (%f), N°d'ordre %4i, avec %i pts de gauss\n", + numdt,dt,numo,ngauss); + else + strcpy(message,">> ERREUR : information sur les pas de temps \n"); + + /* Combien de valeurs a lire ? */ + if (ret == 0 && (! strcmp(maillage_champ,nommaa))) + { + if ((nval = MEDnVal(fid,nomcha,MED_ARETE,typgeo,numdt,numo)) < 0) + { + ret = -1; + strcpy(message,">> ERREUR : nombre de valeurs d'un champ\n"); + } + else + fprintf(stdout,"\n - Il y a %d valeurs sur les noeuds \n",nval); + } + + if (ret == 0 && (! strcmp(maillage_champ,nommaa))) + { + if (typcha == MED_REEL64) + { + valr = (med_float*) malloc(sizeof(med_float)*ncomp*nval); + ret = MEDchampLire(fid,nommaa,nomcha,(unsigned char*)valr,mode_coo,MED_ALL, + pflnom,MED_ARETE,typgeo,numdt,numo); + if (ret < 0) + strcpy(message,">> ERREUR : lecture des champs \n"); + else + for (kp=0;kp> ERREUR : lecture des champs \n"); + else + for (kp=0;kp> ERREUR : lecture de la taille du profil \n"); + } + else + { + fprintf(stdout,"\n \t- Profil : %s de taille %i\n",pflnom,pflsize); + pflval = (med_int*) malloc(sizeof(med_int)*pflsize); + + if ( (ret = MEDprofilLire(fid,pflval,pflnom)) <0) + strcpy(message,">> ERREUR : lecture du profil \n"); + else + for (l=0;l>>>>> FIN DU DUMP DU FICHIER %s >>>>>>\n",argv[1]); + else + fprintf(stderr,">> ERREUR : erreur a la fermeture du fichier %s\n",argv[1]); + + return 0; +} diff --git a/src/MEDWrapper/V2_1/med.hxx b/src/MEDWrapper/V2_1/med.hxx new file mode 100644 index 000000000..2fe174f9a --- /dev/null +++ b/src/MEDWrapper/V2_1/med.hxx @@ -0,0 +1,164 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2003 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#ifndef MED_H +#define MED_H + +extern "C"{ +#include +} + +namespace med_2_1{ + +#define MED_NULL (void *) NULL +#define MED_MAX_PARA 20 + +#define MED_TAILLE_DESC 200 +#define MED_TAILLE_IDENT 8 +#define MED_TAILLE_NOM 32 +#define MED_TAILLE_LNOM 80 +#define MED_TAILLE_PNOM 8 + +/* Integration des developpements OCC */ +typedef enum {MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED} med_grid_type; + +typedef enum {MED_GRID_D1=0, MED_GRID_D2=1, MED_GRID_D3=2, + MED_GRID_NOEUD=3, + MED_FAM_NOEUD=4, MED_FAM_ARETE=5, MED_FAM_FACE=6, MED_FAM_MAILLE=7 } med_grid; + +/* Fin de l'integration*/ + +typedef enum {MED_FULL_INTERLACE, + MED_NO_INTERLACE} med_mode_switch; + +typedef enum {MED_GLOBALE, + MED_COMPACT } med_mode_profil; + +typedef enum {MED_LECT,MED_ECRI,MED_REMP} med_mode_acces; + +typedef enum {MED_MAILLE, MED_FACE, MED_ARETE, MED_NOEUD} med_entite_maillage; + +typedef enum {MED_COOR, MED_CONN, MED_NOM, MED_NUM, MED_FAM} med_table; + +typedef enum {MED_REEL64=6, MED_INT32=24,MED_INT64=26, MED_INT} med_type_champ; + +#define MED_NBR_GEOMETRIE_MAILLE 15 +#define MED_NBR_GEOMETRIE_FACE 4 +#define MED_NBR_GEOMETRIE_ARETE 2 +typedef enum {MED_POINT1=1, MED_SEG2=102, MED_SEG3=103, MED_TRIA3=203, + MED_QUAD4=204, MED_TRIA6=206,MED_QUAD8=208, MED_TETRA4=304, + MED_PYRA5=305, MED_PENTA6=306, MED_HEXA8=308, MED_TETRA10=310, + MED_PYRA13=313, MED_PENTA15=315, MED_HEXA20=320} +med_geometrie_element; + +typedef enum {MED_NOD, MED_DESC} med_connectivite ; + +typedef enum {MED_CART, MED_CYL, MED_SPHER} med_repere; + +typedef enum {MED_FAUX, MED_VRAI} med_booleen ; + +typedef enum {MED_GROUPE, MED_ATTR, MED_FAMILLE} med_dim_famille; + +typedef enum {MED_COMP, MED_DTYPE} med_dim_champ; + +typedef enum {MED_HDF_VERSION, MED_VERSION, MED_FICH_DES} med_fich_info; + +#define MED_NOPG 1 /* -> pas de point de Gauss */ +#define MED_NOPFL "" /* -> pas de profils utilisateur */ +#define MED_NOPFLi " " /* Variable Interne */ +#define MED_NOPF 0 /* -> pas de profils pour _MEDdataseNnumEcrire */ +#define MED_NOPDT -1 /* rem: pas de pas de temps negatifs */ +#define MED_NONOR -1 /* rem: pas de n°ordre negatif */ +#define MED_DIM1 1 /* PAS */ +#define MED_ALL 0 + +#if defined(SUN4SOL2) || defined(PCLINUX) || defined(OSF1_32) || defined(IRIX64_32) || defined(RS6000) +/* interface C/FORTRAN */ +/* this true only with g77 and gcc : we must change it to use directly NOMF_... and INT32 or INT64 - + it will be more simple to understand and to use ! */ +#define NOMF_POST_UNDERSCORE + +/* correspondance des types avec HDF 5 */ +typedef hsize_t med_size; +typedef hssize_t med_ssize; +typedef hid_t med_idt; +typedef herr_t med_err; + +/* types elementaires */ +typedef int med_int; +typedef double med_float; +#endif + +#if defined(HP9000) +/* correspondance des types avec HDF 5 */ +typedef hsize_t med_size; +typedef hssize_t med_ssize; +typedef hid_t med_idt; +typedef herr_t med_err; + +/* types elementaires */ +typedef int med_int; +typedef double med_float; +#endif + +#if defined(IRIX64) || defined(OSF1) +#define NOMF_POST_UNDERSCORE + +/* correspondance des types avec HDF 5 */ +typedef hsize_t med_size; +typedef hssize_t med_ssize; +typedef hid_t med_idt; +typedef herr_t med_err; + +/* types elementaires */ +typedef long med_int; +typedef double med_float; +#endif + + +#if defined(PPRO_NT) +/* correspondance des types avec HDF 5 */ +typedef hsize_t med_size; +typedef hssize_t med_ssize; +typedef hid_t med_idt; +typedef herr_t med_err; + +/* types elementaires */ +typedef int med_int; +typedef double med_float; +#endif + + +#if defined(NOMF_PRE_UNDERSCORE) && defined(NOMF_POST_UNDERSCORE) +# define NOMF(x) _##x##_ +#endif +#if defined(NOMF_PRE_UNDERSCORE) && !defined(NOMF_POST_UNDERSCORE) +# define NOMF(x) _##x +#endif +#if !defined(NOMF_PRE_UNDERSCORE) && defined(NOMF_POST_UNDERSCORE) +# define NOMF(x) x##_ +#endif +#if !defined(NOMF_PRE_UNDERSCORE) && !defined(NOMF_POST_UNDERSCORE) +# define NOMF(x) x +#endif + +} + +#include "med_proto.hxx" + +#endif /* MED_H */ diff --git a/src/MEDWrapper/V2_1/med_hdfi.hxx b/src/MEDWrapper/V2_1/med_hdfi.hxx new file mode 100644 index 000000000..670ff63a9 --- /dev/null +++ b/src/MEDWrapper/V2_1/med_hdfi.hxx @@ -0,0 +1,120 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#ifndef MED_HDFI_H +#define MED_HDFI_H +#include "med.hxx" + +/* FONCTIONS INTERFACE MED/HDF */ +namespace med_2_1{ + +/* Gestion des fichiers HDF */ +extern +med_idt _MEDfichierCreer(char *nom); + +extern +med_idt _MEDfichierOuvrir(char *nom,med_mode_acces mode); + +extern +med_err _MEDfichierFermer(med_idt fid); + + +/* Gestion des datagroups HDF */ +extern +med_idt _MEDdatagroupCreer(med_idt pid, char *nom); + +extern +med_idt _MEDdatagroupOuvrir(med_idt pid, char *nom); + +extern +med_err _MEDdatagroupFermer(med_idt id); + + +/* Gestion des datasets HDF */ + +extern +med_idt _MEDdatasetOuvrir(med_idt pid,char *nom); + +extern +med_err _MEDdatasetFermer(med_idt id); + +extern +med_err _MEDdatasetNumEcrire (med_idt pere,char *nom, med_type_champ type, + med_mode_switch interlace, med_size nbdim, med_size fixdim, + med_size psize, med_ssize * profil, med_int ngauss, + med_size *size, unsigned char *val, med_mode_acces mode); + + +extern +med_err _MEDdatasetNumLire(med_idt pere,char *nom,med_type_champ type, + med_mode_switch interlace, med_size nbdim, med_size fixdim, + med_size psize, med_ssize * pfltab, med_int ngauss, + unsigned char *val); + +extern +med_err _MEDdatasetStringEcrire(med_idt pere,char *nom,med_size *dimd, + char *val, med_mode_acces mode); + +extern +med_err _MEDdatasetStringLire(med_idt pere,char *nom,char *val); + +/* Gestion des attributs HDF */ +extern +med_idt _MEDattrOuvrir(med_idt pid,char * nom); + +extern +med_err _MEDattrFermer(med_idt id); + +extern +med_err _MEDattrNumEcrire(med_idt pere,med_type_champ type,char *nom,unsigned char *val,med_mode_acces mode); + +#define _MEDattrEntierEcrire(w,x,y,z) _MEDattrNumEcrire(w,MED_INT ,x,(unsigned char *) y,z) +#define _MEDattrFloatEcrire(w,x,y,z) _MEDattrNumEcrire(w,MED_REEL64,x,(unsigned char *) y,z) + +extern +med_err _MEDattrNumLire(med_idt pere,med_type_champ type,char *nom,unsigned char *val); + +#define _MEDattrEntierLire(x,y,z) _MEDattrNumLire(x,MED_INT ,y,(unsigned char*)z) +#define _MEDattrFloatLire(x,y,z) _MEDattrNumLire(x,MED_REEL64,y,(unsigned char*)z) + +extern +med_err _MEDattrStringEcrire(med_idt pere,char *nom,int longueur,char *val,med_mode_acces mode); + +extern +med_err _MEDattrStringLire(med_idt pere,char *nom,int longueur,char *val); + + +/* Divers */ +extern +med_err _MEDindiceInfo(med_idt id, const char *nom, void *donnees); + +extern +med_err _MEDindiceNum(med_idt id,const char *nom, void *donnees); + +extern +med_err _MEDobjetIdentifier(med_idt fid,char *chemin,int indice,void *nom); + +extern +med_err _MEDnObjets(med_idt fid,char *chemin,int *n); + +extern +void _MEDmodeErreurVerrouiller(); + +} + +#endif /* MED_HDFI_H */ diff --git a/src/MEDWrapper/V2_1/med_misc.hxx b/src/MEDWrapper/V2_1/med_misc.hxx new file mode 100644 index 000000000..9e9676ec8 --- /dev/null +++ b/src/MEDWrapper/V2_1/med_misc.hxx @@ -0,0 +1,62 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#ifndef MED_MISC_H +#define MED_MISC_H +#include "med.hxx" + + +/* CHAINES DE CARACTERES FORTRAN => C */ +namespace med_2_1{ + +extern +char *_MED1cstring(char *chaine,int longueur_reelle,int longueur_fixee); + +extern +char *_MED2cstring(char *chaine, int longueur); + +extern +med_err _MEDcstringFree(char *chaine); + +extern +med_err _MEDfstring(char *chaine, med_int longueur_fixee); + +/* Noms associes aux objets MED */ +extern +med_err _MEDnomEntite(char *nom_ent,med_entite_maillage type_ent); + +extern +med_err _MEDnomGeometrie(char *nom_geo,med_geometrie_element type_geo); + +extern +med_err _MEDparametresGeometrie(med_entite_maillage type_ent, + med_geometrie_element type_geo, int *dim, int *nnoe, + int *ndes); +extern +med_err _MEDnomDataset(char *nom_dataset,med_table quoi, + med_connectivite type_conn); + +/* Geometrie des objets MED */ +extern +med_err _MEDGeometrieElement(med_geometrie_element typ_geo[], + med_entite_maillage typ_ent); + +} + +#endif /* MED_MISC_H */ + diff --git a/src/MEDWrapper/V2_1/med_outils.hxx b/src/MEDWrapper/V2_1/med_outils.hxx new file mode 100644 index 000000000..b897a6219 --- /dev/null +++ b/src/MEDWrapper/V2_1/med_outils.hxx @@ -0,0 +1,127 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2003 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#ifndef MED_OUTILS_H +#define MED_OUTILS_H +#include "med.hxx" + +#define MED_NOM_MAJEUR "MAJ" +#define MED_NOM_MINEUR "MIN" +#define MED_NOM_RELEASE "REL" + +#define MED_NUM_MAJEUR 2 +#define MED_NUM_MINEUR 1 +#define MED_NUM_RELEASE 6 + +#define MED_NOM_INFOS "INFOS_GENERALES" + +#define MED_NOM_DESCRIPTEUR "descripteur de fichier" +#define MED_VERSION_ACTUELLE "2.1.6" +#define HDF_VERSION_ACTUELLE "5-1.4.4" + +/* Noms des data sets ou attributs correspondant a des entites MED */ +#define MED_TAILLE_NOM_ENTITE 3 +#define MED_NOM_NUM "NUM" +#define MED_NOM_NBR "NBR" +#define MED_NOM_NOM "NOM" +#define MED_NOM_UNV "UNV" +#define MED_NOM_NNS "NNS" +#define MED_NOM_NNM "NNM" +#define MED_NOM_NNI "NNI" +#define MED_NOM_GRO "GRO" +#define MED_NOM_ATT "ATT" +#define MED_NOM_NCO "NCO" +#define MED_NOM_DIM "DIM" +#define MED_NOM_FAM "FAM" +#define MED_NOM_IDE "IDE" +#define MED_NOM_VAL "VAL" +#define MED_NOM_DES "DES" +#define MED_NOM_COR "COR" +#define MED_NOM_DIM "DIM" +#define MED_NOM_NOE "NOE" +#define MED_NOM_COO "COO" +#define MED_NOM_REP "REP" +#define MED_NOM_UNI "UNI" +#define MED_NOM_NOD "NOD" +#define MED_NOM_TYP "TYP" +#define MED_NOM_CO "CO" +#define MED_NOM_NCW "NCW" +#define MED_NOM_TYW "TYW" +#define MED_NOM_MAI "MAI" +#define MED_NOM_FAC "FAC" +#define MED_NOM_ARE "ARE" +#define MED_NOM_PO1 "PO1" +#define MED_NOM_SE2 "SE2" +#define MED_NOM_SE3 "SE3" +#define MED_NOM_TR3 "TR3" +#define MED_NOM_TR6 "TR6" +#define MED_NOM_QU4 "QU4" +#define MED_NOM_QU8 "QU8" +#define MED_NOM_TE4 "TE4" +#define MED_NOM_T10 "T10" +#define MED_NOM_HE8 "HE8" +#define MED_NOM_H20 "H20" +#define MED_NOM_PE6 "PE6" +#define MED_NOM_P15 "P15" +#define MED_NOM_PY5 "PY5" +#define MED_NOM_P13 "P13" + +#define MED_NOM_GEO "GEO" +#define MED_NOM_GAU "GAU" +#define MED_NOM_NGA "NGA" +#define MED_NOM_N "N" +#define MED_NOM_PFL "PFL" +#define MED_NOM_NDT "NDT" +#define MED_NOM_PDT "PDT" +#define MED_NOM_NOR "NOR" + +/* Integration des developpements OCC */ +#define MED_NOM_GRD "GRD" +#define MED_NOM_BOF "BOF" +#define MED_NOM_IN1 "IN1" +#define MED_NOM_IN2 "IN2" +#define MED_NOM_IN3 "IN3" + +/* Nom du DATA GROUP CONTENANT TOUS LES MAILLAGES DU FICHIER HDF */ +#define MED_MAA "/ENS_MAA/" +#define MED_TAILLE_MAA 9 + +/* Nom du data group ou ranger les champs solution */ +#define MED_CHA "/CHA/" +#define MED_TAILLE_CHA 5 + +/* Nom du data group ou ranger les familles */ +#define MED_FAS "/FAS/" +#define MED_TAILLE_FAS 5 + +/* Nom du data group ou ranger les equivalences */ +#define MED_EQS "/EQS/" +#define MED_TAILLE_EQS 5 + +/* Nom du data groupe contenant les profils */ +#define MED_PROFILS "/PROFILS/" +#define MED_TAILLE_PROFILS 9 + +/*Pour eviter le bug solaris*/ +#include + +/* Interface des routines du composant tools */ +#include "med_misc.hxx" +#include "med_hdfi.hxx" +#include "med_utils.hxx" +#endif /* MED_OUTILS_H */ diff --git a/src/MEDWrapper/V2_1/med_proto.hxx b/src/MEDWrapper/V2_1/med_proto.hxx new file mode 100644 index 000000000..1847b56a8 --- /dev/null +++ b/src/MEDWrapper/V2_1/med_proto.hxx @@ -0,0 +1,276 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +#ifndef MED_PROTO_H +#define MED_PROTO_H + +/* Interface de l'API MED */ +namespace med_2_1{ +/* Fichier */ +extern med_idt +MEDouvrir(char *nom, med_mode_acces mode_acces); +extern med_err +MEDfermer(med_idt fid); +extern med_int +MEDlFichDes(med_idt fid); +extern med_err +MEDfichEntete(med_idt fid, med_fich_info quoi, char str[]); +extern med_err +MEDfichDesEcr(med_idt fid, char *des, med_mode_acces mode); +extern med_err +MEDunvCr(med_idt fid, char *maa); +extern med_err +MEDunvLire(med_idt fid, char *maa,char *nomu); +extern med_err +MEDformatConforme(const char * nomfich); +extern med_err +MEDversionConforme(const char *nom); +extern void +MEDversionDonner(med_int *majeur, med_int *mineur, med_int *release); +extern med_err +MEDversionLire(med_idt fid, med_int *majeur, med_int *mineur, med_int *release); + + + +/* Maillage */ +extern med_err +MEDmaaCr(med_idt fid, char *maillage, med_int dim); +extern med_int +MEDdimLire(med_idt fid, char *maillage); +extern med_err +MEDmaaInfo(med_idt fid, int indice, char *maillage, med_int *dim); +extern med_int +MEDnMaa(med_idt fid); +extern med_err +MEDnbnosoEcr(med_idt fid, char *nom_maillage,med_int n); +extern med_int +MEDnbnosoLire(med_idt fid,char *nom_maillage); +extern med_err +MEDnbnoisEcr(med_idt fid, char *nom_maillage,med_int n); +extern med_int +MEDnbnoisLire(med_idt fid,char *nom_maillage); +extern med_err +MEDnbnomaEcr(med_idt fid, char *nom_maillage,med_int n); +extern med_int +MEDnbnomaLire(med_idt fid,char *nom_maillage); + +/* EntMaillage */ +extern med_err +MEDconnEcr(med_idt fid,char *maa, med_int mdim, med_int *connectivite,med_mode_switch mode_switch, + med_int nbre,med_mode_acces mode,med_entite_maillage type_ent, + med_geometrie_element type_geo,med_connectivite type_conn); + +extern med_err +MEDconnLire(med_idt fid,char *maa,med_int mdim,med_int *connectivite,med_mode_switch mode_switch, + med_int * pfltab, med_size psize, + med_entite_maillage type_ent, med_geometrie_element type_geo,med_connectivite type_conn); +extern med_err +MEDnomEcr(med_idt fid,char *maa, char *nom, med_int n, med_mode_acces mode, + med_entite_maillage type_ent,med_geometrie_element type_geo); +extern med_err +MEDnomLire(med_idt fid,char *maa, char *nom, med_int n, + med_entite_maillage type_ent,med_geometrie_element type_geo); +extern med_err +MEDnumLire(med_idt fid,char *maa, med_int *num, med_int n, + med_entite_maillage type_ent,med_geometrie_element type_geo); +extern med_err +MEDnumEcr(med_idt fid,char *maa, med_int *num, med_int n, med_mode_acces mode, + med_entite_maillage type_ent,med_geometrie_element type_geo); +extern med_err +MEDcoordEcr(med_idt fid, char *maa, med_int mdim, med_float *coo, + med_mode_switch mode_coo,med_int n, + med_mode_acces mode, med_repere type_rep, char *nom, char *unit); +extern med_err +MEDcoordLire(med_idt fid, char *maa, med_int mdim, med_float *coo, + med_mode_switch mode_coo,med_int numco, + med_int * pfltab, med_size psize, med_repere *type_rep, char *nom, char *unit); + +extern med_int +MEDnEntMaa(med_idt fid, char *maa, med_table quoi, med_entite_maillage type_ent, + med_geometrie_element type_geo, med_connectivite type_conn); + + +/* Resultat */ +extern med_err MEDchampCr(med_idt fid, char *champ, med_type_champ type, char *comp, + char *unit,med_int ncomp); + +extern med_err +MEDchampEcr(med_idt fid, char *maa, char *cha,unsigned char *val,med_mode_switch interlace,med_int nbelem,med_int ngauss, + med_int numco, char * profil, med_mode_acces mode, med_entite_maillage type_ent, + med_geometrie_element type_geo, med_int numdt,char * dt_unit, med_float dt, med_int numo); + +extern med_err +MEDchampLire(med_idt fid,char *maa, char *cha, unsigned char *val,med_mode_switch interlace,med_int numco, + char *profil,med_entite_maillage type_ent, med_geometrie_element type_geo, + med_int numdt, med_int numo); + +extern med_err +MEDchampInfo(med_idt fid,int indice,char *champ, + med_type_champ *type,char *comp,char *unit, + med_int ncomp); + +extern med_int +MEDnChamp(med_idt fid, int indice); + +extern med_int +MEDnVal(med_idt fid, char *champ, med_entite_maillage typ_ent, + med_geometrie_element typ_geo,med_int numdt, med_int numo); + + +/* Famille */ +extern med_err +MEDfamEcr(med_idt fid,char *maa, med_int *fam, med_int n, med_mode_acces mode, + med_entite_maillage type_ent, med_geometrie_element type_geo); +extern med_err +MEDfamLire(med_idt fid,char *maa, med_int *fam, med_int n, + med_entite_maillage type_ent,med_geometrie_element type_geo); +extern med_err +MEDfamCr(med_idt fid,char* maa,char *famille,med_int numero, + med_int *attr_ident, med_int *attr_val,char *attr_desc,med_int n_attr, + char *groupe , med_int n_groupe); +extern med_int +MEDnFam(med_idt fid,char *maa, int indice, med_dim_famille quoi); + +extern med_err +MEDfamInfo(med_idt fid,char *maa,int indice, char *famille, + med_int *numero, + med_int *attr_ident, med_int *attr_val, char *attr_desc, + med_int *n_attr,char *groupe ,med_int *n_groupe); + +/* Equivalence */ +extern med_err +MEDequivCr(med_idt fid,char *maa, char *eq, char *desc); +extern med_err +MEDequivLire(med_idt fid, char *maa, char *eq, med_int *corr, med_int n, + med_entite_maillage typ_ent,med_geometrie_element typ_geo); +extern med_err +MEDequivEcr(med_idt fid, char *maa, char *eq, med_int *corr, med_int n, + med_mode_acces mode, med_entite_maillage typ_ent, med_geometrie_element typ_geo); +extern med_err +MEDequivInfo(med_idt fid, char *maa, int ind, char *eq, char *des); +extern med_int +MEDnEquiv(med_idt fid, char *maa); +extern med_int +MEDnCorres(med_idt fid,char *maa,char *eq,med_entite_maillage typ_ent, + med_geometrie_element typ_geo); + + +/* Routines de niveau intermediaire */ +extern med_int +MEDnEntites(med_idt fid,char *maa,med_entite_maillage typ_ent, + med_connectivite typ_con); + +extern med_err +MEDnoeudsLire(med_idt fid,char *maa,med_int mdim, med_float *coord, + med_mode_switch mode_coo, + med_repere *repere,char *nomcoo, char *unicoo,char *nom, + med_booleen *inom,med_int *num,med_booleen *inum,med_int *fam, + med_int nnoeuds); + +extern med_err +MEDnoeudsEcr(med_idt fid,char *maa,med_int mdim,med_float *coord, + med_mode_switch mode_coo, + med_repere repere,char *nomcoo, char *unicoo,char *nom, + med_booleen inom,med_int *num,med_booleen inum,med_int *fam, + med_int nnoeuds,med_mode_acces mode); +extern med_err +MEDelementsEcr(med_idt fid,char *maa,med_int mdim,med_int *connectivite,med_mode_switch mode_switch, + char *nom,med_booleen inom,med_int *num,med_booleen inum, + med_int *fam,med_int nele,med_entite_maillage typ_ent, + med_geometrie_element typ_geo,med_connectivite typ_conn,med_mode_acces mode); +extern med_err +MEDelementsLire(med_idt fid,char *maa,med_int mdim,med_int *connectivite,med_mode_switch mode_switch, + char *nom,med_booleen *inom,med_int *num,med_booleen *inum, + med_int *fam,med_int nele,med_entite_maillage typ_ent, + med_geometrie_element typ_geo,med_connectivite typ_conn); + +/* Routines de haut niveau */ + +/*(? On enlève le reste ?)*/ + +extern med_err +MEDfamMaaInfo(med_idt fid,char *maa,med_int *nfam,med_int *nattc, + med_int *ngroc); + +extern med_err +MEDfamMaaLire(med_idt fid,char *maa, + med_int *numfam,med_int *attide, + med_int *attval,char *attdes,int *indatt,char *gro,int *indgro, + med_int nfamilles); + +extern med_err +MEDfamMaaCr(med_idt fid,char *maa, + med_int *numfam,med_int *attide, + med_int *attval,char *attdes,int *indatt,char *gro,int *indgro, + med_int nfamilles); + +/* Routines concernant les profils */ + +extern med_err +MEDprofilInfo(med_idt fid, int indice, char *profil, med_int *n); + +extern med_int +MEDnProfil(med_idt fid); + +extern med_err +MEDprofilEcr(med_idt fid,med_int *pflval,med_int n,char *nom); + +extern med_int +MEDnValProfil(med_idt fid, char *nom); + +extern med_err +MEDprofilLire(med_idt fid, med_int *pflval, char *nom); + +/* Routines concernant les pas de temps/ numéros d'ordre */ + +extern med_int +MEDnPasdetemps(med_idt fid,char *cha,med_entite_maillage type_ent, + med_geometrie_element type_geo); + +extern med_err +MEDpasdetempsInfo(med_idt fid,char *champ + ,med_entite_maillage type_ent, med_geometrie_element type_geo, + int indice, char *maa, med_int * ngauss, med_int * numdt, char * dt_unit, med_float * dt, + med_int * numo); + +/* Grilles */ + +med_int MEDnGrid(med_idt fid, char *maa, med_grid n); +med_err MEDgridCr(med_idt fid, char *maillage, med_int dim, med_grid_type typ); +med_err MEDgridInfo(med_idt fid, int indice, med_int *isAGrid, med_grid_type *typ); +med_err MEDgridEcr( + med_idt fid, char *maa, med_int mdim, med_float *coo, med_int nb, med_int dim, med_mode_switch mode_coo, + med_repere repere, char *nomcoo, char *unicoo, med_mode_acces mode ); +med_err MEDgridLire( + med_idt fid, char *maa, med_int mdim, med_float *coo, med_int dim, med_mode_switch mode_coo, + med_repere *repere, char *nomcoo, char *unicoo ); +med_err MEDfamGridEcr(med_idt fid, char *maa, med_int *fam, med_int n, med_mode_acces mode, med_entite_maillage type_ent); +med_err MEDfamGridLire(med_idt fid, char *maa, med_int *fam, med_int n, med_entite_maillage type_ent); +med_err MEDbodyFittedEcr( + med_idt fid, char *maa, med_int mdim, med_float *coo, med_int *nbr, med_mode_switch mode_coo, + med_repere repere, char *nomcoo, char *unicoo, med_int *fam, med_int nnoeuds, med_mode_acces mode ); +med_err MEDbodyFittedLire( + med_idt fid, char *maa, med_int mdim, med_float *coo, med_mode_switch mode_coo, + med_repere *repere, char *nomcoo, char *unicoo, med_int *fam, med_int nnoeuds ); +} + +#endif /* MED_PROTO_H */ + + + + diff --git a/src/MEDWrapper/V2_1/med_utils.hxx b/src/MEDWrapper/V2_1/med_utils.hxx new file mode 100644 index 000000000..0c16d650e --- /dev/null +++ b/src/MEDWrapper/V2_1/med_utils.hxx @@ -0,0 +1,261 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +# ifndef __UTILITES_H__ +# define __UTILITES_H__ + + +/* pour indiquer le statut des arguments des fonctions. */ + +#ifdef _IN +#error _IN already defined +#endif +#define _IN + +#ifdef _OUT +#error _OUT already defined +#endif +#define _OUT + +#ifdef _INOUT +#error _INOUT already defined +#endif +#define _INOUT + +#ifdef _UNUSED +#error _UNUSED already defined +#endif +#define _UNUSED + + + + + + + +/* --- Pour afficher le nom du fichier source courant et le numero de la ligne courante --- */ +/* --- sur la stderr. --- */ + +# define ICI {\ + fflush(stdout);\ + fprintf(stderr, "%s [%d] : " , __FILE__ , __LINE__ ) ;\ + fflush(stderr) ;\ + } + + + + + + + +/* --- Pour afficher la date et l'heure de la compilation du fichier source courant, --- */ +/* --- sur la stdout. --- */ + +# ifdef INFOS_COMPILATION +# error INFOS_COMPILATION already defined +# endif +# define INFOS_COMPILATION {\ + fflush(stderr);\ + fprintf(stdout, "%s [%d] : " , __FILE__ , __LINE__ ) ;\ + fprintf(stdout,"Compilation le %s" , __DATE__);\ + fprintf(stdout," a %s" , __TIME__ );\ + fprintf(stdout,"\n\n\n" );\ + fflush(stdout) ;\ + } + + + + + + + +/* --- Pour attendre "secondes" secondes et afficher un message sur la stderr indiquant --- */ +/* --- cette attente volontaire. --- */ + +# ifdef ATTENTE +# error ATTENTE already defined +# endif +# define ATTENTE(secondes) {\ + ICI ;\ + fprintf( stderr, "ATTENTE de %d secondes" , secondes);\ + fflush(stderr) ;\ + sleep(secondes) ;\ + fprintf( stderr, "\n" );\ + fflush(stderr) ;\ + } + + + + + + + +/* ---------- Les macros suivantes ne doivent pas deja exister ! ---------- */ + +# ifdef EXECUTION +# error EXECUTION already defined +# endif +# ifdef INTERRUPTION +# error INTERRUPTION already defined +# endif +# ifdef ISCRUTE +# error ISCRUTE already defined +# endif +# ifdef RSCRUTE +# error RSCRUTE already defined +# endif +# ifdef SSCRUTE +# error SSCRUTE already defined +# endif +# ifdef CSCRUTE +# error CSCRUTE already defined +# endif +# ifdef XSCRUTE +# error XSCRUTE already defined +# endif +# ifdef MESSAGE +# error MESSAGE already defined +# endif + + + + + +# ifdef _DEBOG_ + + +/* --- Pour tracer sur la stderr l'execution d"une instruction. --- */ + +# define EXECUTION(instruction) {\ + ICI ;\ + fprintf( stderr,"INSTRUCTION %s" , #instruction ) ;\ + fflush(stderr);\ + instruction ;\ + fflush(stdout);\ + fprintf( stderr," FRANCHIE\n" ) ;\ + fflush(stderr);\ + } + + + + + + + +/* --- Pour afficher un message d'interruption volontaire et retourner le code retour --- */ +/* --- "code" --- */ + +# define INTERRUPTION(code) {\ + ICI ;\ + fprintf( stderr," INTERRUPTION code = %d",code) ;\ + fprintf(stderr,"\n") ;\ + exit(code) ;\ + } + + + + + + + +/* --- Pour conditionner la poursuite du traitement par la validite de la condition --- */ +/* --- "condiiton". --- */ + +# ifndef ASSERT +# define ASSERT(condition) if( !(condition) ){\ + ICI ;\ + fprintf(stderr,"condition %s VIOLEE\n",#condition);\ + INTERRUPTION(17);\ + } +# endif /* # ifndef ASSERT */ + + + + + + + +/* --- Pour afficher sur la stderr la valeur d'une variable precedee de son nom. --- */ + +# define ISCRUTE(entier) {\ + ICI ;\ + fprintf(stderr,"%s = %d\n",#entier,entier) ;\ + fflush(stderr) ;\ + } +# define RSCRUTE(reel) {\ + ICI ;\ + fprintf(stderr,"%s = %f\n",#reel,reel) ;\ + fflush(stderr) ;\ + } +# define XSCRUTE(pointeur) {\ + ICI ;\ + fprintf(stderr,"%s = %x\n",#pointeur,pointeur) ;\ + fflush(stderr) ;\ + } +# define CSCRUTE(car) {\ + ICI ;\ + fprintf(stderr,"%s = %c\n",#car,car) ;\ + fflush(stderr) ;\ + } +# define SSCRUTE(chaine) {\ + ICI ;\ + fprintf(stderr,"%s = \"%s\"\n",#chaine,chaine) ;\ + fflush(stderr) ;\ + } +# define MESSAGE(chaine) {\ + ICI ;\ + fprintf(stderr,"%s\n",chaine) ;\ + fflush(stderr) ;\ + } +# define FIN(nom) {\ + ICI ;\ + fprintf( stderr , "} FIN %s\n\n\n" , nom ) ;\ + fflush(stderr) ;\ + } +# define DEBUT(nom) {\ + fprintf( stderr , "\n\n\n") ;\ + ICI ;\ + fprintf( stderr , "{ DEBUT %s\n" , nom ) ;\ + fflush(stderr) ;\ + } + + +# else /* # ifdef _DEBOG_ */ + + + +# define EXECUTION(instruction) instruction +# define INTERRUPTION(code) + +# ifndef ASSERT +# define ASSERT(condition) +# endif + +# define ISCRUTE(entier) +# define RSCRUTE(reel) +# define CSCRUTE(car) +# define SSCRUTE(chaine) +# define MESSAGE(chaine) +# define DEBUT(nom) +# define FIN(nom) + + +# endif /* # ifdef _DEBOG_ */ + + +# endif /* # ifndef __UTILITES_H__ */ diff --git a/src/MEDWrapper/V2_1/test1_V2_1.cxx b/src/MEDWrapper/V2_1/test1_V2_1.cxx new file mode 100644 index 000000000..20746cb11 --- /dev/null +++ b/src/MEDWrapper/V2_1/test1_V2_1.cxx @@ -0,0 +1,72 @@ +/************************************************************************* +* COPYRIGHT (C) 1999 - 2002 EDF R&D +* 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, OR (AT YOUR OPTION) ANY LATER VERSION. +* +* 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 +* +*************************************************************************/ + +/****************************************************************************** + * - Nom du fichier : test1.c + * + * - Description : tests des routines d'ouverture/fermeture des + * fichiers MED + * + *****************************************************************************/ + +#include "med.hxx" +using namespace med_2_1; + +/****************************************************************************** + * OUVERTURE/FERMETURE DE FICHIERS : + * + * Description : + * - ouverture du fichier en mode ecriture avec remplacement + * - ecriture d'une description du fichier (optionnel) + * - fermeture du fichier + * - ouverture du fichier en mode de lecture + * - fermeture du fichier + *****************************************************************************/ + +int main (int argc, char **argv) +{ + med_err ret = 0; + med_idt fid; + char des[MED_TAILLE_DESC+1]="Ceci est un courte description du mon fichier test1.med"; + + fid = MEDouvrir("test1.med",MED_REMP); + if (fid < 0) + ret = -1; + printf("%d\n",ret); + + if (ret == 0) + ret = MEDfichDesEcr(fid,des, MED_REMP); + printf("%d\n",ret); + + ret = MEDfermer(fid); + printf("%d\n",ret); + + fid = MEDouvrir("test1.med",MED_LECT); + if (fid < 0) + ret = -1; + printf("%d\n",ret); + + ret = MEDfermer(fid); + printf("%d\n",ret); + + return 0; +} + + + + diff --git a/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx b/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx new file mode 100644 index 000000000..179bfa45c --- /dev/null +++ b/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx @@ -0,0 +1,1451 @@ +// +// +// 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 : +// Author : +// Module : +// $Header$ + +#include "MED_V2_2_Wrapper.hxx" +#include "MED_Utilities.hxx" + +extern "C"{ +#include +} + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + + + +namespace MED{ + namespace V2_2{ + + //--------------------------------------------------------------- + class TFile{ + TFile(); + TFile(const TFile&); + + public: + TFile(const std::string& theFileName): + myFid(0), + myCount(0), + myFileName(theFileName) + {} + + ~TFile(){ + Close(); + } + + void Open(EModeAcces theMode, TErr* theErr = NULL){ + if(myCount++ == 0){ + char* aFileName = const_cast(myFileName.c_str()); + myFid = MEDouvrir(aFileName,med_mode_acces(theMode)); + } + if(theErr) + *theErr = TErr(myFid > 0); + else if(myFid < 0) + EXCEPTION(runtime_error,"TFile - MEDouvrir('"<Open(theMode,theErr); + } + + ~TFileWrapper(){ + myFile->Close(); + } + }; + + + //--------------------------------------------------------------- + TVWrapper::TVWrapper(const std::string& theFileName): + myFile(new TFile(theFileName)) + { + } + + + TInt TVWrapper::GetNbMeshes(TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return -1; + + return MEDnMaa(myFile->Id()); + } + + + void TVWrapper::GetMeshInfo(TInt theMeshId, + MED::TMeshInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return; + + med_maillage& aType = (med_maillage&)(theInfo.myType); + + TErr aRet = MEDmaaInfo(myFile->Id(), + theMeshId, + &theInfo.myName[0], + (med_int *)&theInfo.myDim, + &aType, + &theInfo.myDesc[0]); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetMeshInfo - MEDmaaInfo(...)"); + } + + + void TVWrapper::SetMeshInfo(const MED::TMeshInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && !*theErr) + return; + + MED::TMeshInfo& anInfo = const_cast(theInfo); + + med_maillage& aType = (med_maillage&)(theInfo.myType); + + TErr aRet = MEDmaaCr(myFile->Id(), + &anInfo.myName[0], + anInfo.myDim, + aType, + &anInfo.myDesc[0]); + if(aRet == 0){ + aRet = MEDunvCr(myFile->Id(), + &anInfo.myName[0]); + } + + INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<(theInfo); + return MEDnFam(myFile->Id(), + &anInfo.myName[0]); + } + + + TInt TVWrapper::GetNbFamAttr(TInt theFamId, + const MED::TMeshInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return -1; + + MED::TMeshInfo& anInfo = const_cast(theInfo); + return MEDnAttribut(myFile->Id(), + &anInfo.myName[0], + theFamId); + } + + + TInt TVWrapper::GetNbFamGroup(TInt theFamId, + const MED::TMeshInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return -1; + + MED::TMeshInfo& anInfo = const_cast(theInfo); + return MEDnGroupe(myFile->Id(), + &anInfo.myName[0], + theFamId); + } + + + void TVWrapper::GetFamilyInfo(TInt theFamId, + MED::TFamilyInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + + TErr aRet = MEDfamInfo(myFile->Id(), + &aMeshInfo.myName[0], + theFamId, + &theInfo.myName[0], + (med_int *)&theInfo.myId, + (med_int *)&theInfo.myAttrId[0], + (med_int *)&theInfo.myAttrVal[0], + &theInfo.myAttrDesc[0], + (med_int *)&theInfo.myNbAttr, + &theInfo.myGroupNames[0], + (med_int *)&theInfo.myNbGroup); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetFamilyInfo - MEDfamInfo(...) - "<< + " aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<< + "'; theFamId = "<Id(), + &aMeshInfo.myName[0], + &theInfo.myElemNames[0], + nb, + anEntity, + aGeom); + + theInfo.myIsElemNames = (theInfo.myElemNames).empty()? EBooleen(0) : EBooleen(1) ; + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetNames - MEDnomLire(...)"); + } + + void TVWrapper::GetNumeration(TElemInfo& theInfo, + TInt nb, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + + med_entite_maillage& anEntity = (med_entite_maillage&)(theTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theTGeom); + + TErr aRet = MEDnumLire(myFile->Id(), + &aMeshInfo.myName[0], + (med_int*)&theInfo.myElemNum[0], + nb, + anEntity, + aGeom); + + theInfo.myIsElemNum = (theInfo.myElemNum).empty()? EBooleen(0) : EBooleen(1) ; + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetNumeration - MEDnumLire(...)"); + } + + void TVWrapper::GetFamilies(TElemInfo& theInfo, + TInt nb, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + + med_entite_maillage& anEntity = (med_entite_maillage&)(theTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theTGeom); + + TErr aRet = MEDfamLire(myFile->Id(), + &aMeshInfo.myName[0], + (med_int*)&theInfo.myFamNum[0], + nb, + anEntity, + aGeom); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetFamilies - MEDfamLire(...)"); + } + + void TVWrapper::SetNames(const TElemInfo& theInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + SetNames(theInfo,eLECTURE_ECRITURE,theTEntity,theTGeom,theErr); + } + + void TVWrapper::SetNames(const TElemInfo& theInfo, + EModeAcces theMode, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && !*theErr) + return; + + MED::TElemInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_entite_maillage& anEntity = (med_entite_maillage&)(theTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theTGeom); + + TErr aRet = 0; + if (anIsElemNames){ + aRet = MEDnomEcr(myFile->Id(), + &aMeshInfo.myName[0], + &anInfo.myElemNames[0], + anInfo.myElemNames.size(), + anEntity, + aGeom); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetNames - MEDnomEcr(...)"); + } + } + + void TVWrapper::SetNumeration(const TElemInfo& theInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + SetNumeration(theInfo,eLECTURE_ECRITURE,theTEntity,theTGeom,theErr); + } + + void TVWrapper::SetNumeration(const TElemInfo& theInfo, + EModeAcces theMode, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && !*theErr) + return; + + MED::TElemInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); + med_entite_maillage& anEntity = (med_entite_maillage&)(theTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theTGeom); + + TErr aRet = 0; + if (anIsElemNum){ + aRet = MEDnumEcr(myFile->Id(), + &aMeshInfo.myName[0], + (med_int*)&anInfo.myElemNum[0], + anInfo.myElemNum.size(), + anEntity, + aGeom); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetNumeration - MEDnumEcr(...)"); + } + } + + void TVWrapper::SetFamilies(const TElemInfo& theInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + SetFamilies(theInfo,eLECTURE_ECRITURE,theTEntity,theTGeom,theErr); + } + + void TVWrapper::SetFamilies(const TElemInfo& theInfo, + EModeAcces theMode, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && !*theErr) + return; + + MED::TElemInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + med_entite_maillage& anEntity = (med_entite_maillage&)(theTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theTGeom); + + TErr aRet = MEDfamEcr(myFile->Id(), + &aMeshInfo.myName[0], + (med_int *)&anInfo.myFamNum[0], + anInfo.myFamNum.size(), + anEntity, + aGeom); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetFamilies - MEDfamEcr(...)"); + } + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + TInt TVWrapper::GetNbNodes(const MED::TMeshInfo& theMeshInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return -1; + + MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); + + return MEDnEntMaa(myFile->Id(), + &aMeshInfo.myName[0], + MED_COOR, + MED_NOEUD, + med_geometrie_element(0), + med_connectivite(0)); + } + + + void TVWrapper::GetNodeInfo(MED::TNodeInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + + med_repere& aRepere = (med_repere&)(theInfo.mySystem); + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); + + TErr aRet = MEDnoeudsLire(myFile->Id(), + &aMeshInfo.myName[0], + aMeshInfo.myDim, + &theInfo.myCoord[0], + MED_FULL_INTERLACE, + &aRepere, + &theInfo.myCoordNames[0], + &theInfo.myCoordUnits[0], + &theInfo.myElemNames[0], + &anIsElemNames, + (med_int *)&theInfo.myElemNum[0], + &anIsElemNum, + (med_int *)&theInfo.myFamNum[0], + theInfo.myNbElem); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetNodeInfo - MEDnoeudsLire(...)"); + } + + + void TVWrapper::SetNodeInfo(const MED::TNodeInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && !*theErr) + return; + + MED::TNodeInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + med_repere& aRepere = (med_repere&)(theInfo.mySystem); + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); + + TErr aRet = MEDnoeudsEcr(myFile->Id(), + &aMeshInfo.myName[0], + aMeshInfo.myDim, + &anInfo.myCoord[0], + MED_FULL_INTERLACE, + aRepere, + &anInfo.myCoordNames[0], + &anInfo.myCoordUnits[0], + &anInfo.myElemNames[0], + anIsElemNames, + (med_int *)&anInfo.myElemNum[0], + anIsElemNum, + (med_int *)&anInfo.myFamNum[0], + anInfo.myNbElem); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetNodeInfo - MEDnoeudsEcr(...)"); + } + + + void TVWrapper::SetNodeInfo(const MED::TNodeInfo& theInfo, + TErr* theErr) + { + TErr aRet; + SetNodeInfo(theInfo,eLECTURE_ECRITURE,&aRet); + + if(aRet < 0) + SetNodeInfo(theInfo,eLECTURE_AJOUT,theErr); + } + + void TVWrapper::GetPolygoneInfo(MED::TPolygoneInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + TInt aNbElem = theInfo.myElemNum.size(); + + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myTEntity); + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); + + TErr aRet = 0; + + aRet = MEDpolygoneConnLire(myFile->Id(), + &aMeshInfo.myName[0], + (med_int *)&theInfo.myIndex[0], + aNbElem+1, + (med_int *)&theInfo.myConn[0], + anEntity, + aConn); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolygoneInfo(...)"); + + + GetNames(theInfo,aNbElem,theInfo.myTEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; + + GetNumeration(theInfo,aNbElem,theInfo.myTEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; + + GetFamilies(theInfo,aNbElem,theInfo.myTEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; + } + + void TVWrapper::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo, + TErr* theErr) + { + SetPolygoneInfo(theInfo,eLECTURE_ECRITURE,theErr); + } + + void TVWrapper::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && !*theErr) + return; + + MED::TPolygoneInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myTEntity); + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); + + TErr aRet = MEDpolygoneConnEcr(myFile->Id(), + &aMeshInfo.myName[0], + (med_int *)&anInfo.myIndex[0], + anInfo.myNbElem+1, + (med_int *)&anInfo.myConn[0], + anEntity, + aConn); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetPolygoneInfo - MEDpolygoneConnEcr(...)"); + + SetNames(anInfo,theInfo.myTEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; + + SetNumeration(anInfo,theInfo.myTEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; + + SetFamilies(anInfo,theInfo.myTEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; + } + + TInt TVWrapper::GetNbPolygones(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + TErr* theErr) + { + return GetNbCells(theMeshInfo,theTEntity,theTGeom,theTConn,theErr); + } + + TInt TVWrapper::GetNbPolygoneConn(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return 0; + + MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); + + med_entite_maillage& anEntity = (med_entite_maillage&)(theTEntity); + med_connectivite& aConn = (med_connectivite&)(theTConn); + + med_int taille = 0; + + TErr aRet = MEDpolygoneInfo(myFile->Id(), + &aMeshInfo.myName[0], + anEntity, + aConn, + &taille); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolygoneInfo(...)"); + + return TInt(taille); + } + + void TVWrapper::GetPolyedreInfo(TPolyedreInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + TInt aNbElem = theInfo.myElemNum.size(); + + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); + + TErr aRet = 0; + + aRet = MEDpolyedreConnLire(myFile->Id(), + &aMeshInfo.myName[0], + (med_int *)&theInfo.myIndex[0], + aNbElem+1, + (med_int *)&theInfo.myFacesIndex[0], + theInfo.myNbFacesIndex, + (med_int *)&theInfo.myConn[0], + aConn); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolyedreConnLire(...)"); + + GetNames(theInfo,aNbElem,theInfo.myTEntity,ePOLYEDRE,&aRet); + if(theErr) + *theErr = aRet; + + GetNumeration(theInfo,aNbElem,theInfo.myTEntity,ePOLYEDRE,&aRet); + if(theErr) + *theErr = aRet; + + GetFamilies(theInfo,aNbElem,theInfo.myTEntity,ePOLYEDRE,&aRet); + if(theErr) + *theErr = aRet; + } + + void TVWrapper::SetPolyedreInfo(const TPolyedreInfo& theInfo, + TErr* theErr) + { + SetPolyedreInfo(theInfo,eLECTURE_ECRITURE,theErr); + } + + void TVWrapper::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && !*theErr) + return; + + MED::TPolyedreInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myTEntity); + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); + + TErr aRet = MEDpolyedreConnEcr(myFile->Id(), + &aMeshInfo.myName[0], + (med_int *)&anInfo.myIndex[0], + anInfo.myNbElem+1, + (med_int *)&anInfo.myFacesIndex[0], + anInfo.myNbFacesIndex, + (med_int *)&anInfo.myConn[0], + aConn); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetPolyedreInfo - MEDpolyedreConnEcr(...)"); + + if (anIsElemNames){ + aRet = MEDnomEcr(myFile->Id(), + &aMeshInfo.myName[0], + &anInfo.myElemNames[0], + anInfo.myElemNames.size(), + anEntity, + MED_POLYEDRE); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetPolyedreInfo - MEDnomEcr(...)"); + } + + if (anIsElemNum){ + aRet = MEDnumEcr(myFile->Id(), + &aMeshInfo.myName[0], + (med_int *)&anInfo.myElemNum[0], + anInfo.myElemNum.size(), + anEntity, + MED_POLYEDRE); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetPolyedreInfo - MEDnumEcr(...)"); + } + + + aRet = MEDfamEcr(myFile->Id(), + &aMeshInfo.myName[0], + (med_int *)&anInfo.myFamNum[0], + anInfo.myFamNum.size(), + anEntity, + MED_POLYEDRE); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetPolyedreInfo - MEDfamEcr(...)"); + } + + TInt TVWrapper::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + TErr* theErr) + { + return GetNbCells(theMeshInfo,theTEntity,theTGeom,theTConn,theErr); + } + + void TVWrapper::GetNbPolyedreConnF(const MED::TMeshInfo& theMeshInfo, + EConnectivite theTConn, + TInt& nf, + TInt& nc, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) EXCEPTION(runtime_error,"GetPolyedreInfo - (...)"); + + MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); + med_connectivite& aConn = (med_connectivite&)(theTConn); + + TErr aRet = MEDpolyedreInfo(myFile->Id(), + &aMeshInfo.myName[0], + aConn, + (med_int *)&nf, + (med_int *)&nc); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolyedreInfo(...)"); + + } + + TEntityInfo TVWrapper::GetEntityInfo(const MED::TMeshInfo& theMeshInfo, + EConnectivite theTConn, + TErr* theErr) + { + TEntityInfo anInfo; + + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return anInfo; + + TInt aNbElem = GetNbNodes(theMeshInfo); + if(aNbElem > 0){ + anInfo[eNOEUD][ePOINT1] = aNbElem; + const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet(); + TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin(); + TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end(); + for(; anIter != anIterEnd; anIter++){ + const EEntiteMaillage& anEntity = anIter->first; + const TGeomSet& aGeomSet = anIter->second; + TGeomSet::const_iterator anIter2 = aGeomSet.begin(); + TGeomSet::const_iterator anIterEnd2 = aGeomSet.end(); + for(; anIter2 != anIterEnd2; anIter2++){ + const EGeometrieElement& aGeom = *anIter2; + aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theTConn,theErr); + if(aNbElem > 0) + anInfo[anEntity][aGeom] = aNbElem; + } + } + } + return anInfo; + } + + + TInt TVWrapper::GetNbCells(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return -1; + + MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); + + med_entite_maillage anEntity = med_entite_maillage(theTEntity); + med_geometrie_element aGeom = med_geometrie_element(theTGeom); + med_connectivite aConn = med_connectivite(theTConn); + + return MEDnEntMaa(myFile->Id(), + &aMeshInfo.myName[0], + MED_CONN, + anEntity, + aGeom, + aConn); + } + + + void TVWrapper::GetCellInfo(MED::TCellInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + TInt aNbElem = theInfo.myElemNum.size(); + + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theInfo.myTGeom); + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); + + TErr aRet = MEDelementsLire(myFile->Id(), + &aMeshInfo.myName[0], + aMeshInfo.myDim, + (med_int *)&theInfo.myConn[0], + MED_FULL_INTERLACE, + &theInfo.myElemNames[0], + &anIsElemNames, + (med_int *)&theInfo.myElemNum[0], + &anIsElemNum, + (med_int *)&theInfo.myFamNum[0], + aNbElem, + anEntity, + aGeom, + aConn); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetCellInfo - MEDelementsLire(...)"); + } + + + void TVWrapper::SetCellInfo(const MED::TCellInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && !*theErr) + return; + + MED::TCellInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theInfo.myTGeom); + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); + + TErr aRet = MEDelementsEcr(myFile->Id(), + &aMeshInfo.myName[0], + aMeshInfo.myDim, + (med_int *)&anInfo.myConn[0], + MED_FULL_INTERLACE, + &anInfo.myElemNames[0], + anIsElemNames, + (med_int *)&anInfo.myElemNum[0], + anIsElemNum, + (med_int *)&anInfo.myFamNum[0], + anInfo.myNbElem, + anEntity, + aGeom, + aConn); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetCellInfo - MEDelementsLire(...)"); + } + + + void TVWrapper::SetCellInfo(const MED::TCellInfo& theInfo, + TErr* theErr) + { + SetCellInfo(theInfo,eLECTURE_ECRITURE,theErr); + } + + + TInt TVWrapper::GetNbFields(TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return -1; + + return MEDnChamp(myFile->Id(),0); + } + + + TInt TVWrapper::GetNbComp(TInt theFieldId, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return -1; + + return MEDnChamp(myFile->Id(),theFieldId); + } + + + void TVWrapper::GetFieldInfo(TInt theFieldId, + MED::TFieldInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return; + + med_type_champ& aType = (med_type_champ&)(theInfo.myType); + + TErr aRet = MEDchampInfo(myFile->Id(), + theFieldId, + &theInfo.myName[0], + &aType, + &theInfo.myCompNames[0], + &theInfo.myUnitNames[0], + theInfo.myNbComp); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetFieldInfo - MEDchampInfo(...)"); + } + + + void TVWrapper::SetFieldInfo(const MED::TFieldInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && !*theErr) + return; + + MED::TFieldInfo& anInfo = const_cast(theInfo); + + med_type_champ& aType = (med_type_champ&)(theInfo.myType); + + TErr aRet = MEDchampCr(myFile->Id(), + &anInfo.myName[0], + aType, + &anInfo.myCompNames[0], + &anInfo.myUnitNames[0], + anInfo.myNbComp); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetFieldInfo - MEDchampEcr(...)"); + } + + + void TVWrapper::SetFieldInfo(const MED::TFieldInfo& theInfo, + TErr* theErr) + { + TErr aRet; + SetFieldInfo(theInfo,eLECTURE_ECRITURE,&aRet); + + if(aRet < 0) + SetFieldInfo(theInfo,eLECTURE_AJOUT,theErr); + } + + + TInt TVWrapper::GetNbTimeStamps(const MED::TFieldInfo& theInfo, + const MED::TEntityInfo& theEntityInfo, + EEntiteMaillage& theEntity, + TGeom& theGeom, + TErr* theErr) + { + theEntity = EEntiteMaillage(-1); + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr){ + if(theEntityInfo.empty()) + *theErr = -1; + if(*theErr < 0) + return -1; + }else if(theEntityInfo.empty()) + EXCEPTION(runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh"); + + theGeom.clear(); + TInt aNbTimeStamps = 0; + MED::TFieldInfo& anInfo = const_cast(theInfo); + TEntityInfo::const_iterator anIter = theEntityInfo.begin(); + for(; anIter != theEntityInfo.end(); anIter++){ + const med_entite_maillage& anEntity = (const med_entite_maillage&)(anIter->first); + const TGeom& aTGeom = anIter->second; + TGeom::const_iterator anGeomIter = aTGeom.begin(); + for(; anGeomIter != aTGeom.end(); anGeomIter++){ + const med_geometrie_element& aGeom = (const med_geometrie_element&)(anGeomIter->first); + TInt aTmp = MEDnPasdetemps(myFile->Id(),&anInfo.myName[0],anEntity,aGeom); + aNbTimeStamps = max(aTmp,aNbTimeStamps); + if (aNbTimeStamps<1) + continue; + BEGMSG(MYDEBUG,"GetNbTimeStamps aNbTimeStamps="<second; + } + } + if(!theGeom.empty()) + break; + } + return aNbTimeStamps; + } + + + void TVWrapper::GetTimeStampInfo(TInt theTimeStampId, + MED::TTimeStampInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + TGeom& aTGeom = theInfo.myGeom; + + if(theErr){ + if(aTGeom.empty()) + *theErr = -1; + if(*theErr < 0) + return; + }else if(aTGeom.empty()) + EXCEPTION(runtime_error,"GetTimeStampInfo - There is no any cell"); + + MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo; + MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo; + + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myEntity); + + TGeom::iterator anIter = aTGeom.begin(); + med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first); + + med_booleen& anIsLocal = (med_booleen&)(aFieldInfo.myIsLocal); + + TErr aRet = MEDpasdetempsInfo(myFile->Id(), + &aFieldInfo.myName[0], + anEntity, + aGeom, + theTimeStampId, + (med_int *)&theInfo.myNbGauss, + (med_int *)&theInfo.myNumDt, + (med_int *)&theInfo.myNumOrd, + &theInfo.myUnitDt[0], + &theInfo.myDt, + &aMeshInfo.myName[0], + &anIsLocal, + (med_int *)&aFieldInfo.myNbRef); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetTimeStampInfo - MEDpasdetempsInfo(...)"); + + static TInt MAX_NB_GAUSS_POINTS = 32; + if(theInfo.myNbGauss <= 0 || theInfo.myNbGauss > MAX_NB_GAUSS_POINTS) + theInfo.myNbGauss = 1; + } + + + void TVWrapper::GetTimeStampVal(MED::TTimeStampVal& theVal, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return; + + TIdt anId = myFile->Id(); + + MED::TTimeStampInfo& aTimeStampInfo = *theVal.myTimeStampInfo; + MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo; + MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo; + + med_entite_maillage& anEntity = (med_entite_maillage&)(aTimeStampInfo.myEntity); + med_mode_profil& aPflMode = (med_mode_profil&)(theVal.myPflMode); + TGeom& aTGeom = aTimeStampInfo.myGeom; + TGeom::iterator anIter = aTGeom.begin(); + for(; anIter != aTGeom.end(); anIter++){ + med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first); + TInt aNbVal = MEDnVal(anId, + &aFieldInfo.myName[0], + anEntity, + aGeom, + aTimeStampInfo.myNumDt, + aTimeStampInfo.myNumOrd, + &aMeshInfo.myName[0], + aPflMode); + if(aNbVal <= 0){ + if(theErr){ + *theErr = -1; + return; + } + EXCEPTION(runtime_error,"GetTimeStampInfo - MEDnVal(...) - aNbVal == "<Id(); + + MED::TTimeStampVal& aVal = const_cast(theVal); + MED::TTimeStampInfo& aTimeStampInfo = *aVal.myTimeStampInfo; + MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo; + MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo; + MED::TMeshValue& aMeshValue = aVal.myMeshValue; + + med_entite_maillage& anEntity = (med_entite_maillage&)(aTimeStampInfo.myEntity); + med_mode_profil& aPflMode = (med_mode_profil&)(theVal.myPflMode); + TMeshValue::iterator anIter = aMeshValue.begin(); + for(; anIter != aMeshValue.end(); anIter++){ + med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first); + TValue& aValue = aVal.myMeshValue[EGeometrieElement(aGeom)]; + med_int iEnd = aValue.size(); + med_int aNbVal = iEnd / aFieldInfo.myNbComp; + + switch(aFieldInfo.myType){ + case eFLOAT64: { + std::vector& anArray = aValue; + + aRet = MEDchampEcr(anId, + &aMeshInfo.myName[0], + &aFieldInfo.myName[0], + (unsigned char*)&anArray[0], + MED_FULL_INTERLACE, + aNbVal, + &aTimeStampInfo.myGaussName[0], + MED_ALL, + &aVal.myPflName[0], + aPflMode, + anEntity, + aGeom, + aTimeStampInfo.myNumDt, + &aTimeStampInfo.myUnitDt[0], + aTimeStampInfo.myDt, + aTimeStampInfo.myNumOrd); + break; + } + default: { + vector anArray(iEnd); + for(TInt i = 0; i< iEnd; i++) anArray[i] = TInt(aValue[i]); + + aRet = MEDchampEcr(anId, + &aMeshInfo.myName[0], + &aFieldInfo.myName[0], + (unsigned char*)&anArray[0], + MED_FULL_INTERLACE, + aNbVal, + &aTimeStampInfo.myGaussName[0], + MED_ALL, + &aVal.myPflName[0], + aPflMode, + anEntity, + aGeom, + aTimeStampInfo.myNumDt, + &aTimeStampInfo.myUnitDt[0], + aTimeStampInfo.myDt, + aTimeStampInfo.myNumOrd); + break; + }} + + if(aRet < 0){ + if(theErr){ + *theErr = MED_FAUX; + break; + } + EXCEPTION(runtime_error,"SetTimeStamp - MEDchampEcr(...)"); + } + + } + + INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "< TVMeshInfo; + + typedef MED::TTFamilyInfo TVFamilyInfo; + + typedef MED::TTNodeInfo TVNodeInfo; + + typedef MED::TTCellInfo TVCellInfo; + + typedef MED::TTFieldInfo TVFieldInfo; + + typedef MED::TTTimeStampInfo TVTimeStampInfo; + + typedef MED::TTTimeStampVal TVTimeStampVal; + + //--------------------------------------------------------------- + class TFile; + typedef boost::shared_ptr PFile; + + typedef enum {eLECTURE, eLECTURE_ECRITURE, eLECTURE_AJOUT, eCREATION} EModeAcces; + + //--------------------------------------------------------------- + class TVWrapper: public MED::TTWrapper{ + TVWrapper(); + TVWrapper(const TVWrapper&); + TVWrapper& operator=(const TVWrapper&); + + public: + TVWrapper(const std::string& theFileName); + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + TInt + GetNbMeshes(TErr* theErr = NULL); + + virtual + void + GetMeshInfo(TInt theMeshId, MED::TMeshInfo&, + TErr* theErr = NULL); + + virtual + void + SetMeshInfo(const MED::TMeshInfo& theInfo, + TErr* theErr = NULL); + + void SetMeshInfo(const MED::TMeshInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + TInt + GetNbFamilies(const MED::TMeshInfo& theMeshInfo, + TErr* theErr = NULL); + + virtual + TInt + GetNbFamAttr(TInt theFamId, + const MED::TMeshInfo& theInfo, + TErr* theErr = NULL); + + virtual + TInt + GetNbFamGroup(TInt theFamId, + const MED::TMeshInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + GetFamilyInfo(TInt theFamId, + MED::TFamilyInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetFamilyInfo(const MED::TFamilyInfo& theInfo, + TErr* theErr = NULL); + + void + SetFamilyInfo(const MED::TFamilyInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + void + GetNames(TElemInfo& theInfo, + TInt nb, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr = NULL); + + virtual + void + GetNumeration(TElemInfo& theInfo, + TInt nb, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr = NULL); + + virtual + void + GetFamilies(TElemInfo& theInfo, + TInt nb, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr = NULL); + + virtual + void + SetNames(const TElemInfo& theInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr = NULL); + + void + SetNames(const TElemInfo& theInfo, + EModeAcces theMode, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr = NULL); + + virtual + void + SetNumeration(const TElemInfo& theInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr = NULL); + void + SetNumeration(const TElemInfo& theInfo, + EModeAcces theMode, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr = NULL); + + virtual + void + SetFamilies(const TElemInfo& theInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr = NULL); + void + SetFamilies(const TElemInfo& theInfo, + EModeAcces theMode, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + TErr* theErr = NULL); + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + TInt + GetNbNodes(const MED::TMeshInfo& theMeshInfo, + TErr* theErr = NULL); + + virtual + void + GetNodeInfo(MED::TNodeInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetNodeInfo(const MED::TNodeInfo& theInfo, + TErr* theErr = NULL); + + void + SetNodeInfo(const MED::TNodeInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + void + GetPolygoneInfo(TPolygoneInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetPolygoneInfo(const TPolygoneInfo& theInfo, + TErr* theErr = NULL); + + void + SetPolygoneInfo(const MED::TPolygoneInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + virtual + TInt + GetNbPolygones(const TMeshInfo& theMeshInfo, + EEntiteMaillage, + EGeometrieElement, + EConnectivite, + TErr* theErr = NULL); + + virtual + TInt + GetNbPolygoneConn(const TMeshInfo& theMeshInfo, + EEntiteMaillage, + EGeometrieElement, + EConnectivite, + TErr* theErr = NULL); + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + void + GetPolyedreInfo(TPolyedreInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetPolyedreInfo(const TPolyedreInfo& theInfo, + TErr* theErr = NULL); + + void + SetPolyedreInfo(const MED::TPolyedreInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + virtual + TInt + GetNbPolyedres(const TMeshInfo& theMeshInfo, + EEntiteMaillage, + EGeometrieElement, + EConnectivite, + TErr* theErr = NULL); + + virtual + void + GetNbPolyedreConnF(const TMeshInfo& theMeshInfo, + EConnectivite, + TInt& nf, + TInt& nc, + TErr* theErr = NULL); + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + TEntityInfo + GetEntityInfo(const MED::TMeshInfo& theMeshInfo, + EConnectivite theTConn = eNOD, + TErr* theErr = NULL); + + virtual + TInt + GetNbCells(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage, + EGeometrieElement, + EConnectivite theTConn = eNOD, + TErr* theErr = NULL); + + virtual + void + GetCellInfo(MED::TCellInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetCellInfo(const MED::TCellInfo& theInfo, + TErr* theErr = NULL); + + void + SetCellInfo(const MED::TCellInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + TInt + GetNbFields(TErr* theErr = NULL); + + virtual + TInt + GetNbComp(TInt theFieldId, + TErr* theErr = NULL); + + virtual + void + GetFieldInfo(TInt theFieldId, + MED::TFieldInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetFieldInfo(const MED::TFieldInfo& theInfo, + TErr* theErr = NULL); + + void + SetFieldInfo(const MED::TFieldInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + TInt + GetNbTimeStamps(const MED::TFieldInfo& theInfo, + const MED::TEntityInfo& theEntityInfo, + EEntiteMaillage& theEntity, + TGeom& theGeom, + TErr* theErr = NULL); + + virtual + void + GetTimeStampInfo(TInt theTimeStampId, + MED::TTimeStampInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + GetTimeStampVal(MED::TTimeStampVal& theVal, + TErr* theErr = NULL); + + virtual + void + SetTimeStamp(const MED::TTimeStampVal& theTimeStampVal, + TErr* theErr = NULL); + + void + SetTimeStamp(const MED::TTimeStampVal& theTimeStampVal, + EModeAcces theMode, + TErr* theErr = NULL); + + protected: + PFile myFile; + }; + } +} + +#endif diff --git a/src/MEDWrapper/V2_2/Makefile.in b/src/MEDWrapper/V2_2/Makefile.in new file mode 100644 index 000000000..a1cf82e92 --- /dev/null +++ b/src/MEDWrapper/V2_2/Makefile.in @@ -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 : +# Author : +# Module : +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# Libraries targets + +LIB = libMEDWrapper_V2_2.la +LIB_SRC = \ + MED_V2_2_Wrapper.cxx + +EXPORT_HEADERS = \ + MED_V2_2_Wrapper.hxx + +# Executables targets +BIN = +BIN_SRC = + +CPPFLAGS+= $(BOOST_CPPFLAGS) $(MED2_INCLUDES) + +LDFLAGS+= $(MED2_LIBS) $(HDF5_LIBS) -lMEDWrapperBase + +@CONCLUDE@ diff --git a/src/Makefile.in b/src/Makefile.in index 29077823c..6a6fb4dd6 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,21 +1,21 @@ # 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 +# 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 # # # @@ -32,15 +32,15 @@ VPATH=.:@srcdir@ @COMMENCE@ ifeq (@WITHIHM@,yes) -SUBDIRS = INTERPOLATION MEDMEM MEDMEM_SWIG MEDMEM_I MED MEDGUI MedCorba_Swig MED_SWIG MedClient +SUBDIRS = MEDWrapper INTERPOLATION MEDMEM MEDMEM_SWIG MEDMEM_I MED MEDGUI MedCorba_Swig MED_SWIG MedClient endif ifeq (@WITHIHM@,no) -SUBDIRS = INTERPOLATION MEDMEM MEDMEM_SWIG MEDMEM_I MED MedCorba_Swig MED_SWIG MedClient +SUBDIRS = MEDWrapper INTERPOLATION MEDMEM MEDMEM_SWIG MEDMEM_I MED MedCorba_Swig MED_SWIG MedClient endif -LDFLAGS= -L$(top_builddir)/lib/salome +LDFLAGS= -L$(top_builddir)/lib/salome LDFLAGSFORBIN= -L$(top_builddir)/lib/salome @MODULE@ diff --git a/src/MedClient/src/COORDINATEClient.cxx b/src/MedClient/src/COORDINATEClient.cxx index 90e6f8ddb..02f3afe34 100644 --- a/src/MedClient/src/COORDINATEClient.cxx +++ b/src/MedClient/src/COORDINATEClient.cxx @@ -14,10 +14,10 @@ using namespace MED_EN; */ //============================================================================= -COORDINATEClient::COORDINATEClient(const SALOME_MED::MESH_ptr m, +COORDINATEClient::COORDINATEClient(const SALOME_MED::MESH_ptr m, medModeSwitch Mode) : COORDINATE(m->getSpaceDimension(), 1, Mode), - _complete(false), + _complete(false), IOR_Mesh(SALOME_MED::MESH::_duplicate(m)) { BEGIN_OF("COORDINATEClient::COORDINATEClient(...)"); @@ -53,23 +53,23 @@ void COORDINATEClient::blankCopy() ASSERT(nA == getSpaceDimension()); setCoordinatesNames(tA); delete [] tA; - + //convertCorbaArray(tA, nA, IOR_Mesh->getCoordinatesUnits()); convertCorbaArray(tA, nA, &all->coordUnits); ASSERT(nA == getSpaceDimension()); setCoordinatesUnits(tA); delete [] tA; - + setCoordinatesSystem( CORBA::string_dup(all->coordSystem)); - + _complete = false; END_OF("void COORDINATEClient::blankCopy()"); } //============================================================================= /*! - * Remplit les coordonnées + * Remplit les coordonnées */ //============================================================================= @@ -87,18 +87,18 @@ void COORDINATEClient::fillCopy() tC=ReceiverFactory::getValue(senderForCoords,nC); ASSERT(nC == (getSpaceDimension() * nN)); - + MEDARRAY mC(tC, getSpaceDimension(), nN,MED_FULL_INTERLACE,true); setCoordinates(&mC,true); - + _complete = true; - + END_OF("void COORDINATEClient::fillCopy()"); } //============================================================================= /*! - * Retourne les coordonnées + * Retourne les coordonnées */ //============================================================================= @@ -115,7 +115,7 @@ const double * COORDINATEClient::getCoordinates(medModeSwitch Mode) } //============================================================================= /*! - * Retourne une coordonnée + * Retourne une coordonnée */ //============================================================================= @@ -132,7 +132,7 @@ double COORDINATEClient::getCoordinate(int Number,int Axis) } //============================================================================= /*! - * Retourne un axe + * Retourne un axe */ //============================================================================= const double * COORDINATEClient::getCoordinateAxis(int Axis) diff --git a/src/MedCorba_Swig/libMedCorba_Swig.i b/src/MedCorba_Swig/libMedCorba_Swig.i index b005a2304..f8dc2033d 100644 --- a/src/MedCorba_Swig/libMedCorba_Swig.i +++ b/src/MedCorba_Swig/libMedCorba_Swig.i @@ -501,7 +501,7 @@ FIELDINT * createLocalFieldInt(const int, const int); SALOME_MED::MESH_ptr createCorbaMesh(MESH * mesh); %{ - SALOME_MED::FIELDDOUBLE_ptr createCorbaFieldDouble(SALOME_MED::SUPPORT_ptr mySupportIOR,FIELDDOUBLE * field, bool ownCppPtr) + SALOME_MED::FIELDDOUBLE_ptr createCorbaFieldDouble(SALOME_MED::SUPPORT_ptr mySupportIOR,FIELDDOUBLE * field, bool ownCppPtr=false) { BEGIN_OF("SALOME_MED::FIELDDOUBLE_ptr createCorbaFieldDouble from libMedCorba_Swig"); @@ -533,7 +533,7 @@ SALOME_MED::MESH_ptr createCorbaMesh(MESH * mesh); return fieldcorba2; } - SALOME_MED::FIELDINT_ptr createCorbaFieldInt(SALOME_MED::SUPPORT_ptr mySupportIOR,FIELDINT * field, bool ownCppPtr) + SALOME_MED::FIELDINT_ptr createCorbaFieldInt(SALOME_MED::SUPPORT_ptr mySupportIOR,FIELDINT * field, bool ownCppPtr=false) { BEGIN_OF("SALOME_MED::FIELDINT_ptr createCorbaFieldInt from libMedCorba_Swig");