--- /dev/null
+// File: MED.idl
+// Project: SALOME
+// Copyright : CEA/DEN/DMSS/LGLS
+// $Header$
+
+#ifndef MED_IDL
+#define MED_IDL
+
+#include "SALOME_Exception.idl"
+#include "SALOME_Component.idl"
+#include "SALOMEDS.idl"
+
+module Engines {
+ /*!
+ An array of long
+ */
+ typedef sequence<long> long_array;
+ /*!
+ An array of double
+ */
+ typedef sequence<double> double_array;
+ /*!
+ An array of string
+ */
+ typedef sequence<string> string_array;
+ /*!
+ An array of boolean
+ */
+ typedef sequence<boolean> boolean_array;
+
+};
+
+module SALOME_MED {
+
+ // interface FIELD;
+ interface FIELD;
+ interface FAMILY;
+ interface GROUP;
+ interface MESH;
+ interface SUPPORT;
+
+ enum medGeometryElement {
+ MED_NONE,
+ MED_POINT1,
+ MED_SEG2,
+ MED_SEG3,
+ MED_TRIA3,
+ MED_QUAD4,
+ MED_TRIA6,
+ MED_QUAD8,
+ MED_TETRA4,
+ MED_PYRA5,
+ MED_PENTA6,
+ MED_HEXA8,
+ MED_TETRA10,
+ MED_PYRA13,
+ MED_PENTA15,
+ MED_HEXA20,
+ MED_ALL_ELEMENTS
+ };
+
+ enum medEntityMesh {
+ MED_CELL,
+ MED_FACE,
+ MED_EDGE,
+ MED_NODE,
+ MED_ALL_ENTITIES
+ };
+
+ enum medModeSwitch {
+ MED_FULL_INTERLACE,
+ MED_NO_INTERLACE
+ };
+
+ enum medConnectivity {
+ MED_NODAL,
+ MED_DESCENDING
+ };
+
+ enum medDriverTypes {
+ MED_DRIVER ,
+ VTK_DRIVER ,
+ NO_DRIVER
+ };
+
+ /*!
+ An array of medGeometryElement
+ */
+ typedef sequence<medGeometryElement> medGeometryElement_array;
+ /*!
+ An array of FAMILY
+ */
+ typedef sequence<FAMILY> Family_array;
+ /*!
+ An array of GROUP
+ */
+ typedef sequence<GROUP> Group_array;
+
+ // ----------------------
+ // mesh interface
+ // ----------------------
+
+ interface MESH {
+ // Index range begins at 1
+
+ // General Informations
+ //---------------------
+
+ /*!
+ Returns mesh name.
+ */
+ string getName() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns space dimension.
+ */
+ long getSpaceDimension() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns mesh dimension.
+
+ Example :
+ - we have only MED_TETRA4 in MED_CELL : MeshDimension = 3
+ - we have only MED_QUAD4 in MED_CELL : MeshDimension = 2
+ - we have both MED_SEG2 and MED_TRIA3 in MED_CELL : MeshDimension = 2
+ */
+ long getMeshDimension() raises (SALOME::SALOME_Exception);
+
+ // Coordinates
+ //------------
+
+ /*!
+ Returns coordinate's system :
+ - "CARTESIAN"
+ - "CYLINDRICAL"
+ - "SPHERICAL"
+ */
+ string getCoordinateSystem() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns the number of nodes defined in mesh.
+ */
+ long getNumberOfNodes() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns coordinates array :
+ - X1,Y1,Z1,X2,Y2,...,Zn if MED_FULL_INTERLACE
+ - X1,X2,...Xn,Y1,Y2,...Zn if MED_NO_INTERLACE
+ */
+ Engines::double_array getCoordinates(in medModeSwitch typeSwitch)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns an array with names of coordinates.
+
+ Example :
+ - x,y,z
+ - r,teta,phi
+ - ...
+
+ It could be empty.
+ */
+ Engines::string_array getCoordinatesNames()
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns an array with units of coordinates (cm, m, mm, ...)
+
+ It could be empty. We suppose we are IS (meter).
+ */
+ Engines::string_array getCoordinatesUnits()
+ raises (SALOME::SALOME_Exception);
+
+ // Connectivity
+ // ------------
+
+ /*!
+ Returns the number of different <medGeometryElement> types existing
+ in the specified entity.
+
+ Note : Not implemented for MED_ALL_ENTITIES.
+ */
+ long getNumberOfTypes(in medEntityMesh entity)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns an array of all <med geometry elements> types existing
+ in the mesh.
+
+ Note : Not implemented for MED_ALL_ENTITIES.
+ */
+ medGeometryElement_array getTypes(in medEntityMesh entity)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns the number of elements of type <med geometrie element>.
+
+ Note :
+ - Implemented for MED_ALL_ELEMENTS
+ - Not implemented for MED_ALL_ENTITIES
+ */
+ long getNumberOfElements(in medEntityMesh entity,
+ in medGeometryElement geomElement)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Give, in full or no interlace mode (for nodal connectivity),
+ descending or nodal connectivity.
+
+ You must give a <medEntityMesh> (ie:MED_EDGE) and a
+ <medGeometryElement> (ie:MED_SEG3).
+ */
+ Engines::long_array getConnectivity(in medModeSwitch typeSwitch,
+ in medConnectivity mode,
+ in medEntityMesh entity,
+ in medGeometryElement geomElement)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ 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
+ connectivity array.
+
+ Example : i-th element, j-th node of it :
+ - In C mode : Connectivity[ConnectivityIndex[i]-1+j-1]
+ - In fortran mode : Connectivity[ConnectivityIndex[i]+j]
+ */
+ Engines::long_array getConnectivityIndex(in medConnectivity mode,
+ in medEntityMesh entity)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Get global number of element which have same connectivity than
+ connectivity argument.
+ */
+ long getElementNumber(in medConnectivity mode,
+ in medEntityMesh entity,
+ in medGeometryElement type,
+ in Engines::long_array connectivity)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Return a reverse connectivity to MED_CELL.
+
+ 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),
+ the 2 cells of each side. First is cell which face normal is outgoing.
+ */
+ Engines::long_array getReverseConnectivity(in medConnectivity mode)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Give index array to use with getReverseConnectivity(MED_NODAL).
+
+ It is unusefull with MED_DESCENDING mode,
+ because we have allways two cells.
+
+ See getConnectivityIndex for details.
+ */
+ Engines::long_array getReverseConnectivityIndex(in medConnectivity mode)
+ raises (SALOME::SALOME_Exception);
+
+ // Families and Groups
+ // -------------------
+
+ /*!
+ Returns the number of all families.
+ */
+ long getNumberOfFamilies(in medEntityMesh entity)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns the number of all groups.
+ */
+ long getNumberOfGroups(in medEntityMesh entity)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns an array of all families.
+ */
+ Family_array getFamilies(in medEntityMesh entity)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns a reference to i-th to family.
+
+ Note : i is bounded by 1 and NumberOfFamilies.
+ */
+ FAMILY getFamily(in medEntityMesh entity,in long familyNumber)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns an array of all groups.
+ */
+ Group_array getGroups(in medEntityMesh entity)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns a reference to i-th group.
+
+ Note : i is bounded by 1 and NumberOfGroups.
+ */
+ GROUP getGroup(in medEntityMesh entity,in long groupNumber)
+ raises (SALOME::SALOME_Exception);
+
+ // Others
+ // ------
+
+ /*!
+ Returns a field on mySupport containing volume.
+
+ Note : mySupport must be on MED_CELL entity and MeshDimension must be 3.
+ */
+ FIELD getVolume(in SUPPORT mySupport)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns a field on mySupport containing area.
+
+ Note : mySupport must be on MED_FACE entity.
+ */
+ FIELD getArea(in SUPPORT mySupport)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns a field on mySupport containing length.
+
+ Note : mySupport must be on MED_EDGE entity.
+ */
+ FIELD getLength(in SUPPORT mySupport)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns a field on mySupport containing normal.
+
+ Note : mySupport must be on MED_FACE entity if MeshDimension and
+ SpaceDimension=3 and on MED_EDGE if MeshDimension and SpaceDimension=2.
+ */
+ FIELD getNormal(in SUPPORT mySupport)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns a field on mySupport containing barycenter.
+ */
+ FIELD getBarycenter(in SUPPORT mySupport)
+ raises (SALOME::SALOME_Exception);
+
+ /*
+ Returns a field on mySupport containing neighbourhood.
+ */
+ // FIELD getNeighbourhood(in SUPPORT mySupport)
+ // raises (SALOME::SALOME_Exception);
+
+ // Read & Write
+ // -----------
+
+ /*!
+ Add the Mesh in the StudyManager.
+ */
+ void addInStudy(in SALOMEDS::Study myStudy, in MESH myIor )
+ raises (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection);
+
+ // Add a MED/VTK/... driver
+ // Multiple drivers can be added whatever the type
+ 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)
+ raises (SALOME::SALOME_Exception);
+
+ // Cuisine Interne/Internal Kitchen
+ long getCorbaIndex() raises (SALOME::SALOME_Exception);
+ };
+
+
+ // ----------------------
+ // Support interface
+ // ----------------------
+
+ interface SUPPORT {
+
+ /*!
+ Returns the name of the support.
+ */
+ string getName() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns the description of the support.
+ */
+ string getDescription() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns a reference to the mesh.
+ */
+ MESH getMesh() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns the medEntityMesh's type used by the support.
+
+ Note : A support deals only with one entity's type
+ (for example : MED_FACE or MED_NODE)
+ */
+ medEntityMesh getEntity() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns true if all elements of this entity are
+ concerned, false otherwise.
+
+ If true, you must use mesh reference (getMesh) to get more information.
+ */
+ boolean isOnAllElements() raises (SALOME::SALOME_Exception);
+
+ /*!
+ If isOnAllElements is false, returns number of elements in the
+ support.
+
+ Example : number of MED_TRIA3 or MED_ALL_ELEMETNS elements
+ in entity of support.
+
+ Note : If SUPPORT is defined on MED_NODE, use MED_NONE
+ medGeometryElement type.
+ */
+ long getNumberOfElements(in medGeometryElement geomElement)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ If isOnAllElements is false, returns an array of <medGeometryElement>
+ types used by the support.
+
+ <medEntityMesh> is given by getEntity.
+ */
+ medGeometryElement_array getTypes() raises (SALOME::SALOME_Exception);
+
+ /*!
+ If isOnAllElements is false, returns an array which contains
+ all number of given medGeometryElement.
+
+ Numbering is global, ie numbers are bounded by 1 and
+ MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and
+ MESH::getNumberOfElement(entity,geomElement).
+
+ Note : If SUPPORT is defined on MED_NODE, use MED_NONE
+ medGeometryElement type.
+ */
+ Engines::long_array getNumber(in medGeometryElement geomElement)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ If isOnAllElements is false, returns index of element number.
+
+ Use it with getNumber(MED_ALL_ELEMENTS).
+
+ Note : See getConnectivityIndex for details.
+ */
+ Engines::long_array getNumberIndex()
+ raises (SALOME::SALOME_Exception);
+ /*!
+ Returns number of Gauss points for this medGeometryElement.
+
+ Note :
+ - Not defined if SUPPORT is on MED_NODE.
+ - Not defined for MED_ALL_ELEMENTS medGeometryElement type.
+ */
+ long getNumberOfGaussPoints(in medGeometryElement geomElement)
+ raises (SALOME::SALOME_Exception);
+
+ // Cuisine Interne
+ long getCorbaIndex() raises (SALOME::SALOME_Exception);
+ };
+
+
+ //-----------------
+ // Family interface
+ //-----------------
+
+ interface FAMILY : SUPPORT
+ {
+
+ /*!
+ Returns Family identifier (Identifier
+ of the family in the mesh).
+
+ Note : There is precisely one for each family.
+ */
+ long getIdentifier() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns number of attributes.
+ */
+ long getNumberOfAttributes() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns an array of all attributes' identifiers.
+ There is one for each attribute.
+ */
+ Engines::long_array getAttributesIdentifiers()
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns identifier of i-th attribute.
+
+ Note : i is bounded by 1 and NumberOfAttributes.
+ */
+ long getAttributeIdentifier(in long i) raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns an array of all attributes values.
+ There is one for each attribute.
+ */
+ Engines::long_array getAttributesValues()
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns value of i-th attribute.
+
+ Note : i is bounded by 1 and NumberOfAttributes.
+ */
+ long getAttributeValue(in long i) raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns an array of all attributes descriptions.
+ There is one for each attribute.
+ */
+ Engines::string_array getAttributesDescriptions()
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns description of i-th attribute.
+
+ Note : i is bounded by 1 and NumberOfAttributes.
+ */
+ string getAttributeDescription(in long i)
+ raises (SALOME::SALOME_Exception);
+ };
+
+
+ //----------------
+ // Group interface
+ //----------------
+ interface GROUP : SUPPORT
+ {
+
+ /*!
+ Returns number of families in this group.
+ */
+ long getNumberOfFamilies() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns array of all families.
+ */
+ Family_array getFamilies() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns a reference for the i-th family.
+
+ Note : i is bounded by 1 and NumberOfFamilies.
+ */
+ FAMILY getFamily(in long i) raises (SALOME::SALOME_Exception);
+
+ };
+
+
+ //----------------
+ // Field interface
+ //----------------
+
+ interface FIELD
+ {
+
+ /*!
+ Returns the field name.
+ */
+ string getName() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns the field description.
+ */
+ string getDescription() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns a reference to the support
+ on which the field is defined.
+ */
+ SUPPORT getSupport() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns the number of field's components.
+ */
+ long getNumberOfComponents() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns an array containing components names.
+ */
+ Engines::string_array getComponentsNames()
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns the name of i-th component.
+
+ Note :
+ - i is bounded by 1 and NumberOfComponents.
+ - Name is mandatory foreach field's component.
+ */
+ string getComponentName(in long i) raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns an array containing components units.
+ */
+ Engines::string_array getComponentsUnits()
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns the unit of i-th component.
+
+ Note : i is bounded by 1 and NumberOfComponents.
+ */
+ string getComponentUnit(in long i) raises (SALOME::SALOME_Exception);
+
+
+ long getIterationNumber() raises (SALOME::SALOME_Exception);
+
+ /*!
+ Returns time for this iteration.
+ */
+ double getTime() raises (SALOME::SALOME_Exception);
+
+ /*!
+ 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)
+ 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);
+
+ /*!
+ Write field.
+ */
+ void write (in long i, in string driverFieldName)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ Add the Field in the StudyManager.
+ */
+ void addInStudy(in SALOMEDS::Study myStudy, in FIELD myIor )
+ raises (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection);
+
+ // Cuisine Interne
+ long getCorbaIndex()
+ raises (SALOME::SALOME_Exception);
+
+ };
+
+
+ interface FIELDDOUBLE : FIELD {
+
+ /*!
+ Returns the field values array
+ */
+ Engines::double_array getValue(in medModeSwitch mode)
+ raises (SALOME::SALOME_Exception);
+ };
+
+ interface FIELDINT : FIELD {
+
+ /*!
+ Returns the field values array
+ */
+ Engines::long_array getValue(in medModeSwitch mode)
+ raises (SALOME::SALOME_Exception);
+
+ };
+
+ // MED interface
+
+ interface MED {
+
+
+ long getNumberOfMeshes () raises (SALOME::SALOME_Exception);
+ long getNumberOfFields () raises (SALOME::SALOME_Exception);
+ Engines::string_array getMeshNames () raises (SALOME::SALOME_Exception);
+ Engines::string_array getFieldNames () raises (SALOME::SALOME_Exception);
+ MESH getMeshByName ( in string meshName) raises (SALOME::SALOME_Exception);
+ MESH getMesh ( in FIELD fieldPtr) raises (SALOME::SALOME_Exception);
+ 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
+ // be able to read/write files preserving meshes<-->fields association
+ // Multiple drivers can be added whatever the type.
+ // The access point in the <long> returned
+ long addDriver (in medDriverTypes driverType, in string fileName)
+ raises (SALOME::SALOME_Exception);
+ // Remove the driver
+ void rmDriver (in long i) raises (SALOME::SALOME_Exception);
+
+ void readFileStruct(in long i) raises (SALOME::SALOME_Exception);
+ void writeFrom (in long i) raises (SALOME::SALOME_Exception);
+ void write (in long i) raises (SALOME::SALOME_Exception);
+
+ 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);
+ };
+};
+
+#endif /* MED_IDL */
--- /dev/null
+<?xml version='1.0' encoding='us-ascii'?>
+<!DOCTYPE application PUBLIC "" "desktop.dtd">
+
+<!-- GUI customization for MED component -->
+
+<application
+ title="MED component"
+ author="Paul RASCLE"
+ appId=" MED integrated in SALOME" >
+
+ <desktop>
+
+ <!-- ### MENUBAR ### -->
+
+ <menubar>
+ <menu-item label-id="MED" item-id="90" pos-id="3">
+ <popup-item item-id="931" pos-id="1" label-id="Mesh selection" icon-id="" tooltip-id="read a Mesh" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="932" pos-id="2" label-id="Field Selection" icon-id="" tooltip-id="read a Field" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="933" pos-id="3" label-id="Explore Med File" icon-id="" tooltip-id="explore Med File" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="934" pos-id="4" label-id="Dump Mesh" icon-id="" tooltip-id="dump Mesh" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="935" pos-id="5" label-id="Dump SubMesh" icon-id="" tooltip-id="dump Mesh" accel-id="" toggle-id="" execute-action=""/>
+ </menu-item>
+
+ </menubar>
+
+ <!-- ### TOOLBAR ### -->
+
+ <toolbar label-id="Mesh Generation">
+ <toolbutton-item item-id="4031" label-id="Mesh Selection" icon-id="Data.png" tooltip-id="read a Mesh" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="4032" label-id="Field Selection" icon-id="Infos.png" tooltip-id="read a Field" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="4033" label-id="Explore Med File" icon-id="Structure.png" tooltip-id="explore Med File " accel-id="" toggle-id="" execute-action=""/>
+ </toolbar>
+
+ <!-- ### POPUP MENU ### -->
+
+ <popupmenu label-id="Popup for Viewer" context-id="" parent-id="Viewer" object-id="">
+ <popup-item item-id="8031" pos-id="" label-id="Test Popup" icon-id="" tooltip-id="Just a test for Popup" accel-id="" toggle-id="" execute-action=""/>
+ </popupmenu>
+
+ <popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="">
+ <popup-item item-id="9002" pos-id="" label-id="Erase" icon-id="" tooltip-id="" accel-id="Remove CL from viewer" toggle-id="" execute-action=""/>
+ <popup-item item-id="903" pos-id="" label-id="Display" icon-id="" tooltip-id="Display CL on viewer" accel-id="" toggle-id="" execute-action=""/>
+ </popupmenu>
+
+ </desktop>
+</application>
--- /dev/null
+language=en
--- /dev/null
+#==============================================================================
+# File : MED_test1.py
+# Created :
+# Author :
+# Project : SALOME
+# Copyright : EDF 2002
+# $Header$
+#==============================================================================
+
+import salome
+
+med=salome.lcc.FindOrLoadComponent("FactoryServer", "Med")
+
+import os
+filePath=os.getenv("SALOME_BUILD")
+filePath=filePath+"/../SALOME_ROOT/data/"
+fileName="pointe.med"
+fileTout=filePath+fileName
+
+print fileTout
+
+med.readStructFile(fileTout,salome.myStudyName)
+
--- /dev/null
+#==============================================================================
+# File : MED_test2.py
+# Created :
+# Author :
+# Project : SALOME
+# Copyright : EDF 2002
+# $Header$
+#==============================================================================
+
+import salome
+import SALOME
+import os
+
+filePath=os.getenv("SALOME_BUILD")
+filePath=filePath+"/../SALOME_ROOT/data/"
+
+med=salome.lcc.FindOrLoadComponent("FactoryServer", "Med")
+
+try:
+ mesh=med.readMeshInFile(filePath+"/mesh.med", salome.myStudyName,"Mesh 1")
+except SALOME.SALOME_Exception, ex:
+ print ex.details
+ print ex.details.type
+ print ex.details.text
+ print ex.details.sourceFile
+ print ex.details.lineNumber
+
+ raise
+
+print mesh.getName()
+print mesh.getNumberOfNodes()
+
+try:
+ field=med.readFieldInFile(filePath+"/pointe.med",salome.myStudyName,"fieldcelldouble",-1,-1)
+except SALOME.SALOME_Exception, ex:
+ print ex.details
+ print ex.details.type
+ print ex.details.text
+ print ex.details.sourceFile
+ print ex.details.lineNumber
+
+ raise
+
+print field.getName()
+print field.getDescription()
+print field.getNumberOfComponents()
+
--- /dev/null
+#==============================================================================
+# File : Makefile.in
+# Created : ven déc 7 13:33:08 CET 2001
+# Author : Paul RASCLE, EDF
+# Project : SALOME
+# Copyright : EDF 2001
+# $Header$
+#==============================================================================
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=../../..
+srcdir=@srcdir@
+VPATH=.:$(srcdir):$(top_builddir)/share/salome/idl
+
+@COMMENCE@
+
+EXPORT_PYSCRIPTS = MED_test1.py MED_test2.py
+
+# Libraries targets
+
+LIB = libMedEngine.la
+
+LIB_SRC = Med_Gen_i.cxx
+LIB_SERVER_IDL = Med_Gen.idl SALOME_Component.idl \
+ SALOME_Exception.idl MED.idl
+
+LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl
+
+# Executables targets
+BIN =
+BIN_SRC =
+
+# additionnal information to compil and link file
+
+CPPFLAGS += $(OCC_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES)
+CXXFLAGS += $(OCC_CXXFLAGS)
+
+LDFLAGS+= $(OCC_LIBS) $(HDF5_LIBS) -lSalomeContainer -lSalomeHDFPersist -lSalomeDS -lSalomeNS -lRegistry -lOpUtil -lmedmem -lMEDImpl
+
+
+MED.hh MEDSK.cc: MED.idl
+ omniidl -bcxx -Wbtp $^
+
+@CONCLUDE@
--- /dev/null
+//=============================================================================
+// File : Med_Gen_i.cxx
+// Created : mer fév 20 15:47:57 CET 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2001
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "Med_Gen_i.hxx"
+
+#include "Mesh_i.hxx"
+#include "Med_i.hxx"
+#include "FieldInt_i.hxx"
+#include "FieldDouble_i.hxx"
+#include "Support_i.hxx"
+
+
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Med.hxx"
+#include "MEDMEM_MedMedDriver.hxx"
+#include "MEDMEM_MedMeshDriver.hxx"
+#include "MEDMEM_MedFieldDriver.hxx"
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_DriversDef.hxx"
+
+
+#include "Utils_SINGLETON.hxx"
+#include "OpUtil.hxx"
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+#include <string>
+#include <deque>
+#include <map>
+
+#include <TCollection_AsciiString.hxx>
+#include <TColStd_SequenceOfAsciiString.hxx>
+#include "SALOMEDS_Tool.hxx"
+
+// Initialisation des variables statiques
+ map <string, string> Med_Gen_i::_MedCorbaObj;
+ string Med_Gen_i::_myFileName="";
+ string Med_Gen_i::_saveFileName="";
+
+//=============================================================================
+/*!
+ * default constructor: not for use
+ */
+//=============================================================================
+
+Med_Gen_i::Med_Gen_i()
+{
+ MESSAGE("Med_Gen_i::Med_Gen_i");
+}
+
+//=============================================================================
+/*!
+ * standard constructor
+ */
+//=============================================================================
+
+Med_Gen_i:: Med_Gen_i(CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName) :
+ Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
+{
+ MESSAGE("activate object");
+ _thisObj = this ;
+ _id = _poa->activate_object(_thisObj);
+
+ _duringLoad=false;
+ // get an NamingService interface
+ _NS = SINGLETON_<SALOME_NamingService>::Instance() ;
+ ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting()) ;
+ _NS->init_orb( _orb ) ;
+}
+//=============================================================================
+/*!
+ * private method : change a study name in SALOMEDS::Study_var
+ */
+//=============================================================================
+
+SALOMEDS::Study_var Med_Gen_i::studyName2Study(const char* studyName)
+ throw(SALOME::SALOME_Exception)
+{
+ string myStudyName(studyName);
+
+ if (myStudyName.size() == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No Study Name given", \
+ 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))
+ THROW_SALOME_CORBA_EXCEPTION("Wrong Study Name", \
+ SALOME::BAD_PARAM);
+
+ return SALOMEDS::Study::_duplicate(myStudy) ;
+}
+
+//=============================================================================
+/*!
+ * private method : add Med component in Study (Not MedGen ???)
+ */
+//=============================================================================
+
+void Med_Gen_i::addInStudy(SALOMEDS::Study_var myStudy)
+ throw(SALOME::SALOME_Exception)
+{
+ SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
+
+ myBuilder->NewCommand();
+
+ // Create SComponent labelled 'Med' if it doesn't already exit
+ SALOMEDS::SComponent_var medfather = myStudy->FindComponent("Med");
+ if ( CORBA::is_nil(medfather) )
+ {
+ // 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");
+ SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue("Med");
+ // 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();
+
+}
+
+//=============================================================================
+/*!
+ * Lit tous les objets contenus dans un fichier med et les lit en memoire
+ */
+//=============================================================================
+SALOME_MED::MED_ptr Med_Gen_i::readStructFile (const char* fileName,
+ const char* studyName)
+ throw(SALOME::SALOME_Exception)
+{
+ SCRUTE(fileName);
+ SALOMEDS::Study_var myStudy = studyName2Study(studyName) ;
+ if (!_duringLoad) addInStudy(myStudy) ;
+
+ SALOME_MED::MED_ptr myMedIOR ;
+ 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) ;
+ // create ::MED object, read all and add in study !
+ myMedI->init(myStudy,MED_DRIVER,fileName) ;
+ }
+ catch (const SALOMEDS::StudyBuilder::LockProtection & lp) {}
+ catch(...)
+ {
+ MESSAGE("Erreur a la lecture du fichier");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to open File "\
+ ,SALOME::BAD_PARAM);
+ }
+ return SALOME_MED::MED::_duplicate(myMedIOR) ;
+}
+
+//=============================================================================
+/*!
+ * Prepare un Maillage sans le lire en memoire avec stokage dans l'etude
+ * des champs avec leur type
+ */
+//=============================================================================
+void Med_Gen_i::readStructFileWithFieldType (const char* fileName,
+ const char* studyName)
+throw (SALOME::SALOME_Exception)
+{
+ BEGIN_OF("Med_Gen_i::readStructFileWithFieldType (const char* fileName,const char* studyName)");
+
+ SCRUTE(fileName);
+ SALOMEDS::Study_var myStudy = studyName2Study(studyName) ;
+
+ if (!_duringLoad) addInStudy(myStudy) ;
+
+ 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) ;
+ // create ::MED object, read all and add in study !
+ myMedI->initWithFieldType(myStudy,MED_DRIVER,fileName) ;
+ }
+ catch (const SALOMEDS::StudyBuilder::LockProtection & lp) {}
+ catch(...)
+ {
+ MESSAGE("Erreur a la lecture du fichier");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to open File "\
+ ,SALOME::BAD_PARAM);
+ }
+
+ END_OF("Med_Gen_i::readStructFileWithFieldType (const char* fileName,const char* studyName)");
+
+
+}
+
+//=============================================================================
+/*!
+ * Sert un Maillage
+ */
+//=============================================================================
+SALOME_MED::MESH_ptr Med_Gen_i::readMeshInFile(const char* fileName,
+ const char* studyName,
+ const char* meshName)
+throw (SALOME::SALOME_Exception)
+{
+ SCRUTE(fileName);
+ SALOMEDS::Study_var myStudy = studyName2Study(studyName) ;
+
+ if (!_duringLoad) addInStudy(myStudy) ;
+
+// Creation du maillage
+
+ MESH * myMesh= new MESH() ;
+ myMesh->setName(meshName);
+ MED_MESH_RDONLY_DRIVER myMeshDriver(fileName,myMesh);
+ try
+ {
+ myMeshDriver.setMeshName(meshName);
+ myMeshDriver.open();
+ }
+ catch (const exception & ex)
+ {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ THROW_SALOME_CORBA_EXCEPTION("Unable to find this mesh in this file",SALOME::BAD_PARAM);
+ };
+ try
+ {
+ myMeshDriver.read();
+("apres read");
+ myMeshDriver.close();
+ }
+ catch (const exception & ex)
+ {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ THROW_SALOME_CORBA_EXCEPTION("Unable to read this mesh in this file",SALOME::BAD_PARAM);
+ };
+
+ MESH_i * meshi = new MESH_i(myMesh);
+ //SALOME_MED::MESH_var mesh = SALOME_MED::MESH::_narrow(meshi->_this());
+ SALOME_MED::MESH_ptr mesh = meshi->_this();
+ try
+ {
+ // add the mesh object in study
+ if (!_duringLoad) meshi->addInStudy(myStudy,mesh);
+ }
+ catch (const SALOMEDS::StudyBuilder::LockProtection & lp) {}
+ return SALOME_MED::MESH::_duplicate(mesh);
+}
+//=============================================================================
+/*!
+ * Sert un Champ
+ */
+//=============================================================================
+SALOME_MED::FIELD_ptr Med_Gen_i::readFieldInFile(const char* fileName,
+ const char* studyName,
+ const char* fieldName,
+ CORBA::Long ordre,
+ CORBA::Long iter)
+throw (SALOME::SALOME_Exception)
+{
+ SCRUTE(fileName);
+ string myStudyName(studyName);
+
+ if (myStudyName.size() == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No Study Name given", \
+ SALOME::BAD_PARAM);
+
+ // Get StudyManager Reference, current study,
+
+ CORBA::Object_var obj = _NS->Resolve("/myStudyManager");
+ SALOMEDS::StudyManager_var myStudyManager =
+ SALOMEDS::StudyManager::_narrow(obj);
+ ASSERT(! CORBA::is_nil(myStudyManager));
+ SALOMEDS::Study_var myStudy =
+ myStudyManager->GetStudyByName(myStudyName.c_str());
+ if (CORBA::is_nil(myStudy))
+ THROW_SALOME_CORBA_EXCEPTION("Wrong Study Name", \
+ SALOME::BAD_PARAM);
+
+ SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
+ SALOMEDS::SComponent_var medfather = myStudy->FindComponent("Med");
+ if (CORBA::is_nil(medfather))
+ {
+ myBuilder->NewCommand();
+ // mpv: component label must be created in spite of "Locked" study flag state
+ bool aLocked = myStudy->GetProperties()->IsLocked();
+ if (aLocked) myStudy->GetProperties()->SetLocked(false);
+
+ medfather = myBuilder->NewComponent("Med");
+ SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(
+ myBuilder->FindOrCreateAttribute(medfather, "AttributeName"));
+ aName->SetValue("Med");
+ CORBA::Object_var myO = _poa->id_to_reference(*_id); // this ior...
+ myBuilder->DefineComponentInstance(medfather,myO);
+
+ if (aLocked) myStudy->GetProperties()->SetLocked(true);
+ myBuilder->CommitCommand();
+
+ }
+ else
+ MESSAGE("MED dejà dans l étude");
+
+ MESSAGE("Lecture du fichier ")
+ SCRUTE(fileName);
+
+// Creation du champ
+
+ FIELD_ * myField= new FIELD_() ;
+ MED * mymed = new MED(MED_DRIVER,fileName) ;
+ try
+ {
+ deque<string> fieldsNames = mymed->getFieldNames() ;
+ int numberOfFields = fieldsNames.size();
+ int i;
+ for (i=0; i<numberOfFields; i++)
+ {
+ if (fieldsNames[i]== fieldName) break;
+ }
+ if (i == numberOfFields)
+ {
+ THROW_SALOME_CORBA_EXCEPTION("Unable to find this field ",SALOME::BAD_PARAM);
+ }
+ MESSAGE("trouve");
+/*
+ deque<DT_IT_> myIteration = mymed->getFieldIteration (fieldName);
+ if (myIteration.size() != 1)
+ {
+ MESSAGE("WARNING : My iteration size is ")
+ SCRUTE(myIteration.size());
+ }
+*/
+ myField = mymed->getField(fieldName,iter,ordre);
+ }
+ catch (const exception & ex)
+ {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ THROW_SALOME_CORBA_EXCEPTION("Unable to find this field in this file",SALOME::BAD_PARAM);
+ };
+
+ SUPPORT * fieldSupport;
+ SALOME_MED::SUPPORT_ptr mySupportIOR;
+ try
+ {
+ fieldSupport=(SUPPORT *)myField->getSupport() ;
+ ASSERT(fieldSupport != NULL);
+ MESH * myMesh=(MESH *)fieldSupport->getMesh();
+ ASSERT(myMesh != NULL);
+ myMesh->read();
+ SCRUTE(myMesh->getName());
+ fieldSupport->update();
+ SUPPORT_i * mySupportI = new SUPPORT_i(fieldSupport);
+ mySupportIOR=mySupportI->_this();
+ }
+ catch (const exception & ex)
+ {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ THROW_SALOME_CORBA_EXCEPTION("Unable to find associated support",SALOME::BAD_PARAM);
+ };
+
+ med_type_champ type = myField->getValueType() ;
+ switch (type)
+ {
+ case MED_FR::MED_INT32:
+ {
+ try
+ {
+ ((FIELD<int>*)myField)->read() ;
+ FIELDINT_i * myFieldIntI = new FIELDINT_i(mySupportIOR,(FIELD<int>*)myField);
+ POA_SALOME_MED::FIELD_tie<FIELD_i> * myFieldTie = new POA_SALOME_MED::FIELD_tie<FIELD_i>(myFieldIntI);
+ SALOME_MED::FIELD_ptr myFieldIOR = myFieldTie->_this() ;
+ if (!_duringLoad) myFieldIntI->addInStudy(myStudy,myFieldIOR) ;
+ return SALOME_MED::FIELD::_duplicate(myFieldIOR);
+ }
+ catch (const SALOMEDS::StudyBuilder::LockProtection & lp) {}
+ catch (const exception & ex)
+ {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ THROW_SALOME_CORBA_EXCEPTION("Unable to read int field",SALOME::BAD_PARAM);
+ };
+ break;
+ }
+ case MED_FR::MED_REEL64:
+ {
+ try
+ {
+ ((FIELD<double>*)myField)->read() ;
+ FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i(mySupportIOR,(FIELD<double>*)myField);
+ POA_SALOME_MED::FIELD_tie<FIELD_i> * myFieldTie = new POA_SALOME_MED::FIELD_tie<FIELD_i>(myFieldDoubleI);
+ SALOME_MED::FIELD_ptr myFieldIOR = myFieldTie->_this() ;
+ if (!_duringLoad) myFieldDoubleI->addInStudy(myStudy,myFieldIOR) ;
+ return SALOME_MED::FIELD::_duplicate(myFieldIOR);
+ }
+ catch (const SALOMEDS::StudyBuilder::LockProtection & lp) {}
+ catch (const exception & ex)
+ {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ THROW_SALOME_CORBA_EXCEPTION("Unable to read double field",SALOME::BAD_PARAM);
+ };
+ break;
+ }
+ }
+
+
+}
+
+
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+
+Med_Gen_i::~Med_Gen_i()
+{
+ MESSAGE("Med_Gen_i::~Med_Gen_i");
+}
+
+//=============================================================================
+/*!
+ * CORBA: Save Mesh objects (called when a study is saved)
+ */
+//=============================================================================
+SALOMEDS::TMPFile* Med_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent) {
+ const char* LOC = "Med_Gen_i::Save";
+ BEGIN_OF(LOC);
+
+ SALOMEDS::TMPFile_var aStreamFile;
+ // Get a temporary directory to store a file
+ TCollection_AsciiString aTmpDir = SALOMEDS_Tool::GetTmpDir();
+ // Create a list to store names of created files
+ SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
+ TColStd_SequenceOfAsciiString aFileNames;
+
+ SALOMEDS::SObject_var aMedMeshFather = theComponent->GetStudy()->FindObject("MEDMESH");
+ if (!CORBA::is_nil(aMedMeshFather)) {
+ SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedMeshFather);
+ for(; anIter->More(); anIter->Next()) {
+ SALOMEDS::SObject_var aSO = anIter->Value();
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (aSO->FindAttribute(anAttr,"AttributeIOR")) {
+ CORBA::Object_var myIOR = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value());
+ SALOME_MED::MESH_var myMesh = SALOME_MED::MESH::_narrow(myIOR);
+ if (! CORBA::is_nil(myMesh)) {
+ TCollection_AsciiString aName;
+ aName = "MED_tmp_";
+ aName += myMesh->getName();
+ aName += ".med";
+// MESSAGE("Save mesh with name "<<aName.ToCString());
+ long driverId = myMesh->addDriver(SALOME_MED::MED_DRIVER,(aTmpDir+aName).ToCString(),myMesh->getName());
+ myMesh->write(driverId,"");
+ aFileNames.Append(aName);
+ }
+ }
+ }
+ }
+
+ SALOMEDS::SObject_var aMedFieldFather = theComponent->GetStudy()->FindObject("MEDFIELD");
+ if (!CORBA::is_nil(aMedFieldFather)) {
+ SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedFieldFather);
+ for(; anIter->More(); anIter->Next()) {
+ SALOMEDS::SObject_var aSO = anIter->Value();
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (aSO->FindAttribute(anAttr,"AttributeIOR")) {
+ CORBA::Object_var myIOR = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value());
+ SALOME_MED::FIELD_var myField = SALOME_MED::FIELD::_narrow(myIOR);
+ if (! CORBA::is_nil(myField)) {
+ TCollection_AsciiString aName;
+ aName = "MED_tmp_";
+ aName += myField->getName();
+ aName += ".med";
+// MESSAGE("Save mesh with name "<<aName.ToCString());
+ long driverId = myField->addDriver(SALOME_MED::MED_DRIVER,(aTmpDir+aName).ToCString(),myField->getName());
+ myField->write(driverId,"");
+ aFileNames.Append(aName);
+ }
+ }
+ }
+ }
+
+ int i;
+ aSeq->length(aFileNames.Length());
+ for(i = aFileNames.Length(); i > 0; i--) aSeq[i-1] = CORBA::string_dup(aFileNames.Value(i).ToCString());
+ // Conver a file to the byte stream
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq);
+ // Remove the created file and tmp directory
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq, true);
+ // Return the created byte stream
+ return aStreamFile._retn();
+
+ END_OF(LOC);
+}
+
+//=============================================================================
+/*!
+ * CORBA: Load Mesh objects (called when an existing study is opened)
+ */
+//=============================================================================
+
+CORBA::Boolean Med_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream) {
+ const char* LOC = "Med_Gen_i::Load";
+ BEGIN_OF(LOC);
+
+ // Get a temporary directory for a file
+ TCollection_AsciiString aTmpDir = SALOMEDS_Tool::GetTmpDir();
+ _saveFileName = CORBA::string_dup(aTmpDir.ToCString());
+ SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.ToCString());
+ return true;
+
+ END_OF(LOC);
+}
+
+//=============================================================================
+/*!
+ * CORBA:
+ */
+//=============================================================================
+
+void Med_Gen_i::Close(const char *IORSComponent)
+{
+ MESSAGE("Med_Gen_i::Close");
+}
+
+//=============================================================================
+/*!
+ * CORBA:
+ */
+//=============================================================================
+
+char* Med_Gen_i::ComponentDataType()
+{
+ MESSAGE("Med_Gen_i::ComponentDataType");
+ return strdup("Med") ; /* What is this type ? */
+}
+
+//=============================================================================
+/*!
+ * CORBA: give a persistent reference of a transient object (for study save)
+ */
+//=============================================================================
+
+char* Med_Gen_i::IORToLocalPersistentID(const char* IORString,
+ CORBA::Boolean& IsAFile)
+{
+ const char * LOC = "Med_Gen_i::IORToLocalPersistentID" ;
+ BEGIN_OF(LOC) ;
+
+ SCRUTE(IORString);
+ if (string(IORString).size()==0) return strdup("");
+ // Well, we know where put object (_saveFilename) and we know object (IORString)
+ // cast object :
+ CORBA::Object_var myIOR = _orb->string_to_object(IORString);
+
+ // MED
+ SALOME_MED::MED_var myMed = SALOME_MED::MED::_narrow(myIOR);
+ if (! CORBA::is_nil(myMed))
+ {
+ // nothing to save : Support will be saved inside the mesh
+ string str_MedName="Objet Med + /OBJ_MED/";
+ return strdup(str_MedName.c_str()) ;
+ }
+
+ // MESH
+ SALOME_MED::MESH_var myMesh = SALOME_MED::MESH::_narrow(myIOR);
+ if (! CORBA::is_nil(myMesh))
+ {
+ string str_MeshName;
+ try
+ {
+ long driverId = myMesh->addDriver(SALOME_MED::MED_DRIVER,_saveFileName.c_str(),myMesh->getName()) ;
+ myMesh->write(driverId,"");
+ str_MeshName=string("/ENS_MAA/")+string(myMesh->getName());
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to save the mesh");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to save Mesh in Med"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return strdup(str_MeshName.c_str()) ;
+ }
+
+ // SUPPORT
+ SALOME_MED::SUPPORT_var mySupport = SALOME_MED::SUPPORT::_narrow(myIOR);
+ if (! CORBA::is_nil(mySupport))
+ {
+ // nothing to save : Support will be saved inside the mesh
+ string str_SupportName;
+ try
+ {
+ str_SupportName=string("/FAS/")+string(mySupport->getName());
+ str_SupportName+=string("/ENS_MAA/")+string(mySupport->getMesh()->getName());
+ SCRUTE(str_SupportName);
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to save the support");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to save Field in Med"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return strdup(str_SupportName.c_str());
+ }
+
+ SALOME_MED::FIELD_var myField = SALOME_MED::FIELD::_narrow(myIOR);
+ if (! CORBA::is_nil(myField))
+ {
+ string str_FieldName;
+ try
+ {
+ long driverId = myField->addDriver(SALOME_MED::MED_DRIVER,_saveFileName.c_str(),myField->getName()) ;
+ myField->write(driverId,"");
+ str_FieldName=string("/CHA/")+string(myField->getName());
+ ostringstream a,b;
+ a<< myField->getOrderNumber();
+ b<< myField->getIterationNumber();
+ str_FieldName+=string("/ORDRE/")+a.str()+string("/ITER/")+b.str();
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to save the mesh");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to save Field in Med"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return strdup(str_FieldName.c_str());
+ }
+
+ //THROW_SALOME_CORBA_EXCEPTION("Unable to save IOR",SALOME::BAD_PARAM);
+ return strdup("");
+
+ END_OF(LOC) ;
+}
+
+//=============================================================================
+/*!
+ * CORBA: give a transient reference (when loading an object, opening study)
+ */
+//=============================================================================
+
+char* Med_Gen_i::LocalPersistentIDToIOR(const char* aLocalPersistentID)
+{
+ const char * LOC = "Med_Gen_i::LocalPersistentIDToIOR" ;
+ BEGIN_OF(LOC) ;
+
+ TCollection_AsciiString aTmpDir(CORBA::string_dup(_saveFileName.c_str()));
+ TCollection_AsciiString aFileName("MED_tmp_");
+ aFileName += CORBA::string_dup(aLocalPersistentID);
+ aFileName += ".med";
+
+ MESH * myMesh= new MESH() ;
+ myMesh->setName(aLocalPersistentID);
+ MED_MESH_RDONLY_DRIVER myMeshDriver((aTmpDir+aFileName).ToCString(),myMesh);
+ try
+ {
+ myMeshDriver.setMeshName(aLocalPersistentID);
+ myMeshDriver.open();
+ }
+ catch (const exception & ex)
+ {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ THROW_SALOME_CORBA_EXCEPTION("Unable to find this mesh in this file",SALOME::BAD_PARAM);
+ };
+ try
+ {
+ myMeshDriver.read();
+ MESSAGE("apres read");
+ myMeshDriver.close();
+ }
+ catch (const exception & ex)
+ {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ THROW_SALOME_CORBA_EXCEPTION("Unable to read this mesh in this file",SALOME::BAD_PARAM);
+ };
+
+ MESH_i * meshi = new MESH_i(myMesh);
+ //SALOME_MED::MESH_var mesh = SALOME_MED::MESH::_narrow(meshi->_this());
+ SALOME_MED::MESH_ptr mesh = meshi->_this();
+
+ SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
+ aSeq->length(1);
+ aSeq[0]=CORBA::string_dup(aFileName.ToCString());
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq, true);
+
+ return(CORBA::string_dup(_orb->object_to_string(mesh)));
+
+ END_OF(LOC) ;
+}
+
+//=============================================================================
+/*!
+ * returns true, if can publish object
+ */
+//=============================================================================
+bool Med_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) {
+ SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(theIOR);
+ return !(aMesh->_is_nil());
+}
+
+//=============================================================================
+/*!
+ * publish the given object
+ */
+//=============================================================================
+SALOMEDS::SObject_ptr Med_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
+ SALOMEDS::SObject_ptr theSObject,
+ CORBA::Object_ptr theObject,
+ const char* theName) throw (SALOME::SALOME_Exception)
+{
+ SALOMEDS::SObject_var aResultSO;
+
+ if(CORBA::is_nil(theObject)) return aResultSO;
+ if(theStudy->_is_nil()) return aResultSO;
+
+ SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var anIOR;
+ SALOMEDS::SComponent_var aFather = theStudy->FindComponent("Med");
+
+ if (aFather->_is_nil()) {
+ aFather = aBuilder->NewComponent("Med");
+ if (aFather->_is_nil()) return aResultSO;
+ anAttr = aBuilder->FindOrCreateAttribute(aFather, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue("MED");
+ aBuilder->DefineComponentInstance(aFather, Med_Gen::_this());
+ }
+
+ if (CORBA::is_nil(theSObject)) {
+ SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(theObject);
+ aMesh->addInStudy(theStudy, aMesh);
+ SALOMEDS::SObject_var aResultSO = theStudy->FindObjectIOR(_orb->object_to_string(theObject));
+ } else {
+ if (!theSObject->ReferencedObject(aResultSO))
+ THROW_SALOME_CORBA_EXCEPTION("Publish in study MED object error",SALOME::BAD_PARAM);
+ }
+// aBuilder->Addreference(theObject, aResultSO);
+ return aResultSO._retn();
+}
+
+//=============================================================================
+/*!
+ * C factory, accessible with dlsym, after dlopen
+ */
+//=============================================================================
+
+extern "C"
+{
+ PortableServer::ObjectId * MedEngine_factory(
+ CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName)
+ {
+ MESSAGE("PortableServer::ObjectId * MedEngine_factory()");
+ SCRUTE(interfaceName);
+ Med_Gen_i * myMed_Gen
+ = new Med_Gen_i(orb, poa, contId, instanceName, interfaceName);
+ return myMed_Gen->getId() ;
+ }
+}
--- /dev/null
+//=============================================================================
+// File : Med_Gen_i.hxx
+// Created : mer fév 20 15:47:52 CET 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2001
+// $Header$
+//=============================================================================
+
+#ifndef _MED_GEN_I_HXX_
+#define _MED_GEN_I_HXX_
+
+#include <SALOMEconfig.h>
+#include <map>
+#include CORBA_SERVER_HEADER(Med_Gen)
+#include CORBA_SERVER_HEADER(MED)
+
+#include "SALOME_Component_i.hxx"
+#include "SALOME_NamingService.hxx"
+
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class Med_Gen_i:
+ public POA_Engines::Med_Gen,
+ public Engines_Component_i
+{
+private:
+ SALOMEDS::Study_var studyName2Study(const char* studyName)
+ throw(SALOME::SALOME_Exception);
+ void addInStudy(SALOMEDS::Study_var myStudy)
+ throw(SALOME::SALOME_Exception);
+
+public:
+ Med_Gen_i();
+ Med_Gen_i(CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName);
+ virtual ~Med_Gen_i();
+
+ //
+ SALOME_MED::MESH_ptr readMeshInFile(const char* fileName,
+ const char* studyName,
+ const char* meshName)
+ throw(SALOME::SALOME_Exception);
+
+ SALOME_MED::FIELD_ptr readFieldInFile(const char* fileName,
+ const char* studyName,
+ const char* fieldName,
+ CORBA::Long ordre,
+ CORBA::Long iter)
+ throw(SALOME::SALOME_Exception);
+
+ SALOME_MED::MED_ptr readStructFile(const char* fileName,
+ const char* studyName)
+ throw(SALOME::SALOME_Exception);
+
+ void readStructFileWithFieldType(const char* fileName,
+ const char* studyName)
+ throw(SALOME::SALOME_Exception);
+
+ // inherited methods from SALOMEDS::Driver
+
+// void Save(const char *IORSComponent, const char *aUrlOfFile);
+// void Load(const char *IORSComponent, const char *aUrlOfFile);
+ SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent);
+ CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream);
+ void Close(const char *IORSComponent);
+ char* ComponentDataType();
+
+ char* IORToLocalPersistentID(const char* IORString, CORBA::Boolean& IsAFile);
+ char* LocalPersistentIDToIOR(const char* aLocalPersistentID);
+
+ bool CanPublishInStudy(CORBA::Object_ptr theIOR);
+
+ SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
+ SALOMEDS::SObject_ptr theSObject,
+ CORBA::Object_ptr theObject,
+ const char* theName) throw (SALOME::SALOME_Exception) ;
+ private :
+ static map <string, string>_MedCorbaObj;
+ static string _myFileName;
+ static string _saveFileName;
+
+ private:
+ bool _duringLoad;
+ int _myStudyID;
+ string _myStudyName;
+
+ int myCounter;
+ SALOME_NamingService *_NS;
+
+
+};
+
+#endif
--- /dev/null
+#==============================================================================
+# File : Makefile.in
+# Created : dim déc 9 18:35:11 CET 2001
+# Author : Paul RASCLE, EDF
+# Project : SALOME
+# Copyright : EDF 2001
+# $Header$
+#==============================================================================
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=../../..
+srcdir=@srcdir@
+VPATH=.:$(srcdir):$(top_builddir)/share/salome/idl
+
+
+@COMMENCE@
+
+# header files
+EXPORT_HEADERS=
+
+# .po files to transform in .qm
+PO_FILES = \
+ MedGUI_icons.po \
+ MedGUI_msg_fr.po \
+ MedGUI_msg_en.po \
+
+
+# Libraries targets
+LIB = libMedGUI.la
+LIB_SRC = MedGUI.cxx
+LIB_MOC = MedGUI.h
+
+LIB_CLIENT_IDL = SALOMEDS.idl SALOME_Exception.idl \
+ Med_Gen.idl MED.idl \
+ SMESH_Mesh.idl SMESH_Hypothesis.idl SMESH_BasicHypothesis.idl \
+ GEOM_Shape.idl SALOMEDS_Attributes.idl
+
+LIB_SERVER_IDL =
+
+# additionnal information to compil and link file
+
+CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES)
+CXXFLAGS +=
+
+LDFLAGS += -lSalomeGUI -lmedmem -lMEDImpl -lMedEngine -lSMESHFiltersSelection
+
+
+MED.hh MEDSK.cc: MED.idl
+ omniidl -bcxx -Wbtp $^
+
+@CONCLUDE@
--- /dev/null
+//=============================================================================
+// File : MedGUI.cxx
+// Project : SALOME
+// Copyright : EDF 2001
+//=============================================================================
+
+#include "MedGUI.h"
+
+// SALOME Includes
+#include "Utils_ORB_INIT.hxx"
+#include "Utils_SINGLETON.hxx"
+#include "utilities.h"
+
+#include "SALOME_Selection.h"
+#include "SALOME_InteractiveObject.hxx"
+#include "SALOMEGUI_QtCatchCorbaException.hxx"
+
+#include "QAD_MessageBox.h"
+#include "QAD_Tools.h"
+#include "QAD_FileDlg.h"
+
+#include "SMESH_TypeFilter.hxx"
+
+// QT Includes
+#include <qinputdialog.h>
+
+//VRV: porting on Qt 3.0.5
+#if QT_VERSION >= 0x030005
+#include <qlineedit.h>
+#endif
+//VRV: porting on Qt 3.0.5
+
+static CORBA::ORB_var _orb;
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool MedGUI::OnGUIEvent (int theCommandID, QAD_Desktop* parent)
+{
+ setOrb();
+
+ QAD_Study* myActiveStudy = parent->getActiveStudy();
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ SALOME_NamingService* myNameService = parent->getNameService();
+
+ QString file;
+ QStringList filtersList ;
+
+ filtersList.append( tr("MED_MEN_IMPORT_MED") );
+ filtersList.append( tr("MED_MEN_ALL_FILES") ) ;
+
+ switch (theCommandID)
+ {
+ case 4031:
+ case 9031:
+ case 931:
+ {
+ MESSAGE("command " << theCommandID << " activated");
+
+ QString myStudyName = myActiveStudy->getTitle();
+ bool ok=FALSE;
+ int myStudyId = myActiveStudy->getStudyId();
+
+ // load MED engine
+ Engines::Med_Gen_ptr medgen = InitMedGen(parent);
+
+ // Selection du Fichier
+ file = QAD_FileDlg::getFileName(parent,
+ "",
+ filtersList,
+ tr("MED_MEN_IMPORT"),
+ true);
+
+ // Selection du Maillage
+ if (!file.isEmpty() )
+ {
+ SCRUTE(file);
+ QString meshName;
+ meshName = QInputDialog::getText( QString( tr("MED_INF_MESHNAME") ),
+ QString::null,
+ //VRV: porting on Qt 3.0.5
+#if QT_VERSION >= 0x030005
+ QLineEdit::Normal,
+#endif
+ //VRV: porting on Qt 3.0.5
+ QString::null, &ok);
+ if ( ! meshName.isEmpty())
+ {
+ try
+ {
+ medgen->readMeshInFile(file.latin1(),myStudyName,meshName);
+ if (myActiveStudy->getStudyDocument()->GetProperties()->IsLocked()) {
+ QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(),
+ QObject::tr("WRN_WARNING"),
+ QObject::tr("WRN_STUDY_LOCKED"),
+ QObject::tr("BUT_OK"));
+ }
+ }
+ catch (const SALOME::SALOME_Exception & S_ex)
+ {
+ QtCatchCorbaException(S_ex);
+ }
+ }
+ myActiveStudy->updateObjBrowser();
+ }
+ break;
+ }
+ case 4032:
+ case 9032:
+ case 932:
+ {
+ MESSAGE("command " << theCommandID << " activated");
+
+ QString myStudyName = myActiveStudy->getTitle();
+ bool ok=FALSE;
+ int myStudyId = myActiveStudy->getStudyId();
+
+ // load MED engine
+ Engines::Med_Gen_ptr medgen = InitMedGen(parent);
+
+ // Selection du Fichier
+ file = QAD_FileDlg::getFileName(parent,
+ "",
+ filtersList,
+ tr("MED_MEN_IMPORT"),
+ true);
+
+ // Selection du Maillage
+ if (!file.isEmpty() )
+ {
+ SCRUTE(file);
+ QString fieldName;
+ fieldName = QInputDialog::getText(
+ QString( tr("MED_INF_FIELDNAME") ), QString::null,
+ //VRV: porting on Qt 3.0.5
+#if QT_VERSION >= 0x030005
+ QLineEdit::Normal,
+#endif
+ //VRV: porting on Qt 3.0.5
+ QString::null, &ok);
+ if ( ! fieldName.isEmpty())
+ {
+ try
+ {
+ medgen->readFieldInFile(file.latin1(),myStudyName,fieldName,-1,-1);
+ if (myActiveStudy->getStudyDocument()->GetProperties()->IsLocked()) {
+ QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(),
+ QObject::tr("WRN_WARNING"),
+ QObject::tr("WRN_STUDY_LOCKED"),
+ QObject::tr("BUT_OK"));
+ }
+ }
+ catch (const SALOME::SALOME_Exception & S_ex)
+ {
+ QtCatchCorbaException(S_ex);
+ }
+
+ myActiveStudy->updateObjBrowser();
+ }
+ }
+ break;
+ }
+ case 4033:
+ case 933:
+ {
+ MESSAGE("command " << theCommandID << " activated");
+
+ QString myStudyName = myActiveStudy->getTitle();
+ int myStudyId = myActiveStudy->getStudyId();
+
+ // load MED engine
+ Engines::Med_Gen_ptr medgen = InitMedGen(parent);
+
+ // Selection du Fichier
+ file = QAD_FileDlg::getFileName(parent,
+ "",
+ filtersList,
+ tr("MED_MEN_IMPORT"),
+ true);
+ if (!file.isEmpty() )
+ {
+ SCRUTE(file);
+ try
+ {
+ medgen->readStructFile(file.latin1(),myStudyName);
+ if (myActiveStudy->getStudyDocument()->GetProperties()->IsLocked()) {
+ QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(),
+ QObject::tr("WRN_WARNING"),
+ QObject::tr("WRN_STUDY_LOCKED"),
+ QObject::tr("BUT_OK"));
+ }
+ }
+ catch (const SALOME::SALOME_Exception & S_ex)
+ {
+ QtCatchCorbaException(S_ex);
+ }
+ myActiveStudy->updateObjBrowser();
+ }
+ break;
+ }
+
+ case 934:
+ {
+ //Handle(SMESH_TypeFilter) aMeshFilter = new SMESH_TypeFilter( MESH );
+ SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
+ //Sel->AddFilter(aMeshFilter) ;
+
+ int nbSel = Sel->IObjectCount();
+ if ( nbSel == 1 )
+ {
+ SMESH::SMESH_Mesh_var aM;
+ SALOME_MED::MESH_var aMesh;
+ Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
+ if ( IObject->hasEntry() )
+ {
+ SALOMEDS::SObject_var aMorSM = aStudy->FindObjectID( IObject->getEntry() );
+ if ( !aMorSM->_is_nil() )
+ {
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if (aMorSM->FindAttribute(anAttr, "AttributeIOR"))
+ {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ aMesh = SALOME_MED::MESH::_narrow( _orb->string_to_object(anIOR->Value()) );
+ if ( aMesh->_is_nil() )
+ {
+ aM = SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->Value()));
+ if ( aM->_is_nil() )
+ {
+ QAD_MessageBox::warn1
+ ( QAD_Application::getDesktop(),
+ tr ("MED_WRN_WARNING"),
+ tr ("MED_INF_NOTIMPL"),
+ tr ("MED_BUT_OK") );
+ break;
+ }
+ aMesh = aM->GetMEDMesh();
+ if ( aMesh->_is_nil() )
+ {
+ QAD_MessageBox::warn1
+ ( QAD_Application::getDesktop(),
+ tr ("MED_WRN_WARNING"),
+ tr ("MED_INF_NOTIMPL"),
+ tr ("MED_BUT_OK") );
+ break;
+ }
+ }
+ DumpMesh( aMesh );
+ //Sel->ClearFilters() ;
+ }
+ else
+ {
+ QAD_MessageBox::warn1
+ ( QAD_Application::getDesktop(),
+ tr ("MED_WRN_WARNING"),
+ tr ("MED_INF_NOIOR"),
+ tr ("MED_BUT_OK") );
+ break;
+ }
+ }
+ }
+ }
+ break;
+ }
+
+ case 935:
+ {
+ //Handle(SMESH_TypeFilter) aSubMeshFilter = new SMESH_TypeFilter( SUBMESH );
+ SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
+ //Sel->AddFilter(aSubMeshFilter) ;
+
+ int nbSel = Sel->IObjectCount();
+ if ( nbSel == 1 )
+ {
+ SMESH::SMESH_subMesh_var aSubM;
+ SALOME_MED::FAMILY_var aFam;
+ Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
+ if ( IObject->hasEntry() )
+ {
+ SALOMEDS::SObject_var aMorSM = aStudy->FindObjectID( IObject->getEntry() );
+ if ( !aMorSM->_is_nil() )
+ {
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if (aMorSM->FindAttribute(anAttr, "AttributeIOR"))
+ {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ aSubM = SMESH::SMESH_subMesh::_narrow( _orb->string_to_object(anIOR->Value()) );
+ if ( aSubM->_is_nil() )
+ {
+ aFam=SALOME_MED::FAMILY::_narrow( _orb->string_to_object(anIOR->Value()));
+ if ( aFam->_is_nil() )
+ {
+ QAD_MessageBox::warn1
+ ( QAD_Application::getDesktop(),
+ tr ("MED_WRN_WARNING"),
+ tr ("MED_INF_NOTIMPL"),
+ tr ("MED_BUT_OK") );
+ break;
+ }
+ DumpSubMesh( aFam );
+ }
+ else
+ {
+ DumpSubMesh( aSubM );
+ //Sel->ClearFilters() ;
+ }
+ }
+ else
+ {
+ QAD_MessageBox::warn1
+ ( QAD_Application::getDesktop(),
+ tr ("MED_WRN_WARNING"),
+ tr ("MED_INFNOIOR"),
+ tr ("MED_BUT_OK") );
+ break;
+ }
+ }
+ }
+ }
+ break;
+ }
+ }
+ return true;
+}
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool MedGUI::OnMousePress (QMouseEvent* pe ,
+ QAD_Desktop* parent,
+ QAD_StudyFrame* studyFrame)
+{
+ MESSAGE("MedGUI::OnMousePress");
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool MedGUI::OnMouseMove (QMouseEvent* pe ,
+ QAD_Desktop* parent,
+ QAD_StudyFrame* studyFrame)
+{
+ // MESSAGE("MedGUI::OnMouseMouve");
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool MedGUI::OnKeyPress (QKeyEvent* pe,
+ QAD_Desktop* parent,
+ QAD_StudyFrame* studyFrame)
+{
+ MESSAGE("MedGUI::OnKeyPress");
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool MedGUI::SetSettings (QAD_Desktop* parent)
+{
+ MESSAGE("MedGUI::SetSettings");
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool MedGUI::CustomPopup ( QAD_Desktop* parent,
+ QPopupMenu* popup,
+ const QString & theContext,
+ const QString & theParent,
+ const QString & theObject )
+{
+ MESSAGE("MedGUI::CustomPopup");
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void MedGUI::ActiveStudyChanged( QAD_Desktop* parent )
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void MedGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
+{
+ theObject = "";
+ theContext = "";
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool MedGUI::DumpMesh( SALOME_MED::MESH_var MEDMesh)
+{
+
+ if ( MEDMesh->_is_nil() )
+ {
+ return false;
+ }
+
+ //SALOME_MED::MESH_var MEDMesh = aMesh->GetMEDMesh();
+ string name = MEDMesh->getName();
+ SCRUTE(name);
+
+ int dim = MEDMesh->getMeshDimension();
+ SCRUTE(dim);
+ int dim2 = MEDMesh->getSpaceDimension();
+ SCRUTE(dim2);
+
+ int k = MEDMesh->getNumberOfNodes() ;
+ SCRUTE(k);
+ Engines::double_array_var coords = MEDMesh->getCoordinates( SALOME_MED::MED_FULL_INTERLACE );
+ int i = 0;
+ int lu = 0;
+ while (lu < k ) {
+ if (dim2==3)
+ {
+ MESSAGE ( " Coordinates X = " << coords[i] << " Y = " << coords[i+1] << " Z = " << coords[i+2] );
+ i = i + 3; // Only for triangles
+ }
+ else
+ {
+ MESSAGE ( " Coordinates X = " << coords[i] << " Y = " << coords[i+1] );
+ i = i + 2;
+ }
+ lu=lu+1;
+ }
+
+ int nbfam=MEDMesh->getNumberOfFamilies(SALOME_MED::MED_NODE);
+ SCRUTE(nbfam);
+ SALOME_MED::Family_array_var Families=MEDMesh->getFamilies(SALOME_MED::MED_NODE) ;
+
+ for (k=0; k < nbfam; k++) {
+ SCRUTE(k);
+ string nomFam=Families[k]->getName();
+ SCRUTE(nomFam);
+ int identfam=Families[k]->getIdentifier();
+ SCRUTE(identfam);
+ int nbelemnts=Families[k]->getNumberOfElements(SALOME_MED::MED_NONE);
+ SCRUTE(nbelemnts);
+ Engines::long_array_var tabnoeuds=Families[k]->getNumber(SALOME_MED::MED_NONE);
+ for (int l=0;l<tabnoeuds->length();l++)
+ SCRUTE(tabnoeuds[l]);
+ }
+
+ // int famIdent = 1;
+ // SALOME_MED::FAMILY_ptr Family=MEDMesh->getFamily(SALOME_MED::MED_NODE,1) ;
+ // MESSAGE("ici");
+ // string nomFam=Family->getName();
+ // SCRUTE(nomFam);
+ // int identfam=Family->getIdentifier();
+ // SCRUTE(identfam);
+ // Engines::long_array_var tabnoeuds=Family->getNumber(SALOME_MED::MED_NONE);
+ // for (int l=0;l<tabnoeuds->length();l++)
+ // SCRUTE(tabnoeuds[l]);
+
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool MedGUI::DumpSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh )
+{
+ if ( aSubMesh->_is_nil() )
+ return false;
+
+ SALOME_MED::FAMILY_var Fam = aSubMesh->GetFamily();
+ if ( Fam->_is_nil() )
+ return false;
+
+ Engines::long_array_var tabnoeuds=Fam->getNumber(SALOME_MED::MED_NONE);
+ for (int l=0;l<tabnoeuds->length();l++)
+ SCRUTE(tabnoeuds[l]);
+
+ return true;
+}
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool MedGUI::DumpSubMesh( SALOME_MED::FAMILY_var Fam )
+{
+
+ if ( Fam->_is_nil() )
+ return false;
+
+ Engines::long_array_var tabnoeuds=Fam->getNumber(SALOME_MED::MED_NONE);
+ for (int l=0;l<tabnoeuds->length();l++)
+ SCRUTE(tabnoeuds[l]);
+
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+Engines::Med_Gen_ptr MedGUI::InitMedGen(QAD_Desktop* parent)
+{
+ Engines::Component_var comp =
+ parent->getEngine("FactoryServer", "Med");
+ MESSAGE("_________________________________________");
+ Engines::Med_Gen_var clr = Engines::Med_Gen::_narrow(comp);
+ ASSERT(!CORBA::is_nil(clr));
+ return clr._retn();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void MedGUI::setOrb()
+{
+ try {
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
+ _orb = init( 0 , 0 );
+ } catch (...) {
+ INFOS("internal error : orb not found");
+ _orb = 0;
+ }
+ ASSERT(! CORBA::is_nil(_orb));
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+extern "C"
+{
+ bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
+ {
+ return MedGUI::OnGUIEvent(theCommandID, parent);
+ }
+
+ bool OnKeyPress (QKeyEvent* pe,
+ QAD_Desktop* parent,
+ QAD_StudyFrame* studyFrame)
+ {
+ return MedGUI::OnKeyPress (pe, parent, studyFrame);
+ }
+
+ bool OnMousePress (QMouseEvent* pe,
+ QAD_Desktop* parent,
+ QAD_StudyFrame* studyFrame)
+ {
+ return MedGUI::OnMousePress (pe, parent, studyFrame);
+ }
+
+ bool OnMouseMove (QMouseEvent* pe,
+ QAD_Desktop* parent,
+ QAD_StudyFrame* studyFrame)
+ {
+ return MedGUI::OnMouseMove (pe, parent, studyFrame);
+ }
+
+ bool SetSettings ( QAD_Desktop* parent )
+ {
+ return MedGUI::SetSettings( parent );
+ }
+
+ bool customPopup ( QAD_Desktop* parent,
+ QPopupMenu* popup,
+ const QString & theContext,
+ const QString & theParent,
+ const QString & theObject )
+ {
+ return MedGUI::CustomPopup( parent, popup, theContext,
+ theParent, theObject );
+ }
+
+ void definePopup ( QString & theContext, QString & theParent, QString & theObject )
+ {
+ MedGUI::DefinePopup( theContext, theParent, theObject );
+ }
+
+ bool activeStudyChanged ( QAD_Desktop* parent )
+ {
+ MedGUI::ActiveStudyChanged( parent );
+ }
+}
--- /dev/null
+//=============================================================================
+// File : MEDGUI.h
+// Project : SALOME
+// Copyright : EDF 2001
+//=============================================================================
+
+#ifndef _MEDGUI_H_
+#define _MEDGUI_H_
+
+#include "QAD_Desktop.h"
+#include "QAD_StudyFrame.h"
+
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(Med_Gen)
+#include CORBA_CLIENT_HEADER(SMESH_Mesh)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class MedGUI: public QObject
+{
+ Q_OBJECT
+
+public:
+
+ static bool OnGUIEvent (int theCommandID, QAD_Desktop* parent);
+
+ static bool OnMousePress (QMouseEvent* pe ,
+ QAD_Desktop* parent,
+ QAD_StudyFrame* studyFrame);
+
+ static bool OnMouseMove (QMouseEvent* pe ,
+ QAD_Desktop* parent,
+ QAD_StudyFrame* studyFrame);
+
+ static bool OnKeyPress (QKeyEvent* pe,
+ QAD_Desktop* parent,
+ QAD_StudyFrame* studyFrame);
+
+ static bool SetSettings (QAD_Desktop* parent);
+
+ static bool CustomPopup ( QAD_Desktop* parent,
+ QPopupMenu* popup,
+ const QString & theContext,
+ const QString & theParent,
+ const QString & theObject);
+
+ static void DefinePopup(QString & theContext, QString & theParent, QString & theObject);
+
+ static void ActiveStudyChanged ( QAD_Desktop* parent );
+
+ static Engines::Med_Gen_ptr InitMedGen(QAD_Desktop* parent);
+
+ static bool DumpMesh( SALOME_MED::MESH_var aMesh );
+ static bool DumpSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh ) ;
+ static bool DumpSubMesh( SALOME_MED::FAMILY_var Fam ) ;
+
+ static void setOrb();
+
+protected:
+
+private:
+
+};
+
+#endif
--- /dev/null
+# This is a Qt message file in .po format. Each msgid starts with
+# a scope. This scope should *NOT* be translated - eg. translating
+# from French to English, "Foo::Bar" would be translated to "Pub",
+# not "Foo::Pub".
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2001-06-14 09:11:49 PM CEST\n"
+"PO-Revision-Date: YYYY-MM-DD\n"
+"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
--- /dev/null
+# This is a Qt message file in .po format. Each msgid starts with
+# a scope. This scope should *NOT* be translated - eg. translating
+# from French to English, "Foo::Bar" would be translated to "Pub",
+# not "Foo::Pub".
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2001-09-21 14:31:28 METDST\n"
+"PO-Revision-Date: YYYY-MM-DD\n"
+"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
+
+#: MedGUI.cxx:50
+msgid "MedGUI::MED_MEN_ALL_FILES"
+msgstr "All Files ( * )"
+
+#: MedGUI.cxx:167
+msgid "MedGUI::MED_MEN_IMPORT"
+msgstr "Import"
+
+#: MedGUI.cxx:49
+msgid "MedGUI::MED_MEN_IMPORT_MED"
+msgstr "MED Files ( *.med )"
+
+#: MedGUI.cxx:296
+msgid "MED_WRN_WARNING"
+msgstr "Warning"
+
+#: MedGUI.cxx:280
+msgid "MED_INF_NOTIMPL"
+msgstr "Not Implemented for this Object"
+
+#: MedGUI.cxx:298
+msgid "MED_BUT_OK"
+msgstr "OK"
+
+#: MedGUI.cxx:297
+msgid "MED_INF_NOIOR"
+msgstr "Object has no IOR"
+
+#: MedGUI.cxx:297
+msgid "MED_INF_MESHNAME"
+msgstr "Please enter the name of the mesh you want to read"
+
+#: MedGUI.cxx:297
+msgid "MED_INF_FIELDNAME"
+msgstr "Please enter the name of the field you want to read"
--- /dev/null
+# This is a Qt message file in .po format. Each msgid starts with
+# a scope. This scope should *NOT* be translated - eg. translating
+# from French to English, "Foo::Bar" would be translated to "Pub",
+# not "Foo::Pub".
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2001-09-21 14:31:28 METDST\n"
+"PO-Revision-Date: YYYY-MM-DD\n"
+"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
--- /dev/null
+#ifndef __MEDARRAY_H__
+#define __MEDARRAY_H__
+
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+#include "utilities.h"
+
+using namespace MED_EN;
+
+/*!
+ A template class to generate an array of any particular type (int, long,
+ float, double) for our purpose in the MED++ library.
+*/
+
+template <class T> class MEDARRAY
+// Class Template MEDARRAY
+// template to generate an array of any
+// particular type (int, long, float, double)
+// for our purpose in the MED++ library
+{
+private :
+ med_int _ld_values ; // leading dimension of value (example : space dimension with coordinates)
+ med_int _length_values ; // length of values (example : number of nodes with coordinates)
+ medModeSwitch _mode; // data access mode:
+ // MED_FULL_INTERLACE (default mode)
+ // or MED_NO_INTERLACE
+ T * _valuesDefault ; // in _mode representation
+ T * _valuesOther ; // in other _mode
+
+public :
+ MEDARRAY():_ld_values(0),_length_values(0),_mode(MED_FULL_INTERLACE),_valuesDefault((T*)NULL),_valuesOther((T*)NULL)
+ {
+ };
+
+ ~MEDARRAY()
+ {
+ if (_valuesDefault)
+ delete [] _valuesDefault ;
+ if (_valuesOther)
+ delete [] _valuesOther ;
+ };
+
+
+ // the following constructor are for the generation
+ // with the default or not _mode
+
+ MEDARRAY(const med_int ld_values, const med_int length_values,
+ const medModeSwitch mode=MED_FULL_INTERLACE) ;
+
+ MEDARRAY( T*values, const med_int ld_values,
+ const med_int length_values, const medModeSwitch mode=MED_FULL_INTERLACE) ;
+
+ inline med_int getLeadingValue() ; // as Space Dimension with coordinates
+ inline med_int getLengthValue() ; // as Number of Nodes with coordinates
+
+ T * const get(medModeSwitch mode) ;
+ T* const getI(medModeSwitch mode,med_int i) ;
+ T getIJ(med_int i, med_int j) const ;
+
+ // need by write, to get default mode !
+ inline medModeSwitch getMode() const ;
+
+ void set(medModeSwitch mode, T* value);
+ void setI(medModeSwitch mode, med_int i, T* value);
+ void setIJ(med_int i, med_int j, T value);
+
+private:
+ void calculateOther() ;
+ void allocateOther();
+ void updateDefault();
+};
+
+
+// implemented code
+
+template <class T> MEDARRAY<T>::MEDARRAY(const med_int ld_values,
+ const med_int length_values,
+ const medModeSwitch mode = MED_FULL_INTERLACE): _ld_values(ld_values),_length_values(length_values),_mode(mode),_valuesOther((T*)NULL)
+{
+ BEGIN_OF("constructor MEDARRAY<T>::MEDARRAY(const med_int , const med_int, const medModeSwitch (= MED_FULL_INTERLACE))");
+
+ // if could not allocate ?
+ if ((ld_values<1)|(length_values<1))
+ throw MEDEXCEPTION( LOCALIZED("MEDARRAY<T>::MEDARRAY(const med_int, const med_int, const medModeSwitch) : dimension < 1 !"));
+ _valuesDefault = new T[ld_values*length_values] ;
+
+ SCRUTE(_valuesDefault);
+
+ SCRUTE(_valuesOther);
+
+ SCRUTE(_ld_values);
+
+ SCRUTE(_length_values);
+
+ SCRUTE(_mode);
+
+ END_OF("constructor MEDARRAY<T>::MEDARRAY(const med_int , const med_int, const medModeSwitch (= MED_FULL_INTERLACE))");
+}
+
+template <class T> MEDARRAY<T>::MEDARRAY( T*values,
+ const med_int ld_values,
+ const med_int length_values,
+ const medModeSwitch mode=MED_FULL_INTERLACE): _ld_values(ld_values),_length_values(length_values),_mode(mode),_valuesOther((T*)NULL)
+{
+ _valuesDefault = values;
+}
+
+template <class T> inline med_int MEDARRAY<T>::getLeadingValue() {
+ return _ld_values ;
+};
+template <class T> inline med_int MEDARRAY<T>::getLengthValue() {
+ return _length_values ;
+};
+
+template <class T> T* const MEDARRAY<T>::get(medModeSwitch mode)
+{
+ if (_valuesDefault != NULL)
+ if (mode == _mode) {
+ return _valuesDefault;
+ }
+ else {
+ calculateOther() ;
+ return _valuesOther ;
+ }
+ throw MEDEXCEPTION("MEDARRAY::get(mode) : No values defined !");
+}
+
+template <class T> T* const MEDARRAY<T>::getI(medModeSwitch mode,med_int i)
+{
+ // 1<=i<=_length_values and return an array of _ld_values length
+ // if MED_FULL_INTERLACE
+ // 1<=i<=_ld_values and return an array of _length_values length
+ // if MED_NO_INTERLACE
+
+ if (_valuesDefault != NULL) {
+ // if mode = MED_FULL_INTERLACE :
+ int first = _ld_values ;
+ int second = _length_values;
+ // else :
+ if (mode == MED_NO_INTERLACE) {
+ first = _length_values ;
+ second = _ld_values ;
+ }
+ if (i<=0)
+ throw MEDEXCEPTION("MEDARRAY::getI(mode,i) : argument i must be > 0");
+ if (i>second)
+ throw MEDEXCEPTION("MEDARRAY::getI(mode,i) : argument i must be <= second");
+ if (mode == _mode)
+ return _valuesDefault + (i-1)*first ;
+ else {
+ calculateOther() ;
+ return _valuesOther + (i-1)*first ;
+ // return _valuesOther + (i-1)*second ;
+ }
+ }
+ throw MEDEXCEPTION("MEDARRAY::getI(mode,i) : No values defined !");
+}
+
+
+template <class T> T MEDARRAY<T>::getIJ(med_int i, med_int j) const
+{
+ // 1<=i<=_length_values and 1<j<_ld_values
+
+ if (i<1)
+ throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument i must be >= 1");
+ if (i>_length_values)
+ throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument i must be <= _length_values");
+
+ if (j<1)
+ throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument j must be >= 1");
+ if (j>_ld_values)
+ throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument j must be <= _ld_values");
+
+ if (_valuesDefault != NULL) {
+ switch (_mode)
+ {
+ case MED_FULL_INTERLACE :
+ {
+ return _valuesDefault[(i-1)*_ld_values+j-1];
+ }
+ case MED_NO_INTERLACE :
+ {
+ return _valuesDefault[(j-1)*_length_values+i-1];
+ }
+ }
+ } else
+ throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : No value in array !");
+}
+
+template <class T> inline medModeSwitch MEDARRAY<T>::getMode() const
+{
+ return _mode ;
+}
+
+template <class T> void MEDARRAY<T>::set(medModeSwitch mode, T* value)
+{
+
+ BEGIN_OF("MEDARRAY<T>::set(mode,i,value)");
+
+ _mode = mode ;
+
+ SCRUTE(_ld_values);
+ SCRUTE(_length_values);
+ SCRUTE(_valuesDefault);
+ SCRUTE(_valuesOther);
+ SCRUTE(_mode);
+ SCRUTE(mode);
+ SCRUTE(value);
+
+ if (_valuesDefault != NULL)
+ if (mode == _mode) {
+ _valuesDefault = value ;
+ if (_valuesOther != NULL) calculateOther() ;
+ // if (_valuesOther != NULL) _valuesOther = value;
+ }
+ else {
+ allocateOther() ;
+ _valuesOther = value ;
+ updateDefault() ;
+ }
+ else throw MEDEXCEPTION("MEDARRAY::set(mode,value) : No values defined !");
+
+ END_OF("MEDARRAY<T>::set(mode,i,value)");
+}
+
+template <class T> void MEDARRAY<T>::setI(medModeSwitch mode, med_int i, T* value)
+{
+ BEGIN_OF("MEDARRAY<T>::setI(mode,i,value)");
+
+ _mode = mode ;
+
+ SCRUTE(i);
+ SCRUTE(_ld_values);
+ SCRUTE(_length_values);
+ SCRUTE(_valuesDefault);
+ SCRUTE(_valuesOther);
+ SCRUTE(_mode);
+ SCRUTE(mode);
+
+ // 1<=i<=_length_values and return an array of _ld_values length
+ // if MED_FULL_INTERLACE
+ // 1<=i<=_ld_values and return an array of _length_values length
+ // if MED_NO_INTERLACE
+
+ if (_valuesDefault != NULL) {
+ // if mode = MED_FULL_INTERLACE :
+ int first = _ld_values ;
+ int second = _length_values;
+ // else :
+ if (mode == MED_NO_INTERLACE) {
+ first = _length_values ;
+ second = _ld_values ;
+ }
+ SCRUTE(second);
+ if (i<=0)
+ throw MEDEXCEPTION("MEDARRAY::setI(mode,i,value) : argument i must be > 0");
+ if (i>second) {
+ SCRUTE(i);
+ SCRUTE(second);
+ throw MEDEXCEPTION("MEDARRAY::setI(mode,i,value) : argument i must be <= second");}
+ if (mode == _mode)
+ {
+ // _valuesDefault + (i-1)*first = value ;
+ for (int k =0;k<first;k++)
+ // _valuesDefault[(i-1)*second+k] = value[k];
+ (_valuesDefault + (i-1)*first)[k] = value[k];
+ if (_valuesOther != NULL)
+ for (int k =0;k<first;k++) {
+ _valuesOther[k*second+i-1] = value[k];
+ }
+ }
+ else
+ {
+ allocateOther() ;
+ // return _valuesOther + (i-1)*first = &value ;
+ for (int k =0;k<second;k++) {
+ _valuesOther[(i-1)*first+k-1] = value[k];
+ _valuesDefault[k*second+i-1] = value[k];
+ }
+ }
+ }
+ else throw MEDEXCEPTION("MEDARRAY::setI(mode,i,value) : No values defined !");
+
+ SCRUTE(_valuesDefault);
+ SCRUTE( _valuesOther);
+
+ END_OF("MEDARRAY::setI(mode,i,value)");
+}
+
+template <class T> void MEDARRAY<T>::setIJ(med_int i, med_int j, T value)
+{
+ // 1<=i<=_length_values and 1<j<_ld_values
+
+ if (i<1)
+ throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument i must be >= 1");
+ if (i>_length_values)
+ throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument i must be <= _length_values");
+
+ if (j<1)
+ throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument j must be >= 1");
+ if (j>_ld_values)
+ throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument j must be <= _ld_values");
+
+ if (_valuesDefault != NULL) {
+ switch (_mode)
+ {
+ case MED_FULL_INTERLACE :
+ {
+ _valuesDefault[(i-1)*_ld_values+j-1] = value;
+ break;
+ }
+ case MED_NO_INTERLACE :
+ {
+ _valuesDefault[(j-1)*_length_values+i-1] = value;
+ break;
+ }
+ }
+ } else
+ throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : No value in array !");
+}
+
+template <class T> void MEDARRAY<T>::calculateOther()
+{
+ if (_valuesDefault != NULL) {
+ //we allocate _valuesOther if needed
+ if (_valuesOther == NULL) _valuesOther = new T[_ld_values*_length_values] ;
+ // we set _valuesOther
+ // if mode = MED_FULL_INTERLACE :
+ int first = _ld_values ;
+ int second = _length_values;
+ // else :
+ if (_mode == MED_NO_INTERLACE) {
+ first = _length_values ;
+ second = _ld_values;
+ }
+
+ for (int i=0; i<first;i++)
+ for (int j=0; j<second; j++)
+ _valuesOther[i*second+j] = _valuesDefault[j*first+i];
+ }
+ else
+ throw MEDEXCEPTION("MEDARRAY::calculateOther() : No values defined !");
+}
+
+template <class T> void MEDARRAY<T>::allocateOther()
+{
+ if (_valuesDefault != NULL) {
+ if (_valuesOther == NULL) {
+ // we set _valuesOther
+ _valuesOther = new T[_ld_values*_length_values] ;
+ }
+ }
+ else
+ throw MEDEXCEPTION("MEDARRAY::allocateOther() : No values defined !");
+}
+
+template <class T> void MEDARRAY<T>::updateDefault()
+{
+ BEGIN_OF("MEDARRAY<T>::updateDefault()");
+
+ if (_valuesDefault != NULL) {
+ if (_valuesOther != NULL) {
+ // we update _valuesDefault with _valuesOther
+ // if mode = MED_FULL_INTERLACE :
+ int first = _ld_values ;
+ int second = _length_values;
+ // else :
+ if (_mode == MED_NO_INTERLACE) {
+ first = _length_values ;
+ second = _ld_values;
+ }
+ for (int i=0; i<first;i++)
+ for (int j=0; j<second; j++)
+ _valuesDefault[j*first+i] = _valuesOther[i*second+j];
+ }
+ else
+ throw MEDEXCEPTION("MEDARRAY<T>::updateDefault() : No valuesOther defined !");
+ }
+ else
+ throw MEDEXCEPTION("MEDARRAY<T>::updateDefault() : No values defined !");
+
+ END_OF("MEDARRAY<T>::updateDefault()");
+}
+
+# endif /* # ifndef __MEDARRAY_H__ */
--- /dev/null
+/*
+ File MEDMEM_CellModel.cxx
+ $Header$
+*/
+
+#include "utilities.h"
+#include "MEDMEM_CellModel.hxx"
+
+CELLMODEL::CELLMODEL(medGeometryElement t)
+{
+ MESSAGE("CELLMODEL : constructeur pour le type " << t);
+ switch (t)
+ {
+ case MED_POINT1 : {
+ _name="MED_POINT1";
+ _type=t;
+ _dimension=0;
+ _numberOfVertexes=1;
+ _numberOfNodes=1;
+ // nothing else : POINT are none constituent
+ break;
+ }
+ case MED_SEG2 : {
+ _name="MED_SEG2" ;
+ _type=t;
+ _dimension=1;
+ _numberOfVertexes=2;
+ _numberOfNodes=2;
+ // constituent are POINT1 and we have no need to define _constituents vector
+ vector<medGeometryElement> vector_type(2,MED_POINT1) ;
+ vector<medGeometryElement> __constituents_type[]={vector_type};
+ vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+1) ;
+ _constituentsType = _constituents_type ;
+ break;
+ }
+ case MED_SEG3 : {
+ _name="MED_SEG3" ;
+ _type=t;
+ _dimension=1;
+ _numberOfVertexes=2;
+ _numberOfNodes=3;
+ // constituent are POINT1 and we have no need to define _constituents vector
+ vector<medGeometryElement> vector_type(3,MED_POINT1) ;
+ vector<medGeometryElement> __constituents_type[]={vector_type};
+ vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+1) ;
+ _constituentsType = _constituents_type ;
+ break;
+ }
+ case MED_TRIA3 : {
+ _name="MED_TRIA3" ;
+ _type=t;
+ _dimension=2;
+ _numberOfVertexes=3;
+ _numberOfNodes=3;
+ int _edge1[]={1,2} ;
+ int _edge2[]={2,3} ;
+ int _edge3[]={3,1} ;
+ vector<int> edge1(_edge1,_edge1+2) ;
+ vector<int> edge2(_edge2,_edge2+2) ;
+ vector<int> edge3(_edge3,_edge3+2) ;
+ vector<int> _vector_edge[]={edge1,edge2,edge3};
+ vector< vector<int> > vector_edge(_vector_edge,_vector_edge+3) ;
+ vector< vector<int> > __constituents__[]={vector_edge};
+ vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+1) ;
+ _constituents = _constituents_ ;
+ vector<medGeometryElement> vector_edge_type(3,MED_SEG2) ;
+ vector<medGeometryElement> vector_type(3,MED_POINT1) ;
+ vector<medGeometryElement> __constituents_type[]={vector_edge_type,vector_type};
+ vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
+ _constituentsType = _constituents_type ;
+ break;
+ }
+ case MED_TRIA6 : {
+ _name="MED_TRIA6" ;
+ _type=t;
+ _dimension=2;
+ _numberOfVertexes=3;
+ _numberOfNodes=6;
+ int _edge1[]={1,2,4} ;
+ int _edge2[]={2,3,5} ;
+ int _edge3[]={3,1,6} ;
+ vector<int> edge1(_edge1,_edge1+3) ;
+ vector<int> edge2(_edge2,_edge2+3) ;
+ vector<int> edge3(_edge3,_edge3+3) ;
+ vector<int> _vector_edge[]={edge1,edge2,edge3};
+ vector< vector<int> > vector_edge(_vector_edge,_vector_edge+3) ;
+ vector< vector<int> > __constituents__[]={vector_edge};
+ vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+1) ;
+ _constituents = _constituents_ ;
+ vector<medGeometryElement> vector_edge_type(3,MED_SEG3) ;
+ vector<medGeometryElement> vector_type(6,MED_POINT1) ;
+ vector<medGeometryElement> __constituents_type[]={vector_edge_type,vector_type};
+ vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
+ _constituentsType = _constituents_type ;
+ break;
+ }
+ case MED_QUAD4 : {
+ _name="MED_QUAD4" ;
+ _type=t;
+ _dimension=2;
+ _numberOfVertexes=4;
+ _numberOfNodes=4;
+ int _edge1[]={1,2} ;
+ int _edge2[]={2,3} ;
+ int _edge3[]={3,4} ;
+ int _edge4[]={4,1} ;
+ vector<int> edge1(_edge1,_edge1+2) ;
+ vector<int> edge2(_edge2,_edge2+2) ;
+ vector<int> edge3(_edge3,_edge3+2) ;
+ vector<int> edge4(_edge4,_edge4+2) ;
+ vector<int> _vector_edge[]={edge1,edge2,edge3,edge4};
+ vector< vector<int> > vector_edge(_vector_edge,_vector_edge+4) ;
+ vector< vector<int> > __constituents__[]={vector_edge};
+ vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+1) ;
+ _constituents = _constituents_ ;
+ vector<medGeometryElement> vector_edge_type(4,MED_SEG2) ;
+ vector<medGeometryElement> vector_type(4,MED_POINT1) ;
+ vector<medGeometryElement> __constituents_type[]={vector_edge_type,vector_type};
+ vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
+ _constituentsType = _constituents_type ;
+ break;
+ }
+ case MED_QUAD8 : {
+ _name="MED_QUAD8" ;
+ _type=t;
+ _dimension=2;
+ _numberOfVertexes=4;
+ _numberOfNodes=8;
+ int _edge1[]={1,2,5} ;
+ int _edge2[]={2,3,6} ;
+ int _edge3[]={3,4,7} ;
+ int _edge4[]={4,1,8} ;
+ vector<int> edge1(_edge1,_edge1+3) ;
+ vector<int> edge2(_edge2,_edge2+3) ;
+ vector<int> edge3(_edge3,_edge3+3) ;
+ vector<int> edge4(_edge4,_edge4+3) ;
+ vector<int> _vector_edge[]={edge1,edge2,edge3,edge4};
+ vector< vector<int> > vector_edge(_vector_edge,_vector_edge+4) ;
+ vector< vector<int> > __constituents__[]={vector_edge};
+ vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+1) ;
+ _constituents = _constituents_ ;
+ vector<medGeometryElement> vector_edge_type(4,MED_SEG3) ;
+ vector<medGeometryElement> vector_type(8,MED_POINT1) ;
+ vector<medGeometryElement> __constituents_type[]={vector_edge_type,vector_type};
+ vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
+ _constituentsType = _constituents_type ;
+ break;
+ }
+ case MED_TETRA4 : {
+ _name="MED_TETRA4" ;
+ _type=t;
+ _dimension=3;
+ _numberOfVertexes=4;
+ _numberOfNodes=4;
+ int _edge1[]={1,2} ;
+ int _edge2[]={2,3} ;
+ int _edge3[]={3,1} ;
+ int _edge4[]={1,4} ;
+ int _edge5[]={2,4} ;
+ int _edge6[]={3,4} ;
+ vector<int> edge1(_edge1,_edge1+2) ;
+ vector<int> edge2(_edge2,_edge2+2) ;
+ vector<int> edge3(_edge3,_edge3+2) ;
+ vector<int> edge4(_edge4,_edge4+2) ;
+ vector<int> edge5(_edge5,_edge5+2) ;
+ vector<int> edge6(_edge6,_edge6+2) ;
+ vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6};
+ vector< vector<int> > vector_edge(_vector_edge,_vector_edge+6) ;
+ int _face1[]={1,2,3} ;
+ int _face2[]={1,4,2} ;
+ int _face3[]={2,4,3} ;
+ int _face4[]={3,4,1} ;
+ vector<int> face1(_face1,_face1+3) ;
+ vector<int> face2(_face2,_face2+3) ;
+ vector<int> face3(_face3,_face3+3) ;
+ vector<int> face4(_face4,_face4+3) ;
+ vector<int> _vector_face[] = {face1,face2,face3,face4} ;
+ vector< vector<int> > vector_face(_vector_face,_vector_face+4) ;
+ vector< vector<int> > __constituents__[]={vector_face,vector_edge};
+ vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
+ _constituents = _constituents_ ;
+ vector<medGeometryElement> vector_edge_type(6,MED_SEG2) ;
+ vector<medGeometryElement> vector_face_type(4,MED_TRIA3) ;
+ vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
+ vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
+ _constituentsType = _constituents_type ;
+ break;
+ }
+ case MED_TETRA10 : {
+ _name="MED_TETRA10" ;
+ _type=t;
+ _dimension=3;
+ _numberOfVertexes=4;
+ _numberOfNodes=10;
+ int _edge1[]={1,2,5} ;
+ int _edge2[]={2,3,6} ;
+ int _edge3[]={3,1,7} ;
+ int _edge4[]={1,4,8} ;
+ int _edge5[]={2,4,9} ;
+ int _edge6[]={3,4,10} ;
+ vector<int> edge1(_edge1,_edge1+3) ;
+ vector<int> edge2(_edge2,_edge2+3) ;
+ vector<int> edge3(_edge3,_edge3+3) ;
+ vector<int> edge4(_edge4,_edge4+3) ;
+ vector<int> edge5(_edge5,_edge5+3) ;
+ vector<int> edge6(_edge6,_edge6+3) ;
+ vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6};
+ vector< vector<int> > vector_edge(_vector_edge,_vector_edge+6) ;
+ int _face1[]={1,2,3,5,6,7} ;
+ int _face2[]={1,4,2,8,9,5} ;
+ int _face3[]={2,4,3,9,10,6} ;
+ int _face4[]={3,4,1,10,8,7} ;
+ vector<int> face1(_face1,_face1+6) ;
+ vector<int> face2(_face2,_face2+6) ;
+ vector<int> face3(_face3,_face3+6) ;
+ vector<int> face4(_face4,_face4+6) ;
+ vector<int> _vector_face[] = {face1,face2,face3,face4} ;
+ vector< vector<int> > vector_face(_vector_face,_vector_face+4) ;
+ vector< vector<int> > __constituents__[]={vector_face,vector_edge};
+ vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
+ _constituents = _constituents_ ;
+ vector<medGeometryElement> vector_edge_type(6,MED_SEG3) ;
+ vector<medGeometryElement> vector_face_type(4,MED_TRIA6) ;
+ vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
+ vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
+ _constituentsType = _constituents_type ;
+ break;
+ }
+ case MED_HEXA8 : {
+ _name="MED_HEXA8" ;
+ _type=t;
+ _dimension=3;
+ _numberOfVertexes=8;
+ _numberOfNodes=8;
+ int _edge1[]={1,2} ;
+ int _edge2[]={2,3} ;
+ int _edge3[]={3,4} ;
+ int _edge4[]={4,1} ;
+ int _edge5[]={5,6} ;
+ int _edge6[]={6,7} ;
+ int _edge7[]={7,8} ;
+ int _edge8[]={8,5} ;
+ int _edge9[]={1,5} ;
+ int _edge10[]={2,6} ;
+ int _edge11[]={3,7} ;
+ int _edge12[]={4,8} ;
+ vector<int> edge1(_edge1,_edge1+2) ;
+ vector<int> edge2(_edge2,_edge2+2) ;
+ vector<int> edge3(_edge3,_edge3+2) ;
+ vector<int> edge4(_edge4,_edge4+2) ;
+ vector<int> edge5(_edge5,_edge5+2) ;
+ vector<int> edge6(_edge6,_edge6+2) ;
+ vector<int> edge7(_edge7,_edge7+2) ;
+ vector<int> edge8(_edge8,_edge8+2) ;
+ vector<int> edge9(_edge9,_edge9+2) ;
+ vector<int> edge10(_edge10,_edge10+2) ;
+ vector<int> edge11(_edge11,_edge11+2) ;
+ vector<int> edge12(_edge12,_edge12+2) ;
+ vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9,edge10,edge11,edge12};
+ vector< vector<int> > vector_edge(_vector_edge,_vector_edge+12) ;
+ int _face1[]={1,2,3,4} ;
+ int _face2[]={5,8,7,6} ;
+ int _face3[]={1,5,6,2} ;
+ int _face4[]={2,6,7,3} ;
+ int _face5[]={3,7,8,4} ;
+ int _face6[]={4,8,5,1} ;
+ vector<int> face1(_face1,_face1+4) ;
+ vector<int> face2(_face2,_face2+4) ;
+ vector<int> face3(_face3,_face3+4) ;
+ vector<int> face4(_face4,_face4+4) ;
+ vector<int> face5(_face5,_face5+4) ;
+ vector<int> face6(_face6,_face6+4) ;
+ vector<int> _vector_face[] = {face1,face2,face3,face4,face5,face6} ;
+ vector< vector<int> > vector_face(_vector_face,_vector_face+6) ;
+ vector< vector<int> > __constituents__[]={vector_face,vector_edge};
+ vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
+ _constituents = _constituents_ ;
+ vector<medGeometryElement> vector_edge_type(12,MED_SEG2) ;
+ vector<medGeometryElement> vector_face_type(6,MED_QUAD4) ;
+ vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
+ vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2);
+ _constituentsType = _constituents_type ;
+ break;
+ }
+ case MED_HEXA20 : {
+ _name="MED_HEXA20" ;
+ _type=t;
+ _dimension=3;
+ _numberOfVertexes=8;
+ _numberOfNodes=20;
+
+ int _edge1[]={1,2,9} ;
+ int _edge2[]={2,3,10} ;
+ int _edge3[]={3,4,11} ;
+ int _edge4[]={4,1,12} ;
+ int _edge5[]={5,6,13} ;
+ int _edge6[]={6,7,14};
+ int _edge7[]={7,8,15} ;
+ int _edge8[]={8,5,16} ;
+ int _edge9[]={1,5,17} ;
+ int _edge10[]={2,6,18} ;
+ int _edge11[]={3,7,19} ;
+ int _edge12[]={4,8,20} ;
+
+ vector<int> edge1(_edge1,_edge1+3) ;
+ vector<int> edge2(_edge2,_edge2+3) ;
+ vector<int> edge3(_edge3,_edge3+3) ;
+ vector<int> edge4(_edge4,_edge4+3) ;
+ vector<int> edge5(_edge5,_edge5+3) ;
+ vector<int> edge6(_edge6,_edge6+3) ;
+ vector<int> edge7(_edge7,_edge7+3) ;
+ vector<int> edge8(_edge8,_edge8+3) ;
+ vector<int> edge9(_edge9,_edge9+3) ;
+ vector<int> edge10(_edge10,_edge10+3) ;
+ vector<int> edge11(_edge11,_edge11+3) ;
+ vector<int> edge12(_edge12,_edge12+3) ;
+ vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9,edge10, edge11,edge12};
+ vector< vector<int> > vector_edge(_vector_edge,_vector_edge+12) ;
+
+ int _face1[]={1,2,3,4,9,10,11,12} ;
+ int _face2[]={5,8,7,6,16,15,14,13} ;
+ int _face3[]={1,5,6,2,17,13,18,9} ;
+ int _face4[]={2,6,7,3,18,14,19,10} ;
+ int _face5[]={3,7,8,4,19,15,20,11} ;
+ int _face6[]={4,8,5,1,20,16,17,12} ;
+ vector<int> face1(_face1,_face1+8);
+ vector<int> face2(_face2,_face2+8);
+ vector<int> face3(_face3,_face3+8);
+ vector<int> face4(_face4,_face4+8);
+ vector<int> face5(_face5,_face5+8);
+ vector<int> face6(_face6,_face6+8);
+ vector<int> _vector_face[]= {face1,face2,face3,face4,face5,face6} ;
+ vector< vector<int> > vector_face(_vector_face,_vector_face+6);
+
+ vector< vector<int> > __constituents__[]={vector_face,vector_edge};
+ vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
+ _constituents = _constituents_ ;
+ vector<medGeometryElement> vector_edge_type(12,MED_SEG3) ;
+ vector<medGeometryElement> vector_face_type(6,MED_QUAD8) ;
+ vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
+ vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
+ _constituentsType = _constituents_type ;
+ break;
+ }
+ case MED_PENTA6 : {
+ _name="MED_PENTA6" ;
+ _type=t;
+ _dimension=3;
+ _numberOfVertexes=6;
+ _numberOfNodes=6;
+
+ int _edge1[]= {1,2} ;
+ int _edge2[]= {2,3} ;
+ int _edge3[]= {3,1} ;
+ int _edge4[]= {4,5} ;
+ int _edge5[]= {5,6} ;
+ int _edge6[]= {6,4} ;
+ int _edge7[]= {1,4} ;
+ int _edge8[]= {2,5} ;
+ int _edge9[]= {3,6} ;
+
+ vector<int> edge1(_edge1,_edge1+2) ;
+ vector<int> edge2(_edge2,_edge2+2) ;
+ vector<int> edge3(_edge3,_edge3+2) ;
+ vector<int> edge4(_edge4,_edge4+2) ;
+ vector<int> edge5(_edge5,_edge5+2) ;
+ vector<int> edge6(_edge6,_edge6+2) ;
+ vector<int> edge7(_edge7,_edge7+2) ;
+ vector<int> edge8(_edge8,_edge8+2) ;
+ vector<int> edge9(_edge9,_edge9+2) ;
+ vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9};
+ vector< vector<int> > vector_edge(_vector_edge,_vector_edge+9) ;
+
+ int _face1[]={1,2,3};
+ int _face2[]={4,6,5};
+ int _face3[]={1,4,5,2};
+ int _face4[]={2,5,6,3};
+ int _face5[]={3,6,4,1};
+ vector<int> face1(_face1,_face1+3);
+ vector<int> face2(_face2,_face2+3);
+ vector<int> face3(_face3,_face3+4);
+ vector<int> face4(_face4,_face4+4);
+ vector<int> face5(_face5,_face5+4);
+ vector<int> _vector_face[]= {face1,face2,face3,face4,face5} ;
+ vector< vector<int> > vector_face(_vector_face,_vector_face+5);
+
+ vector< vector<int> > __constituents__[]={vector_face,vector_edge};
+ vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
+ _constituents = _constituents_ ;
+ vector<medGeometryElement> vector_edge_type(9,MED_SEG2) ;
+ vector<medGeometryElement> vector_face_type(5,MED_QUAD4) ;
+ vector_face_type[0]=MED_TRIA3 ;
+ vector_face_type[1]=MED_TRIA3 ;
+ vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
+ vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
+ _constituentsType = _constituents_type ;
+ break;
+ }
+ case MED_PENTA15 : {
+ _name="MED_PENTA15" ;
+ _type=t;
+ _dimension=3;
+ _numberOfVertexes=6;
+ _numberOfNodes=15;
+ int _edge1[]={1,2,7} ;
+ int _edge2[]={2,3,8} ;
+ int _edge3[]={3,1,9} ;
+ int _edge4[]={4,5,10} ;
+ int _edge5[]={5,6,11} ;
+ int _edge6[]={6,4,12} ;
+ int _edge7[]={1,4,13} ;
+ int _edge8[]={2,5,14} ;
+ int _edge9[]={3,6,15} ;
+
+ vector<int> edge1(_edge1,_edge1+3) ;
+ vector<int> edge2(_edge2,_edge2+3) ;
+ vector<int> edge3(_edge3,_edge3+3) ;
+ vector<int> edge4(_edge4,_edge4+3) ;
+ vector<int> edge5(_edge5,_edge5+3) ;
+ vector<int> edge6(_edge6,_edge6+3) ;
+ vector<int> edge7(_edge7,_edge7+3) ;
+ vector<int> edge8(_edge8,_edge8+3) ;
+ vector<int> edge9(_edge9,_edge9+3) ;
+ vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9};
+ vector< vector<int> > vector_edge(_vector_edge,_vector_edge+9) ;
+
+ int _face1[]={1,2,3,7,8,9};
+ int _face2[]={4,6,5,12,11,10};
+ int _face3[]={1,4,5,2,13,10,14,7};
+ int _face4[]={2,5,6,3,14,11,15,8};
+ int _face5[]={3,6,4,1,15,12,13,9};
+ vector<int> face1(_face1,_face1+6);
+ vector<int> face2(_face2,_face2+6);
+ vector<int> face3(_face3,_face3+8);
+ vector<int> face4(_face4,_face4+8);
+ vector<int> face5(_face5,_face5+8);
+ vector<int> _vector_face[]= {face1,face2,face3,face4,face5} ;
+ vector< vector<int> > vector_face(_vector_face,_vector_face+5);
+
+ vector< vector<int> > __constituents__[]={vector_face,vector_edge};
+ vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
+ _constituents = _constituents_ ;
+ vector<medGeometryElement> vector_edge_type(9,MED_SEG3) ;
+ vector<medGeometryElement> vector_face_type(5,MED_QUAD8) ;
+ vector_face_type[0]=MED_TRIA6 ;
+ vector_face_type[1]=MED_TRIA6 ;
+ vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
+ vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
+ _constituentsType = _constituents_type ;
+ break;
+ }
+ case MED_PYRA5 : {
+ _name="MED_PYRA5" ;
+ _type=t;
+ _dimension=3;
+ _numberOfVertexes=5;
+ _numberOfNodes=5;
+ int _edge1[]={1,2} ;
+ int _edge2[]={2,3} ;
+ int _edge3[]={3,4} ;
+ int _edge4[]={4,1} ;
+ int _edge5[]={1,5} ;
+ int _edge6[]={2,5} ;
+ int _edge7[]={3,5} ;
+ int _edge8[]={4,5} ;
+
+ vector<int> edge1(_edge1,_edge1+2) ;
+ vector<int> edge2(_edge2,_edge2+2) ;
+ vector<int> edge3(_edge3,_edge3+2) ;
+ vector<int> edge4(_edge4,_edge4+2) ;
+ vector<int> edge5(_edge5,_edge5+2) ;
+ vector<int> edge6(_edge6,_edge6+2) ;
+ vector<int> edge7(_edge7,_edge7+2) ;
+ vector<int> edge8(_edge8,_edge8+2) ;
+ vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8};
+ vector< vector<int> > vector_edge(_vector_edge,_vector_edge+8) ;
+
+ int _face1[]={1,2,3,4} ;
+ int _face2[]={1,5,2} ;
+ int _face3[]={2,5,3} ;
+ int _face4[]={3,5,4} ;
+ int _face5[]={4,5,1} ;
+ vector<int> face1(_face1,_face1+4);
+ vector<int> face2(_face2,_face2+3);
+ vector<int> face3(_face3,_face3+3);
+ vector<int> face4(_face4,_face4+3);
+ vector<int> face5(_face5,_face5+3);
+ vector<int> _vector_face[]= {face1,face2,face3,face4,face5} ;
+ vector< vector<int> > vector_face(_vector_face,_vector_face+5);
+
+ vector< vector<int> > __constituents__[]={vector_face,vector_edge};
+ vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
+ _constituents = _constituents_ ;
+ vector<medGeometryElement> vector_edge_type(8,MED_SEG2) ;
+ vector<medGeometryElement> vector_face_type(5,MED_TRIA3) ;
+ vector_face_type[0]=MED_QUAD4 ;
+ vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
+ vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
+ _constituentsType = _constituents_type ;
+ break;
+ }
+ case MED_PYRA13 : {
+ _name="MED_PYRA13" ;
+ _type=t;
+ _dimension=3;
+ _numberOfVertexes=5;
+ _numberOfNodes=13;
+ int _edge1[]={1,2,6} ;
+ int _edge2[]={2,3,7} ;
+ int _edge3[]={3,4,8} ;
+ int _edge4[]={4,1,9} ;
+ int _edge5[]={1,5,10} ;
+ int _edge6[]={2,5,11} ;
+ int _edge7[]={3,5,12} ;
+ int _edge8[]={4,5,13} ;
+
+ vector<int> edge1(_edge1,_edge1+3) ;
+ vector<int> edge2(_edge2,_edge2+3) ;
+ vector<int> edge3(_edge3,_edge3+3) ;
+ vector<int> edge4(_edge4,_edge4+3) ;
+ vector<int> edge5(_edge5,_edge5+3) ;
+ vector<int> edge6(_edge6,_edge6+3) ;
+ vector<int> edge7(_edge7,_edge7+3) ;
+ vector<int> edge8(_edge8,_edge8+3) ;
+
+
+ vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8};
+ vector< vector<int> > vector_edge(_vector_edge,_vector_edge+8) ;
+
+ int _face1[]={1,2,3,4,6,7,8,9} ;
+ int _face2[]={1,5,2,10,11,6} ;
+ int _face3[]={2,5,3,11,12,7} ;
+ int _face4[]={3,5,4,12,13,8} ;
+ int _face5[]={4,5,1,13,10,9} ;
+ vector<int> face1(_face1,_face1+8);
+ vector<int> face2(_face2,_face2+6);
+ vector<int> face3(_face3,_face3+6);
+ vector<int> face4(_face4,_face4+6);
+ vector<int> face5(_face5,_face5+6);
+ vector<int> _vector_face[]= {face1,face2,face3,face4,face5} ;
+ vector< vector<int> > vector_face(_vector_face,_vector_face+5);
+
+
+ vector< vector<int> > __constituents__[]={vector_face,vector_edge};
+ vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
+ _constituents = _constituents_ ;
+ vector<medGeometryElement> vector_edge_type(8,MED_SEG3) ;
+ vector<medGeometryElement> vector_face_type(5,MED_TRIA6) ;
+ vector_face_type[0]=MED_QUAD8 ;
+ vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
+ vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
+
+ _constituentsType = _constituents_type ;
+ break;
+ }
+// default :
+// _type=0;
+// break;
+ }
+}
+
+ostream & operator<<(ostream &os,const CELLMODEL &my)
+{
+ os << "Cell Model :" << endl ;
+ os << " - name : " << my._name << endl;
+ os << " - type : " << (int)my._type << endl;
+ os << " - dimension : " << my._dimension << endl;
+ os << " - number of nodes : " << my._numberOfNodes << endl ;
+ os << " - number of vertexes : " << my._numberOfVertexes << endl ;
+ for(int i=0;i<my._constituents.size();i++)
+ {
+ os << " - for dimension (-" << i+1 << ") : " << endl ;
+ for(int j=0;j<my._constituents[i].size();j++)
+ {
+ os << " - constituents " << j+1 << " of type "<< my._constituentsType[i][j] <<" : " ;
+ for(int k=0;k<my._constituents[i][j].size();k++)
+ os << my._constituents[i][j][k] << " " ;
+ os << endl ;
+ }
+ }
+ return os;
+}
+
+
+
+ // Return number of constituents type (which dimension is _dimension-1).
+int CELLMODEL::getNumberOfConstituentsType() const
+{
+ set<medGeometryElement> constituentsTypes ;
+ if (_constituentsType.size() > 0 ) {
+ vector<medGeometryElement> constituentsType = _constituentsType[0] ;
+ vector<medGeometryElement>::iterator itvec ;
+ for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++)
+ constituentsTypes.insert(*itvec);
+ }
+ return constituentsTypes.size() ;
+}
+
+ // Return all types of constituents which dimension is (_dimension-1).
+set <medGeometryElement> CELLMODEL::getAllConstituentsType() const
+{
+ set<medGeometryElement> constituentsTypes ;
+ if (_constituentsType.size() > 0 ) {
+ vector<medGeometryElement> constituentsType = _constituentsType[0] ;
+ vector<medGeometryElement>::iterator itvec ;
+ for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++)
+ constituentsTypes.insert(*itvec);
+ }
+ return constituentsTypes ;
+}
+
+ // Return number of constituents foreach type (which dimension is _dimension-1).
+map <medGeometryElement,int> CELLMODEL::getNumberOfConstituentsForeachType() const
+{
+ map<medGeometryElement,int> numberOfConstituentsForeachType ;
+ map<medGeometryElement,int>::iterator itmap ;
+ if (_constituentsType.size() > 0 ) {
+ vector<medGeometryElement> constituentsType = _constituentsType[0] ;
+ vector<medGeometryElement>::iterator itvec ;
+ for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++) {
+ itmap = numberOfConstituentsForeachType.find(*itvec);
+ if (itmap==numberOfConstituentsForeachType.end()) // new element
+ numberOfConstituentsForeachType[*itvec]=1 ;
+ else
+ numberOfConstituentsForeachType[*itvec]++ ;
+ }
+ }
+ return numberOfConstituentsForeachType ;
+}
--- /dev/null
+/*
+ File CellModel.hxx
+ $Header$
+*/
+
+#ifndef CELLMODEL_HXX
+#define CELLMODEL_HXX
+
+#include <vector>
+#include <set>
+#include <map>
+#include <string>
+
+#include "MEDMEM_define.hxx"
+
+using namespace MED_EN;
+
+class CELLMODEL
+{
+
+protected :
+
+ string _name ;
+ medGeometryElement _type ;
+ int _dimension ; // Cell _dimension (!= space _dimension)
+ int _numberOfNodes ;
+ int _numberOfVertexes ;
+ vector< vector< vector<int> > > _constituents ;
+ // define local connectivity for each constituents
+ // composing it (
+ // first vector : for each cell _dimension
+ // (first : dim-1, second if any : dim-2)
+ // second vector : for each constituents of this _dimension,
+ // third vector : list of local nodes
+ vector< vector<medGeometryElement> > _constituentsType ;
+
+public :
+
+ CELLMODEL(){
+ _type=MED_NONE ;
+ _dimension = 0 ;
+ _numberOfNodes = 0 ;
+ _numberOfVertexes = 0 ;
+ }
+ CELLMODEL(medGeometryElement t) ;
+ CELLMODEL(const CELLMODEL &m){
+ _name= m._name ;
+ _type= m._type ;
+ _dimension = m._dimension ;
+ _numberOfNodes = m._numberOfNodes ;
+ _numberOfVertexes = m._numberOfVertexes ;
+ _constituents = m._constituents ;
+ _constituentsType = m._constituentsType ;
+ }
+ ~CELLMODEL() {
+ };
+
+ CELLMODEL & operator=(const CELLMODEL &m) {
+ _name=m._name ;
+ _type= m._type ;
+ _dimension = m._dimension ;
+ _numberOfNodes = m._numberOfNodes ;
+ _numberOfVertexes = m._numberOfVertexes ;
+ _constituents = m._constituents ;
+ _constituentsType = m._constituentsType ;
+ return *this ;
+ }
+ friend ostream & operator<<(ostream &os,const CELLMODEL &my);
+
+ inline string getName() const ;
+ inline int getNumberOfVertexes() const;
+ inline int getNumberOfNodes() const;
+ inline int getDimension() const;
+ inline medGeometryElement getType() const;
+
+ // Return all constituents which dimension is _dimension-dim.
+ vector< vector<int> > getConstituents(int dim) const;
+
+ // Return number of constituents which dimension is _dimension-dim.
+ int getNumberOfConstituents(int dim) const;
+
+ // Return local nodes numbers vector for num-th constituent which dimension is _dimension-dim.
+ vector<int> getNodesConstituent(int dim,int num) const;
+
+ // Return local node number of nodes_index-th node for num-th constituent which dimension is _dimension-dim.
+ int getNodeConstituent(int dim,int num,int nodes_index);
+
+ // Return types of each constituents which dimension is _dimension-dim.
+ vector <medGeometryElement> getConstituentsType(int dim) const;
+
+ // Return type of num-th constituent which dimension is _dimension-dim.
+ medGeometryElement getConstituentType(int dim,int num) const;
+
+
+ // Return number of constituents type (which dimension is _dimension-1).
+ int getNumberOfConstituentsType() const;
+
+ // Return all types of constituents which dimension is (_dimension-1).
+ set <medGeometryElement> getAllConstituentsType() const;
+
+ // Return number of constituents foreach type (which dimension is _dimension-1).
+ map <medGeometryElement,int> getNumberOfConstituentsForeachType() const;
+
+
+};
+
+// ------------------------------------------
+// Methodes Inline
+// ------------------------------------------
+
+inline string CELLMODEL::getName() const
+{
+ return _name ;
+}
+inline int CELLMODEL::getNumberOfVertexes() const
+{
+ return _numberOfVertexes;
+}
+inline int CELLMODEL::getNumberOfNodes() const
+{
+ return _numberOfNodes;
+}
+inline int CELLMODEL::getDimension() const
+{
+ return _dimension;
+}
+inline medGeometryElement CELLMODEL::getType() const
+{
+ return _type;
+}
+inline vector< vector<int> > CELLMODEL::getConstituents(int dim) const
+{
+ return _constituents[dim-1] ;
+}
+inline int CELLMODEL::getNumberOfConstituents(int dim) const
+{
+ return _constituents[dim-1].size() ;
+}
+inline vector<int> CELLMODEL::getNodesConstituent(int dim,int num) const
+{
+ return _constituents[dim-1][num-1];
+}
+inline int CELLMODEL::getNodeConstituent(int dim,int num,int nodesNumber)
+{
+ return _constituents[dim-1][num-1][nodesNumber-1] ;
+}
+inline vector<medGeometryElement> CELLMODEL::getConstituentsType(int dim) const
+{
+ return _constituentsType[dim-1];
+}
+inline medGeometryElement CELLMODEL::getConstituentType(int dim,int num) const
+{
+ return _constituentsType[dim-1][num-1];
+}
+
+#endif /* CELLMODEL_HXX */
--- /dev/null
+#include "MEDMEM_Connectivity.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_CellModel.hxx"
+
+#include "MEDMEM_SkyLineArray.hxx"
+#include "MEDMEM_ModulusArray.hxx"
+
+#include "MEDMEM_STRING.hxx"
+
+//------------------------------------------------------//
+CONNECTIVITY::CONNECTIVITY(medEntityMesh Entity=MED_CELL):
+//------------------------------------------------------//
+ _entity(Entity),
+ _typeConnectivity(MED_NODAL),
+ _numberOfTypes(0),
+ _geometricTypes((medGeometryElement*)NULL),
+ _type((CELLMODEL*)NULL),
+ _entityDimension(0),
+ _count((int*)NULL),
+ _nodal((MEDSKYLINEARRAY*)NULL),
+ _descending((MEDSKYLINEARRAY*)NULL),
+ _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL),
+ _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL),
+ _neighbourhood((MEDSKYLINEARRAY*)NULL),
+ _constituent((CONNECTIVITY*)NULL)
+{
+ MESSAGE("CONNECTIVITY(medEntityMesh Entity=MED_CELL)") ;
+}
+
+//-------------------------------------------------------------------------//
+CONNECTIVITY::CONNECTIVITY(int numberOfTypes,medEntityMesh Entity=MED_CELL):
+//-------------------------------------------------------------------------//
+ _entity(Entity),
+ _typeConnectivity(MED_NODAL),
+ _numberOfTypes(numberOfTypes),
+ _entityDimension(0),
+ _nodal((MEDSKYLINEARRAY*)NULL),
+ _descending((MEDSKYLINEARRAY*)NULL),
+ _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL),
+ _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL),
+ _neighbourhood((MEDSKYLINEARRAY*)NULL),
+ _constituent((CONNECTIVITY*)NULL)
+{
+ MESSAGE("CONNECTIVITY(int numberOfTypes,medEntityMesh Entity=MED_CELL)") ;
+ _geometricTypes = new medGeometryElement[numberOfTypes];
+ _type = new CELLMODEL[numberOfTypes];
+ _count = new int[numberOfTypes];
+}
+
+//----------------------------//
+CONNECTIVITY::~CONNECTIVITY()
+//----------------------------//
+{
+ MESSAGE("Destructeur de CONNECTIVITY()") ;
+ if ( _geometricTypes != NULL )
+ delete [] _geometricTypes ;
+ if ( _count != NULL )
+ delete[] _count ;
+ if ( _nodal != NULL )
+ delete _nodal ;
+ if ( _descending != NULL )
+ delete _descending ;
+ if ( _reverseNodalConnectivity != NULL )
+ delete _reverseNodalConnectivity ;
+ if ( _reverseDescendingConnectivity != NULL )
+ delete _reverseDescendingConnectivity ;
+ if ( _constituent != NULL )
+ delete _constituent ;
+}
+
+/*! A DOCUMENTER */
+//------------------------------------------------------------------------------------------//
+void CONNECTIVITY::calculateConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity)
+//------------------------------------------------------------------------------------------//
+{
+ MESSAGE("CONNECTIVITY::calculateConnectivity");
+
+ // 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
+ if (Entity==MED_CELL)
+ calculateDescendingConnectivity() ;
+ else
+ throw MEDEXCEPTION("CONNECTIVITY::calculateConnectivity : Could not build DESCENDING !");
+ if (Entity!=_entity) {
+ calculateDescendingConnectivity() ;
+ _constituent->calculateConnectivity(ConnectivityType,Entity) ;
+ }
+}
+
+/*! Give, in full or no interlace mode (for nodal connectivity),
+ descending or nodal connectivity.
+
+ You must give a <medEntityMesh> (ie:MED_EDGE)
+ and a <medGeometryElement> (ie:MED_SEG3). */
+
+//------------------------------------------------------------//
+void CONNECTIVITY::updateFamily(vector<FAMILY*> myFamilies)
+//------------------------------------------------------------//
+{
+ const char * LOC = "CONNECTIVITY::updateFamily(vector<FAMILY*>) ";
+ BEGIN_OF(LOC);
+
+ int numberOfFamilies = myFamilies.size();
+ if (numberOfFamilies == 0 ) {
+ MESSAGE(LOC<<"No family") ;
+ return ;
+ }
+ // does we do an update ?
+ if ((_constituent != NULL)&(_descending != NULL)) {
+ MESSAGE(LOC<<"Constituent is already defined") ;
+ return ;
+ }
+
+ if ((_constituent != NULL)&(_descending == NULL)) {
+ if (myFamilies[0]->getEntity() != _constituent->getEntity()) {
+ MESSAGE(LOC<<"Family and constituent entity are different. We do nothing") ;
+ return ;
+ }
+
+ // well we could go !
+ CONNECTIVITY * oldConstituent = _constituent ;
+ _constituent = (CONNECTIVITY *)NULL ;
+ // for instance we must have nodal connectivity in constituent :
+ if (oldConstituent->_nodal == NULL)
+ {
+ MESSAGE(LOC<<"We have no nodal connectivity of sub cell");
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have no nodal connectivity of sub cell")) ;
+ }
+ int oldNumberOfFace = oldConstituent->_nodal->getNumberOf() ;
+ int * oldConstituentValue = oldConstituent->_nodal->getValue() ;
+ int * oldConstituentIndex = oldConstituent->_nodal->getIndex() ;
+
+ calculateDescendingConnectivity() ;
+
+ // if (oldConstituent->_nodal != NULL) {
+ int newNumberOfFace = _constituent->_nodal->getNumberOf() ;
+ int * newConstituentValue = _constituent->_nodal->getValue() ;
+ int * newConstituentIndex = _constituent->_nodal->getIndex() ;
+
+ int * newReverseDescendingIndex =
+ _reverseDescendingConnectivity->getIndex();
+ int * newReverseDescendingValue =
+ _reverseDescendingConnectivity->getValue();
+
+ int * newDescendingIndex = _descending->getIndex();
+ int * newDescendingValue = _descending->getValue();
+
+ // loop on all family,
+ // for all constituent in family, we get it's old connectivity
+ // (with oldCconstituentValue and oldConstituentIndex)
+ // and search the constituent in newConstituentValue with class
+ // ModulusArry
+ //
+ // when a new face is found, replace old constituent
+ // number in family with new one
+ // If face is not rigth oriented, we must change _descending attribute
+ // and _reverseDescendingConnectivity (see calculateDescendingConnectivity()).
+
+ // Voila a toi de jouer Nadir :-)
+
+ // First we get the renumbering from the oldCconstituentValue and
+ // oldConstituentIndex in the the new one, newConstituentValue and
+ // newConstituentIndex with a negative sign if the face is not
+ // right orented
+
+ int * renumberingFromOldToNew = new int [oldNumberOfFace];
+ int index1 = 0;
+ int indexm1 = 0;
+
+ for (int iOldFace=0;iOldFace<oldNumberOfFace;iOldFace++)
+ {
+ int index = 0;
+
+// renumberingFromOldToNew[iOldFace] = 999999;
+
+ int face_it_beginOld = oldConstituentIndex[iOldFace];
+ int face_it_endOld = oldConstituentIndex[iOldFace+1];
+ int face_size_itOld = face_it_endOld - face_it_beginOld;
+ int face_size_itNew;
+
+ MEDMODULUSARRAY modulusArrayOld(face_size_itOld,oldConstituentValue+face_it_beginOld-1);
+
+ for (int iNewFace=0;iNewFace<newNumberOfFace && index == 0;
+ iNewFace++)
+ {
+ int face_it_beginNew = newConstituentIndex[iNewFace];
+ int face_it_endNew = newConstituentIndex[iNewFace+1];
+ face_size_itNew = face_it_endNew - face_it_beginNew;
+
+ if (face_size_itNew == face_size_itOld)
+ {
+ MEDMODULUSARRAY modulusArrayNew(face_size_itNew,newConstituentValue+face_it_beginNew-1);
+
+ int retCompareNewOld = modulusArrayNew.compare(modulusArrayOld);
+
+ // Real new face found
+
+ if(retCompareNewOld == 1)
+ {
+ renumberingFromOldToNew[iOldFace] = iNewFace+1;
+ index = 1;
+ index1++;
+ }
+
+ // Reverse new face found
+
+ if(retCompareNewOld == -1)
+ {
+ renumberingFromOldToNew[iOldFace] = iNewFace+1;
+ index = 1;
+ indexm1++;
+
+ int face_it_begin = newReverseDescendingIndex[iNewFace];
+ int face_it_end = newReverseDescendingIndex[iNewFace+1];
+ int face_size_it = face_it_end - face_it_begin;
+
+ if (face_size_it == 1)
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This is a boundary face/edge, it should not be renumbered and it is wrongly oriented."));
+
+ if (face_size_it > 2)
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This face/edge should not be a (d-1) cell because it has "<<face_size_it<<" neighbouring"));
+
+ // we have always 2 neighbourings
+ int cell1 = newReverseDescendingValue[face_it_begin-1];
+ int cell2 = newReverseDescendingValue[face_it_begin];
+
+ // PROVISOIRE : en attendant que le SKYLINEARRAY de ReverseDescending soit correct (sans le zero)
+// if (cell2 == 0)
+// throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This is a boundary face/edge, it should not be renumbered and it is wrongly oriented."));
+
+ if (cell2 != 0) { // we are not on border !!!!
+
+ newReverseDescendingValue[face_it_begin-1] = cell2;
+ // Updating _constituent->_nodal because of reversity
+ int * oldArray = oldConstituentValue+face_it_beginOld-1;
+ int * newArray = newConstituentValue+face_it_beginNew-1;
+ for(int iarray=0;iarray<face_size_itNew;iarray++)
+ newArray[iarray] = oldArray[iarray] ;
+
+
+ // Updating _reverseDescendingConnectivity
+
+
+ newReverseDescendingValue[face_it_begin] = cell1;
+
+ // Updating _descending for cell1 and cell2
+ for(int iface=newDescendingIndex[cell1-1];iface<newDescendingIndex[cell1];iface++)
+ if (newDescendingValue[iface-1]==iNewFace+1)
+ newDescendingValue[iface-1]=-iNewFace-1 ;
+ else if (newDescendingValue[iface-1]==-iNewFace-1)
+ newDescendingValue[iface-1]=iNewFace+1 ;
+
+ for(int iface=newDescendingIndex[cell2-1];iface<newDescendingIndex[cell2];iface++)
+ if (newDescendingValue[iface-1]==iNewFace+1)
+ newDescendingValue[iface-1]=-iNewFace-1 ;
+ else if (newDescendingValue[iface-1]==-iNewFace-1)
+ newDescendingValue[iface-1]=iNewFace+1 ;
+ } else {// else we are on border and we do nothing !!!!!!!!
+ INFOS("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
+ INFOS(LOC<<" Boudary FACE "<<iOldFace+1<<" are wrong oriented !") ;
+ INFOS("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
+ }
+ }
+ }
+ }
+
+ if(index == 0)
+ {
+ INFOS(LOC<<"Renumbering problem with the Face connectivity given by the User and the new Connectivity computed");
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have a Face connectivity problem"));
+ }
+ }
+
+ MESSAGE(LOC<<"The Renumbering is finished and the status is");
+ SCRUTE(index1);
+ SCRUTE(indexm1);
+
+ // Updating the Family
+
+ for(int i=0; i<numberOfFamilies; i++) {
+ FAMILY * myFamily = myFamilies[i] ;
+
+ int length_skyline = myFamily->getnumber()->getLength();
+ int * value_skyline = myFamily->getnumber()->getValue();
+
+ for (int i=0;i<length_skyline;i++)
+ value_skyline[i] = renumberingFromOldToNew[value_skyline[i]-1];
+ }
+ }
+
+ END_OF(LOC);
+ return ;
+}
+
+//------------------------------------------------------------------------------------------------------------------//
+med_int * CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type)
+//------------------------------------------------------------------------------------------------------------------//
+{
+ const char * LOC = "CONNECTIVITY::getConnectivity" ;
+ BEGIN_OF(LOC);
+
+ MEDSKYLINEARRAY * Connectivity ;
+ if (Entity==_entity) {
+
+ if (ConnectivityType==MED_NODAL)
+ Connectivity=_nodal;
+ else
+ Connectivity=_descending;
+
+ if (Connectivity!=NULL)
+ if (Type==MED_ALL_ELEMENTS)
+ return Connectivity->getValue() ;
+ else {
+ for (med_int i=0; i<_numberOfTypes; i++)
+ if (_geometricTypes[i]==Type)
+ return Connectivity->getI(_count[i]) ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Type not found !")) ;
+ }
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")) ;
+ } else
+ if (_constituent != NULL)
+ return _constituent->getConnectivity(ConnectivityType,Entity,Type);
+
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")) ;
+}
+
+/*! 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 connectivity array.
+
+ Example : i-th element, j-th node of it :
+ - In C mode : Connectivity[ConnectivityIndex[i]-1+j-1]
+ - In fortran mode : Connectivity[ConnectivityIndex[i]+j] */
+//-----------------------------------------------------------------------------------------------//
+med_int * CONNECTIVITY::getConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity)
+//------------------------------------------------------------------------------------------------//
+{
+ const 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
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")) ;
+
+ } else
+ if (_constituent != NULL)
+ return _constituent->getConnectivityIndex(ConnectivityType,Entity);
+
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")) ;
+}
+
+/*! A DOCUMENTER */
+//--------------------------------------------------------------//
+CELLMODEL & CONNECTIVITY::getType(medGeometryElement Type) const
+//--------------------------------------------------------------//
+{
+ const char * LOC = "CONNECTIVITY::getType" ;
+ BEGIN_OF(LOC);
+
+ if ((Type==MED_ALL_ELEMENTS) || (Type==MED_NONE))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE !")) ;
+ for (med_int i=0; i<_numberOfTypes; i++)
+ if (_geometricTypes[i]==Type)
+ return _type[i] ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !")) ;
+}
+
+/*! Returns the number of elements of type <med geometrie element>.
+ Note : not implemented for MED_ALL_ELEMENTS nor for MED_NONE */
+//------------------------------------------------------------------------//
+med_int CONNECTIVITY::getNumberOfNodesInType(medGeometryElement Type) const
+//------------------------------------------------------------------------//
+{
+ const char * LOC = "CONNECTIVITY::getNumberOfNodesInType" ;
+ BEGIN_OF(LOC);
+
+ if ((Type==MED_ALL_ELEMENTS) || (Type==MED_NONE))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!")) ;
+ for (med_int i=0; i<_numberOfTypes; i++)
+ if (_geometricTypes[i]==Type)
+ return _type[i].getNumberOfNodes() ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !")) ;
+}
+
+/*! Returns the number of geometric sub cells of <med geometrie element> type.
+not implemented for MED_ALL_ELEMENTS nor for MED_NONE */
+//------------------------------------------------------------------------//
+med_int CONNECTIVITY::getNumberOfSubCellInType(medGeometryElement Type) const
+//------------------------------------------------------------------------//
+{
+ if ((Type==MED_ALL_ELEMENTS) || (Type==MED_NONE))
+ throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!") ;
+ for (med_int i=0; i<_numberOfTypes; i++)
+ if (_geometricTypes[i]==Type)
+ return _type[i].getNumberOfConstituents(1) ;
+ throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement not found !") ;
+}
+
+/*! Returns the number of elements of type <med geometrie element>.
+
+ Note :
+ - Implemented for MED_ALL_ELEMENTS
+ - Not implemented for MED_ALL_ENTITIES (A VERIFIER)
+ - Not implemented for MED_NONE */
+//-----------------------------------------------------------------------------------//
+med_int CONNECTIVITY::getNumberOf(medEntityMesh Entity, medGeometryElement Type) const
+//-----------------------------------------------------------------------------------//
+{
+ const char * LOC = "CONNECTIVITY::getNumberOf" ;
+ BEGIN_OF(LOC);
+
+ MESSAGE(LOC<<" Entity = "<< Entity << ", _entity = "<<_entity);
+
+ if (Entity==_entity) {
+ if (Type==MED_NONE)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_NONE"));
+ if (Type==MED_ALL_ELEMENTS)
+ return _count[_numberOfTypes]-1;
+ for (med_int i=0; i<_numberOfTypes; i++)
+ if (_geometricTypes[i]==Type)
+ return (_count[i+1] - _count[i]);
+ //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !"));
+ } else
+ if (_constituent != NULL)
+ return _constituent->getNumberOf(Entity,Type);
+
+ return 0 ; // valid if they are nothing !
+ //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")) ;
+}
+
+/*! A DOCUMENTER */
+//--------------------------------------------------------------//
+med_int* CONNECTIVITY::getValue(medConnectivity TypeConnectivity,
+ medGeometryElement Type)
+//--------------------------------------------------------------//
+{
+ if (TypeConnectivity == MED_NODAL)
+ {
+ calculateNodalConnectivity();
+ if (Type==MED_ALL_ELEMENTS)
+ return _nodal->getValue();
+ for (med_int i=0; i<_numberOfTypes; i++)
+ if (_geometricTypes[i]==Type)
+ return _nodal->getI(_count[i]);
+ }
+ else
+ {
+ calculateDescendingConnectivity();
+ if (Type==MED_ALL_ELEMENTS)
+ return _descending->getValue();
+ for (med_int i=0; i<_numberOfTypes; i++)
+ if (_geometricTypes[i]==Type)
+ return _descending->getI(Type);
+ }
+ throw MEDEXCEPTION("Not found");
+}
+
+/*! A DOCUMENTER */
+//---------------------------------------------------------------------//
+med_int* CONNECTIVITY:: getValueIndex(medConnectivity TypeConnectivity)
+//---------------------------------------------------------------------//
+{
+ if (TypeConnectivity == MED_NODAL)
+ {
+ calculateNodalConnectivity();
+ return _nodal->getIndex();
+ }
+ else
+ {
+ calculateDescendingConnectivity();
+ return _descending->getIndex();
+ }
+}
+
+/*! Not yet implemented */
+//----------------------------------------------//
+med_int* CONNECTIVITY:: getNeighbourhood() const
+//----------------------------------------------//
+{
+ throw MEDEXCEPTION("CONNECTIVITY::getNeighbourhood : Not implemented");
+}
+
+/*! Returns an array which contains, for each node, all cells
+ arround it. */
+//-------------------------------------------------//
+med_int* CONNECTIVITY::getReverseNodalConnectivity()
+//-------------------------------------------------//
+{
+ calculateReverseNodalConnectivity();
+ return _reverseNodalConnectivity->getValue();
+}
+
+/*! Give index array to use with getReverseConnectivity(MED_NODAL).
+ It is unusefull with MED_DESCENDING mode, because we have allways two cells. */
+//-------------------------------------------------------//
+med_int* CONNECTIVITY::getReverseNodalConnectivityIndex()
+//-------------------------------------------------------//
+{
+ calculateReverseNodalConnectivity();
+ return _reverseNodalConnectivity->getIndex();
+}
+
+/*! Returns an array which contains, for each face (or edge),
+ the 2 cells of each side. First is cell which face normal is outgoing.
+ arround it. */
+//------------------------------------------------------//
+med_int* CONNECTIVITY::getReverseDescendingConnectivity()
+//------------------------------------------------------//
+{
+ // it is in _constituent connectivity only if we are in MED_CELL
+ if (_entity==MED_CELL) {
+ // we want descending connectivity
+ calculateDescendingConnectivity();
+ return _reverseDescendingConnectivity->getValue();
+ }
+ throw MEDEXCEPTION("CONNECTIVITY::getReverseDescendingConnectivity : Error Only in MED_CELL connectivity");
+}
+
+/*! calculate the reverse descending Connectivity
+ and returns the index ( A DOCUMENTER MIEUX)*/
+//-----------------------------------------------------------//
+med_int* CONNECTIVITY::getReverseDescendingConnectivityIndex()
+//-----------------------------------------------------------//
+{
+ // it is in _constituent connectivity only if we are in MED_CELL
+ if (_entity==MED_CELL) {
+ // we want descending connectivity
+ calculateDescendingConnectivity();
+ return _reverseDescendingConnectivity->getIndex();
+ }
+ throw MEDEXCEPTION("CONNECTIVITY::getReverseDescendingConnectivityIndex : Error Only in MED_CELL connectivity");
+}
+
+/*! A DOCUMENTER (et a finir ???) */
+//--------------------------------------------//
+void CONNECTIVITY::calculateNodalConnectivity()
+//--------------------------------------------//
+{
+ if (_nodal==NULL)
+ {
+ if (_descending==NULL)
+ throw MEDEXCEPTION("CONNECTIVITY::calculateNodalConnectivity : No connectivity found !");
+ // calculate _nodal from _descending
+ }
+}
+
+/*! If not yet done, calculate the nodal Connectivity
+ and the reverse nodal Connectivity*/
+//---------------------------------------------------//
+void CONNECTIVITY::calculateReverseNodalConnectivity()
+//---------------------------------------------------//
+{
+ const char * LOC = "CONNECTIVITY::calculateReverseNodalConnectivity : " ;
+ BEGIN_OF(LOC) ;
+
+ if (_nodal==NULL)
+ calculateNodalConnectivity() ;
+
+ MESSAGE(LOC<<"Number of nodes = "<<_numberOfNodes);
+
+ if(_reverseNodalConnectivity==NULL) {
+
+ med_int node_number = 0;
+ vector <vector <med_int> > reverse_connectivity;
+ reverse_connectivity.resize(_numberOfNodes+1);
+
+ // Treat all cells types
+
+ for (med_int j = 0; j < _numberOfTypes; j++)
+ {
+ // node number of the cell type
+ node_number = _type[j].getNumberOfNodes();
+ // treat all cells of a particular type
+ for (med_int k = _count[j]; k < _count[j+1]; k++)
+ // treat all nodes of the cell type
+ for (med_int local_node_number = 1 ; local_node_number < node_number+1; local_node_number++)
+ {
+ med_int global_node = _nodal->getIJ(k,local_node_number) ;
+ reverse_connectivity[global_node].push_back(k);
+ }
+ }
+
+ // Full reverse_nodal_connectivity and reverse_nodal_connectivity_index
+
+ //calculate size of reverse_nodal_connectivity array
+ med_int size_reverse_nodal_connectivity = 0;
+ for (med_int i = 1; i < _numberOfNodes+1; i++)
+ size_reverse_nodal_connectivity += reverse_connectivity[i].size();
+
+ MEDSKYLINEARRAY * ReverseConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity) ;
+ // reverse_nodal_connectivity_index = new (med_int)[_numberOfNodes+1];
+ // reverse_nodal_connectivity = new (med_int)[size_reverse_nodal_connectivity];
+ med_int * reverse_nodal_connectivity = ReverseConnectivity->getValue() ;
+ med_int * reverse_nodal_connectivity_index = ReverseConnectivity->getIndex() ;
+
+ reverse_nodal_connectivity_index[0] = 1;
+ for (med_int i = 1; i < _numberOfNodes+1; i++)
+ {
+ med_int size = reverse_connectivity[i].size();
+ reverse_nodal_connectivity_index[i] = reverse_nodal_connectivity_index[i-1] + size ;
+ for (med_int j = 0; j < size; j++)
+ reverse_nodal_connectivity[reverse_nodal_connectivity_index[i-1]-1+j]= reverse_connectivity[i][j];
+ }
+
+ _reverseNodalConnectivity = ReverseConnectivity ;
+
+ }
+}
+
+/*! If not yet done, calculate the Descending Connectivity */
+//-------------------------------------------------//
+void CONNECTIVITY::calculateDescendingConnectivity()
+//-------------------------------------------------//
+{
+ const char * LOC = "CONNECTIVITY::calculateDescendingConnectivity() : ";
+ BEGIN_OF(LOC);
+
+ if (_descending==NULL) {
+ if (_nodal==NULL) {
+ MESSAGE(LOC<<"No connectivity found !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity found !"));
+ }
+ // calcul _descending from _nodal
+ // we need CONNECTIVITY for constituent
+
+ 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 !");
+
+ if (_entityDimension == 3)
+ _constituent = new CONNECTIVITY(MED_FACE) ;
+ else if (_entityDimension == 2)
+ _constituent = new CONNECTIVITY(MED_EDGE) ;
+ else {
+ MESSAGE(LOC<<"We are in 1D");
+ return;
+ }
+ _constituent->_typeConnectivity = MED_DESCENDING ;
+ _constituent->_numberOfNodes = _numberOfNodes ;
+ // foreach cells, we built array of constituent
+ int DescendingSize = 0 ;
+ for(int i=0; i<_numberOfTypes; i++)
+ DescendingSize+=(_count[i+1]-_count[i])*_type[i].getNumberOfConstituents(1) ;
+ _descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,DescendingSize) ;
+ int * descend_connectivity = _descending->getValue() ;
+ for (int i=0; i<DescendingSize; i++)
+ descend_connectivity[i]=0;
+ int * descend_connectivity_index = _descending->getIndex() ;
+ descend_connectivity_index[0]=1;
+ medGeometryElement* ConstituentsTypes = new medGeometryElement[2];
+ ConstituentsTypes[0]=MED_NONE ;
+ ConstituentsTypes[1]=MED_NONE ;
+ int * NumberOfConstituentsForeachType = new int[2];
+ NumberOfConstituentsForeachType[0]=0;
+ NumberOfConstituentsForeachType[1]=0;
+ for(int i=0; i<_numberOfTypes; i++) {
+ // initialize descend_connectivity_index array :
+ int NumberOfConstituents = _type[i].getNumberOfConstituents(1) ;
+ for (int j=_count[i];j<_count[i+1];j++){
+ descend_connectivity_index[j]=descend_connectivity_index[j-1]+NumberOfConstituents ;
+ // compute number of constituent of all cell for each type
+ for(int k=1;k<NumberOfConstituents+1;k++) {
+ medGeometryElement MEDType = _type[i].getConstituentType(1,k) ;
+ if (ConstituentsTypes[0]==MED_NONE) {
+ ConstituentsTypes[0]=MEDType;
+ NumberOfConstituentsForeachType[0]++ ;
+ } else if (ConstituentsTypes[0]==MEDType)
+ NumberOfConstituentsForeachType[0]++ ;
+ else if (ConstituentsTypes[1]==MED_NONE) {
+ ConstituentsTypes[1]=MEDType;
+ NumberOfConstituentsForeachType[1]++ ;
+ } else if (ConstituentsTypes[1]==MEDType)
+ NumberOfConstituentsForeachType[1]++ ;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<MEDType<<" is different of "<<ConstituentsTypes[0]<<" and "<<ConstituentsTypes[1]));
+ }
+ }
+ }
+
+ // 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
+ int * ConstituentNodalConnectivity = _constituent->_nodal->getValue();
+ int * ConstituentNodalConnectivityIndex = _constituent->_nodal->getIndex();
+ ConstituentNodalConnectivityIndex[0]=1;
+
+ _constituent->_entityDimension=ConstituentsTypes[0]/100;
+ if (ConstituentsTypes[1]==MED_NONE)
+ _constituent->_numberOfTypes = 1 ;
+ else
+ _constituent->_numberOfTypes = 2 ;
+ _constituent->_geometricTypes = new medGeometryElement[_constituent->_numberOfTypes] ;
+ _constituent->_type = new CELLMODEL[_constituent->_numberOfTypes] ;
+ _constituent->_count = new med_int[_constituent->_numberOfTypes+1] ;
+ _constituent->_count[0]=1;
+ int* tmp_NumberOfConstituentsForeachType = new med_int[_constituent->_numberOfTypes+1] ;
+ tmp_NumberOfConstituentsForeachType[0]=0; // to count constituent of each type
+ for (int i=0; i<_constituent->_numberOfTypes;i++) {
+ _constituent->_geometricTypes[i]=ConstituentsTypes[i] ;
+ _constituent->_count[i+1]=_constituent->_count[i]+NumberOfConstituentsForeachType[i] ;
+ CELLMODEL Type(ConstituentsTypes[i]);
+ _constituent->_type[i]=Type;
+ tmp_NumberOfConstituentsForeachType[i+1]=NumberOfConstituentsForeachType[i] ;
+ for (int j=tmp_NumberOfConstituentsForeachType[i]; j<tmp_NumberOfConstituentsForeachType[i+1]+tmp_NumberOfConstituentsForeachType[i]; j++)
+ ConstituentNodalConnectivityIndex[j+1]=ConstituentNodalConnectivityIndex[j]+(ConstituentsTypes[i]%100) ;
+ }
+ delete[] ConstituentsTypes;
+ delete[] NumberOfConstituentsForeachType ;
+
+ // we need reverse nodal connectivity
+ if (! _reverseNodalConnectivity)
+ calculateReverseNodalConnectivity() ;
+ int * ReverseNodalConnectivityIndex = _reverseNodalConnectivity->getIndex();
+ int * ReverseNodalConnectivityValue = _reverseNodalConnectivity->getValue();
+
+ // 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
+ CELLMODEL Type = _type[i] ;
+ int NumberOfNodesPerCell = Type.getNumberOfNodes() ;
+ int NumberOfConstituentPerCell = Type.getNumberOfConstituents(1);
+ for (int j=_count[i]; j<_count[i+1]; j++) // we loop on all cell of this type
+ for (int k=1 ; k<=NumberOfConstituentPerCell; k++) { // we loop on all sub cell of it
+ if (descend_connectivity[descend_connectivity_index[j-1]+k-2]==0) {
+ // it is a new sub cell !
+ // TotalNumberOfSubCell++;
+ // Which type ?
+ if (Type.getConstituentType(1,k)==_constituent->_geometricTypes[0]){
+ tmp_NumberOfConstituentsForeachType[0]++;
+ TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[0];
+ } else {
+ tmp_NumberOfConstituentsForeachType[1]++;
+ 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; l<NumberOfNodesPerConstituent; l++) {
+ NodesLists[l]=_nodal->getIJ(j,Type.getNodeConstituent(1,k,l+1));
+ ConstituentNodalConnectivity[ConstituentNodalConnectivityIndex[TotalNumberOfSubCell-1]-1+l]=NodesLists[l];
+ }
+ // we use reverse_nodal_connectivity to find the other element which contain this sub cell
+
+ // all elements which contains first node of sub cell :
+ int ReverseNodalConnectivityIndex_0 = ReverseNodalConnectivityIndex[NodesLists[0]-1] ;
+ int ReverseNodalConnectivityIndex_1 = ReverseNodalConnectivityIndex[NodesLists[0]] ;
+ int NumberOfCellsInList = ReverseNodalConnectivityIndex_1-ReverseNodalConnectivityIndex_0 ;
+ int * CellsList = new int[NumberOfCellsInList] ;
+ for (int l=ReverseNodalConnectivityIndex_0; l<ReverseNodalConnectivityIndex_1; l++)
+ CellsList[l-ReverseNodalConnectivityIndex_0]=ReverseNodalConnectivityValue[l-1] ;
+
+ // foreach node in sub cell, we search elements which are in common
+ // at the end, we must have only one !
+
+ for (int l=1; l<NumberOfNodesPerConstituent; l++) {
+ int NewNumberOfCellsInList = 0 ;
+ int * NewCellsList = new int[NumberOfCellsInList] ;
+ for (int l1=0; l1<NumberOfCellsInList; l1++)
+ for (int l2=ReverseNodalConnectivityIndex[NodesLists[l]-1]; l2<ReverseNodalConnectivityIndex[NodesLists[l]]; l2++) {
+ if (CellsList[l1]<ReverseNodalConnectivityValue[l2-1])
+ // increasing order : CellsList[l1] are not in elements list of node l
+ break ;
+ if ((CellsList[l1]==ReverseNodalConnectivityValue[l2-1])&(CellsList[l1]!=j)) {
+ // we have found one
+ NewCellsList[NewNumberOfCellsInList]=CellsList[l1];
+ NewNumberOfCellsInList++;
+ break;
+ }
+ }
+ NumberOfCellsInList = NewNumberOfCellsInList;
+ delete [] CellsList ;
+ CellsList = NewCellsList;
+ }
+
+ int CellNumber = CellsList[0] ;
+ delete [] CellsList ;
+ if (NumberOfCellsInList>1)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one other Cell ("<<NumberOfCellsInList<<") !"));
+
+
+// int cell_number_1=-1 ;
+// int cell_number_2=-1 ;
+// int cell_number_3=-1 ;
+// bool find = false ;
+// for (int l=ReverseNodalConnectivityIndex[NodesLists[0]-1]; l<ReverseNodalConnectivityIndex[NodesLists[0]]; l++) { // first node
+// cell_number_1 = ReverseNodalConnectivityValue[l-1] ;
+// if (cell_number_1 != j)
+// for (int m=ReverseNodalConnectivityIndex[NodesLists[1]-1]; m<ReverseNodalConnectivityIndex[NodesLists[1]]; m++) { //second node
+// cell_number_2 = ReverseNodalConnectivityValue[m-1] ;
+// if ((cell_number_2 != j) && (cell_number_2 == cell_number_1))
+// for (int n=ReverseNodalConnectivityIndex[NodesLists[2]-1]; n<ReverseNodalConnectivityIndex[NodesLists[2]]; n++) { //third node
+// cell_number_3 = ReverseNodalConnectivityValue[n-1] ;
+// if ((cell_number_3 != j) && (cell_number_3 == cell_number_1)) { // we found element which have three node in it
+// find = true ;
+// break ;
+// }
+// if (find)
+// break ;
+// }
+// if (find)
+// break ;
+// }
+// if (find)
+// break ;
+// }
+
+
+// if (find) {
+ 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 ;
+ for (int l=0; l<_numberOfTypes; l++)
+ if (CellNumber < _count[l+1]) {
+ Type2=_type[l] ;
+ break ;
+ }
+ //int sub_cell_count2 = Type2.get_entities_count(1) ;
+ //int nodes_cell_count2 = Type2.get_nodes_count() ;
+ bool find2 = false ;
+ for (int l=1; l<=Type2.getNumberOfConstituents(1) ;l++) { // on all sub cell
+ 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++ ;
+ }
+ if (counter==Type.getConstituentType(1,k)%100) {
+ descend_connectivity[descend_connectivity_index[CellNumber-1]+l-2]=-1*TotalNumberOfSubCell; // because, see it in other side !
+ find2 = true ;
+ }
+ if (find2)
+ break ;
+ }
+ if (!find2)
+ INFOS(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!") ; // exception ?
+ } else
+ ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0 ;
+
+ delete[] NodesLists ;
+ }
+ }
+ }
+ // we adjust _constituent
+ int NumberOfConstituent=0 ;
+ int SizeOfConstituentNodal=0 ;
+ for (int i=0;i<_constituent->_numberOfTypes; i++) {
+ NumberOfConstituent += tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1;
+ SizeOfConstituentNodal += (tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1)*_constituent->_type[i].getNumberOfNodes();
+ }
+ // we built new _nodal attribute in _constituent
+ MEDSKYLINEARRAY *ConstituentNodal = new MEDSKYLINEARRAY(NumberOfConstituent,SizeOfConstituentNodal);
+ int *ConstituentNodalValue = ConstituentNodal->getValue();
+ int *ConstituentNodalIndex = ConstituentNodal->getIndex();
+ ConstituentNodalIndex[0]=1;
+ // we build _reverseDescendingConnectivity
+ _reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,2*NumberOfConstituent) ;
+ int *reverseDescendingConnectivityValue = _reverseDescendingConnectivity->getValue();
+ int *reverseDescendingConnectivityIndex = _reverseDescendingConnectivity->getIndex();
+ reverseDescendingConnectivityIndex[0]=1;
+
+ // first constituent type
+ for(int j=0; j<tmp_NumberOfConstituentsForeachType[0]; j++) {
+ ConstituentNodalIndex[j+1]=ConstituentNodalConnectivityIndex[j+1];
+ for(int k=ConstituentNodalIndex[j]; k<ConstituentNodalIndex[j+1]; k++){
+ ConstituentNodalValue[k-1]=ConstituentNodalConnectivity[k-1];
+ }
+ reverseDescendingConnectivityIndex[j+1]=reverseDescendingConnectivityIndex[j]+2;
+ for(int k=reverseDescendingConnectivityIndex[j]; k<reverseDescendingConnectivityIndex[j+1]; k++){
+ reverseDescendingConnectivityValue[k-1]=ReverseDescendingConnectivityValue[k-1];
+ }
+ }
+ // second type if any
+ if (_constituent->_numberOfTypes==2) {
+ int offset = _constituent->_count[1]-tmp_NumberOfConstituentsForeachType[0]-1 ;
+ int offset1=offset*_constituent->_type[0].getNumberOfNodes();
+ int offset2=offset*2 ;
+ int NumberOfNodesPerConstituent = _constituent->_type[1].getNumberOfNodes();
+ for(int j=tmp_NumberOfConstituentsForeachType[0]; j<NumberOfConstituent; j++) {
+ ConstituentNodalIndex[j+1]=ConstituentNodalIndex[j]+NumberOfNodesPerConstituent;
+ for(int k=ConstituentNodalIndex[j]; k<ConstituentNodalIndex[j+1]; k++){
+ ConstituentNodalValue[k-1]=ConstituentNodalConnectivity[offset1+k-1];
+ }
+ reverseDescendingConnectivityIndex[j+1]=reverseDescendingConnectivityIndex[j]+2;
+ for(int k=reverseDescendingConnectivityIndex[j]; k<reverseDescendingConnectivityIndex[j+1]; k++){
+ reverseDescendingConnectivityValue[k-1]=ReverseDescendingConnectivityValue[offset2+k-1];
+ }
+ }
+ _constituent->_count[2]=NumberOfConstituent+1 ;
+ // we correct _descending to adjust face number
+ for(int j=0;j<DescendingSize;j++)
+ if (descend_connectivity[j]>tmp_NumberOfConstituentsForeachType[0])
+ descend_connectivity[j]-=offset;
+
+ }
+ _constituent->_count[1]=tmp_NumberOfConstituentsForeachType[0]+1;
+ delete _constituent->_nodal ;
+ _constituent->_nodal = ConstituentNodal ;
+
+ delete[] ReverseDescendingConnectivityValue ;
+ }
+ END_OF(LOC);
+}
+
+//-----------------------------------------------------------------------------------------//
+// void CONNECTIVITY::calculateReverseDescendingConnectivity(CONNECTIVITY *myConnectivity)
+//-----------------------------------------------------------------------------------------//
+// {
+// if (_entity==MED_CELL)
+// throw MEDEXCEPTION("CONNECTIVITY::calculateReverseDescending
+// Connectivity : we could not do that with MED_CELL entity !");
+// if (myConnectivity->getEntity()!=MED_CELL)
+// throw MEDEXCEPTION("CONNECTIVITY::calculateReverseDescending
+// Connectivity : we need MED_CELL connectivity !");
+// return ;
+// }
+
+/*! Not implemented yet */
+//--------------------------------------------------------------------//
+void CONNECTIVITY::calculateNeighbourhood(CONNECTIVITY &myConnectivity)
+//--------------------------------------------------------------------//
+{
+ // Mesh dimension !
+ return ;
+}
+
+
+/*!
+ Give, for one element number of a specified entity the geometric type
+ Of this element.
+
+ Example : medGeometryElement myType = myConnectivity.getElementType(MED_CELL,35) ;
+*/
+//--------------------------------------------------------------------//
+medGeometryElement CONNECTIVITY::getElementType(medEntityMesh Entity,int Number) const
+//--------------------------------------------------------------------//
+{
+ if (_entity==Entity) {
+ for(int i=1; i<=_numberOfTypes;i++)
+ if (Number<_count[i])
+ return _geometricTypes[i-1] ;
+ }
+ else if (_constituent!=NULL)
+ return _constituent->getElementType(Entity,Number) ;
+ else
+ throw MEDEXCEPTION(LOCALIZED("getElementType : Entity not defined !")) ;
+ throw MEDEXCEPTION(LOCALIZED("getElementType : Wrong Number !")) ;
+}
--- /dev/null
+#ifndef CONNECTIVITY_HXX
+#define CONNECTIVITY_HXX
+
+#include <vector>
+
+#include "utilities.h"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+using namespace MED_EN;
+
+class MEDSKYLINEARRAY;
+class CELLMODEL;
+class FAMILY;
+
+/*!
+ this class deals with all type of connectivity
+ this a recursive class in order to store
+
+*/
+class CONNECTIVITY // recursive class
+
+{
+ /*
+ Class Attributs
+ */
+
+protected:
+ /*! contains MED_CELL MED_FACE or MED_EDGE */
+ medEntityMesh _entity ;
+ /*! contains MED_NODAL or MED_DESCEND */
+ medConnectivity _typeConnectivity ;
+ /*! count of differents cells types
+ used by the mesh */
+ med_int _numberOfTypes ;
+ /*! array of all med_geometric_type used by MESH. */
+ medGeometryElement* _geometricTypes ;
+
+ /*! map indexed by med_geometric_type
+ which contains the different
+ 'CellModel' used by MESH. */
+ CELLMODEL * _type ;
+ /*! contains the dimension of the entity */
+ med_int _entityDimension ;
+
+ /*! needed by calculateReverseNodalConnectivity */
+ med_int _numberOfNodes ;
+
+ /*! 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
+ must minus _count[i+1] and _count[i]
+ ( 0 <= i < _numberOfTypes ).
+ Note that _count[_numberOfTypes] returns
+ total cells count + 1 */
+ med_int * _count ;
+
+ /*! pointer on an array which stores the nodal connectivity */
+ MEDSKYLINEARRAY* _nodal ;
+ /*! pointer on an array which stores the descending connectivity */
+ MEDSKYLINEARRAY* _descending ;
+ /*! pointer on an array which stores the resverse nodal connectivity */
+ MEDSKYLINEARRAY* _reverseNodalConnectivity ;
+ /*! pointer on an array which stores the reverse descending connectivity */
+ MEDSKYLINEARRAY* _reverseDescendingConnectivity ;
+ /*! if face or edge, list of 2 cells or
+ 2 faces it belongs to.
+ If 2nd number equals 0, we have a
+ boundary entity. We could use
+ MEDSKYLINEARRAY, but we suppose we have
+ always only 2 (or 1) entities. */
+ MEDSKYLINEARRAY* _neighbourhood ;
+ /*! connectivity of sub cell if
+ descendant connectivity is calculated */
+ CONNECTIVITY * _constituent ;
+
+ /*
+ Class Methods
+ */
+
+private:
+ /*! does nothing if already exists, else
+ evaluates _nodal from _descending */
+ void calculateNodalConnectivity() ;
+ /*! does nothing if already exists, else
+ evaluates from _nodal */
+ void calculateReverseNodalConnectivity() ;
+ /*! does nothing if already exists, else
+ evaluates _descending from _nodal */
+ void calculateDescendingConnectivity() ;
+ /*! does nothing if already exists, else
+ evaluates from _descending */
+ // void calculateReverseDescendingConnectivity(CONNECTIVITY *myConnectivity) ;
+ /*! does nothing if already exists, else
+ evaluates _neighbourhood from _descending */
+ void calculateNeighbourhood(CONNECTIVITY &myConnectivity) ;
+
+public:
+
+ friend class MED_MESH_RDONLY_DRIVER;
+ friend class MED_MESH_WRONLY_DRIVER;
+
+ CONNECTIVITY(medEntityMesh Entity=MED_CELL);
+ CONNECTIVITY(int numberOfTypes, medEntityMesh Entity=MED_CELL);
+ ~CONNECTIVITY();
+
+ inline bool existConnectivity (medConnectivity connectivityType, medEntityMesh Entity) const ;
+ void calculateConnectivity (medConnectivity connectivityType, medEntityMesh Entity) ;
+ void updateFamily(vector<FAMILY*> myFamilies) ;
+
+ inline medEntityMesh getEntity () const;
+ inline med_int getNumberOfTypes (medEntityMesh Entity) const;
+ inline medGeometryElement * getGeometricTypes (medEntityMesh Entity) const;
+ medGeometryElement getElementType(medEntityMesh Entity,int Number) const ;
+ inline int * getGlobalNumberingIndex (medEntityMesh Entity) const ;
+
+ med_int * getConnectivity (medConnectivity ConnectivityType, medEntityMesh Entity,
+ medGeometryElement Type) ;
+ med_int * getConnectivityIndex (medConnectivity ConnectivityType,medEntityMesh Entity) ;
+
+ CELLMODEL & getType (medGeometryElement Type) const;
+ CELLMODEL * getCellsTypes (medEntityMesh Entity) const;
+
+ med_int getNumberOfNodesInType (medGeometryElement Type) const;
+ med_int getNumberOfSubCellInType (medGeometryElement Type) const;
+ med_int getNumberOf (medEntityMesh Entity, medGeometryElement Type) const;
+ med_int* getValue (medConnectivity TypeConnectivity, medGeometryElement Type) ;
+ med_int* getValueIndex (medConnectivity TypeConnectivity) ;
+ med_int* getReverseNodalConnectivity () ;
+ med_int* getReverseNodalConnectivityIndex () ;
+ med_int* getReverseDescendingConnectivity () ;
+ med_int* getReverseDescendingConnectivityIndex () ;
+ med_int* getNeighbourhood() const;
+
+} ;
+/*----------------------*/
+/* Methodes Inline */
+/*----------------------*/
+
+/*! Returns the medEntityMesh */
+inline medEntityMesh CONNECTIVITY::getEntity() const
+{
+ return _entity;
+}
+
+/*! Returns the number of different <medGeometryElement> types existing in the specified entity.
+
+ Note : Not implemented for MED_ALL_ENTITIES. */
+inline med_int CONNECTIVITY::getNumberOfTypes(medEntityMesh Entity) const
+{
+ MESSAGE("CONNECTIVITY::getNumberOfTypes : Entity = "<<Entity<<", _entity = "<<_entity);
+ if (_entity==Entity)
+ return _numberOfTypes;
+ else if (_constituent!=NULL)
+ return _constituent->getNumberOfTypes(Entity) ;
+ else
+ return 0 ; // because it is the right information (no need exception !
+ //throw MEDEXCEPTION("Entity not defined !") ;
+}
+
+/*! Returns an array of all <med geometry elements> types existing in the mesh for the given medEntityMesh.
+
+ Note : Not implemented for MED_ALL_ENTITIES. */
+inline medGeometryElement* CONNECTIVITY::getGeometricTypes(medEntityMesh Entity) const
+{
+ if (_entity==Entity)
+ return _geometricTypes;
+ else if (_constituent!=NULL)
+ return _constituent->getGeometricTypes(Entity) ;
+ else
+ throw MEDEXCEPTION("Entity not defined !") ;
+}
+
+/*! A DOCUMENTER */
+inline int * CONNECTIVITY::getGlobalNumberingIndex(medEntityMesh Entity) const
+{
+ if (_entity==Entity)
+ return _count;
+ else if (_constituent!=NULL)
+ return _constituent->getGlobalNumberingIndex(Entity) ;
+ else
+ throw MEDEXCEPTION("Entity not defined !") ;
+}
+
+/*! Returns true if a connectivity exists on elements of type "Entity" */
+inline bool CONNECTIVITY::existConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity) const
+{
+ if (_entity==Entity) {
+ MESSAGE("existConnectivity : _entity==Entity="<<Entity);
+ if ((ConnectivityType==MED_NODAL)&(_nodal!=(MEDSKYLINEARRAY*)NULL))
+ return true ;
+ if ((ConnectivityType==MED_DESCENDING)&(_descending!=(MEDSKYLINEARRAY*)NULL))
+ return true ;
+ } else if (_constituent!=NULL)
+ return _constituent->existConnectivity(ConnectivityType,Entity) ;
+ return false ;
+}
+
+/*!
+Return an array which contain CELLMODEL foreach element type present in connectivity for given medEntityMesh (similar as getGeometricTypes)
+
+Throw an execption if the given entity is not defined or if the array is not defined.
+*/
+inline CELLMODEL * CONNECTIVITY::getCellsTypes(medEntityMesh Entity) const
+{
+ if (Entity == _entity)
+ if (_type!=NULL)
+ return _type ;
+ else
+ throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) : CELLMODEL array is not defined !");
+ else
+ if (_constituent != NULL)
+ return _constituent->getCellsTypes(Entity) ;
+ else
+ throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) : Not found Entity !");
+}
+
+#endif /* CONNECTIVITY_HXX */
+
--- /dev/null
+#include "MEDMEM_Coordinate.hxx"
+#include "utilities.h"
+
+/*! This class contains coordinates of the nodes */
+//----------------------------------------------------------//
+COORDINATE::COORDINATE():_coordinate((MEDARRAY<double>*)NULL),
+ _coordinateName((string*)NULL),
+ _coordinateUnit((string*)NULL),
+ _nodeNumber((int*)NULL)
+//----------------------------------------------------------//
+{
+ BEGIN_OF("Default Constructor COORDINATE");
+}
+
+//------------------------------------------------------------------------------//
+COORDINATE::COORDINATE(medModeSwitch Mode,int SpaceDimension, int NumberOfNodes):
+ _nodeNumber((int*)NULL)
+//------------------------------------------------------------------------------//
+{
+ BEGIN_OF("Constructor COORDINATE");
+ _coordinateName = new string[SpaceDimension] ;
+ _coordinateUnit = new string[SpaceDimension] ;
+ _coordinate = new MEDARRAY<double>(SpaceDimension,NumberOfNodes,Mode);
+}
+//----------------------//
+COORDINATE::~COORDINATE()
+//----------------------//
+{
+ MESSAGE("Debut Destructeur COORDINATE");
+ if (_coordinate!=NULL)
+ delete _coordinate ;
+ if (_coordinateName!=NULL)
+ delete[] _coordinateName ;
+ if (_coordinateUnit!=NULL)
+ delete[] _coordinateUnit ;
+ if (_nodeNumber!=NULL)
+ delete[] _nodeNumber ;
+ }
+
+/*! set the attribute _coordinate with Coordinate */
+//----------------------------------------------------------//
+void COORDINATE::setCoordinates(MEDARRAY<double> *Coordinate)
+//----------------------------------------------------------//
+{
+ _coordinate=Coordinate ;
+}
+
+/*! set the attribute _coordinateName with CoordinateName */
+//----------------------------------------------------------//
+void COORDINATE::setCoordinatesNames(string * CoordinateName)
+//----------------------------------------------------------//
+{
+ _coordinateName=CoordinateName ;
+}
+
+/*! set the attribute _coordinateUnit with CoordinateUnit */
+//----------------------------------------------------------//
+void COORDINATE::setCoordinatesUnits(string * CoordinateUnit)
+//----------------------------------------------------------//
+{
+ _coordinateUnit=CoordinateUnit ;
+}
+
+/*! set the attribute _nodeNumber with NodeNumber */
+//------------------------------------------------//
+void COORDINATE::setNodesNumbers(int * NodeNumber)
+//------------------------------------------------//
+{
+ _nodeNumber=NodeNumber ;
+}
+
+/*! returns the number of nodes defined in the mesh*/
+//-------------------------------------------------//
+int * COORDINATE::getNodesNumbers() const
+//-------------------------------------------------//
+{
+ return _nodeNumber;
+}
+
+/*! returns the mode of coordinates (FULL_INTERLACE or NO_INTERLACE) */
+//-------------------------------------------------------------------//
+const double * COORDINATE::getCoordinates (medModeSwitch Mode)
+//-------------------------------------------------------------------//
+{
+ return _coordinate->get(Mode) ;
+}
+
+/* returns the coordinate of node Number on axis Axis */
+//----------------------------------------------------//
+double COORDINATE::getCoordinate(int Number,int Axis)
+//----------------------------------------------------//
+{
+ return _coordinate->getIJ(Number,Axis) ;
+}
+
+/* returns all nodes coordinates from axis Axis */
+//----------------------------------------------------//
+const double * COORDINATE::getCoordinateAxis(int Axis)
+//----------------------------------------------------//
+{ //< return all nodes coordinates from axis Axis
+ return _coordinate->getI(MED_NO_INTERLACE,Axis) ;
+}
+
+/*! Returns an array with names of coordinates.
+ Example :
+ - x,y,z
+ - r,teta,phi
+ - ... */
+//--------------------------------------//
+string * COORDINATE::getCoordinatesNames()
+{
+ return _coordinateName ;
+}
+
+/* returns the name of axis Axis */
+//-------------------------------------------//
+string COORDINATE::getCoordinateName(int Axis)
+//-------------------------------------------//
+{
+ return _coordinateName[Axis-1];
+}
+
+/*! Returns an array with units of coordinates (cm, m, mm, ...)
+ It could be empty. We suppose we are IS (meter). */
+//-----------------------------------------------------//
+string * COORDINATE::getCoordinatesUnits()
+//-----------------------------------------------------//
+{
+ return _coordinateUnit ;
+}
+
+/*! Returns the unit of axis Axis */
+//------------------------------------------//
+string COORDINATE::getCoordinateUnit(int Axis)
+//------------------------------------------//
+{
+ return _coordinateUnit[Axis-1] ;
+}
+/*! Returns "CARTESIAN", "CYLINDRICAL" or "SPHERICAL"*/
+//---------------------------------------------------//
+string COORDINATE::getCoordinatesSystem() const
+//---------------------------------------------------//
+{
+ return _coordinateSystem ;
+}
--- /dev/null
+/*
+ File Coordinate.hxx
+ $Header$
+*/
+
+#ifndef COORDINATE_HXX
+#define COORDINATE_HXX
+
+#include <string>
+
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+//using namespace MED_EN;
+
+
+#include "MEDMEM_Array.hxx"
+
+class COORDINATE {
+
+protected:
+ /*! contains "CARTESIAN",
+ "CYLINDRICAL" or "SPHERICAL"*/
+ string _coordinateSystem;
+
+ // all in _coordinate object !!!
+ // int _spaceDimension;
+ // int _numberOfNodes;
+
+ /*! array of size spaceDimension*NumberOfNodes */
+ MEDARRAY<double>* _coordinate;
+ /*! array of size spaceDimension */
+ string * _coordinateName;
+ /*! array of size spaceDimension */
+ string * _coordinateUnit;
+ /*! array of size NumberOfNodes : optionnal nodes numbers */
+ int * _nodeNumber;
+
+public :
+
+ friend class MED_MESH_RDONLY_DRIVER;
+ friend class MED_MESH_WRONLY_DRIVER;
+
+
+ COORDINATE();
+ COORDINATE(medModeSwitch Mode,int SpaceDimension, int NumberOfNodes);
+ ~COORDINATE();
+
+ void setCoordinates(MEDARRAY<double> *Coordinate);
+ void setCoordinatesNames(string * CoordinateName);
+ void setCoordinatesUnits(string * CoordinateUnit);
+ void setNodesNumbers(int * NodeNumber);
+
+ int* getNodesNumbers() const;
+ string getCoordinatesSystem() const;
+ const double * getCoordinates(medModeSwitch Mode);
+ double getCoordinate(int Number,int Axis);
+ // return coordinate of node number Number, on axis Axis (1: X, 2: Y, 3: Z)
+ const double * getCoordinateAxis(int Axis);
+ // return all nodes coordinates from axis Axis
+ string * getCoordinatesNames();
+ string getCoordinateName(int Axis);
+ string * getCoordinatesUnits();
+ string getCoordinateUnit(int Axis);
+};
+
+#endif /* COORDINATE_HXX */
--- /dev/null
+#include "MEDMEM_DriversDef.hxx"
+
+namespace MED_FR {
+
+// Returns the (string) name of the geometry of
+// an element given by a med_geometrie_element value
+GEO_NAME::GEO_NAME () : map<int,string>()
+{
+ map<int,string> &table = (map<int,string>&)*this ;
+ table[(int)0 ] = "MED_NONE" ;
+ table[(int)MED_POINT1 ] = "MED_POINT1" ;
+ table[(int)MED_SEG2 ] = "MED_SEG2" ;
+ table[(int)MED_SEG3 ] = "MED_SEG3" ;
+ table[(int)MED_TRIA3 ] = "MED_TRIA3" ;
+ table[(int)MED_TRIA6 ] = "MED_TRIA6" ;
+ table[(int)MED_QUAD4 ] = "MED_QUAD4" ;
+ table[(int)MED_QUAD8 ] = "MED_QUAD8" ;
+ table[(int)MED_TETRA4 ] = "MED_TETRA4" ;
+ table[(int)MED_TETRA10] = "MED_TETRA10";
+ table[(int)MED_HEXA8 ] = "MED_HEXA8" ;
+ table[(int)MED_HEXA20 ] = "MED_HEXA20" ;
+ table[(int)MED_PENTA6 ] = "MED_PENTA6" ;
+ table[(int)MED_PENTA15] = "MED_PENTA15";
+ table[(int)MED_PYRA5 ] = "MED_PYRA5" ;
+ table[(int)MED_PYRA13 ] = "MED_PYRA13" ;
+ assert( table.find( (int)MED_PYRA13 ) != table.end() ) ;
+}
+
+string & GEO_NAME::operator[]( const med_geometrie_element &c ) const
+{
+ map<int,string> &table = (map<int,string>&)*this ;
+ assert( table.find( (int)c ) != table.end() ) ;
+ return table[ (int)c ] ;
+}
+
+
+// Returns the (string) name of the type of
+// an entity given by a med_entite_maillage value
+
+ENT_NAME:: ENT_NAME () : map<int,string>()
+{
+ map<int,string> &table = (map<int,string>&)*this ;
+ table[(int)MED_MAILLE ] = "MED_MAILLE";
+ table[(int)MED_FACE ] = "MED_FACE";
+ table[(int)MED_ARETE ] = "MED_ARETE";
+ table[(int)MED_NOEUD ] = "MED_NOEUD";
+}
+string & ENT_NAME::operator[]( const med_entite_maillage &c ) const
+{
+ map<int,string> &table = (map<int,string>&)*this ;
+ assert( table.find( (int)c ) != table.end() ) ;
+ return table[ (int)c ] ;
+}
+
+MESH_ENTITIES::MESH_ENTITIES () : map<int, const list<med_geometrie_element> >()
+{
+ // Override the const declaration in order to used the find method below
+ map<int, const list<med_geometrie_element> > &table = (map<int, const list<med_geometrie_element> >&)*this ;
+
+ // Initialize the value associated with the ROUGE_ key ( use the private operator = )
+ {
+ const med_geometrie_element T[] = { 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 };
+ static const list<med_geometrie_element> geomList(T,T+sizeof(T)/sizeof(med_geometrie_element));
+ (*this)[MED_MAILLE] = geomList;
+ }
+
+ {
+ const med_geometrie_element T[] = { MED_TRIA3,MED_TRIA6, MED_QUAD4,MED_QUAD8 };
+ static const list<med_geometrie_element> geomList(T,T+sizeof(T)/sizeof(med_geometrie_element));
+ (*this)[MED_FACE] = geomList;
+ }
+
+ {
+ const med_geometrie_element T[] = { MED_SEG2,MED_SEG3 };
+ static const list<med_geometrie_element> geomList(T,T+sizeof(T)/sizeof(med_geometrie_element));
+ (*this)[MED_ARETE] = geomList;
+ }
+
+ {
+ // const med_geometrie_element T[] = { MED_NONE };
+ const med_geometrie_element T[] = { (med_geometrie_element)0 };
+ static const list<med_geometrie_element> geomList(T,T+sizeof(T)/sizeof(med_geometrie_element));
+ (*this)[MED_NOEUD] = geomList;
+ }
+
+}
+
+const list<med_geometrie_element> & MESH_ENTITIES::operator[]( const med_entite_maillage &c ) const
+{
+ map<int,const list<med_geometrie_element> > &table = (map<int,const list<med_geometrie_element> >&)*this ;
+ // Verify the object already exists in the map
+ assert( table.find( (int)c ) != table.end() ) ;
+ return table[ (int)c ] ;
+}
+
+// This operator is used to initialize class objects of type const list<med_geometrie_element>
+list<med_geometrie_element> & MESH_ENTITIES::operator[]( const med_entite_maillage &c )
+{
+ return (list<med_geometrie_element> &) this->map<int,const list<med_geometrie_element> >::operator[]( (int)c) ;
+}
+
+} // End Of NameSpace MED_FR
--- /dev/null
+# ifndef DRIVERS_DEF_HXX
+# define DRIVERS_DEF_HXX
+
+// STL
+# include <string>
+# include <list>
+# include <map>
+
+using namespace std ;
+
+#include "MEDMEM_define.hxx"
+namespace MED_FR {
+
+// Returns the (string) name of the geometry of
+// an element given by a med_geometrie_element value
+class GEO_NAME : public map<int,string>
+{
+
+public :
+
+ GEO_NAME ();
+
+ string & operator[]( const MED_FR::med_geometrie_element &c ) const;
+} ;
+
+
+static const GEO_NAME geoNames ;
+
+// Returns the (string) name of the type of
+// an entity given by a med_entite_maillage value
+class ENT_NAME : public map<int,string>
+{
+
+public :
+ ENT_NAME ();
+ string & operator[]( const MED_FR::med_entite_maillage &c ) const;
+} ;
+
+static const ENT_NAME entNames ;
+
+class MESH_ENTITIES : public map<int, const list<MED_FR::med_geometrie_element> >
+{
+
+public :
+
+ MESH_ENTITIES ();
+ const list<MED_FR::med_geometrie_element> & operator[]( const MED_FR::med_entite_maillage &c ) const;
+
+private:
+ // This operator is used to initialize class objects of type const list<med_geometrie_element>
+ list<MED_FR::med_geometrie_element> & operator[]( const MED_FR::med_entite_maillage &c );
+
+} ;
+
+static const MESH_ENTITIES meshEntities ;
+
+} // End Of NameSpace MED_FR
+
+#endif
+
--- /dev/null
+/*
+ File MedException.cxx
+ $Header$
+*/
+
+using namespace std;
+
+#include "utilities.h"
+#include "MEDMEM_Exception.hxx"
+
+extern "C"
+{
+#include <math.h>
+#include <stdio.h>
+#include <string.h>
+}
+
+
+const char* duplicate( const char *const str ) ;
+
+const char* duplicate( const char *const str )
+{
+ ASSERT(str!=NULL) ;
+ const size_t length = strlen( str ) ;
+ ASSERT(length>0) ;
+ char *new_str = new char[ 1+length ] ;
+ ASSERT(new_str) ;
+ strcpy( new_str , str ) ;
+ return new_str ;
+}
+
+MEDEXCEPTION::MEDEXCEPTION( void ): exception() , _text(0)
+{
+ MESSAGE( "You must user the standard builder : MEDEXCEPTION::MEDEXCEPTION( const char *text )" ) ;
+ INTERRUPTION(1) ;
+}
+
+
+const char *makeText( const char *text, const char *fileName, const unsigned int lineNumber )
+{
+ char *newText = 0 ;
+
+ ASSERT(text) ;
+ const size_t l1 = 1+strlen(text) ;
+ ASSERT(l1>1) ;
+
+ const char* prefix = "MED Exception" ;
+ const size_t l0 = 2+strlen(prefix) ;
+
+ if ( fileName )
+ {
+ const size_t l2 = 4+strlen(fileName) ;
+ ASSERT(l2>4) ;
+
+ ASSERT(lineNumber>=1) ;
+ const size_t l3 = 4+int(log10(float(lineNumber))) ;
+
+ newText = new char [ 1+l0+l1+l2+l3 ] ;
+ sprintf( newText , "%s in %s [%u] : %s" , prefix, fileName, lineNumber, text ) ;
+ }
+ else
+ {
+ newText = new char [ 1+l0+l1 ] ;
+ sprintf( newText , "%s : %s" , prefix, text ) ;
+ }
+ ASSERT(newText) ;
+ return newText ;
+}
+
+
+MEDEXCEPTION::MEDEXCEPTION( const char *text, const char *fileName, const unsigned int lineNumber ) : exception(), _text( makeText( text , fileName , lineNumber ) )
+{
+ MESSAGE(_text);
+}
+
+
+MEDEXCEPTION::~MEDEXCEPTION() throw ()
+{
+ if ( _text )
+ {
+ delete [] _text ;
+ char *& txt = (char*)_text ;
+ txt = 0 ;
+ }
+ ASSERT(_text==NULL) ;
+}
+
+
+
+MEDEXCEPTION::MEDEXCEPTION( const MEDEXCEPTION &ex ): _text(duplicate(ex._text))
+{
+ ;
+}
+
+
+ostream & operator<<( ostream &os , const MEDEXCEPTION &ex )
+{
+ os << ex._text ;
+ return os ;
+}
+
+
+
+const char* MEDEXCEPTION::what( void ) const throw ()
+{
+ return _text ;
+}
+
+
+// -------------------- class MED_DRIVER_NOT_FOUND_EXCEPTION
+
+
+MED_DRIVER_NOT_FOUND_EXCEPTION::MED_DRIVER_NOT_FOUND_EXCEPTION(const MED_DRIVER_NOT_FOUND_EXCEPTION &ex ):MEDEXCEPTION ( ex ) {};
+
+
+MED_DRIVER_NOT_FOUND_EXCEPTION::MED_DRIVER_NOT_FOUND_EXCEPTION
+(
+ const char *text, const char *fileName=0,
+ const unsigned int lineNumber=0
+ ) : MEDEXCEPTION(text, fileName, lineNumber) {};
+
+MED_DRIVER_NOT_FOUND_EXCEPTION::~MED_DRIVER_NOT_FOUND_EXCEPTION() throw (){};
--- /dev/null
+/*
+ File MedException.hxx
+ $Header$
+*/
+
+#ifndef MEDEXCEPTION_HXX
+#define MEDEXCEPTION_HXX
+
+using namespace std;
+
+#include <exception>
+#include <iostream>
+
+#ifndef LOCALIZED
+#define LOCALIZED(message) message , __FILE__ , __LINE__
+#endif
+
+#define MED_EXCEPTION MEDEXCEPTION
+class MEDEXCEPTION : public exception
+{
+private :
+ MEDEXCEPTION(void);
+
+protected :
+ const char* _text ;
+
+public :
+ MEDEXCEPTION(const char *text, const char *fileName=0,
+ const unsigned int lineNumber=0 );
+ MEDEXCEPTION(const MEDEXCEPTION &ex );
+ ~MEDEXCEPTION() throw ();
+ friend ostream & operator<< (ostream &os, const MEDEXCEPTION &ex );
+ virtual const char *what(void) const throw () ;
+} ;
+
+
+class MED_DRIVER_NOT_FOUND_EXCEPTION : public MEDEXCEPTION
+{
+private :
+ MED_DRIVER_NOT_FOUND_EXCEPTION(void);
+
+public :
+ MED_DRIVER_NOT_FOUND_EXCEPTION(const char *text, const char *fileName=0,
+ const unsigned int lineNumber=0 );
+ MED_DRIVER_NOT_FOUND_EXCEPTION(const MED_DRIVER_NOT_FOUND_EXCEPTION &ex );
+ ~MED_DRIVER_NOT_FOUND_EXCEPTION() throw();
+
+};
+
+#endif /* MEDEXCEPTION_HXX */
--- /dev/null
+/*
+ File MEDMEM_Family.cxx
+ $Header$
+*/
+
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Family.hxx"
+
+FAMILY::FAMILY():_identifier(0), _numberOfAttribute(0),
+ _attributeIdentifier((int*)NULL),_attributeValue((int*)NULL), _attributeDescription((string*)NULL),
+ _numberOfGroup(0), _groupName((string*)NULL)
+{
+ MESSAGE("FAMILY::FAMILY()");
+};
+
+FAMILY::FAMILY(MESH* Mesh, int Identifier, string Name, int NumberOfAttribute,
+ int *AttributeIdentifier, int *AttributeValue, string AttributeDescription,
+ int NumberOfGroup, string GroupName
+ ): SUPPORT(Mesh,Name),
+ _identifier(Identifier),
+ _numberOfAttribute(NumberOfAttribute),
+ _attributeIdentifier(AttributeIdentifier),
+ _attributeValue(AttributeValue),
+ _numberOfGroup(NumberOfGroup)
+{
+ MESSAGE("FAMILY(int Identifier, string Name, int NumberOfAttribute,int *AttributeIdentifier,int *AttributeValue,string AttributeDescription,int NumberOfGroup,string GroupName, int ** Number) : "<<Identifier);
+
+ _attributeDescription=new string[_numberOfAttribute];
+ for (int i=0;i<NumberOfAttribute;i++) {
+ _attributeDescription[i].assign(AttributeDescription,i*MED_TAILLE_DESC,MED_TAILLE_DESC);
+ _attributeDescription[i].erase(strlen(_attributeDescription[i].c_str()));
+ //SCRUTE(_attributeDescription[i]);
+ }
+
+ _groupName=new string[_numberOfGroup];
+ for (int i=0;i<NumberOfGroup;i++) {
+ _groupName[i].assign(GroupName,i*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
+ _groupName[i].erase(strlen(_groupName[i].c_str()));
+ //SCRUTE(_groupName[i]);
+ }
+
+ // well, we must set SUPPORT attribut
+ _description = "FAMILY" ;
+ // on which geometric type :
+ bool Find = false ;
+
+
+ // ************************ NODES RELATED PART *************************************************
+ // Scan every node family number <NodeFamilyNumber[i]> in order to create
+ // the list <tmp_NodesList> of node numbers <i+1> belonging to the family <_identifier>
+ int NumberOfNodes = _mesh->getNumberOfNodes();
+ int NumberOfNodesInFamily = 0 ;
+ int * NodeFamilyNumber = _mesh->getMEDArrayNodeFamily() ; // EF : TEMPORAIRE !!
+ int * tmp_NodesList = new int[NumberOfNodes] ; // Un peu brutal...., oui mais ce n'est qu'un tableau de travail !
+ for (int i=0; i<NumberOfNodes; i++)
+ if ( _identifier == NodeFamilyNumber[i] ) {
+ tmp_NodesList[NumberOfNodesInFamily]=i+1 ;
+ NumberOfNodesInFamily++;
+ }
+
+ // If we found nodes set the family attributes adequatly
+ if (NumberOfNodesInFamily>0) {
+
+ Find = true ;
+
+ _entity = MED_NODE ;
+ _numberOfGeometricType = 1 ;
+ _geometricType = new medGeometryElement[1] ;
+ _geometricType[0]=MED_NONE ;
+
+ // family on all NODE
+ if (NumberOfNodesInFamily==NumberOfNodes)
+ _isOnAllElts = true ;
+ else {
+ _isOnAllElts= false ;
+ _numberOfEntities = new int[1] ;
+ _numberOfEntities[0]=NumberOfNodesInFamily ;
+ _totalNumberOfEntities=NumberOfNodesInFamily;
+
+ _number=new MEDSKYLINEARRAY(1,NumberOfNodesInFamily) ;
+ int * NumberIndex = _number->getIndex();
+ int * NumberValue = _number->getValue();
+ NumberIndex[0]=1; //set the MEDSKYLINEARRAY Index table
+ NumberIndex[1]=1+NumberOfNodesInFamily; //set the MEDSKYLINEARRAY Index table
+ for(int i=0; i<NumberOfNodesInFamily; i++) // OH LA LA...
+ NumberValue[i]=tmp_NodesList[i] ; // RESIZE de tmp_NodesList serait plus efficace !!!!!!!!
+ // PG : pas de problème, si ca marche. Il faudra déplacer le delete !
+ }
+ }
+ delete[] tmp_NodesList ;
+
+
+
+ // ************************ CELLS RELATED PART *************************************************
+ // If we previously found nodes in our family don't scan the CELLS because a
+ // family contains different geometic types of only one entity type.
+ // ?? Scan every cell family number <NodeFamilyNumber[i]> in order to create
+ // ?? the list <tmp_NodesList> of node numbers <i+1> belonging to the family <_identifier>
+ if (!Find) {
+
+ // Get cell types information from <_mesh>
+ int numberOfCellTypes = _mesh->getNumberOfTypes(MED_CELL) ;
+ medGeometryElement * cellTypes = _mesh->getTypes(MED_CELL) ;
+
+ int * numberOfCellsInFamily = new int[numberOfCellTypes] ;
+ int numberOfCellTypesInFamily = 0 ;
+
+ medGeometryElement * tmp_CellsTypes = new medGeometryElement[numberOfCellTypes];
+ int ** tmp_CellsLists = new int*[numberOfCellTypes] ;
+ int * GeometricTypeNumber = new int[numberOfCellTypes] ;
+ int ** CellFamilyNumber = _mesh->getMEDArrayCellFamily(); // EF: TEMPORAIRE
+ int * GlobalNumberingIndex = _mesh->getGlobalNumberingIndex(MED_CELL);
+
+ // we search for all cell in this family
+ for (int cellTypeNumber=0; cellTypeNumber < numberOfCellTypes; cellTypeNumber++) {
+
+ int NumberOfCells = _mesh->getNumberOfElements(MED_CELL,cellTypes[cellTypeNumber]) ;
+ int NumberOfCellsInThisFamily = 0 ;
+ int * CellsOfThisFamilyNumber = CellFamilyNumber[cellTypeNumber];
+ int * tmp_CellsList = new int[NumberOfCells];
+
+ for (int i=0; i<NumberOfCells; i++)
+ if (_identifier == CellsOfThisFamilyNumber[i]) {
+ tmp_CellsList[NumberOfCellsInThisFamily]=i+GlobalNumberingIndex[cellTypeNumber] ;
+ NumberOfCellsInThisFamily++;
+ }
+
+ if (NumberOfCellsInThisFamily>0) {// we have found some cells
+ numberOfCellsInFamily[numberOfCellTypesInFamily]=NumberOfCellsInThisFamily;
+ int * CellsList=new int[NumberOfCellsInThisFamily] ;
+
+ for (int i=0;i<NumberOfCellsInThisFamily;i++)
+ CellsList[i]=tmp_CellsList[i] ; // RESIZE de tmp_NodesList serait plus efficace !!!!!!!!
+
+ tmp_CellsLists[numberOfCellTypesInFamily]=CellsList ;
+ tmp_CellsTypes[numberOfCellTypesInFamily]=cellTypes[cellTypeNumber];
+ GeometricTypeNumber[numberOfCellTypesInFamily]=cellTypeNumber+1;
+ numberOfCellTypesInFamily++;
+ }
+
+ delete[] tmp_CellsList ;
+ }
+
+ // we define all attribut in SUPPORT :
+ if (numberOfCellTypesInFamily>0) { // we have found cells
+ Find = true ;
+ _entity = MED_CELL ;
+ _numberOfGeometricType = numberOfCellTypesInFamily ;
+ _geometricType = new medGeometryElement[numberOfCellTypesInFamily] ;
+ _geometricTypeNumber = new int[numberOfCellTypesInFamily] ;
+ _isOnAllElts = false ;
+ _numberOfEntities = new int[numberOfCellTypesInFamily] ;
+ _totalNumberOfEntities=0;
+ for (int i=0; i<numberOfCellTypesInFamily; i++) {
+ _geometricType[i]=tmp_CellsTypes[i] ;
+ _geometricTypeNumber[i]=GeometricTypeNumber[i];
+ _numberOfEntities[i]=numberOfCellsInFamily[i] ;
+ _totalNumberOfEntities+=numberOfCellsInFamily[i] ;
+ }
+ delete[] numberOfCellsInFamily;
+ delete[] tmp_CellsTypes;
+ delete[] GeometricTypeNumber;
+
+ // family on all CELL ?
+ if (_totalNumberOfEntities==Mesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)) {
+ _isOnAllElts = true ;
+ delete[] _numberOfEntities ;
+ _numberOfEntities=(int*)NULL;
+ } else {
+ _number=new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities);
+ int *NumberValue=_number->getValue();
+ int *NumberIndex=_number->getIndex();
+ NumberIndex[0]=1;
+ for (int i=0; i<_numberOfGeometricType; i++) {
+ NumberIndex[i+1]=NumberIndex[i]+_numberOfEntities[i];
+ for (int j=NumberIndex[i]; j<NumberIndex[i+1]; j++)
+ NumberValue[j-1]=tmp_CellsLists[i][j-NumberIndex[i]];
+ delete[] tmp_CellsLists[i];
+ }
+ delete[] tmp_CellsLists;
+ }
+ }
+ }
+ // on face ?
+ if (!Find)
+ if ((_mesh->existConnectivity(MED_NODAL,MED_FACE))|(_mesh->existConnectivity(MED_DESCENDING,MED_FACE))) {
+ int NumberOfFacesType = _mesh->getNumberOfTypes(MED_FACE) ;
+ medGeometryElement * FacesType = _mesh->getTypes(MED_FACE) ;
+ int * NumberOfFacesInFamily = new int[NumberOfFacesType] ;
+ int NumberOfFacesTypeInFamily = 0 ;
+ medGeometryElement * tmp_FacesTypes = new medGeometryElement[NumberOfFacesType];
+ int ** tmp_FacesLists = new int*[NumberOfFacesType] ;
+ int * GeometricTypeNumber = new int[NumberOfFacesType] ;
+ int ** FaceFamilyNumber = _mesh->getMEDArrayFaceFamily();
+ int * GlobalNumberingIndex = _mesh->getGlobalNumberingIndex(MED_FACE);
+ // we search all face in this family
+ for (int FaceTypeNumber=0; FaceTypeNumber<NumberOfFacesType; FaceTypeNumber++) {
+ int NumberOfThisFaces = _mesh->getNumberOfElements(MED_FACE,FacesType[FaceTypeNumber]) ;
+ int NumberOfFacesInThisFamily = 0 ;
+ int * FaceOfThisFamilyNumber = FaceFamilyNumber[FaceTypeNumber];
+ int * tmp_FacesList = new int[NumberOfThisFaces];
+ for (int i=0; i<NumberOfThisFaces; i++)
+ if (_identifier == FaceOfThisFamilyNumber[i]) {
+ tmp_FacesList[NumberOfFacesInThisFamily]=i+GlobalNumberingIndex[FaceTypeNumber] ;
+ NumberOfFacesInThisFamily++;
+
+ SCRUTE(i);
+ SCRUTE(NumberOfFacesInThisFamily);
+
+ }
+ if (NumberOfFacesInThisFamily>0) {// we have found some faces
+ NumberOfFacesInFamily[NumberOfFacesTypeInFamily]=NumberOfFacesInThisFamily;
+ int * FacesList=new int[NumberOfFacesInThisFamily] ;
+ for (int i=0;i<NumberOfFacesInThisFamily;i++)
+ FacesList[i]=tmp_FacesList[i] ;
+ tmp_FacesLists[NumberOfFacesTypeInFamily]=FacesList ;
+ tmp_FacesTypes[NumberOfFacesTypeInFamily]=FacesType[FaceTypeNumber];
+ GeometricTypeNumber[NumberOfFacesTypeInFamily]=FaceTypeNumber+1;
+ NumberOfFacesTypeInFamily++;
+ }
+ delete[] tmp_FacesList ;
+ }
+ // we define all attribut in SUPPORT :
+ if (NumberOfFacesTypeInFamily>0) { // we have found faces
+ Find = true ;
+ _entity = MED_FACE ;
+ _numberOfGeometricType = NumberOfFacesTypeInFamily ;
+ _geometricType = new medGeometryElement[NumberOfFacesTypeInFamily] ;
+ _geometricTypeNumber = new int[NumberOfFacesTypeInFamily] ;
+ _isOnAllElts = false ;
+ _numberOfEntities = new int[NumberOfFacesTypeInFamily] ;
+ _totalNumberOfEntities=0;
+ for (int i=0; i<NumberOfFacesTypeInFamily; i++) {
+ _geometricType[i]=tmp_FacesTypes[i] ;
+ _geometricTypeNumber[i]=GeometricTypeNumber[i];
+ _numberOfEntities[i]=NumberOfFacesInFamily[i] ;
+ _totalNumberOfEntities+=NumberOfFacesInFamily[i] ;
+ }
+ delete[] NumberOfFacesInFamily;
+ delete[] tmp_FacesTypes;
+ delete[] GeometricTypeNumber;
+
+ // family on all FACE ?
+
+ // we suppose family is never on all face !!!!!!!!!
+ // in all case, family is only on boundary and connectivity is partial
+
+// if (_totalNumberOfEntities==Mesh->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS)) {
+// _isOnAllElts = true ;
+// delete[] _numberOfEntities ;
+// _numberOfEntities=(int*)NULL;
+// } else {
+ _number=new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities);
+ int *NumberValue=_number->getValue();
+ int *NumberIndex=_number->getIndex();
+ NumberIndex[0]=1;
+ for (int i=0; i<_numberOfGeometricType; i++) {
+ NumberIndex[i+1]=NumberIndex[i]+_numberOfEntities[i];
+ for (int j=NumberIndex[i]; j<NumberIndex[i+1]; j++)
+ NumberValue[j-1]=tmp_FacesLists[i][j-NumberIndex[i]];
+ delete[] tmp_FacesLists[i];
+ }
+ delete[] tmp_FacesLists;
+// }
+ }
+ }
+
+ // on edge ?
+ if (!Find)
+ if ((_mesh->existConnectivity(MED_NODAL,MED_EDGE))|(_mesh->existConnectivity(MED_DESCENDING,MED_EDGE))) {
+ int NumberOfEdgesType = _mesh->getNumberOfTypes(MED_EDGE) ;
+ medGeometryElement * EdgesType = _mesh->getTypes(MED_EDGE) ;
+ int * NumberOfEdgesInFamily = new int[NumberOfEdgesType] ;
+ int NumberOfEdgesTypeInFamily = 0 ;
+ medGeometryElement * tmp_EdgesTypes = new medGeometryElement[NumberOfEdgesType];
+ int ** tmp_EdgesLists = new int*[NumberOfEdgesType] ;
+ int * GeometricTypeNumber = new int[NumberOfEdgesType] ;
+ int ** EdgeFamilyNumber = _mesh->getMEDArrayEdgeFamily();
+ int * GlobalNumberingIndex = _mesh->getGlobalNumberingIndex(MED_EDGE);
+ // we search all edge in this family
+ for (int EdgeTypeNumber=0; EdgeTypeNumber<NumberOfEdgesType; EdgeTypeNumber++) {
+ int NumberOfThisEdges = _mesh->getNumberOfElements(MED_EDGE,EdgesType[EdgeTypeNumber]) ;
+ int NumberOfEdgesInThisFamily = 0 ;
+ int * EdgeOfThisFamilyNumber = EdgeFamilyNumber[EdgeTypeNumber];
+ int * tmp_EdgesList = new int[NumberOfThisEdges];
+ for (int i=0; i<NumberOfThisEdges; i++)
+ if (_identifier == EdgeOfThisFamilyNumber[i]) {
+ tmp_EdgesList[NumberOfEdgesInThisFamily]=i+GlobalNumberingIndex[EdgeTypeNumber] ;
+ NumberOfEdgesInThisFamily++;
+ }
+ if (NumberOfEdgesInThisFamily>0) {// we have found some edges
+ NumberOfEdgesInFamily[NumberOfEdgesTypeInFamily]=NumberOfEdgesInThisFamily;
+ int * EdgesList=new int[NumberOfEdgesInThisFamily] ;
+ for (int i=0;i<NumberOfEdgesInThisFamily;i++)
+ EdgesList[i]=tmp_EdgesList[i] ;
+ tmp_EdgesLists[NumberOfEdgesTypeInFamily]=EdgesList ;
+ tmp_EdgesTypes[NumberOfEdgesTypeInFamily]=EdgesType[EdgeTypeNumber];
+ GeometricTypeNumber[NumberOfEdgesTypeInFamily]=EdgeTypeNumber+1;
+ NumberOfEdgesTypeInFamily++;
+ }
+ delete[] tmp_EdgesList ;
+ }
+ // we define all attribut in SUPPORT :
+ if (NumberOfEdgesTypeInFamily>0) { // we have found edges
+ Find = true ;
+ _entity = MED_EDGE ;
+ _numberOfGeometricType = NumberOfEdgesTypeInFamily ;
+ _geometricType = new medGeometryElement[NumberOfEdgesTypeInFamily] ;
+ _geometricTypeNumber = new int[NumberOfEdgesTypeInFamily] ;
+ _isOnAllElts = false ;
+ _numberOfEntities = new int[NumberOfEdgesTypeInFamily] ;
+ _totalNumberOfEntities=0;
+ for (int i=0; i<NumberOfEdgesTypeInFamily; i++) {
+ _geometricType[i]=tmp_EdgesTypes[i] ;
+ _geometricTypeNumber[i]=GeometricTypeNumber[i];
+ _numberOfEntities[i]=NumberOfEdgesInFamily[i] ;
+ _totalNumberOfEntities+=NumberOfEdgesInFamily[i] ;
+ }
+ delete[] NumberOfEdgesInFamily;
+ delete[] tmp_EdgesTypes;
+ delete[] GeometricTypeNumber;
+
+ // family on all EDGE ?
+
+ // we suppose family is never on all edge !!!!!!!!!
+ // in all case, family is only on boundary and connectivity is partial
+
+// if (_totalNumberOfEntities==Mesh->getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS)) {
+// _isOnAllElts = true ;
+// delete[] _numberOfEntities ;
+// _numberOfEntities=(int*)NULL;
+// } else {
+ _number=new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities);
+ int *NumberValue=_number->getValue();
+ int *NumberIndex=_number->getIndex();
+ NumberIndex[0]=1;
+ for (int i=0; i<_numberOfGeometricType; i++) {
+ NumberIndex[i+1]=NumberIndex[i]+_numberOfEntities[i];
+ for (int j=NumberIndex[i]; j<NumberIndex[i+1]; j++)
+ NumberValue[j-1]=tmp_EdgesLists[i][j-NumberIndex[i]];
+ delete[] tmp_EdgesLists[i];
+ }
+ delete[] tmp_EdgesLists;
+// }
+ }
+ }
+ // That's all !
+
+ // if not find : no entity in familly !!!
+ if (!Find) {
+ _numberOfGeometricType = 0 ;
+ _isOnAllElts = false ;
+ MESSAGE ("FAMILY() : No entity found !") ;
+ } else { // set gauss point number to be equal one !
+ _numberOfGaussPoint = new int[_numberOfGeometricType] ;
+ for (int i=0; i<_numberOfGeometricType; i++)
+ _numberOfGaussPoint[i]=1 ;
+ }
+};
+
+FAMILY::~FAMILY()
+{
+ MESSAGE("~FAMILY()");
+ if(_attributeIdentifier!=NULL)
+ delete[] _attributeIdentifier;
+ if(_attributeValue!=NULL)
+ delete[] _attributeValue;
+ if(_attributeDescription!=NULL)
+ delete[] _attributeDescription;
+ if(_groupName!=NULL)
+ delete[] _groupName;
+};
+
+FAMILY & FAMILY::operator=(const FAMILY &fam)
+{
+ MESSAGE("FAMILY::operator=");
+ _identifier = fam._identifier;
+ _numberOfAttribute = fam._numberOfAttribute;
+ _attributeIdentifier = fam._attributeIdentifier;
+ _attributeValue = fam._attributeValue;
+ _attributeDescription = fam._attributeDescription;
+ _numberOfGroup = fam._numberOfGroup;
+ _groupName = fam._groupName;
+ return *this;
+};
--- /dev/null
+#ifndef FAMILY_HXX
+#define FAMILY_HXX
+
+#include <string>
+#include "MEDMEM_Support.hxx"
+
+class FAMILY : public SUPPORT
+{
+protected :
+ /*! Identifier of the family in the mesh
+ Note : There is precisely one for each family. */
+ int _identifier ;
+ /*! Number of attribute of the family */
+ int _numberOfAttribute ;
+ /*! Array of all attributes' identifiers.
+ There is one for each attribute. */
+ int * _attributeIdentifier ;
+ /*! Array of all attributes' values.
+ There is one for each attribute. */
+ int * _attributeValue ;
+ /*! Array of all attributes' descriptions.
+ There is one for each attribute. */
+ string * _attributeDescription ;
+
+ /*! Number of the group the family belongs to */
+ int _numberOfGroup ;
+ /*! Name of the group the family belongs to */
+ string * _groupName ;
+
+public:
+ FAMILY();
+
+ // constructor to use with med driver
+ FAMILY(MESH* Mesh, int Identifier, string Name, int NumberOfAttribute,int *AttributeIdentifier,int *AttributeValue,string AttributeDescription,int NumberOfGroup,string GroupName) ;
+
+ ~FAMILY();
+ FAMILY & operator=(const FAMILY &fam);
+
+ inline void setIdentifier (int Identifier);
+ inline void setNumberOfAttributes (int NumberOfAttribute);
+ inline void setAttributesIdentifiers (int * AttributeIdentifier);
+ inline void setAttributesValues (int * AttributeValue);
+ inline void setAttributesDescriptions (string * AttributeDescription);
+ inline void setNumberOfGroups (int NumberOfGroups);
+ inline void setGroupsNames (string * GroupName);
+
+ inline int getIdentifier() const;
+ inline int getNumberOfAttributes() const;
+ inline int * getAttributesIdentifiers() const;
+ inline int * getAttributesValues() const;
+ inline string * getAttributesDescriptions() const;
+ inline int getNumberOfGroups() const;
+ inline string * getGroupsNames() const;
+
+ // A FAIRE : VERIFIER LA VALIDITE DES PARAMETRES !
+ inline int getAttributeIdentifier(int i) const;
+ inline int getAttributeValue(int i) const;
+ inline string getAttributeDescription(int i) const;
+ inline string getGroupName(int i) const;
+};
+
+// inline methods :
+
+/* Set the attribute _identifier to Identifier. */
+//----------------------------------------------
+inline void FAMILY::setIdentifier(int Identifier)
+//----------------------------------------------
+{
+ _identifier = Identifier;
+}
+
+/* Set the attribute _numberOfAttribute to NumberOfAttribute. */
+//--------------------------------------------------------------
+inline void FAMILY::setNumberOfAttributes(int NumberOfAttribute)
+//--------------------------------------------------------------
+{
+ _numberOfAttribute = NumberOfAttribute;
+}
+
+/* Set the attribute _attributeIdentifier to AttributeIdentifier. */
+//---------------------------------------------------------------------
+inline void FAMILY::setAttributesIdentifiers(int * AttributeIdentifier)
+//---------------------------------------------------------------------
+{
+ _attributeIdentifier = AttributeIdentifier ;
+}
+
+/* Set the attribute _attributeValue to AttributeValue. */
+//-----------------------------------------------------------
+inline void FAMILY::setAttributesValues(int * AttributeValue)
+//-----------------------------------------------------------
+{
+ _attributeValue = AttributeValue ;
+}
+
+/* Set the attribute _identifier to Identifier. */
+//--------------------------------------------------------------------------
+inline void FAMILY::setAttributesDescriptions(string * AttributeDescription)
+//--------------------------------------------------------------------------
+{
+ _attributeDescription = AttributeDescription ;
+}
+
+/* Set the attribute _identifier to Identifier. */
+//-------------------------------------------------------
+inline void FAMILY::setNumberOfGroups(int NumberOfGroups)
+//-------------------------------------------------------
+{
+ _numberOfGroup = NumberOfGroups ;
+}
+
+/* Set the attribute _identifier to Identifier. */
+//----------------------------------------------------
+inline void FAMILY::setGroupsNames(string * GroupName)
+//----------------------------------------------------
+{
+ _groupName = GroupName ;
+}
+//--------------------------------------
+inline int FAMILY::getIdentifier() const
+//--------------------------------------
+{
+ return _identifier ;
+}
+//----------------------------------------------
+inline int FAMILY::getNumberOfAttributes() const
+//----------------------------------------------
+{
+ return _numberOfAttribute ;
+}
+//---------------------------------------------------
+inline int * FAMILY::getAttributesIdentifiers() const
+//---------------------------------------------------
+{
+ return _attributeIdentifier ;
+}
+//----------------------------------------------------
+inline int FAMILY::getAttributeIdentifier(int i) const
+//----------------------------------------------------
+{
+ return _attributeIdentifier[i-1] ;
+}
+//----------------------------------------------
+inline int * FAMILY::getAttributesValues() const
+//----------------------------------------------
+{
+ return _attributeValue ;
+}
+//-----------------------------------------------
+inline int FAMILY::getAttributeValue(int i) const
+//-----------------------------------------------
+{
+ return _attributeValue[i-1] ;
+}
+//-------------------------------------------------------
+inline string * FAMILY::getAttributesDescriptions() const
+//-------------------------------------------------------
+{
+ return _attributeDescription ;
+}
+//--------------------------------------------------------
+inline string FAMILY::getAttributeDescription(int i) const
+//--------------------------------------------------------
+{
+ return _attributeDescription[i-1] ;
+}
+//------------------------------------------
+inline int FAMILY::getNumberOfGroups() const
+//------------------------------------------
+{
+ return _numberOfGroup;
+}
+//--------------------------------------------
+inline string * FAMILY::getGroupsNames() const
+//--------------------------------------------
+{
+ return _groupName ;
+}
+//---------------------------------------------
+inline string FAMILY::getGroupName(int i) const
+//---------------------------------------------
+{
+ return _groupName[i-1] ;
+}
+
+
+#endif /* FAMILY_HXX */
--- /dev/null
+#include "MEDMEM_Field.hxx"
+
+// ---------------------------------
+// FIELD_ : Constructors
+// ---------------------------------
+FIELD_::FIELD_():
+ _name(""), _description(""), _support((SUPPORT *)NULL),
+ _numberOfComponents(0), _componentsTypes((int *)NULL),
+ _componentsNames((string *)NULL),
+ _componentsDescriptions((string *)NULL),
+ _componentsUnits((UNIT*)NULL),
+ _MEDComponentsUnits((string *)NULL),
+ _iterationNumber(-1),_time(0.0),_orderNumber(-1)
+{
+ MESSAGE("Constructeur FIELD_ sans parametre");
+}
+
+FIELD_::FIELD_(const SUPPORT * Support, const int NumberOfComponents):
+ _name(""), _description(""), _support(Support),
+ _numberOfComponents(NumberOfComponents),
+ _iterationNumber(-1),_time(0.0),_orderNumber(-1)
+{
+ MESSAGE("FIELD_(const SUPPORT * Support, const int NumberOfComponents)");
+
+ _componentsTypes = new int[NumberOfComponents] ;
+ _componentsNames = new string[NumberOfComponents];
+ _componentsDescriptions = new string[NumberOfComponents];
+ _componentsUnits = new UNIT[NumberOfComponents];
+ _MEDComponentsUnits = new string[NumberOfComponents];
+ for(int i=0;i<NumberOfComponents;i++) {
+ _componentsTypes[i] = 0 ;
+ }
+}
+
+FIELD_::FIELD_(const FIELD_ &m)
+{
+ _name = m._name;
+ _description = m._description;
+ _support = m._support;
+ _numberOfComponents = m._numberOfComponents;
+ _componentsTypes = m._componentsTypes;
+ _componentsNames = m._componentsNames;
+ _componentsDescriptions = m._componentsDescriptions;
+ _componentsUnits = m._componentsUnits;
+ _MEDComponentsUnits = m._MEDComponentsUnits;
+ _iterationNumber = m._iterationNumber;
+ _time = m._time;
+ _orderNumber = m._orderNumber;
+ _valueType = m._valueType;
+}
+
+FIELD_::~FIELD_()
+{
+ MESSAGE("~FIELD_()");
+ if ( _componentsTypes !=NULL)
+ delete[] _componentsTypes ;
+ if ( _componentsNames !=NULL)
+ delete[] _componentsNames ;
+ if ( _componentsDescriptions !=NULL)
+ delete[] _componentsDescriptions ;
+ if ( _componentsUnits !=NULL)
+ delete[] _componentsUnits ;
+ if ( _MEDComponentsUnits !=NULL)
+ delete[] _MEDComponentsUnits ;
+}
+
+// void FIELD_::setIterationNumber (int IterationNumber) {};
+// void FIELD_::setOrderNumber (int OrderNumber) {};
+// void FIELD_::setFieldName (string& fieldName) {};
+
+void FIELD_::rmDriver (int index) {};
+int FIELD_::addDriver (driverTypes driverType,
+ const string & fileName,
+ const string & driverFieldName) {} ;
+int FIELD_::addDriver (GENDRIVER & driver) {};
+void FIELD_::write (const GENDRIVER &) {};
+
+// void FIELD_::setValueType(med_type_champ ValueType) {};
+// med_type_champ FIELD_::getValueType() {};
--- /dev/null
+/*
+ File Field.hxx
+ $Header$
+*/
+
+#ifndef FIELD_HXX
+#define FIELD_HXX
+
+#include <vector>
+
+#include "utilities.h"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Unit.hxx"
+#include "MEDMEM_Array.hxx"
+#include "MEDMEM_GenDriver.hxx"
+
+#include "MEDMEM_MedFieldDriver.hxx"
+
+// template <class T> class MED_FIELD_RDONLY_DRIVER;
+// template <class T> class MED_FIELD_WRONLY_DRIVER;
+// template <class T> class MED_FIELD_RDWR_DRIVER;
+
+using namespace MED_EN;
+
+//class GENDRIVER;
+class FIELD_ // GENERIC POINTER TO a template <class T> class FIELD
+{
+
+protected:
+
+ string _name ;
+ string _description ;
+ const SUPPORT * _support ;
+ int _numberOfComponents ;
+ int * _componentsTypes ; // array of size _numberOfComponents
+ // (constant, scalar, vector, tensor)
+ // we could use an array of integer to store
+ // numbers of values
+ // 1 for scalar,
+ // space dimension for vector,
+ // space dimension square for tensor.
+ // so numbers of values per entities are
+ // sum of _componentsTypes array
+ // Do not use yet! All type are scalar !
+ string * _componentsNames; // array of size _numberOfComponents
+ string * _componentsDescriptions; // array of size _numberOfComponents
+ UNIT * _componentsUnits; // array of size _numberOfComponents
+ string * _MEDComponentsUnits; // array of size _numberOfComponents :
+ // get unit from med file
+
+ int _iterationNumber ;
+ double _time;
+ int _orderNumber ;
+
+ /*MED_EN::*/med_type_champ _valueType ;
+
+public:
+
+ FIELD_ ();
+ FIELD_(const SUPPORT * Support, const int NumberOfComponents);
+ FIELD_(const FIELD_ &m);
+
+ ~FIELD_();
+
+// virtual void setIterationNumber (int IterationNumber);
+// virtual void setOrderNumber (int OrderNumber);
+// virtual void setFieldName (string& fieldName);
+
+ virtual void rmDriver(int index);
+ virtual int addDriver(driverTypes driverType,
+ const string & fileName,
+ const string & driverFieldName) ;
+ virtual int addDriver(GENDRIVER & driver);
+ virtual void write(const GENDRIVER &);
+
+ // virtual void getValueType (MED_FR::med_type_champ ValueType) ;
+ // virtual void setValueType (/*MED_EN::*/med_type_champ ValueType) ;
+ // virtual med_type_champ getValueType () ;
+
+ inline void setName(string Name);
+ inline string getName() const;
+ inline void setDescription(string Description);
+ inline string getDescription()const;
+ inline const SUPPORT * getSupport() const;
+ inline void setSupport(SUPPORT * support);
+ inline void setNumberOfComponents(int NumberOfComponents);
+ inline int getNumberOfComponents() const;
+ // inline void setComponentType(int *ComponentType);
+ // inline int * getComponentType() const;
+ // inline int getComponentTypeI(int i) const;
+ inline void setComponentsNames(string * ComponentsNames);
+ inline void setComponentName(int i, string ComponentName);
+ inline string * getComponentsNames() const;
+ inline string getComponentName(int i) const;
+ inline void setComponentsDescriptions(string *ComponentsDescriptions);
+ inline void setComponentDescription(int i, string ComponentDescription);
+ inline string * getComponentsDescriptions() const;
+ inline string getComponentDescription(int i) const;
+
+ // provisoire : en attendant de regler le probleme des unites !
+ inline void setComponentsUnits(UNIT * ComponentsUnits);
+ inline UNIT * getComponentsUnits() const;
+ inline UNIT * getComponentUnit(int i) const;
+ inline void setMEDComponentsUnits(string * MEDComponentsUnits);
+ inline void setMEDComponentUnit(int i, string MEDComponentUnit);
+ inline string * getMEDComponentsUnits() const;
+ inline string getMEDComponentUnit(int i) const;
+
+ inline void setIterationNumber(int IterationNumber);
+ inline int getIterationNumber() const;
+ inline void setTime(double Time);
+ inline double getTime() const;
+ inline void setOrderNumber(int OrderNumber);
+ inline int getOrderNumber() const;
+
+ inline void setValueType (/*MED_EN::*/med_type_champ ValueType) ;
+ inline /*MED_EN::*/med_type_champ getValueType () ;
+
+};
+
+// ---------------------------------
+// Implemented Methods : constructor
+// ---------------------------------
+
+// -----------------
+// Methodes Inline
+// -----------------
+
+inline void FIELD_::setName(string Name)
+{
+ _name=Name;
+}
+inline string FIELD_::getName() const
+{
+ return _name;
+}
+inline void FIELD_::setDescription(string Description)
+{
+ _description=Description;
+}
+inline string FIELD_::getDescription() const
+{
+ return _description;
+}
+inline void FIELD_::setNumberOfComponents(int NumberOfComponents)
+{
+ _numberOfComponents=NumberOfComponents;
+}
+inline int FIELD_::getNumberOfComponents() const
+{
+ return _numberOfComponents ;
+}
+// inline void FIELD_::setComponentType(int *ComponentType)
+// {
+// _componentsTypes=ComponentType ;
+// }
+// inline int * FIELD_::getComponentType() const
+// {
+// return _componentsTypes ;
+// }
+// inline int FIELD_::getComponentTypeI(int i) const
+// {
+// return _componentsTypes[i-1] ;
+// }
+inline void FIELD_::setComponentsNames(string * ComponentsNames)
+{
+ _componentsNames=ComponentsNames ;
+}
+inline void FIELD_::setComponentName(int i, string ComponentName)
+{
+ _componentsNames[i-1]=ComponentName ;
+}
+inline string * FIELD_::getComponentsNames() const
+{
+ return _componentsNames ;
+}
+inline string FIELD_::getComponentName(int i) const
+{
+ return _componentsNames[i-1] ;
+}
+inline void FIELD_::setComponentsDescriptions(string *ComponentsDescriptions)
+{
+ _componentsDescriptions=ComponentsDescriptions ;
+}
+inline void FIELD_::setComponentDescription(int i,string ComponentDescription)
+{
+ _componentsDescriptions[i-1]=ComponentDescription ;
+}
+inline string * FIELD_::getComponentsDescriptions() const
+{
+ return _componentsDescriptions ;
+}
+inline string FIELD_::getComponentDescription(int i) const
+{
+ return _componentsDescriptions[i-1];
+}
+inline void FIELD_::setComponentsUnits(UNIT * ComponentsUnits)
+{
+ _componentsUnits=ComponentsUnits ;
+}
+inline UNIT * FIELD_::getComponentsUnits() const
+{
+ return _componentsUnits ;
+}
+inline UNIT * FIELD_::getComponentUnit(int i) const
+{
+ return &_componentsUnits[i-1] ;
+}
+inline void FIELD_::setMEDComponentsUnits(string * MEDComponentsUnits)
+{
+ _MEDComponentsUnits=MEDComponentsUnits ;
+}
+inline void FIELD_::setMEDComponentUnit(int i, string MEDComponentUnit)
+{
+ _MEDComponentsUnits[i-1]=MEDComponentUnit ;
+}
+inline string * FIELD_::getMEDComponentsUnits() const
+{
+ return _MEDComponentsUnits ;
+}
+inline string FIELD_::getMEDComponentUnit(int i) const
+{
+ return _MEDComponentsUnits[i-1] ;
+}
+inline void FIELD_::setIterationNumber(int IterationNumber)
+{
+ _iterationNumber=IterationNumber;
+}
+inline int FIELD_::getIterationNumber() const
+{
+ return _iterationNumber ;
+}
+inline void FIELD_::setTime(double Time)
+{
+ _time=Time ;
+}
+inline double FIELD_::getTime() const
+{
+ return _time ;
+}
+inline void FIELD_::setOrderNumber(int OrderNumber)
+{
+ _orderNumber=OrderNumber ;
+}
+inline int FIELD_::getOrderNumber() const
+{
+ return _orderNumber ;
+}
+inline const SUPPORT * FIELD_::getSupport() const
+{
+ return _support ;
+}
+
+inline void FIELD_::setSupport(SUPPORT * support)
+{
+ _support = support ;
+}
+
+inline /*MED_EN::*/med_type_champ FIELD_::getValueType ()
+{
+ return _valueType ;
+}
+
+inline void FIELD_::setValueType (/*MED_EN::*/med_type_champ ValueType)
+{
+ _valueType = ValueType ;
+}
+
+/////////////////////////
+// END OF CLASS FIELD_ //
+/////////////////////////
+
+template <class T> class FIELD : public FIELD_
+{
+
+ // ------- Drivers Management Part
+protected:
+
+ //-----------------------//
+ class INSTANCE
+ //-----------------------//
+ {
+ public:
+ virtual GENDRIVER * run(const string & fileName, FIELD<T> * ptrFIELD) const = 0 ;
+ } ;
+
+ //-------------------------------------------------------//
+ template <class T2> class INSTANCE_DE : public INSTANCE
+ //-------------------------------------------------------//
+ {
+ public :
+ GENDRIVER * run(const string & fileName, FIELD<T> * ptrFIELD) const
+ {
+ return new T2(fileName,ptrFIELD);
+ }
+ } ;
+
+ // static INSTANCE_DE<MED_FIELD_RDONLY_DRIVER> inst_med_rdonly ;
+ static INSTANCE_DE<MED_FIELD_RDWR_DRIVER<T> > inst_med ;
+ static const INSTANCE * const instances[] ;
+
+ // ------ End of Drivers Management Part
+
+ vector<GENDRIVER *> _drivers; // Storage of the drivers currently in use
+
+ // array of value of type T
+ MEDARRAY<T> *_value ;
+
+private:
+ //setValueType() ;
+
+public:
+ FIELD();
+ FIELD(const FIELD &m); // A FAIRE
+ FIELD & operator=(const FIELD &m); // A FAIRE
+ FIELD(const SUPPORT * Support, const int NumberOfComponents); // Ajout NB Constructeur FIELD avec allocation de memoire de tous ses attribut
+ FIELD(driverTypes driverType, const string & fileName="",
+ const string & fieldName="");
+ ~FIELD();
+
+ friend class MED_FIELD_RDONLY_DRIVER<T>;
+ friend class MED_FIELD_WRONLY_DRIVER<T>;
+ friend class MED_FIELD_RDWR_DRIVER <T>;
+
+ void init ();
+ void rmDriver(int index=0);
+ int addDriver(driverTypes driverType,
+ const string & fileName="Default File Name.med",
+ const string & driverFieldName="Default Field Name") ;
+ int addDriver(GENDRIVER & driver);
+
+ void allocValue(const int NumberOfComponents);
+ void allocValue(const int NumberOfComponents, const int LengthValue);
+
+ void deallocValue();
+
+ inline void read(int index=0);
+ inline void write(int index=0, const string & driverName = "");
+ inline void write(const GENDRIVER &);
+
+ inline void setValue(MEDARRAY<T> *Value);
+
+ inline T* getValue(medModeSwitch Mode) const;
+ inline T* getValueI(medModeSwitch Mode,int i) const;
+ inline T getValueIJ(int i,int j) const;
+
+ inline void setValue(medModeSwitch mode, T* value);
+ inline void setValueI(medModeSwitch mode, int i, T* value);
+ inline void setValueIJ(int i, int j, T value);
+};
+
+// --------------------
+// Implemented Methods
+// --------------------
+
+template <class T> FIELD<T>::FIELD():
+ _value((MEDARRAY<T>*)NULL)
+{
+ MESSAGE("Constructeur FIELD sans parametre");
+}
+
+template <class T> FIELD<T>::FIELD(const SUPPORT * Support,
+ const int NumberOfComponents):
+ FIELD_(Support, NumberOfComponents)
+{
+ BEGIN_OF("FIELD<T>::FIELD(const SUPPORT * Support, const int NumberOfComponents)");
+
+ int length = 0 ;
+ try {
+ length = Support->getNumberOfElements(MED_ALL_ELEMENTS);
+ }
+ catch (MEDEXCEPTION &ex) {
+ MESSAGE("No value defined ! ("<<ex.what()<<")");
+ _value = (MEDARRAY<T>*)NULL ;
+ }
+ MESSAGE("FIELD : constructeur : "<<length <<" et "<< NumberOfComponents);
+ if (0<length)
+ _value = new MEDARRAY<T>::MEDARRAY(NumberOfComponents,length);
+ else
+ _value = (MEDARRAY<T>*)NULL ;
+
+ END_OF("FIELD<T>::FIELD(const SUPPORT * Support, const int NumberOfComponents)");
+}
+
+template <class T> void FIELD<T>::init ()
+{
+}
+
+template <class T> FIELD<T>::FIELD(const FIELD &m):
+ FIELD_((FIELD_) m)
+{
+ _value = m._value;
+ _drivers = m._drivers;
+}
+
+template <class T> FIELD<T> & FIELD<T>::FIELD::operator=(const FIELD &m)
+{
+}
+
+template <class T> FIELD<T>::FIELD(driverTypes driverType,
+ const string & fileName="",
+ const string & fieldName="")
+{
+}
+
+template <class T> FIELD<T>::~FIELD()
+{
+ BEGIN_OF(" Destructeur FIELD<T>::~FIELD()");
+ if (_value) delete _value;
+ END_OF(" Destructeur FIELD<T>::~FIELD()");
+}
+
+template <class T> void FIELD<T>::allocValue(const int NumberOfComponents)
+{
+ BEGIN_OF("void FIELD<T>::allocValue(const int NumberOfComponents)");
+
+ _numberOfComponents = NumberOfComponents ;
+ if (_componentsTypes == NULL)
+ _componentsTypes = new int[NumberOfComponents] ;
+ if (_componentsNames == NULL)
+ _componentsNames = new string[NumberOfComponents];
+ if (_componentsDescriptions == NULL)
+ _componentsDescriptions = new string[NumberOfComponents];
+ if (_componentsUnits == NULL)
+ _componentsUnits = new UNIT[NumberOfComponents];
+ if (_MEDComponentsUnits == NULL)
+ _MEDComponentsUnits = new string[NumberOfComponents];
+ for (int i=0;i<NumberOfComponents;i++) {
+ _componentsTypes[i] = 0 ;
+ }
+
+ try {
+ int length = _support->getNumberOfElements(MED_ALL_ELEMENTS);
+ MESSAGE("FIELD : constructeur : "<<length <<" et "<< NumberOfComponents);
+
+ _value = new MEDARRAY<T>::MEDARRAY(NumberOfComponents,length);
+ }
+ catch (MEDEXCEPTION &ex) {
+ MESSAGE("No value defined, problem with NumberOfComponents (and may be _support) size of MEDARRAY<T>::_value !");
+ _value = (MEDARRAY<T>*)NULL ;
+ }
+
+ SCRUTE(_value);
+ END_OF("void FIELD<T>::allocValue(const int NumberOfComponents)");
+}
+
+template <class T> void FIELD<T>::allocValue(const int NumberOfComponents, const int LengthValue)
+{
+ BEGIN_OF("void FIELD<T>::allocValue(const int NumberOfComponents,const int LengthValue)");
+
+ _numberOfComponents = NumberOfComponents ;
+ if (_componentsTypes == NULL)
+ _componentsTypes = new int[NumberOfComponents] ;
+ if (_componentsNames == NULL)
+ _componentsNames = new string[NumberOfComponents];
+ if (_componentsDescriptions == NULL)
+ _componentsDescriptions = new string[NumberOfComponents];
+ if (_componentsUnits == NULL)
+ _componentsUnits = new UNIT[NumberOfComponents];
+ if (_MEDComponentsUnits == NULL)
+ _MEDComponentsUnits = new string[NumberOfComponents];
+ for (int i=0;i<NumberOfComponents;i++) {
+ _componentsTypes[i] = 0 ;
+ }
+
+ MESSAGE("FIELD : constructeur : "<<LengthValue <<" et "<< NumberOfComponents);
+
+ _value = new MEDARRAY<T>::MEDARRAY(NumberOfComponents,LengthValue);
+
+ SCRUTE(_value);
+ END_OF("void FIELD<T>::allocValue(const int NumberOfComponents,const int LengthValue)");
+}
+
+template <class T> void FIELD<T>::deallocValue()
+{
+ BEGIN_OF("void FIELD<T>::deallocValue()");
+
+ delete _value;
+
+ END_OF("void FIELD<T>::deallocValue()");
+}
+
+// -----------------
+// Methodes Inline
+// -----------------
+
+
+template <class T> FIELD<T>::INSTANCE_DE<MED_FIELD_RDWR_DRIVER<T> > FIELD<T>::inst_med ;
+template <class T> const FIELD<T>::INSTANCE * const FIELD<T>::instances[] = { &FIELD<T>::inst_med } ;
+
+
+template <class T> int FIELD<T>::addDriver(driverTypes driverType,
+ const string & fileName="Default File Name.med",
+ const string & driverName="Default Field Name")
+{
+ const char * LOC = "FIELD<T>::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Field Name\") : ";
+
+ GENDRIVER * driver;
+ int current;
+
+ BEGIN_OF(LOC);
+
+ driver = instances[driverType]->run(fileName, this) ;
+ _drivers.push_back(driver);
+ current = _drivers.size()-1;
+
+ _drivers[current]->setFieldName(driverName);
+ return current;
+
+ END_OF(LOC);
+
+}
+
+template <class T> inline int FIELD<T>::addDriver (GENDRIVER & driver )
+{
+ const char * LOC = "FIELD<T>::addDriver(GENDRIVER &) : ";
+ BEGIN_OF(LOC);
+
+ _drivers.push_back(&driver);
+ return _drivers.size() -1 ;
+
+ END_OF(LOC);
+};
+
+template <class T> void FIELD<T>::rmDriver (int index=0)
+{
+ const char * LOC = "FIELD<T>::rmDriver (int index=0): ";
+ BEGIN_OF(LOC);
+
+ if ( _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()
+ )
+ );
+
+ END_OF(LOC);
+}
+
+template <class T> inline void FIELD<T>::read(int index=0)
+{
+ const char * LOC = "FIELD<T>::read(int index=0) : ";
+ BEGIN_OF(LOC);
+
+ if ( _drivers[index] ) {
+ _drivers[index]->open();
+ _drivers[index]->read();
+ _drivers[index]->close();
+ }
+ else
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
+ )
+ );
+ END_OF(LOC);
+}
+
+template <class T> inline void FIELD<T>::write(int index=0, const string & driverName = "")
+{
+ const char * LOC = "FIELD<T>::write(int index=0, const string & driverName = \"\") : ";
+ BEGIN_OF(LOC);
+
+ if( _drivers[index] ) {
+ _drivers[index]->open();
+ if (driverName != "") _drivers[index]->setFieldName(driverName);
+ _drivers[index]->write();
+ _drivers[index]->close();
+ }
+ else
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
+ )
+ );
+ END_OF(LOC);
+}
+
+template <class T> inline void FIELD<T>::write(const GENDRIVER & genDriver)
+{
+ const char * LOC = " FIELD<T>::write(const GENDRIVER &) : ";
+ BEGIN_OF(LOC);
+
+ for (int index=0; index < _drivers.size(); index++ )
+ if ( *_drivers[index] == genDriver ) {
+ _drivers[index]->open();
+ _drivers[index]->write();
+ _drivers[index]->close();
+ }
+
+ END_OF(LOC);
+
+}
+
+template <class T> inline void FIELD<T>::setValue(MEDARRAY<T> *Value)
+{
+ _value=Value ;
+}
+template <class T> inline T* FIELD<T>::getValue(medModeSwitch Mode) const
+{
+ return _value->get(Mode) ;
+}
+template <class T> inline T* FIELD<T>::getValueI(medModeSwitch Mode,int i) const
+{
+ return _value->getI(Mode,i) ;
+}
+template <class T> inline T FIELD<T>::getValueIJ(int i,int j) const
+{
+ return _value->getIJ(i,j) ;
+}
+
+template <class T> inline void FIELD<T>::setValue(medModeSwitch mode, T* value)
+{
+ _value->set(mode,value);
+}
+
+template <class T> inline void FIELD<T>::setValueI(medModeSwitch mode, int i, T* value)
+{
+ _value->setI(mode,i,value);
+}
+
+template <class T> inline void FIELD<T>::setValueIJ(int i, int j, T value)
+{
+ _value->setIJ(i,j,value);
+}
+
+#endif /* FIELD_HXX */
--- /dev/null
+#include "MEDMEM_GenDriver.hxx"
+
+GENDRIVER::GENDRIVER(): _fileName(""),_accessMode((med_mode_acces)MED_INVALID),_status(MED_INVALID),_driverType(NO_DRIVER) {}
+
+GENDRIVER::GENDRIVER(const string & fileName,
+ med_mode_acces accessMode=(med_mode_acces) MED_INVALID): _fileName(fileName),
+ _accessMode(accessMode),
+ _status(MED_CLOSED),
+ _driverType(NO_DRIVER) {}
+
+GENDRIVER::GENDRIVER(const GENDRIVER & genDriver):_fileName(genDriver._fileName),
+ _accessMode(genDriver._accessMode),
+ _status(genDriver._status),_driverType(NO_DRIVER) {}
+GENDRIVER::~GENDRIVER() {}
+
+
+GENDRIVER & GENDRIVER::operator=(const GENDRIVER & genDriver) {
+ _fileName = genDriver._fileName;
+ _accessMode = genDriver._accessMode;
+ _status = genDriver._status;
+
+ return *this;
+}
+
+void GENDRIVER::writeFrom ( void ) {};
+void GENDRIVER::readFileStruct ( void ) {};
+
+void GENDRIVER::setMeshName (const string & meshName) {};
+void GENDRIVER::setFieldName (const string & fieldName) {};
+
+string GENDRIVER::getFileName() const {
+ return _fileName;
+}
+
+void GENDRIVER::setFileName(const string & fileName) {
+ _fileName = fileName;
+}
+
+med_mode_acces GENDRIVER::getAccessMode() const {
+ return _accessMode;
+}
+
+ostream & operator<<(ostream &os,const GENDRIVER & drv)
+{
+ switch (drv._accessMode)
+ {
+ case MED_RDONLY :
+ os<<"C'est un IO de READ"<<endl;
+ break;
+ case MED_RDWR :
+ os<<"C'est un IO d'READ/WRITE"<<endl;
+ break;
+ }
+ switch (drv._status)
+ {
+ case MED_OPENED :
+ os<<"L'IO_Mesh_MED est open"<<endl;
+ break;
+ case MED_CLOSED :
+ os<<"L'IO_Mesh_MED est fermé"<<endl;
+ break;
+ case MED_INVALID :
+ os<<"L'IO_Mesh_MED est non-valide"<<endl;
+ break;
+ }
+ return os;
+}
+
+bool GENDRIVER::operator ==(const GENDRIVER &genDriver) const {
+
+ return ( _id == genDriver._id ) &&
+ ( _fileName == genDriver._fileName ) &&
+ ( _driverType == genDriver._driverType );
+
+};
--- /dev/null
+#ifndef GENDRIVER_HXX
+#define GENDRIVER_HXX
+
+#include <string>
+
+#include "MEDMEM_define.hxx"
+#include "utilities.h"
+
+/* Generic Read/Write Driver Class for Meshes & Fields */
+
+typedef enum { MED_DRIVER = 0, VTK_DRIVER = 1, NO_DRIVER = 255 } driverTypes;
+
+using namespace MED_EN;
+using namespace std;
+
+class GENDRIVER {
+
+protected :
+
+ int _id; // MED_INVALID : if the driver hasn't been created by a MedMedDriver
+ // the MedMedDriver index of the driver vector in the MED object where it has been created
+ /*File related part*/
+ string _fileName;
+ med_mode_acces _accessMode;
+ int _status;
+ driverTypes _driverType; // A FAIRE LE POSITIONNER DS TOUTES LES SS CLASSES !!
+
+public:
+ GENDRIVER();
+
+ GENDRIVER(const string & fileName,med_mode_acces accessMode);
+ GENDRIVER(const GENDRIVER & genDriver);
+ ~GENDRIVER();
+
+ GENDRIVER & operator=(const GENDRIVER & genDriver);
+
+ friend ostream & operator<<(ostream &os,const GENDRIVER &genDriver);
+
+ bool operator ==(const GENDRIVER &genDriver) const;
+
+ virtual void open ( void ) = 0;
+ virtual void close( void ) = 0;
+ virtual void write( void ) const = 0;
+ virtual void read ( void ) = 0;
+
+ // MED related part
+ virtual void writeFrom ( void );
+ virtual void readFileStruct ( void );
+ // MESH related Part
+ virtual void setMeshName ( const string & meshName);
+ // FIELD related Part
+ virtual void setFieldName ( const string & fieldName);
+
+ string getFileName () const;
+ void setFileName (const string & fileName);
+ med_mode_acces getAccessMode() const;
+};
+
+
+
+#endif /* GENDRIVER_HXX */
--- /dev/null
+/*
+ File Group.cxx
+ $Header$
+*/
+#include <list>
+
+#include "MEDMEM_Group.hxx"
+#include "MEDMEM_Family.hxx"
+
+GROUP::GROUP():_numberOfFamilies(0),_family()
+{
+ MESSAGE("GROUP()");
+};
+
+GROUP::~GROUP()
+{
+ MESSAGE("~GROUP()");
+};
+
+GROUP & GROUP::operator=(const GROUP &group)
+{
+ MESSAGE("GROUP::operator=");
+ _numberOfFamilies = group._numberOfFamilies ;
+ _family = group._family ;
+ return *this;
+};
+
+GROUP::GROUP(const string & name, const list<FAMILY*> & families)
+{
+ const char * LOC = "GROUP( const string & , const list<FAMILY*> & ) : " ;
+
+ BEGIN_OF(LOC);
+
+ MESSAGE(LOC<<name);
+ _name = name ;
+ // description : none !
+ // first FAMILY to set all !
+ FAMILY * myFamily = families.front() ;
+ _mesh = myFamily->getMesh() ;
+ _entity = myFamily->getEntity() ;
+ _numberOfGeometricType = myFamily->getNumberOfTypes() ;
+ _geometricType = new medGeometryElement[_numberOfGeometricType];
+ //_geometricTypeNumber = new int[_numberOfGeometricType] ;
+ _numberOfGaussPoint = new int[_numberOfGeometricType] ;
+ _numberOfEntities = new int[_numberOfGeometricType] ;
+ medGeometryElement * geometricType = myFamily->getTypes() ;
+ //int * geometricTypeNumber = myFamily->getGeometricTypeNumber() ;
+ int * numberOfGaussPoint = myFamily->getNumberOfGaussPoint() ;
+ for (int i=0 ; i<_numberOfGeometricType; i++) {
+ _geometricType[i]= geometricType[i] ;
+ // _geometricTypeNumber[i] = geometricTypeNumber[i] ;
+ _numberOfGaussPoint[i] = numberOfGaussPoint[i] ;
+ _numberOfEntities[i]=myFamily->getNumberOfElements(geometricType[i]);
+ }
+ _isOnAllElts = false ;
+ _totalNumberOfEntities = myFamily->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ _number = new MEDSKYLINEARRAY(*myFamily->getnumber()) ;
+
+ _numberOfFamilies = families.size();
+ _family.resize(_numberOfFamilies) ;
+ list<FAMILY*>::const_iterator li ;
+ int it = 0 ;
+ for (li=families.begin();li!=families.end();li++) {
+ blending(*li);
+ _family[it] = (*li) ;
+ it++ ;
+ }
+
+ END_OF(LOC);
+};
+
+void GROUP::init(const list<FAMILY*> & families)
+{
+ const char * LOC = "GROUP::init( const list<FAMILY*> & ) : " ;
+
+ BEGIN_OF(LOC);
+
+ FAMILY * myFamily = families.front() ;
+ _mesh = myFamily->getMesh() ;
+ _entity = myFamily->getEntity() ;
+ _numberOfGeometricType = myFamily->getNumberOfTypes() ;
+ _geometricType = new medGeometryElement[_numberOfGeometricType];
+ //_geometricTypeNumber = new int[_numberOfGeometricType] ;
+ _numberOfGaussPoint = new int[_numberOfGeometricType] ;
+ _numberOfEntities = new int[_numberOfGeometricType] ;
+ medGeometryElement * geometricType = myFamily->getTypes() ;
+ //int * geometricTypeNumber = myFamily->getGeometricTypeNumber() ;
+ int * numberOfGaussPoint = myFamily->getNumberOfGaussPoint() ;
+ for (int i=0 ; i<_numberOfGeometricType; i++) {
+ _geometricType[i]= geometricType[i] ;
+ // _geometricTypeNumber[i] = geometricTypeNumber[i] ;
+ _numberOfGaussPoint[i] = numberOfGaussPoint[i] ;
+ _numberOfEntities[i]=myFamily->getNumberOfElements(geometricType[i]);
+ }
+ _isOnAllElts = false ;
+ _totalNumberOfEntities = myFamily->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ _number = new MEDSKYLINEARRAY(*myFamily->getnumber()) ;
+
+ _numberOfFamilies = families.size();
+ _family.resize(_numberOfFamilies) ;
+ list<FAMILY*>::const_iterator liIni = families.begin() ;
+ _family[0]=(*liIni);
+ liIni++;
+ list<FAMILY*>::const_iterator li ;
+ int it = 1 ;
+ for (li=liIni;li!=families.end();li++) {
+ blending(*li);
+ _family[it] = (*li) ;
+ it++ ;
+ }
+
+ END_OF(LOC);
+};
+
--- /dev/null
+/*
+ File Group.hxx
+ $Header$
+*/
+
+#ifndef GROUP_HXX
+#define GROUP_HXX
+
+#include <vector>
+#include <list>
+//#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Family.hxx"
+
+class FAMILY;
+
+class GROUP : public SUPPORT
+{
+protected :
+ /*! Number of families in the group */
+ int _numberOfFamilies ;
+ /*! Vector of families in the group */
+ vector<FAMILY*> _family ;
+
+public:
+ GROUP();
+ GROUP(const string & name, const list<FAMILY*> & family);
+ ~GROUP();
+ GROUP & operator=(const GROUP &group);
+
+ inline void setNumberOfFamilies(int numberOfFamilies);
+ inline void setFamilies(vector<FAMILY*> Family);
+
+ inline int getNumberOfFamilies() const ;
+ inline vector<FAMILY*> getFamilies() const ;
+ inline FAMILY * getFamily(int i) const ;
+
+ void init(const list<FAMILY*> & family);
+};
+
+// inline method :
+
+/*! set the attribut _numberOfFamilies to numberOfFamilies */
+//----------------------------------------------------------
+inline void GROUP::setNumberOfFamilies(int numberOfFamilies)
+//----------------------------------------------------------
+{
+ _numberOfFamilies = numberOfFamilies;
+};
+
+
+/*! set the attribut _family to Family */
+//----------------------------------------------------
+inline void GROUP::setFamilies(vector<FAMILY*> Family)
+//----------------------------------------------------
+{
+ _family = Family;
+};
+
+/*! returns number of families in the group */
+//--------------------------------------------
+inline int GROUP::getNumberOfFamilies() const
+//-------------------------------------------
+{
+ return _numberOfFamilies;
+};
+
+/*! returns the vector of families in the group */
+//------------------------------------------------
+inline vector<FAMILY*> GROUP::getFamilies() const
+//------------------------------------------------
+{
+ return _family;
+};
+
+/*! returns a reference on family I of the group */
+//--------------------------------------------------
+FAMILY * GROUP::getFamily(int i) const
+//--------------------------------------------------
+{
+ return _family[i-1];
+};
+
+
+#endif /* GROUP_HXX */
--- /dev/null
+# include "MEDMEM_Med.hxx"
+
+# include "MEDMEM_STRING.hxx"
+
+# include "MEDMEM_Mesh.hxx"
+# include "MEDMEM_Field.hxx"
+
+# include "MEDMEM_Exception.hxx"
+# include "utilities.h"
+
+// MED constructors
+MED::MED() {
+ const char * LOC = "MED::MED() : ";
+
+ MESSAGE(LOC << "Construction...");
+
+};
+
+MED::MED(driverTypes driverType, const string & fileName) {
+ const char * LOC = "MED::MED(driverTypes driverType, const string & fileName) : ";
+ int current;
+
+ BEGIN_OF(STRING(LOC));
+ current = addDriver(driverType,fileName);
+ _drivers[current]->open();
+ _drivers[current]->readFileStruct();
+ _drivers[current]->close();
+ END_OF(STRING(LOC));
+};
+
+MED::~MED()
+{
+} ;
+
+// ------- Drivers Management Part
+
+MED::INSTANCE_DE<MED_MED_DRIVER> MED::inst_med ;
+//MED::INSTANCE_DE<VTK_DRIVER> MED::inst_vtk ;
+
+const MED::INSTANCE * const MED::instances[] = { &MED::inst_med }; //, &MED::inst_vtk } ;
+
+int MED::addDriver(driverTypes driverType, const string & fileName="Default File Name.med") {
+
+ const char * LOC = "MED::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\") : ";
+ GENDRIVER * driver;
+ int current;
+
+ BEGIN_OF(LOC);
+
+ driver = instances[driverType]->run(fileName, this) ;
+ _drivers.push_back(driver);
+ current = _drivers.size()-1;
+ // _drivers[current]->set...
+
+ END_OF(LOC);
+ return current;
+}
+
+
+void MED::rmDriver (int index=0) {
+ const char * LOC = "MED::rmDriver (int index=0): ";
+ BEGIN_OF(LOC);
+
+ if (_drivers[index])
+ //_drivers.erase(&_drivers[index]);
+ {}
+ else
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
+ )
+ );
+ END_OF(LOC);
+}
+
+
+void MED::writeFrom (int index=0)
+{
+ const char * LOC = "MED::write (int index=0): ";
+ BEGIN_OF(LOC);
+
+ if (_drivers[index]) {
+ _drivers[index]->open();
+ _drivers[index]->writeFrom();
+ _drivers[index]->close();
+ }
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
+ )
+ );
+ END_OF(LOC);
+};
+
+
+void MED::write (int index=0)
+{
+ const char * LOC = "MED::writeAll (int index=0): ";
+ BEGIN_OF(LOC);
+
+ if (_drivers[index]) {
+ _drivers[index]->open();
+ _drivers[index]->write();
+ _drivers[index]->close();
+ }
+ else
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
+ )
+ );
+ END_OF(LOC);
+};
+
+
+void MED::readFileStruct (int index=0) {
+ const char * LOC = "MED::readFileStruct (int index=0): ";
+ BEGIN_OF(LOC);
+
+ if (_drivers[index]) {
+ _drivers[index]->open();
+ _drivers[index]->readFileStruct();
+ _drivers[index]->close();
+ }
+ else
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
+ )
+ );
+ END_OF(LOC);
+}
+
+// void MED::read (int index=0)
+// {
+// const char * LOC = "MED::read (int index=0): ";
+// BEGIN_OF(LOC);
+
+// if (_drivers[index])
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+// << "The index given is invalid, index must be between >0 and < |"
+// << _drivers.size()-1
+// )
+// );
+// // GERER LE 0
+// _drivers[index]->open();
+// _drivers[index]->read();
+// _drivers[index]->close();
+
+// END_OF(LOC);
+
+// };
+
+// ------- End Of Drivers Management Part
+
+int MED::getNumberOfMeshes ( void ) const {
+
+ const char * LOC = "MED::getNumberOfMeshes ( void ) const : ";
+ BEGIN_OF(LOC);
+
+ return _meshes.size();
+
+ END_OF(LOC);
+};
+
+int MED::getNumberOfFields ( void ) const {
+
+ const char * LOC = "MED::getNumberOfFields ( void ) const : ";
+ BEGIN_OF(LOC);
+
+ // return _meshName.size();
+ return _fields.size(); // we get number of field with different name
+
+ END_OF(LOC);
+};
+
+void MED::getMeshNames ( string * meshNames ) const {
+
+ const char * LOC = "MED::getMeshNames ( string * ) const : ";
+ BEGIN_OF(LOC);
+ int meshNamesSize;
+
+ if ( ( meshNamesSize = sizeof(meshNames) / sizeof(string *) )
+ != _meshes.size() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "Size of parameter meshNames is |"
+ << meshNamesSize << "| and should be |"
+ << _meshes.size() << "| and should be |"
+ )
+ );
+
+ // REM : ALLOCATION D'UN TABLEAU DE POINTEURS SUR STRING FAITE PAR LE CLIENT
+ map<MESH_NAME_,MESH*>::const_iterator currentMesh; // ??ITERATEUR CONST SUR UN OBJET NON CONST ??
+
+ int meshNamesIndex = 0;
+
+ for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
+ meshNames[meshNamesIndex]=(*currentMesh).first;
+ meshNamesIndex++; // CF OPTIMISATION
+ }
+
+ END_OF(LOC);
+};
+
+deque<string> MED::getMeshNames () const {
+
+ const char * LOC = "MED::getMeshNames () const : ";
+ BEGIN_OF(LOC);
+
+ deque<string> meshNames(_meshes.size());
+
+ map<MESH_NAME_,MESH*>::const_iterator currentMesh; // ??ITERATEUR CONST SUR UN OBJET NON CONST ??
+
+ int meshNamesIndex = 0;
+
+ for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
+ meshNames[meshNamesIndex]=(*currentMesh).first;
+ meshNamesIndex++; // CF OPTIMISATION
+ }
+
+ END_OF(LOC);
+ return meshNames ;
+};
+
+MESH * MED::getMesh ( const string & meshName ) const {
+
+ const char * LOC = "MED::getMesh ( const string & meshName ) const : ";
+ BEGIN_OF(LOC);
+
+ map<MESH_NAME_,MESH*>::const_iterator itMeshes = _meshes.find(meshName);
+
+ // if ( itMeshes == _meshName.end() )
+ if ( itMeshes == _meshes.end() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "There is no known mesh named |"
+ << meshName << "|"
+ )
+ );
+
+ return (*itMeshes).second;
+
+ END_OF(LOC);
+}
+
+MESH * MED::getMesh (const FIELD_ * const field ) const {
+
+ const char * LOC = "MED::getMesh ( const FIELD * field ) const : ";
+ BEGIN_OF(LOC);
+
+ FIELD_ * f = const_cast< FIELD_* > (field); // Comment faire mieux ?
+ map<FIELD_ *, MESH_NAME_>::const_iterator itMeshName = _meshName.find(f);
+
+ if ( itMeshName == _meshName.end() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "There is no known field associated with |"
+ << field << "| pointer"
+ )
+ );
+
+ string meshName = (*itMeshName).second;
+ map<MESH_NAME_,MESH*>::const_iterator itMeshes = _meshes.find(meshName);
+ if ( itMeshes == _meshes.end() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "There is no known mesh named |"
+ << meshName << " while it's associated with the found field |"
+ << field << "| pointer"
+ )
+ );
+
+ return (*itMeshes).second;
+
+ END_OF(LOC);
+};
+
+
+void MED::getFieldNames ( string * fieldNames ) const {
+
+ const char * LOC = "MED::getFieldNames ( string * ) const : ";
+ BEGIN_OF(LOC);
+
+ 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 |"
+ )
+ );
+
+ // REM : ALLOCATION D'UN TABLEAU DE POINTEURS SUR STRING FAITE PAR LE CLIENT
+ map<FIELD_NAME_,MAP_DT_IT_>::const_iterator currentField;
+
+ int fieldNamesIndex = 0;
+ for ( currentField=_fields.begin();currentField != _fields.end(); currentField++ ) {
+ fieldNames[fieldNamesIndex]=(*currentField).first;
+ fieldNamesIndex++; // CF OPTIMISATION
+ }
+
+ END_OF(LOC);
+
+};
+
+deque<string> MED::getFieldNames () const {
+
+ const char * LOC = "MED::getFieldNames ( ) const : ";
+ BEGIN_OF(LOC);
+
+ deque<string> fieldNames(_fields.size());
+
+ map<FIELD_NAME_,MAP_DT_IT_>::const_iterator currentField;
+
+ int fieldNamesIndex = 0;
+
+ for ( currentField=_fields.begin();currentField != _fields.end(); currentField++ ) {
+ fieldNames[fieldNamesIndex]=(*currentField).first;
+ fieldNamesIndex++; // CF OPTIMISATION
+ }
+
+ END_OF(LOC);
+ return fieldNames ;
+};
+
+deque<DT_IT_> MED::getFieldIteration (const string & fieldName) const {
+
+ const char * LOC = "MED::getFieldIteration ( const string & ) const : ";
+ BEGIN_OF(LOC);
+
+ map<FIELD_NAME_,MAP_DT_IT_>::const_iterator itFields = _fields.find(fieldName);
+
+ if ( itFields == _fields.end() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "There is no known field named |"
+ << fieldName << "|"
+ )
+ );
+ // const MAP_DT_IT_ & myIterationMap = const_cast<const MAP_DT_IT_ & > ((*itFields).second);
+ const MAP_DT_IT_ & myIterationMap = (*itFields).second ;
+ MAP_DT_IT_::const_iterator currentIterator ;
+
+ deque<DT_IT_> Iteration(myIterationMap.size());
+
+ int iterationIndex = 0;
+
+ for ( currentIterator=myIterationMap.begin();currentIterator != myIterationMap.end(); currentIterator++ ) {
+ Iteration[iterationIndex]=(*currentIterator).first;
+ iterationIndex++; // CF OPTIMISATION
+ }
+
+ END_OF(LOC);
+ return Iteration ;
+};
+
+FIELD_ * MED::getField ( const string & fieldName, const int dt=MED_NOPDT, const int it=MED_NOPDT ) const {
+
+ const char * LOC = "MED::getField ( const string &, const int, const int ) const : ";
+ BEGIN_OF(LOC);
+
+ MESSAGE(LOC << "fieldName = "<<fieldName<<", dt ="<<dt<<", it = "<<it);
+
+ DT_IT_ dtIt;
+
+ dtIt.dt= dt;
+ dtIt.it= it;
+
+ map<FIELD_NAME_,MAP_DT_IT_>::const_iterator itFields = _fields.find(fieldName);
+
+ if ( itFields == _fields.end() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "There is no known field named |"
+ << fieldName << "|"
+ )
+ );
+
+ const MAP_DT_IT_ & map_dtIt = const_cast<const MAP_DT_IT_ & > ((*itFields).second);
+ MAP_DT_IT_::const_iterator itMap_dtIt = map_dtIt.find(dtIt);
+
+ if ( itMap_dtIt == map_dtIt.end() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "There is no (dt,it) |("
+ << dt << "," << it << ")| associated with the found field |"
+ << fieldName << "|"
+ )
+ );
+
+ END_OF(LOC);
+
+ //return _fields[fieldName][dtIt];
+ return (*itMap_dtIt).second;
+
+};
+
+
+// fiend ostream & MED::operator<<(ostream &os,const MED & med) const {
+// return os;
+// };
+
+
+const map<MED_FR::med_entite_maillage,SUPPORT*> & MED::getSupports(const string & meshName) const
+{
+ const char * LOC = "MED::getSupports ( const string ) const : ";
+ BEGIN_OF(LOC);
+
+ map<MESH_NAME_, map<MED_FR::med_entite_maillage,SUPPORT *> >::const_iterator itSupportOnMesh = _support.find(meshName) ;
+
+ if ( itSupportOnMesh == _support.end() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "There is no support on mesh named |"
+ << meshName << "|"
+ )
+ );
+ END_OF(LOC);
+ return (*itSupportOnMesh).second ;
+}
+
+SUPPORT * MED::getSupport (const string & meshName,MED_FR::med_entite_maillage entity) const
+{
+ const char * LOC = "MED::getSupport ( const string, MED_FR::med_entite_maillage ) const : ";
+ BEGIN_OF(LOC);
+
+ map<MESH_NAME_, map<MED_FR::med_entite_maillage,SUPPORT *> >::const_iterator itSupportOnMesh = _support.find(meshName) ;
+
+ if ( itSupportOnMesh == _support.end() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "There is no support on mesh named |"
+ << meshName << "|"
+ )
+ );
+
+ map<MED_FR::med_entite_maillage,SUPPORT *> & SupportOnMesh = (map<MED_FR::med_entite_maillage,SUPPORT *>&) ((*itSupportOnMesh).second) ;
+ map<MED_FR::med_entite_maillage,SUPPORT *>::const_iterator itSupport = SupportOnMesh.find(entity) ;
+
+ if (itSupport == SupportOnMesh.end() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "There is no support on entity "
+ << entity << " in mesh named |"
+ << meshName << "|"
+ )
+ );
+ END_OF(LOC);
+ return (*itSupport).second ;
+};
+
+void MED::updateSupport ()
+{
+
+ const char * LOC = "MED::updateSupport () : ";
+ BEGIN_OF(LOC);
+
+ map<MESH_NAME_, map<MED_FR::med_entite_maillage,SUPPORT *> >::iterator itSupportOnMesh ;
+ for ( itSupportOnMesh=_support.begin();itSupportOnMesh != _support.end(); itSupportOnMesh++ ) {
+ map<MED_FR::med_entite_maillage,SUPPORT *>::iterator itSupport ;
+ for ( itSupport=(*itSupportOnMesh).second.begin();itSupport!=(*itSupportOnMesh).second.end();itSupport++)
+ try {
+ (*itSupport).second->update() ;
+ }
+ catch (MEDEXCEPTION & ex) {
+ // entity not defined in mesh -> we remove support on it !
+ delete (*itSupport).second ;
+ (*itSupportOnMesh).second.erase(itSupport) ; // that's rigth ????
+ }
+ }
+
+ END_OF(LOC);
+}
+
+void MED::addMesh(const MESH * ptrMesh) throw (MEDEXCEPTION)
+{
+ const char * LOC = "MED::addMesh(const MESH * ptrMesh): ";
+
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "WARNING method not yet implemented"));
+}
+
+void MED::addField(const FIELD_ * const ptrField) throw (MEDEXCEPTION)
+{
+ const char * LOC = "MED::addField(const FIELD_ * const ptrField): ";
+
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "WARNING method not yet implemented"));
+}
--- /dev/null
+# ifndef MED_HXX
+# define MED_HXX
+
+// STL
+# include <string>
+# include <map>
+# include <vector>
+# include <deque>
+
+// LOCAL
+# include "MEDMEM_define.hxx"
+# include "MEDMEM_MedMedDriver.hxx"
+# include "MEDMEM_Exception.hxx"
+//using namespace MED_EN;
+
+
+class MESH;
+class FIELD_;
+class SUPPORT ;
+
+typedef string MESH_NAME_;
+typedef string FIELD_NAME_;
+typedef struct { int dt; int it; } DT_IT_;
+struct LT_DT_IT_
+{
+ bool operator() (const DT_IT_ &p1, const DT_IT_ &p2) const
+ {
+ if ( bool test = p1.dt == p2.dt)
+ return p1.it < p2.it ;
+ else
+ return p1.dt < p2.dt ;
+ }
+};
+typedef map<DT_IT_, FIELD_*, LT_DT_IT_ > MAP_DT_IT_;
+
+// - IN THE FIRST CASE THE USER WANTS TO DISCOVER MESHES & FIELD_S
+// CONTAINNED WITHIN A FILE <fileName> OF TYPE GIVEN BY THE <driverType> PARAMETER
+// - IN THE SECOND CASE THE USER BEGINS HIS WORK WITH A MESH OR A FIELD,
+// ?? GET A MED POINTER THEN CAN ADD MESHes OR FIELDs ??
+
+class MED
+{
+ friend class MED_MED_DRIVER;
+ friend class MED_MED_RDONLY_DRIVER;
+
+private:
+
+ map<MESH_NAME_,MESH*> _meshes; // We can't have two MESHes with the same meshName.
+ // The string key is a meshName.
+
+ map<FIELD_NAME_,MAP_DT_IT_> _fields; // We can't have two FIELDs with the same fieldName.
+
+ map<FIELD_ *, MESH_NAME_> _meshName; // Get the meshName associated with a FIELD *
+ // in order to get the MESH* from _meshes
+
+ map < MESH_NAME_, map <MED_FR::med_entite_maillage,SUPPORT * > > _support ;
+ // For each MESH, we list support for each entity on all elements.
+
+ vector<GENDRIVER *> _drivers; // Storage of the MED_MED drivers currently in use
+
+public:
+
+ MED();
+ MED (driverTypes driverType, const string & fileName); // Analyse the file <fileName> by calling readFileStruct
+ ~MED();
+
+ // INUTILE : void addMesh (const string & meshName ); // Read the mesh <meshName> found in the file <_fileName>. <_fileName> must be set.
+ // INUTILE : void addField (const string & fieldName ); // Pensez au cas ou on ajoute un Field/Mesh avec un driver déjà existant.
+
+ void addField (const FIELD_ * const ptrField ) throw (MEDEXCEPTION) ; // Add an existing FIELD object to the FIELD list, the meshName is given by the FIELD object.
+ void addMesh (const MESH * ptrMesh ) throw (MEDEXCEPTION) ; // Add an existing MESH object to the MESH list, the meshName is given by the MESH object.
+
+ // ------ Drivers Management Part
+protected:
+
+ class INSTANCE {
+ public:
+ virtual GENDRIVER * run(const string & fileName, MED * const ptrMed) const = 0 ;
+ } ;
+
+ template <class T> class INSTANCE_DE : public INSTANCE {
+ public :
+ GENDRIVER * run(const string & fileName, MED * const ptrMed) const { return new T(fileName,ptrMed) ; }
+ } ;
+
+ static INSTANCE_DE<MED_MED_DRIVER> inst_med ;
+ //static INSTANCE_DE<VTK_DRIVER> inst_vtk ;
+ static const INSTANCE * const instances[] ;
+
+public:
+
+ int addDriver (driverTypes driverType, const string & fileName);
+ void rmDriver (int index=0);
+ void readFileStruct(int index=0);
+ // void read (int index=0);
+ void writeFrom (int index=0);
+ void write (int index=0);
+
+ // ------ End Of Drivers Management Part
+
+ int getNumberOfMeshes ( void ) const;
+ int getNumberOfFields ( void ) const;
+ void getMeshNames ( string * meshNames ) const;
+ deque<string> getMeshNames () const;
+ MESH * getMesh ( const string & meshName ) const;
+ MESH * getMesh ( const FIELD_ * field ) const;
+ void getFieldNames ( string * fieldNames ) const;
+ deque<string> getFieldNames () const;
+ // A FAIRE DES ROUTINES QUI DONNENT LES PDT ET ITE
+ deque<DT_IT_> getFieldIteration (const string & fieldName) const ;
+ FIELD_ * getField ( const string & fieldName,
+ const int dt, const int it) const;
+
+ const map<MED_FR::med_entite_maillage,SUPPORT *> & getSupports(const string & meshName) const;
+ SUPPORT * getSupport (const string & meshName,MED_FR::med_entite_maillage entity) const ;
+
+ void updateSupport () ;
+
+ // GERER LE CAS DE L'APPARITION DES MEMES NOMS DS DES FICHIERS <> !!!!!
+
+ //friend ostream & operator<<(ostream &os,const MED & med);
+
+};
+
+#endif
+
+//REM : AJOUTER DS LES DRIVERS des attributes INTERLACE, NO INTERLACE .........
+// AJOUTER L'OPERATEUR DE RECOPIE
--- /dev/null
+#ifndef MED_FIELD_DRIVER_HXX
+#define MED_FIELD_DRIVER_HXX
+
+#include <string>
+
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_GenDriver.hxx"
+#include "utilities.h"
+
+#include "MEDMEM_STRING.hxx"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_Unit.hxx"
+//#include "MEDMEM_Field.hxx"
+
+//using namespace MED_FR ;
+
+template <class T> class FIELD;
+
+// A QD LA CLASSE MED_ALL_ELEMENTS_DRIVER.... :) pour mutualiser le open ..... avec led _medIdt...
+template <class T> class MED_FIELD_DRIVER : public GENDRIVER
+{
+protected:
+
+ FIELD<T> * _ptrField;
+ MED_FR::med_idt _medIdt;
+ string _fieldName;
+ int _fieldNum;
+
+ void search_field() ;
+
+public :
+
+ // 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];
+
+ MED_FIELD_DRIVER():GENDRIVER(),
+ _ptrField((FIELD<T> *)MED_NULL),_medIdt(MED_INVALID),
+ _fieldName(""),_fieldNum(MED_INVALID) {}
+ MED_FIELD_DRIVER(const string & fileName, FIELD<T> * ptrField,
+ med_mode_acces accessMode)
+ : GENDRIVER(fileName,accessMode),
+ _ptrField((FIELD<T> *) ptrField),_medIdt(MED_INVALID),
+ _fieldName(""),_fieldNum(MED_INVALID)
+ {
+ }
+
+ void open() {
+ const char * LOC = "MED_FIELD_DRIVER::open() ";
+ BEGIN_OF(LOC);
+
+ // we must set fieldname before open, because we must find field number in file (if it exist !!!)
+
+ MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
+ _medIdt = MED_FR::MEDouvrir( (const_cast <char *> (_fileName.c_str())),(MED_FR::med_mode_acces) _accessMode);
+ MESSAGE(LOC<<"_medIdt : "<< _medIdt );
+ if (_medIdt > 0) _status=MED_OPENED; else {
+ _status = MED_INVALID;
+ }
+
+ END_OF(LOC);
+ }
+
+ void close() {
+ BEGIN_OF("MED_FIELD_DRIVER::close()");
+ MED_FR::med_int err = 0;
+ if (_status == MED_OPENED) {
+ err=MED_FR::MEDfermer(_medIdt);
+ H5close();
+ _status = MED_CLOSED;
+ _medIdt = MED_INVALID;
+ MESSAGE(" MED_FIELD_DRIVER::close() : MEDfermer : _medIdt= " << _medIdt );
+ MESSAGE(" MED_FIELD_DRIVER::close() : MEDfermer : err = " << err );
+ }
+ END_OF("MED_FIELD_DRIVER::close()");
+ }
+
+ virtual void write( void ) const = 0 ;
+ virtual void read ( void ) = 0 ;
+ void setFieldName(const string & fieldName) ;
+ string getFieldName() const ;
+};
+
+template <class T> class MED_FIELD_RDONLY_DRIVER : public virtual MED_FIELD_DRIVER<T>
+{
+
+public :
+
+ MED_FIELD_RDONLY_DRIVER():MED_FIELD_DRIVER<T>() {};
+
+ MED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD<T> * ptrField):
+ MED_FIELD_DRIVER<T>(fileName,ptrField,MED_RDONLY) {
+ BEGIN_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
+ END_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
+ }
+
+ ~MED_FIELD_RDONLY_DRIVER() {
+ BEGIN_OF("MED_FIELD_RDONLY_DRIVER::~MED_FIELD_RDONLY_DRIVER()");
+ END_OF("MED_FIELD_RDONLY_DRIVER::~MED_FIELD_RDONLY_DRIVER()");
+ }
+
+ // CREER UNE METHODE POUR LIRE LA LISTE DES MAILLAGES .....
+
+ void write( void ) const ;
+ void read ( void ) ;
+};
+
+template <class T> class MED_FIELD_WRONLY_DRIVER : public virtual MED_FIELD_DRIVER<T> {
+
+public :
+
+ MED_FIELD_WRONLY_DRIVER():MED_FIELD_DRIVER<T>() {}
+
+ MED_FIELD_WRONLY_DRIVER(const string & fileName, FIELD<T> * ptrField):
+ MED_FIELD_DRIVER<T>(fileName,ptrField,MED_WRONLY)
+ {
+ BEGIN_OF("MED_FIELD_WRONLY_DRIVER::MED_FIELD_WRONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
+ END_OF("MED_FIELD_WRONLY_DRIVER::MED_FIELD_WRONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
+ };
+
+ ~MED_FIELD_WRONLY_DRIVER() { }
+
+ void write( void ) const ;
+ void read ( void ) ;
+};
+
+
+template <class T> class MED_FIELD_RDWR_DRIVER : public MED_FIELD_RDONLY_DRIVER<T>, public MED_FIELD_WRONLY_DRIVER<T> {
+
+public :
+
+ MED_FIELD_RDWR_DRIVER():MED_FIELD_DRIVER<T>() {}
+
+ MED_FIELD_RDWR_DRIVER(const string & fileName, FIELD<T> * ptrField):
+ MED_FIELD_DRIVER<T>(fileName,ptrField,MED_RDWR)
+ {
+ BEGIN_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
+ END_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
+ };
+
+ ~MED_FIELD_RDWR_DRIVER() { }
+
+ void write(void) const ;
+ void read (void) ;
+};
+
+
+/*-------------------------*/
+/* template implementation */
+/*-------------------------*/
+
+/*--------------------- DRIVER PART -------------------------------*/
+
+template <class T> void MED_FIELD_DRIVER<T>::setFieldName(const string & fieldName)
+{
+ _fieldName = fieldName;
+}
+
+template <class T> string MED_FIELD_DRIVER<T>::getFieldName() const
+{
+ return _fieldName;
+}
+
+// template <class T> void MED_FIELD_DRIVER<T>::search_field() {
+// const char * LOC = "template <class T> class MED_FIELD_DRIVER::search_field() :";
+
+// // we search the field number !!!!
+// if (_status==MED_OPENED)
+// if (_fieldNum==MED_INVALID) {
+// int err ;
+// int numberOfFields = 0; //MED_INVALID
+// // char fieldName[MED_TAILLE_NOM+1] = "";
+// char fieldName[MED_TAILLE_NOM+1] ;
+// int numberOfComponents = 0;
+// char * componentName = (char *) MED_NULL;
+// char * unitName = (char *) MED_NULL;
+// MED_FR::med_type_champ type ;
+// numberOfFields = MED_FR::MEDnChamp(_medIdt,0) ;
+// if ( numberOfFields <= 0 )
+// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !"));
+// for (int i=1;i<=numberOfFields;i++) {
+
+// numberOfComponents = MED_FR::MEDnChamp(_medIdt,i) ;
+// if ( numberOfComponents <= 0 )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+// << "Be careful there is no compound for field n°"
+// << i << "in file |"<<_fileName<<"| !"));
+
+// componentName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
+// unitName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
+
+// err = MED_FR::MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
+// unitName, numberOfComponents) ;
+
+// delete[] componentName ;
+// delete[] unitName ;
+// MESSAGE("Champ "<<i<<" : #" << fieldName <<"# et recherche #"<<_fieldName.c_str()<<"#");
+// if ( !strcmp(fieldName,_fieldName.c_str()) ) {
+// MESSAGE("FOUND FIELD "<< fieldName <<" : "<<i);
+// _fieldNum = i ;
+// break ;
+// }
+// }
+// }
+// }
+
+/*--------------------- RDONLY PART -------------------------------*/
+
+template <class T> void MED_FIELD_RDONLY_DRIVER<T>::read(void)
+{
+ const char * LOC = " MED_FIELD_RDONLY_DRIVER::read() " ;
+ BEGIN_OF(LOC);
+
+ if (_ptrField->_name=="")
+ _ptrField->_name = _fieldName ;
+ else
+ _fieldName = _ptrField->_name; // bug indetermine ! apres avoir fait readfilestruct, lorsque je recupere le champ, tout est bon sauf le nom du champ dans le driver !!!!!
+
+ MESSAGE("###### "<<LOC<<" fieldNameDRIVER : "<<_fieldName<<" fieldName : "<<_ptrField->_name);
+
+ string MeshName = _ptrField->getSupport()->getMesh()->getName() ;
+
+ if (_status==MED_OPENED)
+ {
+
+ // search_field() ;
+
+ char * fieldName ;
+ fieldName = new char[MED_TAILLE_NOM+1] ;
+ int err ;
+ int numberOfComponents = 0;
+ char * componentName = (char *) MED_NULL;
+ char * unitName = (char *) MED_NULL;
+ MED_FR::med_type_champ type ;
+
+ // we search the field number !!!!
+ if (_fieldNum==MED_INVALID) {
+ int numberOfFields = 0; //MED_INVALID
+ numberOfFields = MED_FR::MEDnChamp(_medIdt,0) ;
+ if ( numberOfFields <= 0 )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !"));
+ for (int i=1;i<=numberOfFields;i++) {
+
+ numberOfComponents = MED_FR::MEDnChamp(_medIdt,i) ;
+ if ( numberOfComponents <= 0 )
+ // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ // << "Be careful there is no compound for field n°"
+ // << i << "in file |"<<_fileName<<"| !"));
+ MESSAGE(LOC<<"Be careful there is no compound for field n°"<<i<<"in file |"<<_fileName<<"| !");
+
+ componentName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
+ unitName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
+
+ err = MED_FR::MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
+ unitName, numberOfComponents) ;
+
+ MESSAGE("Champ "<<i<<" : #" << fieldName <<"# et recherche #"<<_fieldName.c_str()<<"#");
+ if ( !strcmp(fieldName,_fieldName.c_str()) ) {
+ MESSAGE("FOUND FIELD "<< fieldName <<" : "<<i);
+ _fieldNum = i ;
+ break ;
+ }
+ }
+ }
+
+ delete[] fieldName ;
+
+ if (_fieldNum==MED_INVALID)
+ throw MEDEXCEPTION(LOCALIZED( STRING(LOC) << ": Field "<<_fieldName << " not found in file " << _fileName ) );
+ MESSAGE ("FieldNum : "<<_fieldNum);
+
+ // int err ;
+ // int NumberOfComponents = MED_FR::MEDnChamp(_medIdt,_fieldNum) ;
+ if (numberOfComponents < 1)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no component")) ; // use iostring !
+ // test type to check if it is rigth !!!???
+ _ptrField->_numberOfComponents = numberOfComponents ;
+ _ptrField->_componentsTypes = new int[numberOfComponents] ;
+ _ptrField->_componentsNames = new string[numberOfComponents] ;
+ _ptrField->_componentsUnits = new UNIT[numberOfComponents] ;
+ _ptrField->_componentsDescriptions = new string[numberOfComponents] ;
+ _ptrField->_MEDComponentsUnits = new string[numberOfComponents] ;
+ for (int i=0; i<numberOfComponents; i++) {
+ _ptrField->_componentsTypes[i] = 1 ;
+
+ // PG : what about space !!!
+ _ptrField->_componentsNames[i] = string(componentName,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
+ SCRUTE(_ptrField->_componentsNames[i]);
+ _ptrField->_MEDComponentsUnits[i] = string(unitName,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
+ SCRUTE(_ptrField->_MEDComponentsUnits[i]);
+ }
+ delete[] componentName;
+ delete[] unitName;
+
+ // read values for each geometric type in _support
+ int NumberOfTypes = _ptrField->_support->getNumberOfTypes() ;
+ medGeometryElement *Types = _ptrField->_support->getTypes() ;
+ T ** myValues = new (T*)[NumberOfTypes] ;
+ int * NumberOfValues = new int[NumberOfTypes] ;
+ int TotalNumberOfValues = 0 ;
+ MESSAGE ("NumberOfTypes :"<< NumberOfTypes);
+ for (int i=0; i<NumberOfTypes; i++) {
+ MESSAGE ("Type["<<i+1<<"] :"<< Types[i]);
+ MESSAGE ("Entity :"<<_ptrField->_support->getEntity());
+ NumberOfValues[i] =
+ MEDnVal(_medIdt,
+ const_cast <char*> (_fieldName.c_str()),
+ (MED_FR::med_entite_maillage)_ptrField->_support->getEntity(),
+ (MED_FR::med_geometrie_element)Types[i],
+ _ptrField->_iterationNumber,
+ _ptrField->_orderNumber) ; // no time step ! prend en compte le nbre de pt de gauss
+ // test if NumberOfValues is the same in _support !!! TODO that !!
+ // we suppose it is
+ // we could allocate array
+ myValues[i] = new T[ NumberOfValues[i]*numberOfComponents ] ;
+ TotalNumberOfValues+=NumberOfValues[i] ;// diviser par le nombre de point de gauss
+ char * ProfilName = new char[MED_TAILLE_NOM+1];
+ MESSAGE ("NumberOfValues :"<< NumberOfValues[i]);
+ MESSAGE ("NumberOfComponents :"<< numberOfComponents);
+ MESSAGE ("MESH_NAME :"<< MeshName.c_str());
+ MESSAGE ("FIELD_NAME :"<< _fieldName.c_str());
+ MESSAGE ("MED_ENTITE :"<< (MED_FR::med_entite_maillage) _ptrField->_support->getEntity());
+ MESSAGE("MED_GEOM :"<<(MED_FR::med_geometrie_element)Types[i]);
+ MESSAGE("Iteration :"<<_ptrField->getIterationNumber());
+ MESSAGE("Order :"<<_ptrField->getOrderNumber());
+ if ( MED_FR::MEDchampLire(_medIdt,const_cast <char*> (MeshName.c_str()),
+ const_cast <char*> (_fieldName.c_str()),
+ (unsigned char*) myValues[i],
+ MED_FR::MED_NO_INTERLACE,
+ MED_ALL,
+ ProfilName,
+ (MED_FR::med_entite_maillage) _ptrField->_support->getEntity(),(MED_FR::med_geometrie_element)Types[i],
+ _ptrField->getIterationNumber(),
+ _ptrField->getOrderNumber()
+ ) < 0) {
+ // we must do some delete !!!
+ _fieldNum = MED_INVALID ; // we have not found right field, so reset the field number
+ throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": ERROR when read value")) ;
+ }
+
+ delete[] ProfilName ;
+ }
+ // allocate _value
+ // probleme avec les points de gauss : voir lorsqu-il y en a (!= 1)
+ // MEDARRAY<T> * Values = new MEDARRAY<T>(_ptrField->getNumberOfComponents(),TotalNumberOfValues/_ptrField->getNumberOfComponents(),MED_EN::MED_NO_INTERLACE);
+
+ if (_ptrField->_value==NULL)
+ _ptrField->_value=new MEDARRAY<T>(numberOfComponents,TotalNumberOfValues,MED_EN::MED_NO_INTERLACE);
+
+ MEDARRAY<T> * Values = _ptrField->_value ; // create by constructor ???
+ // check if dimensions are right
+ if (Values->getLeadingValue() != numberOfComponents)
+ throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": leading dimension are false : "<<Values->getLeadingValue()<<" and "<<numberOfComponents) ) ;
+ if (Values->getLengthValue() != TotalNumberOfValues)
+ throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": length dimension are false : "<<Values->getLengthValue()<<" and "<<TotalNumberOfValues) ) ;
+
+ for (int i=0; i<numberOfComponents; i++) {
+ T * ValuesT = Values->getI(MED_NO_INTERLACE,i+1) ;
+ int Count = 0 ;
+ for (int j=0; j<NumberOfTypes; j++) {
+ T * myValue = myValues[j] ;
+ int NumberOf = NumberOfValues[j] ;
+ int offset = NumberOf*i ;
+ for (int k=0 ; k<NumberOf; k++) {
+ ValuesT[Count]=myValue[k+offset] ;
+ Count++;
+ }
+ }
+ }
+
+ for (int j=0; j<NumberOfTypes; j++)
+ delete[] myValues[j] ;
+ delete[] myValues ;
+ delete[] NumberOfValues ;
+ }
+ END_OF(LOC);
+}
+
+template <class T> void MED_FIELD_RDONLY_DRIVER<T>::write( void ) const
+{
+ throw MEDEXCEPTION("MED_FIELD_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
+}
+
+/*--------------------- WRONLY PART -------------------------------*/
+
+template <class T> void MED_FIELD_WRONLY_DRIVER<T>::read (void)
+{
+ throw MEDEXCEPTION("MED_FIELD_WRONLY_DRIVER::write : Can't read with a WRONLY driver !");
+}
+
+template <class T> void MED_FIELD_WRONLY_DRIVER<T>::write(void) const
+{
+ const char * LOC = "MED_FIELD_WRONLY_DRIVER::write(void) const " ;
+ BEGIN_OF(LOC);
+ if (_status==MED_OPENED)
+ {
+ int err ;
+
+ int component_count=_ptrField->getNumberOfComponents();
+ string component_name(component_count*MED_TAILLE_PNOM,' ') ;
+ string component_unit(component_count*MED_TAILLE_PNOM,' ') ;
+
+ string * listcomponent_name=_ptrField->getComponentsNames() ;
+ string * listcomponent_unit=_ptrField->getMEDComponentsUnits() ;
+ int length ;
+ for (int i=0; i < component_count ; i++) {
+ length = min(MED_TAILLE_PNOM,(int)listcomponent_name[i].size());
+ component_name.replace(i*MED_TAILLE_PNOM,length,
+ listcomponent_name[i],0,length);
+ length = min(MED_TAILLE_PNOM,(int)listcomponent_unit[i].size());
+ component_unit.replace(i*MED_TAILLE_PNOM,length,
+ listcomponent_unit[i],0,length);
+ }
+
+ MESSAGE("component_name=|"<<component_name<<"|");
+ MESSAGE("component_unit=|"<<component_unit<<"|");
+
+ MED_EN::med_type_champ ValueType=_ptrField->getValueType() ;
+
+ // le champ existe deja ???
+ char * champName = new char[MED_TAILLE_NOM+1] ;
+ MED_FR::med_type_champ type ;
+ char * compName ;
+ char * compUnit ;
+ bool Find = false ;
+ int n = MED_FR::MEDnChamp(_medIdt,0);
+ int nbComp ;
+ for (int i=1; i<=n; i++) {
+ nbComp = MED_FR::MEDnChamp(_medIdt,i);
+ compName = new char[MED_TAILLE_PNOM*nbComp+1];
+ compUnit = new char[MED_TAILLE_PNOM*nbComp+1];
+ err = MED_FR::MEDchampInfo(_medIdt,i,champName,&type,compName,compUnit,nbComp);
+ if (err == 0)
+ if (strcmp(champName,_ptrField->getName().c_str())==0) { // Found !
+ Find = true ;
+ break ;
+ }
+ delete[] compName ;
+ delete[] compUnit ;
+ }
+ delete[] champName ;
+ if (Find) {
+ // the same ?
+ if (nbComp != component_count)
+ throw MEDEXCEPTION( LOCALIZED (STRING(LOC)
+ <<": Field exist in file, but number of component are different : "<<nbComp<<" in file and "<<component_count<<" in memory."
+ )
+ );
+ // component name and unit
+ MESSAGE(LOC<<" Component name in file : "<<compName);
+ MESSAGE(LOC<<" Component name in memory : "<<component_name);
+ MESSAGE(LOC<<" Component unit in file : "<<compUnit);
+ MESSAGE(LOC<<" Component unit in memory : "<<component_unit);
+ delete[] compName ;
+ delete[] compUnit ;
+
+ } else {
+ // Verify the field doesn't exist
+
+ string dataGroupName = "/CHA/";
+ dataGroupName += _ptrField->getName();
+ MESSAGE(LOC << "|" << dataGroupName << "|" );
+ med_idt gid = H5Gopen(_medIdt, dataGroupName.c_str() );
+
+ if ( gid < 0 ) {
+ // create field :
+ err=MED_FR::MEDchampCr(_medIdt,
+ const_cast <char*> ((_ptrField->getName()).c_str()),
+ (MED_FR::med_type_champ) ValueType,
+ const_cast <char*> ( component_name.c_str() ),
+ const_cast <char*> ( component_unit.c_str() ),
+ component_count);
+ if ( err < 0 )
+ throw MEDEXCEPTION( LOCALIZED (STRING(LOC)
+ << ": Error MEDchampCr : "<<err
+ )
+ );
+ }
+ else H5Gclose(gid);
+ }
+
+ const SUPPORT * mySupport = _ptrField->getSupport() ;
+
+ if (! mySupport->isOnAllElements())
+ throw MEDEXCEPTION( LOCALIZED (STRING(LOC)
+ <<": Field must be on all entity"
+ )
+ );
+
+ MESH * myMesh = mySupport->getMesh() ;
+ string MeshName = myMesh->getName() ;
+ //MED_EN::medModeSwitch Mode = _ptrField->_value->getMode() ;
+ // on boucle sur tout les types pour ecrire les tableaux de valeur
+ int NumberOfType = mySupport->getNumberOfTypes() ;
+ int Index = 1 ;
+ medGeometryElement * Types = mySupport->getTypes() ;
+ int * NumberOfGaussPoint = mySupport->getNumberOfGaussPoint() ;
+ for (int i=0;i<NumberOfType;i++) {
+ int NumberOfElements = mySupport->getNumberOfElements(Types[i]) ;
+
+ MESSAGE(" "<<_ptrField->getName());
+ MESSAGE(" "<<NumberOfElements);
+ MESSAGE(" "<<NumberOfGaussPoint[i]);
+ MESSAGE(" "<<mySupport->getEntity());
+ MESSAGE(" "<<Types[i]);
+ MESSAGE(" "<<_ptrField->getIterationNumber());
+ MESSAGE(" "<<_ptrField->getTime());
+ MESSAGE(" "<<_ptrField->getOrderNumber());
+ MESSAGE("MEDchampEcr :"<<MeshName.c_str());
+
+ T * value = _ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ;
+
+ err=MED_FR::MEDchampEcr(_medIdt, const_cast <char*> ( MeshName.c_str()) , //( string(mesh_name).resize(MED_TAILLE_NOM).c_str())
+ const_cast <char*> ( (_ptrField->getName()).c_str()),
+ (unsigned char*)value, MED_FR::MED_FULL_INTERLACE,
+ NumberOfElements,
+ NumberOfGaussPoint[i],MED_ALL, MED_NOPFL, MED_FR::MED_REMP, // PROFIL NON GERE, mode de remplacement non géré
+ (MED_FR::med_entite_maillage)mySupport->getEntity(),
+ (MED_FR::med_geometrie_element)Types[i],
+ _ptrField->getIterationNumber()," ",
+ _ptrField->getTime(),_ptrField->getOrderNumber()
+ );
+ if (err < MED_VALID )
+ throw MEDEXCEPTION(LOCALIZED( STRING(LOC)
+ <<": Error in writing Field "<< _ptrField->getName() <<", type "<<Types[i]
+ )
+ );
+ Index += NumberOfElements ;
+
+ }
+ }
+
+ END_OF(LOC);
+}
+
+/*--------------------- RDWR PART -------------------------------*/
+
+template <class T> void MED_FIELD_RDWR_DRIVER<T>::write(void) const
+{
+ BEGIN_OF("MED_FIELD_RDWR_DRIVER::write(void)");
+ MED_FIELD_WRONLY_DRIVER<T>::write();
+ END_OF("MED_FIELD_RDWR_DRIVER::write(void)");
+}
+
+template <class T> void MED_FIELD_RDWR_DRIVER<T>::read (void)
+{
+ BEGIN_OF("MED_FIELD_RDWR_DRIVER::read(void)");
+ MED_FIELD_RDONLY_DRIVER<T>::read();
+ END_OF("MED_FIELD_RDWR_DRIVER::read(void)");
+}
+
+/*-----------------------------------------------------------------*/
+
+#endif /* MED_FIELD_DRIVER_HXX */
+
--- /dev/null
+# include <string>
+
+# include "MEDMEM_MedMedDriver.hxx"
+
+# include "MEDMEM_DriversDef.hxx"
+
+# include "MEDMEM_Mesh.hxx"
+# include "MEDMEM_Field.hxx"
+// EN ATTENDANT L'utilisation de MedFieldDriver.hxx ds Field.hxx
+# include "MEDMEM_MedFieldDriver.hxx"
+# include "MEDMEM_Med.hxx"
+
+# include "MEDMEM_define.hxx"
+
+using namespace MED_FR;
+
+MED_MED_DRIVER::MED_MED_DRIVER(): GENDRIVER(),
+ _ptrMed((MED * const)MED_NULL),
+ _medIdt(MED_INVALID)
+{}
+
+MED_MED_DRIVER::MED_MED_DRIVER(const string & fileName, MED * const ptrMed):
+ GENDRIVER(fileName,MED_EN::MED_RDWR), _ptrMed(ptrMed), _medIdt(MED_INVALID)
+{}
+
+MED_MED_DRIVER::MED_MED_DRIVER(const string & fileName,
+ MED * const ptrMed,
+ MED_EN::med_mode_acces accessMode):
+ GENDRIVER(fileName,accessMode), _ptrMed(ptrMed), _medIdt(MED_INVALID)
+{}
+
+//REM : As t'on besoin du champ _status : _medIdt <-> _status ? Oui
+
+
+void MED_MED_DRIVER::open() {
+
+ const char * LOC ="MED_MED_DRIVER::open() : ";
+ BEGIN_OF(LOC);
+
+ // REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE
+ if ( _medIdt != MED_INVALID )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "_medIdt is already in use, please close the file |"
+ << _fileName << "| before calling open()"
+ )
+ );
+
+ if ( _status != MED_CLOSED )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "_status is closed, please close the file |"
+ << _fileName << "| before calling open()"
+ )
+ );
+
+ if ( _fileName == "" )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "_fileName is |\"\"|, please set a correct fileName before calling open()"
+ )
+ );
+
+ _medIdt = MEDouvrir( (const_cast <char *> (_fileName.c_str())), (MED_FR::med_mode_acces) _accessMode);
+
+ if (_medIdt > 0) _status=MED_OPENED;
+ else {
+ _status = MED_CLOSED;
+ _medIdt = MED_INVALID;
+ throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
+ << "Can't open |" << _fileName
+ << "|, _medIdt : " << _medIdt
+ )
+ );
+ }
+
+ END_OF(LOC);
+}
+
+
+void MED_MED_DRIVER::close() {
+ MED_FR::med_int err = 0;
+ const char * LOC = "MED_MED_DRIVER::close() : ";
+
+
+ if ( _status == MED_CLOSED)
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
+ << _fileName << "| is already closed"
+ )
+ );
+
+ if ( _medIdt == MED_INVALID )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_medIdt invalid, but the file |"
+ << _fileName << "| seems to be openned !"
+ )
+ );
+
+ err=MEDfermer(_medIdt);
+
+ _status = MED_CLOSED;
+ _medIdt = MED_INVALID;
+
+ if (err != MED_VALID)
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
+ << _fileName << "| couldn't be closed"
+ )
+ );
+
+ END_OF(LOC);
+}
+
+
+
+void MED_MED_DRIVER::readFileStruct( void )
+{
+ const char * LOC = "MED_MED_DRIVER::readFileStruct() : ";
+ int err,i,j;
+
+ BEGIN_OF(LOC);
+
+ if ( _medIdt == MED_INVALID )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "_medIdt is invalid, please open the file |"
+ << _fileName << "| before calling readFileStruct()"
+ )
+ );
+ // Read number of meshes and their associated name
+ {
+ int numberOfMeshes;
+ char meshName[MED_TAILLE_NOM+1]="";
+ int meshDim;
+ MESH * ptrMesh;
+ MED_MESH_RDWR_DRIVER * ptrDriver;
+
+ numberOfMeshes = MEDnMaa(_medIdt) ;
+ if ( numberOfMeshes <= 0 )
+ MESSAGE(LOC << "Be careful there is no mesh in file |"<<_fileName<<"| !");
+
+ MESH_ENTITIES::const_iterator currentEntity;
+ for (i=1;i<=numberOfMeshes;i++) {
+ err = MEDmaaInfo(_medIdt, i ,meshName, &meshDim) ;
+ if (err != MED_VALID)
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": can't get information about the mesh n°"
+ << i <<" of the file |" << _fileName << "| !"
+ )
+ );
+ MESSAGE(LOC<<": Mesh n°"<<i<<" nammed "<<meshName);
+
+ ptrMesh = new MESH();
+ // NO : create a MED_MESH_RDWR_DRIVER with the currently used
+ // _medIdt which remains VALID as long as _fileName is openned
+ // NO: then as long as the MED driver remains open
+ MED_MESH_RDWR_DRIVER * _ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
+ _ptrDriver->setMeshName(meshName);
+ ptrMesh->addDriver(*_ptrDriver);
+ _ptrMed->_meshes[meshName] = ptrMesh;
+ // we create all global support (for each entity type :
+ for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
+ string supportName="SupportOnAll_" ;
+ supportName+=entNames[(MED_FR::med_entite_maillage)(*currentEntity).first] ;
+ (_ptrMed->_support)[meshName][(MED_FR::med_entite_maillage)(*currentEntity).first]=new SUPPORT(ptrMesh,supportName,(MED_EN::medEntityMesh) (*currentEntity).first) ;
+ }
+ }
+ }
+
+
+ // Read number of fields, their associated name and their list of (timeStepNumber,iterationNumber)
+ {
+ int numberOfFields = 0; //MED_INVALID
+ // char fieldName[MED_TAILLE_NOM+1] = "";
+ char fieldName[MED_TAILLE_NOM+1] ;
+ int numberOfComponents = 0;
+ char * componentName = (char *) MED_NULL;
+ char * unitName = (char *) MED_NULL;
+ // char meshName[MED_TAILLE_NOM+1] = "";
+ char meshName[MED_TAILLE_NOM+1] ;
+ MED_FR::med_type_champ type;
+ MESH * ptrMesh = (MESH *) MED_NULL;
+ FIELD_ * ptrField = (FIELD_ *) MED_NULL;
+ //MED_FIELD_RDWR_DRIVER * ptrDriver = (MED_FIELD_RDWR_DRIVER * ) MED_NULL;
+ GENDRIVER * ptrDriver = (GENDRIVER * ) MED_NULL;
+ SUPPORT * ptrSupport = (SUPPORT * ) MED_NULL;
+ MESH_ENTITIES::const_iterator currentEntity;
+ list<MED_FR::med_geometrie_element>::const_iterator currentGeometry;
+ int NbOfGaussPts = 0;
+ int numberOfTimeSteps = -1;
+ int timeStepNumber = -1;
+ // char timeStepUnit[MED_TAILLE_PNOM]= "";
+ char timeStepUnit[MED_TAILLE_PNOM+1] ;
+ double timeStep = 0.0;
+ int orderNumber = -1; //???init?????
+ map<MESH_NAME_,MESH*> & _meshes = _ptrMed->_meshes;
+ map<FIELD_NAME_,MAP_DT_IT_> & _fields = _ptrMed->_fields;
+ map<FIELD_ *, MESH_NAME_> & _meshName = _ptrMed->_meshName;
+ map<MESH_NAME_, map<MED_FR::med_entite_maillage,SUPPORT *> > & _support = _ptrMed->_support;
+
+
+ numberOfFields = MEDnChamp(_medIdt,0) ;
+ if ( numberOfFields <= 0 )
+ MESSAGE(LOC << "Be careful there is no field in file |"<<_fileName<<"| !");
+
+ for (i=1;i<=numberOfFields;i++) {
+
+ numberOfComponents = MEDnChamp(_medIdt,i) ;
+ if ( numberOfComponents <= 0 )
+ if (err != MED_VALID)
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Be careful there is no compound for field n°"
+ << i << "in file |"<<_fileName<<"| !"));
+
+ componentName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
+ unitName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
+
+ err = MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
+ unitName, numberOfComponents) ;
+
+ if (err != MED_VALID)
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << ": can't get information about the field n°"
+ << i <<" of the file |" << _fileName << "| !"));
+
+ MESSAGE(LOC << "Field n°"<<i<<" nammed "<< fieldName
+ << " ,component(s) : " << componentName
+ <<" ,unit(s) : " << unitName);
+
+
+ // Loop on all (entity type,geometry type) until you find an existing one then
+ // get the (n°dt,n°it) pairs list for the current (field,entity type,geometry type)
+ // We suppose there is the same list whatever the existing (entity type,geometry type) pair
+ // support map :
+ for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
+ // numberOfTimeSteps MUST be given by MEDchampInfo !!!!!
+ for (currentGeometry = (*currentEntity).second.begin();currentGeometry != (*currentEntity).second.end(); currentGeometry++) {
+ MESSAGE("Field information with Entity,Geom = "<<(*currentEntity).first<<","<<(*currentGeometry));
+ numberOfTimeSteps = MEDnPasdetemps(_medIdt, fieldName,
+ (MED_FR::med_entite_maillage)(*currentEntity).first,
+ (MED_FR::med_geometrie_element) (*currentGeometry) );
+ MESSAGE("Field information 2 : NumberOfTimeStep :"<<numberOfTimeSteps);
+ if ( numberOfTimeSteps > MED_VALID )
+ break ; // There are value for some med_geometrie_element of this med_entite_maillage.
+ }
+ if (numberOfTimeSteps>0) // we have at least one
+
+ for (currentGeometry = (*currentEntity).second.begin();currentGeometry != (*currentEntity).second.end(); currentGeometry++) {
+
+ MESSAGE("Field information 3 : Geom : "<<(*currentGeometry));
+ for (j=1;j <= numberOfTimeSteps; j++) {
+
+ MESSAGE("Field information 4 : time step j = "<<j);
+ err = MEDpasdetempsInfo( _medIdt, fieldName,
+ (MED_FR::med_entite_maillage) (*currentEntity).first,
+ (*currentGeometry),j,
+ meshName, &NbOfGaussPts,
+ &timeStepNumber, timeStepUnit, &timeStep,
+ &orderNumber);
+ if (err == MED_VALID) { // we have found for (*currentEntity).first and (*currentGeometry)
+
+ MESSAGE("Field information 5 ;: NumberOfGaussPoint : "<<NbOfGaussPts<<", timeStepNumber : "<<timeStepNumber);
+ // CORRECT a bug in MEDpasdetempsInfo :
+ // we get a value n'importe quoi in NbOfGaussPts !!!!
+
+ if (NbOfGaussPts>100)
+ NbOfGaussPts=1 ;
+ if (timeStepNumber<0)
+ timeStepNumber=-1 ;
+
+
+ // ATTENTION TRAITER L'EXCEPTION !!!!!!!!!!!!
+
+ // Il faudra traiter le cas d'un champ qui utilise +sieurs (entity,geom) voir le travail de patrick
+ // Il faudra traiter le cas des profils...
+ // ptrField = new FIELD();
+ // _ptrDriver = new MED_FIELD_RDWR_DRIVER(_fileName, ptrField);
+ // ptrField->addDriver(_ptrDriver);
+ // _fields[fieldName]=ptrField;
+
+ // Verify meshName is already known
+
+ map<MESH_NAME_,MESH*>::iterator _meshesIt = _meshes.find(meshName);
+ if ( _meshesIt == _meshes.end() ) {
+ MESSAGE(LOC << "There is no mesh |"
+ << meshName <<"| in the file |"
+ << _fileName <<"|, but |" << meshName <<"| is referenced by field |"
+ << fieldName <<"|, entity : |"
+ << entNames [ (MED_FR::med_entite_maillage) (*currentEntity).first] <<"|, geometric element of type |"
+ << geoNames [ (MED_FR::med_geometrie_element) (*currentGeometry)] <<"|"
+ );
+ } // POURQUOI SI JE NE MET PAS DE BLOCK J'AI UN PARSE ERROR : PG : c'est la macro MESSAGE qui fait ca !
+ else
+ ptrMesh = _meshes[meshName];
+
+ ptrSupport = _support[meshName][(MED_FR::med_entite_maillage) (*currentEntity).first];
+ if (NbOfGaussPts != 1)
+ throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<"Number of Gauss Point must be equal to 1 for instance")) ;
+
+ // init to null to prevent some error if not correctly allocated !
+ ptrField = (FIELD_*)NULL ;
+ ptrDriver = (GENDRIVER*)NULL ;
+
+ switch ( type) {
+ case MED_FR::MED_INT64 :
+ if ( sizeof(MED_FR::med_int) != 8 )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
+ " The Field type of |"
+ << fieldName <<"|, entity : |"
+ << entNames [(MED_FR::med_entite_maillage) (*currentEntity).first] <<"|, geometric element of type |"
+ << geoNames [(MED_FR::med_geometrie_element) (*currentGeometry) ] <<
+ "| is MED_INT64 but size of med_int is not equal to 8 bytes !"
+ )
+ );
+ break;
+ case MED_FR::MED_INT32 : {
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
+// "NOT IMPLEMENTED : BUG IN STL !")
+// ) ;
+ // ptrField = new FIELD<MED_FR::med_int> ( ptrSupport,numberOfComponents ); // Les valeurs du champ ne doivent pas être lue pour l'instant
+
+ ptrField = new FIELD<MED_FR::med_int> ( ); // Les valeurs du champ ne doivent pas être lue pour l'instant
+ ((FIELD<MED_FR::med_int>*) ptrField)->setSupport(ptrSupport);
+ ((FIELD<MED_FR::med_int>*) ptrField)->setNumberOfComponents(numberOfComponents);
+ ((FIELD<MED_FR::med_int>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
+ MESSAGE("#### SET NAME in FIELD : "<<fieldName);
+ ptrDriver = new MED_FIELD_RDWR_DRIVER<MED_FR::med_int> (_fileName, (FIELD<MED_FR::med_int> *) ptrField);
+ break;
+ }
+ case MED_FR::MED_REEL64 : {
+ // ptrField = new FIELD<MED_FR::med_float> ( ptrSupport,numberOfComponents ); // Les valeurs du champ ne doivent pas être lue pour l'instant
+ ptrField = new FIELD<MED_FR::med_float> ( ); // Les valeurs du champ ne doivent pas être lue pour l'instant
+ ((FIELD<MED_FR::med_float>*) ptrField)->setSupport(ptrSupport);
+ ((FIELD<MED_FR::med_float>*) ptrField)->setNumberOfComponents(numberOfComponents);
+ ((FIELD<MED_FR::med_float>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
+ MESSAGE("#### SET NAME in FIELD : "<<fieldName);
+
+ ptrDriver = new MED_FIELD_RDWR_DRIVER<MED_FR::med_float>(_fileName, (FIELD<MED_FR::med_float> *) ptrField);
+ break;
+ }
+ default : {
+ if ( numberOfTimeSteps > 1)
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
+ " The Field type of |"
+ << fieldName <<"|, entity : |"
+ << entNames [(MED_FR::med_entite_maillage) (*currentEntity).first]
+ <<"|, geometric element of type |"
+ << geoNames [(MED_FR::med_geometrie_element) (*currentGeometry)]
+ <<"| is neither MED_INT, MED_INT32, MED_INT64 nor MED_REEL64 !"
+ )
+ );
+ break ;
+ }
+ }
+ ptrField->setValueType((MED_EN::med_type_champ) type) ; // need to write field !
+
+ MESSAGE("timeStepNumber :"<<timeStepNumber<<",orderNumber :"<<orderNumber);
+ ptrField->setIterationNumber ( timeStepNumber); // A ajouter dans la classe FIELD
+ ptrField->setOrderNumber ( orderNumber);
+ ptrField->setTime ( timeStep);
+
+ // Create a driver for this (field n°dt,n°it)
+
+ MESSAGE("###### ptrDriver->setFieldName : #"<<fieldName<<"#");
+ ptrDriver->setFieldName(fieldName);
+
+ ptrField->addDriver(*ptrDriver);
+
+ DT_IT_ dtIt;
+ dtIt.dt = timeStepNumber;
+ dtIt.it = orderNumber;
+
+ (_fields [fieldName])[dtIt] = ptrField;
+ _meshName[ptrField ] = meshName;
+ }
+ }
+ }
+ }
+ delete[] componentName ;
+ delete[] unitName ;
+ }
+ }
+
+ // read profil count and their names
+ int support_count_= 0 ;
+ // il faut lire les champs pour avoir les profils stockes !!!
+ // il faudrait implémenter la lecture des profils dans med !!!
+
+ END_OF(LOC);
+
+}
+
+void MED_MED_DRIVER::read( void ) {
+
+ const char * LOC = "MED_MED_DRIVER::read() : ";
+
+ BEGIN_OF(LOC);
+ MESSAGE("METHODE PAS ENCORE IMPLEMENTEE !!! ");
+ END_OF(LOC);
+}
+
+void MED_MED_DRIVER::writeFrom( void) const {
+
+ const char * LOC = "MED_MED_DRIVER::writeFrom() : ";
+
+ BEGIN_OF(LOC);
+
+ const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
+ map<MESH_NAME_,MESH*>::const_iterator currentMesh;
+
+ const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
+ map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
+
+ for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
+ try {
+ (*currentMesh).second->write(*this);
+ // A CREER pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id
+ }
+ catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
+ continue;
+ }
+ // catch (const MED_EXCEPTION & ex) {
+ // throw ex; // DOIT-ON CREER UNE NOUVELLE EXCEPTION AVEC UN MESSAGE INDIQUANT LA PILE
+ // }
+ }
+
+ for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
+ try {
+ (*currentField).first->write(*this);
+ }
+ catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
+ continue;
+ }
+ }
+
+ END_OF(LOC);
+
+}
+
+void MED_MED_DRIVER::write(void ) const {
+
+ const char * LOC = "MED_MED_DRIVER::write() : ";
+
+ BEGIN_OF(LOC);
+
+ // BCLE SUR LES DRIVERS AVEC APPELS WriteFrom
+ END_OF(LOC);
+
+}
+
+MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed):
+ MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_RDONLY)
+{
+ MESSAGE("MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed) Constructeur read only");
+}
+
+void MED_MED_RDONLY_DRIVER::open() {
+ BEGIN_OF("MED_MED_RDONLY_DRIVER::open()");
+ MED_MED_DRIVER::open();
+ END_OF("MED_MED_RDONLY_DRIVER::open()");
+}
+
+void MED_MED_RDONLY_DRIVER::close() {
+ BEGIN_OF("MED_MED_RDONLY_DRIVER::close()");
+ MED_MED_DRIVER::close();
+ END_OF("MED_MED_RDONLY_DRIVER::clode()");
+}
+
+void MED_MED_RDONLY_DRIVER::read(void) {
+ BEGIN_OF("MED_MED_RDONLY_DRIVER::read(void)");
+ MED_MED_DRIVER::read();
+ END_OF("MED_MED_RDONLY_DRIVER::read(void)");
+}
+
+void MED_MED_RDONLY_DRIVER::readFileStruct(void) {
+ BEGIN_OF("MED_MED_RDONLY_DRIVER::readFileStruct(void)");
+ MED_MED_DRIVER::readFileStruct();
+ END_OF("MED_MED_RDONLY_DRIVER::readFileStruct(void)");
+}
+
+MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed):
+ MED_MED_DRIVER(fileName,ptrMed)
+{}
+
+void MED_MED_WRONLY_DRIVER::open() {
+ BEGIN_OF("MED_MED_WRONLY_DRIVER::open()");
+ MED_MED_DRIVER::open();
+ END_OF("MED_MED_WRONLY_DRIVER::open()");
+}
+
+void MED_MED_WRONLY_DRIVER::close() {
+ BEGIN_OF("MED_MED_WRONLY_DRIVER::close()");
+ MED_MED_DRIVER::close();
+ END_OF("MED_MED_WRONLY_DRIVER::clode()");
+}
+
+void MED_MED_WRONLY_DRIVER::write(void) const {
+ BEGIN_OF("MED_MED_WRONLY_DRIVER::write(void) const");
+ MED_MED_DRIVER::write();
+ END_OF("MED_MED_WRONLY_DRIVER::write(void) const");
+}
+
+void MED_MED_WRONLY_DRIVER::writeFrom(void) const {
+ BEGIN_OF("MED_MED_WRONLY_DRIVER::writeFrom(void) const");
+ MED_MED_DRIVER::writeFrom();
+ END_OF("MED_MED_WRONLY_DRIVER::writeFrom(void) const");
+}
+
+MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER(const string & fileName, MED * const ptrMed):
+ MED_MED_DRIVER(fileName,ptrMed)
+{}
+
+void MED_MED_RDWR_DRIVER::open() {
+ BEGIN_OF("MED_MED_RDWR_DRIVER::open()");
+ MED_MED_DRIVER::open();
+ END_OF("MED_MED_RDWR_DRIVER::open()");
+}
+
+void MED_MED_RDWR_DRIVER::close() {
+ BEGIN_OF("MED_MED_RDWR_DRIVER::close()");
+ MED_MED_DRIVER::close();
+ END_OF("MED_MED_RDWR_DRIVER::clode()");
+}
+
+void MED_MED_RDWR_DRIVER::read(void) {
+ BEGIN_OF("MED_MED_RDWR_DRIVER::read(void)");
+ MED_MED_RDONLY_DRIVER::read();
+ END_OF("MED_MED_RDWR_DRIVER::read(void)");
+}
+
+void MED_MED_RDWR_DRIVER::readFileStruct(void) {
+ BEGIN_OF("MED_MED_RDWR_DRIVER::readFileStruct(void)");
+ MED_MED_RDONLY_DRIVER::readFileStruct();
+ END_OF("MED_MED_RDWR_DRIVER::readFileStruct(void)");
+}
+
+void MED_MED_RDWR_DRIVER::write(void) const {
+ BEGIN_OF("MED_MED_RDWR_DRIVER::write(void) const");
+ MED_MED_WRONLY_DRIVER::write();
+ END_OF("MED_MED_RDWR_DRIVER::write(void) const");
+}
+
+void MED_MED_RDWR_DRIVER::writeFrom(void) const {
+ BEGIN_OF("MED_MED_RDWR_DRIVER::writeFrom(void) const");
+ MED_MED_WRONLY_DRIVER::writeFrom();
+ END_OF("MED_MED_RDWR_DRIVER::writeFrom(void) const");
+}
--- /dev/null
+#ifndef MED_MED_DRIVER_HXX
+#define MED_MED_DRIVER_HXX
+
+#include <string>
+#include "MEDMEM_STRING.hxx"
+#include "utilities.h"
+#include "MEDMEM_Exception.hxx"
+
+#include "MEDMEM_GenDriver.hxx"
+
+#include "MEDMEM_define.hxx"
+
+//using namaspace MED_FR ;
+
+class MESH;
+class FIELD_;
+class MED;
+
+// This driver pilots within a MED class read/write accesses of fields/meshes
+class MED_MED_DRIVER : public GENDRIVER
+{
+protected:
+
+ MED * const _ptrMed; // Store 'MED_DRIVER (0..n)----(1) MED' associations
+ med_idt _medIdt; // The _medIdt used to write/read Meshes to ::_filename
+
+ //private:
+ // MED_MED_DRIVER();
+
+public :
+ MED_MED_DRIVER();
+
+ MED_MED_DRIVER(const string & fileName, MED * const ptrMed);
+
+ MED_MED_DRIVER(const string & fileName, MED * const ptrMed,
+ MED_EN::med_mode_acces accessMode);
+ // OPERATEUR DE RECOPIE AVEC _medIdt ??
+
+ void open();
+ void close();
+
+ virtual void write ( void ) const ;
+ virtual void writeFrom ( void ) const ;
+ virtual void read ( void ) ;
+ virtual void readFileStruct ( void ) ;
+
+};
+
+class MED_MED_RDONLY_DRIVER : public virtual MED_MED_DRIVER
+{
+public :
+ MED_MED_RDONLY_DRIVER():MED_MED_DRIVER(){};
+
+ MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed);
+
+ ~MED_MED_RDONLY_DRIVER() {
+ MESSAGE("MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER() has been destroyed");
+ }
+
+ void open();
+ void close();
+
+ void read ( void ) ;
+ void readFileStruct ( void ) ;
+};
+
+class MED_MED_WRONLY_DRIVER : public virtual MED_MED_DRIVER
+{
+
+public :
+ MED_MED_WRONLY_DRIVER():MED_MED_DRIVER(){};
+
+ MED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed);
+
+ ~MED_MED_WRONLY_DRIVER() {
+ MESSAGE("MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER() has been destroyed");
+ }
+
+ void open();
+ void close();
+
+ void write ( void ) const ;
+ void writeFrom ( void ) const ;
+};
+
+class MED_MED_RDWR_DRIVER : public virtual MED_MED_RDONLY_DRIVER,
+ public virtual MED_MED_WRONLY_DRIVER,
+ public virtual MED_MED_DRIVER
+{
+
+public :
+ MED_MED_RDWR_DRIVER():MED_MED_DRIVER(){};
+
+ MED_MED_RDWR_DRIVER(const string & fileName, MED * const ptrMed);
+
+ ~MED_MED_RDWR_DRIVER() {
+ MESSAGE("MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER() has been destroyed");
+ }
+
+ void open();
+ void close();
+
+ void write ( void ) const ;
+ void writeFrom ( void ) const ;
+ void read ( void ) ;
+ void readFileStruct ( void ) ;
+};
+
+#endif /* MED_MED_DRIVER_HXX */
--- /dev/null
+#include "MEDMEM_MedMeshDriver.hxx"
+
+#include "MEDMEM_DriversDef.hxx"
+
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Group.hxx"
+#include "MEDMEM_Coordinate.hxx"
+#include "MEDMEM_Connectivity.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_CellModel.hxx"
+
+extern "C" {
+ extern med_idt _MEDdatagroupOuvrir(med_idt pid, char *nom);
+ extern med_err _MEDdatagroupFermer(med_idt id);
+}
+using namespace MED_FR;
+
+// Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor
+
+void MED_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; };
+string MED_MESH_DRIVER::getMeshName() const { return _meshName; };
+
+//---------------------------------- RDONLY PART -------------------------------------------------------------
+
+//A FAIRE UTILISER LES MAPS...
+const MED_FR::med_geometrie_element MED_MESH_DRIVER::all_cell_type[MED_NBR_GEOMETRIE_MAILLE]=
+ { MED_FR::MED_POINT1,MED_FR::MED_SEG2,MED_FR::MED_SEG3,MED_FR::MED_TRIA3,MED_FR::MED_QUAD4,MED_FR::MED_TRIA6,MED_FR::MED_QUAD8,
+ MED_FR::MED_TETRA4,MED_FR::MED_PYRA5,MED_FR::MED_PENTA6,MED_FR::MED_HEXA8,MED_FR::MED_TETRA10,MED_FR::MED_PYRA13,
+ MED_FR::MED_PENTA15, MED_FR::MED_HEXA20};
+
+const char * const MED_MESH_DRIVER::all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE]=
+ { "MED_POINT1","MED_SEG2","MED_SEG3","MED_TRIA3","MED_QUAD4","MED_TRIA6","MED_QUAD8",
+ "MED_TETRA4","MED_PYRA5","MED_PENTA6","MED_HEXA8","MED_TETRA10","MED_PYRA13",
+ "MED_PENTA15","MED_HEXA20"};
+
+
+
+
+void MED_MESH_RDONLY_DRIVER::read(void)
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER::read() : " ;
+ BEGIN_OF(LOC);
+ if (_status!=MED_OPENED)
+ throw MEDEXCEPTION(" ");
+ //throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << _medIdt << " (the file is not opened)." )) ;
+
+ _ptrMesh->_name = _meshName;
+
+ if (getCOORDINATE()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOORDINATE" )) ;
+
+ if (getCONNECTIVITY()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOONECTIVITY")) ;
+
+ if (getFAMILY()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY" )) ;
+
+ updateFamily();
+
+ // we build all groups
+ // on node
+ buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
+ _ptrMesh->_numberOfNodesGroups = _ptrMesh->_groupNode.size() ;
+ // on cell
+ buildAllGroups(_ptrMesh->_groupCell,_ptrMesh->_familyCell) ;
+ _ptrMesh->_numberOfCellsGroups = _ptrMesh->_groupCell.size() ;
+ // on face
+ buildAllGroups(_ptrMesh->_groupFace,_ptrMesh->_familyFace) ;
+ _ptrMesh->_numberOfFacesGroups = _ptrMesh->_groupFace.size() ;
+ // on edge
+ buildAllGroups(_ptrMesh->_groupEdge,_ptrMesh->_familyEdge) ;
+ _ptrMesh->_numberOfEdgesGroups = _ptrMesh->_groupEdge.size() ;
+
+ END_OF(LOC);
+}
+
+
+// A FAIRE : RENVOYER DU VOID
+int MED_MESH_RDONLY_DRIVER::getCOORDINATE()
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER::getCOORDINATE() : " ;
+ BEGIN_OF(LOC);
+
+ if (_status==MED_OPENED)
+ {
+ int err ;
+
+ // Read the dimension of the space for the mesh <_meshName>
+ // to be able to create a COORDINATE object
+ int SpaceDimension = MEDdimLire(_medIdt,const_cast <char *> (_meshName.c_str())) ;
+ if ( SpaceDimension <= MED_VALID )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The space dimension |" << SpaceDimension << "| seems to be incorrect "
+ << "for the mesh : |" << _meshName << "|")) ;
+ _ptrMesh->_spaceDimension = SpaceDimension ;
+
+
+
+ // Read the number of nodes used in the mesh <_meshName>
+ // to be able to create a COORDINATE object
+ int NumberOfNodes=MEDnEntMaa(_medIdt,
+ const_cast <char *> (_meshName.c_str()),
+ MED_FR::MED_COOR,
+ MED_FR::MED_NOEUD,
+ (MED_FR::med_geometrie_element) MED_NONE,
+ (MED_FR::med_connectivite) MED_NONE);
+ if ( NumberOfNodes <= MED_VALID )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" << NumberOfNodes << "| seems to be incorrect "
+ << "for the mesh : |" << _meshName << "|" )) ;
+ _ptrMesh->_numberOfNodes = NumberOfNodes ;
+
+
+
+ // create a COORDINATE object
+ _ptrMesh->_coordinate = new COORDINATE(MED_EN::MED_FULL_INTERLACE, SpaceDimension, NumberOfNodes);
+
+ MED_FR::med_repere rep ; // ATTENTION ---> DOIT ETRE INTEGRE DS MESH EF: FAIT NON?
+ string tmp_nom_coord (MED_TAILLE_PNOM*(_ptrMesh->_spaceDimension)+1,'\0');
+ string tmp_unit_coord(MED_TAILLE_PNOM*(_ptrMesh->_spaceDimension)+1,'\0');
+ char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
+ char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
+
+ err=MEDcoordLire(_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ _ptrMesh->_spaceDimension,
+ const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
+ MED_FR::MED_FULL_INTERLACE,
+ MED_ALL, // we read all the coordinates
+ NULL, // we don't use a profile
+ 0, // so the profile's size is 0
+ &rep,tmp_nom,tmp_unit);
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" << NumberOfNodes << "| nodes "
+ << "for the mesh : |" << _meshName
+ << "| of space dimension |" << SpaceDimension
+ << "| with units names |" << tmp_nom
+ << "| and units |" << tmp_unit
+ << " |")) ;
+
+ for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
+ // PG : What about blank !!!!!
+ _ptrMesh->_coordinate->_coordinateName[i]=string(tmp_nom,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
+ _ptrMesh->_coordinate->_coordinateUnit[i]=string(tmp_unit,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM);
+ }
+
+ // Pourquoi le stocker sous forme de chaîne ?
+ switch (rep)
+ {
+ case MED_FR::MED_CART :
+ {
+ _ptrMesh->_coordinate->_coordinateSystem = "CARTESIAN";
+ break ;
+ }
+ case MED_FR::MED_CYL :
+ {
+ _ptrMesh->_coordinate->_coordinateSystem = "CYLINDRICAL";
+ break ;
+ }
+ case MED_FR::MED_SPHER :
+ {
+ _ptrMesh->_coordinate->_coordinateSystem = "SPHERICAL";
+ break ;
+ }
+ default :
+ {
+ _ptrMesh->_coordinate->_coordinateSystem = "UNDEFINED"; // ?Erreur ?
+ break ;
+ }
+ }
+
+ // Read the unused optionnal node Names
+ char * tmp_node_name = new char[NumberOfNodes*MED_TAILLE_PNOM+1];
+ tmp_node_name[NumberOfNodes]='\0' ;
+ err=MEDnomLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
+ tmp_node_name,NumberOfNodes*MED_TAILLE_PNOM,MED_FR::MED_NOEUD,
+ (MED_FR::med_geometrie_element) MED_NONE);
+ if (err == MED_VALID)
+ INFOS(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have names but we do not read them !");
+ delete[] tmp_node_name ;
+
+
+ // ??? Read the unused optionnal node Numbers ???
+ int * tmp_node_number = new int[NumberOfNodes] ;
+ err=MEDnumLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
+ tmp_node_number,NumberOfNodes,MED_NOEUD,(MED_FR::med_geometrie_element)0);
+ if (err == MED_VALID) {
+ INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
+ INFOS(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have numbers but we do not take care of them !");
+ INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
+ _ptrMesh->_coordinate->_nodeNumber = tmp_node_number ;
+ } else
+ delete[] tmp_node_number ;
+
+ END_OF(LOC);
+ return MED_VALID;
+ }
+ return MED_ERROR;
+}
+
+
+int MED_MESH_RDONLY_DRIVER::getCONNECTIVITY()
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER::getCONNECTIVITY : " ;
+ BEGIN_OF(LOC);
+
+ if (_status==MED_OPENED)
+ {
+
+ int err = 0 ;
+ // read MED_CELL connectivity
+ CONNECTIVITY * Connectivity = new CONNECTIVITY(MED_CELL) ;
+ Connectivity->_numberOfNodes = _ptrMesh->_numberOfNodes ; // EF : Pourquoi cet attribut est-il dans MESH et non dans COORDINATE ?
+
+ // Try to read nodal connectivity of the cells <Connectivity->_nodal>
+ // then try to read descending connectivity <Connectivity->_descending>
+ // if neither nodal nor descending connectivity exists
+ // throw an exception.
+ err = getNodalConnectivity(Connectivity) ;
+ if (err!=MED_VALID) {
+ Connectivity->_typeConnectivity = MED_DESCENDING ;
+ err = getDescendingConnectivity(Connectivity) ;
+ } else
+ getDescendingConnectivity(Connectivity) ; // we read it if there is one
+
+ if (err!=MED_VALID) {
+ delete Connectivity ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "We could not read any Connectivity")) ;
+ }
+
+ _ptrMesh->_meshDimension = Connectivity->_entityDimension ;
+
+ // At this point Connectivity->_typeConnectivity is either NODAL or DESCENDING
+ // If both connectivities are found Connectivity->_typeConnectivity is NODAL
+ // If space dimension is 3
+ // try to read the nodal connectivity of the faces <ConnectivityFace->_nodal> then
+ // try to read the descending connectivity <ConnectivityFace->_descending>
+ // if there is no descending connectivity and the CELLS are
+ // defined in descending mode then throw an exception
+
+ // PROVISOIRE : if we have some face or edge in MED_MAILLE, we don't read more. There could not be have face or edge !!!!
+
+ if(Connectivity->_constituent==NULL) {
+
+ SCRUTE(_ptrMesh->_meshDimension);
+ if (_ptrMesh->_meshDimension == 3) {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES FACES..." );
+ CONNECTIVITY * ConnectivityFace = new CONNECTIVITY(MED_EN::MED_FACE) ;
+ ConnectivityFace->_typeConnectivity = Connectivity->_typeConnectivity ; // NODAL or DESCENDING
+ SCRUTE(ConnectivityFace->_typeConnectivity);
+ if (Connectivity->_typeConnectivity == MED_DESCENDING) {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES FACES" );
+ err = getDescendingConnectivity(ConnectivityFace) ;
+ if (err!=MED_VALID)
+ throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No FACE in descending connectivity")) ;
+ getNodalConnectivity(ConnectivityFace) ; // if any !
+ } else {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES FACES" );
+ err = getNodalConnectivity(ConnectivityFace) ;
+ if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
+ err = getDescendingConnectivity(ConnectivityFace) ;
+ } else
+ getDescendingConnectivity(ConnectivityFace); // if any !
+ }
+ if (err!=MED_VALID) {
+ delete ConnectivityFace ;
+ MESSAGE(LOC<<"No FACE defined.") ;
+ } else {
+ MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES FACES DANS L'OBJET CONNECTIVITY" );
+ Connectivity->_constituent=ConnectivityFace ;
+ }
+ }
+
+ // read MED_EDGE connectivity
+ if (_ptrMesh->_meshDimension > 1) { // we are in 3 or 2D
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES ARRETES...." );
+ CONNECTIVITY * ConnectivityEdge = new CONNECTIVITY(MED_EDGE) ;
+ ConnectivityEdge->_typeConnectivity = Connectivity->_typeConnectivity ;
+ if (Connectivity->_typeConnectivity == MED_DESCENDING) {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES ARRETES" );
+ err = getDescendingConnectivity(ConnectivityEdge) ;
+ if (err!=MED_VALID)
+ throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No EDGE in descending connectivity")) ;
+ getNodalConnectivity(ConnectivityEdge) ; // if any !
+ } else {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES ARRETES" );
+ err = getNodalConnectivity(ConnectivityEdge) ;
+ if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
+ err = getDescendingConnectivity(ConnectivityEdge) ;
+ } else
+ getDescendingConnectivity(ConnectivityEdge) ; // if any !
+ }
+ if (err!=MED_VALID) {
+ delete ConnectivityEdge ;
+ MESSAGE(LOC<<"No EDGE defined.") ;
+ } else {
+ if (_ptrMesh->_meshDimension == 3)
+ if (Connectivity->_constituent != NULL)
+ Connectivity->_constituent->_constituent=ConnectivityEdge ;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "EDGE defined but there are no FACE !")) ;
+ else { // IN 2D
+ MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES ARETES DANS L'OBJET CONNECTIVITY" );
+ Connectivity->_constituent=ConnectivityEdge ;
+ }
+ }
+ }
+ }
+ _ptrMesh->_connectivity = Connectivity ;
+
+ // all right !
+
+ // we have read all connectivity in file, now we must build descending connectivity if necessary !
+
+ // If connectivity descending is defined, we have nothing to do, all constituent are defined !
+ // If connectivity is only nodal, we must rebuild descending if we have some contituent !
+
+ //A FAIRE !!!!
+// if (Connectivity->_descending == NULL)
+// if (Connectivity->_constituent != NULL){
+// // update Connectivity->_constituent
+// CONNECTIVITY * myConstituentOld = Connectivity->_constituent ;
+// Connectivity->_constituent = (CONNECTIVITY *)NULL ;
+// Connectivity->calculateDescendingConnectivity() ;
+
+// }
+
+ END_OF(LOC);
+ return MED_VALID;
+ }
+ return MED_ERROR;
+}
+
+int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER::getNodalConnectivity : " ;
+ BEGIN_OF(LOC);
+ if (_status==MED_OPENED)
+ {
+ // Get the type of entity to work on (previously set in the Connectivity Object)
+ MED_FR::med_entite_maillage Entity = (MED_FR::med_entite_maillage) Connectivity->getEntity();
+
+ // Get the number of cells of each type & store it in <tmp_cells_count>.
+ int * tmp_cells_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
+ for (int i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) { // EF :ON SCANNE DES GEOMETRIES INUTILES, UTILISER LES MAPS
+ tmp_cells_count[i]=MEDnEntMaa(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
+ MED_FR::MED_CONN,(MED_FR::med_entite_maillage) Entity,
+ all_cell_type[i],MED_FR::MED_NOD);
+
+ // We suppose there is no cells used as faces, this is forbidden !!!
+
+ // Only in version 2.2.x of MED, but before, it's right :-(
+
+ if (tmp_cells_count[i]>0) {
+ Connectivity->_entityDimension=all_cell_type[i]/100;
+ Connectivity->_numberOfTypes++;
+ }
+ }
+
+
+ // well if there is nothing, we quit !
+ if ( Connectivity->_numberOfTypes == 0 ) {
+ delete[] tmp_cells_count ;
+ return MED_ERROR ;
+ }
+
+ // if MED version < 2.2.x, we read only entity with dimention = Connectivity->_entityDimension. Lesser dimension are face or edge !
+
+ char version_med[10] ;
+ if ( MEDfichEntete(_medIdt,MED_FR::MED_VERSION,version_med) != 0 ){
+ // error : we suppose we have not a good med file !
+ delete[] tmp_cells_count ;
+ return MED_ERROR ;
+ }
+
+ // we get version number
+// string medVersion(version_med);
+// int firstNumber =
+ int * tmp_edges_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
+ int numberOfEdgesTypes = 0;
+ int * tmp_faces_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
+ int numberOfFacesTypes = 0;
+ if ((version_med != "2.2")&(Entity==MED_MAILLE)) {
+ Connectivity->_numberOfTypes=0;
+ for (int i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) {
+ tmp_faces_count[i]=0;
+ tmp_edges_count[i]=0;
+ if (tmp_cells_count[i]!=0) {
+ int dimension = all_cell_type[i]/100 ;
+ if (Connectivity->_entityDimension==dimension)
+ Connectivity->_numberOfTypes++ ;
+
+ if (dimension == 2)
+ if (Connectivity->_entityDimension==3) {
+ tmp_faces_count[i]=tmp_cells_count[i] ;
+ tmp_cells_count[i]=0 ;
+ numberOfFacesTypes++;
+ }
+ if (dimension == 1)
+ if (Connectivity->_entityDimension>dimension) {
+ tmp_edges_count[i]=tmp_cells_count[i] ;
+ tmp_cells_count[i]=0;
+ numberOfEdgesTypes++ ;
+ }
+ }
+ }
+ }
+
+ // bloc to read CELL :
+ {
+ // Prepare an array of indexes on the different cell types to create a MEDSKYLINEARRAY
+ // We use <tmp_cells_count> to calculate <Connectivity->_count> then we release it
+ Connectivity->_geometricTypes = new MED_EN::medGeometryElement [Connectivity->_numberOfTypes] ; // Double emploi pour des raisons pratiques
+ Connectivity->_type = new CELLMODEL [Connectivity->_numberOfTypes] ; //
+ Connectivity->_count = new int [Connectivity->_numberOfTypes+1] ;
+ Connectivity->_count[0] = 1;
+
+ int size = 0 ;
+ int TypeNumber=1 ;
+ for (int i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) { // no point1 cell type (?)
+ if (tmp_cells_count[i]>0) {
+
+ Connectivity->_count[TypeNumber]=Connectivity->_count[TypeNumber-1]+tmp_cells_count[i];
+
+ CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i]) ;
+ Connectivity->_type[TypeNumber-1]=t ;
+
+ Connectivity->_geometricTypes[TypeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ;
+
+ // probleme avec les mailles de dimension < a dimension du maillage :
+ // Il faut oter le zero a la lecture est le remettre a l'ecriture : ce n'est pas fait !!!!! On interdit ce cas pour l'instant !!!
+
+
+ size+=tmp_cells_count[i]*((MED_MESH_DRIVER::all_cell_type[i])%100) ;
+
+ MESSAGE(LOC
+ << Connectivity->_count[TypeNumber]-1 << " cells of type "
+ << all_cell_type_tab[i] );
+ TypeNumber++;
+ }
+ }
+
+ // Creation of the MEDSKYLINEARRAY
+ Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,size) ;
+ int * NodalIndex = Connectivity->_nodal->getIndex() ;
+ NodalIndex[0]=1 ;
+
+ // Fill the MEDSKYLINEARRAY by reading the MED file.
+ for (int i=0;i<Connectivity->_numberOfTypes;i++) {
+ int multi = 0 ;
+ MED_FR::med_geometrie_element med_type = (MED_FR::med_geometrie_element) Connectivity->_type[i].getType() ;
+// if ( Connectivity->_type[i].getDimension() < Connectivity->_entityDimension)
+ if (Connectivity->_entity == MED_CELL)
+ if ( Connectivity->_type[i].getDimension() < _ptrMesh->_spaceDimension)
+ multi=1;
+
+ // int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ;
+ int NumberOfNodeByCell = Connectivity->_type[i].getNumberOfNodes() ;
+
+ // initialise index
+ for (int j=Connectivity->_count[i]; j<Connectivity->_count[i+1];j++)
+ NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByCell ;
+
+ int tmp_numberOfCells = Connectivity->_count[i+1]-Connectivity->_count[i] ;
+ int * tmp_ConnectivityArray = new int[(NumberOfNodeByCell+multi)*tmp_numberOfCells];
+
+// int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+// Connectivity->_entityDimension,tmp_ConnectivityArray,
+// MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,MED_FR::MED_NOD);
+ int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ _ptrMesh->_spaceDimension,tmp_ConnectivityArray,
+ MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,MED_FR::MED_NOD);
+ if ( err != MED_VALID) {
+ delete[] tmp_ConnectivityArray;
+ delete[] tmp_cells_count;
+ delete[] tmp_faces_count;
+ delete[] tmp_edges_count;
+ MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
+ return MED_ERROR ;
+ }
+ int * ConnectivityArray = Connectivity->_nodal->getI(Connectivity->_count[i]) ;
+ for (int j=0; j<tmp_numberOfCells; j++)
+ for (int k=0; k<NumberOfNodeByCell; k++)
+ ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
+
+ delete[] tmp_ConnectivityArray;
+
+ }
+ } // end of bloc to read CELL
+
+ delete[] tmp_cells_count;
+
+ // get Face if any
+ // ===============
+
+ if (numberOfFacesTypes!=0) {
+ CONNECTIVITY * constituent = new CONNECTIVITY(numberOfFacesTypes,MED_EN::MED_FACE) ;
+ constituent->_entityDimension = 2 ;
+ constituent->_count[0]=1 ;
+
+ int size = 0 ;
+ int size_more_one = 0 ;
+ int TypeNumber=1 ;
+ for (int i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) { // no point1 cell type (?)
+ if (tmp_faces_count[i]>0) {
+
+ constituent->_count[TypeNumber]=constituent->_count[TypeNumber-1]+tmp_faces_count[i];
+ CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i]) ;
+ constituent->_type[TypeNumber-1]=t ;
+
+ constituent->_geometricTypes[TypeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ;
+
+ size+=tmp_faces_count[i]*((MED_MESH_DRIVER::all_cell_type[i])%100) ;
+ TypeNumber++;
+ }
+ }
+
+ // Creation of the MEDSKYLINEARRAY
+ constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
+ int * NodalIndex = constituent->_nodal->getIndex() ;
+ NodalIndex[0]=1 ;
+
+ // Fill the MEDSKYLINEARRAY by reading the MED file.
+ for (int i=0;i<constituent->_numberOfTypes;i++) {
+ MED_FR::med_geometrie_element med_type = (MED_FR::med_geometrie_element) constituent->_type[i].getType() ;
+
+ int NumberOfNodeByFace = constituent->_type[i].getNumberOfNodes() ;
+
+ // initialise index
+ for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
+ NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByFace ;
+
+ int tmp_numberOfFaces = constituent->_count[i+1]-constituent->_count[i] ;
+ // Il faut ajouter 1 pour le zero a la lecture !!!
+ int * tmp_constituentArray = new int[(NumberOfNodeByFace+1)*tmp_numberOfFaces] ;
+
+ int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ Connectivity->_entityDimension,tmp_constituentArray,
+ MED_FR::MED_FULL_INTERLACE,NULL,0,MED_FR::MED_MAILLE,med_type,MED_FR::MED_NOD);
+ if ( err != MED_VALID) {
+ MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
+ delete constituent ;
+ delete[] tmp_constituentArray;
+ delete[] tmp_faces_count;
+ delete[] tmp_edges_count;
+ return MED_ERROR ;
+ }
+
+ int * constituentArray = constituent->_nodal->getI(constituent->_count[i]) ;
+ for (int j=0; j<tmp_numberOfFaces; j++)
+ for (int k=0; k<NumberOfNodeByFace; k++)
+ constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
+
+ delete[] tmp_constituentArray;
+ }
+
+ Connectivity->_constituent = constituent ;
+ }
+
+ delete[] tmp_faces_count;
+
+ // get Edge if any
+ // ===============
+ if (numberOfEdgesTypes!=0) {
+ CONNECTIVITY * constituent = new CONNECTIVITY(numberOfEdgesTypes,MED_EDGE) ;
+ constituent->_entityDimension = 2 ;
+ constituent->_count[0]=1 ;
+
+ int size = 0 ;
+ int size_more_one = 0 ;
+ int TypeNumber=1 ;
+ for (int i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) { // no point1 cell type (?)
+ if (tmp_edges_count[i]>0) {
+
+ constituent->_count[TypeNumber]=constituent->_count[TypeNumber-1]+tmp_edges_count[i];
+ CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i]) ;
+ constituent->_type[TypeNumber-1]=t ;
+
+ constituent->_geometricTypes[TypeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ;
+
+ size+=tmp_edges_count[i]*((MED_MESH_DRIVER::all_cell_type[i])%100) ;
+ TypeNumber++;
+ }
+ }
+
+ // Creation of the MEDSKYLINEARRAY
+ constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
+ int * NodalIndex = constituent->_nodal->getIndex() ;
+ NodalIndex[0]=1 ;
+
+ // Fill the MEDSKYLINEARRAY by reading the MED file.
+ for (int i=0;i<constituent->_numberOfTypes;i++) {
+ MED_FR::med_geometrie_element med_type = (MED_FR::med_geometrie_element) constituent->_type[i].getType() ;
+
+ int NumberOfNodeByEdge = constituent->_type[i].getNumberOfNodes() ;
+
+ // initialise index
+ for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
+ NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByEdge ;
+
+ int tmp_numberOfEdges = constituent->_count[i+1]-constituent->_count[i] ;
+ // Il faut ajouter 1 pour le zero a la lecture !!!
+ int * tmp_constituentArray = new int[(NumberOfNodeByEdge+1)*tmp_numberOfEdges] ;
+
+ int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ Connectivity->_entityDimension,tmp_constituentArray,
+ MED_FR::MED_FULL_INTERLACE,NULL,0,MED_FR::MED_MAILLE,med_type,MED_FR::MED_NOD);
+ if ( err != MED_VALID) {
+ MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
+ delete constituent ;
+ delete[] tmp_constituentArray;
+ delete[] tmp_edges_count;
+ return MED_ERROR ;
+ }
+
+ int * constituentArray = constituent->_nodal->getI(constituent->_count[i]) ;
+ for (int j=0; j<tmp_numberOfEdges; j++)
+ for (int k=0; k<NumberOfNodeByEdge; k++)
+ constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k] ;
+
+ delete[] tmp_constituentArray;
+ }
+
+ if (Connectivity->_entityDimension == 3) {
+ if (Connectivity->_constituent==NULL)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Edges are defined but there are no Faces !"));
+ Connectivity->_constituent->_constituent = constituent ;
+ } else
+ Connectivity->_constituent = constituent ;
+ }
+
+ delete[] tmp_edges_count;
+
+ return MED_VALID;
+ }
+ return MED_ERROR;
+}
+
+int MED_MESH_RDONLY_DRIVER::getDescendingConnectivity(CONNECTIVITY * Connectivity)
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER::getDescendingConnectivity " ;
+ if (_status==MED_OPENED)
+ {
+ MESSAGE(LOC<<" Not implemented !");
+ }
+ return MED_ERROR;
+}
+
+// int MED_MESH_RDONLY_DRIVER::getElementFamilies(CONNECTIVITY * Connectivity)
+// {
+// int err = 0 ;
+// int NumberOfTypes = Connectivity->_numberOfTypes ;
+// int * Count = Connectivity->_count ;
+// medGeometryElement * GeometricTypes= Connectivity->_geometricTypes ;
+// int ** tmp_array = new int*[NumberOfTypes] ;
+// for (int i=0; i<NumberOfTypes; i++)
+// tmp_array[i]=NULL ;
+// for (int i=0; i<NumberOfTypes; i++) {
+// int NumberOfElements = Count[i+1]-Count[i] ;
+// int * tmp_families_number = new int[NumberOfElements] ;
+// err = MEDfamLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
+// tmp_families_number,NumberOfElements,
+// Connectivity->_entity,GeometricTypes[i]);
+// tmp_array[i]=tmp_families_number ;
+// if (err != MED_VALID) {
+// for (int j=0; j<NumberOfTypes; j++)
+// if (tmp_array[j] != NULL)
+// delete[] tmp_array[j] ;
+// delete[] tmp_array ;
+// throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::getElementFamilies : No Family in element GeometricTypes[i]");
+// }
+// }
+
+// if (Connectivity->_entity == MED_CELL)
+// _ptrMesh->_MEDArrayCellFamily = tmp_array ;
+// else if (Connectivity->_entity == MED_FACE)
+// _ptrMesh->_MEDArrayFaceFamily = tmp_array ;
+// else if (Connectivity->_entity == MED_EDGE)
+// _ptrMesh->_MEDArrayEdgeFamily = tmp_array ;
+
+// return MED_VALID ;
+// }
+
+int MED_MESH_RDONLY_DRIVER::getFAMILY()
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER::getFAMILY() : " ;
+ BEGIN_OF(LOC);
+
+ if (_status==MED_OPENED) {
+ int err = 0 ;
+ // read number :
+ // NODE :
+ err = getNodesFamiliesNumber() ; // error only if (_status!=MED_OPENED), other case exeception !
+ // CELL
+ _ptrMesh->_MEDArrayCellFamily = new (int*)[_ptrMesh->_connectivity->_numberOfTypes] ; // ET SI IL N'Y A PAS DE CELLS ?
+ getCellsFamiliesNumber(_ptrMesh->_MEDArrayCellFamily,_ptrMesh->_connectivity) ;
+ if (_ptrMesh->_connectivity->_constituent != NULL) {
+ if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE) {
+ // FACE
+ _ptrMesh->_MEDArrayFaceFamily = new (int*)[_ptrMesh->_connectivity->_constituent->_numberOfTypes] ;
+ getCellsFamiliesNumber(_ptrMesh->_MEDArrayFaceFamily,_ptrMesh->_connectivity->_constituent) ;
+ } else {
+ // EDGE in 2D
+ _ptrMesh->_MEDArrayEdgeFamily = new (int*)[_ptrMesh->_connectivity->_constituent->_numberOfTypes] ;
+ getCellsFamiliesNumber(_ptrMesh->_MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent) ;
+ }
+ // EDGE in 3D
+ if (_ptrMesh->_connectivity->_constituent->_constituent != NULL) {
+ _ptrMesh->_MEDArrayEdgeFamily = new (int*)[_ptrMesh->_connectivity->_constituent->_constituent->_numberOfTypes] ;
+ getCellsFamiliesNumber(_ptrMesh->_MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent) ; // we are in 3D !
+ }
+ }
+
+ // Creation of the families
+ int NumberOfFamilies = MEDnFam(_medIdt,const_cast <char *> (_meshName.c_str()),0,MED_FR::MED_FAMILLE) ;
+ if ( NumberOfFamilies < 1 ) // at least family 0 must exist
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"There is no FAMILY, FAMILY 0 must exists" ));
+
+ vector<FAMILY*> &NodeFamilyVector = _ptrMesh->_familyNode ;
+ vector<FAMILY*> &CellFamilyVector = _ptrMesh->_familyCell ;
+ vector<FAMILY*> &FaceFamilyVector = _ptrMesh->_familyFace ;
+ vector<FAMILY*> &EdgeFamilyVector = _ptrMesh->_familyEdge ;
+
+ int numberOfNodesFamilies = 0 ;
+ int numberOfCellsFamilies = 0 ;
+ int numberOfFacesFamilies = 0 ;
+ int numberOfEdgesFamilies = 0 ;
+
+ for (int i=0;i<NumberOfFamilies;i++) {
+
+ int NumberOfAttributes = MEDnFam(_medIdt,const_cast <char *> (_meshName.c_str()),i+1,MED_FR::MED_ATTR) ;
+ if (NumberOfAttributes < 0)
+ throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::getFAMILY() : NumberOfAttributes" );
+
+ int NumberOfGroups = MEDnFam(_medIdt,const_cast <char *> (_meshName.c_str()),i+1,MED_FR::MED_GROUPE) ;
+ if (NumberOfGroups < 0)
+ throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::getFAMILY() : NumberOfGroups" );
+
+ int FamilyIdentifier ;
+ string FamilyName(MED_TAILLE_NOM,' ');
+ int * AttributesIdentifier = new int[NumberOfAttributes] ;
+ int * AttributesValues = new int[NumberOfAttributes] ;
+ string AttributesDescription(MED_TAILLE_DESC*NumberOfAttributes,' ') ;
+ string GroupsNames(MED_TAILLE_LNOM*NumberOfGroups,' ') ;
+ err = MEDfamInfo(_medIdt,const_cast <char *> (_meshName.c_str()),
+ i+1,const_cast <char *> (FamilyName.c_str()),
+ &FamilyIdentifier,AttributesIdentifier,AttributesValues,
+ const_cast <char *> (AttributesDescription.c_str()),
+ &NumberOfAttributes,
+ const_cast <char *> (GroupsNames.c_str()),&NumberOfGroups
+ );
+ //SCRUTE(GroupsNames);
+ if (err != MED_VALID)
+ throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::getFAMILY() : ERROR when get FAMILY informations" );
+ if (FamilyIdentifier != 0 ) {
+ FAMILY * Family = new FAMILY(_ptrMesh,FamilyIdentifier,FamilyName,
+ NumberOfAttributes,AttributesIdentifier,
+ AttributesValues,AttributesDescription,
+ NumberOfGroups,GroupsNames) ;
+ switch (Family->getEntity()) {
+ case MED_EN::MED_NODE :
+ NodeFamilyVector.push_back(Family) ;
+ numberOfNodesFamilies++ ;
+ break ;
+ case MED_EN::MED_CELL :
+ CellFamilyVector.push_back(Family) ;
+ numberOfCellsFamilies++ ;
+ break ;
+ case MED_EN::MED_FACE :
+ FaceFamilyVector.push_back(Family) ;
+ numberOfFacesFamilies++ ;
+ break ;
+ case MED_EN::MED_EDGE :
+ EdgeFamilyVector.push_back(Family) ;
+ numberOfEdgesFamilies++ ;
+ break ;
+ }
+ }
+ }
+ _ptrMesh->_numberOfNodesFamilies = numberOfNodesFamilies ;
+ _ptrMesh->_numberOfCellsFamilies = numberOfCellsFamilies ;
+ _ptrMesh->_numberOfFacesFamilies = numberOfFacesFamilies ;
+ _ptrMesh->_numberOfEdgesFamilies = numberOfEdgesFamilies ;
+
+ END_OF(LOC);
+ return MED_VALID ;
+ }
+ return MED_ERROR;
+}
+
+int MED_MESH_RDONLY_DRIVER::getNodesFamiliesNumber()
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER::getNodesFamiliesNumber() : " ;
+ BEGIN_OF(LOC);
+ if (_status==MED_OPENED) {
+ int err = 0 ;
+ int * tmp_NodesFamilies = new int[_ptrMesh->getNumberOfNodes()] ;
+ err = MEDfamLire(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
+ tmp_NodesFamilies, _ptrMesh->getNumberOfNodes(),
+ MED_NOEUD,(enum MED_FR::med_geometrie_element) MED_NONE);
+ if ( err != MED_VALID) {
+ delete[] tmp_NodesFamilies ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "There is no family for the |"<< _ptrMesh->getNumberOfNodes()
+ << "| nodes in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
+ }
+ _ptrMesh->_MEDArrayNodeFamily = tmp_NodesFamilies ;
+ END_OF(LOC);
+ return MED_VALID;
+ }
+ return MED_ERROR;
+}
+
+int MED_MESH_RDONLY_DRIVER::getCellsFamiliesNumber(int **MEDArrayFamily,CONNECTIVITY *Connectivity)
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER::getCellsFamiliesNumber " ;
+ BEGIN_OF(LOC);
+
+ if (_status==MED_OPENED) {
+ int i, err = 0 ;
+ for (i=0;i<Connectivity->_numberOfTypes;i++) {
+ int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ;
+ int * fam = new int[NumberOfCell] ;
+
+ err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ fam,NumberOfCell,
+ (MED_FR::med_entite_maillage) Connectivity->_entity,
+ (MED_FR::med_geometrie_element) Connectivity->_geometricTypes[i]);
+
+ // provisoire : si les faces ou les aretes sont des mailles !!!
+ if (err != MED_VALID) {
+ MESSAGE(LOC<<"search face/edge family on cell !!!");
+ err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ fam,NumberOfCell,
+ MED_FR::MED_MAILLE,
+ (MED_FR::med_geometrie_element) Connectivity->_geometricTypes[i]);
+ }
+
+ MEDArrayFamily[i]=fam ;
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Family not found for entity "<<Connectivity->_entity<<" and geometric type "<<Connectivity->_geometricTypes[i]));
+
+ }
+ return MED_VALID;
+ }
+ return MED_ERROR;
+}
+
+void MED_MESH_RDONLY_DRIVER::buildAllGroups(vector<GROUP*> & Groups, vector<FAMILY*> & Families)
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER::buildAllGroups " ;
+ BEGIN_OF(LOC);
+
+ int numberOfFamilies = Families.size() ;
+ //SCRUTE(numberOfFamilies);
+ map< string,list<FAMILY*> > groupsNames ;
+ for(int i=0; i<numberOfFamilies; i++) {
+ FAMILY * myFamily = Families[i] ;
+ int numberOfGroups_ = myFamily->getNumberOfGroups();
+ //SCRUTE(i);
+ //SCRUTE(numberOfGroups_);
+ for (int j=0; j<numberOfGroups_; j++) {
+ //SCRUTE(j);
+ //SCRUTE(myFamily->getGroupName(j+1));
+ groupsNames[myFamily->getGroupName(j+1)].push_back(myFamily);
+ }
+ }
+ int numberOfGroups = groupsNames.size() ;
+ SCRUTE(numberOfGroups);
+ Groups.resize(numberOfGroups);
+ map< string,list<FAMILY*> >::const_iterator currentGroup ;
+ int it = 0 ;
+ for(currentGroup=groupsNames.begin();currentGroup!=groupsNames.end();currentGroup++) {
+ // GROUP * myGroup = new GROUP((*currentGroup).first,(*currentGroup).second) ;
+ GROUP * myGroup = new GROUP() ;
+ myGroup->setName((*currentGroup).first);
+ SCRUTE(myGroup->getName());
+ //myGroup->setMesh(_ptrMesh);
+ myGroup->init((*currentGroup).second);
+ Groups[it]=myGroup;
+ //SCRUTE(it);
+ it++;
+ }
+
+ END_OF(LOC);
+}
+
+void MED_MESH_RDONLY_DRIVER::updateFamily()
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER::updateFamily() " ;
+ BEGIN_OF(LOC);
+
+ // we need to update family on constituent if we have constituent, but no
+ // descending connectivity, so, we must calculate all constituent and
+ // numbering correctly family !
+ _ptrMesh->_connectivity->updateFamily(_ptrMesh->_familyFace) ; // in 2d, do nothing
+ _ptrMesh->_connectivity->updateFamily(_ptrMesh->_familyEdge) ; // in 3d, do nothing
+
+ END_OF(LOC);
+}
+
+
+void MED_MESH_RDONLY_DRIVER::write( void ) const { INFOS("MED_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");}
+
+/*--------------------- RDWR PART -------------------------------*/
+
+void MED_MESH_RDWR_DRIVER::write(void) const { MED_MESH_WRONLY_DRIVER::write(); }
+void MED_MESH_RDWR_DRIVER::read (void) { MED_MESH_RDONLY_DRIVER::read(); }
+
+
+/*--------------------- WRONLY PART -------------------------------*/
+void MED_MESH_WRONLY_DRIVER::read (void) { INFOS("MED_MESH_WRONLY_DRIVER::write : Can't read with a WRONLY driver !");}
+
+void MED_MESH_WRONLY_DRIVER::write(void) const {
+ const char * LOC = "void MED_MESH_WRONLY_DRIVER::write(void) const : ";
+ BEGIN_OF(LOC);
+
+ // we must first create mesh !!
+ MESSAGE(LOC<< "MeshName : "<< _meshName <<"FileName : "<<_fileName<<" MedIdt : "<< _medIdt);
+
+ if (writeCoordinates()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeCoordinates()" )) ;
+
+ if (writeConnectivities(MED_EN::MED_CELL)!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_CELL)" )) ;
+ if (writeConnectivities(MED_EN::MED_FACE)!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_FACE)" )) ;
+ if (writeConnectivities(MED_EN::MED_EDGE)!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_EDGE)" )) ;
+
+ if (writeFamilyNumbers() !=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilyNumbers()" )) ;
+
+ // well we must first write zero family :
+ if (_status==MED_OPENED) {
+ int err ;
+ // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
+ string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/FAMILLE_0/";
+ SCRUTE("|"<<dataGroupFam<<"|");
+ if ( err =_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) < MED_VALID ) {
+ SCRUTE(err);
+
+ err = MEDfamCr( _medIdt, const_cast <char *> ( _meshName.c_str() ),
+ "FAMILLE_0", 0,
+ (int*)NULL, (int*)NULL, (char*)NULL, 0,
+ (char*)NULL, 0);
+
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |FAMILLE_0| with identifier |0| groups names || and attributes descriptions ||")) ;
+ }
+ else
+ _MEDdatagroupFermer(_medIdt);
+
+ }
+
+ MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyNode)");
+ if (writeFamilies(_ptrMesh->_familyNode) !=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyNode)" )) ;
+
+ MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyCell)");
+ if (writeFamilies(_ptrMesh->_familyCell) !=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyCell)" )) ;
+
+ MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyFace)");
+ if (writeFamilies(_ptrMesh->_familyFace) !=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyFace)" )) ;
+
+ MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyEdge)");
+ if (writeFamilies(_ptrMesh->_familyEdge) !=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyEdge)" )) ;
+
+ END_OF(LOC);
+}
+
+
+int MED_MESH_WRONLY_DRIVER::writeCoordinates() const {
+
+ const char * LOC = "int MED_MESH_WRONLY_DRIVER::writeCoordinates() const : ";
+ BEGIN_OF(LOC);
+ if (_status==MED_OPENED) {
+
+ MED_FR::med_err err = MED_ERROR;
+ MED_FR::med_repere rep;
+ string tmp_name,tmp_unit;
+
+ // Recompose the <_spaceDimension> strings in 1 string
+ for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
+ tmp_name += _ptrMesh->_coordinate->_coordinateName[i];
+ tmp_unit += _ptrMesh->_coordinate->_coordinateUnit[i];
+
+ }
+
+ // Test if the mesh <_meshName> already exists
+ // If it doesn't exists create it
+ // If it already exists verify if its dimension is the same as <_ptrMesh->_spaceDimension>
+ // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
+ int dim = MEDdimLire(_medIdt, const_cast <char *> (_meshName.c_str()) );
+ if (dim < MED_VALID)
+ if (MEDmaaCr(_medIdt,const_cast <char *> (_meshName.c_str()),_ptrMesh->_spaceDimension) != 0 )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh"));
+ else
+ {
+ MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !");
+ }
+ else if (dim != _ptrMesh->_spaceDimension)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| already exists in file |" << _fileName
+ << "| with dimension |" << dim << "| but the dimension of the mesh we want to write is |"
+ << _ptrMesh->_spaceDimension <<"|" )) ;
+
+ // Pourquoi le stocker sous forme de chaîne ?
+ const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
+ if (coordinateSystem == "CARTESIAN")
+ rep = MED_FR::MED_CART;
+ else if ( coordinateSystem == "CYLINDRICAL")
+ rep = MED_FR::MED_CYL;
+ else if ( coordinateSystem == "SPHERICAL" )
+ rep = MED_FR::MED_SPHER;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| doesn't have a valid coordinate system : |"
+ << _ptrMesh->_coordinate->_coordinateSystem
+ << "|" )) ;
+
+ err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
+ _ptrMesh->_spaceDimension,
+ const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
+ MED_FR::MED_FULL_INTERLACE,
+ _ptrMesh->_numberOfNodes, // _ptrMesh->_coordinate->_numberOfNodes
+ MED_FR::MED_REMP,
+ rep,
+ const_cast <char *> (tmp_name.c_str()),
+ const_cast <char *> (tmp_unit.c_str())
+ );
+
+ if (err<0)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ << " with units names |" << tmp_name
+ << "| and units |" << tmp_unit
+ << " |")) ;
+
+ END_OF(LOC);
+
+ return MED_VALID;
+ }
+
+ MESSAGE (LOC<<" Not open !!!");
+ return MED_ERROR;
+}
+
+
+
+
+int MED_MESH_WRONLY_DRIVER::writeConnectivities(medEntityMesh entity) const {
+
+ const char * LOC="int MED_MESH_WRONLY_DRIVER::writeConnectivities() const : ";
+ BEGIN_OF(LOC);
+
+ MED_FR::med_err err;
+
+ if (_status==MED_OPENED) {
+
+ // REM SI LA METHODE EST APPELEE DIRECTEMENT ET QUE LE MAILLAGE N'EST PAS CREE IL Y A PB !
+
+ // A FAIRE : A tester surtout dans les methodes de MESH.
+ // if ( _ptrMesh->_connectivity == (CONNECTIVITY *) MED_INVALID )
+ if ( _ptrMesh->_connectivity == (CONNECTIVITY *) NULL )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The connectivity is not defined in the MESH object ")) ;
+
+ if ( _ptrMesh->existConnectivity(MED_NODAL,entity) ) {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+
+ for (int i=0; i<numberOfTypes; i++) {
+
+ int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
+ int * connectivity = _ptrMesh->getConnectivity (MED_EN::MED_FULL_INTERLACE,
+ MED_NODAL, entity, types[i]); // ?? et SI MED_NODAL n'existe pas, recalcul auto ??
+
+ // Pour l'instant la class utilise le multi.....
+ int multi = 0 ;
+ if (entity==MED_EN::MED_CELL)
+ if ( (types[i]/ 100) < _ptrMesh->_spaceDimension)
+ multi=1 ;
+ int numberOfNodes = types[i]%100 ;
+ int * connectivityArray = new int[numberOfElements*(numberOfNodes+multi)];
+ for (int j=0 ; j<numberOfElements; j++) {
+ for (int k=0; k<numberOfNodes; k++)
+ connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
+ connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
+ }
+ err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
+ connectivityArray, MED_FR::MED_FULL_INTERLACE , numberOfElements,
+ MED_FR::MED_REMP,
+ (MED_FR::med_entite_maillage ) entity,
+ (MED_FR::med_geometrie_element) types[i], MED_NOD );
+ delete[] connectivityArray ;
+
+ if (err<0) // ETENDRE LES EXPLICATIONS
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ )) ;
+ }
+ }
+ // Connctivity descending :
+ if ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+
+ for (int i=0; i<numberOfTypes; i++) {
+
+ int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
+ int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]);
+
+ // Pour l'instant la class utilise le multi.....
+ err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
+ connectivity, MED_FR::MED_FULL_INTERLACE , numberOfElements,
+ MED_FR::MED_REMP,
+ (MED_FR::med_entite_maillage ) entity,
+ (MED_FR::med_geometrie_element) types[i], MED_DESC );
+
+ if (err<0) // ETENDRE LES EXPLICATIONS
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ )) ;
+ }
+ }
+ // Connctivity descending :
+ if ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+
+ for (int i=0; i<numberOfTypes; i++) {
+
+ int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
+ int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]);
+
+ // Pour l'instant la class utilise le multi.....
+ err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
+ connectivity, MED_FR::MED_FULL_INTERLACE , numberOfElements,
+ MED_FR::MED_REMP,
+ (MED_FR::med_entite_maillage ) entity,
+ (MED_FR::med_geometrie_element) types[i], MED_DESC );
+
+ if (err<0) // ETENDRE LES EXPLICATIONS
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ )) ;
+
+ }
+ }
+ END_OF(LOC);
+ return MED_VALID;
+ }
+ return MED_ERROR;
+}
+
+int MED_MESH_WRONLY_DRIVER::writeFamilyNumbers() const {
+
+ const char * LOC="int MED_MESH_WRONLY_DRIVER::writeFamilyNumbers() const : ";
+ BEGIN_OF(LOC);
+
+ MED_FR::med_err err;
+
+ if (_status==MED_OPENED) {
+
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArrayNodeFamily DOIT ETRE ENLEVER DE LA CLASSE MESH
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ _ptrMesh->_MEDArrayNodeFamily, _ptrMesh->getNumberOfNodes(),MED_FR::MED_REMP ,
+ MED_NOEUD,(enum MED_FR::med_geometrie_element) MED_NONE);
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write node family for the |"<< _ptrMesh->getNumberOfNodes()
+ << "| nodes in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
+
+
+ { // CELLS RELATED BLOCK
+ medEntityMesh entity=MED_EN::MED_CELL;
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
+ if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+
+ for (int i=0; i<numberOfTypes; i++) {
+
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ _ptrMesh->_MEDArrayCellFamily[i], _ptrMesh->getNumberOfElements(entity, types[i]),
+ MED_FR::MED_REMP ,
+ (MED_FR::med_entite_maillage) entity,
+ (MED_FR::med_geometrie_element) types[i]);
+
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
+ << "| cells of geometric type |" << geoNames[ (MED_FR::med_geometrie_element) types[i]] <<"|in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
+ }
+ }
+ }
+
+ { // FACE RELATED BLOCK
+ medEntityMesh entity=MED_EN::MED_FACE;
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
+ if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+
+ int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
+ int * familyArray = new int[numberOfElements] ;
+ for (int i=0;i<numberOfElements;i++)
+ familyArray[i]=0;
+
+ int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
+ vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
+ for (int i=0;i<numberOfFamilies;i++) {
+ int familyNumber = myFamilies[i]->getIdentifier() ;
+ int numberOfFamilyElements = myFamilies[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ int * myFamilyElements = myFamilies[i]->getNumber(MED_ALL_ELEMENTS) ;
+ for (int ii=0;ii<numberOfFamilyElements;ii++)
+ familyArray[myFamilyElements[ii]-1]=familyNumber;
+ }
+
+ int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
+
+ for (int i=0; i<numberOfTypes; i++) {
+
+ int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ familyArray+typeCount[i]-1, typeNumberOfElements,
+ MED_FR::MED_REMP ,
+ (MED_FR::med_entite_maillage) entity,
+ (MED_FR::med_geometrie_element) types[i]);
+
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
+ << "| faces of geometric type |" << geoNames[ (MED_FR::med_geometrie_element) types[i]] <<"|in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
+ }
+ delete[] familyArray ;
+ }
+ }
+
+ { // EDGE RELATED BLOCK
+ //medEntityMesh entity=MED_EN::MED_FACE;
+ medEntityMesh entity=MED_EN::MED_EDGE;
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
+ if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+
+ int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
+ int * familyArray = new int[numberOfElements] ;
+ for (int i=0;i<numberOfElements;i++)
+ familyArray[i]=0;
+
+ int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
+ vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
+ for (int i=0;i<numberOfFamilies;i++) {
+ int familyNumber = myFamilies[i]->getIdentifier() ;
+ int numberOfFamilyElements = myFamilies[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ int * myFamilyElements = myFamilies[i]->getNumber(MED_ALL_ELEMENTS) ;
+ for (int ii=0;ii<numberOfFamilyElements;ii++)
+ familyArray[myFamilyElements[ii]-1]=familyNumber;
+ }
+
+ int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
+
+ for (int i=0; i<numberOfTypes; i++) {
+
+ int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ familyArray+typeCount[i]-1, typeNumberOfElements,
+ MED_FR::MED_REMP ,
+ (MED_FR::med_entite_maillage) entity,
+ (MED_FR::med_geometrie_element) types[i]);
+
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
+ << "| edges of geometric type |" << geoNames[ (MED_FR::med_geometrie_element) types[i]] <<"|in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
+ }
+ }
+ }
+
+ END_OF(LOC);
+ return MED_VALID;
+ }
+ return MED_ERROR;
+}
+
+
+int MED_MESH_WRONLY_DRIVER::writeFamilies(vector<FAMILY*> & families ) const {
+
+ const char * LOC="int MED_MESH_WRONLY_DRIVER::writeFamilies(vector<FAMILY*> families) const : ";
+ BEGIN_OF(LOC);
+
+ MED_FR::med_err err;
+
+ if (_status==MED_OPENED) {
+
+ MESSAGE(LOC<<" families.size() :"<<families.size());
+
+ for (int i=0; i< families.size(); i++) {
+
+ int numberOfAttributes = families[i]->getNumberOfAttributes ();
+ string attributesDescriptions = "";
+
+ // Recompose the attributes descriptions arg for MED
+ for (int j=0; j < numberOfAttributes; j++) {
+
+ string attributeDescription = families[i]->getAttributeDescription(j+1);
+
+ if ( attributeDescription.size() > MED_TAILLE_DESC )
+ throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the attribute description n° |" << j+1 << "| of the family |" << families[i]->getName()
+ << "| with identifier |" << families[i]->getIdentifier() << "| is |"
+ << attributeDescription.size() <<"| and is more than |" << MED_TAILLE_DESC << "|")) ;
+
+ attributesDescriptions += attributeDescription;
+ }
+
+
+ int numberOfGroups = families[i]->getNumberOfGroups();
+ string groupsNames(numberOfGroups*MED_TAILLE_LNOM,'\0') ;
+ // Recompose the groups names arg for MED
+ for (int j=0; j < numberOfGroups; j++) {
+
+ string groupName = families[i]->getGroupName(j+1);
+
+ if ( groupName.size() > MED_TAILLE_LNOM )
+ throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the group name n° |" << j+1 << "| of the family |" << families[i]->getName()
+ << "| with identifier |" << families[i]->getIdentifier() << "| is |"
+ << groupName.size() <<"| and is more than |" << MED_TAILLE_LNOM << "|")) ;
+
+
+ int length = min(MED_TAILLE_LNOM,(int)groupName.size());
+ groupsNames.replace(j*MED_TAILLE_LNOM,length, groupName,0,length);
+
+ }
+
+ // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
+ string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/"+families[i]->getName()+"/";
+ SCRUTE("|"<<dataGroupFam<<"|");
+ if ( err =_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) < MED_VALID ) {
+ SCRUTE(err);
+
+ MESSAGE(LOC<<"families[i]->getName().c_str() : "<<families[i]->getName().c_str());
+ MESSAGE(LOC<<"_meshName.c_str() : "<<_meshName.c_str());
+ MESSAGE(LOC<<"families[i]->getIdentifier() : "<<families[i]->getIdentifier());
+ MESSAGE(LOC<<"families[i]->getAttributesIdentifiers() : "<<families[i]->getAttributesIdentifiers()[0]);
+ MESSAGE(LOC<<"families[i]->getAttributesValues() : "<<families[i]->getAttributesValues()[0]);
+ MESSAGE(LOC<<"attributesDescriptions.c_str() : "<<attributesDescriptions.c_str());
+ MESSAGE(LOC<<"numberOfAttributes : "<<numberOfAttributes);
+ MESSAGE(LOC<<"groupsNames.c_str() : "<<groupsNames.c_str());
+ MESSAGE(LOC<<"numberOfGroups : "<<numberOfGroups);
+
+ err = MEDfamCr( _medIdt,
+ const_cast <char *> ( _meshName.c_str() ),
+ const_cast <char *> ( families[i]->getName().c_str() ),
+ families[i]->getIdentifier(),
+ families[i]->getAttributesIdentifiers(),
+ families[i]->getAttributesValues(),
+ const_cast <char *> (attributesDescriptions.c_str()),
+ numberOfAttributes,
+ const_cast <char *> (groupsNames.c_str()),
+ numberOfGroups);
+ SCRUTE(err);
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |" << families[i]->getName()
+ << "| with identifier |" << families[i]->getIdentifier() << "| groups names |"
+ << groupsNames <<"| and attributes descriptions |" << attributesDescriptions << "|")) ;
+ }
+ else
+ _MEDdatagroupFermer(_medIdt);
+
+
+ }
+
+ END_OF(LOC);
+
+ return MED_VALID;
+ }
+ return MED_ERROR;
+}
+
+
+// A FAIRE POUR LES NOEUDS ET LES ELEMENTS ret = MEDfamEcr(
--- /dev/null
+#ifndef MED_MESH_DRIVER_HXX
+#define MED_MESH_DRIVER_HXX
+
+#include <string>
+#include <vector>
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_GenDriver.hxx"
+
+#include "MEDMEM_STRING.hxx"
+#include "MEDMEM_Exception.hxx"
+#include "utilities.h"
+
+class MESH;
+class FAMILY;
+class GROUP;
+class CONNECTIVITY;
+
+class MED_MESH_DRIVER : public GENDRIVER
+{
+protected:
+
+ MESH * _ptrMesh;
+ MED_FR::med_idt _medIdt;
+ string _meshName; // const ?
+ int _meshNum; // INUTILE ?
+
+public :
+
+ // all MED cell type
+ static const MED_FR::med_geometrie_element all_cell_type[MED_NBR_GEOMETRIE_MAILLE];
+
+ static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE];
+
+ MED_MESH_DRIVER():GENDRIVER(),
+ _ptrMesh(( MESH *)MED_NULL),_medIdt(MED_INVALID),
+ _meshName(""),_meshNum(MED_INVALID)
+ {
+ }
+ MED_MESH_DRIVER(const string & fileName, MESH * ptrMesh, med_mode_acces accessMode):
+ GENDRIVER(fileName,accessMode),
+ _ptrMesh(ptrMesh),_medIdt(MED_INVALID),
+ _meshName(""),_meshNum(MED_INVALID)
+ {
+ }
+
+ void open() {
+ BEGIN_OF("MED_MESH_DRIVER::open()");
+ _medIdt = MED_FR::MEDouvrir( (const_cast <char *> (_fileName.c_str())),(MED_FR::med_mode_acces) _accessMode);
+ MESSAGE("MED_MESH_DRIVER::open() _medIdt : "<< _medIdt );
+ if (_medIdt > 0) _status=MED_OPENED; else {
+ MESSAGE(" MED_MESH__DRIVER::open() : MEDouvrir : _medIdt= " << _medIdt );
+ _status = MED_INVALID;
+ }
+ END_OF("MED_MESH_DRIVER::open()");
+ }
+
+ void close() {
+ const char * LOC = "MED_MESH_DRIVER::close() " ;
+ BEGIN_OF(LOC);
+ med_int err = 0;
+ if ( _status == MED_OPENED) {
+ err=MED_FR::MEDfermer(_medIdt);
+ H5close();
+ if (err != 0)
+ throw MEDEXCEPTION( LOCALIZED(STRING(LOC)
+ <<" Error when closing file !"
+ )
+ );
+ MESSAGE(LOC <<": _medIdt= " << _medIdt );
+ MESSAGE(LOC<<": MEDfermer : err = " << err );
+ _status = MED_CLOSED;
+ _medIdt = MED_INVALID;
+ }
+ END_OF(LOC);
+ }
+
+ virtual void write( void ) const = 0 ;
+ virtual void read ( void ) = 0 ;
+
+ void setMeshName(const string & meshName) ;
+ string getMeshName() const ;
+
+};
+
+class MED_MESH_RDONLY_DRIVER : public virtual MED_MESH_DRIVER
+{
+
+public :
+
+ MED_MESH_RDONLY_DRIVER():MED_MESH_DRIVER() {};
+
+ MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh):
+ MED_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY) {
+ MESSAGE("MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+ }
+
+ ~MED_MESH_RDONLY_DRIVER() {
+ MESSAGE("MED_MESH_RDONLY_DRIVER::~MED_MESH_RDONLY_DRIVER() has been destroyed");
+ }
+
+ // CREER UNE METHODE POUR LIRE LA LISTE DES MAILLAGES .....
+ int getCOORDINATE();
+ int getCONNECTIVITY();
+ int getFAMILY();
+ void write( void ) const ;
+ void read ( void ) ;
+
+private:
+ int getNodalConnectivity(CONNECTIVITY * Connectivity) ;
+ int getDescendingConnectivity(CONNECTIVITY * Connectivity) ;
+ int getNodesFamiliesNumber() ;
+ int getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity) ;
+ void updateFamily() ;
+ void buildAllGroups(vector<GROUP*> & Groups, vector<FAMILY*> & Families) ;
+
+};
+
+class MED_MESH_WRONLY_DRIVER : public virtual MED_MESH_DRIVER {
+
+public :
+
+ MED_MESH_WRONLY_DRIVER():MED_MESH_DRIVER() {}
+
+ MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh):
+ MED_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
+ {
+ MESSAGE("MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+ };
+
+ ~MED_MESH_WRONLY_DRIVER() {
+ MESSAGE("MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
+ }
+
+ void write( void ) const ;
+ void read ( void ) ;
+
+ int writeCoordinates () const;
+ int writeConnectivities (medEntityMesh entity) const;
+ int writeFamilyNumbers () const;
+ int writeFamilies (vector<FAMILY*> & families) const;
+};
+
+
+class MED_MESH_RDWR_DRIVER : public MED_MESH_RDONLY_DRIVER, public MED_MESH_WRONLY_DRIVER {
+
+public :
+
+ MED_MESH_RDWR_DRIVER():MED_MESH_DRIVER() {}
+
+ MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh):
+ MED_MESH_DRIVER(fileName,ptrMesh,MED_RDWR)
+ {
+ MESSAGE("MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+ };
+
+ ~MED_MESH_RDWR_DRIVER() {
+ MESSAGE("MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
+ }
+
+ void write(void) const ;
+ void read (void) ;
+};
+
+
+#endif /* MED_MESH_DRIVER_HXX */
--- /dev/null
+/*
+ File Mesh.cxx
+ $Header$
+*/
+
+#include <math.h>
+
+#include <list>
+#include <map>
+
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Mesh.hxx"
+
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Group.hxx"
+#include "MEDMEM_Connectivity.hxx"
+#include "MEDMEM_CellModel.hxx"
+
+//update Families with content list
+//int family_count(int family_number, int count, int * entities_number, int * entities_list) ;
+
+// ------- Drivers Management Part
+
+// MESH::INSTANCE_DE<MED_MESH_RDONLY_DRIVER> MESH::inst_med_rdonly ;
+//const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med_rdonly , &MESH::inst_med_rdwr } ;
+
+MESH::INSTANCE_DE<MED_MESH_RDWR_DRIVER> MESH::inst_med ;
+const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med } ;
+
+/*! Add a MESH driver of type (MED_DRIVER, ....) associated with file <fileName>. The meshname used in the file
+ is <driverName>. addDriver returns an int handler. */
+int MESH::addDriver(driverTypes driverType,
+ const string & fileName="Default File Name.med",const string & driverName="Default Mesh Name") {
+
+ const char * LOC = "MESH::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Mesh Name\") : ";
+
+ GENDRIVER * driver;
+ int current;
+
+ BEGIN_OF(LOC);
+
+ driver = instances[driverType]->run(fileName, this) ;
+ _drivers.push_back(driver);
+ current = _drivers.size()-1;
+
+ _drivers[current]->setMeshName(driverName);
+ return current;
+
+ END_OF(LOC);
+
+}
+
+/*! Add an existing MESH driver. */
+int MESH::addDriver(GENDRIVER & driver) {
+ const char * LOC = "MESH::addDriver(GENDRIVER &) : ";
+ BEGIN_OF(LOC);
+
+ // A FAIRE VERIFIER QUE LE DRIVER EST DE TYPE MESH !!
+ _drivers.push_back(&driver);
+ return _drivers.size()-1;
+
+ END_OF(LOC);
+}
+
+/*! Remove an existing MESH driver. */
+void MESH::rmDriver (int index=0) {
+ const char * LOC = "MESH::rmDriver (int index=0): ";
+ BEGIN_OF(LOC);
+
+ if ( _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()
+ )
+ );
+
+ END_OF(LOC);
+
+};
+
+// ------ End of Drivers Management Part
+
+
+void MESH::init() {
+
+ string _name = "NOT DEFINED"; // A POSITIONNER EN FCT DES IOS ?
+
+ _numberOfMEDNodeFamily = MED_INVALID;
+ _MEDArrayNodeFamily = (int * ) NULL; // SOLUTION TEMPORAIRE
+ _numberOfMEDCellFamily = (int * ) NULL;
+ _numberOfMEDFaceFamily = (int * ) NULL;
+ _numberOfMEDEdgeFamily = (int * ) NULL;
+ _MEDArrayCellFamily = (int **) NULL; // SOLUTION TEMPORAIRE
+ _MEDArrayFaceFamily = (int **) NULL; // SOLUTION TEMPORAIRE
+ _MEDArrayEdgeFamily = (int **) NULL; // SOLUTION TEMPORAIRE
+
+ COORDINATE * _coordinate = (COORDINATE *) NULL;
+ CONNECTIVITY * _connectivity = (CONNECTIVITY *) NULL;
+
+ _spaceDimension = MED_INVALID; // 0 ?!?
+ _meshDimension = MED_INVALID;
+ _numberOfNodes = MED_INVALID;
+
+ _numberOfNodesFamilies = 0; // MED_INVALID ?!?
+ _numberOfCellsFamilies = 0;
+ _numberOfFacesFamilies = 0;
+ _numberOfEdgesFamilies = 0;
+
+ _numberOfNodesGroups = 0; // MED_INVALID ?!?
+ _numberOfCellsGroups = 0;
+ _numberOfFacesGroups = 0;
+ _numberOfEdgesGroups = 0;
+
+};
+
+/*! Create an empty MESH. */
+MESH::MESH() {
+ init();
+};
+
+MESH::MESH(const MESH &m)
+{
+ // VERIFIER QUE TS LES OPERATEURS DE RECOPIE DES ATTRIBUTS
+ // SONT CORRECTS.
+ *this = m;
+}
+
+MESH::~MESH() {
+
+ if ( _MEDArrayNodeFamily != (int * ) NULL) delete [] _MEDArrayNodeFamily; // SOLUTION TEMPORAIRE
+ if ( _numberOfMEDCellFamily != (int * ) NULL) delete [] _numberOfMEDCellFamily;
+ if ( _numberOfMEDFaceFamily != (int * ) NULL) delete [] _numberOfMEDFaceFamily;
+ if ( _numberOfMEDEdgeFamily != (int * ) NULL) delete [] _numberOfMEDEdgeFamily;
+ // IL FAUT FAIRE UNE BOUCLE DE DESALLOCATION
+ if ( _MEDArrayCellFamily != (int **) NULL) delete [] _MEDArrayCellFamily; // SOLUTION TEMPORAIRE
+ if ( _MEDArrayFaceFamily != (int **) NULL) delete [] _MEDArrayFaceFamily; // SOLUTION TEMPORAIRE
+ if ( _MEDArrayEdgeFamily != (int **) NULL) delete [] _MEDArrayEdgeFamily; // SOLUTION TEMPORAIRE
+
+ if (_coordinate != NULL) delete _coordinate ;
+ if (_connectivity != NULL) delete _connectivity ;
+ int size ;
+ size = _familyNode.size() ;
+ for (int i=0;i<size;i++)
+ delete _familyNode[i] ;
+ size = _familyCell.size() ;
+ for (int i=0;i<size;i++)
+ delete _familyCell[i] ;
+ size = _familyFace.size() ;
+ for (int i=0;i<size;i++)
+ delete _familyFace[i] ;
+ size = _familyEdge.size() ;
+ for (int i=0;i<size;i++)
+ delete _familyEdge[i] ;
+ size = _groupNode.size() ;
+ for (int i=0;i<size;i++)
+ delete _groupNode[i] ;
+ size = _groupCell.size() ;
+ for (int i=0;i<size;i++)
+ delete _groupCell[i] ;
+ size = _groupFace.size() ;
+ for (int i=0;i<size;i++)
+ delete _groupFace[i] ;
+ size = _groupEdge.size() ;
+ for (int i=0;i<size;i++)
+ delete _groupEdge[i] ;
+
+}
+
+MESH & MESH::operator=(const MESH &m)
+{
+
+ // A FAIRE.........
+
+ // ATTENTION CET OPERATEUR DE RECOPIE EST DANGEREUX POUR LES
+ // POINTEURS : ex : nodal_connectivity ???? EXPRES ????
+// _drivers = m._drivers;
+
+// space_dimension=m.space_dimension;
+// mesh_dimension=m.mesh_dimension;
+
+// nodes_count=m.nodes_count;
+// coordinates=m.coordinates;
+// coordinates_name=m.coordinates_name ;
+// coordinates_unit=m.coordinates_unit ;
+// nodes_numbers=m.nodes_numbers ;
+
+// cells_types_count=m.cells_types_count;
+// cells_type=m.cells_type;
+// cells_count=m.cells_count;
+// nodal_connectivity=m.nodal_connectivity;
+
+// nodes_families_count=m.nodes_families_count;
+// nodes_Families=m.nodes_Families;
+
+// cells_families_count=m.cells_families_count;
+// cells_Families=m.cells_Families;
+
+// maximum_cell_number_by_node = m.maximum_cell_number_by_node;
+// if (maximum_cell_number_by_node > 0)
+// {
+// reverse_nodal_connectivity = m.reverse_nodal_connectivity;
+// reverse_nodal_connectivity_index = m.reverse_nodal_connectivity_index ;
+// }
+ return *this;
+}
+
+/*! Create a MESH object using a MESH driver of type (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="") {
+ const char * LOC ="MESH::MESH(driverTypes driverType, const string & fileName="", const string & driverName="") : ";
+
+ int current;
+
+ BEGIN_OF(LOC);
+
+ init();
+
+ current = addDriver(driverType,fileName,driverName);
+ switch(_drivers[current]->getAccessMode() ) {
+ case MED_RDONLY : {
+ MESSAGE("MESH::MESH(driverTypes driverType, .....) : driverType must have a MED_RDWR accessMode");
+ rmDriver(current);
+ break;}
+ default : {
+ }
+ }
+ _drivers[current]->open();
+ _drivers[current]->read();
+ _drivers[current]->close();
+ END_OF(LOC);
+};
+
+
+// Node MESH::Donne_Barycentre(const Maille &m) const
+// {
+// Node N=node[m[0]];
+// for (int i=1;i<m.donne_nbr_sommets();i++) N=N+node[m[i]];
+// N=N*(1.0/m.donne_nbr_sommets());
+// return N;
+// }
+
+ostream & operator<<(ostream &os, MESH &myMesh)
+{
+// int space_dimension = myMesh.get_space_dimension();
+// os << "Space dimension "<< space_dimension << endl ;
+// int nodes_count = myMesh.get_nodes_count() ;
+// os << "Nodes count : "<< nodes_count << endl ;
+// double * coord = myMesh.get_coordinates();
+// os << "Coordinates :" << endl ;
+// string * coordinate_name = myMesh.get_coordinates_name() ;
+// string * coordinate_unit = myMesh.get_coordinates_unit() ;
+
+// for(int i=0;i<space_dimension;i++) {
+// os << " - name "<< i << " : "<< coordinate_name[i] << endl;
+// os << " - unit "<< i << " : "<< coordinate_unit[i] << endl ;
+// }
+
+// for(int j=0;j<nodes_count;j++) {
+// for(int i=0;i<space_dimension;i++)
+// os << " coord["<< i <<","<< j << "] : "<< coord[j+i*nodes_count] <<" ," ;
+// os << endl;
+// }
+
+// int cells_types_count = myMesh.get_cells_types_count() ;
+// os << "cells_types_count : " << cells_types_count << endl ;
+// for(int i=1;i<cells_types_count;i++) {
+// os << "cell type : " << myMesh.get_cells_type(i) << endl ;
+// os << " - cells count : " << myMesh.get_cells_count(i) << endl ;
+// int *conectivity = myMesh.get_nodal_connectivity(i) ;
+// int nodes_cells_count = myMesh.get_cells_type(i).get_nodes_count() ;
+// for(int j=0;j<myMesh.get_cells_count(i);j++) {
+// os << " " ;
+// for(int k=0;k<nodes_cells_count;k++)
+// os <<conectivity[j*nodes_cells_count+k] << " " ;
+// os << endl ;
+// }
+// }
+
+// int nodes_families_count = myMesh.get_nodes_families_count() ;
+// os << "nodes_families_count : " << nodes_families_count << endl ;
+// vector<FamilyNode*> nodes_Families = myMesh.get_nodes_Families() ;
+// for(int i=0;i<nodes_families_count;i++)
+// os << " - Famile "<<i<<" : "<< (FamilyNode &) (*nodes_Families[i]) << endl ;
+// os << endl ;
+
+// int cells_families_count = myMesh.get_cells_families_count() ;
+// os << "cells_families_count : " << cells_families_count << endl ;
+// vector<FamilyCell*> cells_Families = myMesh.get_cells_Families() ;
+// for(int i=0;i<cells_families_count;i++)
+// os << " - Famile "<<i<<" : "<< (*cells_Families[i]) << endl ;
+// os << endl ;
+
+ return os ;
+}
+
+/*!
+ Get global number of element which have same connectivity than connectivity argument
+*/
+int MESH::getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity)
+{
+ const char* LOC="MESH::getElementNumber " ;
+ BEGIN_OF(LOC) ;
+
+ int numberOfValue ; // size of connectivity array
+ CELLMODEL myType(Type) ;
+ if (ConnectivityType==MED_DESCENDING)
+ numberOfValue = myType.getNumberOfConstituents(1) ; // faces (3D) or edges (2D)
+ else
+ numberOfValue = myType.getNumberOfNodes() ; // nodes
+
+ int * myReverseConnectivityValue = getReverseConnectivity(ConnectivityType) ;
+ int * myReverseConnectivityIndex = getReverseConnectivityIndex(ConnectivityType) ;
+
+ // First node or face/edge
+ int indexBegin = myReverseConnectivityIndex[connectivity[0]-1] ;
+ int indexEnd = myReverseConnectivityIndex[connectivity[0]] ;
+
+ // list to put cells numbers
+ list<int> cellsList ;
+ list<int>::iterator itList ;
+ for (int i=indexBegin; i<indexEnd; i++)
+ cellsList.push_back(myReverseConnectivityValue[i-1]) ;
+
+ // Foreach node or face/edge in cell, we search cells which are in common.
+ // At the end, we must have only one !
+
+ for (int i=1; i<numberOfValue; i++) {
+ int connectivity_i = connectivity[i] ;
+ for (itList=cellsList.begin();itList!=cellsList.end();itList++) {
+ bool find = false ;
+ for (int j=myReverseConnectivityIndex[connectivity_i-1]; j<myReverseConnectivityIndex[connectivity_i]; j++) {
+ if ((*itList)==myReverseConnectivityValue[j-1]) {
+ find=true ;
+ break ;
+ }
+ }
+ if (!find) {
+ itList=cellsList.erase(itList);
+ itList--; // well : rigth if itList = cellsList.begin() ??
+ }
+ }
+ }
+
+ if (cellsList.size()>1) // we have more than one cell
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Found more than one element !")) ;
+
+ if (cellsList.size()==0)
+ return -1;
+
+ END_OF(LOC);
+
+ return cellsList.front() ;
+}
+
+
+/*!
+ 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) throw (MEDEXCEPTION)
+{
+ const char * LOC = "MESH::getBoundaryElements : " ;
+ BEGIN_OF(LOC) ;
+ // some test :
+ // actually we could only get face (in 3D) and edge (in 2D)
+ if (_spaceDimension == 3)
+ if (Entity != MED_FACE)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 3D mesh for entity "<<Entity<<" !"));
+ if (_spaceDimension == 2)
+ if (Entity != MED_EDGE)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 2D mesh for entity "<<Entity<<" !"));
+
+ // well, all rigth !
+ SUPPORT * mySupport = new SUPPORT(this,"Boundary",Entity);
+ //mySupport.setDescription("boundary of type ...");
+ mySupport->setAll(false);
+
+
+ int * myConnectivityValue = getReverseConnectivity(MED_DESCENDING) ;
+ int * myConnectivityIndex = getReverseConnectivityIndex(MED_DESCENDING) ;
+ int numberOf = getNumberOfElements(Entity,MED_ALL_ELEMENTS) ;
+ list<int> myElementsList ;
+ int size = 0 ;
+ SCRUTE(numberOf) ;
+ for (int i=0 ; i<numberOf; i++)
+ if (myConnectivityValue[myConnectivityIndex[i]] == 0) {
+ SCRUTE(i+1) ;
+ myElementsList.push_back(i+1) ;
+ size++ ;
+ }
+ SCRUTE(size) ;
+ // Well, we must know how many geometric type we have found
+ int * myListArray = new int[size] ;
+ int id = 0 ;
+ list<int>::iterator myElementsListIt ;
+ for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
+ myListArray[id]=(*myElementsListIt) ;
+ SCRUTE(id);
+ SCRUTE(myListArray[id]);
+ id ++ ;
+ }
+
+ int numberOfGeometricType ;
+ medGeometryElement* geometricType ;
+ int * numberOfGaussPoint ;
+ int * geometricTypeNumber ;
+ int * numberOfEntities ;
+ MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ;
+ int * mySkyLineArrayIndex ;
+
+ int numberOfType = getNumberOfTypes(Entity) ;
+ if (numberOfType == 1) { // wonderfull : it's easy !
+ numberOfGeometricType = 1 ;
+ geometricType = new medGeometryElement[1] ;
+ medGeometryElement * allType = getTypes(Entity);
+ geometricType[0] = allType[0] ;
+ numberOfGaussPoint = new int[1] ;
+ numberOfGaussPoint[0] = 1 ;
+ geometricTypeNumber = new int[1] ; // not use, but initialized to nothing
+ geometricTypeNumber[0] = 0 ;
+ numberOfEntities = new int[1] ;
+ numberOfEntities[0] = size ;
+ mySkyLineArrayIndex = new int[2] ;
+ mySkyLineArrayIndex[0]=1 ;
+ mySkyLineArrayIndex[1]=1+size ;
+ }
+ else {// hemmm
+ map<medGeometryElement,int> theType ;
+ for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
+ medGeometryElement myType = getElementType(Entity,*myElementsListIt) ;
+ if (theType.find(myType) != theType.end() )
+ theType[myType]+=1 ;
+ else
+ theType[myType]=1 ;
+ }
+ numberOfGeometricType = theType.size() ;
+ geometricType = new medGeometryElement[numberOfGeometricType] ;
+ medGeometryElement * allType = getTypes(Entity);
+ numberOfGaussPoint = new int[numberOfGeometricType] ;
+ geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing
+ numberOfEntities = new int[numberOfGeometricType] ;
+ mySkyLineArrayIndex = new int[numberOfGeometricType+1] ;
+ int index = 0 ;
+ mySkyLineArrayIndex[0]=1 ;
+ map<medGeometryElement,int>::iterator theTypeIt ;
+ for (theTypeIt=theType.begin();theTypeIt!=theType.end();theTypeIt++) {
+ geometricType[index] = (*theTypeIt).first ;
+ numberOfGaussPoint[index] = 1 ;
+ geometricTypeNumber[index] = 0 ;
+ numberOfEntities[index] = (*theTypeIt).second ;
+ mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfEntities[index] ;
+ index++ ;
+ }
+ }
+ mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
+
+ mySupport->setNumberOfGeometricType(numberOfGeometricType) ;
+ mySupport->setGeometricType(geometricType) ;
+ mySupport->setNumberOfGaussPoint(numberOfGaussPoint) ;
+ mySupport->setGeometricTypeNumber(geometricTypeNumber) ;
+ mySupport->setNumberOfEntities(numberOfEntities) ;
+ mySupport->setTotalNumberOfEntities(size) ;
+ mySupport->setNumber(mySkyLineArray) ;
+
+ END_OF(LOC) ;
+ return mySupport ;
+}
+
+FIELD<double>* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION)
+{
+ // Support must be on 3D elements
+ MESSAGE("MESH::getVolume(SUPPORT*)");
+
+ // Make sure that the MESH class is the same as the MESH class attribut
+ // in the class Support
+ MESH* myMesh = Support->getMesh();
+ if (this != myMesh)
+ throw MEDEXCEPTION("MESH::getVolume(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
+
+ int dim_space = getSpaceDimension();
+ medEntityMesh support_entity = Support->getEntity();
+ bool onAll = Support->isOnAllElements();
+
+ int nb_type, length_values;
+ medGeometryElement* types;
+ int nb_entity_type;
+ // !!!! WARNING : use of nodal global numbering in the mesh !!!!
+ int* global_connectivity;
+
+ if (onAll)
+ {
+ nb_type = myMesh->getNumberOfTypes(support_entity);
+ length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+ types = getTypes(support_entity);
+ }
+ else
+ {
+ nb_type = Support->getNumberOfTypes();
+ length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
+ types = Support->getTypes();
+ }
+
+ int index;
+ FIELD<double>* Volume;
+
+ Volume = new FIELD<double>::FIELD(Support,1);
+ // double *volume = new double [length_values];
+ Volume->setName("VOLUME");
+ Volume->setDescription("cells volume");
+ Volume->setComponentName(1,"volume");
+ Volume->setComponentDescription(1,"desc-comp");
+
+ /* string MEDComponentUnit(MED_TAILLE_PNOM,' ');*/
+
+ string MEDComponentUnit = myMesh->getCoordinatesUnits()[0]+"*"+myMesh->getCoordinatesUnits()[1]+"*"+myMesh->getCoordinatesUnits()[2];
+
+ Volume->setMEDComponentUnit(1,MEDComponentUnit);
+
+ Volume->setValueType(MED_REEL64);
+
+ Volume->setIterationNumber(0);
+ Volume->setOrderNumber(0);
+ Volume->setTime(0.0);
+
+ double *volume = Volume->getValue(MED_FULL_INTERLACE);
+
+ index = 0;
+ const double * coord = getCoordinates(MED_FULL_INTERLACE);
+
+ for (int i=0;i<nb_type;i++)
+ {
+ medGeometryElement type = types[i] ;
+ double xvolume;
+
+ if (onAll)
+ {
+ nb_entity_type = getNumberOfElements(support_entity,type);
+ global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
+ }
+ else
+ {
+ nb_entity_type = Support->getNumberOfElements(type);
+
+ int * supp_number = Support->getNumber(type);
+ int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ global_connectivity = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+ }
+
+ switch (type)
+ {
+ case MED_TETRA4 : case MED_TETRA10 :
+ {
+ for (int tetra=0;tetra<nb_entity_type;tetra++)
+ {
+ int tetra_index = (type%100)*tetra;
+
+ int N1 = global_connectivity[tetra_index]-1;
+ int N2 = global_connectivity[tetra_index+1]-1;
+ int N3 = global_connectivity[tetra_index+2]-1;
+ int N4 = global_connectivity[tetra_index+3]-1;
+
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+ double x3 = coord[dim_space*N3];
+ double x4 = coord[dim_space*N4];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+ double y3 = coord[dim_space*N3+1];
+ double y4 = coord[dim_space*N4+1];
+
+ double z1 = coord[dim_space*N1+2];
+ double z2 = coord[dim_space*N2+2];
+ double z3 = coord[dim_space*N3+2];
+ double z4 = coord[dim_space*N4+2];
+
+ xvolume = ((x3-x1)*((y2-y1)*(z4-z1) - (z2-z1)*(y4-y1)) -
+ (x2-x1)*((y3-y1)*(z4-z1) - (z3-z1)*(y4-y1)) +
+ (x4-x1)*((y3-y1)*(z2-z1) - (z3-z1)*(y2-y1)))/6.0;
+
+ volume[index] = xvolume ;
+ index++;
+ }
+ break;
+ }
+ case MED_PYRA5 : case MED_PYRA13 :
+ {
+ for (int pyra=0;pyra<nb_entity_type;pyra++)
+ {
+ int pyra_index = (type%100)*pyra;
+
+ int N1 = global_connectivity[pyra_index]-1;
+ int N2 = global_connectivity[pyra_index+1]-1;
+ int N3 = global_connectivity[pyra_index+2]-1;
+ int N4 = global_connectivity[pyra_index+3]-1;
+ int N5 = global_connectivity[pyra_index+4]-1;
+
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+ double x3 = coord[dim_space*N3];
+ double x4 = coord[dim_space*N4];
+ double x5 = coord[dim_space*N5];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+ double y3 = coord[dim_space*N3+1];
+ double y4 = coord[dim_space*N4+1];
+ double y5 = coord[dim_space*N5+1];
+
+ double z1 = coord[dim_space*N1+2];
+ double z2 = coord[dim_space*N2+2];
+ double z3 = coord[dim_space*N3+2];
+ double z4 = coord[dim_space*N4+2];
+ double z5 = coord[dim_space*N5+2];
+
+ xvolume = (((x3-x1)*((y2-y1)*(z5-z1) - (z2-z1)*(y5-y1)) -
+ (x2-x1)*((y3-y1)*(z5-z1) - (z3-z1)*(y5-y1)) +
+ (x5-x1)*((y3-y1)*(z2-z1) - (z3-z1)*(y2-y1))) +
+ ((x4-x1)*((y3-y1)*(z5-z1) - (z3-z1)*(y5-y1)) -
+ (x3-x1)*((y4-y1)*(z5-z1) - (z4-z1)*(y5-y1)) +
+ (x5-x1)*((y4-y1)*(z3-z1) - (z4-z1)*(y3-y1)))
+ )/6.0;
+
+ volume[index] = xvolume ;
+ index = index++;
+ }
+ break;
+ }
+ case MED_PENTA6 : case MED_PENTA15 :
+ {
+ for (int penta=0;penta<nb_entity_type;penta++)
+ {
+ int penta_index = (type%100)*penta;
+
+ int N1 = global_connectivity[penta_index]-1;
+ int N2 = global_connectivity[penta_index+1]-1;
+ int N3 = global_connectivity[penta_index+2]-1;
+ int N4 = global_connectivity[penta_index+3]-1;
+ int N5 = global_connectivity[penta_index+4]-1;
+ int N6 = global_connectivity[penta_index+5]-1;
+
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+ double x3 = coord[dim_space*N3];
+ double x4 = coord[dim_space*N4];
+ double x5 = coord[dim_space*N5];
+ double x6 = coord[dim_space*N6];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+ double y3 = coord[dim_space*N3+1];
+ double y4 = coord[dim_space*N4+1];
+ double y5 = coord[dim_space*N5+1];
+ double y6 = coord[dim_space*N6+1];
+
+ double z1 = coord[dim_space*N1+2];
+ double z2 = coord[dim_space*N2+2];
+ double z3 = coord[dim_space*N3+2];
+ double z4 = coord[dim_space*N4+2];
+ double z5 = coord[dim_space*N5+2];
+ double z6 = coord[dim_space*N6+2];
+
+ double a1 = (x2-x3)/2.0, a2 = (y2-y3)/2.0, a3 = (z2-z3)/2.0;
+ double b1 = (x5-x6)/2.0, b2 = (y5-y6)/2.0, b3 = (z5-z6)/2.0;
+ double c1 = (x4-x1)/2.0, c2 = (y4-y1)/2.0, c3 = (z4-z1)/2.0;
+ double d1 = (x5-x2)/2.0, d2 = (y5-y2)/2.0, d3 = (z5-z2)/2.0;
+ double e1 = (x6-x3)/2.0, e2 = (y6-y3)/2.0, e3 = (z6-z3)/2.0;
+ double f1 = (x1-x3)/2.0, f2 = (y1-y3)/2.0, f3 = (z1-z3)/2.0;
+ double h1 = (x4-x6)/2.0, h2 = (y4-y6)/2.0, h3 = (z4-z6)/2.0;
+
+ double A = a1*c2*f3 - a1*c3*f2 - a2*c1*f3 + a2*c3*f1 +
+ a3*c1*f2 - a3*c2*f1;
+ double B = b1*c2*h3 - b1*c3*h2 - b2*c1*h3 + b2*c3*h1 +
+ b3*c1*h2 - b3*c2*h1;
+ double C = (a1*c2*h3 + b1*c2*f3) - (a1*c3*h2 + b1*c3*f2) -
+ (a2*c1*h3 + b2*c1*f3) + (a2*c3*h1 + b2*c3*f1) +
+ (a3*c1*h2 + b3*c1*f2) - (a3*c2*h1 + b3*c2*f1);
+ double D = a1*d2*f3 - a1*d3*f2 - a2*d1*f3 + a2*d3*f1 +
+ a3*d1*f2 - a3*d2*f1;
+ double E = b1*d2*h3 - b1*d3*h2 - b2*d1*h3 + b2*d3*h1 +
+ b3*d1*h2 - b3*d2*h1;
+ double F = (a1*d2*h3 + b1*d2*f3) - (a1*d3*h2 + b1*d3*f2) -
+ (a2*d1*h3 + b2*d1*f3) + (a2*d3*h1 + b2*d3*f1) +
+ (a3*d1*h2 + b3*d1*f2) - (a3*d2*h1 + b3*d2*f1);
+ double G = a1*e2*f3 - a1*e3*f2 - a2*e1*f3 + a2*e3*f1 +
+ a3*e1*f2 - a3*e2*f1;
+ double H = b1*e2*h3 - b1*e3*h2 - b2*e1*h3 + b2*e3*h1 +
+ b3*e1*h2 - b3*e2*h1;
+ double P = (a1*e2*h3 + b1*e2*f3) - (a1*e3*h2 + b1*e3*f2) -
+ (a2*e1*h3 + b2*e1*f3) + (a2*e3*h1 + b2*e3*f1) +
+ (a3*e1*h2 + b3*e1*f2) - (a3*e2*h1 + b3*e2*f1);
+
+ xvolume = -2.0*(2.0*(A + B + D + E + G + H) + C + F + P)/9.0;
+
+ volume[index] = xvolume ;
+ index++;
+ }
+ break;
+ }
+ case MED_HEXA8 : case MED_HEXA20 :
+ {
+ for (int hexa=0;hexa<nb_entity_type;hexa++)
+ {
+ int hexa_index = (type%100)*hexa;
+
+ int N1 = global_connectivity[hexa_index]-1;
+ int N2 = global_connectivity[hexa_index+1]-1;
+ int N3 = global_connectivity[hexa_index+2]-1;
+ int N4 = global_connectivity[hexa_index+3]-1;
+ int N5 = global_connectivity[hexa_index+4]-1;
+ int N6 = global_connectivity[hexa_index+5]-1;
+ int N7 = global_connectivity[hexa_index+6]-1;
+ int N8 = global_connectivity[hexa_index+7]-1;
+
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+ double x3 = coord[dim_space*N3];
+ double x4 = coord[dim_space*N4];
+ double x5 = coord[dim_space*N5];
+ double x6 = coord[dim_space*N6];
+ double x7 = coord[dim_space*N7];
+ double x8 = coord[dim_space*N8];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+ double y3 = coord[dim_space*N3+1];
+ double y4 = coord[dim_space*N4+1];
+ double y5 = coord[dim_space*N5+1];
+ double y6 = coord[dim_space*N6+1];
+ double y7 = coord[dim_space*N7+1];
+ double y8 = coord[dim_space*N8+1];
+
+ double z1 = coord[dim_space*N1+2];
+ double z2 = coord[dim_space*N2+2];
+ double z3 = coord[dim_space*N3+2];
+ double z4 = coord[dim_space*N4+2];
+ double z5 = coord[dim_space*N5+2];
+ double z6 = coord[dim_space*N6+2];
+ double z7 = coord[dim_space*N7+2];
+ double z8 = coord[dim_space*N8+2];
+
+ double a1 = (x3-x4)/8.0, a2 = (y3-y4)/8.0, a3 = (z3-z4)/8.0;
+ double b1 = (x2-x1)/8.0, b2 = (y2-y1)/8.0, b3 = (z2-z1)/8.0;
+ double c1 = (x7-x8)/8.0, c2 = (y7-y8)/8.0, c3 = (z7-z8)/8.0;
+ double d1 = (x6-x5)/8.0, d2 = (y6-y5)/8.0, d3 = (z6-z5)/8.0;
+ double e1 = (x3-x2)/8.0, e2 = (y3-y2)/8.0, e3 = (z3-z2)/8.0;
+ double f1 = (x4-x1)/8.0, f2 = (y4-y1)/8.0, f3 = (z4-z1)/8.0;
+ double h1 = (x7-x6)/8.0, h2 = (y7-y6)/8.0, h3 = (z7-z6)/8.0;
+ double p1 = (x8-x5)/8.0, p2 = (y8-y5)/8.0, p3 = (z8-z5)/8.0;
+ double q1 = (x3-x7)/8.0, q2 = (y3-y7)/8.0, q3 = (z3-z7)/8.0;
+ double r1 = (x4-x8)/8.0, r2 = (y4-y8)/8.0, r3 = (z4-z8)/8.0;
+ double s1 = (x2-x6)/8.0, s2 = (y2-y6)/8.0, s3 = (z2-z6)/8.0;
+ double t1 = (x1-x5)/8.0, t2 = (y1-y5)/8.0, t3 = (z1-z5)/8.0;
+
+ double A = a1*e2*q3 - a1*e3*q2 - a2*e1*q3 + a2*e3*q1 +
+ a3*e1*q2 - a3*e2*q1;
+ double B = c1*h2*q3 - c1*h3*q2 - c2*h1*q3 + c2*h3*q1 +
+ c3*h1*q2 - c3*h2*q1;
+ double C = (a1*h2 + c1*e2)*q3 - (a1*h3 + c1*e3)*q2 -
+ (a2*h1 + c2*e1)*q3 + (a2*h3 + c2*e3)*q1 +
+ (a3*h1 + c3*e1)*q2 - (a3*h2 + c3*e2)*q1;
+ double D = b1*e2*s3 - b1*e3*s2 - b2*e1*s3 + b2*e3*s1 +
+ b3*e1*s2 - b3*e2*s1;
+ double E = d1*h2*s3 - d1*h3*s2 - d2*h1*s3 + d2*h3*s1 +
+ d3*h1*s2 - d3*h2*s1;
+ double F = (b1*h2 + d1*e2)*s3 - (b1*h3 + d1*e3)*s2 -
+ (b2*h1 + d2*e1)*s3 + (b2*h3 + d2*e3)*s1 +
+ (b3*h1 + d3*e1)*s2 - (b3*h2 + d3*e2)*s1;
+ double G = (a1*e2*s3 + b1*e2*q3) - (a1*e3*s2 + b1*e3*q2) -
+ (a2*e1*s3 + b2*e1*q3) + (a2*e3*s1 + b2*e3*q1) +
+ (a3*e1*s2 + b3*e1*q2) - (a3*e2*s1 + b3*e2*q1);
+ double H = (c1*h2*s3 + d1*h2*q3) - (c1*h3*s2 + d1*h3*q2) -
+ (c2*h1*s3 + d2*h1*q3) + (c2*h3*s1 + d2*h3*q1) +
+ (c3*h1*s2 + d3*h1*q2) - (c3*h2*s1 + d3*h2*q1);
+ double I = ((a1*h2 + c1*e2)*s3 + (b1*h2 + d1*e2)*q3) -
+ ((a1*h3 + c1*e3)*s2 + (b1*h3 + d1*e3)*q2) -
+ ((a2*h1 + c2*e1)*s3 + (b2*h1 + d2*e1)*q3) +
+ ((a2*h3 + c2*e3)*s1 + (b2*h3 + d2*e3)*q1) +
+ ((a3*h1 + c3*e1)*s2 + (b3*h1 + d3*e1)*q2) -
+ ((a3*h2 + c3*e2)*s1 + (b3*h2 + d3*e2)*q1);
+ double J = a1*f2*r3 - a1*f3*r2 - a2*f1*r3 + a2*f3*r1 +
+ a3*f1*r2 - a3*f2*r1;
+ double K = c1*p2*r3 - c1*p3*r2 - c2*p1*r3 + c2*p3*r1 +
+ c3*p1*r2 - c3*p2*r1;
+ double L = (a1*p2 + c1*f2)*r3 - (a1*p3 + c1*f3)*r2 -
+ (a2*p1 + c2*f1)*r3 + (a2*p3 + c2*f3)*r1 +
+ (a3*p1 + c3*f1)*r2 - (a3*p2 + c3*f2)*r1;
+ double M = b1*f2*t3 - b1*f3*t2 - b2*f1*t3 + b2*f3*t1 +
+ b3*f1*t2 - b3*f2*t1;
+ double N = d1*p2*t3 - d1*p3*t2 - d2*p1*t3 + d2*p3*t1 +
+ d3*p1*t2 - d3*p2*t1;
+ double O = (b1*p2 + d1*f2)*t3 - (b1*p3 + d1*f3)*t2 -
+ (b2*p1 + d2*f1)*t3 + (b2*p3 + d2*f3)*t1 +
+ (b3*p1 + d3*f1)*t2 - (b3*p2 + d3*f2)*t1;
+ double P = (a1*f2*t3 + b1*f2*r3) - (a1*f3*t2 + b1*f3*r2) -
+ (a2*f1*t3 + b2*f1*r3) + (a2*f3*t1 + b2*f3*r1) +
+ (a3*f1*t2 + b3*f1*r2) - (a3*f2*t1 + b3*f2*r1);
+ double Q = (c1*p2*t3 + d1*p2*r3) - (c1*p3*t2 + d1*p3*r2) -
+ (c2*p1*t3 + d2*p1*r3) + (c2*p3*t1 + d2*p3*r1) +
+ (c3*p1*t2 + d3*p1*r2) - (c3*p2*t1 + d3*p2*r1);
+ double R = ((a1*p2 + c1*f2)*t3 + (b1*p2 + d1*f2)*r3) -
+ ((a1*p3 + c1*f3)*t2 + (b1*p3 + d1*f3)*r2) -
+ ((a2*p1 + c2*f1)*t3 + (b2*p1 + d2*f1)*r3) +
+ ((a2*p3 + c2*f3)*t1 + (b2*p3 + d2*f3)*r1) +
+ ((a3*p1 + c3*f1)*t2 + (b3*p1 + d3*f1)*r2) -
+ ((a3*p2 + c3*f2)*t1 + (b3*p2 + d3*f2)*r1);
+ double S = (a1*e2*r3 + a1*f2*q3) - (a1*e3*r2 + a1*f3*q2) -
+ (a2*e1*r3 + a2*f1*q3) + (a2*e3*r1 + a2*f3*q1) +
+ (a3*e1*r2 + a3*f1*q2) - (a3*e2*r1 + a3*f2*q1);
+ double T = (c1*h2*r3 + c1*p2*q3) - (c1*h3*r2 + c1*p3*q2) -
+ (c2*h1*r3 + c2*p1*q3) + (c2*h3*r1 + c2*p3*q1) +
+ (c3*h1*r2 + c3*p1*q2) - (c3*h2*r1 + c3*p2*q1);
+ double U = ((a1*h2 + c1*e2)*r3 + (a1*p2 + c1*f2)*q3) -
+ ((a1*h3 + c1*e3)*r2 + (a1*p3 + c1*f3)*q2) -
+ ((a2*h1 + c2*e1)*r3 + (a2*p1 + c2*f1)*q3) +
+ ((a2*h3 + c2*e3)*r1 + (a2*p3 + c2*f3)*q1) +
+ ((a3*h1 + c3*e1)*r2 + (a3*p1 + c3*f1)*q2) -
+ ((a3*h2 + c3*e2)*r1 + (a3*p2 + c3*f2)*q1);
+ double V = (b1*e2*t3 + b1*f2*s3) - (b1*e3*t2 + b1*f3*s2) -
+ (b2*e1*t3 + b2*f1*s3) + (b2*e3*t1 + b2*f3*s1) +
+ (b3*e1*t2 + b3*f1*s2) - (b3*e2*t1 + b3*f2*s1);
+ double W = (d1*h2*t3 + d1*p2*s3) - (d1*h3*t2 + d1*p3*s2) -
+ (d2*h1*t3 + d2*p1*s3) + (d2*h3*t1 + d2*p3*s1) +
+ (d3*h1*t2 + d3*p1*s2) - (d3*h2*t1 + d3*p2*s1);
+ double X = ((b1*h2 + d1*e2)*t3 + (b1*p2 + d1*f2)*s3) -
+ ((b1*h3 + d1*e3)*t2 + (b1*p3 + d1*f3)*s2) -
+ ((b2*h1 + d2*e1)*t3 + (b2*p1 + d2*f1)*s3) +
+ ((b2*h3 + d2*e3)*t1 + (b2*p3 + d2*f3)*s1) +
+ ((b3*h1 + d3*e1)*t2 + (b3*p1 + d3*f1)*s2) -
+ ((b3*h2 + d3*e2)*t1 + (b3*p2 + d3*f2)*s1);
+ double Y = (a1*e2*t3 + a1*f2*s3 + b1*e2*r3 + b1*f2*q3) -
+ (a1*e3*t2 + a1*f3*s2 + b1*e3*r2 + b1*f3*q2) -
+ (a2*e1*t3 + a2*f1*s3 + b2*e1*r3 + b2*f1*q3) +
+ (a2*e3*t1 + a2*f3*s1 + b2*e3*r1 + b2*f3*q1) +
+ (a3*e1*t2 + a3*f1*s2 + b3*e1*r2 + b3*f1*q2) -
+ (a3*e2*t1 + a3*f2*s1 + b3*e2*r1 + b3*f2*q1);
+ double Z = (c1*h2*t3 + c1*p2*s3 + d1*h2*r3 + d1*p2*q3) -
+ (c1*h3*t2 + c1*p3*s2 + d1*h3*r2 + d1*p3*q2) -
+ (c2*h1*t3 + c2*p1*s3 + d2*h1*r3 + d2*p1*q3) +
+ (c2*h3*t1 + c2*p3*s1 + d2*h3*r1 + d2*p3*q1) +
+ (c3*h1*t2 + c3*p1*s2 + d3*h1*r2 + d3*p1*q2) -
+ (c3*h2*t1 + c3*p2*s1 + d3*h2*r1 + d3*p2*q1);
+ double AA = ((a1*h2 + c1*e2)*t3 + (a1*p2 + c1*f2)*s3 +
+ (b1*h2 + d1*e2)*r3 + (b1*p2 + d1*f2)*q3) -
+ ((a1*h3 + c1*e3)*t2 + (a1*p3 + c1*f3)*s2 +
+ (b1*h3 + d1*e3)*r2 + (b1*p3 + d1*f3)*q2) -
+ ((a2*h1 + c2*e1)*t3 + (a2*p1 + c2*f1)*s3 +
+ (b2*h1 + d2*e1)*r3 + (b2*p1 + d2*f1)*q3) +
+ ((a2*h3 + c2*e3)*t1 + (a2*p3 + c2*f3)*s1 +
+ (b2*h3 + d2*e3)*r1 + (b2*p3 + d2*f3)*q1) +
+ ((a3*h1 + c3*e1)*t2 + (a3*p1 + c3*f1)*s2 +
+ (b3*h1 + d3*e1)*r2 + (b3*p1 + d3*f1)*q2) -
+ ((a3*h2 + c3*e2)*t1 + (a3*p2 + c3*f2)*s1 +
+ (b3*h2 + d3*e2)*r1 + (b3*p2 + d3*f2)*q1);
+
+ xvolume = 64.0*(8.0*(A + B + D + E + J + K + M + N) +
+ 4.0*(C + F + G + H + L + O + P + Q + S + T +
+ V + W) + 2.0*(I + R + U + X + Y + Z) +
+ AA)/27.0;
+
+ volume[index] = xvolume ;
+ index++;
+ }
+ break;
+ }
+ default :
+ throw MEDEXCEPTION("MESH::getVolume(SUPPORT*) Bad Support to get Volumes on it !");
+ break;
+ }
+ }
+
+ return Volume;
+}
+
+FIELD<double>* MESH::getArea(const SUPPORT * Support) throw (MEDEXCEPTION)
+{
+ // Support must be on 2D elements
+ MESSAGE("MESH::getArea(SUPPORT*)");
+
+ // Make sure that the MESH class is the same as the MESH class attribut
+ // in the class Support
+ MESH* myMesh = Support->getMesh();
+ if (this != myMesh)
+ throw MEDEXCEPTION("MESH::getArea(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
+
+ int dim_space = getSpaceDimension();
+ medEntityMesh support_entity = Support->getEntity();
+ bool onAll = Support->isOnAllElements();
+
+ int nb_type, length_values;
+ medGeometryElement* types;
+ int nb_entity_type;
+ // !!!! WARNING : use of nodal global numbering in the mesh !!!!
+ int* global_connectivity;
+
+ if (onAll)
+ {
+ nb_type = myMesh->getNumberOfTypes(support_entity);
+ length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+ types = getTypes(support_entity);
+ }
+ else
+ {
+ nb_type = Support->getNumberOfTypes();
+ length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
+ types = Support->getTypes();
+ }
+
+ int index;
+ FIELD<double>* Area;
+
+ Area = new FIELD<double>::FIELD(Support,1);
+ Area->setName("AREA");
+ Area->setDescription("cells or faces area");
+
+ Area->setComponentName(1,"area");
+ Area->setComponentDescription(1,"desc-comp");
+
+ /* string MEDComponentUnit = myMesh->getCoordinatesUnits()[0]+"*"+myMesh->getCoordinatesUnits()[1];*/
+
+ string MEDComponentUnit="trucmuch";
+
+ Area->setMEDComponentUnit(1,MEDComponentUnit);
+
+ Area->setValueType(MED_REEL64);
+
+ Area->setIterationNumber(0);
+ Area->setOrderNumber(0);
+ Area->setTime(0.0);
+
+ double *area = new double[length_values];
+ //double *area = Area->getValue(MED_FULL_INTERLACE);
+
+ const double * coord = getCoordinates(MED_FULL_INTERLACE);
+ index = 0;
+
+ for (int i=0;i<nb_type;i++)
+ {
+ medGeometryElement type = types[i] ;
+ double xarea;
+
+ if (onAll)
+ {
+ nb_entity_type = getNumberOfElements(support_entity,type);
+ global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
+ }
+ else
+ {
+ nb_entity_type = Support->getNumberOfElements(type);
+
+ int * supp_number = Support->getNumber(type);
+ int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ global_connectivity = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+ }
+
+ switch (type)
+ {
+ case MED_TRIA3 : case MED_TRIA6 :
+ {
+ for (int tria=0;tria<nb_entity_type;tria++)
+ {
+ int tria_index = (type%100)*tria;
+
+ int N1 = global_connectivity[tria_index]-1;
+ int N2 = global_connectivity[tria_index+1]-1;
+ int N3 = global_connectivity[tria_index+2]-1;
+
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+ double x3 = coord[dim_space*N3];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+ double y3 = coord[dim_space*N3+1];
+
+ if (dim_space==2)
+ {
+ xarea = - ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1))/2.0;
+ }
+ else
+ {
+ double z1 = coord[dim_space*N1+2];
+ double z2 = coord[dim_space*N2+2];
+ double z3 = coord[dim_space*N3+2];
+
+ xarea = sqrt(((y2-y1)*(z3-z1) - (y3-y1)*(z2-z1))*
+ ((y2-y1)*(z3-z1) - (y3-y1)*(z2-z1)) +
+ ((x3-x1)*(z2-z1) - (x2-x1)*(z3-z1))*
+ ((x3-x1)*(z2-z1) - (x2-x1)*(z3-z1)) +
+ ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1))*
+ ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1)))/2.0;
+ }
+
+ area[index] = xarea ;
+ index++;
+ }
+ break;
+ }
+ case MED_QUAD4 : case MED_QUAD8 :
+ {
+ for (int quad=0;quad<nb_entity_type;quad++)
+ {
+ int quad_index = (type%100)*quad;
+
+ int N1 = global_connectivity[quad_index]-1;
+ int N2 = global_connectivity[quad_index+1]-1;
+ int N3 = global_connectivity[quad_index+2]-1;
+ int N4 = global_connectivity[quad_index+3]-1;
+
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+ double x3 = coord[dim_space*N3];
+ double x4 = coord[dim_space*N4];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+ double y3 = coord[dim_space*N3+1];
+ double y4 = coord[dim_space*N4+1];
+
+ if (dim_space==2)
+ {
+ double a1 = (x2-x1)/4.0, a2 = (y2-y1)/4.0;
+ double b1 = (x3-x4)/4.0, b2 = (y3-y4)/4.0;
+ double c1 = (x3-x2)/4.0, c2 = (y3-y2)/4.0;
+ double d1 = (x4-x1)/4.0, d2 = (y4-y1)/4.0;
+
+ xarea = - 4.0*(b1*c2 - c1*b2 + a1*c2 - c1*a2 + b1*d2 -
+ d1*b2 + a1*d2 - d1*a2);
+ }
+ else
+ {
+ double z1 = coord[dim_space*N1+2];
+ double z2 = coord[dim_space*N2+2];
+ double z3 = coord[dim_space*N3+2];
+ double z4 = coord[dim_space*N4+2];
+
+ xarea = (sqrt(((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1))*
+ ((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1)) +
+ ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1))*
+ ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1)) +
+ ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))*
+ ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))) +
+ sqrt(((y4-y3)*(z2-z3) - (y2-y3)*(z4-z3))*
+ ((y4-y3)*(z2-z3) - (y2-y3)*(z4-z3)) +
+ ((x2-x3)*(z4-z3) - (x4-x3)*(z2-z3))*
+ ((x2-x3)*(z4-z3) - (x4-x3)*(z2-z3)) +
+ ((x4-x3)*(y2-y3) - (x2-x3)*(y4-y3))*
+ ((x4-x3)*(y2-y3) - (x2-x3)*(y4-y3))))/2.0;
+ }
+
+ area[index] = xarea ;
+ index++;
+ }
+ break;
+ }
+ default :
+ throw MEDEXCEPTION("MESH::getArea(SUPPORT*) Bad Support to get Areas on it !");
+ break;
+ }
+ }
+
+ Area->setValue(MED_FULL_INTERLACE,area);
+
+ return Area;
+}
+
+FIELD<double>* MESH::getLength(const SUPPORT * Support) throw (MEDEXCEPTION)
+{
+ // Support must be on 1D elements
+ MESSAGE("MESH::getLength(SUPPORT*)");
+
+ // Make sure that the MESH class is the same as the MESH class attribut
+ // in the class Support
+ MESH* myMesh = Support->getMesh();
+ if (this != myMesh)
+ throw MEDEXCEPTION("MESH::getLength(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
+
+ int dim_space = getSpaceDimension();
+ medEntityMesh support_entity = Support->getEntity();
+ bool onAll = Support->isOnAllElements();
+
+ int nb_type, length_values;
+ medGeometryElement* types;
+ int nb_entity_type;
+ // !!!! WARNING : use of nodal global numbering in the mesh !!!!
+ int* global_connectivity;
+
+ if (onAll)
+ {
+ nb_type = myMesh->getNumberOfTypes(support_entity);
+ length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+ types = getTypes(support_entity);
+ }
+ else
+ {
+ nb_type = Support->getNumberOfTypes();
+ length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
+ types = Support->getTypes();
+ }
+
+ int index;
+ FIELD<double>* Length;
+
+ Length = new FIELD<double>::FIELD(Support,1);
+ // double *length = new double [length_values];
+ Length->setValueType(MED_REEL64);
+
+ double *length = Length->getValue(MED_FULL_INTERLACE);
+
+ const double * coord = getCoordinates(MED_FULL_INTERLACE);
+ index = 0;
+
+ for (int i=0;i<nb_type;i++)
+ {
+ medGeometryElement type = types[i] ;
+ double xlength;
+
+ if (onAll)
+ {
+ nb_entity_type = getNumberOfElements(support_entity,type);
+ global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
+ }
+ else
+ {
+ nb_entity_type = Support->getNumberOfElements(type);
+
+ int * supp_number = Support->getNumber(type);
+ int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ global_connectivity = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+ }
+
+ switch (type)
+ {
+ case MED_SEG2 : case MED_SEG3 :
+ {
+ for (int edge=0;edge<nb_entity_type;edge++)
+ {
+ int edge_index = (type%100)*edge;
+
+ int N1 = global_connectivity[edge_index]-1;
+ int N2 = global_connectivity[edge_index+1]-1;
+
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+
+ double z1, z2 ; z1 = 0.0 ; z2 = 0.0 ; if (dim_space==3) {
+ z1 = coord[dim_space*N1+2]; z2 = coord[dim_space*N2+2];}
+
+ xlength = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2) +
+ (z1 - z2)*(z1 - z2));
+
+ length[index] = xlength ;
+ index++;
+ }
+ break;
+ }
+ default :
+ throw MEDEXCEPTION("MESH::getLength(SUPPORT*) Bad Support to get Lengths on it !");
+ break;
+ }
+ }
+
+ return Length;
+}
+
+FIELD<double>* MESH::getNormal(const SUPPORT * Support) throw (MEDEXCEPTION)
+{
+ // Support must be on 2D or 1D elements
+ MESSAGE("MESH::getNormal(SUPPORT*)");
+
+ // Make sure that the MESH class is the same as the MESH class attribut
+ // in the class Support
+ MESH* myMesh = Support->getMesh();
+ if (this != myMesh)
+ throw MEDEXCEPTION("MESH::getNormal(SUPPORT*) no compatibility between *this and SUPPORT::_mesh : pointeur problem !");
+
+ int dim_space = getSpaceDimension();
+ medEntityMesh support_entity = Support->getEntity();
+ bool onAll = Support->isOnAllElements();
+
+ int nb_type, length_values;
+ medGeometryElement* types;
+ int nb_entity_type;
+ // !!!! WARNING : use of nodal global numbering in the mesh !!!!
+ int* global_connectivity;
+
+ if (onAll)
+ {
+ nb_type = myMesh->getNumberOfTypes(support_entity);
+ length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+ types = getTypes(support_entity);
+ }
+ else
+ {
+ nb_type = Support->getNumberOfTypes();
+ length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
+ types = Support->getTypes();
+ }
+
+ int index;
+
+ FIELD<double>* Normal = new FIELD<double>::FIELD(Support,dim_space);
+ Normal->setName("NORMAL");
+ Normal->setDescription("cells or faces normal");
+ for (int k=0;k<dim_space;k++) {
+ int kp1 = k + 1;
+ Normal->setComponentName(kp1,"normal");
+ Normal->setComponentDescription(kp1,"desc-comp");
+ Normal->setMEDComponentUnit(kp1,"unit");
+ }
+
+ Normal->setValueType(MED_REEL64);
+
+ Normal->setIterationNumber(0);
+ Normal->setOrderNumber(0);
+ Normal->setTime(0.0);
+
+ double * normal = new double [dim_space*length_values];
+ //double *normal = Normal->getValue(MED_FULL_INTERLACE);
+
+ const double * coord = getCoordinates(MED_FULL_INTERLACE);
+ index = 0;
+
+ for (int i=0;i<nb_type;i++)
+ {
+ medGeometryElement type = types[i] ;
+
+ // 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
+
+ if ( (((type==MED_TRIA3) || (type==MED_TRIA6) ||
+ (type==MED_QUAD4) || (type==MED_QUAD8)) &&
+ (dim_space != 3)) || (((type==MED_SEG2) || (type==MED_SEG3)) &&
+ (dim_space != 2)) )
+ throw MEDEXCEPTION("MESH::getNormal(SUPPORT*) no compatibility between *this and SUPPORT::_mesh : dimension problem !");
+
+ double xnormal1, xnormal2, xnormal3 ;
+
+ if (onAll)
+ {
+ nb_entity_type = getNumberOfElements(support_entity,type);
+ global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
+ }
+ else
+ {
+ nb_entity_type = Support->getNumberOfElements(type);
+
+ int * supp_number = Support->getNumber(type);
+ int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ global_connectivity = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+ }
+
+ switch (type)
+ {
+ case MED_TRIA3 : case MED_TRIA6 :
+ {
+ for (int tria=0;tria<nb_entity_type;tria++)
+ {
+ int tria_index = (type%100)*tria;
+
+ int N1 = global_connectivity[tria_index]-1;
+ int N2 = global_connectivity[tria_index+1]-1;
+ int N3 = global_connectivity[tria_index+2]-1;
+
+ double xarea;
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+ double x3 = coord[dim_space*N3];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+ double y3 = coord[dim_space*N3+1];
+
+ double z1 = coord[dim_space*N1+2];
+ double z2 = coord[dim_space*N2+2];
+ double z3 = coord[dim_space*N3+2];
+
+ xnormal1 = ((y2-y1)*(z3-z1) - (y3-y1)*(z2-z1))/2.0;
+ xnormal2 = ((x3-x1)*(z2-z1) - (x2-x1)*(z3-z1))/2.0;
+ xnormal3 = ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1))/2.0;
+
+ normal[3*index] = xnormal1 ;
+ normal[3*index+1] = xnormal2 ;
+ normal[3*index+2] = xnormal3 ;
+
+ index++;
+ }
+ break;
+ }
+ case MED_QUAD4 : case MED_QUAD8 :
+ {
+ for (int quad=0;quad<nb_entity_type;quad++)
+ {
+ int quad_index = (type%100)*quad;
+
+ int N1 = global_connectivity[quad_index]-1;
+ int N2 = global_connectivity[quad_index+1]-1;
+ int N3 = global_connectivity[quad_index+2]-1;
+ int N4 = global_connectivity[quad_index+3]-1;
+
+ double xarea;
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+ double x3 = coord[dim_space*N3];
+ double x4 = coord[dim_space*N4];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+ double y3 = coord[dim_space*N3+1];
+ double y4 = coord[dim_space*N4+1];
+
+ double z1 = coord[dim_space*N1+2];
+ double z2 = coord[dim_space*N2+2];
+ double z3 = coord[dim_space*N3+2];
+ double z4 = coord[dim_space*N4+2];
+
+ xnormal1 = (y2-y1)*(z4-z1) - (y4-y1)*(z2-z1);
+ xnormal2 = (x4-x1)*(z2-z1) - (x2-x1)*(z4-z1);
+ xnormal3 = (x2-x1)*(y4-y1) - (x4-x1)*(y2-y1);
+ xarea = sqrt(xnormal1*xnormal1 + xnormal2*xnormal2 +
+ xnormal3*xnormal3);
+
+ xnormal1 = xnormal1/xarea;
+ xnormal2 = xnormal2/xarea;
+ xnormal3 = xnormal3/xarea;
+
+ xarea = (sqrt(((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1))*
+ ((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1)) +
+ ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1))*
+ ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1)) +
+ ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))*
+ ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))) +
+ sqrt(((y3-y2)*(z4-z3) - (y4-y3)*(z3-z2))*
+ ((y3-y2)*(z4-z3) - (y4-y3)*(z3-z2)) +
+ ((x4-x3)*(z2-z2) - (x3-x2)*(z4-z3))*
+ ((x4-x3)*(z4-z2) - (x3-x2)*(z4-z3)) +
+ ((x3-x2)*(y4-y3) - (x4-x3)*(y3-y2))*
+ ((x3-x2)*(y4-y3) - (x4-x3)*(y3-y2))))/2.0;
+
+ xnormal1 = xnormal1*xarea;
+ xnormal2 = xnormal2*xarea;
+ xnormal3 = xnormal3*xarea;
+
+ normal[3*index] = xnormal1 ;
+ normal[3*index+1] = xnormal2 ;
+ normal[3*index+2] = xnormal3 ;
+
+ index++;
+ }
+ break;
+ }
+ case MED_SEG2 : case MED_SEG3 :
+ {
+ for (int edge=0;edge<nb_entity_type;edge++)
+ {
+ int edge_index = (type%100)*edge;
+
+ int N1 = global_connectivity[edge_index]-1;
+ int N2 = global_connectivity[edge_index+1]-1;
+
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+
+ xnormal1 = -(y2-y1);
+ xnormal2 = x2-x1;
+
+ normal[2*index] = xnormal1 ;
+ normal[2*index+1] = xnormal2 ;
+
+ index++;
+ }
+ break;
+ }
+ default :
+ throw MEDEXCEPTION("MESH::getNormal(SUPPORT*) Bad Support to get Normals on it !");
+ break;
+ }
+ }
+
+ Normal->setValue(MED_FULL_INTERLACE,normal);
+
+ return Normal;
+}
+
+FIELD<double>* MESH::getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION)
+{
+ MESSAGE("MESH::getBarycenter(SUPPORT*)");
+
+ // Make sure that the MESH class is the same as the MESH class attribut
+ // in the class Support
+ MESH* myMesh = Support->getMesh();
+ if (this != myMesh)
+ throw MEDEXCEPTION("MESH::getBarycenter(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
+
+ int dim_space = getSpaceDimension();
+ medEntityMesh support_entity = Support->getEntity();
+ bool onAll = Support->isOnAllElements();
+
+ int nb_type, length_values;
+ medGeometryElement* types;
+ int nb_entity_type;
+ // !!!! WARNING : use of nodal global numbering in the mesh !!!!
+ int* global_connectivity;
+
+ if (onAll)
+ {
+ nb_type = myMesh->getNumberOfTypes(support_entity);
+ length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+ types = getTypes(support_entity);
+ }
+ else
+ {
+ nb_type = Support->getNumberOfTypes();
+ length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
+ types = Support->getTypes();
+ }
+
+ int index;
+ FIELD<double>* Barycenter;
+
+ Barycenter = new FIELD<double>::FIELD(Support,dim_space);
+ Barycenter->setName("BARYCENTER");
+ Barycenter->setDescription("cells or faces barycenter");
+
+ for (int k=0;k<dim_space;k++) {
+ int kp1 = k + 1;
+ Barycenter->setComponentName(kp1,myMesh->getCoordinatesNames()[k]);
+ Barycenter->setComponentDescription(kp1,"desc-comp");
+ Barycenter->setMEDComponentUnit(kp1,myMesh->getCoordinatesUnits()[k]);
+ }
+
+ Barycenter->setValueType(MED_REEL64);
+
+ Barycenter->setIterationNumber(0);
+ Barycenter->setOrderNumber(0);
+ Barycenter->setTime(0.0);
+
+ double *barycenter = new double [dim_space*length_values];
+ // double *barycenter = Barycenter->getValue(MED_FULL_INTERLACE);
+
+ const double * coord = getCoordinates(MED_FULL_INTERLACE);
+ index = 0;
+
+ for (int i=0;i<nb_type;i++)
+ {
+ medGeometryElement type = types[i] ;
+ double xbarycenter1, xbarycenter2, xbarycenter3;
+
+ if (onAll)
+ {
+ nb_entity_type = getNumberOfElements(support_entity,type);
+ global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
+ }
+ else
+ {
+ nb_entity_type = Support->getNumberOfElements(type);
+
+ int * supp_number = Support->getNumber(type);
+ int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ global_connectivity = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+ }
+
+ switch (type)
+ {
+ case MED_TETRA4 : case MED_TETRA10 :
+ {
+ for (int tetra =0;tetra<nb_entity_type;tetra++)
+ {
+ int tetra_index = (type%100)*tetra;
+
+ int N1 = global_connectivity[tetra_index]-1;
+ int N2 = global_connectivity[tetra_index+1]-1;
+ int N3 = global_connectivity[tetra_index+2]-1;
+ int N4 = global_connectivity[tetra_index+3]-1;
+
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+ double x3 = coord[dim_space*N3];
+ double x4 = coord[dim_space*N4];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+ double y3 = coord[dim_space*N3+1];
+ double y4 = coord[dim_space*N4+1];
+
+ double z1 = coord[dim_space*N1+2];
+ double z2 = coord[dim_space*N2+2];
+ double z3 = coord[dim_space*N3+2];
+ double z4 = coord[dim_space*N4+2];
+
+ xbarycenter1 = (x1 + x2 + x3 + x4)/4.0;
+ xbarycenter2 = (y1 + y2 + y3 + y4)/4.0;
+ xbarycenter3 = (z1 + z2 + z3 + z4)/4.0;
+ barycenter[3*index] = xbarycenter1 ;
+ barycenter[3*index+1] = xbarycenter2 ;
+ barycenter[3*index+2] = xbarycenter3 ;
+ index++;
+ }
+ break;
+ }
+ case MED_PYRA5 : case MED_PYRA13 :
+ {
+ for (int pyra=0;pyra<nb_entity_type;pyra++)
+ {
+ int pyra_index = (type%100)*pyra;
+
+ int N1 = global_connectivity[pyra_index]-1;
+ int N2 = global_connectivity[pyra_index+1]-1;
+ int N3 = global_connectivity[pyra_index+2]-1;
+ int N4 = global_connectivity[pyra_index+3]-1;
+ int N5 = global_connectivity[pyra_index+4]-1;
+
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+ double x3 = coord[dim_space*N3];
+ double x4 = coord[dim_space*N4];
+ double x5 = coord[dim_space*N5];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+ double y3 = coord[dim_space*N3+1];
+ double y4 = coord[dim_space*N4+1];
+ double y5 = coord[dim_space*N5+1];
+
+ double z1 = coord[dim_space*N1+2];
+ double z2 = coord[dim_space*N2+2];
+ double z3 = coord[dim_space*N3+2];
+ double z4 = coord[dim_space*N4+2];
+ double z5 = coord[dim_space*N5+2];
+
+ xbarycenter1 = (x1 + x2 + x3 + x4 + x5)/5.0;
+ xbarycenter2 = (y1 + y2 + y3 + y4 + y5)/5.0;
+ xbarycenter3 = (z1 + z2 + z3 + z4 + z5)/5.0;
+ barycenter[3*index] = xbarycenter1 ;
+ barycenter[3*index+1] = xbarycenter2 ;
+ barycenter[3*index+2] = xbarycenter3 ;
+ index++;
+ }
+ break;
+ }
+ case MED_PENTA6 : case MED_PENTA15 :
+ {
+ for (int penta=0;penta<nb_entity_type;penta++)
+ {
+ int penta_index = (type%100)*penta;
+
+ int N1 = global_connectivity[penta_index]-1;
+ int N2 = global_connectivity[penta_index+1]-1;
+ int N3 = global_connectivity[penta_index+2]-1;
+ int N4 = global_connectivity[penta_index+3]-1;
+ int N5 = global_connectivity[penta_index+4]-1;
+ int N6 = global_connectivity[penta_index+5]-1;
+
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+ double x3 = coord[dim_space*N3];
+ double x4 = coord[dim_space*N4];
+ double x5 = coord[dim_space*N5];
+ double x6 = coord[dim_space*N6];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+ double y3 = coord[dim_space*N3+1];
+ double y4 = coord[dim_space*N4+1];
+ double y5 = coord[dim_space*N5+1];
+ double y6 = coord[dim_space*N6+1];
+
+ double z1 = coord[dim_space*N1+2];
+ double z2 = coord[dim_space*N2+2];
+ double z3 = coord[dim_space*N3+2];
+ double z4 = coord[dim_space*N4+2];
+ double z5 = coord[dim_space*N5+2];
+ double z6 = coord[dim_space*N6+2];
+
+ xbarycenter1 = (x1 + x2 + x3 + x4 + x5 + x6)/6.0;
+ xbarycenter2 = (y1 + y2 + y3 + y4 + y5 + y6)/6.0;
+ xbarycenter3 = (z1 + z2 + z3 + z4 + z5 + z6)/6.0;
+ barycenter[3*index] = xbarycenter1 ;
+ barycenter[3*index+1] = xbarycenter2 ;
+ barycenter[3*index+2] = xbarycenter3 ;
+ index++;
+ }
+ break;
+ }
+ case MED_HEXA8 : case MED_HEXA20 :
+ {
+ for (int hexa=0;hexa<nb_entity_type;hexa++)
+ {
+ int hexa_index = (type%100)*hexa;
+
+ int N1 = global_connectivity[hexa_index]-1;
+ int N2 = global_connectivity[hexa_index+1]-1;
+ int N3 = global_connectivity[hexa_index+2]-1;
+ int N4 = global_connectivity[hexa_index+3]-1;
+ int N5 = global_connectivity[hexa_index+4]-1;
+ int N6 = global_connectivity[hexa_index+5]-1;
+ int N7 = global_connectivity[hexa_index+6]-1;
+ int N8 = global_connectivity[hexa_index+7]-1;
+
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+ double x3 = coord[dim_space*N3];
+ double x4 = coord[dim_space*N4];
+ double x5 = coord[dim_space*N5];
+ double x6 = coord[dim_space*N6];
+ double x7 = coord[dim_space*N7];
+ double x8 = coord[dim_space*N8];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+ double y3 = coord[dim_space*N3+1];
+ double y4 = coord[dim_space*N4+1];
+ double y5 = coord[dim_space*N5+1];
+ double y6 = coord[dim_space*N6+1];
+ double y7 = coord[dim_space*N7+1];
+ double y8 = coord[dim_space*N8+1];
+
+ double z1 = coord[dim_space*N1+2];
+ double z2 = coord[dim_space*N2+2];
+ double z3 = coord[dim_space*N3+2];
+ double z4 = coord[dim_space*N4+2];
+ double z5 = coord[dim_space*N5+2];
+ double z6 = coord[dim_space*N6+2];
+ double z7 = coord[dim_space*N7+2];
+ double z8 = coord[dim_space*N8+2];
+
+ xbarycenter1 = (x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8)/8.0;
+ xbarycenter2 = (y1 + y2 + y3 + y4 + y5 + y6 + y7 + y8)/8.0;
+ xbarycenter3 = (z1 + z2 + z3 + z4 + z5 + z6 + z7 + z8)/8.0;
+
+ barycenter[3*index] = xbarycenter1 ;
+ barycenter[3*index+1] = xbarycenter2 ;
+ barycenter[3*index+2] = xbarycenter3 ;
+
+ index++;
+ }
+ break;
+ }
+ case MED_TRIA3 : case MED_TRIA6 :
+ {
+ for (int tria=0;tria<nb_entity_type;tria++)
+ {
+ int tria_index = (type%100)*tria;
+
+ int N1 = global_connectivity[tria_index]-1;
+ int N2 = global_connectivity[tria_index+1]-1;
+ int N3 = global_connectivity[tria_index+2]-1;
+
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+ double x3 = coord[dim_space*N3];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+ double y3 = coord[dim_space*N3+1];
+
+ xbarycenter1 = (x1 + x2 + x3)/3.0;
+ xbarycenter2 = (y1 + y2 + y3)/3.0;
+
+ if (dim_space==2)
+ {
+ barycenter[2*index] = xbarycenter1 ;
+ barycenter[2*index+1] = xbarycenter2 ;
+ }
+ else
+ {
+ double z1 =
+ coord[dim_space*N1+2];
+ double z2 =
+ coord[dim_space*N2+2];
+ double z3 =
+ coord[dim_space*N3+2];
+
+ xbarycenter3 = (z1 + z2 + z3)/3.0;
+
+ barycenter[3*index] = xbarycenter1 ;
+ barycenter[3*index+1] = xbarycenter2 ;
+ barycenter[3*index+2] = xbarycenter3 ;
+ }
+
+ index++;
+ }
+ break;
+ }
+ case MED_QUAD4 : case MED_QUAD8 :
+ {
+ for (int quad=0;quad<nb_entity_type;quad++)
+ {
+ int quad_index = (type%100)*quad;
+
+ int N1 = global_connectivity[quad_index]-1;
+ int N2 = global_connectivity[quad_index+1]-1;
+ int N3 = global_connectivity[quad_index+2]-1;
+ int N4 = global_connectivity[quad_index+3]-1;
+
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+ double x3 = coord[dim_space*N3];
+ double x4 = coord[dim_space*N4];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+ double y3 = coord[dim_space*N3+1];
+ double y4 = coord[dim_space*N4+1];
+
+ xbarycenter1 = (x1 + x2 + x3 + x4)/4.0;
+ xbarycenter2 = (y1 + y2 + y3 + y4)/4.0;
+
+ if (dim_space==2)
+ {
+ barycenter[2*index] = xbarycenter1 ;
+ barycenter[2*index+1] = xbarycenter2 ;
+ }
+ else
+ {
+ double z1 = coord[dim_space*N1+2];
+ double z2 = coord[dim_space*N2+2];
+ double z3 = coord[dim_space*N3+2];
+ double z4 = coord[dim_space*N4+2];
+
+ xbarycenter3 = (z1 + z2 + z3 + z4)/4.0;
+
+ barycenter[3*index] = xbarycenter1 ;
+ barycenter[3*index+1] = xbarycenter2 ;
+ barycenter[3*index+2] = xbarycenter3 ;
+ }
+ index++;
+ }
+ break;
+ }
+ case MED_SEG2 : case MED_SEG3 :
+ {
+ for (int edge=0;edge<nb_entity_type;edge++)
+ {
+ int edge_index = (type%100)*edge;
+
+ int N1 = global_connectivity[edge_index]-1;
+ int N2 = global_connectivity[edge_index+1]-1;
+
+ double x1 = coord[dim_space*N1];
+ double x2 = coord[dim_space*N2];
+
+ double y1 = coord[dim_space*N1+1];
+ double y2 = coord[dim_space*N2+1];
+
+ xbarycenter1 = (x1 + x2)/2.0;
+ xbarycenter2 = (y1 + y2)/2.0;
+
+ if (dim_space==2)
+ {
+ barycenter[2*index] = xbarycenter1 ;
+ barycenter[2*index+1] = xbarycenter2 ;
+ }
+ else
+ {
+ double z1 = coord[dim_space*N1+2];
+ double z2 = coord[dim_space*N2+2];
+
+ xbarycenter3 = (z1 + z2)/2.0;
+
+ barycenter[3*index] = xbarycenter1 ;
+ barycenter[3*index+1] = xbarycenter2 ;
+ barycenter[3*index+2] = xbarycenter3 ;
+ }
+ index++;
+ }
+ break;
+ }
+ default :
+ throw MEDEXCEPTION("MESH::getBarycenter(SUPPORT*) Bad Support to get a barycenter on it (in fact unknown type) !");
+ break;
+ }
+ }
+
+ Barycenter->setValue(MED_FULL_INTERLACE,barycenter);
+
+ return Barycenter;
+}
--- /dev/null
+#ifndef MESH_HXX
+#define MESH_HXX
+
+#include <string>
+#include <vector>
+
+#include "utilities.h"
+#include "MEDMEM_STRING.hxx"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+//#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Coordinate.hxx"
+#include "MEDMEM_Connectivity.hxx"
+
+#include "MEDMEM_MedMeshDriver.hxx"
+
+class CELLMODEL;
+class FAMILY;
+class GROUP;
+class SUPPORT;
+
+template <class T> class FIELD;
+
+//class GENDRIVER ;
+//class MED_MESH_RDONLY_DRIVER ;
+//class MED_MESH_WRONLY_DRIVER ;
+
+using namespace MED_EN;
+
+/*! This class contains all the informations related with a MESH :
+ - COORDINATES
+ - CONNECTIVITIES
+ - FAMILIES OF NODES
+ - FAMILIES OF CELLS
+ - FAMILIES OF FACES
+ - FAMILIES OF EDGES
+
+ NOTE: A Family is only on one type of entity (MED_CELL, MED_FACE, MED_EDGE, MED_NODE).
+ You can't have a family on MED_CELL and MED_FACE
+
+*/
+
+class MESH
+{
+
+
+public :
+
+ // ------- Drivers Management Part
+protected:
+
+ //-----------------------//
+ class INSTANCE
+ //-----------------------//
+ {
+ public:
+ virtual GENDRIVER * run(const string & fileName, MESH * ptrMesh) const = 0 ;
+ } ;
+
+ //-------------------------------------------------------//
+ template <class T> class INSTANCE_DE : public INSTANCE
+ //-------------------------------------------------------//
+ {
+ public :
+ GENDRIVER * run(const string & fileName, MESH * ptrMesh) const
+ { return new T(fileName,ptrMesh) ; }
+ } ;
+
+ static INSTANCE_DE<MED_MESH_RDWR_DRIVER> inst_med ;
+ //static INSTANCE_DE<VTK_DRIVER> inst_vtk ;
+ static const INSTANCE * const instances[] ;
+
+ // ------ End of Drivers Management Part
+
+
+ //-----------------------//
+ // Attributes
+ //-----------------------//
+
+protected :
+
+ string _name; // A POSITIONNER EN FCT DES IOS ?
+
+ int _numberOfMEDNodeFamily ; // INUTILE
+ int * _MEDArrayNodeFamily ; // SOLUTION TEMPORAIRE
+ int * _numberOfMEDCellFamily ; // INUTILE
+ int * _numberOfMEDFaceFamily ; // INUTILE
+ int * _numberOfMEDEdgeFamily ; // INUTILE
+ int ** _MEDArrayCellFamily ; // SOLUTION TEMPORAIRE
+ int ** _MEDArrayFaceFamily ; // SOLUTION TEMPORAIRE
+ int ** _MEDArrayEdgeFamily ; // SOLUTION TEMPORAIRE
+
+ COORDINATE * _coordinate;
+ CONNECTIVITY * _connectivity;
+
+ int _spaceDimension;
+ int _meshDimension ;
+ int _numberOfNodes ;
+
+ int _numberOfNodesFamilies; //INUTILE ? -> _familyNode.size()
+ vector<FAMILY*> _familyNode ; // array of size _numberOfNodesFamilies;
+ int _numberOfCellsFamilies;
+ vector<FAMILY*> _familyCell ; // array of size _numberOfCellsFamilies;
+ int _numberOfFacesFamilies;
+ vector<FAMILY*> _familyFace ; // array of size _numberOfFacesFamilies;
+ int _numberOfEdgesFamilies;
+ vector<FAMILY*> _familyEdge ; // array of size _numberOfEdgesFamilies;
+
+ int _numberOfNodesGroups; //INUTILE ?
+ vector<GROUP*> _groupNode; // array of size _numberOfNodesGroups;
+ int _numberOfCellsGroups; //INUTILE ?
+ vector<GROUP*> _groupCell; // array of size _numberOfCellsGroups;
+ int _numberOfFacesGroups; //INUTILE ?
+ vector<GROUP*> _groupFace; // array of size _numberOfFacesGroups;
+ int _numberOfEdgesGroups; //INUTILE ?
+ vector<GROUP*> _groupEdge; // array of size _numberOfEdgesGroups;
+ // list of all Group
+
+ vector<GENDRIVER *> _drivers; // Storage of the drivers currently in use
+
+ //-----------------------//
+ // Methods
+ //-----------------------//
+
+public :
+
+ friend class MED_MESH_RDONLY_DRIVER;
+ friend class MED_MESH_WRONLY_DRIVER;
+
+ void init();
+ MESH();
+ MESH(const MESH &m);
+ MESH & operator=(const MESH &m);
+ MESH( driverTypes driverType, const string & fileName="",
+ const string & meshName="");
+ ~MESH();
+ friend ostream & operator<<(ostream &os, MESH &my) ;
+
+ int addDriver(driverTypes driverType,
+ const string & fileName ="Default File Name.med",
+ const string & driverName="Default Mesh Name");
+ int addDriver(GENDRIVER & driver);
+ void rmDriver(int index=0);
+
+ inline void read(int index=0);
+ inline void write(int index=0, const string & driverName = "");
+ inline void write(const GENDRIVER &);
+
+ inline int * getMEDArrayNodeFamily() ;
+ inline int ** getMEDArrayCellFamily() ;
+ inline int ** getMEDArrayFaceFamily() ;
+ inline int ** getMEDArrayEdgeFamily() ;
+
+ // void calculateReverseConnectivity();
+ // void createFaces(); //Faces creation => full constituent informations
+ // void buildConstituent() ; // calculate descendent connectivity + face-cell connectivity
+
+
+ inline void setName(string name);
+
+ inline string getName() const;
+ inline int getSpaceDimension();
+ inline int getMeshDimension();
+
+ inline int getNumberOfNodes();
+ inline COORDINATE * getCoordinateptr();
+ inline string getCoordinatesSystem();
+ inline const double * getCoordinates(medModeSwitch Mode);
+ inline const double getCoordinate(int Number,int Axis);
+ inline string * getCoordinatesNames();
+ inline string * getCoordinatesUnits();
+ // inline int * getNodesNumbers();
+
+ inline int getNumberOfTypes(medEntityMesh Entity);
+ inline medGeometryElement * getTypes(medEntityMesh Entity);
+ inline CELLMODEL * getCellsTypes(medEntityMesh Entity);
+ inline int * getGlobalNumberingIndex(medEntityMesh Entity);
+ inline int getNumberOfElements(medEntityMesh Entity,medGeometryElement Type);
+ inline bool existConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity);
+ inline medGeometryElement getElementType(medEntityMesh Entity,int Number) ;
+ inline void calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity);
+ inline int * getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity, medGeometryElement Type);
+ inline int * getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity);
+ int getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity) ;
+ inline int * getReverseConnectivity(medConnectivity ConnectivityType);
+ inline int * getReverseConnectivityIndex(medConnectivity ConnectivityType);
+
+ inline int getNumberOfFamilies(medEntityMesh Entity);
+ inline vector<FAMILY*> getFamilies(medEntityMesh Entity);
+ inline FAMILY* getFamily(medEntityMesh Entity,int i);
+ inline int getNumberOfGroups(medEntityMesh Entity);
+ inline vector<GROUP*> getGroups(medEntityMesh Entity);
+ inline GROUP* getGroup(medEntityMesh Entity,int i);
+
+
+ SUPPORT * getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION) ;
+
+ // Node DonneBarycentre(const Cell &m) const;
+ FIELD<double>* getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 3D elements
+ FIELD<double>* getArea(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 2D elements
+ FIELD<double>* getLength(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 1D elements
+ FIELD<double>* getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 2D elements
+ FIELD<double>* getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION) ;
+ // FIELD<int>* getNeighbourhood(SUPPORT * Support) throw (MEDEXCEPTION) ; // Il faut preciser !
+};
+
+// ---------------------------------------
+// Methodes Inline
+// ---------------------------------------
+
+inline void MESH::read(int index=0)
+{
+ const char * LOC = "MESH::read(int index=0) : ";
+ BEGIN_OF(LOC);
+
+ if (_drivers[index]) {
+ _drivers[index]->open();
+ _drivers[index]->read();
+ _drivers[index]->close();
+ }
+ else
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
+ )
+ );
+ END_OF(LOC);
+}
+
+/*! Write all the content of the MESH using driver referenced by the handler <index>*/
+inline void MESH::write(int index=0, const string & driverName = "")
+{
+ const char * LOC = "MESH::write(int index=0, const string & driverName = \"\") : ";
+ BEGIN_OF(LOC);
+
+ if ( _drivers[index] ) {
+ _drivers[index]->open();
+ if (driverName != "") _drivers[index]->setMeshName(driverName);
+ _drivers[index]->write();
+ _drivers[index]->close();
+ }
+ else
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
+ )
+ );
+ END_OF(LOC);
+}
+
+// This method is MED specific : don't use it
+// must be private.
+inline void MESH::write(const GENDRIVER & genDriver)
+{
+ const char * LOC = "MESH::write(const GENDRIVER & genDriver): ";
+ BEGIN_OF(LOC);
+
+ for (int index=0; index < _drivers.size(); index++ )
+ if ( *_drivers[index] == genDriver ) {
+ _drivers[index]->open();
+ _drivers[index]->write();
+ _drivers[index]->close();
+ // ? FINALEMENT PAS BESOIN DE L'EXCEPTION ?
+ }
+
+ END_OF(LOC);
+
+}
+
+/*! Set the MESH name */
+inline void MESH::setName(string name)
+{
+ _name=name ; //NOM interne à la classe
+}
+
+/*! Get the MESH name */
+inline string MESH::getName() const
+{
+ return _name ;
+}
+
+/*! Get the dimension of the space */
+inline int MESH::getSpaceDimension()
+{
+ return _spaceDimension;
+}
+
+/*! Get the dimension of the MESH */
+inline int MESH::getMeshDimension()
+{
+ return _meshDimension;
+}
+
+/*! Get the number of nodes used in the MESH */
+inline int MESH::getNumberOfNodes()
+{
+ return _numberOfNodes;
+}
+
+/*! Get the COORDINATES object. Use it only if you need COORDINATES informations not provided by the MESH class.*/
+inline COORDINATE * MESH::getCoordinateptr()
+{
+ return _coordinate;
+}
+
+/*! Get the system in which coordinates are given (CARTESIAN,CYLINDRICAL,SPHERICAL) __??MED_CART??__. */
+inline string MESH::getCoordinatesSystem()
+{
+ return _coordinate->getCoordinatesSystem();
+}
+
+/*! Get the whole coordinates array in a given interlacing mode. The interlacing mode are :
+ - MED_NO_INTERLACE : X1 X2 Y1 Y2 Z1 Z2
+ - MED_FULL_INTERLACE : X1 Y1 Z1 X2 Y2 Z2
+ */
+inline const double * MESH::getCoordinates(medModeSwitch Mode)
+{
+ return _coordinate->getCoordinates(Mode);
+}
+
+/*! Get the coordinate n° number on axis n°axis*/
+inline const double MESH::getCoordinate(int number, int axis)
+{
+ return _coordinate->getCoordinate(number,axis);
+}
+
+/*! Get the coordinate names array ("x ","y ","z ")
+ of size n*MED_TAILLE_PNOM
+*/
+inline string * MESH::getCoordinatesNames()
+{
+ return _coordinate->getCoordinatesNames();
+}
+
+/*! Get the coordinate unit names array ("cm ","cm ","cm ")
+ of size n*MED_TAILLE_PNOM
+*/
+inline string * MESH::getCoordinatesUnits()
+{
+ return _coordinate->getCoordinatesUnits();
+}
+// int * MESH::getNodesNumbers() {
+// return nodesNumbers;
+// }
+
+/*! Get the number of different geometric types for a given entity type.
+ For exemple getNumberOfTypes(MED_CELL) would return 2 is the MESH have some MED_TETRA4 and MED_HEXA6 in it.
+ medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_NODE, MED_ALL_ENTITIES
+*/
+inline int MESH::getNumberOfTypes(medEntityMesh entity)
+{
+ MESSAGE("MESH::getNumberOfTypes(medEntityMesh entity) : "<<entity);
+ if (entity == MED_NODE)
+ return 1 ;
+ if (_connectivity != NULL)
+ return _connectivity->getNumberOfTypes(entity) ;
+ throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !"));
+}
+
+/*!
+ Get the list of geometric types used by a given entity.
+ medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_ALL_ENTITIES
+ REM : Don't use MED_NODE
+*/
+inline medGeometryElement * MESH::getTypes(medEntityMesh entity)
+{
+ if (entity == MED_NODE)
+ throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : No medGeometryElement with MED_NODE entity !"));
+
+ if (_connectivity != NULL)
+ return _connectivity->getGeometricTypes(entity) ;
+ throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : Connectivity not defined !"));
+}
+
+/*!
+ Get the whole list of CELLMODEL used by cells of given type (medEntityMesh).
+ REMARK : Don't use MED_NODE as medEntityMesh
+*/
+inline CELLMODEL * MESH::getCellsTypes(medEntityMesh Entity)
+{
+ if (_connectivity != NULL)
+ return _connectivity->getCellsTypes(Entity) ;
+ throw MEDEXCEPTION(LOCALIZED("MESH::getCellsTypes( medEntityMesh ) : Connectivity not defined !"));
+}
+
+/*! Since informations related with an entity type are stored in independent arrays, the only way to
+ get a uniq index is to call this method.
+ For exemple if you want the global numbers of your ... ????? size ?????
+*/
+inline int * MESH::getGlobalNumberingIndex(medEntityMesh entity)
+{
+ if (_connectivity != NULL)
+ return _connectivity->getGlobalNumberingIndex(entity);
+ throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !"));
+}
+inline int MESH::getNumberOfElements(medEntityMesh entity, medGeometryElement Type)
+{
+ const char * LOC = "MESH::getNumberOfElements(medEntityMesh,medGeometryElement) : " ;
+ if (entity==MED_NODE)
+ if ((Type==MED_NONE)|(Type==MED_ALL_ELEMENTS))
+ return _numberOfNodes ;
+ else
+ return 0 ;
+ //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"wrong medGeometryElement with MED_NODE"));
+ else
+ if (_connectivity != (CONNECTIVITY*)NULL)
+ return _connectivity->getNumberOf(entity,Type) ;
+ else
+ return 0 ;
+ //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"connectivity not defined !"));
+}
+inline bool MESH::existConnectivity(medConnectivity connectivityType, medEntityMesh entity)
+{
+ if (_connectivity==(CONNECTIVITY*)NULL)
+ throw MEDEXCEPTION("MESH::existConnectivity(medConnectivity,medEntityMesh) : no connectivity defined !");
+ return _connectivity->existConnectivity(connectivityType,entity) ;
+}
+/*!
+ Return the geometric type of element Number of entity Entity.
+
+ Throw an exception if Entity is not defined or Number are wrong (too big).
+ */
+inline medGeometryElement MESH::getElementType(medEntityMesh Entity,int Number)
+{
+ if (_connectivity==(CONNECTIVITY*)NULL)
+ throw MEDEXCEPTION("MESH::getElementType(medEntityMesh,int) : no connectivity defined !");
+ return _connectivity->getElementType(Entity,Number) ;
+}
+inline void MESH::calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity)
+{
+ if (Mode==MED_FULL_INTERLACE)
+ _connectivity->calculateConnectivity(ConnectivityType,entity) ;
+ else
+ throw MEDEXCEPTION(LOCALIZED("MESH::calculateConnectivity : only for MED_FULL_INTERLACE mode"));
+}
+inline int * MESH::getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity, medGeometryElement Type)
+{
+ if (Mode==MED_FULL_INTERLACE)
+ return _connectivity->getConnectivity(ConnectivityType,entity,Type) ;
+ throw MEDEXCEPTION(LOCALIZED("MESH::getConnectivity : only for MED_FULL_INTERLACE mode"));
+}
+inline int * MESH::getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh entity)
+{
+ return _connectivity->getConnectivityIndex(ConnectivityType, entity) ;
+}
+inline int * MESH::getReverseConnectivity(medConnectivity ConnectivityType)
+{
+ if (ConnectivityType==MED_NODAL)
+ return _connectivity->getReverseNodalConnectivity() ;
+ else if (ConnectivityType==MED_DESCENDING)
+ return _connectivity->getReverseDescendingConnectivity() ;
+ throw MEDEXCEPTION("MESH::getReverseConnectivity : connectivity mode not supported !");
+}
+inline int * MESH::getReverseConnectivityIndex(medConnectivity ConnectivityType)
+{
+ if (ConnectivityType==MED_NODAL)
+ return _connectivity->getReverseNodalConnectivityIndex() ;
+ else if (ConnectivityType==MED_DESCENDING)
+ return _connectivity->getReverseDescendingConnectivityIndex() ;
+ throw MEDEXCEPTION("MESH::getReverseConnectivityIndex : connectivity mode not supported !");
+}
+
+
+inline int MESH::getNumberOfFamilies (medEntityMesh entity)
+{
+ switch (entity) {
+ case MED_NODE :
+ return _numberOfNodesFamilies ;
+ case MED_CELL :
+ return _numberOfCellsFamilies ;
+ case MED_FACE :
+ return _numberOfFacesFamilies ;
+ case MED_EDGE :
+ return _numberOfEdgesFamilies ;
+ default :
+ throw MEDEXCEPTION("MESH::getNumberOfFamilies : Unknown entity");
+ }
+}
+inline int MESH::getNumberOfGroups (medEntityMesh entity)
+{
+ switch (entity) {
+ case MED_NODE :
+ return _numberOfNodesGroups ;
+ case MED_CELL :
+ return _numberOfCellsGroups ;
+ case MED_FACE :
+ return _numberOfFacesGroups ;
+ case MED_EDGE :
+ return _numberOfEdgesGroups ;
+ default :
+ throw MEDEXCEPTION("MESH::getNumberOfGroups : Unknown entity");
+ }
+}
+vector<FAMILY*> MESH::getFamilies(medEntityMesh entity) {
+ switch (entity) {
+ case MED_NODE :
+ return _familyNode ;
+ case MED_CELL :
+ return _familyCell ;
+ case MED_FACE :
+ return _familyFace ;
+ case MED_EDGE :
+ return _familyEdge ;
+ default :
+ throw MEDEXCEPTION("MESH::getFamilies : Unknown entity");
+ }
+}
+
+vector<GROUP*> MESH::getGroups(medEntityMesh entity) {
+ switch (entity) {
+ case MED_NODE :
+ return _groupNode ;
+ case MED_CELL :
+ return _groupCell ;
+ case MED_FACE :
+ return _groupFace ;
+ case MED_EDGE :
+ return _groupEdge ;
+ default :
+ throw MEDEXCEPTION("MESH::getGroups : Unknown entity");
+ }
+}
+
+FAMILY* MESH::getFamily(medEntityMesh entity, int i) {
+ if (i<=0)
+ throw MEDEXCEPTION("MESH::getFamily(i) : argument i must be > 0");
+ int NumberOfFamilies = 0 ;
+ vector<FAMILY*> Family ;
+ switch (entity) {
+ case MED_NODE : {
+ NumberOfFamilies = _numberOfNodesFamilies ;
+ Family = _familyNode ;
+ break ;
+ }
+ case MED_CELL : {
+ NumberOfFamilies = _numberOfCellsFamilies ;
+ Family = _familyCell ;
+ break ;
+ }
+ case MED_FACE : {
+ NumberOfFamilies = _numberOfFacesFamilies ;
+ Family = _familyFace ;
+ break ;
+ }
+ case MED_EDGE : {
+ NumberOfFamilies = _numberOfEdgesFamilies ;
+ Family = _familyEdge ;
+ break ;
+ }
+ default :
+ throw MEDEXCEPTION("MESH::getFamilies : Unknown entity");
+ }
+ if (i>NumberOfFamilies)
+ throw MEDEXCEPTION("MESH::getFamily(entity,i) : argument i must be <= _numberOfFamilies");
+ return Family[i-1];
+}
+
+GROUP* MESH::getGroup(medEntityMesh entity, int i) {
+ const char * LOC = "MESH::getGroup(medEntityMesh entity, int i) : " ;
+ if (i<=0)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"argument i must be > 0"));
+ int NumberOfGroups = 0 ;
+ vector<GROUP*> Group ;
+ switch (entity) {
+ case MED_NODE : {
+ NumberOfGroups = _numberOfNodesGroups ;
+ Group = _groupNode ;
+ break ;
+ }
+ case MED_CELL : {
+ NumberOfGroups = _numberOfCellsGroups ;
+ Group = _groupCell ;
+ break ;
+ }
+ case MED_FACE : {
+ NumberOfGroups = _numberOfFacesGroups ;
+ Group = _groupFace ;
+ break ;
+ }
+ case MED_EDGE : {
+ NumberOfGroups = _numberOfEdgesGroups ;
+ Group = _groupEdge ;
+ break ;
+ }
+ default :
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Unknown entity"));
+ }
+ if (i>NumberOfGroups)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"argument i="<<i<<" must be <= _numberOfGroups="<<NumberOfGroups));
+ return Group[i-1];
+}
+
+
+// int * get_() {
+// return ;
+// }
+
+//inline void MESH::write(const string & driverName) {
+// write(0,driverName);
+//}
+
+
+// this method are temporary, perhaps we remove it if we put information in an other place
+inline int * MESH::getMEDArrayNodeFamily() {
+ return _MEDArrayNodeFamily ;
+}
+inline int ** MESH::getMEDArrayCellFamily() {
+ return _MEDArrayCellFamily ;
+}
+inline int ** MESH::getMEDArrayFaceFamily() {
+ return _MEDArrayFaceFamily ;
+}
+inline int ** MESH::getMEDArrayEdgeFamily() {
+ return _MEDArrayEdgeFamily ;
+}
+
+#endif /* MESH_HXX */
--- /dev/null
+#ifndef __MEDMODULUSARRAY_H__
+#define __MEDMODULUSARRAY_H__
+
+#include "utilities.h"
+
+/*
+ This class is use to set cyclic (modulus length) array.
+ (array[length+1]==array[1])
+
+ We use it in particular to compare faces nodes lists to know if
+ they are the same (positive or negative cycle) !
+*/
+
+
+class MEDMODULUSARRAY {
+private:
+ int _length ;
+ int * _array ;
+
+public:
+ MEDMODULUSARRAY(int length, int * array) ;
+ ~MEDMODULUSARRAY() ;
+
+ int & operator[](const int &i) const ;
+
+ int compare(const MEDMODULUSARRAY &modulusArray) const;
+
+};
+
+MEDMODULUSARRAY::MEDMODULUSARRAY(int length, int * array) :
+ _length(length), _array(array)
+{
+ // MESSAGE("MEDMODULUSARRAY::MEDMODULUSARRAY("<<length<<", "<<array<<")") ;
+};
+
+MEDMODULUSARRAY::~MEDMODULUSARRAY()
+{
+ // do nothing because nothing is allocated !
+ // MESSAGE("MEDMODULUSARRAY::~MEDMODULUSARRAY()") ;
+};
+
+
+int & MEDMODULUSARRAY::operator[](const int &i) const
+{
+ int position = i%_length ;
+ if (position<0)
+ position+=_length ;
+ return _array[position] ;
+};
+
+int MEDMODULUSARRAY::compare(const MEDMODULUSARRAY &modulusArray) const
+{
+ int ret = 0 ;
+
+ if (modulusArray._length != _length)
+ return ret ;
+
+ if (_length==1)
+ if (_array[0]==modulusArray[0])
+ return 1;
+ else
+ return 0;
+
+ if (_length==2)
+ if ((_array[0]==modulusArray[0])&(_array[1]==modulusArray[1]))
+ return 1;
+ else if ((_array[0]==modulusArray[1])&(_array[1]==modulusArray[0]))
+ return -1;
+ else
+ return 0;
+
+ //search if there is one start point in common in two array
+ for(int i=0;i<_length;i++)
+ if ( _array[0] == modulusArray[i] ) {
+ // we search if cycle is the same
+ if (_array[1]==modulusArray[i+1]){ // positive order
+ ret=1;
+ for(int j=2;j<_length;j++)
+ if (_array[j]!=modulusArray[i+j]) {
+ ret = 0 ;
+ break ;
+ }
+ } else if(_array[1]==modulusArray[i-1]) { //negative order
+ ret=-1;
+ for(int j=2;j<_length;j++)
+ if (_array[j]!=modulusArray[i-j]) {
+ ret = 0 ;
+ break ;
+ }
+ }
+ if (ret!=0) {// we have found it !
+ break ;
+ }
+ // else we continue if there is another start point i
+ }
+ return ret ;
+}
+
+# endif /* # ifndef __MEDMODULUSARRAY_H__ */
+
--- /dev/null
+# ifndef STRING_HXX
+# define STRING_HXX
+
+# include <string>
+# include <sstream>
+
+using namespace std;
+
+class STRING : public string
+{
+private :
+ ostringstream _s ;
+public :
+ operator const char*() const
+ {
+ return _s.str().c_str() ;
+ }
+ STRING() : _s()
+ {
+ }
+ template <class T> STRING( const T &valeur ) : _s()
+ {
+ _s << valeur ;
+ }
+ template <class T> STRING &operator<<( const T &valeur )
+ {
+ _s << valeur ;
+ return *this ;
+ }
+} ;
+
+// Exemple d'utilisation avec les exceptions SALOME
+// STRING msgErr;
+// msgErr << "ESSAI::ESSAI() : This Object cannot be instanciated by now ! Try "<< 11 << "times just to see what happens ";
+// throw SALOME_EXCEPTION (LOCALIZED(msgErr)) ;
+
+# endif
--- /dev/null
+#include "MEDMEM_SkyLineArray.hxx"
+#include "utilities.h"
+
+MEDSKYLINEARRAY::MEDSKYLINEARRAY(): _count(0), _length(0),
+ _index((med_int*)NULL),_value((med_int*)NULL)
+{
+ MESSAGE("Constructeur MEDSKYLINEARRAY sans parametre");
+}
+
+MEDSKYLINEARRAY::MEDSKYLINEARRAY(const MEDSKYLINEARRAY &myArray)
+{
+ MESSAGE("MEDSKYLINEARRAY(const MEDSKYLINEARRAY &)");
+ _count = myArray._count ;
+ _length = myArray._length ;
+ _index = new med_int[_count+1] ;
+ _value = new med_int[_length] ;
+ memcpy(_index,myArray._index,sizeof(med_int)*(_count+1));
+ memcpy(_value,myArray._value,sizeof(med_int)*_length);
+}
+
+MEDSKYLINEARRAY::~MEDSKYLINEARRAY()
+{
+ MESSAGE("Destructeur ~MEDSKYLINEARRAY");
+
+ if (_index != NULL) delete [] _index;
+ if (_value != NULL) delete [] _value;
+}
+
+MEDSKYLINEARRAY::MEDSKYLINEARRAY(const med_int count , const med_int length ) :
+ _count(count), _length(length)
+{
+ MESSAGE("Constructeur MEDSKYLINEARRAY(count="<<count<<", length="<<length<<") avec parametres");
+
+ _index = new med_int[count+1] ;
+ _value = new med_int[length] ;
+}
+
+void MEDSKYLINEARRAY::setMEDSKYLINEARRAY( const med_int count , const med_int length, med_int* index , med_int* value )
+{
+ MESSAGE("void MEDSKYLINEARRAY::setMEDSKYLINEARRAY(count, length, index, value)");
+ _count = count ;
+ _length = length ;
+
+ if (_index != NULL) delete [] _index;
+ if (_value != NULL) delete [] _value;
+
+ _index = index;
+ _value = value;
+}
--- /dev/null
+# ifndef __MEDSKYLINEARRAY_H__
+# define __MEDSKYLINEARRAY_H__
+
+#include "MEDMEM_Exception.hxx"
+
+#include "MEDMEM_define.hxx"
+
+using MED_EN::med_int ;
+
+class MEDSKYLINEARRAY
+{
+private :
+ med_int _count ;
+ med_int _length ;
+ med_int * _index ; // array of size _count+1 : _index[0]=1 and
+ // _index[_count]=length+1
+ med_int * _value ; // array of size _length
+
+public :
+ MEDSKYLINEARRAY();
+ ~MEDSKYLINEARRAY();
+ MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray );
+ MEDSKYLINEARRAY( const med_int count , const med_int length );
+
+ void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ;
+
+ inline med_int getNumberOf() const;
+ inline med_int getLength() const;
+ inline med_int* getIndex() const;
+ inline med_int* getValue() const;
+ inline med_int getNumberOfI(int i) const throw (MEDEXCEPTION) ;
+ inline med_int* getI(int i) const throw (MEDEXCEPTION) ;
+ inline med_int getIJ(int i, int j) const throw (MEDEXCEPTION) ;
+
+} ;
+
+// ---------------------------------------
+// Methodes Inline
+// ---------------------------------------
+inline med_int MEDSKYLINEARRAY::getNumberOf() const
+{
+ return _count ;
+};
+inline med_int MEDSKYLINEARRAY::getLength() const
+{
+ return _length ;
+};
+inline med_int* MEDSKYLINEARRAY::getIndex() const
+{
+ return _index ;
+} ;
+inline med_int* MEDSKYLINEARRAY::getValue() const
+{
+ return _value ;
+} ;
+inline med_int MEDSKYLINEARRAY::getNumberOfI(int i) const throw (MEDEXCEPTION)
+{
+ if (i<1)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::getNumberOfI : argument must be >= 1");
+ if (i>_count)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::getNumberOfI : argument is out of range");
+ return _index[i]-_index[i-1] ;
+} ;
+inline med_int* MEDSKYLINEARRAY::getI(int i) const throw (MEDEXCEPTION)
+{
+ if (i<1)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument must be >= 1");
+ if (i>_count)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument is out of range");
+ return _value+_index[i-1]-1 ;
+}
+inline med_int MEDSKYLINEARRAY::getIJ(int i, int j) const throw (MEDEXCEPTION)
+{
+ if (i<1)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : first argument must be >= 1");
+ if (j<1)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : second argument must be >= 1");
+ if (i>_count)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : first argument is out of range") ;
+ if (j>_index[i])
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : second argument is out of range") ;
+ return _value[_index[i-1]+j-2] ;
+}
+
+
+# endif
--- /dev/null
+/*
+ File Support.cxx
+ $Header$
+*/
+
+#include <set>
+#include <list>
+
+#include "utilities.h"
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_DriversDef.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Group.hxx"
+#include "MEDMEM_Mesh.hxx"
+
+using namespace MED_EN;
+
+/* This class is a generic class for family and group */
+//--------------------------------------------------------------------------
+SUPPORT::SUPPORT(): _name(""), _description(""), _mesh((MESH*)NULL),
+ _entity(MED_CELL), _numberOfGeometricType(0),
+ _geometricType((medGeometryElement*)NULL),
+ _numberOfGaussPoint((int*)NULL),
+ _geometricTypeNumber((int*)NULL), _isOnAllElts(false),
+ _numberOfEntities((int*)NULL), _totalNumberOfEntities(0),
+ _number((MEDSKYLINEARRAY*)NULL)
+//--------------------------------------------------------------------------
+{
+ MESSAGE("Constructeur SUPPORT sans parametre");
+};
+
+//--------------------------------------------------------------------------
+SUPPORT::SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL):
+ _name(Name), _description(""), _mesh(Mesh), _entity(Entity),
+ _numberOfGeometricType(0),
+ _geometricType((medGeometryElement*)NULL),
+ _numberOfGaussPoint((int*)NULL),
+ _geometricTypeNumber((int*)NULL),
+ _isOnAllElts(true), _numberOfEntities((int*)NULL),
+ _totalNumberOfEntities(0),
+ _number((MEDSKYLINEARRAY*)NULL)
+//--------------------------------------------------------------------------
+{
+ MESSAGE("Constructeur SUPPORT avec parametres MESH* Mesh,string name,medEntityMesh Entity");
+ if ( Entity == MED_NODE) {
+ _numberOfGeometricType=1 ;
+ _geometricType=new medGeometryElement[1] ;
+ _geometricType[0]=MED_NONE ;
+ }
+};
+
+//-----------------
+SUPPORT::~SUPPORT()
+//-----------------
+{
+ MESSAGE("Destructeur ~SUPPORT()");
+ if (_geometricType!=NULL)
+ delete[] _geometricType ;
+ if (_numberOfGaussPoint!=NULL)
+ delete[] _numberOfGaussPoint ;
+ if (_geometricTypeNumber!=NULL)
+ delete[] _geometricTypeNumber ;
+ if (_numberOfEntities!=NULL)
+ delete[] _numberOfEntities ;
+ if (_number!=NULL)
+ delete _number ;
+}
+
+//--------------------------------------------------
+ostream & operator<<(ostream &os, const SUPPORT &my)
+//--------------------------------------------------
+{
+ os << "Name : "<<my._name<< endl ;
+ os << "Description : "<< my._description << endl ;
+ os << "Mesh name : ";
+ if (my._mesh==NULL)
+ os << "ERROR : Mesh not defined !" << endl ;
+ else
+ os << my._mesh->getName() << endl ;
+ return os ;
+}
+
+/*! A DOCUMENTER */
+//-------------------
+void SUPPORT::update()
+//-------------------
+{
+ const char * LOC = "SUPPORT::update() : " ;
+ BEGIN_OF(LOC) ;
+
+ if (_isOnAllElts)
+ if (_numberOfGaussPoint==NULL) {
+ MESSAGE( "ENTITY : "<< _entity );
+ int NumberOfTypes = _mesh->getNumberOfTypes(_entity) ;
+ MESSAGE( "NumberOfTypes : "<< NumberOfTypes );
+ _numberOfGaussPoint = new int[NumberOfTypes] ;
+ for (int i=0;i<NumberOfTypes;i++)
+ _numberOfGaussPoint[i]=1 ;
+ }
+ if (_entity == MED_NODE)
+ _totalNumberOfEntities = _mesh->getNumberOfNodes();
+
+ END_OF(LOC);
+};
+
+/*! A DOCUMENTER */
+//-------------------
+void SUPPORT::blending(SUPPORT * mySupport)
+//-------------------
+{
+ const char * LOC = "SUPPORT::blending() : " ;
+ BEGIN_OF(LOC) ;
+
+ // on same entity :
+ if ( _entity != mySupport->getEntity() )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Entities are different !"));
+
+ int * tmp_NumberOfElementsInType = new int[MED_NBR_GEOMETRIE_MAILLE];
+ medGeometryElement * myType = new medGeometryElement[MED_NBR_GEOMETRIE_MAILLE];
+ int * whereIsType = new int[MED_NBR_GEOMETRIE_MAILLE];
+ //MESH_ENTITIES myMeshEntities() ;
+ list<MED_FR::med_geometrie_element>::const_iterator listIt ;
+ int it=0 ;
+ for(listIt=(MED_FR::meshEntities[(MED_FR::med_entite_maillage)_entity]).begin();listIt!=(MED_FR::meshEntities[(MED_FR::med_entite_maillage)_entity]).end();listIt++){
+ tmp_NumberOfElementsInType[it]=0;
+ whereIsType[it]=0 ;
+ try {
+ tmp_NumberOfElementsInType[it]+=getNumberOfElements((medGeometryElement)(*listIt)) ;
+ whereIsType[it]+=1 ;
+ }
+ catch (const MEDEXCEPTION & ex) {};
+ try {
+ tmp_NumberOfElementsInType[it]+=mySupport->getNumberOfElements((medGeometryElement)(*listIt)) ;
+ whereIsType[it]+=2 ;
+ }
+ catch (const MEDEXCEPTION & ex) {};
+ if (whereIsType[it]!=0) {
+ myType[it]=(medGeometryElement)(*listIt) ;
+ it++;
+ }
+ }
+ // set new value :
+ int * numberOfEntities=_numberOfEntities ;
+ _numberOfEntities = new int[it] ;
+ _totalNumberOfEntities = 0 ;
+ // int totalSize = 0 ;
+ int ** tmp_array = new (int*)[it];
+ for (int i=0;i<it;i++) {
+ int numberOfElementsInType = tmp_NumberOfElementsInType[i] ;
+ _numberOfEntities[i] = numberOfElementsInType ;
+ tmp_array[i] = new int[numberOfElementsInType] ;
+ //totalSize+=numberOfElementsInType*(myType[i]%100) ;
+ _totalNumberOfEntities+=numberOfElementsInType ;
+ if (whereIsType[i] == 1) { // only first Support
+ memcpy(tmp_array[i],getNumber(myType[i]),sizeof(int)*numberOfElementsInType);
+ } else if (whereIsType[i] == 2) { // only second Support
+ memcpy(tmp_array[i],mySupport->getNumber(myType[i]),sizeof(int)*numberOfElementsInType);
+ } else if (whereIsType[i] == 3) { // more difficult :-)
+ set<int> elementList ;
+ int i1 = 0 ;
+ int i2 = 0 ;
+ int ii = 0 ;
+ int * number1 = getNumber(myType[i]) ;
+ int * number2 = mySupport->getNumber(myType[i]) ;
+
+ int numberOfElements1 = numberOfEntities[i] ;
+ int numberOfElements2 = mySupport->getNumberOfElements(myType[i]) ;
+
+ for(int j=0;j<numberOfElements1;j++){
+ elementList.insert(number1[j]) ;
+ }
+
+ for(int j=0;j<numberOfElements2;j++){
+ elementList.insert(number2[j]) ;
+ }
+
+ //create the array !
+ int newNumberOfEntities = elementList.size() ;
+ _numberOfEntities[i] = newNumberOfEntities ;
+ int * tmp_arrayNew = new int[newNumberOfEntities];
+
+ set<int>::iterator its ;
+ for(its=elementList.begin();its!=elementList.end(); its++) {
+ tmp_arrayNew[ii]=*its ;
+ ii++;
+ }
+
+ delete[] tmp_array[i] ;
+ tmp_array[i] = tmp_arrayNew ;
+ _totalNumberOfEntities-=(numberOfElementsInType-newNumberOfEntities) ;
+
+ } else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"ERROR")) ;
+ }
+ delete[] whereIsType ;
+ delete[] tmp_NumberOfElementsInType ;
+
+ _numberOfGeometricType = it ;
+ medGeometryElement * geometricType=_geometricType ;
+ _geometricType = new medGeometryElement[it] ;
+ int * numberOfGaussPoint=_numberOfGaussPoint ;
+ _numberOfGaussPoint= new int[it] ;
+ int * geometricTypeNumber=_geometricTypeNumber ;
+ _geometricTypeNumber = new int[it] ;
+
+ MEDSKYLINEARRAY* numberNew = new MEDSKYLINEARRAY(it,_totalNumberOfEntities);
+ int * numberIndex = numberNew->getIndex() ;
+ numberIndex[0]=1;
+ for (int i=0;i<it;i++) {
+ memcpy(numberNew->getI(i+1),tmp_array[i],sizeof(int)*_numberOfEntities[i]) ;
+ delete[] tmp_array[i] ;
+ numberIndex[i+1]=numberIndex[i]+_numberOfEntities[i] ;
+
+ _geometricType[i]=myType[i] ;
+ _numberOfGaussPoint[i]=1 ;
+ _geometricTypeNumber[i]=0 ;
+
+ }
+ delete _number ;
+ _number = numberNew ;
+
+ delete[] myType ;
+ delete[] tmp_array ;
+
+ delete[] geometricType ;
+ delete[] numberOfGaussPoint ;
+ delete[] geometricTypeNumber ;
+ delete[] numberOfEntities ;
+
+ END_OF(LOC);
+};
+
+/*!
+ This function allows the user to set a support not on all entities Entity,
+ it should be used after an initialisation with the constructor
+ SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL) and
+ after the call to the function setAll(false).
+ It allocates and initialises all the attributs of the class SUPPORT.;
+ useful for the Python API.
+ */
+
+//-------------------
+void SUPPORT::setpartial(string Description, int NumberOfGeometricType,
+ int TotalNumberOfEntity,
+ medGeometryElement *GeometricType,
+ int *NumberOfEntity, int *NumberValue)
+//-------------------
+{
+ const char * LOC = "SUPPORT::setpartial(string , int , int , medGeometryElement * , int * , int *) : " ;
+ BEGIN_OF(LOC) ;
+
+ _description=Description;
+
+ _numberOfGeometricType=NumberOfGeometricType;
+
+ _totalNumberOfEntities=TotalNumberOfEntity;
+
+ _geometricType = new medGeometryElement[NumberOfGeometricType];
+ _geometricType = GeometricType;
+
+ // attributes initialised at 0 because not really useful but it has to be
+ // allocated !! WARNING !!
+
+ _geometricTypeNumber = new int[NumberOfGeometricType] ;
+ for (int i=0;i<NumberOfGeometricType;i++) _geometricTypeNumber[i] = 0;
+
+ //_numberOfEntities = new int[NumberOfGeometricType] ;
+ _numberOfEntities = NumberOfEntity;
+
+ MEDSKYLINEARRAY * number = new MEDSKYLINEARRAY();
+
+ int * index = new int[_numberOfGeometricType+1];
+ index[0]=1;
+
+ for (int i=0;i<_numberOfGeometricType;i++)
+ index[i+1] = index[i]+_numberOfEntities[i] ;
+
+ number->setMEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities,index,NumberValue);
+
+ if (_number!=NULL) delete _number ;
+ _number = number;
+
+ update();
+
+ END_OF(LOC);
+};
--- /dev/null
+/*
+ File Support.hxx
+ $Header$
+*/
+
+#ifndef SUPPORT_HXX
+#define SUPPORT_HXX
+
+#include <vector>
+#include <string>
+
+#include "utilities.h"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_SkyLineArray.hxx"
+#include "MEDMEM_Mesh.hxx"
+
+using namespace MED_EN;
+
+class MESH ;
+
+class SUPPORT
+{
+protected:
+ /*! name of the support */
+ string _name;
+ /*! description of the support (optionnal) */
+ string _description;
+ /*! reference to the mesh on which the support is defined */
+ MESH * _mesh;
+ /*! type of entity on which the support is defined
+ (only one for each support) */
+ medEntityMesh _entity ;
+ /*! number of geometric type defined in the support */
+ int _numberOfGeometricType;
+ /*! array of all geometric type defined in the support */
+ medGeometryElement * _geometricType;
+ /*! array of size _numberOfGeometricType which contains
+ for each type the number of gauss point
+ (not yet implemented) */
+ int * _numberOfGaussPoint ;
+ /*! array of size _numberOfGeometricType
+ which contains number of geometric
+ entity type in Mesh
+ (to get corresponding CellModel)*/
+ int * _geometricTypeNumber;
+ /*! If true, we consider all entities of type _entity */
+ bool _isOnAllElts;
+ /*! array of size _numberOfGeometricType wich contains
+ for each geometric type, count of entities.
+ (if _isOnAllElts is true, we could get same
+ information from _mesh) */
+ int * _numberOfEntities;
+ /*! sum of each _numberOfEntities component (if
+ _isOnAllElts is true, we could get same
+ information from _mesh) */
+ int _totalNumberOfEntities;
+
+ // the two following arrays are defined only if _isOnAllElts is false :
+
+ /* array of size _numberOfType+1 wich contains for
+ each geometric type, index in _number._value
+ (if _all is true, we must ask _mesh to get
+ information). _typeIndex[i+1]-_typeIndex[i]
+ represents count of entities of ith geometric
+ type. _typeIndex[_numberOfType] contains total
+ entities count. If _numberOf[i]=0,
+ _typeIndex[i+1]=_typeIndex[i]
+ defined only if _isOnAllElts is false*/
+ // int * _typeIndex;
+ /*! array of size _index[_numberOfType] wich contain number of
+ entities of each geometric type. We use global numbering.
+ defined only if _isOnAllElts is false*/
+ MEDSKYLINEARRAY * _number;
+
+public:
+ SUPPORT();
+ SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL);
+ ~SUPPORT();
+ friend ostream & operator<<(ostream &os,const SUPPORT &my);
+
+ // function to set all value when SUPPORT was created by MedMedDriver without all MESH information !!! Change with new API !
+ void update();
+
+ inline void setName(string Name);
+ inline void setDescription(string Description);
+ inline void setMesh(MESH *Mesh);
+ inline void setAll(bool All);
+ inline void setEntity(medEntityMesh Entity);
+ inline void setNumberOfGeometricType(int NumberOfGeometricType);
+ inline void setGeometricType(medGeometryElement *GeometricType);
+ inline void setNumberOfGaussPoint(int *NumberOfGaussPoint);
+ inline void setGeometricTypeNumber(int *GeometricTypeNumber);
+ inline void setNumberOfEntities(int *NumberOfEntities);
+ inline void setTotalNumberOfEntities(int TotalNumberOfEntities);
+ inline void setNumber(MEDSKYLINEARRAY * Number);
+
+ inline string getName() const;
+ inline string getDescription() const;
+ inline MESH * getMesh() const;
+ inline medEntityMesh getEntity() const;
+
+ inline bool isOnAllElements() const;
+ inline int getNumberOfTypes() const;
+ inline medGeometryElement* getTypes() const ;
+ inline int * getNumberOfGaussPoint() const throw (MEDEXCEPTION);
+ inline int getNumberOfGaussPoint(medGeometryElement geomElement) const throw (MEDEXCEPTION);
+ inline int * getGeometricTypeNumber() const;
+ // inline int getNumberOfTotalEntity() const;
+ inline int getNumberOfElements(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
+ inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION);
+ inline int * getNumber(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
+ inline int * getNumberIndex() const throw (MEDEXCEPTION);
+
+ void blending(SUPPORT * mySupport);
+
+ /*
+ This function allows the user to set a support not on all entities Entity,
+ it should be used after an initialisation with the constructor
+ SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL) and
+ after the call to the function setAll(false).
+ It allocates and initialises all the attributs of the class SUPPORT.
+ */
+
+ void setpartial(string Description, int NumberOfGeometricType,
+ int TotalNumberOfEntity, medGeometryElement *GeometricType,
+ int *NumberOfEntity, int *NumberValue);
+};
+// _____________________
+// Methodes Inline
+// _____________________
+
+/*! If isOnAllElements is false, returns number of elements in the
+ support else returns number of nodes.
+
+ Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements
+ in entity of support.
+
+ Note : If SUPPORT is defined on MED_NODE, use MED_NONE
+ medGeometryElement type. */
+//-----------------------------------------------------------------------------
+inline int SUPPORT::getNumberOfElements(medGeometryElement GeometricType) const
+throw (MEDEXCEPTION)
+//-----------------------------------------------------------------------------
+{
+ if (_isOnAllElts){
+ return _mesh->getNumberOfElements(_entity,GeometricType);
+ } else {
+ if (GeometricType==MED_ALL_ELEMENTS)
+ return _totalNumberOfEntities;
+ for (int i=0;i<_numberOfGeometricType;i++)
+ if (_geometricType[i]==GeometricType)
+ return _numberOfEntities[i] ;
+ throw MEDEXCEPTION("Support::getNumberOfElements : Type not found !") ;
+ }
+}
+// inline int SUPPORT::getNumberOf(medGeometryElement GeometricType) const
+// throw (MEDEXCEPTION)
+// {
+// if (GeometricType==MED_ALL_ELEMENTS)
+// return _totalNumberOfEntities ;
+// for (int i=0;i<_numberOfGeometricType;i++)
+// if (_geometricType[i]==GeometricType)
+// return _numberOfEntities[i] ;
+// throw MEDEXCEPTION("Support::getNumberOf: GeometricType not found !");
+// }
+
+// inline int SUPPORT::getNumberOfTotalEntity() const
+// {
+// return _totalNumberOfEntities ;
+// }
+
+//---------------------------------------------------------------------
+inline MEDSKYLINEARRAY * SUPPORT::getnumber() const
+ throw (MEDEXCEPTION)
+//---------------------------------------------------------------------
+{
+ if (_number==NULL)
+ throw MEDEXCEPTION("Support::getnumber : Not defined !") ;
+ return _number ;
+}
+
+/*! If isOnAllElements is false, returns an array which contains
+ all number of given medGeometryElement.
+
+ Numbering is global, ie numbers are bounded by 1 and
+ MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and
+ MESH::getNumberOfElement(entity,geomElement).
+
+ Note : If SUPPORT is defined on MED_NODE, use MED_NONE
+ medGeometryElement type. */
+//---------------------------------------------------------------------
+inline int * SUPPORT::getNumber(medGeometryElement GeometricType) const
+ throw (MEDEXCEPTION)
+//---------------------------------------------------------------------
+{
+ const char * LOC = "Support::getNumber : " ;
+ if (_isOnAllElts)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined, support is on all entity !")) ;
+ if (GeometricType==MED_ALL_ELEMENTS)
+ return _number->getValue() ;
+ for (int i=0;i<_numberOfGeometricType;i++)
+ if (_geometricType[i]==GeometricType)
+ return _number->getI(i+1) ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"GeometricType not found !")) ;
+}
+
+/*! If isOnAllElements is false, returns index of element number.
+ Use it with getNumber(MED_ALL_ELEMENTS).
+
+ Note : See getConnectivityIndex for details. */
+//-------------------------------------------
+inline int * SUPPORT::getNumberIndex() const
+//-------------------------------------------
+throw (MEDEXCEPTION)
+{
+ if (_isOnAllElts)
+ throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ;
+ return _number->getIndex() ;
+}
+
+/*! A DOCUMENTER */
+//-------------------------------------------------
+inline int * SUPPORT::getNumberOfGaussPoint() const
+throw (MEDEXCEPTION)
+//-------------------------------------------------
+{
+ if (_numberOfGaussPoint!=NULL)
+ return _numberOfGaussPoint ;
+ else
+ throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
+}
+
+/*! Returns number of Gauss points for this medGeometryElement.
+
+ Note :
+ - Not defined if SUPPORT is on MED_NODE.
+ - Not defined for MED_ALL_ELEMENTS medGeometryElement type. */
+//-----------------------------------------------------------------------------
+inline int SUPPORT::getNumberOfGaussPoint(medGeometryElement geomElement) const
+throw (MEDEXCEPTION)
+//-----------------------------------------------------------------------------
+{
+ if (_numberOfGaussPoint!=NULL) {
+ for (int i=0;i<_numberOfGeometricType;i++)
+ if (_geometricType[i]==geomElement)
+ return _numberOfGaussPoint[i] ;
+ throw MEDEXCEPTION("Support::getGlobalNumber : GeometricType not found !") ;
+ } else
+ throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
+}
+// inline int SUPPORT::getNumberLength() const
+// throw (MEDEXCEPTION)
+// {
+// if (_isOnAllElts)
+// throw MEDEXCEPTION("Support::getNumberLength : Not defined, support is on all entity !") ;
+// return _number->getLength() ;
+// }
+
+/*! set the attribute _name to Name */
+//--------------------------------------
+inline void SUPPORT::setName(string Name)
+//--------------------------------------
+{
+ _name=Name;
+}
+
+/*! set the attribute _description to Description */
+//--------------------------------------------------
+inline void SUPPORT::setDescription(string Description)
+//--------------------------------------------------
+{
+ _description=Description;
+}
+
+/*! set the reference _mesh to Mesh */
+//--------------------------------------
+inline void SUPPORT::setMesh(MESH *Mesh)
+//--------------------------------------
+{
+ _mesh=Mesh;
+}
+
+/*! set the attribute _isOnAllElts to All */
+//------------------------------------------
+inline void SUPPORT::setAll(bool All)
+//------------------------------------------
+{
+ _isOnAllElts=All;
+}
+
+/*! set the attribute _entity to Entity */
+//------------------------------------------
+inline void SUPPORT::setEntity(medEntityMesh Entity)
+{
+ _entity=Entity;
+ if ( Entity == MED_NODE) {
+ _numberOfGeometricType=1 ;
+ _geometricType=new medGeometryElement[1] ; // delete previous ???
+ _geometricType[0]=MED_NONE ;
+ }
+}
+
+/*! set the attribute _numberOfGeometricType to NumberOfGeometricType */
+//---------------------------------------------------------------------
+inline void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType)
+//---------------------------------------------------------------------
+{
+ _numberOfGeometricType=NumberOfGeometricType;
+}
+
+/*! set the attribute _geometricType to geometricType */
+//---------------------------------------------------------------------
+inline void SUPPORT::setGeometricType(medGeometryElement *GeometricType)
+//---------------------------------------------------------------------
+{
+ _geometricType=GeometricType;
+}
+
+/*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */
+//-----------------------------------------------------------------
+inline void SUPPORT::setNumberOfGaussPoint(int *NumberOfGaussPoint)
+//-----------------------------------------------------------------
+{
+ _numberOfGaussPoint = NumberOfGaussPoint ;
+}
+
+/*! set the attribute _geometricTypeNumber to GeometricTypeNumber */
+//-------------------------------------------------------------------
+inline void SUPPORT::setGeometricTypeNumber(int *GeometricTypeNumber)
+//-------------------------------------------------------------------
+{
+ _geometricTypeNumber=GeometricTypeNumber;
+}
+
+/*! set the attribute _numberOfEntities to NumberOfEntities */
+//----------------------------------------------------------
+inline void SUPPORT::setNumberOfEntities(int *NumberOfEntities)
+//----------------------------------------------------------
+{
+ _numberOfEntities=NumberOfEntities;
+}
+
+/*! set the attribute _totalNumberOfEntities to TotalNumberOfEntities */
+//--------------------------------------------------------------------
+inline void SUPPORT::setTotalNumberOfEntities(int TotalNumberOfEntities)
+//--------------------------------------------------------------------
+{
+ _totalNumberOfEntities=TotalNumberOfEntities;
+}
+
+/*! set the attribute _number to Number */
+//---------------------------------------------------
+inline void SUPPORT::setNumber(MEDSKYLINEARRAY * Number)
+//---------------------------------------------------
+{
+ _number=Number;
+}
+
+/*! returns the name of the support. */
+//------------------------------------
+inline string SUPPORT::getName() const
+//------------------------------------
+{
+ return _name;
+}
+
+
+/*! returns the description of the support. */
+//--------------------------------------------
+inline string SUPPORT::getDescription() const
+//--------------------------------------------
+{
+ return _description;
+}
+
+/*! returns a refernce to the mesh */
+//------------------------------------
+inline MESH * SUPPORT::getMesh() const
+//------------------------------------
+{
+ return _mesh;
+}
+
+/*! Returns true if all elements of this entity are
+ concerned, false otherwise.
+ If true, you must use mesh reference (getMesh) to get more information.*/
+//------------------------------------------
+inline bool SUPPORT::isOnAllElements() const
+//------------------------------------------
+{
+ return _isOnAllElts;
+}
+
+/*! Returns number of geometric Types
+ defines in the support */
+//------------------------------------------
+inline int SUPPORT::getNumberOfTypes() const
+//------------------------------------------
+{
+ if ((_isOnAllElts)&(_entity != MED_NODE))
+ return _mesh->getNumberOfTypes(_entity) ;
+ else
+ return _numberOfGeometricType ;
+}
+
+/*! Returns the medEntityMesh's type used by the support.
+ Note : A support deals only with one entity's type
+ (for example : MED_FACE or MED_NODE)*/
+//---------------------------------------------
+inline medEntityMesh SUPPORT::getEntity() const
+//---------------------------------------------
+{
+ return _entity;
+}
+
+/*! If isOnAllElements is false, returns an array of <medGeometryElement>
+ types used by the support.
+
+ <medEntityMesh> is given by getEntity. */
+//---------------------------------------------------
+inline medGeometryElement * SUPPORT::getTypes() const
+//---------------------------------------------------
+{
+ if ((_isOnAllElts)&(_entity != MED_NODE))
+ return _mesh->getTypes(_entity) ;
+ else
+ return _geometricType;
+}
+
+//---------------------------------------------------
+inline int * SUPPORT::getGeometricTypeNumber() const
+//---------------------------------------------------
+{
+ const char * LOC = "SUPPORT::getGeometricTypeNumber() : ";
+ if (_isOnAllElts)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined (is on all elements) !"));
+ if (_geometricTypeNumber==NULL)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined !"));
+ return _geometricTypeNumber;
+}
+
+
+#endif /* SUPPORT_HXX */
--- /dev/null
+/*
+ File MEDMEM_Unit.cxx
+ $Header$
+*/
+
+#include "MEDMEM_Unit.hxx"
+
+UNIT::UNIT():_name(""),_description(""),_masse(0),_length(0),_time(0),_temperature(0),_matterQuantity(0),_currentStrength(0),_lightIntensity(0) {
+ MESSAGE("UNIT()");
+};
+
+UNIT::UNIT(string Name, string Description):_name(Name),_description(Description),_masse(0),_length(0),_time(0),_temperature(0),_matterQuantity(0),_currentStrength(0),_lightIntensity(0) {
+ MESSAGE("UNIT(string Name, string Description)");
+};
+
+UNIT::~UNIT() {
+ MESSAGE("~UNIT()") ;
+};
+
+UNIT & UNIT::operator=(const UNIT &unit) {
+ MESSAGE("UNIT::operateur=") ;
+ _name=unit._name ;
+ _description=unit._description ;
+ _masse=unit._masse ;
+ _length=unit._length ;
+ _time=unit._time ;
+ _temperature=unit._temperature ;
+ _matterQuantity=unit._matterQuantity ;
+ _currentStrength=unit._currentStrength ;
+ _lightIntensity=unit._lightIntensity ;
+ return *this;
+};
--- /dev/null
+/*
+ File Unit.hxx
+ $Header$
+*/
+
+#ifndef UNIT_HXX
+#define UNIT_HXX
+
+#include <string>
+
+#include "utilities.h"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+//using namespace MED_EN;
+
+class UNIT {
+protected:
+ string _name ;
+ string _description ;
+
+ int _masse ; // kilogram (kg)
+ int _length ; // meter (m)
+ int _time ; // second (s)
+ int _temperature ; // Kelvin (K)
+ int _matterQuantity ; // mole (mol)
+ int _currentStrength ; // ampere (A)
+ int _lightIntensity ; // candela (cd)
+
+ // Unit in IS !
+ // Example :
+ // J = kg.m^2.s^(-2)
+ // so : Name="Joule",Masse=1,Length=2 and Time=-2, other are null
+
+public:
+ UNIT();
+ UNIT(string Name, string Description);
+ ~UNIT();
+ UNIT & operator=(const UNIT &unit);
+
+ inline void setName(string Name) ;
+ inline void setDescription(string Description) ;
+ inline void setMasse(int Masse) ;
+ inline void setLength(int Length) ;
+ inline void setTime(int Time) ;
+ inline void setTemperature(int Temperature) ;
+ inline void setMatterQuantity(int MatterQuantity) ;
+ inline void setCurrentStrength(int CurrentStrength) ;
+ inline void setLightIntensity(int LightIntensity) ;
+
+ inline string getName() const ;
+ inline string getDescription() const ;
+ inline int getMasse() const ;
+ inline int getLength() const ;
+ inline int getTime() const ;
+ inline int getTemperature() const ;
+ inline int getMatterQuantity() const ;
+ inline int getCurrentStrength() const ;
+ inline int getLightIntensity() const ;
+
+} ;
+
+// inline method :
+
+inline void UNIT::setName(string Name) {
+ _name = Name ;
+};
+inline void UNIT::setDescription(string Description) {
+ _description = Description ;
+};
+inline void UNIT::setMasse(int Masse) {
+ _masse=Masse ;
+};
+inline void UNIT::setLength(int Length) {
+ _length=Length ;
+};
+inline void UNIT::setTime(int Time) {
+ _time=Time ;
+};
+inline void UNIT::setTemperature(int Temperature) {
+ _temperature=Temperature ;
+};
+inline void UNIT::setMatterQuantity(int MatterQuantity) {
+ _matterQuantity=MatterQuantity ;
+};
+inline void UNIT::setCurrentStrength(int CurrentStrength) {
+ _currentStrength=CurrentStrength ;
+};
+inline void UNIT::setLightIntensity(int LightIntensity) {
+ _lightIntensity=LightIntensity ;
+};
+
+inline string UNIT::getName() const { return _name ; } ;
+inline string UNIT::getDescription() const { return _description ; } ;
+inline int UNIT::getMasse() const { return _masse ; } ;
+inline int UNIT::getLength() const { return _length ; } ;
+inline int UNIT::getTime() const { return _time ; } ;
+inline int UNIT::getTemperature() const { return _temperature ; } ;
+inline int UNIT::getMatterQuantity() const { return _matterQuantity ; } ;
+inline int UNIT::getCurrentStrength() const { return _currentStrength ; } ;
+inline int UNIT::getLightIntensity() const { return _lightIntensity ; } ;
+
+#endif /* UNIT_HXX */
--- /dev/null
+#include "MEDMEM_VtkMedDriver.hxx"
+
+#include "MEDMEM_Med.hxx"
+
+VTK_MED_DRIVER::VTK_MED_DRIVER(): GENDRIVER(),
+ _ptrMed((MED * const)MED_NULL),
+ _vtkFile(MED_INVALID)
+{
+ // What about _id in Gendriver ?
+ // _driverType ???
+}
+
+
+VTK_MED_DRIVER::VTK_MED_DRIVER(const string & fileName, MED * const ptrMed):
+ GENDRIVER(fileName,MED_EN::MED_RDWR), _ptrMed(ptrMed), _vtkFile(MED_INVALID)
+{
+ // What about _id in Gendriver ?
+ // _driverType ???
+}
+
+//REM : As t'on besoin du champ _status : _vtkFile <-> _status ? Oui
+
+
+void VTK_MED_DRIVER::open() {
+
+ const char * LOC ="VTK_MED_DRIVER::open() : ";
+ BEGIN_OF(LOC);
+
+ // REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE
+// if ( _vtkFile != MED_INVALID )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+// << "_vtkFile is already in use, please close the file |"
+// << _fileName << "| before calling open()"
+// )
+// );
+
+ if ( _status != MED_CLOSED )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "_status is not closed, please close the file |"
+ << _fileName << "| before calling open()"
+ )
+ );
+
+ if ( _fileName == "" )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "_fileName is |\"\"|, please set a correct fileName before calling open()"
+ )
+ );
+ _vtkFile.open(filename.c_str()) ; // ? if error ????
+ _status = MED_OPENED ;
+
+// if (_vtkFile > 0) _status=MED_OPENED;
+// else {
+// _status = MED_CLOSED;
+// _vtkFile = MED_INVALID;
+// throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
+// << "Can't open |" << _fileName
+// << "|, _vtkFile : " << _vtkFile
+// )
+// );
+// }
+
+ END_OF(LOC);
+}
+
+
+void VTK_MED_DRIVER::close() {
+
+ const char * LOC = "MED_MED_DRIVER::close() : ";
+ BEGIN_OF(LOC);
+
+ if ( _status == MED_CLOSED)
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
+ << _fileName << "| is already closed"
+ )
+ );
+
+ // if ( _vtkFile == MED_INVALID )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_vtkFile invalid, but the file |"
+// << _fileName << "| seems to be openned !"
+// )
+// );
+ vtkFile_.close();
+
+ _status = MED_CLOSED;
+ // _vtkFile = MED_INVALID;
+
+// if (err != MED_VALID)
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
+// << _fileName << "| couldn't be closed"
+// )
+// );
+
+ END_OF(LOC);
+}
+
+
+void VTK_MED_DRIVER::write() {
+
+ const char * LOC = "MED_MED_DRIVER::write() : ";
+ BEGIN_OF(LOC);
+
+ // could we put more than one Mesh ?????
+ _vtkFile << "# vtk DataFile Version 2.0" << endl
+ << "maillage SALOLME" << endl ;
+ // only ASCII for the moment (binary came latest :-)
+ _vtkFile << "ASCII" << endl ;
+
+ int NumberOfMeshes = _ptrMED->getNumberOfMeshes() ;
+ string * MeshName = new string[NumberOfMeshes] ;
+ _ptrMED->getMeshNames(MeshName) ;
+ // In fact, we must take care of all supports
+ // We restrict Field on all nodes or cells
+ for (int i=0; i<NumberOfMeshes; i++) {
+ MESH * myMesh = _ptrMED->getMesh(MeshName[i]) ;
+ writeMesh(myMesh) ;
+ // get all field which values are on this mesh => revoir api de Med !!!
+ _vtkFile << "NODE" << endl ;
+ // first : field on node
+ for (int j=0; j<NumberOfFields; j++) {
+ FIELD_ * myField = _ptrMED->getField() ;
+ if (myField->getSupport()->getEntity()!=MED_NODE)
+ if (myField->getSupport()->isOnAllElements())
+ writeField(myField) ;
+
+ }
+ _vtkFile << "CELL" << endl ;
+ // second : field on cell
+ for (int j=0; j<NumberOfFields; j++) {
+ FIELD_ * myField = _ptrMED->getField() ;
+ if (myField->getSupport()->getEntity()!=MED_CELL)
+ if (myField->getSupport()->isOnAllElements())
+ writeField(myField) ;
+
+ }
+
+ }
+
+ END_OF(LOC);
+}
+
+void VTK_MED_DRIVER::writeMesh(MESH * myMesh) {
+
+ const char * LOC = "MED_MED_DRIVER::writeMesh() : ";
+ BEGIN_OF(LOC);
+
+ _vtkFile << "DATASET UNSTRUCTURED_GRID" << endl ;
+ // put points (all point are in 3D, so if we are in 1D or 2D, we complete by zero !
+ int SpaceDimension = myMesh->getSpaceDimension() ;
+ int NumberOfNodes = myMesh->getNumberOfNodes() ;
+ _vtkFile << "POINTS " << NumberOfNodes << " float" << endl ;
+ double *coordinate = myMesh->getCoordinates(MED_FULL_ENTERLACE) ;
+ if (SpaceDimension<3) { // 1D or 2D
+ coordinate_z = new double[NumberOfNodes] ;
+ // we put zero :
+ for (int i=0;i<NumberOfNodes;i++)
+ coordinate_z[i] = 0.0 ;
+ if (SpaceDimension==1)
+ coordinate_y = coordinate_z ; // only one array of zero !
+ else
+ coordinate_y = coordinate_x + NumberOfNodes ;
+ } else {
+ coordinate_y = coordinate_x + NumberOfNodes ;
+ coordinate_z = coordinate_y + NumberOfNodes ;
+ }
+ for (int i=0;i<NumberOfNodes;i++)
+ for (int j=0;j<SpaceDimension;j++)
+ _vtkFile << coordinate[i*SpaceDimension+j] << " " ;
+ if (SpaceDimension==1)
+ _vtkFile << "0 0" ;
+ if (SpaceDimension==2)
+ _vtkFile << "0" ;
+ _vtkFile << endl ;
+
+ // we put connectivity
+ // how many cells and how many value in connectivity :
+ int cells_types_count = myMesh->getNumberOfTypes(MED_CELL) ;
+ int * cells_count = myMesh->get_cells_count() ;
+ int cells_sum = cells_count[cells_types_count] ;
+ CellModel * cells_type = myMesh->get_cells_type() ;
+ int connectivity_sum = 0 ;
+
+ int * connectivity = myMesh->getConnectivity(MED_FULL_ENTERLACE,MED_CELL,MED_ALL_ELEMENTS) ;
+ int * connectivityIndex = myMesh->getConnectivityIndex(MED_CELL) ;
+
+ for (int i=0;i<cells_types_count;i++) {
+ int nodes_cell = cells_type[i].getNumberOfNodes();
+ connectivity_sum+= (cells_count[i+1]-cells_count[i])*(nodes_cell + 1);
+ // we add 1 because we put nodes count in vtk file !
+ }
+ _vtkFile << "CELLS " << cells_sum << " " << connectivity_sum << endl ;
+ // we put connectivity
+ for (int i=0;i<cells_types_count;i++) {
+ int *filter = (int*) NULL ; // index in vtk connectivity
+ switch (cells_type[i].get_type())
+ {
+ case MED_POINT1 : {
+ filter = new int[1] ;
+ filter[0] = 0 ;
+ break ;
+ }
+ case MED_SEG2 : {
+ filter = new int[2] ;
+ filter[0] = 0 ;
+ filter[1] = 1 ;
+ break ;
+ }
+ case MED_SEG3 : {
+ break ;
+ }
+ case MED_TRIA3 : {
+ filter = new int[3] ;
+ filter[0] = 0 ;
+ filter[1] = 1 ;
+ filter[2] = 2 ;
+ break ;
+ }
+ case MED_QUAD4 : {
+ filter = new int[4] ;
+ filter[0] = 0 ;
+ filter[1] = 1 ;
+ filter[2] = 2 ;
+ filter[3] = 3 ;
+ break ;
+ }
+ case MED_TRIA6 : {
+ break ;
+ }
+ case MED_QUAD8 : {
+ break ;
+ }
+ case MED_TETRA4 : {
+ filter = new int[4] ;
+ filter[0] = 0 ;
+ filter[1] = 1 ;
+ filter[2] = 3 ; // 3td element in med are 4th in vtk (array begin at 0 !)
+ filter[3] = 2 ; // 4th element in med are 3rd in vtk (array begin at 0 !)
+ break ;
+ }
+ case MED_PYRA5 : {
+ filter = new int[5] ;
+ filter[0] = 0 ;
+ filter[1] = 3 ; // 2nd element in med are 4th in vtk (array begin at 0 !)
+ filter[2] = 2 ;
+ filter[3] = 1 ; // 4th element in med are 2nd in vtk (array begin at 0 !)
+ filter[4] = 4 ;
+ break ;
+ }
+ case MED_PENTA6 : {
+ filter = new int[6] ;
+ filter[0] = 0 ;
+ filter[1] = 1 ;
+ filter[2] = 2 ;
+ filter[3] = 3 ;
+ filter[4] = 4 ;
+ filter[5] = 5 ;
+ break ;
+ }
+ case MED_HEXA8 : {
+ filter = new int[8] ;
+ filter[0] = 0 ;
+ filter[1] = 3 ;
+ filter[2] = 2 ;
+ filter[3] = 1 ;
+ filter[4] = 4 ;
+ filter[5] = 7 ;
+ filter[6] = 6 ;
+ filter[7] = 5 ;
+ break ;
+ }
+ case MED_TETRA10 : {
+ break ;
+ }
+ case MED_PYRA13 : {
+ break ;
+ }
+ case MED_PENTA15 : {
+ break ;
+ }
+ case MED_HEXA20 : {
+ break ;
+ }
+ default : {
+ break ;
+ }
+ }
+ if (filter==NULL)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].get_type() ) ) ;
+ int nodes_cell = cells_type[i].get_NumberOfNodes();
+ for (int j=0;j<cells_count[i+1]-cells_count[i];j++) {
+ _vtkFile << nodes_cell << " " ;
+ for (int k=0;k<nodes_cell;k++)
+ _vtkFile << (myMesh->get_nodal_connectivity(i+1))[j*nodes_cell+filter[k]] - 1 << " " ;
+ _vtkFile << endl ;
+ }
+ }
+ _vtkFile << endl ;
+ // we put cells type
+ _vtkFile << "CELL_TYPES " << cells_sum << endl ;
+ for (int i=0;i<cells_types_count;i++) {
+ int vtkType = 0 ;
+ switch (cells_type[i].get_type())
+ {
+ case MED_POINT1 : {
+ vtkType = 1 ;
+ break ;
+ }
+ case MED_SEG2 : {
+ vtkType = 3 ;
+ break ;
+ }
+ case MED_SEG3 : {
+ vtkType = 0 ;
+ break ;
+ }
+ case MED_TRIA3 : {
+ vtkType = 5 ;
+ break ;
+ }
+ case MED_QUAD4 : {
+ vtkType = 9 ;
+ break ;
+ }
+ case MED_TRIA6 : {
+ vtkType = 0 ;
+ break ;
+ }
+ case MED_QUAD8 : {
+ vtkType = 0 ;
+ break ;
+ }
+ case MED_TETRA4 : {
+ vtkType = 10 ;
+ break ;
+ }
+ case MED_PYRA5 : {
+ vtkType = 14 ;
+ break ;
+ }
+ case MED_PENTA6 : {
+ vtkType = 13 ;
+ break ;
+ }
+ case MED_HEXA8 : {
+ vtkType = 12 ;
+ break ;
+ }
+ case MED_TETRA10 : {
+ vtkType = 0 ;
+ break ;
+ }
+ case MED_PYRA13 : {
+ vtkType = 0 ;
+ break ;
+ }
+ case MED_PENTA15 : {
+ vtkType = 0 ;
+ break ;
+ }
+ case MED_HEXA20 : {
+ vtkType = 0 ;
+ break ;
+ }
+ default : {
+ vtkType = 0 ;
+ break ;
+ }
+ }
+ if (vtkType == 0)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].get_type() ) ) ;
+ for (int j=0;j<cells_count[i+1]-cells_count[i];j++)
+ _vtkFile << vtkType << endl ;
+ if (filter != NULL)
+ delete[] filter ;
+ }
+
+ // add a constant field on all node to test !
+ // _vtkFile << "POINT_DATA " << NumberOfNodes << endl ;
+ // _vtkFile << "SCALARS example_scalaire float 1" << endl ;
+ // _vtkFile << "LOOKUP_TABLE default" << endl ;
+ // for (int i=0;i<NumberOfNodes;i++)
+ // _vtkFile << i << endl ;
+
+ return 1 ;
+
+
+ END_OF(LOC);
+}
+
+void VTK_MED_DRIVER::writeField(FIELD * myField) {
+
+ const char * LOC = "MED_MED_DRIVER::writeField() : ";
+ BEGIN_OF(LOC);
+
+
+
+ END_OF(LOC);
+}
--- /dev/null
+#ifndef VTK_MED_DRIVER_HXX
+#define VTK_MED_DRIVER_HXX
+
+#include <string>
+#include "MEDMEM_STRING.hxx"
+#include "utilities.h"
+#include "MEDMEM_Exception.hxx"
+
+#include "MEDMEM_GenDriver.hxx"
+
+
+class MESH;
+class FIELD_;
+class MED;
+
+// This driver pilots within a VTK class read/write accesses of fields/meshes
+class VTK_VTK_DRIVER : public GENDRIVER
+{
+protected:
+
+ MED * const _ptrMED ; // Store 'VTK_DRIVER (0..n)----(1) VTK' associations
+ ofstream _vtkFile ; // The _vtkFile used to write Meshes and Fields to _filename
+
+private:
+ VTK_MED_DRIVER();
+
+public :
+ VTK_MED_DRIVER(const string & fileName, MED * const ptrMed);
+ // OPERATEUR DE RECOPIE AVEC _vtkFile ??
+
+ void open();
+ void close();
+
+ virtual void write ( void ) const ;
+ // virtual void writeFrom ( void ) const ;
+ // virtual void read ( void ) ;
+
+protected :
+ void writeMesh(MESH * myMesh) ;
+ void writeField(FIELD_ * myField) ;
+
+};
+
+
+#endif /* VTK_MED_DRIVER_HXX */
--- /dev/null
+#ifndef DEFINE_HXX
+#define DEFINE_HXX
+
+#include <stdio.h>
+#include <iostream.h>
+#include <string.h>
+#include <assert.h>
+
+// UTILE AUX DEUX NAMESPACES
+#include <hdf5.h>
+
+namespace MED_FR {
+ extern "C" {
+# include <med.h>
+# include <med_proto.h>
+ }
+}
+
+
+namespace MED_EN {
+ extern "C" {
+
+#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
+
+typedef enum {MED_FULL_INTERLACE,
+ MED_NO_INTERLACE} medModeSwitch;
+
+typedef enum {MED_LECT,MED_ECRI,MED_REMP} med_mode_acces;
+
+typedef enum {MED_CELL, MED_FACE, MED_EDGE, MED_NODE, MED_ALL_ENTITIES} medEntityMesh;
+
+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_NONE=0, 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_ALL_ELEMENTS=999}
+medGeometryElement;
+
+typedef enum {MED_NODAL, MED_DESCENDING} medConnectivity ;
+
+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 !!!!! NB: WARNING MED_ALL deja utilise dans l'enum medGeometryElement !!!!!!!!
+#define MED_ALL 0
+
+#if defined(SUN4SOL2) || defined(PCLINUX) || defined(OSF1) || 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)
+#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.h"
+
+ }
+
+// valeurs des algos de connexites
+#define FRACT_ALGO 10
+#define MAX_LOOP 200
+// fin
+
+// Valeurs de IO_MED
+//#define READ 0
+//#define WRITE 1
+
+
+#define MED_CLOSED 0
+#define MED_OPENED 1
+#define MED_INVALID -1
+#define MED_ERROR -1
+#define MED_VALID 0
+//#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.
+#define MED_WRONLY MED_ECRI
+#define MED_RDWR MED_ECRI
+// Fin
+
+#define FAUX 0
+#define VRAI 1
+#define longueur_string 100
+#define PRECISION 0.0000001
+// #define undefined -1
+#define UNDEFINED -1
+
+// type des connectivites
+//#define CONN_NOD 0
+//#define CONN_DESC_PART 1
+//#define CONN_DESC_TOT 2
+
+// valeurs de type_interpolation
+#define P1 0
+#define pseudo_P2 1
+#define trilineaire 2
+#define P2_adapte 3
+#define VF_conservatif 4
+#define VF_non_conservatif 5
+// valeurs de type_mapping
+#define connexite 0
+#define conn_octree 1
+#define brutal 2
+// valeurs des type_support
+#define support_noeud 0
+#define support_maille 1
+// retour des fonctions
+#define OK 0
+#define KO 1
+// fin
+
+}
+// End Of NameSpace MED_EN
+
+
+#endif /* DEFINE_HXX */
+
--- /dev/null
+#==============================================================================
+# File : Makefile.in
+# Author : Patrick GOLDBRONN (CEA/DEN/DM2S/SFME/LGLS)
+# CVS : $Header$
+#==============================================================================
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=../../..
+srcdir=@srcdir@
+VPATH=.:$(srcdir)
+
+MACHINE=PCLINUX
+
+@COMMENCE@
+
+
+EXPORT_PYSCRIPTS = \
+
+
+EXPORT_HEADERS = \
+MEDMEM_CellModel.hxx \
+MEDMEM_Connectivity.hxx \
+MEDMEM_Coordinate.hxx \
+MEDMEM_define.hxx \
+MEDMEM_DriversDef.hxx \
+MEDMEM_Family.hxx \
+MEDMEM_Field.hxx \
+MEDMEM_GenDriver.hxx \
+MEDMEM_Group.hxx \
+MEDMEM_Array.hxx \
+MEDMEM_Exception.hxx \
+MEDMEM_MedFieldDriver.hxx \
+MEDMEM_Med.hxx \
+MEDMEM_MedMedDriver.hxx \
+MEDMEM_MedMeshDriver.hxx \
+MEDMEM_ModulusArray.hxx \
+MEDMEM_SkyLineArray.hxx \
+MEDMEM_VtkMedDriver.hxx \
+MEDMEM_Mesh.hxx \
+MEDMEM_STRING.hxx \
+MEDMEM_Support.hxx \
+MEDMEM_Unit.hxx
+
+# Libraries targets
+
+LIB=libmedmem.la
+
+LIB_SRC = \
+MEDMEM_CellModel.cxx \
+MEDMEM_Connectivity.cxx \
+MEDMEM_Coordinate.cxx \
+MEDMEM_DriversDef.cxx \
+MEDMEM_Family.cxx \
+MEDMEM_Field.cxx \
+MEDMEM_GenDriver.cxx \
+MEDMEM_Group.cxx \
+MEDMEM_Med.cxx \
+MEDMEM_Exception.cxx \
+MEDMEM_MedMedDriver.cxx \
+MEDMEM_MedMeshDriver.cxx \
+MEDMEM_SkyLineArray.cxx \
+MEDMEM_Mesh.cxx \
+MEDMEM_Support.cxx \
+MEDMEM_Unit.cxx \
+
+#VtkMedDriver.cxx \
+
+
+# Executables targets
+BIN = duplicateMED med_test duplicateMEDMESH
+BIN_SRC =
+BIN_SERVER_IDL =
+BIN_CLIENT_IDL =
+
+TEST_PROGS = test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray test_MEDMEM_CellModel
+
+CPPFLAGS+=$(MED2_INCLUDES) $(HDF5_INCLUDES)
+CXXFLAGS+=-ftemplate-depth-42
+LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lSalomeLoggerServer
+
+# build create_mesh :
+bin: create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_mesh_c3h8q4_wrong create_mesh_c2q4s2_wrong
+
+create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4: %: %.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(MED2_LIBS) $(HDF5_LIBS) $(LDFLAGS) $<
+
+@CONCLUDE@
--- /dev/null
+#include <med.h>
+#include <string.h>
+
+#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
+
+int main (int argc, char **argv)
+{
+ med_err ret;
+ med_idt fid;
+ char maa[MED_TAILLE_NOM+1] = "maa1";
+ med_int mdim = 3;
+ med_int nnoe = 19;
+ med_float coo[57] = {
+ 0.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0,
+ 2.0, 0.0, 1.0,
+ 0.0, 2.0, 1.0,
+ -2.0, 0.0, 1.0,
+ 0.0, -2.0, 1.0,
+ 1.0, 1.0, 2.0,
+ -1.0, 1.0, 2.0,
+ -1.0, -1.0, 2.0,
+ 1.0, -1.0, 2.0,
+ 1.0, 1.0, 3.0,
+ -1.0, 1.0, 3.0,
+ -1.0, -1.0, 3.0,
+ 1.0, -1.0, 3.0,
+ 1.0, 1.0, 4.0,
+ -1.0, 1.0, 4.0,
+ -1.0, -1.0, 4.0,
+ 1.0, -1.0, 4.0,
+ 0.0, 0.0, 5.0
+ };
+ char nomcoo[3*MED_TAILLE_PNOM+1] = "x y z ";
+ char unicoo[3*MED_TAILLE_PNOM+1] = "cm cm cm ";
+ /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
+ char *nomnoe ;
+ med_int numnoe[19] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+ med_int nufano[19] = {1,1,3,3,0,0,2,0,4,0,4,2,4,2,4,2,4,1,3};
+
+ med_int ntet4 = 12;
+ med_int tet4[12*4] = {
+ 1,2,3,6,
+ 1,2,4,3,
+ 1,2,5,4,
+ 1,2,6,5,
+ 2,7,4,3,
+ 2,8,5,4,
+ 2,9,6,5,
+ 2,10,3,6,
+ 2,7,3,10,
+ 2,8,4,7,
+ 2,9,5,8,
+ 2,10,6,9
+ };
+ char * nomtet4 ;
+ med_int numtet4[12] = {1,2,3,4,5,6,7,8,9,10,11,12};
+ med_int nufatet4[12] = {-1,-1,-1,-1,0,0,0,0,0,0,-2,-3};
+
+ med_int npyra5 = 2;
+ med_int pyra5[5*2] = {
+ 7,8,9,10,2,
+ 15,18,17,16,19
+ };
+ char nompyra5[MED_TAILLE_PNOM*2+1] = "pyra1 pyra2 ";
+ med_int numpyra5[2] = {13,16};
+ med_int nufapyra5[2] = {0,-3};
+
+ med_int nhexa8 = 2;
+ med_int hexa8[8*2] = {
+ 11,12,13,14,7,8,9,10,
+ 15,16,17,18,11,12,13,14
+ };
+ char nomhexa8[MED_TAILLE_PNOM*2+1] = "hexa1 hexa2 ";
+ med_int numhexa8[2] = {14,15};
+ med_int nufahexa8[2] = {0,0};
+
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ char attdes[MED_TAILLE_DESC+1];
+ med_int natt;
+ med_int attide;
+ med_int attval;
+ med_int ngro;
+ char gro[MED_TAILLE_LNOM+1];
+ char gro2[MED_TAILLE_LNOM*2+1];
+ char gro3[MED_TAILLE_LNOM*3+1];
+ int i;
+ int nfame = 3;
+ int nfamn = 2;
+
+
+ /*
+ Some fields : 2 on nodes : one int and one double , one on cells : double
+ */
+ char champ1[MED_TAILLE_NOM+1]="fieldnodeint" ;
+ char champ1_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champ1_unit[MED_TAILLE_PNOM+1]="M " ;
+ med_int fieldnodeint[19] = {1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7};
+
+ char champ2[MED_TAILLE_NOM+1]="fieldnodedouble" ;
+ char champ2_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champ2_unit[MED_TAILLE_PNOM+1]="J " ;
+ med_float fieldnodedouble1[19] = {1.,1.,1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.};
+ med_float fieldnodedouble2[19] = {1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.,7.,7.};
+
+ char champ3[MED_TAILLE_NOM+1]="fieldcelldouble" ;
+ char champ3_comp[MED_TAILLE_PNOM*3+1]="comp1 comp2 comp3 " ;
+ char champ3_unit[MED_TAILLE_PNOM*3+1]="M/S M/s m/s " ;
+ med_float fieldcelldouble1[12*3] = {1,1,1,2,2,2,3,3,3,4,4,4,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0};
+ med_float fieldcelldouble2[2*3] = {5,5,0,1,0,1};
+ med_float fieldcelldouble3[2*3] = {6,6,1,0,1,0};
+
+ /***************************************************************************/
+ fid = MEDouvrir("pointe.med",MED_REMP);
+ if (fid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("MEDouvrir : %d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDmaaCr(fid,maa,mdim);
+ printf("MEDmaaCr : %d\n",ret);
+ if (ret == 0)
+ ret = MEDunvCr(fid,maa);
+ printf("MEDunvCr : %d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
+ nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
+ nufano,nnoe,MED_ECRI);
+ printf("MEDnoeudsEcr : %d\n",ret);
+
+
+ /***************************************************************************/
+ /* ecriture des mailles MED_TETRA4 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,tet4,MED_FULL_INTERLACE,
+ nomtet4,MED_FAUX,numtet4,MED_VRAI,nufatet4,ntet4,
+ MED_MAILLE,MED_TETRA4,MED_NOD,MED_ECRI);
+ printf("MEDelementsEcr : %d \n",ret);
+
+ /* ecriture des mailles MED_PYRA5 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,pyra5,MED_FULL_INTERLACE,
+ nompyra5,MED_VRAI,numpyra5,MED_VRAI,nufapyra5,npyra5,
+ MED_MAILLE,MED_PYRA5,MED_NOD,MED_ECRI);
+ printf("MEDelementsEcr : %d \n",ret);
+
+ /* ecriture des mailles MED_HEXA8 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,hexa8,MED_FULL_INTERLACE,
+ nomhexa8,MED_FAUX,numhexa8,MED_VRAI,nufahexa8,nhexa8,
+ MED_MAILLE,MED_HEXA8,MED_NOD,MED_ECRI);
+ printf("MEDelementsEcr : %d \n",ret);
+
+ /***************************************************************************/
+ /* ecriture des familles */
+ /* Conventions :
+ - toujours creer une famille de numero 0 ne comportant aucun attribut
+ ni groupe (famille de reference pour les noeuds ou les elements
+ qui ne sont rattaches a aucun groupe ni attribut)
+ - les numeros de familles de noeuds sont > 0
+ - les numeros de familles des elements sont < 0
+ - rien d'imposer sur les noms de familles
+ */
+
+ /* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+ gro,0);
+ }
+ printf("MEDfamCr : %d \n",ret);
+
+ /* on cree :
+ - 3 familles d'elements (-1,-2,-3) et
+ - 2 familles de noeuds (1,2)
+ */
+ if (ret == 0)
+ {
+ nfame = 3;
+ for (i=0;i<nfame;i++)
+ {
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_ELEMENT_");
+ numfam = -(i+1);
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe1");
+ ngro = 1;
+ /*printf("nomfam : %s - numfam : %d - attide : %d - attval : %d - ngro : %d \n",nomfam,numfam,attide,attval,ngro);*/
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ }
+ }
+
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_NOEUD_1");
+ numfam = 1;
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro2,"groupe2");
+ strcpy(gro2+MED_TAILLE_LNOM,"groupe3");
+ ngro = 2;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro2,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_NOEUD_2");
+ numfam = 2;
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro2,"groupe3");
+ strcpy(gro2+MED_TAILLE_LNOM,"groupe4");
+ ngro = 2;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro2,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_NOEUD_3");
+ numfam = 3;
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro2,"groupe2");
+ strcpy(gro2+MED_TAILLE_LNOM,"groupe4");
+ ngro = 2;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro2,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_NOEUD_4");
+ numfam = 4;
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe5");
+ ngro = 1;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+
+ /***************************************************************************/
+ /*
+ Les champs
+ */
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ1,MED_INT32,champ1_comp,champ1_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ1, (unsigned char *)fieldnodeint,
+ MED_NO_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0., MED_NONOR);
+
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ2,MED_REEL64,champ2_comp,champ2_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+ MED_NO_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, 1,"S ", 1.1 , MED_NONOR);
+ printf("MEDchampEcr1 : %d \n",ret);
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble2,
+ MED_NO_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, 2,"S ", 1.2 , MED_NONOR);
+ printf("MEDchampEcr2 : %d \n",ret);
+ }
+ }
+
+ // on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !
+ if (ret == 0)
+ {
+/* ret = MEDchampCr(fid,champ2,MED_REEL64,champ2_comp,champ2_unit,1); */
+/* printf("MEDchampCr : %d \n",ret); */
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+ MED_NO_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0. , MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ3,MED_REEL64,champ3_comp,champ3_unit,3);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble1,
+ MED_NO_INTERLACE, ntet4,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_TETRA4, MED_NOPDT," ", 0., MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble2,
+ MED_NO_INTERLACE, npyra5,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_PYRA5, MED_NOPDT," ", 0., MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble3,
+ MED_NO_INTERLACE, nhexa8,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ /***************************************************************************/
+ ret = MEDfermer(fid);
+ printf("MEDfermer : %d\n",ret);
+
+ return 0;
+}
+
--- /dev/null
+/*
+ creation d'une geometrie 2d : un cube [0,1]^2
+ maillé uniformement en quadrangle reguliers;
+ avec en plus une partie des aretes (une partie
+ des arretes de la frontiere) du maillage.
+ ATTENTION : 3 noeuds dans chaque direction
+*/
+
+#include <med.h>
+#include <string.h>
+
+int main (int argc, char **argv)
+{
+ med_err ret;
+ med_idt fid;
+ char maa[MED_TAILLE_NOM+1] = "carre_en_quad4_seg2";
+ med_int mdim = 2;
+ med_int nnoe = 9;
+ /*
+ les noeuds:
+ */
+ med_float coo[18] = {
+ 0.0, 0.0,
+ 0.5, 0.0,
+ 1.0, 0.0,
+ 0.0, 0.5,
+ 0.5, 0.5,
+ 1.0, 0.5,
+ 0.0, 1.0,
+ 0.5, 1.0,
+ 1.0, 1.0
+ };
+ char nomcoo[2*MED_TAILLE_PNOM+1] = "x y ";
+ char unicoo[2*MED_TAILLE_PNOM+1] = "cm cm ";
+ /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
+ char *nomnoe ;
+ med_int numnoe[9] = {1,2,3,4,5,6,7,8,9};
+ med_int nufano[9] = {0,0,0,0,0,0,0,0,0};
+ /*
+ les elements:
+ */
+ med_int nquad4 = 4;
+ med_int quad4[16] = {
+ 4, 5, 2, 1,
+ 5, 6, 3, 2,
+ 7, 8, 5, 4,
+ 8, 9, 6, 5
+ };
+ char nomquad4[MED_TAILLE_PNOM*4+1] = "quad1 quad2 quad3 quad4 ";
+ med_int numquad4[4] = {1,2,3,4};
+ med_int nufaquad4[4] = {-10,-10,0,0};
+
+ /*
+ Les Faces qui dans ce cas (2D) sont des arretes
+ */
+
+ med_int nseg2 = 6;
+ med_int seg2[12] = {
+ 6, 3,
+ 8, 9,
+ 3, 2,
+ 9, 6,
+ 2, 5,
+ 5, 8
+ };
+ char nomseg2[MED_TAILLE_PNOM*6+1] = "seg1 seg2 seg3 seg4 seg5 seg6 ";
+ med_int numseg2[6] = {1,2,3,4,5,6};
+ med_int nufaseg2[6] = {-1,-2,-1,-1,-2,-2};
+
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ char attdes[MED_TAILLE_DESC+1];
+ med_int natt;
+ med_int attide;
+ med_int attval;
+ med_int ngro;
+ char gro[MED_TAILLE_LNOM+1];
+ int i;
+ int nfame = 1;
+ int nfamn = 1;
+
+ /*
+ Some fields : 2 on nodes : one int and one double , one on cells : double
+ */
+ char champ1[MED_TAILLE_NOM+1]="fieldnodeint" ;
+ char champ1_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champ1_unit[MED_TAILLE_PNOM+1]="M " ;
+ med_int fieldnodeint[9] = {1,1,3,2,2,3,4,4,5};
+
+ char champ2[MED_TAILLE_NOM+1]="fieldnodedouble" ;
+ char champ2_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champ2_unit[MED_TAILLE_PNOM+1]="J " ;
+ med_float fieldnodedouble1[9] = {1.,3.,4.,1.,3.,4.,3.,2.,5.};
+ med_float fieldnodedouble2[9] = {1.,2.,2.,3.,3.,3.,4.,4.,5.};
+
+ char champ3[MED_TAILLE_NOM+1]="fieldcelldouble" ;
+ char champ3_comp[MED_TAILLE_PNOM*2+1]="comp1 comp2 " ;
+ char champ3_unit[MED_TAILLE_PNOM*2+1]="M/S m/s " ;
+ med_float fieldcelldouble[4*2] = {0.,1.,1.,1.,1.,2.,2.,3.};
+
+ /***************************************************************************/
+ fid = MEDouvrir("carre_en_quad4_seg2.med",MED_REMP);
+ if (fid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDmaaCr(fid,maa,mdim);
+ printf("%d\n",ret);
+ if (ret == 0)
+ ret = MEDunvCr(fid,maa);
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
+ nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
+ nufano,nnoe,MED_ECRI);
+ printf("%d\n",ret);
+
+ /* ecriture des mailles MED_QUAD4 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE,
+ nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4,
+ MED_MAILLE,MED_QUAD4,MED_NOD,MED_ECRI);
+ printf("%d \n",ret);
+
+ /* ecriture des mailles MED_SEG2 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,seg2,MED_FULL_INTERLACE,
+ nomseg2,MED_FAUX,numseg2,MED_VRAI,nufaseg2,nseg2,
+ MED_ARETE,MED_SEG2,MED_NOD,MED_ECRI);
+ printf("%d \n",ret);
+
+ /***************************************************************************/
+ /* ecriture des familles */
+ /* Conventions :
+ - toujours creer une famille de numero 0 ne comportant aucun attribut
+ ni groupe (famille de reference pour les noeuds ou les elements
+ qui ne sont rattaches a aucun groupe ni attribut)
+ - les numeros de familles de noeuds sont > 0
+ - les numeros de familles des elements sont < 0
+ - rien d'imposer sur les noms de familles
+ */
+
+ /* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+ gro,0);
+ }
+ printf("%d \n",ret);
+
+ /* on cree :
+ - 1 familles d'elements de dimension (d-1)
+ en fait de edge (-1)
+ - 1 familles d'elements de dimension (d-1)
+ en fait de edge (-2)
+ - 1 familles d'elements de dimension (d)
+ en fait de face (-10)
+ */
+
+ if (ret == 0)
+ {
+ numfam = -1;
+ strcpy(nomfam,"FAMILLE_EDGE_");
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe1");
+ ngro = 1;
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ if (ret == 0)
+ {
+ numfam = -2;
+ strcpy(nomfam,"FAMILLE_EDGE_");
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe1");
+ ngro = 1;
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ if (ret == 0)
+ {
+ numfam = -10;
+ strcpy(nomfam,"FAMILLE_CELL_");
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe0");
+ ngro = 1;
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ /***************************************************************************/
+ /*
+ Les champs
+ */
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ1,MED_INT32,champ1_comp,champ1_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ1, (unsigned char *)fieldnodeint,
+ MED_NO_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0., MED_NONOR);
+
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ2,MED_REEL64,champ2_comp,champ2_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+ MED_NO_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, 1,"S ", 1.1 , MED_NONOR);
+ printf("MEDchampEcr1 : %d \n",ret);
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble2,
+ MED_NO_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, 2,"S ", 1.2 , MED_NONOR);
+ printf("MEDchampEcr2 : %d \n",ret);
+ }
+ }
+
+ // on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+ MED_NO_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0. , MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ3,MED_REEL64,champ3_comp,champ3_unit,2);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble,
+ MED_NO_INTERLACE, nquad4,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_QUAD4, MED_NOPDT," ", 0., MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ /***************************************************************************/
+
+ ret = MEDfermer(fid);
+ printf("%d\n",ret);
+
+ return 0;
+}
+
--- /dev/null
+/*
+ creation d'une geometrie 2d : un cube [0,1]^2
+ maillé uniformement en quadrangle reguliers;
+ avec en plus une partie des aretes (une partie
+ des arretes de la frontiere) du maillage.
+ ATTENTION : 3 noeuds dans chaque direction
+*/
+
+#include <med.h>
+#include <string.h>
+
+int main (int argc, char **argv)
+{
+ med_err ret;
+ med_idt fid;
+ char maa[MED_TAILLE_NOM+1] = "carre_en_quad4_seg2_wrong";
+ med_int mdim = 2;
+ med_int nnoe = 9;
+ /*
+ les noeuds:
+ */
+ med_float coo[18] = {
+ 0.0, 0.0,
+ 0.5, 0.0,
+ 1.0, 0.0,
+ 0.0, 0.5,
+ 0.5, 0.5,
+ 1.0, 0.5,
+ 0.0, 1.0,
+ 0.5, 1.0,
+ 1.0, 1.0
+ };
+ char nomcoo[2*MED_TAILLE_PNOM+1] = "x y ";
+ char unicoo[2*MED_TAILLE_PNOM+1] = "cm cm ";
+ /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
+ char *nomnoe ;
+ med_int numnoe[9] = {1,2,3,4,5,6,7,8,9};
+ med_int nufano[9] = {0,0,0,0,0,0,0,0,0};
+ /*
+ les elements:
+ */
+ med_int nquad4 = 4;
+ med_int quad4[16] = {
+ 4, 5, 2, 1,
+ 5, 6, 3, 2,
+ 7, 8, 5, 4,
+ 8, 9, 6, 5
+ };
+ char nomquad4[MED_TAILLE_PNOM*4+1] = "quad1 quad2 quad3 quad4 ";
+ med_int numquad4[4] = {1,2,3,4};
+ med_int nufaquad4[4] = {-10,-10,0,0};
+
+ /*
+ Les Faces qui dans ce cas (2D) sont des arretes
+
+ a face is wrongly oriented, it is just to test the applidation
+ duplicateMEDMESH
+ */
+
+ med_int nseg2 = 6;
+ med_int seg2[12] = {
+ 6, 3,
+ 8, 9,
+ 3, 2,
+ /*9, 6,*/
+ 6, 9,
+ 2, 5,
+ 5, 8
+ };
+ char nomseg2[MED_TAILLE_PNOM*6+1] = "seg1 seg2 seg3 seg4 seg5 seg6 ";
+ med_int numseg2[6] = {1,2,3,4,5,6};
+ med_int nufaseg2[6] = {-1,-2,-1,-1,-2,-2};
+
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ char attdes[MED_TAILLE_DESC+1];
+ med_int natt;
+ med_int attide;
+ med_int attval;
+ med_int ngro;
+ char gro[MED_TAILLE_LNOM+1];
+ int i;
+ int nfame = 1;
+ int nfamn = 1;
+
+ /*
+ Some fields : 2 on nodes : one int and one double , one on cells : double
+ */
+ char champ1[MED_TAILLE_NOM+1]="fieldnodeint" ;
+ char champ1_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champ1_unit[MED_TAILLE_PNOM+1]="M " ;
+ med_int fieldnodeint[9] = {1,1,3,2,2,3,4,4,5};
+
+ char champ2[MED_TAILLE_NOM+1]="fieldnodedouble" ;
+ char champ2_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champ2_unit[MED_TAILLE_PNOM+1]="J " ;
+ med_float fieldnodedouble1[9] = {1.,3.,4.,1.,3.,4.,3.,2.,5.};
+ med_float fieldnodedouble2[9] = {1.,2.,2.,3.,3.,3.,4.,4.,5.};
+
+ char champ3[MED_TAILLE_NOM+1]="fieldcelldouble" ;
+ char champ3_comp[MED_TAILLE_PNOM*2+1]="comp1 comp2 " ;
+ char champ3_unit[MED_TAILLE_PNOM*2+1]="M/S m/s " ;
+ med_float fieldcelldouble[4*2] = {0.,1.,1.,1.,1.,2.,2.,3.};
+
+ /***************************************************************************/
+ fid = MEDouvrir("carre_en_quad4_seg2_wrong.med",MED_REMP);
+ if (fid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDmaaCr(fid,maa,mdim);
+ printf("%d\n",ret);
+ if (ret == 0)
+ ret = MEDunvCr(fid,maa);
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
+ nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
+ nufano,nnoe,MED_ECRI);
+ printf("%d\n",ret);
+
+ /* ecriture des mailles MED_QUAD4 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE,
+ nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4,
+ MED_MAILLE,MED_QUAD4,MED_NOD,MED_ECRI);
+ printf("%d \n",ret);
+
+ /* ecriture des mailles MED_SEG2 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,seg2,MED_FULL_INTERLACE,
+ nomseg2,MED_FAUX,numseg2,MED_VRAI,nufaseg2,nseg2,
+ MED_ARETE,MED_SEG2,MED_NOD,MED_ECRI);
+ printf("%d \n",ret);
+
+ /***************************************************************************/
+ /* ecriture des familles */
+ /* Conventions :
+ - toujours creer une famille de numero 0 ne comportant aucun attribut
+ ni groupe (famille de reference pour les noeuds ou les elements
+ qui ne sont rattaches a aucun groupe ni attribut)
+ - les numeros de familles de noeuds sont > 0
+ - les numeros de familles des elements sont < 0
+ - rien d'imposer sur les noms de familles
+ */
+
+ /* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+ gro,0);
+ }
+ printf("%d \n",ret);
+
+ /* on cree :
+ - 1 familles d'elements de dimension (d-1)
+ en fait de edge (-1)
+ - 1 familles d'elements de dimension (d-1)
+ en fait de edge (-2)
+ - 1 familles d'elements de dimension (d)
+ en fait de face (-10)
+ */
+
+ if (ret == 0)
+ {
+ numfam = -1;
+ strcpy(nomfam,"FAMILLE_EDGE_");
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe1");
+ ngro = 1;
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ if (ret == 0)
+ {
+ numfam = -2;
+ strcpy(nomfam,"FAMILLE_EDGE_");
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe1");
+ ngro = 1;
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ if (ret == 0)
+ {
+ numfam = -10;
+ strcpy(nomfam,"FAMILLE_CELL_");
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe0");
+ ngro = 1;
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ /***************************************************************************/
+ /*
+ Les champs
+ */
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ1,MED_INT32,champ1_comp,champ1_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ1, (unsigned char *)fieldnodeint,
+ MED_NO_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0., MED_NONOR);
+
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ2,MED_REEL64,champ2_comp,champ2_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+ MED_NO_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, 1,"S ", 1.1 , MED_NONOR);
+ printf("MEDchampEcr1 : %d \n",ret);
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble2,
+ MED_NO_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, 2,"S ", 1.2 , MED_NONOR);
+ printf("MEDchampEcr2 : %d \n",ret);
+ }
+ }
+
+ // on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+ MED_NO_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0. , MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ3,MED_REEL64,champ3_comp,champ3_unit,2);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble,
+ MED_NO_INTERLACE, nquad4,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_QUAD4, MED_NOPDT," ", 0., MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ /***************************************************************************/
+
+ ret = MEDfermer(fid);
+ printf("%d\n",ret);
+
+ return 0;
+}
+
--- /dev/null
+/*
+ creation d'une geometrie 3d : un cube [0,1]^3
+ maillé uniformement en hexahedres reguliers;
+ avec en plus une partie des faces (une partie
+ des faces de la frontiere) du maillage.
+ ATTENTION : 3 noeuds dans chaque direction
+*/
+
+#include <med.h>
+#include <string.h>
+
+int main (int argc, char **argv)
+{
+ med_err ret;
+ med_idt fid;
+ char maa[MED_TAILLE_NOM+1] = "CUBE_EN_HEXA8_QUAD4";
+ med_int mdim = 3;
+ med_int nnoe = 27;
+ /*
+ les noeuds:
+ */
+ med_float coo[81] = {
+ 0.0, 0.0, 0.0,
+ 0.5, 0.0, 0.0,
+ 1.0, 0.0, 0.0,
+ 0.0, 0.5, 0.0,
+ 0.5, 0.5, 0.0,
+ 1.0, 0.5, 0.0,
+ 0.0, 1.0, 0.0,
+ 0.5, 1.0, 0.0,
+ 1.0, 1.0, 0.0,
+ 0.0, 0.0, 0.5,
+ 0.5, 0.0, 0.5,
+ 1.0, 0.0, 0.5,
+ 0.0, 0.5, 0.5,
+ 0.5, 0.5, 0.5,
+ 1.0, 0.5, 0.5,
+ 0.0, 1.0, 0.5,
+ 0.5, 1.0, 0.5,
+ 1.0, 1.0, 0.5,
+ 0.0, 0.0, 1.0,
+ 0.5, 0.0, 1.0,
+ 1.0, 0.0, 1.0,
+ 0.0, 0.5, 1.0,
+ 0.5, 0.5, 1.0,
+ 1.0, 0.5, 1.0,
+ 0.0, 1.0, 1.0,
+ 0.5, 1.0, 1.0,
+ 1.0, 1.0, 1.0
+ };
+ char nomcoo[3*MED_TAILLE_PNOM+1] = "x y z ";
+ char unicoo[3*MED_TAILLE_PNOM+1] = "cm cm cm ";
+ /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
+ char *nomnoe ;
+ med_int numnoe[27] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27};
+ med_int nufano[27] = {1,1,1,1,1,1,1,1,1,3,3,3,3,0,3,3,3,3,2,2,2,2,2,2,2,2,2};
+ /*
+ les elements:
+ */
+ med_int nhexa8 = 8;
+ med_int hexa8[64] = {
+ 4, 13, 14, 5, 1, 10, 11, 2,
+ 5, 14, 15, 6, 2, 11, 12, 3,
+ 7, 16, 17, 8, 4, 13, 14, 5,
+ 8, 17, 18, 9, 5, 14, 15, 6,
+ 13, 22, 23, 14, 10, 19, 20, 11,
+ 14, 23, 24, 15, 11, 20, 21, 12,
+ 16, 25, 26, 17, 13, 22, 23, 14,
+ 17, 26, 27, 18, 14, 23, 24, 15
+ };
+ char nomhexa8[MED_TAILLE_PNOM*8+1] = "hexa1 hexa2 hexa3 hexa4 hexa5 hexa6 hexa7 hexa8 ";
+ med_int numhexa8[8] = {1,2,3,4,5,6,7,8};
+ med_int nufahexa8[8] = {-1,-1,-1,-1,-2,-2,-2,-2};
+
+ /*
+ Les Faces qui dans ce cas (2D) sont des arretes
+ */
+
+ med_int nquad4 = 8;
+ med_int quad4[32] = {
+ 20, 21, 24, 23,
+ 22, 23, 26, 25,
+ 19, 20, 23, 22,
+ 23, 24, 27, 26,
+ 1 , 4, 5, 2,
+ 5, 8, 9, 6,
+ 2, 5, 6, 3,
+ 7, 8, 5, 4
+ };
+
+ char nomquad4[MED_TAILLE_PNOM*8+1] = "quad1 quad2 quad3 quad4 quad5 quad6 quad7 quad8 ";
+ med_int numquad4[8] = {1,2,3,4,5,6,7,8};
+ med_int nufaquad4[8] = {-3,-3,-3,-3,-4, -4, -4 , -4};
+
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ char attdes[MED_TAILLE_DESC+1];
+ med_int natt;
+ med_int attide;
+ med_int attval;
+ med_int ngro;
+ char gro[MED_TAILLE_LNOM+1];
+ int i;
+ int nfame = 1;
+ int nfamn = 1;
+ int nfamf = 1;
+
+ /*
+ Some fields : 2 on nodes : one int and one double , one on cells : double
+ */
+
+ char champ1[MED_TAILLE_NOM+1]="fieldnodeint" ;
+ char champ1_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champ1_unit[MED_TAILLE_PNOM+1]="M " ;
+ med_int fieldnodeint[27] = {1,1,3,2,2,3,4,4,5,1,1,3,2,2,3,4,4,5,1,1,3,2,2,3,4,4,5};
+
+ char champ2[MED_TAILLE_NOM+1]="fieldnodedouble" ;
+ char champ2_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champ2_unit[MED_TAILLE_PNOM+1]="J " ;
+ med_float fieldnodedouble1[27] = {1.,3.,4.,1.,3.,4.,3.,2.,5.,1.,3.,4.,1.,3.,4.,3.,2.,5.,1.,3.,4.,1.,3.,4.,3.,2.,5.};
+ med_float fieldnodedouble2[27] = {1.,2.,2.,3.,3.,3.,4.,4.,5.,1.,2.,2.,3.,3.,3.,4.,4.,5.,1.,2.,2.,3.,3.,3.,4.,4.,5.};
+
+ char champ3[MED_TAILLE_NOM+1]="fieldcelldouble" ;
+ char champ3_comp[MED_TAILLE_PNOM*3+1]="comp1 comp2 comp3 " ;
+ char champ3_unit[MED_TAILLE_PNOM*3+1]="M/S m/s m/s " ;
+ med_float fieldcelldouble[8*3] = {0.,1.,1.,1.,1.,2.,2.,3.,0.,1.,1.,1.,1.,2.,2.,3.,0.,1.,1.,1.,1.,2.,2.,3.};
+
+ /***************************************************************************/
+ fid = MEDouvrir("cube_hexa8_quad4.med",MED_REMP);
+ if (fid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDmaaCr(fid,maa,mdim);
+ printf("%d\n",ret);
+ if (ret == 0)
+ ret = MEDunvCr(fid,maa);
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
+ nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
+ nufano,nnoe,MED_ECRI);
+ printf("%d\n",ret);
+
+ /* ecriture des mailles MED_HEXA8 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,hexa8,MED_FULL_INTERLACE,
+ nomhexa8,MED_FAUX,numhexa8,MED_VRAI,nufahexa8,nhexa8,
+ MED_MAILLE,MED_HEXA8,MED_NOD,MED_ECRI);
+ printf("%d \n",ret);
+
+ /* ecriture des mailles MED_QUAD4 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE,
+ nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4,
+ MED_FACE,MED_QUAD4,MED_NOD,MED_ECRI);
+ printf("%d \n",ret);
+
+ /***************************************************************************/
+ /* ecriture des familles */
+ /* Conventions :
+ - toujours creer une famille de numero 0 ne comportant aucun attribut
+ ni groupe (famille de reference pour les noeuds ou les elements
+ qui ne sont rattaches a aucun groupe ni attribut)
+ - les numeros de familles de noeuds sont > 0
+ - les numeros de familles des elements sont < 0
+ - rien d'imposer sur les noms de familles
+ */
+
+ /* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+ gro,0);
+ }
+ printf("%d \n",ret);
+
+ /* on cree :
+ - 2 familles d'elements (-1,-2) et
+ - 3 familles de noeuds (1,2,3)
+ - 1 famille(s) d'elements de dimension (d-1)
+ en fait de face (-3)
+ */
+
+ if (ret == 0)
+ {
+ nfame = 2;
+ for (i=0;i<nfame;i++)
+ {
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_ELEMENT_");
+ numfam = -(i+1);
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe1");
+ ngro = 1;
+
+ /*printf("nomfam : %s - numfam : %d - attide : %d - attval : %d - ngro : %d \n",nomfam,numfam,attide,attval,ngro);*/
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ }
+ }
+
+ if (ret == 0)
+ {
+ nfamn = 3;
+ for (i=0;i<nfamn;i++)
+ {
+ if(ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_NOEUD_");
+ numfam = i+1;
+ sprintf(nomfam,"%s%d",nomfam,numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe2");
+ ngro = 1;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ }
+ }
+
+ if (ret == 0)
+ {
+ nfamf = 2;
+ for (i=0;i<nfamf;i++)
+ {
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_FACE_");
+ numfam = -(i+3);
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe3");
+ ngro = 1;
+ /*printf("nomfam : %s - numfam : %d - attide : %d - attval : %d - ngro : %d \n",nomfam,numfam,attide,attval,ngro);*/
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ }
+ }
+
+ /***************************************************************************/
+ /*
+ Les champs
+ */
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ1,MED_INT32,champ1_comp,champ1_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ1, (unsigned char *)fieldnodeint,
+ MED_FULL_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0., MED_NONOR);
+
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ2,MED_REEL64,champ2_comp,champ2_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+ MED_FULL_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, 1,"S ", 1.1 , MED_NONOR);
+ printf("MEDchampEcr1 : %d \n",ret);
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble2,
+ MED_FULL_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, 2,"S ", 1.2 , MED_NONOR);
+ printf("MEDchampEcr2 : %d \n",ret);
+ }
+ }
+
+ // on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+ MED_FULL_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0. , MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ3,MED_REEL64,champ3_comp,champ3_unit,3);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble,
+ MED_FULL_INTERLACE, nhexa8,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ /***************************************************************************/
+
+ ret = MEDfermer(fid);
+ printf("%d\n",ret);
+
+ return 0;
+}
+
--- /dev/null
+/*
+ creation d'une geometrie 3d : un cube [0,1]^3
+ maillé uniformement en hexahedres reguliers;
+ avec en plus une partie des faces (une partie
+ des faces de la frontiere) du maillage.
+ ATTENTION : 3 noeuds dans chaque direction
+*/
+
+#include <med.h>
+#include <string.h>
+
+int main (int argc, char **argv)
+{
+ med_err ret;
+ med_idt fid;
+ char maa[MED_TAILLE_NOM+1] = "CUBE_EN_HEXA8_QUAD4_WRONG";
+ med_int mdim = 3;
+ med_int nnoe = 27;
+ /*
+ les noeuds:
+ */
+ med_float coo[81] = {
+ 0.0, 0.0, 0.0,
+ 0.5, 0.0, 0.0,
+ 1.0, 0.0, 0.0,
+ 0.0, 0.5, 0.0,
+ 0.5, 0.5, 0.0,
+ 1.0, 0.5, 0.0,
+ 0.0, 1.0, 0.0,
+ 0.5, 1.0, 0.0,
+ 1.0, 1.0, 0.0,
+ 0.0, 0.0, 0.5,
+ 0.5, 0.0, 0.5,
+ 1.0, 0.0, 0.5,
+ 0.0, 0.5, 0.5,
+ 0.5, 0.5, 0.5,
+ 1.0, 0.5, 0.5,
+ 0.0, 1.0, 0.5,
+ 0.5, 1.0, 0.5,
+ 1.0, 1.0, 0.5,
+ 0.0, 0.0, 1.0,
+ 0.5, 0.0, 1.0,
+ 1.0, 0.0, 1.0,
+ 0.0, 0.5, 1.0,
+ 0.5, 0.5, 1.0,
+ 1.0, 0.5, 1.0,
+ 0.0, 1.0, 1.0,
+ 0.5, 1.0, 1.0,
+ 1.0, 1.0, 1.0
+ };
+ char nomcoo[3*MED_TAILLE_PNOM+1] = "x y z ";
+ char unicoo[3*MED_TAILLE_PNOM+1] = "cm cm cm ";
+ /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
+ char *nomnoe ;
+ med_int numnoe[27] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27};
+ med_int nufano[27] = {1,1,1,1,1,1,1,1,1,3,3,3,3,0,3,3,3,3,2,2,2,2,2,2,2,2,2};
+ /*
+ les elements:
+ */
+ med_int nhexa8 = 8;
+ med_int hexa8[64] = {
+ 4, 13, 14, 5, 1, 10, 11, 2,
+ 5, 14, 15, 6, 2, 11, 12, 3,
+ 7, 16, 17, 8, 4, 13, 14, 5,
+ 8, 17, 18, 9, 5, 14, 15, 6,
+ 13, 22, 23, 14, 10, 19, 20, 11,
+ 14, 23, 24, 15, 11, 20, 21, 12,
+ 16, 25, 26, 17, 13, 22, 23, 14,
+ 17, 26, 27, 18, 14, 23, 24, 15
+ };
+ char nomhexa8[MED_TAILLE_PNOM*8+1] = "hexa1 hexa2 hexa3 hexa4 hexa5 hexa6 hexa7 hexa8 ";
+ med_int numhexa8[8] = {1,2,3,4,5,6,7,8};
+ med_int nufahexa8[8] = {-1,-1,-1,-1,-2,-2,-2,-2};
+
+ /*
+ Les Faces qui dans ce cas (2D) sont des arretes
+
+ a face is wrongly oriented, it is just to test the applidation
+ duplicateMEDMESH
+ */
+
+ med_int nquad4 = 8;
+ med_int quad4[32] = {
+ 20, 21, 24, 23,
+ 22, 23, 26, 25,
+ 19, 20, 23, 22,
+ 23, 24, 27, 26,
+ /*1 , 4, 5, 2,*/
+ 1 , 2, 5, 4,
+ 5, 8, 9, 6,
+ 2, 5, 6, 3,
+ 7, 8, 5, 4
+ };
+
+ char nomquad4[MED_TAILLE_PNOM*8+1] = "quad1 quad2 quad3 quad4 quad5 quad6 quad7 quad8 ";
+ med_int numquad4[8] = {1,2,3,4,5,6,7,8};
+ med_int nufaquad4[8] = {-3,-3,-3,-3,-4, -4, -4 , -4};
+
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ char attdes[MED_TAILLE_DESC+1];
+ med_int natt;
+ med_int attide;
+ med_int attval;
+ med_int ngro;
+ char gro[MED_TAILLE_LNOM+1];
+ int i;
+ int nfame = 1;
+ int nfamn = 1;
+ int nfamf = 1;
+
+ /*
+ Some fields : 2 on nodes : one int and one double , one on cells : double
+ */
+
+ char champ1[MED_TAILLE_NOM+1]="fieldnodeint" ;
+ char champ1_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champ1_unit[MED_TAILLE_PNOM+1]="M " ;
+ med_int fieldnodeint[27] = {1,1,3,2,2,3,4,4,5,1,1,3,2,2,3,4,4,5,1,1,3,2,2,3,4,4,5};
+
+ char champ2[MED_TAILLE_NOM+1]="fieldnodedouble" ;
+ char champ2_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champ2_unit[MED_TAILLE_PNOM+1]="J " ;
+ med_float fieldnodedouble1[27] = {1.,3.,4.,1.,3.,4.,3.,2.,5.,1.,3.,4.,1.,3.,4.,3.,2.,5.,1.,3.,4.,1.,3.,4.,3.,2.,5.};
+ med_float fieldnodedouble2[27] = {1.,2.,2.,3.,3.,3.,4.,4.,5.,1.,2.,2.,3.,3.,3.,4.,4.,5.,1.,2.,2.,3.,3.,3.,4.,4.,5.};
+
+ char champ3[MED_TAILLE_NOM+1]="fieldcelldouble" ;
+ char champ3_comp[MED_TAILLE_PNOM*3+1]="comp1 comp2 comp3 " ;
+ char champ3_unit[MED_TAILLE_PNOM*3+1]="M/S m/s m/s " ;
+ med_float fieldcelldouble[8*3] = {0.,1.,1.,1.,1.,2.,2.,3.,0.,1.,1.,1.,1.,2.,2.,3.,0.,1.,1.,1.,1.,2.,2.,3.};
+
+ /***************************************************************************/
+ fid = MEDouvrir("cube_hexa8_quad4_wrong.med",MED_REMP);
+ if (fid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDmaaCr(fid,maa,mdim);
+ printf("%d\n",ret);
+ if (ret == 0)
+ ret = MEDunvCr(fid,maa);
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
+ nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
+ nufano,nnoe,MED_ECRI);
+ printf("%d\n",ret);
+
+ /* ecriture des mailles MED_HEXA8 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,hexa8,MED_FULL_INTERLACE,
+ nomhexa8,MED_FAUX,numhexa8,MED_VRAI,nufahexa8,nhexa8,
+ MED_MAILLE,MED_HEXA8,MED_NOD,MED_ECRI);
+ printf("%d \n",ret);
+
+ /* ecriture des mailles MED_QUAD4 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE,
+ nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4,
+ MED_FACE,MED_QUAD4,MED_NOD,MED_ECRI);
+ printf("%d \n",ret);
+
+ /***************************************************************************/
+ /* ecriture des familles */
+ /* Conventions :
+ - toujours creer une famille de numero 0 ne comportant aucun attribut
+ ni groupe (famille de reference pour les noeuds ou les elements
+ qui ne sont rattaches a aucun groupe ni attribut)
+ - les numeros de familles de noeuds sont > 0
+ - les numeros de familles des elements sont < 0
+ - rien d'imposer sur les noms de familles
+ */
+
+ /* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+ gro,0);
+ }
+ printf("%d \n",ret);
+
+ /* on cree :
+ - 2 familles d'elements (-1,-2) et
+ - 3 familles de noeuds (1,2,3)
+ - 1 famille(s) d'elements de dimension (d-1)
+ en fait de face (-3)
+ */
+
+ if (ret == 0)
+ {
+ nfame = 2;
+ for (i=0;i<nfame;i++)
+ {
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_ELEMENT_");
+ numfam = -(i+1);
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe1");
+ ngro = 1;
+
+ /*printf("nomfam : %s - numfam : %d - attide : %d - attval : %d - ngro : %d \n",nomfam,numfam,attide,attval,ngro);*/
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ }
+ }
+
+ if (ret == 0)
+ {
+ nfamn = 3;
+ for (i=0;i<nfamn;i++)
+ {
+ if(ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_NOEUD_");
+ numfam = i+1;
+ sprintf(nomfam,"%s%d",nomfam,numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe2");
+ ngro = 1;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ }
+ }
+
+ if (ret == 0)
+ {
+ nfamf = 2;
+ for (i=0;i<nfamf;i++)
+ {
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_FACE_");
+ numfam = -(i+3);
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe3");
+ ngro = 1;
+ /*printf("nomfam : %s - numfam : %d - attide : %d - attval : %d - ngro : %d \n",nomfam,numfam,attide,attval,ngro);*/
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ }
+ }
+
+ /***************************************************************************/
+ /*
+ Les champs
+ */
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ1,MED_INT32,champ1_comp,champ1_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ1, (unsigned char *)fieldnodeint,
+ MED_FULL_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0., MED_NONOR);
+
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ2,MED_REEL64,champ2_comp,champ2_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+ MED_FULL_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, 1,"S ", 1.1 , MED_NONOR);
+ printf("MEDchampEcr1 : %d \n",ret);
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble2,
+ MED_FULL_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, 2,"S ", 1.2 , MED_NONOR);
+ printf("MEDchampEcr2 : %d \n",ret);
+ }
+ }
+
+ // on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+ MED_FULL_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0. , MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ3,MED_REEL64,champ3_comp,champ3_unit,3);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble,
+ MED_FULL_INTERLACE, nhexa8,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ /***************************************************************************/
+
+ ret = MEDfermer(fid);
+ printf("%d\n",ret);
+
+ return 0;
+}
+
--- /dev/null
+#include<string>
+#include<deque>
+
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_Med.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Field.hxx"
+
+#include "MEDMEM_GenDriver.hxx"
+#include "MEDMEM_MedMedDriver.hxx"
+#include "MEDMEM_MedMeshDriver.hxx"
+#include "MEDMEM_MedFieldDriver.hxx"
+
+
+void usage(char * name)
+{
+ cout << " " << name << " <input med file> <output med file> " <<endl ;
+ cout << " " << "(the two file name are mandatory)" << endl ;
+ exit(-1);
+}
+
+int main (int argc, char ** argv) {
+
+ if (argc != 3) usage(argv[0]);
+
+ string filenameIN = argv[1] ;
+ string filenameOUT = argv[2] ;
+
+ MED * myMed = new MED() ;
+ MED_MED_DRIVER myMedDriver(filenameIN,myMed) ;
+
+ // we read all meshes and fields in filenameIN
+ try {
+
+ int read ;
+ myMedDriver.open();
+ myMedDriver.readFileStruct();
+ myMedDriver.close();
+
+ // read all mesh
+ MESSAGE("Read all meshes :") ;
+ int NumberOfMeshes = myMed->getNumberOfMeshes() ;
+ MESSAGE("Number of meshes : "<<NumberOfMeshes) ;
+ deque<string> MeshName = myMed->getMeshNames() ;
+ map<string,MESH*> _meshes ;
+ for (int i=0; i<NumberOfMeshes; i++) {
+ _meshes[MeshName[i]]=myMed->getMesh(MeshName[i]) ;
+ _meshes[MeshName[i]]->read();
+ MESSAGE(" - Mesh "<<i+1<<", named "<<MeshName[i]<<" read !");
+ MED_MESH_WRONLY_DRIVER myMeshDriver(filenameOUT,_meshes[MeshName[i]]);
+ myMeshDriver.setMeshName(MeshName[i]);
+ myMeshDriver.open() ;
+ myMeshDriver.write() ;
+ myMeshDriver.close() ;
+ }
+
+ // set support : support must be calculated with mesh information !!!
+ myMed->updateSupport() ;
+
+ // read all field
+ MESSAGE("Read all fields :") ;
+ int NumberOfFields = myMed->getNumberOfFields() ;
+ MESSAGE("Number of fields : "<<NumberOfFields);
+ deque<string> FieldName = myMed->getFieldNames() ;
+ map<string,FIELD_*> _fields ;
+ for (int i=0; i<NumberOfFields; i++) {
+ deque<DT_IT_> FieldIteration = myMed->getFieldIteration(FieldName[i]) ;
+ MESSAGE(" - Field "<<i+1<<", named "<<FieldName[i]<<" :");
+ int NumberOfIteration = FieldIteration.size() ;
+ MESSAGE(" Number of iteration pair : "<<NumberOfIteration);
+ for (int j=0; j<NumberOfIteration; j++) {
+ MESSAGE(" FieldName[i] "<<FieldName[i]<<",Iteration "<< FieldIteration[j].dt<<", order number "<<FieldIteration[j].it<<" j="<<j<<",i="<<i<<" :");
+ FIELD_ * myField = myMed->getField(FieldName[i],FieldIteration[j].dt,FieldIteration[j].it) ;
+
+ med_type_champ type = myField->getValueType() ;
+ switch (type) {
+ case MED_FR::MED_INT32: {
+ // if (type == MED_FR::MED_INT32) {
+ MESSAGE(" * Field named "<<((FIELD<int>*)myField)->getName());
+ ((FIELD<int>*)myField)->read() ;
+ MESSAGE(" * Iteration "<<FieldIteration[j].dt<<", order number "<<FieldIteration[j].it<<" read !");
+ MED_FIELD_WRONLY_DRIVER<int> myFieldDriver(filenameOUT,(FIELD<int>*)myField);
+ myFieldDriver.setFieldName(FieldName[i]);
+ myFieldDriver.open() ;
+ myFieldDriver.write() ;
+ myFieldDriver.close() ;
+ break ;
+ }
+ // else
+ case MED_FR::MED_REEL64: {
+ // if (type == MED_FR::MED_REEL64) {
+ FIELD<double>* myField2 = (FIELD<double>*)myField ;
+ MESSAGE(" * Field named "<<myField2->getName());
+ myField2->read() ;
+ MESSAGE(" * Iteration "<<FieldIteration[j].dt<<", order number "<<FieldIteration[j].it<<" read !");
+ MED_FIELD_WRONLY_DRIVER<double> myFieldDriver(filenameOUT,myField2);
+ myFieldDriver.setFieldName(FieldName[i]);
+ myFieldDriver.open() ;
+ myFieldDriver.write() ;
+ myFieldDriver.close() ;
+ break ;
+ }
+ // else {
+ default: {
+ MESSAGE(" * Iteration "<<FieldIteration[j].dt<<", order number "<<FieldIteration[j].it<<" not read : wrond type "<<type);
+ break ;
+ }
+ }
+ }
+ }
+ } catch (MEDEXCEPTION& ex){
+ MESSAGE(ex.what()) ;
+ }
+
+ // we write all in file filenameOUT :
+// try {
+
+// MED_MED_DRIVER myMedDriverOUT("/tmp/test.med",myMed) ;
+// myMedDriverOUT.open() ;
+// myMedDriverOUT.write() ;
+// myMedDriverOUT.close() ;
+// } catch (MEDEXCEPTION& ex){
+// MESSAGE(ex.what()) ;
+// }
+
+ delete myMed ;
+
+}
--- /dev/null
+#include<string>
+#include<deque>
+
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_Med.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Support.hxx"
+
+#include "MEDMEM_GenDriver.hxx"
+#include "MEDMEM_MedMedDriver.hxx"
+#include "MEDMEM_MedMeshDriver.hxx"
+
+int main (int argc, char ** argv) {
+
+ string filenameIN = argv[1] ;
+ string filenameOUT = argv[2] ;
+
+ MED * myMed = new MED() ;
+ MED_MED_DRIVER myMedDriver(filenameIN,myMed) ;
+
+ // we read all meshes in filenameIN
+ try {
+
+ int read ;
+ myMedDriver.open();
+ myMedDriver.readFileStruct();
+ myMedDriver.close();
+
+ // read all mesh
+ MESSAGE("Read all meshes :") ;
+ int NumberOfMeshes = myMed->getNumberOfMeshes() ;
+ MESSAGE("Number of meshes : "<<NumberOfMeshes) ;
+ deque<string> MeshName = myMed->getMeshNames() ;
+ map<string,MESH*> _meshes ;
+ for (int i=0; i<NumberOfMeshes; i++) {
+ _meshes[MeshName[i]]=myMed->getMesh(MeshName[i]) ;
+ _meshes[MeshName[i]]->read();
+ MESSAGE(" - Mesh "<<i+1<<", named "<<MeshName[i]<<" read !");
+ MED_MESH_WRONLY_DRIVER myMeshDriver(filenameOUT,_meshes[MeshName[i]]);
+ MESSAGE("After declaration of MED_MESH_DRIVER");
+ myMeshDriver.setMeshName(MeshName[i]);
+ MESSAGE("After setMeshName");
+ myMeshDriver.open() ;
+ MESSAGE("After open");
+ myMeshDriver.write() ;
+ MESSAGE("After write");
+ myMeshDriver.close() ;
+ MESSAGE("After close");
+ }
+
+ // set support : support must be calculated with mesh information !!!
+ myMed->updateSupport() ;
+
+ } catch (MEDEXCEPTION& ex){
+ MESSAGE(ex.what()) ;
+ }
+}
--- /dev/null
+#include<string>
+
+#include <math.h>
+#include <stdlib.h>
+
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Group.hxx"
+
+#include "MEDMEM_MedMeshDriver.hxx"
+#include "MEDMEM_MedFieldDriver.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_define.hxx"
+
+
+double dmax(double x, double y) { return (x>y)?x:y;}
+
+double dmin(double x, double y) { return (x>y)?y:x;}
+
+double infty = 1.e20;
+
+void affiche_support(SUPPORT * mySupport)
+{
+ MESSAGE( " - Name : "<<mySupport->getName().c_str());
+ MESSAGE( " - Description : "<<mySupport->getDescription().c_str());
+ MESSAGE( " - Entity : "<<mySupport->getEntity());
+ MESSAGE( " - Entities list : ");
+ if (!(mySupport->isOnAllElements())) {
+ int NumberOfTypes = mySupport->getNumberOfTypes() ;
+ MESSAGE(" - NumberOfTypes : "<<NumberOfTypes);
+ medGeometryElement * Types = mySupport->getTypes() ;
+ for (int j=0;j<NumberOfTypes;j++) {
+ MESSAGE( " * Type "<<Types[j]<<" : " );
+ int NumberOfElements = mySupport->getNumberOfElements(Types[j]) ;
+ int * Number = mySupport->getNumber(Types[j]) ;
+ for (int k=0; k<NumberOfElements;k++)
+ MESSAGE( Number[k] << " ");
+ MESSAGE("");
+ }
+ } else
+ MESSAGE( " Is on all entities !");
+}
+
+
+void affiche_famille(MESH *myMesh,medEntityMesh Entity)
+{
+ int NumberOfFamilies = myMesh->getNumberOfFamilies(Entity) ;
+ MESSAGE( "NumberOfFamilies : "<<NumberOfFamilies);
+ for (int i=1; i<NumberOfFamilies+1;i++) {
+ FAMILY* myFamily = myMesh->getFamily(Entity,i);
+ affiche_support(myFamily);
+ MESSAGE( " - Identifier : "<<myFamily->getIdentifier());
+ int NumberOfAttributes = myFamily->getNumberOfAttributes() ;
+ MESSAGE( " - Attributes ("<<NumberOfAttributes<<") :");
+ for (int j=1;j<NumberOfAttributes+1;j++)
+ MESSAGE( " * "<<myFamily->getAttributeIdentifier(j)<<" : "<<myFamily->getAttributeValue(j)<<", "<<myFamily->getAttributeDescription(j).c_str());
+ int NumberOfGroups = myFamily->getNumberOfGroups() ;
+ MESSAGE( " - Groups ("<<NumberOfGroups<<") :");
+ for (int j=1;j<NumberOfGroups+1;j++)
+ MESSAGE( " * "<<myFamily->getGroupName(j).c_str());
+ }
+}
+
+void affiche_groupe(MESH *myMesh,medEntityMesh Entity)
+{
+ int NumberOfGroups = myMesh->getNumberOfGroups(Entity) ;
+ MESSAGE( "NumberOfGroups : "<<NumberOfGroups);
+ for (int i=1; i<NumberOfGroups+1;i++) {
+ GROUP* myGroup = myMesh->getGroup(Entity,i);
+ affiche_support(myGroup);
+ int NumberOfFamillies = myGroup->getNumberOfFamilies() ;
+ MESSAGE( " - Families ("<<NumberOfFamillies<<") :");
+ for (int j=1;j<NumberOfFamillies+1;j++)
+ MESSAGE( " * "<<myGroup->getFamily(j)->getName().c_str());
+ }
+}
+
+int main (int argc, char ** argv) {
+
+ int read;
+
+ if ((argc !=3) && (argc != 4)) {
+ cerr << "Usage : " << argv[0]
+ << " filename meshname [fieldname]" << endl << endl;
+ exit(-1);
+ }
+
+ string filename = argv[1] ;
+ string meshname = argv[2] ;
+
+ // MESH * myMesh= new MESH(MED_DRIVER,filename,meshname) ;
+ MESH * myMesh= new MESH() ;
+ myMesh->setName(meshname);
+ MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
+ myMeshDriver.setMeshName(meshname);
+ myMeshDriver.open() ;
+ myMeshDriver.read() ;
+ myMeshDriver.close() ;
+
+ // int drv = myMesh->addDriver(MED_DRIVER,"sortie.med",meshname);
+ // myMesh->write(drv);
+
+
+ int SpaceDimension = myMesh->getSpaceDimension() ;
+ int MeshDimension = myMesh->getMeshDimension() ;
+ int NumberOfNodes = myMesh->getNumberOfNodes() ;
+
+ MESSAGE( "Space Dimension : " << SpaceDimension << endl );
+
+ MESSAGE( "Mesh Dimension : " << MeshDimension << endl );
+
+ const double * Coordinates = myMesh->getCoordinates(MED_FULL_INTERLACE) ;
+
+ MESSAGE( "Show Nodes Coordinates : " );
+
+ MESSAGE( "Name :" );
+ string * CoordinatesNames = myMesh->getCoordinatesNames() ;
+ for(int i=0; i<SpaceDimension ; i++) {
+ MESSAGE( " - " << CoordinatesNames[i] );
+ }
+ MESSAGE( "Unit :" );
+ string * CoordinatesUnits = myMesh->getCoordinatesUnits() ;
+ for(int i=0; i<SpaceDimension ; i++) {
+ MESSAGE( " - " << CoordinatesUnits[i] );
+ }
+ for(int i=0; i<NumberOfNodes ; i++) {
+ MESSAGE( "Nodes " << i+1 << " : " );
+ for (int j=0; j<SpaceDimension ; j++)
+ MESSAGE( Coordinates[i*SpaceDimension+j] << " " );
+ MESSAGE("");
+ }
+
+ int NumberOfTypes = myMesh->getNumberOfTypes(MED_CELL) ;
+ medGeometryElement * Types = myMesh->getTypes(MED_CELL) ;
+
+ MESSAGE( "Show Connectivity (Nodal) :" );
+ for (int i=0; i<NumberOfTypes; i++) {
+ MESSAGE( "For type " << Types[i] << " : " );
+ int NumberOfElements = myMesh->getNumberOfElements(MED_CELL,Types[i]);
+ int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,Types[i]);
+ int NomberOfNodesPerCell = Types[i]%100 ;
+ for (int j=0;j<NumberOfElements;j++){
+ MESSAGE( "Element "<< j+1 <<" : " );
+ for (int k=0;k<NomberOfNodesPerCell;k++)
+ MESSAGE( connectivity[j*NomberOfNodesPerCell+k]<<" ");
+ MESSAGE("");
+ }
+ }
+
+ MESSAGE( "Show Family :");
+ affiche_famille(myMesh,MED_NODE);
+ affiche_famille(myMesh,MED_CELL);
+ affiche_famille(myMesh,MED_FACE);
+ affiche_famille(myMesh,MED_EDGE);
+
+ MESSAGE( "Show Group :");
+ affiche_groupe(myMesh,MED_NODE);
+ affiche_groupe(myMesh,MED_CELL);
+ affiche_groupe(myMesh,MED_FACE);
+ affiche_groupe(myMesh,MED_EDGE);
+
+ MESSAGE( "Show Reverse Nodal Connectivity :" );
+ int * ReverseNodalConnectivity = myMesh->getReverseConnectivity(MED_NODAL) ;
+ int * ReverseNodalConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_NODAL) ;
+ for (int i=0; i<NumberOfNodes; i++) {
+ MESSAGE( "Node "<<i+1<<" : " );
+ for (int j=ReverseNodalConnectivityIndex[i];j<ReverseNodalConnectivityIndex[i+1];j++)
+ MESSAGE( ReverseNodalConnectivity[j-1] << " " );
+ MESSAGE("");
+ }
+
+ MESSAGE( "Show Connectivity (Descending) :" );
+ int NumberOfElements ;
+ int * connectivity ;
+ int * connectivity_index ;
+ myMesh->calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL);
+ try {
+ NumberOfElements = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS);
+ connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS);
+ connectivity_index = myMesh->getConnectivityIndex(MED_DESCENDING,MED_CELL);
+ }
+ catch (MEDEXCEPTION m) {
+ MESSAGE( m.what() );
+ exit (-1) ;
+ }
+ for (int j=0;j<NumberOfElements;j++) {
+ MESSAGE( "Element "<<j+1<<" : " );
+ for (int k=connectivity_index[j];k<connectivity_index[j+1];k++)
+ MESSAGE( connectivity[k-1]<<" ");
+ MESSAGE("");
+ }
+
+ MESSAGE( "Show Reverse Descending Connectivity :" );
+ int * ReverseDescendingConnectivity = myMesh->getReverseConnectivity(MED_DESCENDING) ;
+ int * ReverseDescendingConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_DESCENDING) ;
+
+ int NumberOfConstituents = 0;
+ string constituent ;
+ medEntityMesh constituentEntity ;
+
+ if (MeshDimension==3) {
+ constituent = "Face" ;
+ constituentEntity = MED_FACE ;
+ }
+
+ if (MeshDimension==2) {
+ constituent = "Edge" ;
+ constituentEntity = MED_EDGE ;
+ }
+
+ if (MeshDimension==1) {
+ MESSAGE("ERROR : MeshDimension = 1 !");
+ MESSAGE("We could not see Reverse Descending Connectivity.") ;
+ } else {
+ NumberOfConstituents = myMesh->getNumberOfElements (constituentEntity,MED_ALL_ELEMENTS);
+ for (int i=0; i<NumberOfConstituents; i++) {
+ MESSAGE( constituent <<i+1<<" : " );
+ for (int j=ReverseDescendingConnectivityIndex[i];j<ReverseDescendingConnectivityIndex[i+1];j++)
+ MESSAGE( ReverseDescendingConnectivity[j-1] << " " );
+ MESSAGE("");
+ }
+ }
+ MESSAGE( "Show "<<constituent<<" Connectivity (Nodal) :" );
+ int * face_connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,constituentEntity,MED_ALL_ELEMENTS);
+ int * face_connectivity_index = myMesh->getConnectivityIndex(MED_NODAL,constituentEntity);
+ for (int i=0; i<NumberOfConstituents; i++) {
+ MESSAGE( constituent <<i+1<<" : " );
+ for (int j=face_connectivity_index[i];j<face_connectivity_index[i+1];j++)
+ MESSAGE( face_connectivity[j-1]<<" ");
+ MESSAGE("");
+ }
+
+ /* test of normal, area, volume, barycenter */
+
+ SUPPORT * support1 = (SUPPORT*) NULL;
+
+ FIELD<double>* normal = new FIELD<double>::FIELD();
+ FIELD<double>* length = new FIELD<double>::FIELD();
+ normal = NULL;
+ length = NULL;
+ string support_name = "Support on all " ;
+ support_name+=constituent;
+ support1 = new SUPPORT(myMesh,support_name,constituentEntity);
+ MESSAGE( "Building of the Support on all cells dimensionned (Meshdim-1) of the mesh :");
+ MESSAGE( "Face in 3D or Edge in 2D" );
+
+ MESSAGE( "Getting the normal of each face of this support !" );
+
+ normal = myMesh->getNormal(support1);
+
+ double normal_square, norm ;
+ double maxnorm=-infty;
+ double minnorm=infty;
+ double tmp_value ;
+ for (int i = 1; i<=NumberOfConstituents;i++) {
+ normal_square = 0. ;
+ MESSAGE( "Normal " << i << " " );
+ for (int j=1; j<=SpaceDimension; j++) {
+ tmp_value = normal->getValueIJ(i,j) ;
+ normal_square += tmp_value*tmp_value ;
+ MESSAGE( tmp_value << " " );
+ }
+ norm = sqrt(normal_square);
+ maxnorm = dmax(maxnorm,norm);
+ minnorm = dmin(minnorm,norm);
+ MESSAGE( ", Norm = " << norm );
+ }
+ MESSAGE( "Max Norm " << maxnorm << " Min Norm " << minnorm );
+
+
+ if (SpaceDimension == 2)
+ {
+ MESSAGE( "Getting the length of each edge !" );
+
+ length = myMesh->getLength(support1);
+
+ double length_value,maxlength,minlength;
+ maxlength = -infty;
+ minlength = infty;
+ for (int i = 1; i<=NumberOfConstituents;i++)
+ {
+ length_value = length->getValueIJ(i,1) ;
+ MESSAGE( "Length " << i << " " << length_value );
+ maxlength = dmax(maxlength,length_value);
+ minlength = dmin(minlength,length_value);
+ }
+ MESSAGE( "Max Length " << maxlength << " Min Length " << minlength );
+ }
+
+ MESSAGE( "Building of the Support on all space-dimensionned cells of the mesh :");
+ SUPPORT * support = new SUPPORT(myMesh);
+
+ MESSAGE( "Getting the barycenter of each element of this support !" );
+
+ FIELD<double>* barycenter = new FIELD<double>::FIELD();
+
+ barycenter = myMesh->getBarycenter(support);
+ NumberOfElements = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS);
+
+ for (int i = 1; i<=NumberOfElements;i++)
+ {
+ if (SpaceDimension == 3)
+ MESSAGE( "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) << " " << barycenter->getValueIJ(i,3) );
+
+ if (SpaceDimension == 2)
+ MESSAGE( "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) );
+ }
+
+ FIELD<double>* volume = new FIELD<double>::FIELD();
+ FIELD<double>* area = new FIELD<double>::FIELD();
+ volume = NULL;
+ area = NULL;
+
+ if (SpaceDimension == 3)
+ {
+ MESSAGE( "Getting the Volume of each element of this support which is a 3D one !" );
+
+ volume = myMesh->getVolume(support);
+
+ double maxvol,minvol,voltot;
+ maxvol = -infty;
+ minvol = infty;
+ voltot = 0.0;
+ for (int i = 1; i<=NumberOfElements;i++)
+ {
+ MESSAGE( "Volume " << i << " " << volume->getValueIJ(i,1) );
+ maxvol = dmax(maxvol,volume->getValueIJ(i,1));
+ minvol = dmin(minvol,volume->getValueIJ(i,1));
+ voltot = voltot + volume->getValueIJ(i,1);
+ }
+
+ MESSAGE( "Max Volume " << maxvol << " Min Volume " << minvol );
+ MESSAGE( "Support Volume " << voltot );
+ }
+ else if (SpaceDimension == 2)
+ {
+ MESSAGE( "Getting the Area of each element of this support which is a 2D one !" );
+
+ area = myMesh->getArea(support);
+
+ // MESSAGE( "nb of comp "<< area->getNumberOfComponents() << " length " << area->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS) );
+
+ double maxarea,minarea,areatot;
+ maxarea = -infty;
+ minarea = infty;
+ areatot = 0.0;
+ for (int i = 1; i<=NumberOfElements;i++)
+ {
+ MESSAGE( "Area " << i << " " << area->getValueIJ(i,1) );
+ maxarea = dmax(maxarea,area->getValueIJ(i,1));
+ minarea = dmin(minarea,area->getValueIJ(i,1));
+ areatot = areatot + area->getValueIJ(i,1);
+ }
+
+ MESSAGE( "Max Area " << maxarea << " Min Area " << minarea );
+ MESSAGE( "Support Area " << areatot );
+ }
+
+ if (barycenter != NULL) delete barycenter;
+ if (volume != NULL ) delete volume;
+ if (area != NULL ) delete area;
+
+
+ if (argc < 4) return 0;
+
+ // read field :
+
+ if (argc != 4) exit(0) ;
+ // else we have a field !
+
+ string fieldname = argv[3];
+
+ // SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
+ SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_cell",MED_CELL);
+ FIELD<double> * myField= new FIELD<double>() ;
+
+ myField->setName(fieldname);
+ myField->setSupport(mySupport);
+ MED_FIELD_RDONLY_DRIVER<double> myFieldDriver(filename,myField) ;
+ myFieldDriver.setFieldName(fieldname);
+ myFieldDriver.open() ;
+
+ try {
+ myFieldDriver.read() ;
+ } catch (...) {
+ delete mySupport ;
+ mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
+ myField->setSupport(mySupport);
+ try {
+ myFieldDriver.read() ;
+ } catch (...) {
+ cout << "Field " << fieldname << " not found !!!" << endl ;
+ exit (-1) ;
+ }
+ }
+
+ myFieldDriver.close() ;
+
+ MESSAGE( "Field "<< myField->getName() << " : " <<myField->getDescription() );
+ int NumberOfComponents = myField->getNumberOfComponents() ;
+ MESSAGE( "- Nombre de composantes : "<< NumberOfComponents );
+ for (int i=1; i<NumberOfComponents+1; i++) {
+ MESSAGE( " - composante "<<i<<" :");
+ MESSAGE( " - nom : "<<myField->getComponentName(i));
+ MESSAGE( " - description : "<<myField->getComponentDescription(i) );
+ MESSAGE( " - units : "<<myField->getMEDComponentUnit(i) );
+ }
+ MESSAGE( "- iteration :" );
+ MESSAGE( " - numero : " << myField->getIterationNumber());
+ MESSAGE( " - ordre : " << myField->getOrderNumber());
+ MESSAGE( " - temps : " << myField->getTime());
+
+ MESSAGE( "- Valeurs :");
+ int NumberOf = mySupport->getNumberOfElements(MED_ALL_ELEMENTS);
+ // for (int i=1; i<NumberOfComponents+1; i++) {
+ // double * value = myField->getValueI(MED_NO_INTERLACE,i) ;
+ // for (int j=0; j<NumberOf; j++)
+ // MESSAGE( value[j]<< " ");
+ // MESSAGE();
+ // }
+ for (int i=1; i<NumberOf+1; i++) {
+ double * value = myField->getValueI(MED_FULL_INTERLACE,i) ;
+ for (int j=0; j<NumberOfComponents; j++)
+ MESSAGE( value[j]<< " ");
+ MESSAGE("");
+ }
+
+
+ return 0;
+}
--- /dev/null
+#include "utilities.h"
+#include "MEDMEM_Array.hxx"
+
+int main (int argc, char ** argv) {
+
+ int SpaceDimension = 3 ;
+ int NumberOfNodes = 4 ;
+ MEDARRAY<int> * myArray = new MEDARRAY<int>(SpaceDimension,NumberOfNodes,MED_FULL_INTERLACE) ;
+
+ int * value = myArray->get(MED_FULL_INTERLACE) ;
+ for (int i=0; i<SpaceDimension*NumberOfNodes; i++)
+ value[i]=i ;
+
+ int numberof ;
+ MESSAGE("Show all 1 :");
+ numberof = myArray->getLeadingValue() ;
+ for (int i=1; i<=myArray->getLengthValue() ; i++) {
+ int * node = myArray->getI(MED_FULL_INTERLACE,i) ;
+ MESSAGE( " - " );
+ for (int j=0;j<numberof;j++)
+ MESSAGE( node[j] << " " );
+ MESSAGE("");
+ }
+ MESSAGE("Show all 2 :");
+ numberof = myArray->getLengthValue() ;
+ for (int i=1; i<=myArray->getLeadingValue() ; i++) {
+ int * node = myArray->getI(MED_NO_INTERLACE,i) ;
+ MESSAGE( " - " );
+ for (int j=0;j<numberof;j++)
+ MESSAGE( node[j] << " " );
+ MESSAGE("");
+ }
+ MESSAGE("Show all 3 :");
+ numberof = myArray->getLeadingValue() ;
+ for (int i=1; i<=myArray->getLengthValue() ; i++) {
+ MESSAGE( " - " );
+ for (int j=1;j<numberof+1;j++)
+ MESSAGE( myArray->getIJ(i,j) << " " );
+ MESSAGE("");
+ }
+
+ MESSAGE("Show all 0 :");
+ numberof = myArray->getLeadingValue() ;
+ int length = myArray->getLengthValue() ;
+ int * NoInterlaceArray = myArray->get(MED_NO_INTERLACE) ;
+ for (int i=0; i<length ; i++) {
+ MESSAGE( " - " );
+ for (int j=0;j<numberof;j++)
+ MESSAGE( NoInterlaceArray[j*length+i] << " " );
+ MESSAGE("");
+ }
+ return 0 ;
+}
+
--- /dev/null
+#include "utilities.h"
+#include "MEDMEM_CellModel.hxx"
+#include "MEDMEM_DriversDef.hxx"
+
+int main (int argc, char ** argv) {
+ list<MED_FR::med_geometrie_element> geomList = MED_FR::meshEntities[MED_FR::MED_MAILLE] ;
+ list<MED_FR::med_geometrie_element>::iterator itGeomList ;
+ for(itGeomList=geomList.begin();itGeomList!=geomList.end();itGeomList++) {
+ CELLMODEL myCellModel((MED_EN::medGeometryElement)(*itGeomList)) ;
+
+ cout << myCellModel << endl ;
+
+ cout << "Number of constituents type : "<<myCellModel.getNumberOfConstituentsType() << endl ;
+
+ set <medGeometryElement> geomType = myCellModel.getAllConstituentsType() ;
+ set <medGeometryElement>::iterator geomTypeIt ;
+ cout << "Types list : " ;
+ for(geomTypeIt=geomType.begin();geomTypeIt!=geomType.end();geomTypeIt++)
+ cout << (*geomTypeIt) << " " ;
+ cout << endl;
+
+ map <medGeometryElement,int> myMap = myCellModel.getNumberOfConstituentsForeachType() ;
+ map <medGeometryElement,int>::iterator myMapIt ;
+ for(myMapIt=myMap.begin();myMapIt!=myMap.end();myMapIt++)
+ cout << " - " << (*myMapIt).second << " constituent(s) of type " << (*myMapIt).first << endl ;
+ cout << endl;
+
+ }
+}
--- /dev/null
+#include "utilities.h"
+#include "MEDMEM_ModulusArray.hxx"
+
+int main (int argc, char ** argv) {
+
+ int array[5]={0,1,2,1,4} ;
+ MEDMODULUSARRAY modulusArray(5,array);
+
+ MESSAGE("ModuloArray :");
+ for(int i=-10;i<15;i++)
+ MESSAGE(" - A["<<i<<"]="<<modulusArray[i]);
+ MESSAGE("");
+
+ // test compare
+ int ret ;
+
+ int array2[5]={1,4,0,1,2} ;
+ MEDMODULUSARRAY modulusArray2(5,array2) ;
+ MESSAGE("Same arrays, same order ... ");
+ if ((ret=modulusArray2.compare(modulusArray))!=1)
+ MESSAGE( "Error : two arrays must be identical !"<<ret)
+ else
+ MESSAGE( "OK" )
+
+ int array3[5]={1,2,1,0,4} ;
+ MEDMODULUSARRAY modulusArray3(5,array3) ;
+ MESSAGE("Same arrays, reverse order ... ");
+ if ((ret=modulusArray3.compare(modulusArray))!=-1)
+ MESSAGE( "Error : two arrays are in reverse order !"<<ret)
+ else
+ MESSAGE( "OK" )
+
+ int array4[6]={1,2,1,0} ;
+ MEDMODULUSARRAY modulusArray4(4,array4) ;
+ MESSAGE("Different arrays size ... ");
+ if ((ret=modulusArray4.compare(modulusArray))!=0)
+ MESSAGE( "Error : two arrays have different size !"<<ret)
+ else
+ MESSAGE( "OK" )
+
+ int array5[5]={1,2,1,0,1} ;
+ MEDMODULUSARRAY modulusArray5(5,array5) ;
+ MESSAGE("Different array, same size ... ");
+ if ((ret=modulusArray5.compare(modulusArray))!=0)
+ MESSAGE( "Error : two arrays are not be identical !"<<ret)
+ else
+ MESSAGE( "OK" )
+
+ // test small array :
+
+ // 1
+ int array6[1]={1} ;
+ MEDMODULUSARRAY modulusArray6(1,array6);
+
+ MESSAGE("ModuloArray 1 :");
+ for(int i=-10;i<15;i++)
+ MESSAGE(" - A["<<i<<"]="<<modulusArray6[i]);
+ MESSAGE("");
+
+ int array7[1]={1} ;
+ MEDMODULUSARRAY modulusArray7(1,array7);
+ MESSAGE("Same arrays, same order ... ");
+ if ((ret=modulusArray6.compare(modulusArray7))!=1)
+ MESSAGE( "Error : two arrays are identical !"<<ret)
+ else
+ MESSAGE( "OK" )
+
+ int array8[1]={2} ;
+ MEDMODULUSARRAY modulusArray8(1,array8);
+ MESSAGE("Different arrays ... ");
+ if ((ret=modulusArray6.compare(modulusArray8))!=0)
+ MESSAGE( "Error : two arrays are different !"<<ret)
+ else
+ MESSAGE( "OK" )
+
+
+ // 2
+ int array60[2]={1,2} ;
+ MEDMODULUSARRAY modulusArray60(2,array60);
+
+ MESSAGE("ModuloArray 2 :");
+ for(int i=-10;i<15;i++)
+ MESSAGE(" - A["<<i<<"]="<<modulusArray60[i]);
+ MESSAGE("");
+
+ int array70[2]={1,2} ;
+ MEDMODULUSARRAY modulusArray70(2,array70);
+ MESSAGE("Same arrays, same order ... ");
+ if ((ret=modulusArray60.compare(modulusArray70))!=1)
+ MESSAGE( "Error : two arrays are identical !"<<ret)
+ else
+ MESSAGE( "OK" );
+ int array80[2]={2,2} ;
+ MEDMODULUSARRAY modulusArray80(2,array80);
+ MESSAGE("Different arrays ... ");
+ if ((ret=modulusArray60.compare(modulusArray80))!=0)
+ MESSAGE( "Error : two arrays are different !"<<ret)
+ else
+ MESSAGE( "OK" )
+ int array90[2]={2,1} ;
+ MEDMODULUSARRAY modulusArray90(2,array90);
+ MESSAGE("Same arrays, reverse order ... ");
+ if ((ret=modulusArray60.compare(modulusArray90))!=-1)
+ MESSAGE( "Error : two arrays are in reverse order !"<<ret)
+ else
+ MESSAGE( "OK" )
+
+
+
+
+
+ return 0 ;
+}
--- /dev/null
+#include "utilities.h"
+#include "MEDMEM_SkyLineArray.hxx"
+
+int main (int argc, char ** argv) {
+
+ int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle
+ int Size = 10 ; // 10 nodes
+ MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size) ;
+
+ int * index = myArray->getIndex() ;
+ index[0]=1;
+ index[1]=4;
+ index[2]=8;
+ index[3]=11;
+ int * value = myArray->getValue() ;
+ value[0]=1; // first
+ value[1]=2;
+ value[2]=5;
+ value[3]=2; // second
+ value[4]=3;
+ value[5]=5;
+ value[6]=6;
+ value[7]=3; // thirst
+ value[8]=4;
+ value[9]=6;
+ // value[]=; // forth
+
+ MESSAGE( "Show all 1 :" );
+ for (int i=1; i<NumberOfCell+1 ; i++) {
+ int * cell = myArray->getI(i) ;
+ int numberof = myArray->getNumberOfI(i) ;
+ MESSAGE( " - " );
+ for (int j=0;j<numberof;j++)
+ MESSAGE( cell[j] << " " );
+ MESSAGE("");
+ }
+ MESSAGE( "Show all 2 :" );
+ for (int i=1; i<NumberOfCell+1 ; i++) {
+ MESSAGE( " - " );
+ int numberof = myArray->getNumberOfI(i) ;
+ for (int j=1;j<numberof+1;j++)
+ MESSAGE( myArray->getIJ(i,j) << " " );
+ MESSAGE("");
+ }
+
+ MEDSKYLINEARRAY * myArray2 = new MEDSKYLINEARRAY(*myArray) ;
+ delete myArray ;
+
+ MESSAGE( "Show all 3 :" );
+ for (int i=1; i<NumberOfCell+1 ; i++) {
+ int * cell = myArray2->getI(i) ;
+ int numberof = myArray2->getNumberOfI(i) ;
+ MESSAGE( " - " );
+ for (int j=0;j<numberof;j++)
+ MESSAGE( cell[j] << " " );
+ MESSAGE("");
+ }
+
+ return 0 ;
+}
+
--- /dev/null
+#include "MEDMEM_SWIG_FieldDouble.hxx"
+
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=============================================================================
+FIELDDOUBLE::FIELDDOUBLE() : FIELD<double>()
+{
+ BEGIN_OF("Default Constructor (for Python API) FIELDDOUBLE");
+
+ END_OF("Default Constructor (for Python API) FIELDDOUBLE");
+}
+//=============================================================================
+/*!
+ * Constructor with arguments
+ */
+//=============================================================================
+FIELDDOUBLE::FIELDDOUBLE(const SUPPORT * Support, const int NumberOfComponents) : FIELD<double>(Support,NumberOfComponents)
+{
+ BEGIN_OF("Constructor with arguments (for Python API) FIELDDOUBLE");
+
+ med_type_champ type = MED_REEL64;
+
+ setValueType(type);
+
+ END_OF("Constructor with arguments (for Python API) FIELDDOUBLE");
+}
+/*
+FIELDDOUBLE::FIELDDOUBLE(FIELD_ *field)
+ : FIELD<double> ( * (FIELD<double> *)(field))
+{
+ BEGIN_OF("Constructor (for Python API) FIELDDOUBLE avec parametre");
+
+ SCRUTE(_value);
+
+ END_OF("Constructor(for Python API) FIELDDOUBLE avec parametre");
+}
+*/
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+FIELDDOUBLE::~FIELDDOUBLE()
+{
+ BEGIN_OF("Default Destructor (for Python API) FIELDDOUBLE");
+
+ END_OF("Default Destructor (for Python API) FIELDDOUBLE");
+}
--- /dev/null
+#ifndef MEDMEM_SWIG_FIELDDOUBLE_HXX_
+#define MEDMEM_SWIG_FIELDDOUBLE_HXX_
+
+#include "MEDMEM_Field.hxx"
+
+class FIELDDOUBLE : public FIELD<double>
+{
+public:
+ FIELDDOUBLE();
+ FIELDDOUBLE(const SUPPORT * Support, const int NumberOfComponents);
+ ~FIELDDOUBLE();
+};
+
+#endif /* MEDMEM_SWIG_FIELDDOUBLE_HXX_ */
--- /dev/null
+#include "MEDMEM_SWIG_FieldInt.hxx"
+
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=============================================================================
+FIELDINT::FIELDINT() : FIELD<int>()
+{
+ BEGIN_OF("Default Constructor (for Python API) FIELDINT");
+
+ END_OF("Default Constructor (for Python API) FIELDINT");
+}
+//=============================================================================
+/*!
+ * Constructor with arguments
+ */
+//=============================================================================
+FIELDINT::FIELDINT(const SUPPORT * Support, const int NumberOfComponents) : FIELD<int>(Support,NumberOfComponents)
+{
+ BEGIN_OF("Constructor with arguments (for Python API) FIELDINT");
+
+ med_type_champ type = MED_INT32;
+
+ setValueType(type);
+
+ END_OF("Constructor with arguments (for Python API) FIELDINT");
+}
+/*
+FIELDINT::FIELDINT(FIELD_ * field)
+ : FIELD<int> ( * (FIELD<int> *) (field))
+{
+ BEGIN_OF("Constructor (for Python API) FIELDINT avec parametre");
+
+ END_OF("Constructor (for Python API) FIELDINT avec parametre");
+}
+*/
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+FIELDINT::~FIELDINT()
+{
+ BEGIN_OF("Default Destructor (for Python API) FIELDINT");
+
+ END_OF("Default Destructor (for Python API) FIELDINT");
+}
--- /dev/null
+#ifndef MEDMEM_SWIG_FIELDINT_HXX_
+#define MEDMEM_SWIG_FIELDINT_HXX_
+
+#include "MEDMEM_Field.hxx"
+
+class FIELDINT : public FIELD<int>
+{
+public:
+ FIELDINT();
+ FIELDINT(const SUPPORT * Support, const int NumberOfComponents);
+ ~FIELDINT();
+};
+
+#endif /* MEDMEM_SWIG_FIELDINT_HXX_ */
--- /dev/null
+#==============================================================================
+# File : Makefile.in
+# Author : Nadir BOUHAMOU (CEA/DEN/DM2S/SFME/LGLS)
+# CVS : $Header$
+#==============================================================================
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=../../..
+srcdir=@srcdir@
+VPATH=.:$(srcdir)
+
+@COMMENCE@
+
+EXPORT_HEADERS = \
+ libMEDMEM_Swig.i \
+ my_typemap.i \
+ MEDMEM_SWIG_FieldDouble.hxx \
+ MEDMEM_SWIG_FieldInt.hxx
+
+# Libraries targets
+
+LIB = libMEDMEM_Swigcmodule.la
+
+LIB_SRC = MEDMEM_SWIG_FieldDouble.cxx \
+ MEDMEM_SWIG_FieldInt.cxx
+
+SWIG_DEF = libMEDMEM_Swig.i
+
+EXPORT_PYSCRIPTS = libMEDMEM_Swig.py med_test1.py med_test2.py med_test3.py
+
+#############################################################################
+
+CPPFLAGS+= $(PYTHON_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES)
+CXXFLAGS=-g -D_DEBUG_ -D__x86__ -D__linux__
+CXXFLAGS+=-ftemplate-depth-42
+LIBS= $(PYTHON_LIBS)
+LDFLAGS+= -lmedmem $(MED2_LIBS) $(HDF5_LIBS)
+
+#############################################################################
+
+@CONCLUDE@
--- /dev/null
+%module libMEDMEM_Swig
+
+%include "typemaps.i"
+%include "my_typemap.i"
+
+%{
+#include "MEDMEM_CellModel.hxx"
+#include "MEDMEM_GenDriver.hxx"
+#include "MEDMEM_MedMeshDriver.hxx"
+#include "MEDMEM_Connectivity.hxx"
+#include "MEDMEM_Group.hxx"
+#include "MEDMEM_SkyLineArray.hxx"
+#include "MEDMEM_Coordinate.hxx"
+#include "MEDMEM_Array.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_STRING.hxx"
+#include "MEDMEM_DriversDef.hxx"
+#include "MEDMEM_MedFieldDriver.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Med.hxx"
+#include "MEDMEM_Unit.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_MedMedDriver.hxx"
+#include "MEDMEM_SWIG_FieldDouble.hxx"
+#include "MEDMEM_SWIG_FieldInt.hxx"
+%}
+
+/*
+ enum du MED++ que l'on utilise dans l'API Python
+*/
+
+typedef enum {MED_FULL_INTERLACE, MED_NO_INTERLACE} medModeSwitch;
+
+typedef enum {MED_LECT,MED_ECRI,MED_REMP} med_mode_acces;
+
+typedef enum {MED_CELL, MED_FACE, MED_EDGE, MED_NODE,
+ MED_ALL_ENTITIES} medEntityMesh;
+
+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,
+ 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_ALL_ELEMENTS=999} medGeometryElement;
+
+typedef enum {MED_NODAL, MED_DESCENDING} medConnectivity ;
+
+typedef enum {MED_DRIVER=0, VTK_DRIVER=1, NO_DRIVER=255} driverTypes;
+
+typedef enum {MED_REEL64=6, MED_INT32=24, MED_INT64=26,
+ MED_INT} med_type_champ;
+
+typedef struct { int dt; int it; } DT_IT_;
+
+%extend DT_IT_ {
+ int getdt()
+ {
+ return self->dt;
+ }
+
+ int getit()
+ {
+ return self->it;
+ }
+}
+/*
+ Class et methodes du MED++ que l'on utilise dans l'API Python
+*/
+
+class CELLMODEL;
+
+class SUPPORT
+{
+ public:
+ // SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL);
+ // ~SUPPORT();
+
+ void update ( void );
+
+ MESH * getMesh() const;
+
+ void setMesh(MESH * Mesh);
+
+ medEntityMesh getEntity() const;
+
+ void setEntity(medEntityMesh Entity);
+
+ bool isOnAllElements() const;
+
+ void setAll(bool All);
+
+ int getNumberOfTypes() const;
+
+ void setNumberOfGeometricType(int NumberOfGeometricType);
+
+ int getNumberOfElements(medGeometryElement GeometricType) const;
+
+ void setGeometricType(medGeometryElement *GeometricType);
+
+ void setGeometricTypeNumber(int *GeometricTypeNumber);
+
+ void setNumberOfEntities(int *NumberOfEntities);
+
+ void setTotalNumberOfEntities(int TotalNumberOfEntities);
+
+ %extend {
+ SUPPORT(MESH* Mesh, char * Name="", medEntityMesh Entity=MED_CELL)
+ {
+ return new SUPPORT(Mesh,string(Name),Entity);
+ }
+
+ void setpartial(char * Description, int NumberOfGeometricType,
+ int TotalNumberOfEntity, medGeometryElement *GeometricType,
+ int *NumberOfEntity, int *NumberValue)
+ {
+ self->setpartial(string(Description), NumberOfGeometricType,
+ TotalNumberOfEntity, GeometricType,
+ NumberOfEntity, NumberValue);
+ }
+
+ void setName(char * Name)
+ {
+ self->setName(string(Name));
+ }
+
+ const char * getName()
+ {
+ string tmp_str = self->getName();
+ char * tmp = new char[strlen(tmp_str.c_str())+1];
+ strcpy(tmp,tmp_str.c_str());
+ return tmp;
+ }
+
+ void setDescription(char * Description)
+ {
+ self->setDescription(string(Description));
+ }
+
+ const char * getDescription()
+ {
+ string tmp_str = self->getDescription();
+ char * tmp = new char[strlen(tmp_str.c_str())+1];
+ strcpy(tmp,tmp_str.c_str());
+ return tmp;
+ }
+
+ PyObject * getTypes()
+ {
+ PyObject *py_list;
+
+ medGeometryElement * types = self->getTypes();
+ int size = self->getNumberOfTypes();
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("i", (int) types[i]));
+ if(err)
+ {
+ char * message = "Error in SUPPORT::getTypes";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+
+ PyObject * getGeometricTypeNumber()
+ {
+ PyObject *py_list;
+
+ int * GeometricTypeNumber = self->getGeometricTypeNumber();
+ int size = self->getNumberOfTypes();
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("i",
+ GeometricTypeNumber[i]));
+ if(err)
+ {
+ char * message = "Error in SUPPORT::getGeometricTypeNumber";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+
+ PyObject * getNumber(medGeometryElement GeometricType)
+ {
+ PyObject *py_list;
+
+ int * number = self->getNumber(GeometricType);
+ int size = self->getNumberOfElements(GeometricType);
+
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("i", number[i]));
+ if(err)
+ {
+ char * message = "Error in SUPPORT::getNumber";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+
+ PyObject * getNumberIndex()
+ {
+ PyObject *py_list;
+
+ int * numberindex = self->getNumberIndex();
+ int size = (self->getNumberOfElements(MED_ALL_ELEMENTS))+1;
+
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("i", numberindex[i]));
+ if(err)
+ {
+ char * message = "Error in SUPPORT::getNumberIndex";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+ }
+};
+
+class FAMILY : public SUPPORT
+{
+ public:
+ // ~FAMILY();
+
+ void setIdentifier(int Identifier);
+ void setNumberOfAttributes(int NumberOfAttribute);
+ void setAttributesIdentifiers(int * AttributeIdentifier);
+ void setAttributesValues(int * AttributeValue);
+ void setAttributesDescriptions(string * AttributeDescription);
+ void setNumberOfGroups(int NumberOfGroups);
+ void setGroupsNames(string * GroupName);
+
+ int getIdentifier() const;
+ int getNumberOfAttributes() const;
+ /* int * getAttributesIdentifiers() const;*/
+ /* int * getAttributesValues() const;*/
+ /* string * getAttributesDescriptions() const;*/
+ int getNumberOfGroups() const;
+ /* string * getGroupsNames() const;*/
+
+ %extend {
+ FAMILY(MESH* Mesh, int Identifier, char * Name, int NumberOfAttribute,
+ int *AttributeIdentifier, int *AttributeValue,
+ char * AttributeDescription, int NumberOfGroup,
+ char * GroupName)
+ {
+ return new FAMILY(Mesh,Identifier,string(Name),NumberOfAttribute,
+ AttributeIdentifier,AttributeValue,
+ string(AttributeDescription),NumberOfGroup,
+ string(GroupName));
+ }
+
+ const char * getAttributeDescription(int i)
+ {
+ string tmp_str = self->getAttributeDescription(i);
+ char * tmp = new char[strlen(tmp_str.c_str())+1];
+ strcpy(tmp,tmp_str.c_str());
+ return tmp;
+ }
+
+ const char * getGroupName(int i)
+ {
+ string tmp_str = self->getGroupName(i);
+ char * tmp = new char[strlen(tmp_str.c_str())+1];
+ strcpy(tmp,tmp_str.c_str());
+ return tmp;
+ }
+
+ PyObject * getAttributesIdentifiers()
+ {
+ PyObject *py_list;
+
+ int * attributesids = self->getAttributesIdentifiers();
+ int size = self->getNumberOfAttributes();
+
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("i",attributesids[i]));
+ if(err)
+ {
+ char * message = "Error in FAMILY::getAttributesIdentifiers";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+
+ PyObject * getAttributesValues()
+ {
+ PyObject *py_list;
+
+ int * attributesvals = self->getAttributesValues();
+ int size = self->getNumberOfAttributes();
+
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("i",attributesvals[i]));
+ if(err)
+ {
+ char * message = "Error in FAMILY::getAttributesValues";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+ }
+};
+
+class FIELD_
+{
+public:
+ FIELD_(const SUPPORT * Support, const int NumberOfComponents);
+ // ~FIELD_();
+
+ void rmDriver(int index=0);
+
+ void setIterationNumber (int IterationNumber);
+ int getIterationNumber() const;
+
+ void setTime(double Time);
+ double getTime() const;
+
+ void setOrderNumber (int OrderNumber);
+ int getOrderNumber() const;
+
+ void setValueType(med_type_champ ValueType) ;
+ med_type_champ getValueType() ;
+
+ SUPPORT * getSupport();
+ void setSupport(SUPPORT * support);
+
+ void setNumberOfComponents(int NumberOfComponents);
+ int getNumberOfComponents() const;
+
+ %extend {
+ int addDriver(driverTypes driverType,
+ char * fileName="Default File Name.med",
+ char * driverName="Default Field Name")
+ {
+ return self->addDriver(driverType,string(fileName),
+ string(driverName));
+ }
+
+ void setName(char * name)
+ {
+ self->setName(string(name));
+ }
+
+ const char * getName()
+ {
+ string tmp_str = self->getName();
+ char * tmp = new char[strlen(tmp_str.c_str())+1];
+ strcpy(tmp,tmp_str.c_str());
+ return tmp;
+ }
+
+ void setDescription(char * Description)
+ {
+ self->setDescription(string(Description));
+ }
+
+ const char * getDescription()
+ {
+ string tmp_str = self->getDescription();
+ char * tmp = new char[strlen(tmp_str.c_str())+1];
+ strcpy(tmp,tmp_str.c_str());
+ return tmp;
+ }
+
+ const char * getComponentName(int i)
+ {
+ string tmp_str = self->getComponentName(i);
+ char * tmp = new char[strlen(tmp_str.c_str())+1];
+ strcpy(tmp,tmp_str.c_str());
+ return tmp;
+ }
+
+ void setComponentName(int i, char * ComponentName)
+ {
+ self->setComponentName(i,string(ComponentName));
+ }
+
+ const char * getComponentDescription(int i)
+ {
+ string tmp_str = self->getComponentDescription(i);
+ char * tmp = new char[strlen(tmp_str.c_str())+1];
+ strcpy(tmp,tmp_str.c_str());
+ return tmp;
+ }
+
+ void setComponentDescription(int i, char * ComponentDescription)
+ {
+ self->setComponentDescription(i,string(ComponentDescription));
+ }
+
+ const char * getMEDComponentUnit(int i)
+ {
+ string tmp_str = self->getMEDComponentUnit(i);
+ char * tmp = new char[strlen(tmp_str.c_str())+1];
+ strcpy(tmp,tmp_str.c_str());
+ return tmp;
+ }
+
+ void setMEDComponentUnit(int i, char * MEDComponentUnit)
+ {
+ self->setMEDComponentUnit(i,string(MEDComponentUnit));
+ }
+ }
+};
+
+class FIELDDOUBLE : public FIELD_
+{
+public:
+ // ~FIELDDOUBLE();
+
+ FIELDDOUBLE(const SUPPORT * Support, const int NumberOfComponents);
+
+ void read(int index=0);
+
+ double getValueIJ(int i,int j) const;
+
+ void setValue(medModeSwitch mode, double* value);
+
+ void setValueI(medModeSwitch mode, int i, double* value);
+
+ void setValueIJ(int i, int j, double value);
+
+ void allocValue(const int NumberOfComponents);
+
+ void deallocValue();
+
+ %extend {
+ /*
+ FIELDDOUBLE(FIELD_ * field)
+ {
+ MESSAGE("Constructor (pour API Python) FIELDDOUBLE avec parameters");
+ return (FIELDDOUBLE *) field;
+ }
+ */
+
+ void write(int index=0, char * driverName="")
+ {
+ self->write(index, string(driverName));
+ }
+
+ PyObject * getValue(medModeSwitch Mode)
+ {
+ PyObject *py_list;
+
+ int size = (self->getNumberOfComponents())*
+ ((self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS));
+
+ double * value = self->getValue(Mode);
+
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("d", value[i]));
+ if(err)
+ {
+ char * message = "Error in FIELDDOUBLE::getValue";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+
+ PyObject * getValueI(medModeSwitch Mode, int index)
+ {
+ PyObject *py_list;
+
+ int size = self->getNumberOfComponents();
+
+ if ( Mode == MED_NO_INTERLACE ) size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS);
+
+ double * value = self->getValueI(Mode,index);
+
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("d", value[i]));
+ if(err)
+ {
+ char * message = "Error in FIELDDOUBLE::getValueI";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+
+ void allocValue2(int NumberOfComponents, int LengthValue)
+ {
+ self->allocValue(NumberOfComponents, LengthValue);
+ }
+ }
+};
+
+class FIELDINT : public FIELD_
+{
+public:
+ // ~FIELDINT();
+
+ FIELDINT(const SUPPORT * Support, const int NumberOfComponents);
+
+ void read(int index=0);
+
+ int getValueIJ(int i,int j) const;
+
+ void setValue(medModeSwitch mode, int* value);
+
+ void setValueI(medModeSwitch mode, int i, int* value);
+
+ void setValueIJ(int i, int j, int value);
+
+ void allocValue(const int NumberOfComponents);
+
+ void deallocValue();
+
+ %extend {
+ /*
+ FIELDINT(FIELD_ * field)
+ {
+ MESSAGE("Constructor (pour API Python) FIELDINT avec parameters");
+ return (FIELDINT *) field;
+ }
+ */
+
+ void write(int index=0, char * driverName="")
+ {
+ self->write(index, string(driverName));
+ }
+
+ PyObject * getValue(medModeSwitch Mode)
+ {
+ PyObject *py_list;
+
+ int size = (self->getNumberOfComponents())*
+ ((self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS));
+
+ int * value = self->getValue(Mode);
+
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("i", value[i]));
+ if(err)
+ {
+ char * message = "Error in FIELDINT::getValue";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+
+ PyObject * getValueI(medModeSwitch Mode, int index)
+ {
+ PyObject *py_list;
+
+ int size = self->getNumberOfComponents();
+
+ if ( Mode == MED_NO_INTERLACE ) size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS);
+
+ int * value = self->getValueI(Mode,index);
+
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("i", value[i]));
+ if(err)
+ {
+ char * message = "Error in FIELDINT::getValueI";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+
+ void allocValue2(int NumberOfComponents, int LengthValue)
+ {
+ self->allocValue(NumberOfComponents, LengthValue);
+ }
+ }
+};
+
+class GROUP : public SUPPORT
+{
+public:
+ GROUP();
+ // ~GROUP();
+
+ void setNumberOfFamilies(int numberOfFamilies);
+ void setFamilies(vector<FAMILY*> Family);
+
+ int getNumberOfFamilies() const ;
+ vector<FAMILY*> getFamilies() const ;
+ FAMILY * getFamily(int i) const ;
+};
+
+class MESH
+{
+ public :
+ void rmDriver(int index=0);
+
+ void read(int index=0);
+
+ int getSpaceDimension();
+
+ int getMeshDimension();
+
+ int getNumberOfNodes();
+
+ const double getCoordinate(int Number, int Axis);
+
+ int getNumberOfTypes(medEntityMesh Entity);
+
+ void calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity);
+
+ int getNumberOfElements(medEntityMesh Entity,medGeometryElement Type);
+
+ int getNumberOfFamilies(medEntityMesh Entity);
+
+ int getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity);
+
+ FAMILY* getFamily(medEntityMesh Entity,int i);
+
+ int getNumberOfGroups(medEntityMesh Entity);
+
+ GROUP * getGroup(medEntityMesh Entity,int i);
+
+ medGeometryElement getElementType(medEntityMesh Entity,int Number);
+
+ SUPPORT * getBoundaryElements(medEntityMesh Entity) ;
+
+ %extend {
+ int addDriver(driverTypes driverType,
+ char * fileName="Default File Name.med",
+ char * driverName="Default Mesh Name")
+ {
+ return self->addDriver(driverType,string(fileName),
+ string(driverName));
+ }
+
+ void write(int index=0, char * driverName="")
+ {
+ self->write(index, string(driverName));
+ }
+
+ void setName(char * name)
+ {
+ self->setName(string(name));
+ }
+
+ const char * getName()
+ {
+ string tmp_str = self->getName();
+ char * tmp = new char[strlen(tmp_str.c_str())+1];
+ strcpy(tmp,tmp_str.c_str());
+ return tmp;
+ }
+
+ const char * getCoordinatesSystem()
+ {
+ string tmp_str = self->getCoordinatesSystem();
+ char * tmp = new char[strlen(tmp_str.c_str())+1];
+ strcpy(tmp,tmp_str.c_str());
+ return tmp;
+ }
+
+ const char * getCoordinateName(int i)
+ {
+ string tmp_str = self->getCoordinatesNames()[i];
+ char * tmp = new char[strlen(tmp_str.c_str())+1];
+ strcpy(tmp,tmp_str.c_str());
+ return tmp;
+ }
+
+ const char * getCoordinateUnit(int i)
+ {
+ string tmp_str = self->getCoordinatesUnits()[i];
+ char * tmp = new char[strlen(tmp_str.c_str())+1];
+ strcpy(tmp,tmp_str.c_str());
+ return tmp;
+ }
+ PyObject * getCoordinates(medModeSwitch Mode)
+ {
+ PyObject *py_list;
+ const double * array = self->getCoordinates(Mode);
+ int size = (self->getSpaceDimension())*(self->getNumberOfNodes());
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("d", array[i]));
+ if(err)
+ {
+ char * message = "Error in MESH::getCoordinates";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+
+ PyObject * getTypes(medEntityMesh Entity)
+ {
+ PyObject *py_list;
+
+ medGeometryElement * types = self->getTypes(Entity);
+ int size = self->getNumberOfTypes(Entity);
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("i", (int) types[i]));
+ if(err)
+ {
+ char * message = "Error in MESH::getTypes";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+
+ PyObject * getConnectivity(medModeSwitch Mode,
+ medConnectivity ConnectivityType,
+ medEntityMesh Entity,
+ medGeometryElement Type)
+ {
+ PyObject *py_list;
+ int * connectivity = self->getConnectivity(Mode,ConnectivityType,
+ Entity,Type);
+ int nbOfElm = self->getNumberOfElements(Entity,Type);
+ int size;
+
+ if (Type == MED_ALL_ELEMENTS)
+ {
+ size = self->getConnectivityIndex(ConnectivityType,Entity)[nbOfElm];
+ }
+ else
+ {
+ size = nbOfElm*(((int) Type)%100);
+ }
+
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("i", connectivity[i]));
+ if(err)
+ {
+ char * message = "Error in MESH::getConnectivity";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+
+ PyObject * getConnectivityIndex(medConnectivity ConnectivityType,
+ medEntityMesh Entity)
+ {
+ PyObject *py_list;
+ int * connectivity_index =
+ self->getConnectivityIndex(ConnectivityType,Entity);
+ int size = (self->getNumberOfElements(Entity,MED_ALL_ELEMENTS))+1;
+
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("i",
+ connectivity_index[i]));
+ if(err)
+ {
+ char * message = "Error in MESH::getConnectivityIndex";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+
+ PyObject * getReverseConnectivity(medConnectivity ConnectivityType)
+ {
+ PyObject *py_list;
+ int * reverseconnectivity =
+ self->getReverseConnectivity(ConnectivityType);
+ int spaceDim = self->getSpaceDimension();
+ int nb;
+
+ if (ConnectivityType == MED_NODAL)
+ {
+ nb = (self->getNumberOfNodes());
+ }
+ else
+ {
+ if (spaceDim == 2)
+ nb = (self->getNumberOfElements(MED_EDGE,
+ MED_ALL_ELEMENTS));
+ else if (spaceDim == 3)
+ nb = (self->getNumberOfElements(MED_FACE,
+ MED_ALL_ELEMENTS));
+ }
+
+ int size = self->getReverseConnectivityIndex(ConnectivityType)[nb];
+
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err =
+ PyList_SetItem(py_list,i,
+ Py_BuildValue("i",reverseconnectivity[i]));
+ if(err)
+ {
+ char * message = "Error in MESH::getReverseConnectivity";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+
+ PyObject * getReverseConnectivityIndex(medConnectivity
+ ConnectivityType)
+ {
+ PyObject *py_list;
+ int * reverseconnectivity_index =
+ self->getReverseConnectivityIndex(ConnectivityType);
+
+ int size;
+ int spaceDim = self->getSpaceDimension();
+
+ if (ConnectivityType == MED_NODAL)
+ {
+ size = (self->getNumberOfNodes())+1;
+ }
+ else
+ {
+ if (spaceDim == 2)
+ size = (self->getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS))+1;
+ else if (spaceDim == 3)
+ size = (self->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS))+1;
+ }
+
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err =
+ PyList_SetItem(py_list,i,
+ Py_BuildValue("i",
+ reverseconnectivity_index[i]));
+ if(err)
+ {
+ char * message = "Error in MESH::getReverseConnectivityIndex";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ return Py_BuildValue("O", py_list);
+ }
+
+ FIELDDOUBLE * getVolume(const SUPPORT * Support)
+ {
+ return (FIELDDOUBLE *) self->getVolume(Support);
+ }
+
+ FIELDDOUBLE * getArea(const SUPPORT * Support)
+ {
+ return (FIELDDOUBLE *) self->getArea(Support);
+ }
+
+ FIELDDOUBLE * getLength(const SUPPORT * Support)
+ {
+ return (FIELDDOUBLE *) self->getLength(Support);
+ }
+
+ FIELDDOUBLE * getNormal(const SUPPORT * Support)
+ {
+ return (FIELDDOUBLE *) self->getNormal(Support);
+ }
+
+ FIELDDOUBLE * getBarycenter(const SUPPORT * Support)
+ {
+ return (FIELDDOUBLE *) self->getBarycenter(Support);
+ }
+ }
+} ;
+
+class MED
+{
+ public:
+ MED();
+
+ ~MED();
+
+ int getNumberOfMeshes ( void ) const;
+
+ int getNumberOfFields ( void ) const;
+
+ void updateSupport ( void ) ;
+
+ %extend {
+ const char * getMeshName(int i)
+ {
+ deque<string> list_string = self->getMeshNames();
+ char * tmp = new char[strlen(list_string[i].c_str())+1];
+ strcpy(tmp,list_string[i].c_str());
+ return tmp;
+ }
+
+ const char * getFieldName(int i)
+ {
+ deque<string> list_string = self->getFieldNames();
+ char * tmp = new char[strlen(list_string[i].c_str())+1];
+ strcpy(tmp,list_string[i].c_str());
+ return tmp;
+ }
+
+ MESH * getMesh(char * meshName)
+ {
+ MESH * myMesh = self->getMesh(string(meshName));
+ return myMesh;
+ }
+
+ int getFieldNumberOfIteration(char * fieldName)
+ {
+ deque<DT_IT_> list_dtit =
+ self->getFieldIteration(string(fieldName));
+ return list_dtit.size();
+ }
+
+ DT_IT_ getFieldIteration(char * fieldName, int i)
+ {
+ deque<DT_IT_> list_dtit =
+ self->getFieldIteration(string(fieldName));
+ return list_dtit[i];
+ }
+
+ FIELD_ * getField(char * fieldName, int dt, int it)
+ {
+ return self->getField(string(fieldName),dt,it);
+ }
+ }
+};
+
+/*
+ APPI du driver MED_MED
+*/
+
+class MED_MED_DRIVER
+{
+ public :
+ void open();
+ void close();
+
+ virtual void write ( void ) const ;
+ virtual void writeFrom ( void ) const ;
+ virtual void read ( void ) ;
+ virtual void readFileStruct ( void ) ;
+
+ %extend {
+ MED_MED_DRIVER(char * fileName, MED * ptrMed)
+ {
+ return new MED_MED_DRIVER(string(fileName), ptrMed);
+ }
+ }
+};
+
+class MED_MED_RDONLY_DRIVER : public virtual MED_MED_DRIVER
+{
+ public :
+ void open();
+ void close();
+
+ void read ( void ) ;
+ void readFileStruct ( void ) ;
+
+ %extend {
+ MED_MED_RDONLY_DRIVER(char * fileName, MED * ptrMed)
+ {
+ return new MED_MED_RDONLY_DRIVER(string(fileName), ptrMed);
+ }
+ }
+};
+
+class MED_MED_WRONLY_DRIVER : public virtual MED_MED_DRIVER
+{
+ public :
+ void open();
+ void close();
+
+ void write ( void ) const ;
+ void writeFrom ( void ) const ;
+
+ %extend {
+ MED_MED_WRONLY_DRIVER(char * fileName, MED * ptrMed)
+ {
+ return new MED_MED_WRONLY_DRIVER(string(fileName), ptrMed);
+ }
+ }
+};
+
+class MED_MED_RDWR_DRIVER : public virtual MED_MED_RDONLY_DRIVER,
+ public virtual MED_MED_WRONLY_DRIVER,
+ public virtual MED_MED_DRIVER
+{
+ public :
+ void open();
+ void close();
+
+ void write ( void ) const ;
+ void writeFrom ( void ) const ;
+ void read ( void ) ;
+ void readFileStruct ( void ) ;
+
+ %extend {
+ MED_MED_RDWR_DRIVER(char * fileName, MED * ptrMed)
+ {
+ return new MED_MED_RDWR_DRIVER(string(fileName), ptrMed);
+ }
+ }
+};
+
+/*
+ API du driver MED_MESH
+*/
+
+/*
+class MED_MESH_DRIVER
+{
+ public :
+ // MED_MESH_DRIVER();
+
+ // MED_MESH_DRIVER(const string & fileName, MESH * ptrMesh, med_mode_acces accessMode);
+
+ void open();
+ void close();
+
+ // virtual void write( void ) const = 0;
+ // virtual void read ( void ) = 0;
+
+ // void setMeshName(const string & meshName) ;
+ // string getMeshName() const ;
+
+ %extend {
+ MED_MESH_DRIVER(char * fileName, MESH * ptrMesh,
+ med_mode_acces accessMode)
+ {
+ return new MED_MESH_DRIVER(string(fileName), ptrMesh, accessMode);
+ }
+
+ void setMeshName(char * meshName)
+ {
+ self->setMeshName(string(meshName));
+ }
+
+ char * getMeshName()
+ {
+ string tmp_str = self->getMeshName();
+ char * tmp = new char[strlen(tmp_str.c_str())];
+ strcat(tmp,tmp_str.c_str());
+ return tmp;
+ }
+ }
+};
+*/
+
+class MED_MESH_RDONLY_DRIVER
+// : public virtual MED_MESH_DRIVER
+{
+ public :
+
+ // MED_MESH_RDONLY_DRIVER();
+
+ // MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh);
+
+ ~MED_MESH_RDONLY_DRIVER();
+
+ int getCOORDINATE();
+
+ int getCONNECTIVITY();
+
+ int getFAMILY();
+
+ void write( void ) ;
+
+ void read ( void ) ;
+
+ %extend {
+ MED_MESH_RDONLY_DRIVER(char * fileName, MESH * ptrMesh)
+ {
+ return new MED_MESH_RDONLY_DRIVER(string(fileName), ptrMesh);
+ }
+ }
+};
+
+class MED_MESH_WRONLY_DRIVER
+// : public virtual MED_MESH_DRIVER
+{
+ public :
+
+ // MED_MESH_WRONLY_DRIVER():MED_MESH_DRIVER() {}
+
+ // MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh);
+
+ ~MED_MESH_WRONLY_DRIVER();
+
+ void write( void ) const ;
+ void read ( void ) ;
+
+ int writeCoordinates () const;
+ int writeConnectivities (medEntityMesh entity) const;
+ int writeFamilyNumbers () const;
+ int writeFamilies (vector<FAMILY*> & families) const;
+
+ %extend {
+ MED_MESH_WRONLY_DRIVER(char * fileName, MESH * ptrMesh)
+ {
+ return new MED_MESH_WRONLY_DRIVER(string(fileName), ptrMesh);
+ }
+ }
+};
+
+class MED_MESH_RDWR_DRIVER : public MED_MESH_RDONLY_DRIVER, public MED_MESH_WRONLY_DRIVER
+{
+ public :
+
+ // MED_MESH_RDWR_DRIVER();
+
+ // MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh);
+
+ ~MED_MESH_RDWR_DRIVER();
+
+ void write(void) const ;
+ void read (void) ;
+
+ %extend {
+ MED_MESH_RDWR_DRIVER(char * fileName, MESH * ptrMesh)
+ {
+ return new MED_MESH_RDWR_DRIVER(string(fileName), ptrMesh);
+ }
+ }
+};
+
+FIELDDOUBLE * createFieldDoubleFromField(FIELD_ * field) ;
+
+FIELDINT * createFieldIntFromField(FIELD_ * field) ;
+
+%{
+ FIELDDOUBLE * createFieldDoubleFromField(FIELD_ * field)
+ {
+ MESSAGE("creatFieldDoubleFromField : Constructor (for Python API) FIELDDOUBLE with parameter FIELD_");
+ return (FIELDDOUBLE *) field;
+ }
+
+ FIELDINT * createFieldIntFromField(FIELD_ * field)
+ {
+ MESSAGE("creatFieldIntFromField : Constructor (for Python API) FIELDINT with parameter FIELD_");
+ return (FIELDINT *) field;
+ }
+%}
--- /dev/null
+###################################################################################
+#
+# This Python script is parsing a MED file using MED Memory from SALOME platform:
+# It analyses all meshes in the MED file (coordinates, connectivity of d-cells as
+# well as (d-1)-cells, families). It analyses fields stored in the MED file (d is
+# the space dimension). You can assume that it is a kind of MED file parser.
+#
+###################################################################################
+
+from libMEDMEM_Swig import *
+from random import *
+
+medFile = "carre_en_quad4_seg2.med"
+#medFile = "cube_hexa8_quad4.med"
+
+def print_ord(i):
+ if i == 0:
+ return 'first'
+ elif i == 1:
+ return 'second'
+ elif i == 2:
+ return 'third'
+ else:
+ return `i`+'th'
+
+md = MED()
+
+mdDriver = MED_MED_RDONLY_DRIVER(medFile,md)
+
+mdDriver.open()
+mdDriver.readFileStruct()
+mdDriver.close()
+
+nbMeshes = md.getNumberOfMeshes()
+
+nbFields = md.getNumberOfFields()
+
+print "The med file", medFile, "contains", nbMeshes, "mesh(es) and", nbFields, "field(s)"
+
+if (nbMeshes>0):
+ print "Mesh(es) Name(s) is(are) "
+
+ for i in range(nbMeshes):
+ mesh_name = md.getMeshName(i)
+ print " - ",mesh_name
+
+if (nbFields>0):
+ print "Field(s) Name(s) is(are) "
+
+ for i in range(nbFields):
+ field_name = md.getFieldName(i)
+ print " - ",field_name
+
+print ""
+
+if (nbMeshes>0):
+ print "Mesh(es) Analysis "
+ for i in range(nbMeshes):
+ mesh_name = md.getMeshName(i)
+ mesh = md.getMesh(mesh_name)
+ mesh.read()
+ spaceDim = mesh.getSpaceDimension()
+ meshDim = mesh.getMeshDimension()
+ print "The",print_ord(i), "mesh, '",mesh_name,"', is a",spaceDim,"D mesh on a",meshDim,"D geometry"
+ nbNodes = mesh.getNumberOfNodes()
+ print "The mesh has",nbNodes,"Nodes"
+ coordSyst = mesh.getCoordinatesSystem()
+ print "The coordinates system is",coordSyst
+ print "The Coordinates :"
+ coordNames = []
+ coordUnits = []
+ for isd in range(spaceDim):
+ coordNames.append(mesh.getCoordinateName(isd))
+ coordUnits.append(mesh.getCoordinateUnit(isd))
+
+ print "names:", coordNames
+ print "units", coordUnits
+ print "values:"
+ coordinates = mesh.getCoordinates(MED_FULL_INTERLACE)
+ for k in range(nbNodes):
+ kp1 = k+1
+ coords = []
+ for isd in range(spaceDim):
+ isdp1 = isd+1
+ coords.append(mesh.getCoordinate(kp1,isdp1))
+
+ print coords," ---- ", coordinates[k*spaceDim:((k+1)*spaceDim)]
+
+ print ""
+ print "Show the Nodal Connectivity:"
+ nbTypesCell = mesh.getNumberOfTypes(MED_CELL)
+ print ""
+ if (nbTypesCell>0):
+ print "The Mesh has",nbTypesCell,"Type(s) of Cell"
+ types = mesh.getTypes(MED_CELL)
+ for k in range(nbTypesCell):
+ type = types[k]
+ nbElemType = mesh.getNumberOfElements(MED_CELL,type)
+ print "For the type:",type,"there is(are)",nbElemType,"elemnt(s)"
+ connectivity = mesh.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,type)
+ nbNodesPerCell = type%100
+ for j in range(nbElemType):
+ print "Element",(j+1)," ",connectivity[j*nbNodesPerCell:(j+1)*nbNodesPerCell]
+
+ print ""
+ print "Show the Reverse Nodal Connectivity:"
+ ReverseConnectivity = mesh.getReverseConnectivity(MED_NODAL)
+ ReverseConnectivityIndex = mesh.getReverseConnectivityIndex(MED_NODAL)
+ print ""
+ for j in range(nbNodes):
+ begin = ReverseConnectivityIndex[j]-1
+ end = ReverseConnectivityIndex[j+1]-1
+ print "Node",(j+1),"-->",ReverseConnectivity[begin:end]
+
+ print ""
+ print "Show the Descending Connectivity:"
+ mesh.calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL)
+ nbElemts = mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)
+ Connectivity = mesh.getConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS)
+ ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,MED_CELL)
+ print ""
+ for j in range(nbElemts):
+ begin = ConnectivityIndex[j]-1
+ end = ConnectivityIndex[j+1]-1
+ print "Element",(j+1),"-->",Connectivity[begin:end]
+
+ print ""
+ for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]:
+ nbFam = mesh.getNumberOfFamilies(entity)
+ if (entity == MED_NODE) & (nbFam > 0):
+ print "This mesh has",nbFam,"Node Family(ies)"
+ elif (entity == MED_CELL) & (nbFam > 0):
+ print "This mesh has",nbFam,"Cell Family(ies)"
+ elif (entity == MED_FACE) & (nbFam > 0):
+ print "This mesh has",nbFam,"Face Family(ies)"
+ elif (entity == MED_EDGE) & (nbFam > 0):
+ print "This mesh has",nbFam,"Edge Family(ies)"
+
+ if nbFam > 0:
+ for j in range(nbFam):
+ print ""
+ family = mesh.getFamily(entity,j+1)
+ familyName = family.getName()
+ familyDescription = family.getDescription()
+ familyEntity = family.getEntity()
+ familyBool = family.isOnAllElements()
+ print " -Name:",familyName
+ print " -Description:",familyDescription
+ print " -Entity:",familyEntity
+ familyIdentifier = family.getIdentifier()
+ nbOfAtt = family.getNumberOfAttributes()
+ print " -Identifier:",familyIdentifier
+ print " -Number Of Attributes:",nbOfAtt
+ attributesids = family.getAttributesIdentifiers()
+ attributesvals = family.getAttributesValues()
+ for k in range(nbOfAtt):
+ print " * Attributes:",attributesids[k],":",attributesvals[k],",",family.getAttributeDescription(k+1)
+ nbOfGrp = family.getNumberOfGroups()
+ print " -Number Of Groups:",nbOfGrp
+ for k in range(nbOfGrp):
+ print " * Group:",family.getGroupName(k+1)
+ print " -Entities list:"
+ if (familyBool):
+ print " -Is on all entities"
+ else:
+ nbOfTypes = family.getNumberOfTypes()
+ types = family.getTypes()
+ print " -Number Of Types:",nbOfTypes
+ for k in range(nbOfTypes):
+ type = types[k]
+ nbOfElmtsOfType = family.getNumberOfElements(type)
+ number = family.getNumber(type)
+ print " * Type",type
+ print " * Number",number[0:nbOfElmtsOfType]
+ print ""
+ print " * Getting an Integer Field on the family ",familyName
+ fieldFamilyIntg = FIELDINT(family,spaceDim)
+ fieldFamilyIntg.setIterationNumber(0)
+ fieldFamilyIntg.setOrderNumber(0)
+ fieldFamilyIntg.setTime(0.0)
+ for kcomp in range(spaceDim):
+ kcomp1 = kcomp+1
+ if kcomp == 0:
+ fieldCompName = "comp1"
+ fieldCompDesc = "desc1"
+ fieldCompUnit = "unit1"
+ if kcomp == 1:
+ fieldCompName = "comp2"
+ fieldCompDesc = "desc2"
+ fieldCompUnit = "unit2"
+ if kcomp == 2:
+ fieldCompName = "comp2"
+ fieldCompDesc = "desc2"
+ fieldCompUnit = "unit2"
+
+ fieldFamilyIntg.setComponentName(kcomp1,fieldCompName)
+ fieldFamilyIntg.setComponentDescription(kcomp1,fieldCompDesc)
+ fieldFamilyIntg.setMEDComponentUnit(kcomp1,fieldCompUnit)
+ fieldFamilyName = "Integer Field on "+familyName
+ fieldFamilyIntg.setName(fieldFamilyName)
+ field_name = fieldFamilyIntg.getName()
+ type_field = fieldFamilyIntg.getValueType()
+ nbOfComp = fieldFamilyIntg.getNumberOfComponents()
+ print " The field",field_name,"is with the type",type_field
+ print " It has",nbOfComp,"Component(s)"
+ for kcomp in range(nbOfComp):
+ kcomp1 = kcomp+1
+ compName = fieldFamilyIntg.getComponentName(kcomp1)
+ compDesc = fieldFamilyIntg.getComponentDescription(kcomp1)
+ compUnit = fieldFamilyIntg.getMEDComponentUnit(kcomp1)
+ print " * Component:",kcomp1
+ print " Name:",compName
+ print " Description:",compDesc
+ print " Unit:",compUnit
+
+ nbOf = fieldFamilyIntg.getSupport().getNumberOfElements(MED_ALL_ELEMENTS)
+ print " Values:",nbOf
+ print " Randomly set and get to check ..!"
+ mode = MED_FULL_INTERLACE
+ for k in range(nbOf):
+ valueI = []
+ for kcomp in range(nbOfComp):
+ valueI.append(randint(0,100))
+
+# print " Set Entry *",(k+1)," ",valueI[:nbOfComp]
+
+ fieldFamilyIntg.setValueI(mode,k+1,valueI)
+ valueIverif = fieldFamilyIntg.getValueI(mode,k+1)
+ print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
+ print " * Getting a Real Field"
+ fieldFamilyDble = FIELDDOUBLE(family,spaceDim)
+ fieldFamilyDble.setIterationNumber(0)
+ fieldFamilyDble.setOrderNumber(0)
+ fieldFamilyDble.setTime(0.0)
+ for kcomp in range(spaceDim):
+ kcomp1 = kcomp+1
+ if kcomp == 0:
+ fieldCompName = "comp1"
+ fieldCompDesc = "desc1"
+ fieldCompUnit = "unit1"
+ if kcomp == 1:
+ fieldCompName = "comp2"
+ fieldCompDesc = "desc2"
+ fieldCompUnit = "unit2"
+ if kcomp == 2:
+ fieldCompName = "comp2"
+ fieldCompDesc = "desc2"
+ fieldCompUnit = "unit2"
+
+ fieldFamilyDble.setComponentName(kcomp1,fieldCompName)
+ fieldFamilyDble.setComponentDescription(kcomp1,fieldCompDesc)
+ fieldFamilyDble.setMEDComponentUnit(kcomp1,fieldCompUnit)
+
+ fieldFamilyName = "Real Field on "+familyName
+ fieldFamilyDble.setName(fieldFamilyName)
+ field_name = fieldFamilyDble.getName()
+ type_field = fieldFamilyDble.getValueType()
+ nbOfComp = fieldFamilyDble.getNumberOfComponents()
+ print " The field",field_name,"is with the type",type_field
+ print " It has",nbOfComp,"Component(s)"
+ for kcomp in range(nbOfComp):
+ kcomp1 = kcomp+1
+ compName = fieldFamilyDble.getComponentName(kcomp1)
+ compDesc = fieldFamilyDble.getComponentDescription(kcomp1)
+ compUnit = fieldFamilyDble.getMEDComponentUnit(kcomp1)
+ print " * Component:",kcomp1
+ print " Name:",compName
+ print " Description:",compDesc
+ print " Unit:",compUnit
+
+ nbOf = fieldFamilyDble.getSupport().getNumberOfElements(MED_ALL_ELEMENTS)
+ print " Values:",nbOf
+ print " Randomly set and get to check ..!"
+ for k in range(nbOf):
+ valueI = []
+ for kcomp in range(nbOfComp):
+ valueI.append(random())
+
+# print " Set Entry *",(k+1)," ",valueI[:nbOfComp]
+
+ fieldFamilyDble.setValueI(MED_FULL_INTERLACE,k+1,valueI)
+ valueIverif = fieldFamilyDble.getValueI(MED_FULL_INTERLACE,k+1)
+ print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
+ print ""
+ print ""
+ for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]:
+ nbGrp = mesh.getNumberOfGroups(entity)
+ if (entity == MED_NODE) & (nbGrp > 0):
+ print "This mesh has",nbGrp,"Node Group(s)"
+ elif (entity == MED_CELL) & (nbGrp > 0):
+ print "This mesh has",nbGrp,"Cell Group(s)"
+ elif (entity == MED_FACE) & (nbGrp > 0):
+ print "This mesh has",nbGrp,"Face Group(s)"
+ elif (entity == MED_EDGE) & (nbGrp > 0):
+ print "This mesh has",nbGrp,"Edge Group(s)"
+
+ if nbGrp > 0:
+ for j in range(nbGrp):
+ print ""
+ group = mesh.getGroup(entity,j+1)
+ groupName = group.getName()
+ groupDescription = group.getDescription()
+ groupEntity = group.getEntity()
+ groupBool = group.isOnAllElements()
+ print " -Name:",groupName
+ print " -Description:",groupDescription
+ print " -Entity:",groupEntity
+ nbOfFam = group.getNumberOfFamilies()
+ print " -Number Of Families:",nbOfFam
+ for k in range(nbOfFam):
+ print " * Family:",group.getFamily(k+1).getName()
+ print " -Entities list:"
+ if (groupBool):
+ print " -Is on all entities"
+ else:
+ nbOfTypes = group.getNumberOfTypes()
+ types = group.getTypes()
+ print " -Number Of Types:",nbOfTypes
+ for k in range(nbOfTypes):
+ type = types[k]
+ nbOfElmtsOfType = group.getNumberOfElements(type)
+ number = group.getNumber(type)
+ print " * Type",type
+ print " * Number",number[0:nbOfElmtsOfType]
+ print ""
+ print ""
+
+ print "Building of the support on all Cells of the mesh."
+ supportCell = SUPPORT(mesh)
+ supportCell.update()
+ print ""
+ barycenter = mesh.getBarycenter(supportCell)
+ print "Getting barycenter of all Cells of the mesh"
+ for j in range(nbElemts):
+ barycenterCell = barycenter.getValueI(MED_FULL_INTERLACE,j+1)
+ print " * ",barycenterCell[:spaceDim]
+ print ""
+ if spaceDim == 3 :
+ print "Getting volume of all Cells of the mesh:"
+ volume = mesh.getVolume(supportCell)
+ voltot = 0.
+ for j in range(nbElemts):
+ volumeCell = volume.getValueIJ(j+1,1)
+ print " * ",volumeCell
+ voltot = voltot + volumeCell
+ print "Volume of the mesh:",voltot
+ print ""
+ print "Building of the support on all Faces of the mesh."
+ supportFace = SUPPORT(mesh,"Support on all faces of the mesh",MED_FACE)
+ nbFace = mesh.getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS)
+ print ""
+ print "Getting normal of each face of this support",nbFace
+ nbTypeFace = mesh.getNumberOfTypes(MED_FACE)
+ TypeFace = mesh.getTypes(MED_FACE)
+ print "nbTypeFace:",nbTypeFace,"----",TypeFace[:nbTypeFace]
+ normal = mesh.getNormal(supportFace)
+ for j in range(nbFace):
+ normalFace = normal.getValueI(MED_FULL_INTERLACE,j+1)
+ value1 = normalFace[0]
+ value2 = normalFace[1]
+ value3 = normalFace[2]
+ norm = (value1*value1 + value2*value2 + value3*value3)**(0.5)
+ print " * ",normalFace[:spaceDim],"norm:",norm
+ elif spaceDim == 2:
+ print "Getting area on all Cells of the mesh:"
+ area = mesh.getArea(supportCell)
+ areatot = 0.
+ for j in range(nbElemts):
+ areaCell = area.getValueIJ(j+1,1)
+ print " * ",areaCell
+ areatot = areatot + areaCell
+ print "Area of the mesh:",areatot
+ print ""
+ print "Building of the support on all Edges of the mesh."
+ supportEdge = SUPPORT(mesh,"Support on all edges of the mesh",MED_EDGE)
+ nbEdge = mesh.getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS)
+ print ""
+ print "Getting normal of each edge of this support",nbEdge
+ nbTypeEdge = mesh.getNumberOfTypes(MED_EDGE)
+ TypeEdge = mesh.getTypes(MED_EDGE)
+ print "nbTypeEdge:",nbTypeEdge,"----",TypeEdge[:nbTypeEdge]
+ normal = mesh.getNormal(supportEdge)
+ for j in range(nbEdge):
+ normalEdge = normal.getValueI(MED_FULL_INTERLACE,j+1)
+ value1 = normalEdge[0]
+ value2 = normalEdge[1]
+ norm = (value1*value1 + value2*value2)**(0.5)
+ print " * ",normalEdge[:spaceDim],"norm:",norm
+ print ""
+ print "Building support on Elements of the boundary"
+ if spaceDim == 3 :
+ suppBound = mesh.getBoundaryElements(MED_FACE)
+ nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS)
+ print "Getting normal field on the boundary",nbElmBound
+ normalBound = mesh.getNormal(suppBound)
+ for j in range(nbElmBound):
+ normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1)
+ value1 = normalBoundJ[0]
+ value2 = normalBoundJ[1]
+ value3 = normalBoundJ[2]
+ norm = (value1*value1 + value2*value2 + value3*value3)**(0.5)
+ print " * ",normalBoundJ[:spaceDim],"norm:",norm
+ elif spaceDim == 2:
+ suppBound = mesh.getBoundaryElements(MED_EDGE)
+ nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS)
+ print "Getting normal field on the boundary",nbElmBound
+ normalBound = mesh.getNormal(suppBound)
+ for j in range(nbElmBound):
+ normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1)
+ value1 = normalBoundJ[0]
+ value2 = normalBoundJ[1]
+ norm = (value1*value1 + value2*value2)**(0.5)
+ print " * ",normalBoundJ[:spaceDim],"norm:",norm
+ print ""
+if (nbFields>0):
+ print "Field(s) Analysis "
+ for i in range(nbFields):
+ field_name = md.getFieldName(i)
+ nbOfIt = md.getFieldNumberOfIteration(field_name)
+ print "The",print_ord(i),"field is",field_name,"with",nbOfIt,"iteration(s)"
+ for j in range(nbOfIt):
+ dtitfield = md.getFieldIteration(field_name,j)
+ dt = dtitfield.getdt()
+ it = dtitfield.getit()
+ field = md.getField(field_name,dt,it)
+ type = field.getValueType()
+ print " * Iteration:",dt,"Order number:",it,"Type:",type
+ if type == MED_INT32:
+ fieldint = createFieldIntFromField(field)
+ fieldint.read()
+ name = fieldint.getName()
+ desc = fieldint.getDescription()
+ nbOfComp = fieldint.getNumberOfComponents()
+ print " Field",name," : ",desc
+ print " Number Of Components:",nbOfComp
+ iterationNb = fieldint.getIterationNumber()
+ orderNb = fieldint.getOrderNumber()
+ time = fieldint.getTime()
+ print " Iteration Number",iterationNb
+ print " Order Number",orderNb
+ print " Time",time
+ for k in range(nbOfComp):
+ kp1 = k+1
+ compName = fieldint.getComponentName(kp1)
+ compDesc = fieldint.getComponentDescription(kp1)
+ compUnit = fieldint.getMEDComponentUnit(kp1)
+ print " * Component:",kp1
+ print " Name:",compName
+ print " Description:",compDesc
+ print " Unit:",compUnit
+
+ support = fieldint.getSupport()
+ nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+ print " Values:",nbOf
+ for k in range(nbOf):
+ valueI = fieldint.getValueI(MED_FULL_INTERLACE,k+1)
+ print " *",valueI[:nbOfComp]
+ elif type == MED_REEL64:
+ fielddouble = createFieldDoubleFromField(field)
+ fielddouble.read()
+ name = fielddouble.getName()
+ desc = fielddouble.getDescription()
+ nbOfComp = fielddouble.getNumberOfComponents()
+ print " Field",name," : ",desc
+ print " Number Of Components:",nbOfComp
+ iterationNb = fielddouble.getIterationNumber()
+ orderNb = fielddouble.getOrderNumber()
+ time = fielddouble.getTime()
+ print " Iteration Number",iterationNb
+ print " Order Number",orderNb
+ print " Time",time
+ for k in range(nbOfComp):
+ kp1 = k+1
+ compName = fielddouble.getComponentName(kp1)
+ compDesc = fielddouble.getComponentDescription(kp1)
+ compUnit = fielddouble.getMEDComponentUnit(kp1)
+ print " * Component:",kp1
+ print " Name:",compName
+ print " Description:",compDesc
+ print " Unit:",compUnit
+
+ support = fielddouble.getSupport()
+ nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+ print " Values:",nbOf
+ for k in range(nbOf):
+ valueI = fielddouble.getValueI(MED_FULL_INTERLACE,k+1)
+ print " *",valueI[:nbOfComp]
+ else:
+ print " !!!! Bad type of Field !!!!"
+
--- /dev/null
+###################################################################################
+#
+# This Python script is parsing a MED file using MED Memory from SALOME platform:
+# It analyses all meshes in the MED file (coordinates, connectivity of d-cells as
+# well as (d-1)-cells, families), it tests all fields generated ine the MESH class
+# and write them in a new file , it gives only the number of fields stored in the
+# MED file (d is the space dimension).
+#
+###################################################################################
+
+from libMEDMEM_Swig import *
+from random import *
+
+#==============================================================================
+
+def AnalyzeField(field):
+ name = field.getName()
+ desc = field.getDescription()
+ nbComp = field.getNumberOfComponents()
+ itNum = field.getIterationNumber()
+ ordNum = field.getOrderNumber()
+ type = field.getValueType()
+
+ print "Analysis of the field ",name," with the description ",desc
+ print "iteration number ",itNum," order Number ",ordNum
+ print "It has ",nbComp," component(s) with the type ",type
+
+ fieldValue = field.getValue(MED_FULL_INTERLACE)
+ fieldSupport = field.getSupport()
+ fieldMesh = fieldSupport.getMesh()
+ fieldEntity = fieldSupport.getEntity()
+ bool = fieldSupport.isOnAllElements()
+
+ if bool:
+ print "The support of this field is on all entities ",fieldEntity," of the mesh ",fieldMesh.getName()
+ if fieldEntity == MED_NODE:
+ nbValByComp = fieldMesh.getNumberOfNodes()
+ else:
+ nbValByComp = fieldMesh.getNumberOfElements(fieldEntity,MED_ALL_ELEMENTS)
+ print "and its dimension (number of values by component of the field) is ",nbValByComp
+ else:
+ print "The support of this field is partially on entities ",fieldEntity," of the mesh ",fieldMesh.getName()
+ nbValByComp = fieldSupport.getNumberOfElements(MED_ALL_ELEMENTS)
+ print "and its dimension (number of values by component of the field) is ",nbValByComp
+
+ for i in range(nbComp):
+ ip1 = i + 1
+ compName = field.getComponentName(ip1)
+ compDesc = field.getComponentDescription(ip1)
+ compUnit = field.getMEDComponentUnit(ip1)
+ print "The ",(i+1),"-th component ",compName," with the dexription ",compDesc," and the unit ",compUnit
+
+ for i in range(nbValByComp):
+ print " * ",fieldValue[i*nbComp:(i+1)*nbComp]
+
+#==============================================================================
+
+medFile = "carre_en_quad4_seg2.med"
+#medFile = "cube_hexa8_quad4.med"
+
+def print_ord(i):
+ if i == 0:
+ return 'first'
+ elif i == 1:
+ return 'second'
+ elif i == 2:
+ return 'third'
+ else:
+ return `i`+'th'
+
+md = MED()
+
+mdDriver = MED_MED_RDONLY_DRIVER(medFile,md)
+
+mdDriver.open()
+mdDriver.readFileStruct()
+mdDriver.close()
+
+nbMeshes = md.getNumberOfMeshes()
+
+nbFields = md.getNumberOfFields()
+
+print "The med file", medFile, "contains", nbMeshes, "mesh(es) and", nbFields, "field(s)"
+
+if (nbMeshes>0):
+ print "Mesh(es) Name(s) is(are) "
+
+ for i in range(nbMeshes):
+ mesh_name = md.getMeshName(i)
+ print " - ",mesh_name
+
+if (nbFields>0):
+ print "Field(s) Name(s) is(are) "
+
+ for i in range(nbFields):
+ field_name = md.getFieldName(i)
+ print " - ",field_name
+
+print ""
+
+if (nbMeshes>0):
+ print "Mesh(es) Analysis "
+ for i in range(nbMeshes):
+ mesh_name = md.getMeshName(i)
+ mesh = md.getMesh(mesh_name)
+ mesh.read()
+ spaceDim = mesh.getSpaceDimension()
+ meshDim = mesh.getMeshDimension()
+ print "The",print_ord(i), "mesh, '",mesh_name,"', is a",spaceDim,"D mesh on a",meshDim,"D geometry"
+ nbNodes = mesh.getNumberOfNodes()
+ print "The mesh has",nbNodes,"Nodes"
+ coordSyst = mesh.getCoordinatesSystem()
+ print "The coordinates system is",coordSyst
+ print "The Coordinates :"
+ coordNames = []
+ coordUnits = []
+ for isd in range(spaceDim):
+ coordNames.append(mesh.getCoordinateName(isd))
+ coordUnits.append(mesh.getCoordinateUnit(isd))
+
+ print "names:", coordNames
+ print "units", coordUnits
+ print "values:"
+ coordinates = mesh.getCoordinates(MED_FULL_INTERLACE)
+ for k in range(nbNodes):
+ kp1 = k+1
+ coords = []
+ for isd in range(spaceDim):
+ isdp1 = isd+1
+ coords.append(mesh.getCoordinate(kp1,isdp1))
+
+ print coords," ---- ", coordinates[k*spaceDim:((k+1)*spaceDim)]
+
+ print ""
+ print "Show the Nodal Connectivity:"
+ nbTypesCell = mesh.getNumberOfTypes(MED_CELL)
+ print ""
+ if (nbTypesCell>0):
+ print "The Mesh has",nbTypesCell,"Type(s) of Cell"
+ types = mesh.getTypes(MED_CELL)
+ for k in range(nbTypesCell):
+ type = types[k]
+ nbElemType = mesh.getNumberOfElements(MED_CELL,type)
+ print "For the type:",type,"there is(are)",nbElemType,"elemnt(s)"
+ connectivity = mesh.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,type)
+ nbNodesPerCell = type%100
+ for j in range(nbElemType):
+ print "Element",(j+1)," ",connectivity[j*nbNodesPerCell:(j+1)*nbNodesPerCell]
+
+ print ""
+ print "Show the Reverse Nodal Connectivity:"
+ ReverseConnectivity = mesh.getReverseConnectivity(MED_NODAL)
+ ReverseConnectivityIndex = mesh.getReverseConnectivityIndex(MED_NODAL)
+ print ""
+ for j in range(nbNodes):
+ begin = ReverseConnectivityIndex[j]-1
+ end = ReverseConnectivityIndex[j+1]-1
+ print "Node",(j+1),"-->",ReverseConnectivity[begin:end]
+
+ print ""
+ print "Show the Descending Connectivity:"
+ mesh.calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL)
+ nbElemts = mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)
+ Connectivity = mesh.getConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS)
+ ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,MED_CELL)
+ print ""
+ for j in range(nbElemts):
+ begin = ConnectivityIndex[j]-1
+ end = ConnectivityIndex[j+1]-1
+ print "Element",(j+1),"-->",Connectivity[begin:end]
+
+ print ""
+ for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]:
+ nbFam = mesh.getNumberOfFamilies(entity)
+ if (entity == MED_NODE) & (nbFam > 0):
+ print "This mesh has",nbFam,"Node Family(ies)"
+ elif (entity == MED_CELL) & (nbFam > 0):
+ print "This mesh has",nbFam,"Cell Family(ies)"
+ elif (entity == MED_FACE) & (nbFam > 0):
+ print "This mesh has",nbFam,"Face Family(ies)"
+ elif (entity == MED_EDGE) & (nbFam > 0):
+ print "This mesh has",nbFam,"Edge Family(ies)"
+
+ if nbFam > 0:
+ for j in range(nbFam):
+ print ""
+ family = mesh.getFamily(entity,j+1)
+ familyName = family.getName()
+ familyDescription = family.getDescription()
+ familyEntity = family.getEntity()
+ familyBool = family.isOnAllElements()
+ print " -Name:",familyName
+ print " -Description:",familyDescription
+ print " -Entity:",familyEntity
+ familyIdentifier = family.getIdentifier()
+ nbOfAtt = family.getNumberOfAttributes()
+ print " -Identifier:",familyIdentifier
+ print " -Number Of Attributes:",nbOfAtt
+ attributesids = family.getAttributesIdentifiers()
+ attributesvals = family.getAttributesValues()
+ for k in range(nbOfAtt):
+ print " * Attributes:",attributesids[k],":",attributesvals[k],",",family.getAttributeDescription(k+1)
+ nbOfGrp = family.getNumberOfGroups()
+ print " -Number Of Groups:",nbOfGrp
+ for k in range(nbOfGrp):
+ print " * Group:",family.getGroupName(k+1)
+ print " -Entities list:"
+ if (familyBool):
+ print " -Is on all entities"
+ else:
+ nbOfTypes = family.getNumberOfTypes()
+ types = family.getTypes()
+ print " -Number Of Types:",nbOfTypes
+ for k in range(nbOfTypes):
+ type = types[k]
+ nbOfElmtsOfType = family.getNumberOfElements(type)
+ number = family.getNumber(type)
+ print " * Type",type
+ print " * Number",number[0:nbOfElmtsOfType]
+ print ""
+ print " * Getting an Integer Field on the family ",familyName
+ fieldFamilyIntg = FIELDINT(family,spaceDim)
+ fieldFamilyIntg.setIterationNumber(0)
+ fieldFamilyIntg.setOrderNumber(0)
+ fieldFamilyIntg.setTime(0.0)
+ for kcomp in range(spaceDim):
+ kcomp1 = kcomp+1
+ if kcomp == 0:
+ fieldCompName = "comp1"
+ fieldCompDesc = "desc1"
+ fieldCompUnit = "unit1"
+ if kcomp == 1:
+ fieldCompName = "comp2"
+ fieldCompDesc = "desc2"
+ fieldCompUnit = "unit2"
+ if kcomp == 2:
+ fieldCompName = "comp2"
+ fieldCompDesc = "desc2"
+ fieldCompUnit = "unit2"
+
+ fieldFamilyIntg.setComponentName(kcomp1,fieldCompName)
+ fieldFamilyIntg.setComponentDescription(kcomp1,fieldCompDesc)
+ fieldFamilyIntg.setMEDComponentUnit(kcomp1,fieldCompUnit)
+ fieldFamilyName = "Integer Field on "+familyName
+ fieldFamilyIntg.setName(fieldFamilyName)
+ field_name = fieldFamilyIntg.getName()
+ type_field = fieldFamilyIntg.getValueType()
+ nbOfComp = fieldFamilyIntg.getNumberOfComponents()
+ print " The field",field_name,"is with the type",type_field
+ print " It has",nbOfComp,"Component(s)"
+ for kcomp in range(nbOfComp):
+ kcomp1 = kcomp+1
+ compName = fieldFamilyIntg.getComponentName(kcomp1)
+ compDesc = fieldFamilyIntg.getComponentDescription(kcomp1)
+ compUnit = fieldFamilyIntg.getMEDComponentUnit(kcomp1)
+ print " * Component:",kcomp1
+ print " Name:",compName
+ print " Description:",compDesc
+ print " Unit:",compUnit
+
+ nbOf = fieldFamilyIntg.getSupport().getNumberOfElements(MED_ALL_ELEMENTS)
+ print " Values:",nbOf
+ print " Randomly set and get to check ..!"
+ mode = MED_FULL_INTERLACE
+ for k in range(nbOf):
+ valueI = []
+ for kcomp in range(nbOfComp):
+ valueI.append(randint(0,100))
+
+# print " Set Entry *",(k+1)," ",valueI[:nbOfComp]
+
+ fieldFamilyIntg.setValueI(mode,k+1,valueI)
+ valueIverif = fieldFamilyIntg.getValueI(mode,k+1)
+ print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
+ print " * Getting a Real Field"
+ fieldFamilyDble = FIELDDOUBLE(family,spaceDim)
+ fieldFamilyDble.setIterationNumber(0)
+ fieldFamilyDble.setOrderNumber(0)
+ fieldFamilyDble.setTime(0.0)
+ for kcomp in range(spaceDim):
+ kcomp1 = kcomp+1
+ if kcomp == 0:
+ fieldCompName = "comp1"
+ fieldCompDesc = "desc1"
+ fieldCompUnit = "unit1"
+ if kcomp == 1:
+ fieldCompName = "comp2"
+ fieldCompDesc = "desc2"
+ fieldCompUnit = "unit2"
+ if kcomp == 2:
+ fieldCompName = "comp2"
+ fieldCompDesc = "desc2"
+ fieldCompUnit = "unit2"
+
+ fieldFamilyDble.setComponentName(kcomp1,fieldCompName)
+ fieldFamilyDble.setComponentDescription(kcomp1,fieldCompDesc)
+ fieldFamilyDble.setMEDComponentUnit(kcomp1,fieldCompUnit)
+
+ fieldFamilyName = "Real Field on "+familyName
+ fieldFamilyDble.setName(fieldFamilyName)
+ field_name = fieldFamilyDble.getName()
+ type_field = fieldFamilyDble.getValueType()
+ nbOfComp = fieldFamilyDble.getNumberOfComponents()
+ print " The field",field_name,"is with the type",type_field
+ print " It has",nbOfComp,"Component(s)"
+ for kcomp in range(nbOfComp):
+ kcomp1 = kcomp+1
+ compName = fieldFamilyDble.getComponentName(kcomp1)
+ compDesc = fieldFamilyDble.getComponentDescription(kcomp1)
+ compUnit = fieldFamilyDble.getMEDComponentUnit(kcomp1)
+ print " * Component:",kcomp1
+ print " Name:",compName
+ print " Description:",compDesc
+ print " Unit:",compUnit
+
+ nbOf = fieldFamilyDble.getSupport().getNumberOfElements(MED_ALL_ELEMENTS)
+ print " Values:",nbOf
+ print " Randomly set and get to check ..!"
+ for k in range(nbOf):
+ valueI = []
+ for kcomp in range(nbOfComp):
+ valueI.append(random())
+
+# print " Set Entry *",(k+1)," ",valueI[:nbOfComp]
+
+ fieldFamilyDble.setValueI(MED_FULL_INTERLACE,k+1,valueI)
+ valueIverif = fieldFamilyDble.getValueI(MED_FULL_INTERLACE,k+1)
+ print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
+ if (entity != MED_NODE):
+ print ""
+ print "Getting barycenter on this family"
+ barycenterfamily = mesh.getBarycenter(family)
+ nbVal = barycenterfamily.getSupport().getNumberOfElements(MED_ALL_ELEMENTS)
+ nbComp = barycenterfamily.getNumberOfComponents()
+ for j in range(nbVal):
+ barycenterfamilyentity = barycenterfamily.getValueI(MED_FULL_INTERLACE,j+1)
+ print " * ",barycenterfamilyentity[:nbComp]
+ print ""
+
+ print "Building of the support on all Cells of the mesh."
+ supportCell = SUPPORT(mesh)
+ supportCell.update()
+ print ""
+ print "Getting barycenter of all Cells of the mesh"
+ barycenter = mesh.getBarycenter(supportCell)
+ for j in range(nbElemts):
+ barycenterCell = barycenter.getValueI(MED_FULL_INTERLACE,j+1)
+ print " * ",barycenterCell[:spaceDim]
+
+ print "Writing on file the mesh"
+
+ writeMedFile = medFile[0:(len(medFile)-4)]+"_fields.med"
+ fieldsMesh = barycenter.getSupport().getMesh()
+ fieldsMeshName = "Fields Mesh"
+ fieldsMesh.setName(fieldsMeshName)
+ indexMesh = fieldsMesh.addDriver(MED_DRIVER,writeMedFile,fieldsMeshName)
+ fieldsMesh.write(indexMesh,"")
+
+ AnalyzeField(barycenter)
+
+ print "Writing on file the cells barycenter field"
+
+ barycenterName = barycenter.getName()
+ indexFieldBarycenter = barycenter.addDriver(MED_DRIVER,writeMedFile,barycenterName)
+ barycenter.write(indexFieldBarycenter,"")
+
+ print ""
+ if spaceDim == 3 :
+ print "Getting volume of all Cells of the mesh:"
+ volume = mesh.getVolume(supportCell)
+ voltot = 0.
+ for j in range(nbElemts):
+ volumeCell = volume.getValueIJ(j+1,1)
+ print " * ",volumeCell
+ voltot = voltot + volumeCell
+ print "Volume of the mesh:",voltot
+ print ""
+
+ AnalyzeField(volume)
+
+ print "Writing on file the cells volume field"
+
+ volumeName = volume.getName()
+ indexFieldVolume = volume.addDriver(MED_DRIVER,writeMedFile,volumeName)
+ volume.write(indexFieldVolume,"")
+
+ print ""
+ print "Building of the support on all Faces of the mesh."
+ supportFace = SUPPORT(mesh,"Support on all faces of the mesh",MED_FACE)
+ supportFace.update()
+ nbFace = mesh.getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS)
+ print ""
+ print "Getting normal of each face of this support",nbFace
+ nbTypeFace = mesh.getNumberOfTypes(MED_FACE)
+ TypeFace = mesh.getTypes(MED_FACE)
+ print "nbTypeFace:",nbTypeFace,"----",TypeFace[:nbTypeFace]
+ normal = mesh.getNormal(supportFace)
+ for j in range(nbFace):
+ normalFace = normal.getValueI(MED_FULL_INTERLACE,j+1)
+ value1 = normalFace[0]
+ value2 = normalFace[1]
+ value3 = normalFace[2]
+ norm = (value1*value1 + value2*value2 + value3*value3)**(0.5)
+ print " * ",normalFace[:spaceDim],"norm:",norm
+ print ""
+
+ AnalyzeField(normal)
+
+ print "Writing on file the face normal field"
+
+ normalName = normal.getName()
+ indexFieldNormal = normal.addDriver(MED_DRIVER,writeMedFile,normalName)
+ normal.write(indexFieldNormal,"")
+
+ elif spaceDim == 2:
+ print "Getting area on all Cells of the mesh:"
+ area = mesh.getArea(supportCell)
+ areatot = 0.
+ for j in range(nbElemts):
+ areaCell = area.getValueIJ(j+1,1)
+ print " * ",areaCell
+ areatot = areatot + areaCell
+ print "Area of the mesh:",areatot
+ print ""
+
+ AnalyzeField(area)
+
+ print "Writing on file the cells area field"
+
+ areaName = area.getName()
+ indexFieldArea = area.addDriver(MED_DRIVER,writeMedFile,areaName)
+ area.write(indexFieldArea,"")
+ print ""
+ print "Building of the support on all Edges of the mesh."
+ supportEdge = SUPPORT(mesh,"Support on all edges of the mesh",MED_EDGE)
+ supportEdge.update()
+ nbEdge = mesh.getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS)
+ print ""
+ print "Getting normal of each edge of this support",nbEdge
+ nbTypeEdge = mesh.getNumberOfTypes(MED_EDGE)
+ TypeEdge = mesh.getTypes(MED_EDGE)
+ print "nbTypeEdge:",nbTypeEdge,"----",TypeEdge[:nbTypeEdge]
+ normal = mesh.getNormal(supportEdge)
+ for j in range(nbEdge):
+ normalEdge = normal.getValueI(MED_FULL_INTERLACE,j+1)
+ value1 = normalEdge[0]
+ value2 = normalEdge[1]
+ norm = (value1*value1 + value2*value2)**(0.5)
+ print " * ",normalEdge[:spaceDim],"norm:",norm
+ print ""
+
+ AnalyzeField(normal)
+
+ print "Writing on file the edge normal field"
+
+ normalName = normal.getName()
+ indexFieldNormal = normal.addDriver(MED_DRIVER,writeMedFile,normalName)
+ normal.write(indexFieldNormal,"")
+ print ""
--- /dev/null
+###################################################################################
+#
+# This Python script is parsing a MED file using MED Memory from SALOME platform:
+# It tests the setValue(I) function on MED fields
+#
+###################################################################################
+
+from libMEDMEM_Swig import *
+from random import *
+
+medFile = "carre_en_quad4_seg2.med"
+#medFile = "cube_hexa8_quad4.med"
+
+def print_ord(i):
+ if i == 0:
+ return 'first'
+ elif i == 1:
+ return 'second'
+ elif i == 2:
+ return 'third'
+ else:
+ return `i`+'th'
+
+md = MED()
+
+mdDriver = MED_MED_RDONLY_DRIVER(medFile,md)
+
+mdDriver.open()
+mdDriver.readFileStruct()
+mdDriver.close()
+
+nbMeshes = md.getNumberOfMeshes()
+
+nbFields = md.getNumberOfFields()
+
+print "The med file", medFile, "contains", nbMeshes, "mesh(es) and", nbFields, "field(s)"
+
+if (nbMeshes>0):
+ print "Mesh(es) Name(s) is(are) "
+
+ for i in range(nbMeshes):
+ mesh_name = md.getMeshName(i)
+ print " - ",mesh_name
+
+if (nbFields>0):
+ print "Field(s) Name(s) is(are) "
+
+ for i in range(nbFields):
+ field_name = md.getFieldName(i)
+ print " - ",field_name
+
+print ""
+
+if (nbMeshes>0):
+ print "Mesh(es) Analysis "
+ for i in range(nbMeshes):
+ mesh_name = md.getMeshName(i)
+ mesh = md.getMesh(mesh_name)
+ mesh.read()
+ spaceDim = mesh.getSpaceDimension()
+ for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]:
+ nbFam = mesh.getNumberOfFamilies(entity)
+ if (entity == MED_NODE) & (nbFam > 0):
+ print "This mesh has",nbFam,"Node Family(ies)"
+ elif (entity == MED_CELL) & (nbFam > 0):
+ print "This mesh has",nbFam,"Cell Family(ies)"
+ elif (entity == MED_FACE) & (nbFam > 0):
+ print "This mesh has",nbFam,"Face Family(ies)"
+ elif (entity == MED_EDGE) & (nbFam > 0):
+ print "This mesh has",nbFam,"Edge Family(ies)"
+
+ if nbFam > 0:
+ for j in range(nbFam):
+ print ""
+ family = mesh.getFamily(entity,j+1)
+ familyName = family.getName()
+ familyDescription = family.getDescription()
+ familyEntity = family.getEntity()
+ familyBool = family.isOnAllElements()
+ print " -Name:",familyName
+ print " -Description:",familyDescription
+ print " -Entity:",familyEntity
+ familyIdentifier = family.getIdentifier()
+ nbOfAtt = family.getNumberOfAttributes()
+ print " -Identifier:",familyIdentifier
+ print " -Number Of Attributes:",nbOfAtt
+ attributesids = family.getAttributesIdentifiers()
+ attributesvals = family.getAttributesValues()
+ for k in range(nbOfAtt):
+ print " * Attributes:",attributesids[k],":",attributesvals[k],",",family.getAttributeDescription(k+1)
+ nbOfGrp = family.getNumberOfGroups()
+ print " -Number Of Groups:",nbOfGrp
+ for k in range(nbOfGrp):
+ print " * Group:",family.getGroupName(k+1)
+ print " -Entities list:"
+ if (familyBool):
+ print " -Is on all entities"
+ else:
+ nbOfTypes = family.getNumberOfTypes()
+ types = family.getTypes()
+ print " -Number Of Types:",nbOfTypes
+ for k in range(nbOfTypes):
+ type = types[k]
+ nbOfElmtsOfType = family.getNumberOfElements(type)
+ number = family.getNumber(type)
+ print " * Type",type
+ print " * Number",number[0:nbOfElmtsOfType]
+ print ""
+ print " * Getting an Integer Field on the family ",familyName
+ fieldFamilyIntg = FIELDINT(family,spaceDim)
+ fieldFamilyIntg.setIterationNumber(0)
+ fieldFamilyIntg.setOrderNumber(0)
+ fieldFamilyIntg.setTime(0.0)
+ for kcomp in range(spaceDim):
+ if kcomp == 0:
+ fieldCompName = "comp1"
+ fieldCompDesc = "desc1"
+ fieldCompUnit = "unit1"
+ if kcomp == 1:
+ fieldCompName = "comp2"
+ fieldCompDesc = "desc2"
+ fieldCompUnit = "unit2"
+ if kcomp == 2:
+ fieldCompName = "comp2"
+ fieldCompDesc = "desc2"
+ fieldCompUnit = "unit2"
+
+ kcomp1 = kcomp+1
+ fieldFamilyIntg.setComponentName(kcomp1,fieldCompName)
+ fieldFamilyIntg.setComponentDescription(kcomp1,fieldCompDesc)
+ fieldFamilyIntg.setMEDComponentUnit(kcomp1,fieldCompUnit)
+ fieldFamilyName = "Integer Field on "+familyName
+ fieldFamilyIntg.setName(fieldFamilyName)
+ field_name = fieldFamilyIntg.getName()
+ type_field = fieldFamilyIntg.getValueType()
+ nbOfComp = fieldFamilyIntg.getNumberOfComponents()
+ print " The field",field_name,"is with the type",type_field
+ print " It has",nbOfComp,"Component(s)"
+ for kcomp in range(nbOfComp):
+ kcomp1 = kcomp+1
+ compName = fieldFamilyIntg.getComponentName(kcomp1)
+ compDesc = fieldFamilyIntg.getComponentDescription(kcomp1)
+ compUnit = fieldFamilyIntg.getMEDComponentUnit(kcomp1)
+ print " * Component:",kcomp1
+ print " Name:",compName
+ print " Description:",compDesc
+ print " Unit:",compUnit
+
+ nbOf = fieldFamilyIntg.getSupport().getNumberOfElements(MED_ALL_ELEMENTS)
+ print " Values:",nbOf
+ print " Randomly set (via setValue) and get (via getValue) to check with the same mode ..!"
+ value = []
+ for k in range(nbOf*nbOfComp):
+ value.append(randint(0,100))
+ print " the mode is full interlace"
+ mode = MED_FULL_INTERLACE
+ fieldFamilyIntg.setValue(mode,value)
+ valueverif = fieldFamilyIntg.getValue(mode)
+ for k in range(nbOf*nbOfComp):
+ print " Set/Get Entry * ",value[k]," / ",valueverif[k]
+ print ""
+ value = []
+ for k in range(nbOf*nbOfComp):
+ value.append(randint(0,100))
+ print " the mode is no interlace"
+ mode = MED_NO_INTERLACE
+ fieldFamilyIntg.setValue(mode,value)
+ valueverif = fieldFamilyIntg.getValue(mode)
+ for k in range(nbOf*nbOfComp):
+ print " Set/Get Entry * ",value[k]," / ",valueverif[k]
+ print ""
+ print " Randomly set (via setValue) and get (via getValue) to check with different mode ..!"
+ value = []
+ for k in range(nbOf*nbOfComp):
+ value.append(randint(0,100))
+ print " the mode for set is full interlace and no interlace for get"
+ mode_full = MED_FULL_INTERLACE
+ mode_no = MED_NO_INTERLACE
+ fieldFamilyIntg.setValue(mode_full,value)
+ valueverif = fieldFamilyIntg.getValue(mode_no)
+ for k in range(nbOf*nbOfComp):
+ print " Set/Get Entry * ",value[k]," / ",valueverif[k]
+ print ""
+ value = []
+ for k in range(nbOf*nbOfComp):
+ value.append(randint(0,100))
+ print " the mode for set is no interlace and full interlace for get"
+ fieldFamilyIntg.setValue(mode_no,value)
+ valueverif = fieldFamilyIntg.getValue(mode_full)
+ for k in range(nbOf*nbOfComp):
+ print " Set/Get Entry * ",value[k]," / ",valueverif[k]
+ print ""
+ print " Randomly set (via setValueI) and get (via getValueI) to check with the same mode ..!"
+ value = []
+ for k in range(nbOf*nbOfComp):
+ value.append(randint(0,100))
+ print " the mode is full interlace"
+ mode = MED_FULL_INTERLACE
+ for k in range(nbOf):
+ fieldFamilyIntg.setValueI(mode,(k+1),value[k*nbOfComp:(k+1)*nbOfComp])
+ valueverif = []
+ for k in range(nbOf):
+ valueverif.extend(fieldFamilyIntg.getValueI(mode,(k+1)))
+ for k in range(nbOf*nbOfComp):
+ print " Set/Get Entry * ",value[k]," / ",valueverif[k]
+ print ""
+ value = []
+ for k in range(nbOf*nbOfComp):
+ value.append(randint(0,100))
+ print " the mode is no interlace"
+ mode = MED_NO_INTERLACE
+ for k in range(nbOfComp):
+ fieldFamilyIntg.setValueI(mode,(k+1),value[k*nbOf:(k+1)*nbOf])
+ valueverif = []
+ for k in range(nbOfComp):
+ valueverif.extend(fieldFamilyIntg.getValueI(mode,(k+1)))
+ for k in range(nbOf*nbOfComp):
+ print " Set/Get Entry * ",value[k]," / ",valueverif[k]
+ print ""
+ print " Randomly set (via setValueI) and get (via getValueI) to check with different mode ..!"
+ value = []
+ for k in range(nbOf*nbOfComp):
+ value.append(randint(0,100))
+ print " the mode for set is full interlace and no interlace for get"
+ mode_full = MED_FULL_INTERLACE
+ mode_no = MED_NO_INTERLACE
+ for k in range(nbOf):
+ fieldFamilyIntg.setValueI(mode_full,(k+1),value[k*nbOfComp:(k+1)*nbOfComp])
+ valueverif = []
+ for k in range(nbOfComp):
+ valueverif.extend(fieldFamilyIntg.getValueI(mode_no,(k+1)))
+ for k in range(nbOf*nbOfComp):
+ print " Set/Get Entry * ",value[k]," / ",valueverif[k]
+ print ""
+ value = []
+ for k in range(nbOf*nbOfComp):
+ value.append(randint(0,100))
+ print " the mode for set is no interlace and full interlace for get"
+ for k in range(nbOfComp):
+ fieldFamilyIntg.setValueI(mode_no,(k+1),value[k*nbOf:(k+1)*nbOf])
+ valueverif = []
+ for k in range(nbOf):
+ valueverif.extend(fieldFamilyIntg.getValueI(mode_full,(k+1)))
+ for k in range(nbOf*nbOfComp):
+ print " Set/Get Entry * ",value[k]," / ",valueverif[k]
+ print ""
--- /dev/null
+%{
+#include <stdio.h>
+%}
+
+%typemap(python,in) double *
+{
+ /* Check if is a list */
+ if (PyList_Check($input)) {
+ int size = PyList_Size($input);
+ int i = 0;
+ $1 = (double *) malloc(size*sizeof(double));
+ for (i = 0; i < size; i++) {
+ PyObject *o = PyList_GetItem($input,i);
+ if (PyFloat_Check(o))
+ $1[i] = PyFloat_AsDouble(PyList_GetItem($input,i));
+ else {
+ PyErr_SetString(PyExc_TypeError,"list must contain floats");
+ free($1);
+ return NULL;
+ }
+ }
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,"not a list");
+ return NULL;
+ }
+}
+
+%typemap(python,in) int *
+{
+ /* Check if is a list */
+ if (PyList_Check($input)) {
+ int size = PyList_Size($input);
+ int i = 0;
+ $1 = (int *) malloc(size*sizeof(int));
+ for (i = 0; i < size; i++) {
+ PyObject *o = PyList_GetItem($input,i);
+ if (PyInt_Check(o))
+ $1[i] = PyInt_AsLong(PyList_GetItem($input,i));
+ else {
+ PyErr_SetString(PyExc_TypeError,"list must contain integers");
+ free($1);
+ return NULL;
+ }
+ }
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,"not a list");
+ return NULL;
+ }
+}
+
+
+%typemap(python,in) medGeometryElement *
+{
+ /* Check if is a list */
+ if (PyList_Check($input)) {
+ int size = PyList_Size($input);
+ int i = 0;
+ $1 = (medGeometryElement *) malloc(size*sizeof(int));
+ for (i = 0; i < size; i++) {
+ PyObject *o = PyList_GetItem($input,i);
+ if (PyInt_Check(o))
+ $1[i] = (medGeometryElement) PyInt_AsLong(PyList_GetItem($input,i));
+ else {
+ PyErr_SetString(PyExc_TypeError,"list must contain integers");
+ free($1);
+ return NULL;
+ }
+ }
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,"not a list");
+ return NULL;
+ }
+}
+
+
+%typemap(python,out) list<string> {
+ int i;
+ list<string>::iterator iL;
+
+ $result = PyList_New($1->size());
+ for (i=0, iL=$1->begin(); iL!=$1->end(); i++, iL++)
+ PyList_SetItem($result,i,PyString_FromString((*iL).c_str()));
+}
--- /dev/null
+#==============================================================================
+# File : Makefile.in
+# Created : ven déc 7 13:32:20 CET 2001
+# Author : Paul RASCLE, EDF
+# Project : SALOME
+# Copyright : EDF 2001
+# $Header$
+#==============================================================================
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@
+
+@COMMENCE@
+
+SUBDIRS = MEDMEM MEDMEM_SWIG MedMem MED MEDGUI MedCorba_Swig
+
+@MODULE@
--- /dev/null
+#==============================================================================
+# File : Makefile.in
+# Author : Nadir BOUHAMOU (CEA/DEN/DM2S/SFME/LGLS)
+# CVS : $Header$
+#==============================================================================
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=../../..
+srcdir=@srcdir@
+VPATH=.:$(srcdir):$(top_srcdir)/idl
+
+@COMMENCE@
+
+# Libraries targets
+
+LIB = libMedCorba_Swigcmodule.la
+
+LIB_SRC =
+
+SWIG_DEF = libMedCorba_Swig.i
+
+LIB_SERVER_IDL = MED.idl
+
+LIB_CLIENT_IDL= SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl
+
+EXPORT_PYSCRIPTS = libMedCorba_Swig.py medcorba_test.py batchmode_medcorba_test.py
+
+#############################################################################
+
+CPPFLAGS+= $(PYTHON_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES)
+CXXFLAGS=-g -D_DEBUG_ -D__x86__ -D__linux__
+CXXFLAGS+=-ftemplate-depth-42
+LIBS= $(PYTHON_LIBS)
+LDFLAGS+= -lMEDImpl -lMEDMEM_Swigcmodule
+
+#############################################################################
+
+MED.hh MEDSK.cc: MED.idl
+ omniidl -bcxx -Wbtp $^
+
+@CONCLUDE@
--- /dev/null
+import batchmode_salome
+
+import SALOME_MED
+
+from libMedCorba_Swig import *
+
+from random import *
+
+#==============================================================================
+
+def AnalyzeField(field):
+ name = field.getName()
+ desc = field.getDescription()
+ nbComp = field.getNumberOfComponents()
+ itNum = field.getIterationNumber()
+ ordNum = field.getOrderNumber()
+
+ print "Analysis of the field ",name," with the description ",desc
+ print "iteration number ",itNum," order Number ",ordNum
+ print "It has ",nbComp," component(s)"
+
+ fieldValue = field.getValue(SALOME_MED.MED_FULL_INTERLACE)
+ fieldSupport = field.getSupport()
+ fieldMesh = fieldSupport.getMesh()
+ fieldEntity = fieldSupport.getEntity()
+ bool = fieldSupport.isOnAllElements()
+
+ if bool:
+ print "The support of this field is on all entities ",fieldEntity," of the mesh ",fieldMesh.getName()
+ if fieldEntity == SALOME_MED.MED_NODE:
+ nbValByComp = fieldMesh.getNumberOfNodes()
+ else:
+ nbValByComp = fieldMesh.getNumberOfElements(fieldEntity,SALOME_MED.MED_ALL_ELEMENTS)
+ print "and its dimension (number of values by component of the field) is ",nbValByComp
+ else:
+ print "The support of this field is partially on entities ",fieldEntity," of the mesh ",fieldMesh.getName()
+ nbValByComp = fieldSupport.getNumberOfElements(SALOME_MED.MED_ALL_ELEMENTS)
+ print "and its dimension (number of values by component of the field) is ",nbValByComp
+
+ for i in range(nbComp):
+ compName = field.getComponentName(i+1)
+ compUnit = field.getComponentUnit(i+1)
+ print "The ",(i+1),"-th component ",compName," with the unit ",compUnit
+
+ for i in range(nbValByComp):
+ print " * ",fieldValue[i*nbComp:(i+1)*nbComp]
+
+#==============================================================================
+
+def getMeshObjectFromStudy(number):
+ mySO = batchmode_salome.myStudy.FindObject("MEDMESH")
+ mysub = mySO.FindSubObject(number)[1]
+ if mysub:
+ Builder = batchmode_salome.myStudy.NewBuilder()
+ anAttr = Builder.FindOrCreateAttribute(mysub, "AttributeIOR")
+ obj = batchmode_salome.orb.string_to_object(anAttr.Value())
+ myObj = obj._narrow(SALOME_MED.MESH)
+ return myObj
+ else:
+ print "ERROR: No Mesh Object stored in this Study"
+ return None
+
+#==============================================================================
+
+def getMedObjectFromStudy():
+ mySO = batchmode_salome.myStudy.FindObject("Objet MED")
+ Builder = batchmode_salome.myStudy.NewBuilder()
+ anAttr = Builder.FindOrCreateAttribute(mySO, "AttributeIOR")
+ obj = batchmode_salome.orb.string_to_object(anAttr.Value())
+ myObj = obj._narrow(SALOME_MED.MED)
+ return myObj
+
+#==============================================================================
+#
+# Since Corba pointeurs will be generated in this Python script
+# a POA has to be registred to activate those Corba pointeurs
+# and make them available by any clients (in general). In our
+# case, it is to make those pointeurs avail able to itself
+#==============================================================================
+
+print "Activation of a POA to make available any Corba pointeurs"
+poa = batchmode_salome.orb.resolve_initial_references("RootPOA")
+poaManager = poa._get_the_POAManager()
+poaManager.activate()
+
+#==============================================================================
+
+studyCurrent = batchmode_salome.myStudyName
+studyCurrentId = batchmode_salome.myStudyId
+
+print "We are working in the study ",studyCurrent," with the ID ",studyCurrentId
+print ""
+
+#medFile = "carre_en_quad4_seg2.med"
+medFile = "cube_hexa8_quad4.med"
+
+print "Loading of the Med Component"
+print ""
+
+med_comp = batchmode_salome.lcc.FindOrLoadComponent("FactoryServer", "Med")
+
+med_comp.readStructFile(medFile,studyCurrent)
+
+med_obj = getMedObjectFromStudy()
+
+nbMeshes = med_obj.getNumberOfMeshes()
+
+nbFields = med_obj.getNumberOfFields()
+
+print ""
+print "The med file ",medFile," has ",nbMeshes," Meshe(s) and ",nbFields," Field(s)"
+print ""
+
+meshcorba = getMeshObjectFromStudy(1)
+
+name = meshcorba.getName()
+
+nbNodes = meshcorba.getNumberOfNodes()
+
+spaceDim = meshcorba.getSpaceDimension()
+
+print "The mesh from the Study is ",name,".It is a ",spaceDim,"-D mesh and it has ",nbNodes," Nodes"
+print ""
+
+for entity in [SALOME_MED.MED_NODE,SALOME_MED.MED_CELL,SALOME_MED.MED_FACE,SALOME_MED.MED_EDGE]:
+ nbFam = meshcorba.getNumberOfFamilies(entity)
+ if (entity == SALOME_MED.MED_NODE) & (nbFam > 0):
+ print "This mesh has",nbFam,"Node Family(ies)"
+ elif (entity == SALOME_MED.MED_CELL) & (nbFam > 0):
+ print "This mesh has",nbFam,"Cell Family(ies)"
+ elif (entity == SALOME_MED.MED_FACE) & (nbFam > 0):
+ print "This mesh has",nbFam,"Face Family(ies)"
+ elif (entity == SALOME_MED.MED_EDGE) & (nbFam > 0):
+ print "This mesh has",nbFam,"Edge Family(ies)"
+
+ if nbFam > 0:
+ for j in range(nbFam):
+ print ""
+ familycorba = meshcorba.getFamily(entity,j+1)
+ familyName = familycorba.getName()
+ familyDescription = familycorba.getDescription()
+ familyEntity = familycorba.getEntity()
+ familyBool = familycorba.isOnAllElements()
+ print " -Name:",familyName
+ print " -Description:",familyDescription
+ print " -Entity:",familyEntity
+ familyIdentifier = familycorba.getIdentifier()
+ nbOfAtt = familycorba.getNumberOfAttributes()
+ print " -Identifier:",familyIdentifier
+ print " -Number Of Attributes:",nbOfAtt
+ attributesids = familycorba.getAttributesIdentifiers()
+ attributesvals = familycorba.getAttributesValues()
+ for k in range(nbOfAtt):
+ print " * Attributes:",attributesids[k],":",attributesvals[k],",",familycorba.getAttributeDescription(k+1)
+ print " -Entities list:"
+ if (familyBool):
+ print " -Is on all entities"
+ else:
+ types = familycorba.getTypes()
+ nbOfTypes = len(types)
+ print " -Number Of Types:",nbOfTypes
+ for k in range(nbOfTypes):
+ type = types[k]
+ nbOfElmtsOfType = familycorba.getNumberOfElements(type)
+ number = familycorba.getNumber(type)
+ print " * Type",type
+ print " * Number",number[0:nbOfElmtsOfType]
+ print ""
+ lengthValue = familycorba.getNumberOfElements(SALOME_MED.MED_ALL_ELEMENTS)
+ nbOfComp = 1
+ print "Generate a Local scalar double field"
+ fieldScalDblLoc = createLocalFieldDouble(nbOfComp,lengthValue)
+ for k in range(lengthValue):
+ valueI = []
+ for kcomp in range(nbOfComp):
+ valueI.append(random())
+ fieldScalDblLoc.setValueI(MED_FULL_INTERLACE,k+1,valueI)
+ valueIverif = fieldScalDblLoc.getValueI(MED_FULL_INTERLACE,k+1)
+ print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
+ print "Generate a Corba scalar double field"
+ fieldScalDblCorba = createCorbaFieldDouble(familycorba,fieldScalDblLoc)
+ AnalyzeField(fieldScalDblCorba)
+ print ""
+ print "Generate a Local scalar integer field"
+ fieldScalIntLoc = createLocalFieldInt(nbOfComp,lengthValue)
+ for k in range(lengthValue):
+ valueI = []
+ for kcomp in range(nbOfComp):
+ valueI.append(randint(0,100))
+ fieldScalIntLoc.setValueI(MED_FULL_INTERLACE,k+1,valueI)
+ valueIverif = fieldScalIntLoc.getValueI(MED_FULL_INTERLACE,k+1)
+ print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
+ print "Generate a Corba scalar integer field"
+ fieldScalIntCorba = createCorbaFieldInt(familycorba,fieldScalIntLoc)
+ AnalyzeField(fieldScalIntCorba)
+ print ""
+ nbOfComp = spaceDim
+ print "Generate a Local vector double field"
+ fieldVectDblLoc = createLocalFieldDouble(nbOfComp,lengthValue)
+ for k in range(lengthValue):
+ valueI = []
+ for kcomp in range(nbOfComp):
+ valueI.append(random())
+ fieldVectDblLoc.setValueI(MED_FULL_INTERLACE,k+1,valueI)
+ valueIverif = fieldVectDblLoc.getValueI(MED_FULL_INTERLACE,k+1)
+ print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
+ print "Generate a Corba vector double field"
+ fieldVectDblCorba = createCorbaFieldDouble(familycorba,fieldVectDblLoc)
+ AnalyzeField(fieldVectDblCorba)
+ print ""
+ print "Generate a Local vector integer field"
+ fieldVectIntLoc = createLocalFieldInt(nbOfComp,lengthValue)
+ for k in range(lengthValue):
+ valueI = []
+ for kcomp in range(nbOfComp):
+ valueI.append(randint(0,100))
+ fieldVectIntLoc.setValueI(MED_FULL_INTERLACE,k+1,valueI)
+ valueIverif = fieldVectIntLoc.getValueI(MED_FULL_INTERLACE,k+1)
+ print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
+ print "Generate a Corba vector integer field"
+ fieldVectIntCorba = createCorbaFieldInt(familycorba,fieldVectIntLoc)
+ AnalyzeField(fieldVectIntCorba)
+ print ""
+print "Fin du script Python ...."
+
+
--- /dev/null
+%module libMedCorba_Swig
+
+%include "libMEDMEM_Swig.i"
+
+%{
+#include "convert.hxx"
+#include "Family_i.hxx"
+#include "FieldDouble_i.hxx"
+#include "Field_i.hxx"
+#include "FieldInt_i.hxx"
+#include "FieldOf_i.hxx"
+#include "Group_i.hxx"
+#include "Med_i.hxx"
+#include "Mesh_i.hxx"
+#include "Support_i.hxx"
+#include "MEDMEM_SWIG_FieldDouble.hxx"
+#include "MEDMEM_SWIG_FieldInt.hxx"
+%}
+
+/*
+ typemap in and out for Corba Objects (MESH, FIELDDOUBLE, FIELDINT and
+ Support) between C++ and Python
+
+ WARNING (NB) to the user of those typmaps (SWIG wrapping for C++ routines
+ -------------------------------------------------------------------------
+
+ You have to be quite careful about the SWIG version your are currently
+ using, because CORBA pointeur _ptr or _var could be wrapped by SWIG using
+ their reference rather than the pointeur itself (differences detected using
+ SWIG 1.1.x, SWIG 1.3.13 and SWIG 1.3.17)
+*/
+
+%typemap(python,out) SALOME_MED::MESH_ptr, SALOME_MED::FIELDDOUBLE_ptr,
+ SALOME_MED::FIELDINT_ptr, SALOME_MED::SUPPORT_ptr,
+ const SALOME_MED::MESH_ptr, const SALOME_MED::FIELDDOUBLE_ptr,
+ const SALOME_MED::FIELDINT_ptr, const SALOME_MED::SUPPORT_ptr
+{
+ MESSAGE("typemap out sur Objet Corba version ptr");
+
+ SCRUTE($1);
+
+ // Get the orb corba python
+
+ PyObject* pdict = PyDict_New();
+ PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
+ PyRun_String("import CORBA", Py_single_input, pdict, pdict);
+
+ PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
+ pdict, pdict);
+
+ PyObject* orb = PyDict_GetItemString(pdict, "o");
+
+ // Get the orb Corba C++
+
+ int argc = 0;
+ char *xargv = "";
+ char **argv = &xargv;
+ CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
+
+ string s = ORB->object_to_string($1);
+ SCRUTE(s);
+ PyObject * tmp = PyString_FromString(s.c_str());
+ SCRUTE(tmp);
+ $result = PyObject_CallMethod(orb, "string_to_object", "O", tmp);
+ SCRUTE($result);
+}
+
+%typemap(python,out) SALOME_MED::MESH_var, SALOME_MED::FIELDDOUBLE_var,
+ SALOME_MED::FIELDINT_var, SALOME_MED::SUPPORT_var,
+ const SALOME_MED::MESH_var, const SALOME_MED::FIELDDOUBLE_var,
+ const SALOME_MED::FIELDINT_var, const SALOME_MED::SUPPORT_var
+{
+ MESSAGE("typemap out sur Objet Corba version var");
+
+ // Get the orb corba python
+
+ PyObject* pdict = PyDict_New();
+ PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
+ PyRun_String("import CORBA", Py_single_input, pdict, pdict);
+
+ PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
+ pdict, pdict);
+
+ PyObject* orb = PyDict_GetItemString(pdict, "o");
+
+ // Get the orb Corba C++
+
+ int argc = 0;
+ char *xargv = "";
+ char **argv = &xargv;
+ CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
+
+ string s = ORB->object_to_string(*$1);
+ SCRUTE(s);
+ PyObject * tmp = PyString_FromString(s.c_str());
+ SCRUTE(tmp);
+ $result = PyObject_CallMethod(orb, "string_to_object", "O", tmp);
+ SCRUTE($result);
+}
+
+%typemap(python,in) const SALOME_MED::MESH_ptr &, SALOME_MED::MESH_ptr &
+{
+
+ MESSAGE("typemap in sur Objet Corba MESH avec reference");
+
+ PyObject* pdict = PyDict_New();
+ PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
+ PyRun_String("import CORBA", Py_single_input, pdict, pdict);
+
+ PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
+ pdict, pdict);
+
+ PyObject* orb = PyDict_GetItemString(pdict, "o");
+
+ // Ask omniORBpy to transform MESH (python Corba) ptr to IOR string
+
+ PyObject* iorMesh
+ = PyObject_CallMethod(orb, "object_to_string", "O", $input);
+
+ if (iorMesh == Py_None)
+ return NULL;
+ char * s = PyString_AsString(PyObject_Str(iorMesh));
+
+ // Ask omniORB to convert IOR string to MESH (C++ Corba) ptr
+
+ int argc = 0;
+ char *xargv = "";
+ char **argv = &xargv;
+ CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
+ CORBA::Object_var O = ORB->string_to_object(s);
+ SCRUTE(O);
+ SALOME_MED::MESH_ptr t = SALOME_MED::MESH::_narrow(O);
+
+ $1 = &t;
+ SCRUTE(*$1);
+}
+
+%typemap(python,in) const SALOME_MED::FIELDDOUBLE_ptr &,
+ SALOME_MED::FIELDDOUBLE_ptr &
+{
+
+ MESSAGE("typemap in sur Objet Corba FIELDDOUBLE avec reference");
+
+ PyObject* pdict = PyDict_New();
+ PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
+ PyRun_String("import CORBA", Py_single_input, pdict, pdict);
+
+ PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
+ pdict, pdict);
+
+ PyObject* orb = PyDict_GetItemString(pdict, "o");
+
+ // Ask omniORBpy to transform FIELDDOUBLE (python Corba) ptr to IOR string
+
+ PyObject* iorFieldDouble
+ = PyObject_CallMethod(orb, "object_to_string", "O", $input);
+
+ if (iorFieldDouble == Py_None)
+ return NULL;
+ char * s = PyString_AsString(PyObject_Str(iorFieldDouble));
+
+ // Ask omniORB to convert IOR string to FIELDDOUBLE (C++ Corba) ptr
+
+ int argc = 0;
+ char *xargv = "";
+ char **argv = &xargv;
+ CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
+ CORBA::Object_var O = ORB->string_to_object(s);
+ SCRUTE(O);
+ SALOME_MED::FIELDDOUBLE_ptr t = SALOME_MED::FIELDDOUBLE::_narrow(O);
+
+ $1 = &t;
+ SCRUTE(*$1);
+}
+
+%typemap(python,in) const SALOME_MED::FIELDINT_ptr &,
+ SALOME_MED::FIELDINT_ptr &
+{
+
+ MESSAGE("typemap in sur Objet Corba FIELDINT avec reference");
+
+ PyObject* pdict = PyDict_New();
+ PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
+ PyRun_String("import CORBA", Py_single_input, pdict, pdict);
+
+ PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
+ pdict, pdict);
+
+ PyObject* orb = PyDict_GetItemString(pdict, "o");
+
+ // Ask omniORBpy to transform FIELDINT (python Corba) ptr to IOR string
+
+ PyObject* iorFieldInt
+ = PyObject_CallMethod(orb, "object_to_string", "O", $input);
+
+ if (iorFieldInt == Py_None)
+ return NULL;
+ char * s = PyString_AsString(PyObject_Str(iorFieldInt));
+
+ // Ask omniORB to convert IOR string to FIELDINT (C++ Corba) ptr
+
+ int argc = 0;
+ char *xargv = "";
+ char **argv = &xargv;
+ CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
+ CORBA::Object_var O = ORB->string_to_object(s);
+ SCRUTE(O);
+ SALOME_MED::FIELDINT_ptr t = SALOME_MED::FIELDINT::_narrow(O);
+
+ $1 = &t;
+ SCRUTE(*$1);
+}
+
+%typemap(python,in) const SALOME_MED::SUPPORT_ptr &, SALOME_MED::SUPPORT_ptr &
+{
+
+ MESSAGE("typemap in sur Objet Corba SUPPORT avec reference");
+
+ PyObject* pdict = PyDict_New();
+ PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
+ PyRun_String("import CORBA", Py_single_input, pdict, pdict);
+
+ PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
+ pdict, pdict);
+
+ PyObject* orb = PyDict_GetItemString(pdict, "o");
+
+ // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string
+
+ PyObject* iorSupport
+ = PyObject_CallMethod(orb, "object_to_string", "O", $input);
+
+ if (iorSupport == Py_None)
+ return NULL;
+ char * s = PyString_AsString(PyObject_Str(iorSupport));
+
+ // Ask omniORB to convert IOR string to SUPPORT (C++ Corba) ptr
+
+ int argc = 0;
+ char *xargv = "";
+ char **argv = &xargv;
+ CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
+ CORBA::Object_var O = ORB->string_to_object(s);
+ SCRUTE(O);
+ SALOME_MED::SUPPORT_ptr t = SALOME_MED::SUPPORT::_narrow(O);
+
+ $1 = &t;
+ SCRUTE(*$1);
+}
+
+%typemap(python,in) const SALOME_MED::SUPPORT_ptr, SALOME_MED::SUPPORT_ptr
+{
+
+ MESSAGE("typemap in sur Objet Corba SUPPORT sans reference");
+
+ SCRUTE($input);
+
+ PyObject* pdict = PyDict_New();
+ PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
+ PyRun_String("import CORBA", Py_single_input, pdict, pdict);
+
+ PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
+ pdict, pdict);
+
+ PyObject* orb = PyDict_GetItemString(pdict, "o");
+
+ // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string
+
+ PyObject* iorSupport
+ = PyObject_CallMethod(orb, "object_to_string", "O", $input);
+
+ if (iorSupport == Py_None)
+ return NULL;
+ char * s = PyString_AsString(PyObject_Str(iorSupport));
+
+ // Ask omniORB to convert IOR string to SUPPORT (C++ Corba) ptr
+
+ int argc = 0;
+ char *xargv = "";
+ char **argv = &xargv;
+ CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
+ CORBA::Object_var O = ORB->string_to_object(s);
+ SCRUTE(O);
+ SALOME_MED::SUPPORT_ptr t = SALOME_MED::SUPPORT::_narrow(O);
+
+ $1 = t;
+ SCRUTE($1);
+}
+
+%typemap(python,in) const SALOME_MED::MESH_ptr, SALOME_MED::MESH_ptr
+{
+
+ MESSAGE("typemap in sur Objet Corba MESH sans reference");
+
+ SCRUTE($input);
+
+ PyObject* pdict = PyDict_New();
+ PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
+ PyRun_String("import CORBA", Py_single_input, pdict, pdict);
+
+ PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
+ pdict, pdict);
+
+ PyObject* orb = PyDict_GetItemString(pdict, "o");
+
+ // Ask omniORBpy to transform MESH (python Corba) ptr to IOR string
+
+ PyObject* iorMesh
+ = PyObject_CallMethod(orb, "object_to_string", "O", $input);
+
+ if (iorMesh == Py_None)
+ return NULL;
+ char * s = PyString_AsString(PyObject_Str(iorMesh));
+
+ // Ask omniORB to convert IOR string to MESH (C++ Corba) ptr
+
+ int argc = 0;
+ char *xargv = "";
+ char **argv = &xargv;
+ CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
+ CORBA::Object_var O = ORB->string_to_object(s);
+ SCRUTE(O);
+ SALOME_MED::MESH_ptr t = SALOME_MED::MESH::_narrow(O);
+
+ $1 = t;
+ SCRUTE($1);
+}
+
+%typemap(python,in) const SALOME_MED::FIELDDOUBLE_ptr,
+ SALOME_MED::FIELDDOUBLE_ptr &
+{
+
+ MESSAGE("typemap in sur Objet Corba FIELDDOUBLE sans reference");
+
+ SCRUTE($input);
+
+ PyObject* pdict = PyDict_New();
+ PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
+ PyRun_String("import CORBA", Py_single_input, pdict, pdict);
+
+ PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
+ pdict, pdict);
+
+ PyObject* orb = PyDict_GetItemString(pdict, "o");
+
+ // Ask omniORBpy to transform FIELDDOUBLE (python Corba) ptr to IOR string
+
+ PyObject* iorFieldDouble
+ = PyObject_CallMethod(orb, "object_to_string", "O", $input);
+
+ if (iorFieldDouble == Py_None)
+ return NULL;
+ char * s = PyString_AsString(PyObject_Str(iorFieldDouble));
+
+ // Ask omniORB to convert IOR string to FIELDDOUBLE (C++ Corba) ptr
+
+ int argc = 0;
+ char *xargv = "";
+ char **argv = &xargv;
+ CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
+ CORBA::Object_var O = ORB->string_to_object(s);
+ SCRUTE(O);
+ SALOME_MED::FIELDDOUBLE_ptr t = SALOME_MED::FIELDDOUBLE::_narrow(O);
+
+ $1 = t;
+ SCRUTE($1);
+}
+
+%typemap(python,in) const SALOME_MED::FIELDINT_ptr,
+ SALOME_MED::FIELDINT_ptr
+{
+
+ MESSAGE("typemap in sur Objet Corba FIELDINT sans reference");
+
+ SCRUTE($input);
+
+ PyObject* pdict = PyDict_New();
+ PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
+ PyRun_String("import CORBA", Py_single_input, pdict, pdict);
+
+ PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
+ pdict, pdict);
+
+ PyObject* orb = PyDict_GetItemString(pdict, "o");
+
+ // Ask omniORBpy to transform FIELDINT (python Corba) ptr to IOR string
+
+ PyObject* iorFieldInt
+ = PyObject_CallMethod(orb, "object_to_string", "O", $input);
+
+ if (iorFieldInt == Py_None)
+ return NULL;
+ char * s = PyString_AsString(PyObject_Str(iorFieldInt));
+
+ // Ask omniORB to convert IOR string to FIELDINT (C++ Corba) ptr
+
+ int argc = 0;
+ char *xargv = "";
+ char **argv = &xargv;
+ CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
+ CORBA::Object_var O = ORB->string_to_object(s);
+ SCRUTE(O);
+ SALOME_MED::FIELDINT_ptr t = SALOME_MED::FIELDINT::_narrow(O);
+
+ $1 = t;
+ SCRUTE($1);
+}
+
+SALOME_MED::FIELDDOUBLE_ptr createCorbaFieldDouble(SALOME_MED::SUPPORT_ptr,
+ FIELDDOUBLE *);
+
+SALOME_MED::FIELDINT_ptr createCorbaFieldInt(SALOME_MED::SUPPORT_ptr,
+ FIELDINT *);
+
+SALOME_MED::SUPPORT_ptr createCorbaSupport(const SUPPORT *);
+
+FIELDDOUBLE * createLocalFieldDouble(const int, const int);
+
+FIELDINT * createLocalFieldInt(const int, const int);
+
+%{
+ SALOME_MED::FIELDDOUBLE_ptr createCorbaFieldDouble(SALOME_MED::SUPPORT_ptr mySupportIOR,FIELDDOUBLE * field)
+ {
+ BEGIN_OF("SALOME_MED::FIELDDOUBLE_ptr createCorbaFieldDouble from libMedCorba_Swig");
+
+ SCRUTE(mySupportIOR);
+
+ SCRUTE(field);
+
+ field->setName("Corba Double Field");
+
+ field->setDescription("Got From A Local One");
+
+ FIELDDOUBLE_i * fieldimpl = new FIELDDOUBLE_i(mySupportIOR,field);
+
+ POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * fieldcorba1 =
+ new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(fieldimpl,true);
+
+ SALOME_MED::FIELDDOUBLE_ptr fieldcorba2 = fieldcorba1->_this();
+
+ SALOME_MED::FIELDDOUBLE_ptr fieldcorba3 = SALOME_MED::FIELDDOUBLE::_duplicate(fieldcorba2);
+
+ fieldcorba1->_remove_ref();
+
+ SCRUTE(fieldimpl);
+
+ SCRUTE(fieldcorba1);
+
+ SCRUTE(fieldcorba2);
+
+ SCRUTE(fieldcorba3);
+
+ END_OF("SALOME_MED::FIELDDOUBLE_ptr createCorbaFieldDouble from libMedCorba_Swig");
+
+ MESSAGE("Test de tirarge sur le pointeur Corba Field dans le cxx");
+
+ char * name = fieldcorba3->getName();
+
+ SCRUTE(name);
+
+ return fieldcorba3;
+ }
+
+ SALOME_MED::FIELDINT_ptr createCorbaFieldInt(SALOME_MED::SUPPORT_ptr mySupportIOR,FIELDINT * field)
+ {
+ BEGIN_OF("SALOME_MED::FIELDINT_ptr createCorbaFieldInt from libMedCorba_Swig");
+
+ SCRUTE(mySupportIOR);
+
+ SCRUTE(field);
+
+ field->setName("Corba Integer Field");
+
+ field->setDescription("Got From A Local One");
+
+ FIELDINT_i * fieldimpl = new FIELDINT_i(mySupportIOR,field);
+
+ POA_SALOME_MED::FIELDINT_tie<FIELDINT_i> * fieldcorba1 =
+ new POA_SALOME_MED::FIELDINT_tie<FIELDINT_i>(fieldimpl,true);
+
+ SALOME_MED::FIELDINT_ptr fieldcorba2 = fieldcorba1->_this();
+
+ SALOME_MED::FIELDINT_ptr fieldcorba3 = SALOME_MED::FIELDINT::_duplicate(fieldcorba2);
+
+ fieldcorba1->_remove_ref();
+
+ SCRUTE(fieldimpl);
+
+ SCRUTE(fieldcorba1);
+
+ SCRUTE(fieldcorba2);
+
+ SCRUTE(fieldcorba3);
+
+ END_OF("SALOME_MED::FIELDINT_ptr createCorbaFieldInt from libMedCorba_Swig");
+ MESSAGE("Test de tirarge sur le pointeur Corba Field dans le cxx");
+
+ char * name = fieldcorba3->getName();
+
+ SCRUTE(name);
+
+ return fieldcorba3;
+ }
+
+ SALOME_MED::SUPPORT_ptr createCorbaSupport(const SUPPORT * const support)
+ {
+ BEGIN_OF("SALOME_MED::SUPPORT_ptr createCorbaSupport from libMedCorba_Swig");
+
+ SCRUTE(support);
+
+ SUPPORT_i * supportimpl = new SUPPORT_i(support);
+
+ SALOME_MED::SUPPORT_ptr supportcorba =
+ supportimpl->POA_SALOME_MED::SUPPORT::_this();
+
+ SCRUTE(supportimpl);
+
+ SCRUTE(supportcorba);
+
+ supportimpl->_remove_ref();
+
+ END_OF("SALOME_MED::SUPPORT_ptr createCorbaSupport from libMedCorba_Swig");
+
+ return supportcorba;
+ }
+
+ FIELDDOUBLE * createLocalFieldDouble(const int NumberOfComponents,
+ const int LengthValue)
+ {
+ BEGIN_OF("FIELDDOUBLE createLocalFieldDouble from libMedCorba_Swig");
+
+ SCRUTE(NumberOfComponents);
+ SCRUTE(LengthValue);
+
+ //FIELD<double> * fieldloc = new FIELD<double>();
+ FIELDDOUBLE * fieldloc = new FIELDDOUBLE();
+ fieldloc -> allocValue(NumberOfComponents,LengthValue);
+
+ END_OF("FIELDDOUBLE createLocalFieldDouble from libMedCorba_Swig");
+
+ return fieldloc;
+ }
+
+ FIELDINT * createLocalFieldInt(const int NumberOfComponents,
+ const int LengthValue)
+ {
+ BEGIN_OF("FIELDINT createLocalFieldInt from libMedCorba_Swig");
+
+ SCRUTE(NumberOfComponents);
+ SCRUTE(LengthValue);
+
+ //FIELD<int> * fieldloc = new FIELD<int>();
+ FIELDINT * fieldloc = new FIELDINT();
+ fieldloc -> allocValue(NumberOfComponents,LengthValue);
+
+ END_OF("FIELDDOUBLE createLocalFieldInt from libMedCorba_Swig");
+
+ return fieldloc;
+ }
+%}
--- /dev/null
+import salome
+
+import SALOME_MED
+
+from libMedCorba_Swig import *
+
+from random import *
+
+#==============================================================================
+
+def AnalyzeField(field):
+ name = field.getName()
+ desc = field.getDescription()
+ nbComp = field.getNumberOfComponents()
+ itNum = field.getIterationNumber()
+ ordNum = field.getOrderNumber()
+
+ print "Analysis of the field ",name," with the description ",desc
+ print "iteration number ",itNum," order Number ",ordNum
+ print "It has ",nbComp," component(s)"
+
+ fieldValue = field.getValue(SALOME_MED.MED_FULL_INTERLACE)
+ fieldSupport = field.getSupport()
+ fieldMesh = fieldSupport.getMesh()
+ fieldEntity = fieldSupport.getEntity()
+ bool = fieldSupport.isOnAllElements()
+
+ if bool:
+ print "The support of this field is on all entities ",fieldEntity," of the mesh ",fieldMesh.getName()
+ if fieldEntity == SALOME_MED.MED_NODE:
+ nbValByComp = fieldMesh.getNumberOfNodes()
+ else:
+ nbValByComp = fieldMesh.getNumberOfElements(fieldEntity,SALOME_MED.MED_ALL_ELEMENTS)
+ print "and its dimension (number of values by component of the field) is ",nbValByComp
+ else:
+ print "The support of this field is partially on entities ",fieldEntity," of the mesh ",fieldMesh.getName()
+ nbValByComp = fieldSupport.getNumberOfElements(SALOME_MED.MED_ALL_ELEMENTS)
+ print "and its dimension (number of values by component of the field) is ",nbValByComp
+
+ for i in range(nbComp):
+ compName = field.getComponentName(i+1)
+ compUnit = field.getComponentUnit(i+1)
+ print "The ",(i+1),"-th component ",compName," with the unit ",compUnit
+
+ for i in range(nbValByComp):
+ print " * ",fieldValue[i*nbComp:(i+1)*nbComp]
+
+#==============================================================================
+
+def getMeshObjectFromStudy(number):
+ mySO = salome.myStudy.FindObject("MEDMESH")
+ mysub = mySO.FindSubObject(number)[1]
+ if mysub:
+ Builder = salome.myStudy.NewBuilder()
+ anAttr = Builder.FindOrCreateAttribute(mysub, "AttributeIOR")
+ obj = salome.orb.string_to_object(anAttr.Value())
+ myObj = obj._narrow(SALOME_MED.MESH)
+ return myObj
+ else:
+ print "ERROR: No Mesh Object stored in this Study"
+ return None
+
+#==============================================================================
+
+def getMedObjectFromStudy():
+ mySO = salome.myStudy.FindObject("Objet MED")
+ Builder = salome.myStudy.NewBuilder()
+ anAttr = Builder.FindOrCreateAttribute(mySO, "AttributeIOR")
+ obj = salome.orb.string_to_object(anAttr.Value())
+ myObj = obj._narrow(SALOME_MED.MED)
+ return myObj
+
+#==============================================================================
+
+studyCurrent = salome.myStudyName
+studyCurrentId = salome.myStudyId
+
+print "We are working in the study ",studyCurrent," with the ID ",studyCurrentId
+print ""
+
+#medFile = "carre_en_quad4_seg2.med"
+medFile = "cube_hexa8_quad4.med"
+
+print "Loading of the Med Component"
+print ""
+
+med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "Med")
+
+med_comp.readStructFile(medFile,studyCurrent)
+
+med_obj = getMedObjectFromStudy()
+
+nbMeshes = med_obj.getNumberOfMeshes()
+
+nbFields = med_obj.getNumberOfFields()
+
+print ""
+print "The med file ",medFile," has ",nbMeshes," Meshe(s) and ",nbFields," Field(s)"
+print ""
+
+meshcorba = getMeshObjectFromStudy(1)
+
+name = meshcorba.getName()
+
+nbNodes = meshcorba.getNumberOfNodes()
+
+spaceDim = meshcorba.getSpaceDimension()
+
+print "The mesh from the Study is ",name,".It is a ",spaceDim,"-D mesh and it has ",nbNodes," Nodes"
+print ""
+
+for entity in [SALOME_MED.MED_NODE,SALOME_MED.MED_CELL,SALOME_MED.MED_FACE,SALOME_MED.MED_EDGE]:
+ nbFam = meshcorba.getNumberOfFamilies(entity)
+ if (entity == SALOME_MED.MED_NODE) & (nbFam > 0):
+ print "This mesh has",nbFam,"Node Family(ies)"
+ elif (entity == SALOME_MED.MED_CELL) & (nbFam > 0):
+ print "This mesh has",nbFam,"Cell Family(ies)"
+ elif (entity == SALOME_MED.MED_FACE) & (nbFam > 0):
+ print "This mesh has",nbFam,"Face Family(ies)"
+ elif (entity == SALOME_MED.MED_EDGE) & (nbFam > 0):
+ print "This mesh has",nbFam,"Edge Family(ies)"
+
+ if nbFam > 0:
+ for j in range(nbFam):
+ print ""
+ familycorba = meshcorba.getFamily(entity,j+1)
+ familyName = familycorba.getName()
+ familyDescription = familycorba.getDescription()
+ familyEntity = familycorba.getEntity()
+ familyBool = familycorba.isOnAllElements()
+ print " -Name:",familyName
+ print " -Description:",familyDescription
+ print " -Entity:",familyEntity
+ familyIdentifier = familycorba.getIdentifier()
+ nbOfAtt = familycorba.getNumberOfAttributes()
+ print " -Identifier:",familyIdentifier
+ print " -Number Of Attributes:",nbOfAtt
+ attributesids = familycorba.getAttributesIdentifiers()
+ attributesvals = familycorba.getAttributesValues()
+ for k in range(nbOfAtt):
+ print " * Attributes:",attributesids[k],":",attributesvals[k],",",familycorba.getAttributeDescription(k+1)
+ print " -Entities list:"
+ if (familyBool):
+ print " -Is on all entities"
+ else:
+ types = familycorba.getTypes()
+ nbOfTypes = len(types)
+ print " -Number Of Types:",nbOfTypes
+ for k in range(nbOfTypes):
+ type = types[k]
+ nbOfElmtsOfType = familycorba.getNumberOfElements(type)
+ number = familycorba.getNumber(type)
+ print " * Type",type
+ print " * Number",number[0:nbOfElmtsOfType]
+ print ""
+ lengthValue = familycorba.getNumberOfElements(SALOME_MED.MED_ALL_ELEMENTS)
+ nbOfComp = 1
+ print "Generate a Local scalar double field"
+ fieldScalDblLoc = createLocalFieldDouble(nbOfComp,lengthValue)
+ for k in range(lengthValue):
+ valueI = []
+ for kcomp in range(nbOfComp):
+ valueI.append(random())
+ fieldScalDblLoc.setValueI(MED_FULL_INTERLACE,k+1,valueI)
+ valueIverif = fieldScalDblLoc.getValueI(MED_FULL_INTERLACE,k+1)
+ print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
+ print "Generate a Corba scalar double field"
+ fieldScalDblCorba = createCorbaFieldDouble(familycorba,fieldScalDblLoc)
+ AnalyzeField(fieldScalDblCorba)
+ print ""
+ print "Generate a Local scalar integer field"
+ fieldScalIntLoc = createLocalFieldInt(nbOfComp,lengthValue)
+ for k in range(lengthValue):
+ valueI = []
+ for kcomp in range(nbOfComp):
+ valueI.append(randint(0,100))
+ fieldScalIntLoc.setValueI(MED_FULL_INTERLACE,k+1,valueI)
+ valueIverif = fieldScalIntLoc.getValueI(MED_FULL_INTERLACE,k+1)
+ print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
+ print "Generate a Corba scalar integer field"
+ fieldScalIntCorba = createCorbaFieldInt(familycorba,fieldScalIntLoc)
+ AnalyzeField(fieldScalIntCorba)
+ print ""
+ nbOfComp = spaceDim
+ print "Generate a Local vector double field"
+ fieldVectDblLoc = createLocalFieldDouble(nbOfComp,lengthValue)
+ for k in range(lengthValue):
+ valueI = []
+ for kcomp in range(nbOfComp):
+ valueI.append(random())
+ fieldVectDblLoc.setValueI(MED_FULL_INTERLACE,k+1,valueI)
+ valueIverif = fieldVectDblLoc.getValueI(MED_FULL_INTERLACE,k+1)
+ print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
+ print "Generate a Corba vector double field"
+ fieldVectDblCorba = createCorbaFieldDouble(familycorba,fieldVectDblLoc)
+ AnalyzeField(fieldVectDblCorba)
+ print ""
+ print "Generate a Local vector integer field"
+ fieldVectIntLoc = createLocalFieldInt(nbOfComp,lengthValue)
+ for k in range(lengthValue):
+ valueI = []
+ for kcomp in range(nbOfComp):
+ valueI.append(randint(0,100))
+ fieldVectIntLoc.setValueI(MED_FULL_INTERLACE,k+1,valueI)
+ valueIverif = fieldVectIntLoc.getValueI(MED_FULL_INTERLACE,k+1)
+ print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
+ print "Generate a Corba vector integer field"
+ fieldVectIntCorba = createCorbaFieldInt(familycorba,fieldVectIntLoc)
+ AnalyzeField(fieldVectIntCorba)
+ print ""
+print "Fin du script Python ...."
+
+
--- /dev/null
+//=============================================================================
+// File : Family_i.cxx
+// Project : SALOME
+// Copyright : EDF 2002
+// Author : EDF
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Family_i.cxx
+//=============================================================================
+
+#include "Family_i.hxx"
+
+#include "utilities.h"
+#include "Utils_CorbaException.hxx"
+
+#include "MEDMEM_Family.hxx"
+
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=============================================================================
+FAMILY_i::FAMILY_i(): _family((::FAMILY*)NULL),
+ SUPPORT_i()
+{
+ BEGIN_OF("Default Constructor FAMILY_i");
+ END_OF("Default Constructor FAMILY_i");
+}
+//=============================================================================
+/*!
+ * constructor par recopie
+ */
+//=============================================================================
+FAMILY_i::FAMILY_i(const FAMILY_i & f): _family(f._family),
+ SUPPORT_i(f._family)
+{
+ BEGIN_OF("Default Constructor FAMILY_i");
+ END_OF("Default Constructor FAMILY_i");
+}
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+FAMILY_i::~FAMILY_i()
+{
+}
+//=============================================================================
+/*!
+ * Constructor
+ */
+//=============================================================================
+FAMILY_i::FAMILY_i(const ::FAMILY * const f): _family(f),
+ SUPPORT_i(f)
+{
+ BEGIN_OF("Constructor FAMILY_i");
+ END_OF("Constructor FAMILY_i");
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Family's Identifier
+ */
+//=============================================================================
+
+CORBA::Long FAMILY_i::getIdentifier()
+throw (SALOME::SALOME_Exception)
+{
+ if (_family==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _family->getIdentifier();
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces Family Identifier");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Family C++ Object"
+ ,SALOME::INTERNAL_ERROR);
+ }
+
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for number of attributes
+ */
+//=============================================================================
+CORBA::Long FAMILY_i::getNumberOfAttributes()
+throw (SALOME::SALOME_Exception)
+{
+ if (_family==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _family->getNumberOfAttributes();
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to get number of attributes");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Family C++ Object"
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for attributes identifiers
+ */
+//=============================================================================
+Engines::long_array* FAMILY_i::getAttributesIdentifiers()
+throw (SALOME::SALOME_Exception)
+{
+ if (_family==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+ Engines::long_array_var myseq= new Engines::long_array;
+ try
+ {
+ int nbAttribute=_family->getNumberOfAttributes();
+ myseq->length(nbAttribute);
+ int * identifiers=_family->getAttributesIdentifiers();
+ for (int i=0;i<nbAttribute;i++)
+ {
+ myseq[i]=identifiers[i];
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces Family Identifiers");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Family C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for attribute identifier I
+ */
+//=============================================================================
+CORBA::Long FAMILY_i::getAttributeIdentifier(CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_family==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _family->getAttributeIdentifier(i);
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces Family Identifier");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Family C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for attributes values
+ */
+//=============================================================================
+Engines::long_array* FAMILY_i::getAttributesValues()
+throw (SALOME::SALOME_Exception)
+{
+ if (_family==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+ Engines::long_array_var myseq= new Engines::long_array;
+ try
+ {
+ int nbAttribute=_family->getNumberOfAttributes();
+ myseq->length(nbAttribute);
+ int * values=_family->getAttributesValues();
+ for (int i=0;i<nbAttribute;i++)
+ {
+ myseq[i]=values[i];
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces attributs values");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Family C++ Object"
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for attribute value I
+ */
+//=============================================================================
+CORBA::Long FAMILY_i::getAttributeValue(CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_family==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _family->getAttributeValue(i);
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces specified attribut value");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Family C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for attributes desriptions
+ */
+//=============================================================================
+Engines::string_array * FAMILY_i::getAttributesDescriptions()
+throw (SALOME::SALOME_Exception)
+{
+ if (_family==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+
+ Engines::string_array_var myseq = new Engines::string_array;
+ try
+ {
+ int nbAttribute=_family->getNumberOfAttributes();
+ myseq->length(nbAttribute);
+ string * descattribute=_family->getAttributesDescriptions();
+ for (int i=0;i<nbAttribute;i++)
+ {
+ myseq[i]=CORBA::string_dup(descattribute[i].c_str());
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces attributs descriptions");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Family C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for attribute description i
+ */
+//=============================================================================
+char * FAMILY_i::getAttributeDescription( CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_family==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return CORBA::string_dup(_family->getAttributeDescription(i).c_str());
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces specified attribut description");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Family C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+
--- /dev/null
+//=============================================================================
+// File : Family_i.hxx
+// Project : SALOME
+// Copyright : EDF 2002
+// Author : EDF
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Family_i.hxx
+//=============================================================================
+#ifndef MED_FAMILY_I_HXX_
+#define MED_FAMILY_I_HXX_
+
+
+#include "Support_i.hxx"
+
+class FAMILY;
+class FAMILY_i:
+ public POA_SALOME_MED::FAMILY,
+ public SUPPORT_i
+{
+protected :
+ FAMILY_i();
+ ~FAMILY_i();
+
+ // C++ object containing values
+ const ::FAMILY * const _family ;
+
+public :
+ // Constructors and associated internal methods
+ FAMILY_i(const ::FAMILY * const f);
+ FAMILY_i(const FAMILY_i & f);
+
+ CORBA::Long getIdentifier()
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getNumberOfAttributes()
+ throw (SALOME::SALOME_Exception);
+ Engines::long_array* getAttributesIdentifiers()
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getAttributeIdentifier(CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ Engines::long_array* getAttributesValues()
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getAttributeValue(CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ Engines::string_array* getAttributesDescriptions()
+ throw (SALOME::SALOME_Exception);
+ char* getAttributeDescription( CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+
+};
+#endif /* MED_FAMILY_I_HXX_ */
--- /dev/null
+//=============================================================================
+// File : Fielddouble_i.hxx
+// Project : SALOME
+// Author : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fielddouble_i.hxx
+//=============================================================================
+
+#include "FieldDouble_i.hxx"
+#include "utilities.h"
+#include "convert.hxx"
+
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=============================================================================
+FIELDDOUBLE_i::FIELDDOUBLE_i(): FIELDOF_i<double>()
+{
+ BEGIN_OF("Default Constructor FIELDDOUBLE_i");
+ END_OF("Default Constructor FIELDDOUBLE_i");
+}
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+FIELDDOUBLE_i::~FIELDDOUBLE_i()
+{
+ BEGIN_OF("Default Destructor FIELDDOUBLE_i");
+ END_OF("Default Destructor FIELDDOUBLE_i");
+}
+//=============================================================================
+/*!
+ * Constructor par recopie
+ */
+//=============================================================================
+FIELDDOUBLE_i::FIELDDOUBLE_i(FIELDDOUBLE_i & fd):
+ FIELDOF_i<double>(fd._fieldTptr)
+{
+ BEGIN_OF("Default Constructor FIELDDOUBLE_i");
+ END_OF("Default Constructor FIELDDOUBLE_i");
+}
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=============================================================================
+FIELDDOUBLE_i::FIELDDOUBLE_i(SALOME_MED::SUPPORT_ptr mySupportIOR,::FIELD<double> * const f): FIELDOF_i<double>(mySupportIOR,f)
+{
+ BEGIN_OF("Constructor FIELDDOUBLE_i");
+ END_OF(" Constructor FIELDDOUBLE_i");
+}
+
+//=============================================================================
+/*!
+ * CORBA: Accessor for Field's values
+*/
+//=============================================================================
+
+Engines::double_array* FIELDDOUBLE_i::getValue( SALOME_MED::medModeSwitch mode )
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ Engines::double_array_var myseq = new Engines::double_array;
+ try
+ {
+ int nbval=_fieldTptr->getNumberOfComponents();
+
+ // Ajout NB pour avoir la valeur correct de nbval
+ SALOME_MED::medEntityMesh entity = _support->getEntity();
+ if (_support->isOnAllElements())
+ {
+ if (entity == SALOME_MED::MED_NODE)
+ nbval = (_support->getMesh()->getNumberOfNodes())*nbval;
+ else
+ nbval = (_support->getMesh()->getNumberOfElements(entity,SALOME_MED::MED_ALL_ELEMENTS))*nbval;
+ }
+ else
+ {
+ nbval = (_support->getNumberOfElements(SALOME_MED::MED_ALL_ELEMENTS))*nbval;
+ }
+
+ medModeSwitch modemed=convertIdlModeToMedMode(mode);
+ double * values =_fieldTptr->getValue(modemed);
+
+ myseq->length(nbval);
+ for (int i=0; i<nbval; i++)
+ {
+ myseq[i]=values[i];
+ };
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces Field ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
--- /dev/null
+//=============================================================================
+// File : Fielddouble_i.hxx
+// Project : SALOME
+// Author : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fielddouble_i.hxx
+//=============================================================================
+
+#ifndef MED_FIELDDOUBLE_I_HXX_
+#define MED_FIELDDOUBLE_I_HXX_
+
+#include <SALOMEconfig.h>
+
+#include CORBA_SERVER_HEADER(MED)
+
+#include "Field_i.hxx"
+#include "FieldOf_i.hxx"
+
+#include "MEDMEM_Field.hxx"
+
+class FIELDDOUBLE_i: public FIELDOF_i<double>
+{
+private:
+
+public:
+ FIELDDOUBLE_i();
+ ~FIELDDOUBLE_i();
+ FIELDDOUBLE_i(SALOME_MED::SUPPORT_ptr mySupportIOR,::FIELD<double> * const f);
+ FIELDDOUBLE_i(FIELDDOUBLE_i & f);
+
+ Engines::double_array * getValue (SALOME_MED::medModeSwitch mode )
+ throw (SALOME::SALOME_Exception);
+};
+
+
+#endif /* MED_FIELDDOUBLE_I_HXX_ */
--- /dev/null
+//=============================================================================
+// File : Fieldint_i.hxx
+// Project : SALOME
+// Author : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fieldint_i.hxx
+//=============================================================================
+
+#include "FieldInt_i.hxx"
+#include "utilities.h"
+#include "convert.hxx"
+
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=============================================================================
+FIELDINT_i::FIELDINT_i(): FIELDOF_i<int>()
+{
+ BEGIN_OF("Default Constructor FIELDINT_i");
+ END_OF("Default Constructor FIELDINT_i");
+}
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+FIELDINT_i::~FIELDINT_i()
+{
+ BEGIN_OF("Default Destructor FIELDINT_i");
+ END_OF("Default Destructor FIELDINT_i");
+}
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=============================================================================
+FIELDINT_i::FIELDINT_i(SALOME_MED::SUPPORT_ptr mySupportIOR, ::FIELD<int> * const f): FIELDOF_i<int>(mySupportIOR,f)
+{
+ BEGIN_OF("Constructor FIELDINT_i");
+ END_OF(" Constructor FIELDINT_i");
+}
+//=============================================================================
+/*!
+ * Constructor par recopie
+ */
+//=============================================================================
+FIELDINT_i::FIELDINT_i(FIELDINT_i &fi):
+ FIELDOF_i<int>(fi._fieldTptr)
+{
+ BEGIN_OF("Constructor FIELDINT_i");
+ END_OF(" Constructor FIELDINT_i");
+}
+
+//=============================================================================
+/*!
+ * CORBA: Accessor for Field's values
+*/
+//=============================================================================
+
+Engines::long_array* FIELDINT_i::getValue( SALOME_MED::medModeSwitch mode )
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ Engines::long_array_var myseq = new Engines::long_array;
+ try
+ {
+ int nbval=_fieldTptr->getNumberOfComponents();
+
+ // Ajout NB pour avoir la valeur correct de nbval
+ SALOME_MED::medEntityMesh entity = _support->getEntity();
+ if (_support->isOnAllElements())
+ {
+ if (entity == SALOME_MED::MED_NODE)
+ nbval = (_support->getMesh()->getNumberOfNodes())*nbval;
+ else
+ nbval = (_support->getMesh()->getNumberOfElements(entity,SALOME_MED::MED_ALL_ELEMENTS))*nbval;
+ }
+ else
+ {
+ nbval = (_support->getNumberOfElements(SALOME_MED::MED_ALL_ELEMENTS))*nbval;
+ }
+
+ medModeSwitch modemed=convertIdlModeToMedMode(mode);
+ int * values =_fieldTptr->getValue(modemed);
+
+ myseq->length(nbval);
+ for (int i=0; i<nbval; i++)
+ {
+ myseq[i]=values[i];
+ };
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces Field");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
--- /dev/null
+//=============================================================================
+// File : FieldInt_i.hxx
+// Project : SALOME
+// Author : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/FieldInt_i.hxx
+//=============================================================================
+
+#ifndef MED_FIELDINT_I_HXX_
+#define MED_FIELDINT_I_HXX_
+
+#include <SALOMEconfig.h>
+
+#include CORBA_SERVER_HEADER(MED)
+
+#include "Field_i.hxx"
+#include "FieldOf_i.hxx"
+
+#include "MEDMEM_Field.hxx"
+
+class FIELDINT_i: public FIELDOF_i<int>
+{
+private:
+ FIELDINT_i();
+
+public:
+ ~FIELDINT_i();
+ FIELDINT_i(SALOME_MED::SUPPORT_ptr mySupportIOR, ::FIELD<int> * const f);
+ FIELDINT_i(FIELDINT_i & f);
+ Engines::long_array * getValue (SALOME_MED::medModeSwitch mode )
+ throw (SALOME::SALOME_Exception);
+};
+#endif /* MED_FIELDINT_I_HXX_ */
--- /dev/null
+//=============================================================================
+// File : FieldOf_i.hxx
+// Project : SALOME
+// Author : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/FieldOf_i.hxx
+//=============================================================================
+
+
+#ifndef MED_FIELDOF_I_HXX_
+#define MED_FIELDOF_I_HXX_
+
+#include <map>
+#include <string>
+# include <sstream>
+
+#include <SALOMEconfig.h>
+
+# include "Utils_ORB_INIT.hxx"
+# include "Utils_SINGLETON.hxx"
+
+#include CORBA_SERVER_HEADER(MED)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "Field_i.hxx"
+#include "Support_i.hxx"
+
+#include "convert.hxx"
+
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Field.hxx"
+
+template <class T> class FIELDOF_i: public FIELD_i
+{
+public :
+ static map < int, ::FIELD<T> * > fieldMap ;
+protected :
+ static int fieldIndex ;
+
+protected :
+ // C++ object containing values
+
+ ::FIELD<T> * const _fieldTptr;
+ const int _corbaIndex;
+ string _FieldId;
+
+ // CORBA : SUPPORT IOR
+ const SALOME_MED::SUPPORT_ptr _support ;
+
+
+public :
+ // Constructors and associated internal methods
+ FIELDOF_i();
+ FIELDOF_i(SALOME_MED::SUPPORT_ptr support,::FIELD<T> * const field);
+ FIELDOF_i(::FIELD<T> * const f);
+ FIELDOF_i(FIELDOF_i & f);
+ ~FIELDOF_i();
+
+ char * getName() throw (SALOME::SALOME_Exception);
+ char * getDescription() throw (SALOME::SALOME_Exception);
+ SALOME_MED::SUPPORT_ptr getSupport() throw (SALOME::SALOME_Exception);
+ CORBA::Long getNumberOfComponents()
+ throw (SALOME::SALOME_Exception);
+ char * getComponentName(CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ char * getComponentUnit(CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getIterationNumber()
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getOrderNumber() throw (SALOME::SALOME_Exception);
+ CORBA::Double getTime() throw (SALOME::SALOME_Exception);
+ CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception);
+
+ Engines::string_array * getComponentsNames() throw (SALOME::SALOME_Exception);
+ Engines::string_array * getComponentsUnits() throw (SALOME::SALOME_Exception);
+ void addInStudy(SALOMEDS::Study_ptr myStudy,
+ SALOME_MED::FIELD_ptr myIor) throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection);
+
+ CORBA::Long addDriver (SALOME_MED::medDriverTypes driverType,
+ const char* fileName, const char* fieldName)
+ throw (SALOME::SALOME_Exception);
+ void rmDriver (CORBA::Long i) throw (SALOME::SALOME_Exception);
+ void read (CORBA::Long i) throw (SALOME::SALOME_Exception);
+ void write (CORBA::Long i, const char* driverFieldName)
+ throw (SALOME::SALOME_Exception);
+
+ // Cuisine Interne
+ ::FIELD<T> * constructConstField() const;
+
+ };
+template <class T> map < int, ::FIELD<T> * > FIELDOF_i<T>::fieldMap ;
+template <class T> int FIELDOF_i<T>::fieldIndex = 0;
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=============================================================================
+
+//template <class T> FIELDOF_i<T>::FIELDOF_i():_fieldTptr(FIELDOF_i<T>::constructConstField())
+template <class T> FIELDOF_i<T>::FIELDOF_i():_fieldTptr(constructConstField()),
+ _support((SALOME_MED::SUPPORT_ptr) NULL)
+{
+ BEGIN_OF("Default Constructor Field_i");
+ END_OF(" Default Constructor Field_i");
+}
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+template <class T> FIELDOF_i<T>::~FIELDOF_i()
+{
+}
+//=============================================================================
+/*!
+ * Constructor
+ */
+//=============================================================================
+template <class T> FIELDOF_i<T>::FIELDOF_i(SALOME_MED::SUPPORT_ptr support,::FIELD<T> * const field):
+ _fieldTptr(field),
+ _corbaIndex(FIELDOF_i<T>::fieldIndex++),
+ _FieldId(""),
+ _support(SALOME_MED::SUPPORT::_duplicate(support))
+{
+ BEGIN_OF("Constructor FIELDOF_i(SALOME_MED::SUPPORT_ptr support,::FIELD<T> * const field)");
+ FIELDOF_i<T>::fieldMap[_corbaIndex]=_fieldTptr;
+
+ MESSAGE("FIELDOF_i<T>::FIELDOF_i Checking of pointeurs !!!");
+
+ SCRUTE(_fieldTptr);
+ SCRUTE(_support);
+ SCRUTE(_support->getMesh());
+
+ END_OF("Constructor FIELDOF_i(SALOME_MED::SUPPORT_ptr support,::FIELD<T> * const field)");
+}
+
+
+template <class T> FIELDOF_i<T>::FIELDOF_i( FIELD<T> * const f):
+ _fieldTptr(f),
+ _corbaIndex(FIELDOF_i<T>::fieldIndex++),
+ _FieldId(""),
+ _support((SALOME_MED::SUPPORT_ptr) NULL)
+{
+ BEGIN_OF("Constructor Field_i");
+ FIELDOF_i<T>::fieldMap[_corbaIndex]=_fieldTptr;
+ END_OF("Constructor Field_i");
+}
+//=============================================================================
+/*!
+ * Constructor par recopie
+ */
+//=============================================================================
+template <class T> FIELDOF_i<T>::FIELDOF_i( FIELDOF_i & f):_fieldTptr(f._fieldTptr),
+ _corbaIndex(FIELDOF_i<T>::fieldIndex++),
+ _FieldId("")
+{
+ BEGIN_OF("Constructor Field_i");
+ FIELDOF_i<T>::fieldMap[_corbaIndex]=_fieldTptr;
+ END_OF("Constructor Field_i");
+}
+//=============================================================================
+/*!
+ * Constructor d un pointeur constant
+ */
+//=============================================================================
+template <class T> ::FIELD<T> * FIELDOF_i<T>::constructConstField() const
+{
+ ::FIELD<T> * const ptrField =new ::FIELD<T>();
+ return ptrField;
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Fields's Name
+ */
+//=============================================================================
+template <class T> char * FIELDOF_i<T>::getName()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return CORBA::string_dup(_fieldTptr->getName().c_str());
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au nom");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Fields's Description
+ */
+//=============================================================================
+template <class T> char * FIELDOF_i<T>::getDescription()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return CORBA::string_dup(_fieldTptr->getDescription().c_str());
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant a la description");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Fields's Support
+ */
+//=============================================================================
+
+template <class T> SALOME_MED::SUPPORT_ptr FIELDOF_i<T>::getSupport()
+ throw (SALOME::SALOME_Exception)
+{
+ BEGIN_OF("SALOME_MED::SUPPORT_ptr FIELDOF_i<T>::getSupport()");
+
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field",
+ SALOME::INTERNAL_ERROR);
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No Support in Field",
+ SALOME::INTERNAL_ERROR);
+
+ SCRUTE(_fieldTptr);
+
+ SCRUTE(_support);
+
+ SALOME_MED::SUPPORT_ptr support = SALOME_MED::SUPPORT::_duplicate(_support);
+
+ END_OF("SALOME_MED::SUPPORT_ptr FIELDOF_i<T>::getSupport()");
+
+ return support ;
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Fields's Number of components
+ */
+//=============================================================================
+template <class T> CORBA::Long FIELDOF_i<T>::getNumberOfComponents()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _fieldTptr->getNumberOfComponents();
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au support");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for names of component I
+ */
+//=============================================================================
+template <class T> char * FIELDOF_i<T>::getComponentName(CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return CORBA::string_dup(_fieldTptr->getComponentName(i).c_str());
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au nom d un component");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for unit of component I
+ */
+//=============================================================================
+template <class T> char * FIELDOF_i<T>::getComponentUnit(CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return CORBA::string_dup(_fieldTptr->getMEDComponentUnit(i).c_str());
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au nom d un component");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for iteration number
+ */
+//=============================================================================
+template <class T> CORBA::Long FIELDOF_i<T>::getIterationNumber()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _fieldTptr->getIterationNumber();
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Corba Number
+ */
+//=============================================================================
+template <class T> CORBA::Long FIELDOF_i<T>::getCorbaIndex()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ return _corbaIndex;
+
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for iteration number
+ */
+//=============================================================================
+template <class T> CORBA::Long FIELDOF_i<T>::getOrderNumber()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _fieldTptr->getOrderNumber();
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor
+ */
+//=============================================================================
+template <class T> CORBA::Double FIELDOF_i<T>::getTime()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _fieldTptr->getTime();
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Fields's Components names
+ */
+//=============================================================================
+template <class T> Engines::string_array * FIELDOF_i<T>::getComponentsNames()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ Engines::string_array_var myseq = new Engines::string_array;
+ try
+ {
+ int nbcom = _fieldTptr->getNumberOfComponents();
+ myseq->length(nbcom);
+ string * namecom=_fieldTptr->getComponentsNames();
+ for (int i=0;i<nbcom;i++)
+ {
+ myseq[i]=CORBA::string_dup(namecom[i].c_str());
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Fields's Components units
+ */
+//=============================================================================
+template <class T> Engines::string_array * FIELDOF_i<T>::getComponentsUnits()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ Engines::string_array_var myseq = new Engines::string_array;
+ try
+ {
+ int nbcom = _fieldTptr->getNumberOfComponents();
+ myseq->length(nbcom);
+ string * unitcom=_fieldTptr->getMEDComponentsUnits();
+ for (int i=0;i<nbcom;i++)
+ {
+ myseq[i]=CORBA::string_dup(unitcom[i].c_str());
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Add in Study
+ */
+//=============================================================================
+template <class T> void FIELDOF_i<T>::addInStudy(SALOMEDS::Study_ptr myStudy,
+ SALOME_MED::FIELD_ptr myIor )
+throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
+{
+ BEGIN_OF(" FIELDOF_i::addInStudy");
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ if ( _FieldId != "" )
+ {
+ MESSAGE("Field already in Study");
+ THROW_SALOME_CORBA_EXCEPTION("Field already in Study", \
+ SALOME::BAD_PARAM);
+ };
+
+
+ SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var aIOR;
+
+ // Create SComponent labelled 'Med'
+ SALOMEDS::SComponent_var medfather = myStudy->FindComponent("Med");
+ if ( CORBA::is_nil(medfather) )
+ THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
+
+ // Create SObject labelled 'MEDFIELD' if it doesn't already exit
+ SALOMEDS::SObject_var medfieldfather = myStudy->FindObject("MEDFIELD");
+
+ myBuilder->NewCommand();
+ if ( CORBA::is_nil(medfieldfather) )
+ {
+ MESSAGE("Add Object 'MEDFIELD'");
+ medfieldfather = myBuilder->NewObject(medfather);
+ anAttr = myBuilder->FindOrCreateAttribute(medfieldfather, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue("MEDFIELD");
+
+ } ;
+
+ // Create SObject labelled 'FIELDNAME' if it doesn't already exit
+ SALOMEDS::SObject_var medfieldnamefather = myStudy->FindObject((_fieldTptr->getName()).c_str());
+ if ( CORBA::is_nil(medfieldnamefather) )
+ {
+ MESSAGE("Add Object "<<_fieldTptr->getName());
+ medfieldnamefather = myBuilder->NewObject(medfieldfather);
+ anAttr = myBuilder->FindOrCreateAttribute(medfieldnamefather, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue((_fieldTptr->getName()).c_str());
+
+ } ;
+
+ // Create object labelled according to Field's Name
+
+ MESSAGE("Add a Field Object under "<<_fieldTptr->getName());
+ SALOMEDS::SObject_var newObj = myBuilder->NewObject(medfieldnamefather);
+
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
+ CORBA::ORB_var &orb = init(0,0);
+
+ ostringstream iterationName ;
+ iterationName<<"("<<_fieldTptr->getIterationNumber()<<","<<_fieldTptr->getOrderNumber()<<")";
+ anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue(iterationName.str().c_str());
+
+ string iorStr = orb->object_to_string(myIor);
+ anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
+ aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ aIOR->SetValue(iorStr.c_str());
+
+ SALOMEDS::SObject_var supportObject = myStudy->FindObject(_support->getName());
+ if ( CORBA::is_nil(supportObject) ) {
+ MESSAGE("FIELDOF_i::addInStudy : SUPPORT not found") ;
+ } else {
+ SALOMEDS::SObject_var newObjSupport = myBuilder->NewObject(newObj);
+ myBuilder->Addreference(newObjSupport,supportObject);
+ }
+ myBuilder->CommitCommand();
+ _FieldId = newObj->GetID();
+ MESSAGE("FIELDOF_i::addInStudy _FieldId="<< _FieldId);
+
+ END_OF(" FIELDOF_i::addInStudy");
+
+}
+//=============================================================================
+/*!
+ * CORBA: write
+ */
+//=============================================================================
+template <class T> void FIELDOF_i<T>::write (CORBA::Long i, const char* driverFieldName)
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ _fieldTptr->write(i,driverFieldName);
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: read
+ */
+//=============================================================================
+template <class T> void FIELDOF_i<T>::read (CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ _fieldTptr->read(i);
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: rmDriver
+ */
+//=============================================================================
+template <class T> void FIELDOF_i<T>::rmDriver (CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ _fieldTptr->rmDriver(i);
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: addDriver
+ */
+//=============================================================================
+template <class T> CORBA::Long FIELDOF_i<T>::addDriver (SALOME_MED::medDriverTypes driverType,
+ const char* fileName, const char* fieldName) throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ int drivernum=_fieldTptr->addDriver(
+ convertIdlDriverToMedDriver(driverType),
+ fileName,
+ fieldName);
+ return drivernum;
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+
+#endif /* MED_FIELDOF_I_HXX_ */
--- /dev/null
+//=============================================================================
+// File : Field_i.cxx
+// Created : mer fév 20 15:47:57 CET 2002
+// Author : EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Field_i.cxx
+//=============================================================================
+# include "Field_i.hxx"
+
+FIELD_i::FIELD_i()
+{
+}
+FIELD_i::FIELD_i(const FIELD_i & x)
+{
+}
+FIELD_i::~FIELD_i()
+{
+}
+
--- /dev/null
+//=============================================================================
+// File : Field_i.hxx
+// Created : mer fév 20 15:47:57 CET 2002
+// Author : EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Field_i.hxx
+//=============================================================================
+# ifndef __FIELD_I_H__
+# define __FIELD_I_H__
+
+# include <SALOMEconfig.h>
+
+//# include "SALOME_Component_i.hxx"
+# include CORBA_SERVER_HEADER(MED)
+
+# include "Utils_CorbaException.hxx"
+
+class FIELD_i
+{
+
+protected :
+ FIELD_i();
+
+public :
+ FIELD_i( const FIELD_i & x);
+ ~FIELD_i();
+ virtual char * getName()
+ throw (SALOME::SALOME_Exception) = 0;
+ virtual char * getDescription()
+ throw (SALOME::SALOME_Exception) = 0;
+ virtual SALOME_MED::SUPPORT_ptr getSupport()
+ throw (SALOME::SALOME_Exception) = 0;
+ virtual CORBA::Long getNumberOfComponents()
+ throw (SALOME::SALOME_Exception) = 0;
+ virtual char * getComponentName(CORBA::Long i)
+ throw (SALOME::SALOME_Exception) = 0;
+ virtual char * getComponentUnit(CORBA::Long i)
+ throw (SALOME::SALOME_Exception) = 0;
+ virtual CORBA::Long getIterationNumber()
+ throw (SALOME::SALOME_Exception) = 0;
+ virtual CORBA::Long getOrderNumber()
+ throw (SALOME::SALOME_Exception) = 0;
+ virtual CORBA::Double getTime()
+ throw (SALOME::SALOME_Exception) = 0;
+ virtual CORBA::Long getCorbaIndex()
+ throw (SALOME::SALOME_Exception) = 0;
+ virtual Engines::string_array * getComponentsNames()
+ throw (SALOME::SALOME_Exception) = 0;
+ virtual Engines::string_array * getComponentsUnits()
+ throw (SALOME::SALOME_Exception) = 0;
+ virtual void addInStudy(SALOMEDS::Study_ptr myStudy ,
+ SALOME_MED::FIELD_ptr myIor)
+ throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection) = 0;
+ virtual CORBA::Long addDriver (SALOME_MED::medDriverTypes driverType,
+ const char* fileName,
+ const char* fieldName)
+ throw (SALOME::SALOME_Exception) = 0;
+ virtual void rmDriver (CORBA::Long i)
+ throw (SALOME::SALOME_Exception) = 0;
+ virtual void read (CORBA::Long i)
+ throw (SALOME::SALOME_Exception) = 0;
+ virtual void write (CORBA::Long i,
+ const char* driverFieldName)
+ throw (SALOME::SALOME_Exception) = 0;
+};
+# endif /* ifndef ____FIELD_I_H__ */
--- /dev/null
+//=============================================================================
+// File : Group_i.cxx
+// Project : SALOME
+// Author : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/
+//=============================================================================
+
+#include <vector>
+
+#include "utilities.h"
+#include "Utils_CorbaException.hxx"
+
+#include "Group_i.hxx"
+#include "Family_i.hxx"
+
+#include "MEDMEM_Group.hxx"
+#include "MEDMEM_Family.hxx"
+
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=============================================================================
+GROUP_i::GROUP_i():_group((::GROUP*)NULL),
+ SUPPORT_i()
+{
+ BEGIN_OF("Default Constructor GROUP_i");
+ END_OF("Default Constructor GROUP_i");
+};
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+GROUP_i::~GROUP_i()
+{
+};
+//=============================================================================
+/*!
+ * Constructor
+ */
+//=============================================================================
+GROUP_i::GROUP_i(const ::GROUP * const g):_group(g),
+ SUPPORT_i(g)
+{
+ BEGIN_OF("Constructor GROUP_i");
+ END_OF("Constructor GROUP_i");
+};
+//=============================================================================
+/*!
+ * Constructor par recopie
+ */
+//=============================================================================
+GROUP_i::GROUP_i(const GROUP_i & g):_group(g._group),
+ SUPPORT_i(g._group)
+{
+ BEGIN_OF("Constructor GROUP_i");
+ END_OF("Constructor GROUP_i");
+};
+//=============================================================================
+/*!
+ * CORBA: Number of Families existing in the group
+ */
+//=============================================================================
+
+CORBA::Long GROUP_i::getNumberOfFamilies()
+throw (SALOME::SALOME_Exception)
+{
+ if (_group==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Group",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _group->getNumberOfFamilies();
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to get number of families of the group");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Group C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+};
+//=============================================================================
+/*!
+ * CORBA: Returns references for families within the group
+ */
+//=============================================================================
+
+SALOME_MED::Family_array* GROUP_i::getFamilies()
+throw (SALOME::SALOME_Exception)
+{
+ if (_group==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Group",\
+ SALOME::INTERNAL_ERROR);
+ SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array;
+ try
+ {
+ int nbfam= _group->getNumberOfFamilies();
+ myseq->length(nbfam);
+ vector<FAMILY*> fam(nbfam);
+ fam = _group->getFamilies();
+ for (int i=0;i<nbfam;i++)
+ {
+ FAMILY_i * f1=new FAMILY_i(fam[i]);
+ SALOME_MED::FAMILY_ptr f2 =
+ f1->POA_SALOME_MED::FAMILY::_this();
+ f1->_remove_ref();
+ myseq[i] = f2;
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to access families");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Family C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+};
+//=============================================================================
+/*!
+ * CORBA: Returns reference for family I within the group
+ */
+//=============================================================================
+
+SALOME_MED::FAMILY_ptr GROUP_i::getFamily(CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_group==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Group",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ FAMILY * fam=_group->getFamily(i);
+ FAMILY_i * f1=new FAMILY_i(fam);
+ SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this();
+ f1->_remove_ref();
+ return (SALOME_MED::FAMILY::_duplicate(f2));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces to the specified family");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Family C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+};
--- /dev/null
+//=============================================================================
+// File : Group_i.hxx
+// Project : SALOME
+// Author : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Group_i.hxx
+//=============================================================================
+#ifndef MED_GROUP_I_HXX_
+#define MED_GROUP_I_HXX_
+
+#include "Support_i.hxx"
+
+class FAMILY_i;
+class GROUP;
+
+class GROUP_i:
+ public POA_SALOME_MED::GROUP,
+ public SUPPORT_i
+{
+protected :
+ GROUP_i();
+ ~GROUP_i();
+
+ // C++ object containing values
+ const ::GROUP * const _group;
+
+public :
+ // Constructors and associated internal methods
+ GROUP_i(const ::GROUP * const g);
+ GROUP_i(const GROUP_i & g);
+
+ CORBA::Long getNumberOfFamilies()
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::Family_array* getFamilies()
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::FAMILY_ptr getFamily(CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+};
+
+#endif /* MED_GROUP_I_HXX_ */
--- /dev/null
+#==============================================================================
+// File : Field_i.hxx
+// Author : Marc Tajchman
+// Project : SALOME
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Makefile.in
+//=============================================================================
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=../../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_srcdir)/idl
+
+MACHINE=PCLINUX
+
+@COMMENCE@
+
+
+#EXPORT_PYSCRIPTS = \
+# testMed.py
+
+EXPORT_HEADERS = \
+ convert.hxx \
+ Med_i.hxx \
+ Family_i.hxx \
+ FieldDouble_i.hxx \
+ FieldInt_i.hxx \
+ FieldOf_i.hxx \
+ Field_i.hxx \
+ Group_i.hxx \
+ Mesh_i.hxx \
+ Support_i.hxx
+
+# Libraries targets
+
+LIB=libMEDImpl.la
+LIB_SRC = Med_i.cxx Family_i.cxx FieldDouble_i.cxx FieldInt_i.cxx Field_i.cxx Group_i.cxx Mesh_i.cxx Support_i.cxx convert.cxx
+LIB_SERVER_IDL = MED.idl
+LIB_CLIENT_IDL= SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl
+
+# Executables targets
+BIN_SRC =
+BIN_SERVER_IDL =
+BIN_CLIENT_IDL =
+
+
+CPPFLAGS+= $(MED2_INCLUDES) $(HDF5_INCLUDES)
+CXXFLAGS=-g -D_DEBUG_ -D__x86__ -D__linux__
+LDFLAGS+=-lmedmem -lOpUtil
+#LDFLAGS+=-lmedmem -L. -lSalomeContainer -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification
+# does we put only -lSalomeContainer and compiler retrieves -lSalomeNS -lRegistry -lOpUtil ????
+
+MED.hh MEDSK.cc: MED.idl
+ omniidl -bcxx -Wbtp $^
+
+@CONCLUDE@
--- /dev/null
+//=============================================================================
+// File : Med_i.cxx
+// Project : SALOME
+// Author : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Med_i.cxx
+//=============================================================================
+
+#include <deque>
+
+//#include "MEDMEM_Field.hxx"
+
+#include "Med_i.hxx"
+#include "Mesh_i.hxx"
+#include "FieldDouble_i.hxx"
+#include "FieldInt_i.hxx"
+#include "Support_i.hxx"
+#include "Family_i.hxx"
+#include "Group_i.hxx"
+
+#include "MEDMEM_DriversDef.hxx"
+#include "convert.hxx"
+#include "utilities.h"
+#include "Utils_CorbaException.hxx"
+
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=================================POA_SALOME_MED::FAMILY::_============================================
+MED_i::MED_i():_med((::MED*)NULL)
+{
+ BEGIN_OF("Default Constructor MED_i");
+ END_OF("Default Constructor MED_i");
+}
+//=============================================================================
+/*!
+ * methods
+ */
+//=============================================================================
+void MED_i::init(SALOMEDS::Study_ptr myStudy,driverTypes driverType, const string & fileName)
+{
+ const char * LOC = "MED_i::init(driverTypes, const string &)" ;
+ BEGIN_OF(LOC);
+
+ _med = new ::MED(driverType,fileName) ;
+ // we create all IOR from _med
+
+ // MESH :
+ deque<string> meshesNames = _med->getMeshNames() ;
+ int numberOfMeshes = meshesNames.size() ;
+ for (int i=0; i<numberOfMeshes; i++) {
+ ::MESH * myMesh = _med->getMesh(meshesNames[i]) ;
+ myMesh->read() ;
+ MESH_i * myMeshI = new MESH_i(myMesh) ;
+ SALOME_MED::MESH_ptr myMeshIOR = myMeshI->_this() ;
+ _meshes[meshesNames[i]]=myMeshIOR ;
+ myMeshI->addInStudy(myStudy,myMeshIOR,fileName) ;
+ }
+
+ // SUPPORT :
+ _med->updateSupport() ;
+
+ // we add all group and family in study :
+ // we add all families
+ vector<FAMILY*> familyVector ;
+ vector<FAMILY*>::iterator familyVectorIt ;
+ // we add all groups
+ vector<GROUP*> groupVector ;
+ vector<GROUP*>::iterator groupVectorIt ;
+
+ MED_FR::MESH_ENTITIES::const_iterator currentEntity;
+ for (int i=0; i<numberOfMeshes; i++) {
+ ::MESH * ptrMesh = _med->getMesh(meshesNames[i]) ;
+ for (currentEntity=MED_FR::meshEntities.begin();currentEntity != MED_FR::meshEntities.end(); currentEntity++) {
+ // family :
+ familyVector = ptrMesh->getFamilies((MED_EN::medEntityMesh)(*currentEntity).first) ;
+ for(familyVectorIt=familyVector.begin();familyVectorIt!=familyVector.end();familyVectorIt++) {
+ FAMILY_i * myFamilyI = new FAMILY_i(*familyVectorIt);
+ SALOME_MED::FAMILY_ptr myFamilyIOR = myFamilyI->POA_SALOME_MED::FAMILY::_this() ;
+ myFamilyI->addInStudy(myStudy,myFamilyIOR) ;
+ }
+ // group :
+ groupVector = ptrMesh->getGroups((MED_EN::medEntityMesh)(*currentEntity).first) ;
+ for(groupVectorIt=groupVector.begin();groupVectorIt!=groupVector.end();groupVectorIt++) {
+ GROUP_i * myGroupI = new GROUP_i(*groupVectorIt);
+ SALOME_MED::GROUP_ptr myGroupIOR = myGroupI->POA_SALOME_MED::GROUP::_this() ;
+ myGroupI->addInStudy(myStudy,myGroupIOR) ;
+ }
+ }
+ }
+
+ for (int i=0; i<numberOfMeshes; i++) {
+ map<MED_FR::med_entite_maillage,::SUPPORT*> mySupports = _med->getSupports(meshesNames[i]) ;
+ map<MED_FR::med_entite_maillage,::SUPPORT*>::const_iterator itSupport ;
+ map<MED_FR::med_entite_maillage,SALOME_MED::SUPPORT_ptr> & mySupportsIOR = _supports[meshesNames[i]] ;
+ for ( itSupport=mySupports.begin(); itSupport!=mySupports.end(); itSupport++ ) {
+ SUPPORT_i * mySupportI = new SUPPORT_i((*itSupport).second);
+ SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this() ;
+ mySupportsIOR[(*itSupport).first]= mySupportIOR ;
+ mySupportI->addInStudy(myStudy,mySupportIOR) ;
+ }
+ }
+
+ // FIELD :
+ deque<string> fieldsNames = _med->getFieldNames() ;
+ int numberOfFields = fieldsNames.size() ;
+ for (int i=0; i<numberOfFields; i++) {
+ deque<DT_IT_> myIteration = _med->getFieldIteration (fieldsNames[i]) ;
+ int numberOfIteration = myIteration.size() ;
+ for (int j=0; j<numberOfIteration; j++) {
+ ::FIELD_ * myField = _med->getField(fieldsNames[i],myIteration[j].dt,myIteration[j].it) ;
+ string meshName = myField->getSupport()->getMesh()->getName() ;
+ medEntityMesh myEntity = myField->getSupport()->getEntity() ;
+ map<string, map<MED_FR::med_entite_maillage,SALOME_MED::SUPPORT_ptr> >::const_iterator itSupportOnMesh = _supports.find(meshName) ;
+ if ( itSupportOnMesh == _supports.end() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "There is no support on mesh named |"
+ << meshName << "|"
+ )
+ );
+ const map<MED_FR::med_entite_maillage,SALOME_MED::SUPPORT_ptr> & SupportOnMesh = (*itSupportOnMesh).second ;
+ map<MED_FR::med_entite_maillage,SALOME_MED::SUPPORT_ptr>::const_iterator itSupport = SupportOnMesh.find((MED_FR::med_entite_maillage)myEntity) ;
+ if (itSupport == SupportOnMesh.end() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "There is no support on entity "
+ << entity << " in mesh named |"
+ << meshName << "|"
+ )
+ );
+ SALOME_MED::SUPPORT_ptr mySupportIOR = (*itSupport).second ;
+ med_type_champ type = myField->getValueType() ;
+ SALOME_MED::FIELD_ptr myFieldIOR ;
+ switch (type) {
+ case MED_FR::MED_INT32: {
+ ((FIELD<int>*)myField)->read() ;
+ FIELDINT_i * myFieldIntI = new FIELDINT_i(mySupportIOR,(FIELD<int>*)myField);
+ //SALOME_MED::FIELDINT_ptr myFieldIntIOR = myFieldIntI->_this() ;
+ POA_SALOME_MED::FIELD_tie<FIELD_i> * myFieldTie = new POA_SALOME_MED::FIELD_tie<FIELD_i>(myFieldIntI) ;
+ myFieldIOR = myFieldTie->_this() ;
+ myFieldIntI->addInStudy(myStudy,myFieldIOR) ;
+
+ break ;
+ }
+ // else
+ case MED_FR::MED_REEL64: {
+ ((FIELD<double>*)myField)->read() ;
+ FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i(mySupportIOR,(FIELD<double>*)myField);
+ //SALOME_MED::FIELDDOUBLE_ptr myFieldDoubleIOR = myFieldDoubleI->_this() ;
+ POA_SALOME_MED::FIELD_tie<FIELD_i> * myFieldTie= new POA_SALOME_MED::FIELD_tie<FIELD_i>(myFieldDoubleI) ;
+ myFieldIOR = myFieldTie->_this() ;
+ myFieldDoubleI->addInStudy(myStudy,myFieldIOR) ;
+ break ;
+ }
+ default: {
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ <<" * Iteration "<<FieldIteration[j].dt
+ <<", order number "<<FieldIteration[j].it
+ <<" has wrond type : "<<type)
+ );
+ break ;
+ }
+ }
+ // SALOME_MED::FIELD_ptr myFieldIOR = myFieldI->POA_SALOME_MED::FIELD::_this() ;
+ DT_IT_ dtIt;
+ dtIt.dt = myIteration[j].dt ;
+ dtIt.it = myIteration[j].it ;
+ _fields[fieldsNames[i]][dtIt] = myFieldIOR ;
+ }
+ }
+
+ END_OF(LOC);
+}
+
+//=============================================================================
+/*!
+ * methods
+ */
+//=============================================================================
+void MED_i::initWithFieldType(SALOMEDS::Study_ptr myStudy,driverTypes driverType, const string & fileName)
+{
+ const char * LOC = "MED_i::initWithFieldType(driverTypes, const string &)" ;
+ BEGIN_OF(LOC);
+
+ _med = new ::MED(driverType,fileName) ;
+ // we create all IOR from _med
+
+ // MESH :
+ deque<string> meshesNames = _med->getMeshNames() ;
+ int numberOfMeshes = meshesNames.size() ;
+ for (int i=0; i<numberOfMeshes; i++) {
+ ::MESH * myMesh = _med->getMesh(meshesNames[i]) ;
+ myMesh->read() ;
+ MESH_i * myMeshI = new MESH_i(myMesh) ;
+ SALOME_MED::MESH_ptr myMeshIOR = myMeshI->_this() ;
+ //POA_SALOME_MED::MESH_tie<MESH_i> * myMeshTie = new POA_SALOME_MED::MESH_tie<MESH_i>(myMeshI) ;
+ //SALOME_MED::MESH_ptr myMeshIOR = myMeshTie->_this() ;
+ _meshes[meshesNames[i]]=myMeshIOR ;
+ myMeshI->addInStudy(myStudy,myMeshIOR) ;
+ }
+
+ // SUPPORT :
+ _med->updateSupport() ;
+ for (int i=0; i<numberOfMeshes; i++) {
+ map<MED_FR::med_entite_maillage,::SUPPORT*> mySupports = _med->getSupports(meshesNames[i]) ;
+ map<MED_FR::med_entite_maillage,::SUPPORT*>::const_iterator itSupport ;
+ map<MED_FR::med_entite_maillage,SALOME_MED::SUPPORT_ptr> & mySupportsIOR = _supports[meshesNames[i]] ;
+ for ( itSupport=mySupports.begin(); itSupport!=mySupports.end(); itSupport++ ) {
+ SUPPORT_i * mySupportI = new SUPPORT_i((*itSupport).second);
+ SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this() ;
+ //POA_SALOME_MED::SUPPORT_tie<SUPPORT_i> * mySupportTie = new POA_SALOME_MED::SUPPORT_tie<SUPPORT_i>(mySupportI) ;
+ //SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportTie->_this() ;
+ mySupportsIOR[(*itSupport).first]= mySupportIOR ;
+ mySupportI->addInStudy(myStudy,mySupportIOR) ;
+ }
+ }
+
+ // FIELD :
+ deque<string> fieldsNames = _med->getFieldNames() ;
+ int numberOfFields = fieldsNames.size() ;
+ for (int i=0; i<numberOfFields; i++) {
+ deque<DT_IT_> myIteration = _med->getFieldIteration (fieldsNames[i]) ;
+ int numberOfIteration = myIteration.size() ;
+ for (int j=0; j<numberOfIteration; j++) {
+ ::FIELD_ * myField = _med->getField(fieldsNames[i],myIteration[j].dt,myIteration[j].it) ;
+ string meshName = myField->getSupport()->getMesh()->getName() ;
+ medEntityMesh myEntity = myField->getSupport()->getEntity() ;
+ map<string, map<MED_FR::med_entite_maillage,SALOME_MED::SUPPORT_ptr> >::const_iterator itSupportOnMesh = _supports.find(meshName) ;
+ if ( itSupportOnMesh == _supports.end() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "There is no support on mesh named |"
+ << meshName << "|"
+ )
+ );
+ const map<MED_FR::med_entite_maillage,SALOME_MED::SUPPORT_ptr> & SupportOnMesh = (*itSupportOnMesh).second ;
+ map<MED_FR::med_entite_maillage,SALOME_MED::SUPPORT_ptr>::const_iterator itSupport = SupportOnMesh.find((MED_FR::med_entite_maillage)myEntity) ;
+ if (itSupport == SupportOnMesh.end() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "There is no support on entity "
+ << entity << " in mesh named |"
+ << meshName << "|"
+ )
+ );
+ SALOME_MED::SUPPORT_ptr mySupportIOR = (*itSupport).second ;
+ med_type_champ type = myField->getValueType() ;
+ // SALOME_MED::FIELD_ptr myFieldIOR ;
+
+ DT_IT_ dtIt;
+ dtIt.dt = myIteration[j].dt ;
+ dtIt.it = myIteration[j].it ;
+
+ switch (type) {
+ case MED_FR::MED_INT32: {
+ ((FIELD<int>*)myField)->read() ;
+ FIELDINT_i * myFieldIntI = new FIELDINT_i(mySupportIOR,(FIELD<int>*)myField);
+ //SALOME_MED::FIELDINT_ptr myFieldIntIOR = myFieldIntI->_this() ;
+ // POA_SALOME_MED::FIELD_tie<FIELD_i> * myFieldTie = new POA_SALOME_MED::FIELD_tie<FIELD_i>(myFieldIntI) ;
+ // myFieldIOR = myFieldTie->_this() ;
+ // myFieldIntI->addInStudy(myStudy,myFieldIOR) ;
+
+ SALOME_MED::FIELDINT_ptr myFieldIntIOR ;
+ POA_SALOME_MED::FIELDINT_tie<FIELDINT_i> * myFieldIntTie = new POA_SALOME_MED::FIELDINT_tie<FIELDINT_i>(myFieldIntI) ;
+ myFieldIntIOR = myFieldIntTie->_this() ;
+ myFieldIntI->addInStudy(myStudy,myFieldIntIOR) ;
+
+ _fields[fieldsNames[i]][dtIt] = myFieldIntIOR ;
+
+ break ;
+ }
+ // else
+ case MED_FR::MED_REEL64: {
+ ((FIELD<double>*)myField)->read() ;
+ FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i(mySupportIOR,(FIELD<double>*)myField);
+ //SALOME_MED::FIELDDOUBLE_ptr myFieldDoubleIOR = myFieldDoubleI->_this() ;
+ // POA_SALOME_MED::FIELD_tie<FIELD_i> * myFieldTie= new POA_SALOME_MED::FIELD_tie<FIELD_i>(myFieldDoubleI) ;
+ // myFieldIOR = myFieldTie->_this() ;
+ // myFieldDoubleI->addInStudy(myStudy,myFieldIOR) ;
+
+ SALOME_MED::FIELDDOUBLE_ptr myFieldDoubleIOR ;
+ POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * myFieldDoubleTie = new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(myFieldDoubleI) ;
+ myFieldDoubleIOR = myFieldDoubleTie->_this() ;
+ myFieldDoubleI->addInStudy(myStudy,myFieldDoubleIOR) ;
+
+ _fields[fieldsNames[i]][dtIt] = myFieldDoubleIOR ;
+
+ break ;
+ }
+ default: {
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ <<" * Iteration "<<FieldIteration[j].dt
+ <<", order number "<<FieldIteration[j].it
+ <<" has wrond type : "<<type)
+ );
+ break ;
+ }
+ }
+ // SALOME_MED::FIELD_ptr myFieldIOR = myFieldI->POA_SALOME_MED::FIELD::_this() ;
+ // DT_IT_ dtIt;
+ // dtIt.dt = myIteration[j].dt ;
+ // dtIt.it = myIteration[j].it ;
+ // _fields[fieldsNames[i]][dtIt] = myFieldIOR ;
+ }
+ }
+
+ END_OF(LOC);
+}
+
+// MED_i::MED_i(::MED * const m):_med(m)
+// {
+// BEGIN_OF("Constructor MED_i");
+// END_OF("Constructor MED_i");
+// }
+//=============================================================================
+/*!
+ * Constructor par recopie
+ */
+//=============================================================================
+// MED_i::MED_i(MED_i & m):_med(m._med)
+// {
+// BEGIN_OF("Constructor par recopie MED_i");
+// END_OF("Constructorpar recopie MED_i");
+// }
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+MED_i::~MED_i()
+{
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Number of meshes
+ */
+//=============================================================================
+CORBA::Long MED_i::getNumberOfMeshes()
+throw (SALOME::SALOME_Exception)
+{
+ if (_med==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _med->getNumberOfMeshes();
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to get the number of meshes in Med Object");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces MED C++ Object"
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Number of fields
+ */
+//=============================================================================
+CORBA::Long MED_i::getNumberOfFields()
+throw (SALOME::SALOME_Exception)
+{
+ if (_med==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _med->getNumberOfFields();
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to get the number of fields in Med Object");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces MED C++ Object"
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for meshes names
+ */
+//=============================================================================
+Engines::string_array * MED_i::getMeshNames()
+throw (SALOME::SALOME_Exception)
+{
+ if (_med==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
+ SALOME::INTERNAL_ERROR);
+ Engines::string_array_var myseq = new Engines::string_array;
+ try
+ {
+ int nbMeshes=_med->getNumberOfMeshes();
+ myseq->length(nbMeshes);
+ string * nameMeshes = new string[nbMeshes];
+ _med->getMeshNames(nameMeshes);
+ for (int i=0;i<nbMeshes;i++)
+ {
+ myseq[i]=CORBA::string_dup(nameMeshes[i].c_str());
+ }
+ delete [] nameMeshes;
+ nameMeshes=NULL;
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to get the names of the meshes in Med Object");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces MED C++ Object"
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for fields names
+ */
+//=============================================================================
+Engines::string_array * MED_i::getFieldNames()
+throw (SALOME::SALOME_Exception)
+{
+ if (_med==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
+ SALOME::INTERNAL_ERROR);
+ Engines::string_array_var myseq = new Engines::string_array;
+ try
+ {
+ int nbFields=_med->getNumberOfFields();
+ myseq->length(nbFields);
+ string * nameFields = new string[nbFields];
+ _med->getFieldNames(nameFields);
+ for (int i=0;i<nbFields;i++)
+ {
+ myseq[i]=CORBA::string_dup(nameFields[i].c_str());
+ }
+ delete nameFields;
+ nameFields=NULL;
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to get the names of the fields in Med Object");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces MED C++ Object"
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for a specific mesh
+ */
+//=============================================================================
+SALOME_MED::MESH_ptr MED_i::getMeshByName(const char* meshName)
+throw (SALOME::SALOME_Exception)
+{
+ if (_med==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ MESH * mesh=_med->getMesh(meshName);
+ MESH_i * m1 = new MESH_i(mesh);
+ SALOME_MED::MESH_ptr m2 = m1->POA_SALOME_MED::MESH::_this();
+ m1->_remove_ref();
+ return (SALOME_MED::MESH::_duplicate(m2));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to get the specified mesh");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces MED C++ Object"
+ ,SALOME::INTERNAL_ERROR);
+ }
+
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for a specific mesh
+ */
+//=============================================================================
+SALOME_MED::MESH_ptr MED_i::getMesh(SALOME_MED::FIELD_ptr fieldPtr)
+throw (SALOME::SALOME_Exception)
+{
+ if (_med==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
+ SALOME::INTERNAL_ERROR);
+ int ind=fieldPtr->getCorbaIndex();
+ SCRUTE(ind);
+
+ MESH * mesh;
+ SALOME_MED::FIELDINT_var fieldint =SALOME_MED::FIELDINT::_narrow(fieldPtr);
+ if (CORBA::is_nil(fieldint))
+ {
+ MESSAGE("Double");
+ SALOME_MED::FIELDDOUBLE_var fielddouble =
+ SALOME_MED::FIELDDOUBLE::_narrow(fieldPtr);
+ ASSERT(!CORBA::is_nil(fielddouble));
+ ASSERT(FIELDOF_i<double>::fieldMap.find(ind)
+ !=FIELDOF_i<double>::fieldMap.end());
+ ::FIELD<double> * fdouble = FIELDOF_i<double>::fieldMap[ind];
+ MESH * mesh=_med->getMesh(fdouble);
+ }
+ else
+ {
+ MESSAGE("Integer");
+ ASSERT(FIELDOF_i<int>::fieldMap.find(ind)!=FIELDOF_i<int>::fieldMap.end());
+ ::FIELD<int> * fint = FIELDOF_i<int>::fieldMap[ind];
+ MESH * mesh=_med->getMesh(fint);
+ }
+ MESH_i * meshi = new MESH_i(mesh);
+ SALOME_MED::MESH_ptr meshptr = meshi->POA_SALOME_MED::MESH::_this();
+ meshi->_remove_ref();
+ return (SALOME_MED::MESH::_duplicate(meshptr));
+
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for a specific field
+ */
+//=============================================================================
+SALOME_MED::FIELD_ptr MED_i::getField(const char* fieldName,
+ CORBA::Long pasTemps,
+ CORBA::Long numOrdre )
+throw (SALOME::SALOME_Exception)
+{
+ const char * LOC="MED_i::getField(const char*,CORBA::Long,CORBA::Long) " ;
+ BEGIN_OF(LOC) ;
+
+ DT_IT_ dtIt;
+
+ dtIt.dt= (int)pasTemps;
+ dtIt.it= (int)numOrdre;
+
+ map<string,MAP_IOR_DT_IT_>::const_iterator itFields = _fields.find(fieldName);
+
+ if ( itFields == _fields.end() )
+ THROW_SALOME_CORBA_EXCEPTION("Field not found !", SALOME::INTERNAL_ERROR) ;
+
+ const MAP_IOR_DT_IT_ & map_dtIt = (*itFields).second ;
+ MAP_IOR_DT_IT_::const_iterator itMap_dtIt = map_dtIt.find(dtIt);
+
+ if ( itMap_dtIt == map_dtIt.end() )
+ THROW_SALOME_CORBA_EXCEPTION("Iteration not found !", SALOME::INTERNAL_ERROR) ;
+
+ END_OF(LOC) ;
+ return (*itMap_dtIt).second;
+
+// if (_med==NULL)
+// THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
+// SALOME::INTERNAL_ERROR);
+// try
+// {
+// if (dynamic_cast<FIELD<int> * >
+// (_med->getField(fieldName,pasTemps,numOrdre)) !=NULL)
+// {
+// MESSAGE("Champ d entier");
+// ::FIELD<int>*f=dynamic_cast<FIELD<int> * >
+// (_med->getField(fieldName,pasTemps,numOrdre));
+// FIELDINT_i * medf = new FIELDINT_i(f);
+// POA_SALOME_MED::FIELDINT_tie<FIELDINT_i> * f1 =
+// new POA_SALOME_MED::FIELDINT_tie<FIELDINT_i>(medf,true);
+// SALOME_MED::FIELDINT_ptr f2 = f1->_this();
+// f1->_remove_ref();
+// return f2;
+
+// }
+// else
+// {
+// ASSERT (dynamic_cast<FIELD<double>* >(_med->getField(fieldName,pasTemps,numOrdre))!=NULL);
+// MESSAGE("Champ de double");
+// ::FIELD<double>*f=dynamic_cast<FIELD<double>* >
+// (_med->getField(fieldName,pasTemps,numOrdre));
+// FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
+// POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
+// new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
+// SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
+// f1->_remove_ref();
+// return f2;
+// }
+// }
+// catch(...)
+// {
+// MESSAGE("Exception en accedant a l objet C++ Med");
+// THROW_SALOME_CORBA_EXCEPTION("Unable to acces MED C++ Object"
+// ,SALOME::INTERNAL_ERROR);
+// }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for a specific field
+ */
+//=============================================================================
+CORBA::Long MED_i::addDriver(SALOME_MED::medDriverTypes driverType, const char* fileName)
+throw (SALOME::SALOME_Exception)
+{
+ if (_med==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ int driv=_med->addDriver(convertIdlDriverToMedDriver(driverType),
+ fileName);
+ return driv;
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to add a driver to the med object");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces MED C++ Object"
+ ,SALOME::INTERNAL_ERROR);
+ }
+
+}
+//=============================================================================
+/*!
+ * CORBA: relase the driver (mandatory)
+ */
+//=============================================================================
+void MED_i::rmDriver(CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_med==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ _med->rmDriver(i);
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to unlink the driver from the med object");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces MED C++ Object"
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: read med objects relations
+ */
+//=============================================================================
+void MED_i::readFileStruct(CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_med==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ _med->readFileStruct(i);
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to read the structure of this file ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces MED C++ Object"
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: write specifics objects f
+ */
+//=============================================================================
+void MED_i::writeFrom(CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_med==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ _med->writeFrom(i);
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to write this driver ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces MED C++ Object"
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: write objects
+ */
+//=============================================================================
+void MED_i::write(CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_med==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ _med->write(i);
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to write this file ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces MED C++ Object"
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Add Mesh in Med objects
+ */
+//=============================================================================
+void MED_i::addMesh(SALOME_MED::MESH_ptr ptrMesh)
+throw (SALOME::SALOME_Exception)
+{
+ if (_med==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ int ind=ptrMesh->getCorbaIndex();
+ SCRUTE(ind);
+ ASSERT(MESH_i::meshMap.find(ind) !=MESH_i::meshMap.end());
+ MESH * mesh= MESH_i::meshMap[ind];
+ _med->addMesh(mesh);
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to link this mesh to this med object");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces MED C++ Object"
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Add field in Med objects
+ */
+//=============================================================================
+void MED_i::addField(SALOME_MED::FIELD_ptr ptrField)
+throw (SALOME::SALOME_Exception)
+{
+ if (_med==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
+ SALOME::INTERNAL_ERROR);
+ int ind=ptrField->getCorbaIndex();
+ SCRUTE(ind);
+
+ SALOME_MED::FIELDINT_var fieldint =SALOME_MED::FIELDINT::_narrow(ptrField);
+ if (CORBA::is_nil(fieldint))
+ {
+ MESSAGE("Double");
+ SALOME_MED::FIELDDOUBLE_var fielddouble =
+ SALOME_MED::FIELDDOUBLE::_narrow(ptrField);
+ ASSERT(!CORBA::is_nil(fielddouble));
+ ASSERT(FIELDOF_i<double>::fieldMap.find(ind)
+ !=FIELDOF_i<double>::fieldMap.end());
+ ::FIELD<double> * fdouble = FIELDOF_i<double>::fieldMap[ind];
+ // A modifier
+ //_med->addField(fdouble);
+ }
+ else
+ {
+ MESSAGE("Integer");
+ ASSERT(FIELDOF_i<int>::fieldMap.find(ind)!=FIELDOF_i<int>::fieldMap.end());
+ ::FIELD<int> * fint = FIELDOF_i<int>::fieldMap[ind];
+ //_med->addField(fint);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Add Med in Study
+ */
+//=============================================================================
+void MED_i::addInStudy(SALOMEDS::Study_ptr myStudy, SALOME_MED::MED_ptr myIor)
+throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
+{
+ BEGIN_OF("MED_Mesh_i::addInStudy");
+ if ( _medId != "" )
+ {
+ MESSAGE("Med already in Study");
+ THROW_SALOME_CORBA_EXCEPTION("Med already in Study", \
+ SALOME::BAD_PARAM);
+ };
+
+ SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
+ myBuilder->NewCommand();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var aIOR;
+
+ // Create SComponent labelled 'MED' if it doesn't already exit
+ SALOMEDS::SComponent_var medfather = myStudy->FindComponent("Med");
+ if ( CORBA::is_nil(medfather) )
+ {
+ THROW_SALOME_CORBA_EXCEPTION("Component Med not found",
+ SALOME::BAD_PARAM);
+ } ;
+
+ MESSAGE("Add a MED Object under Med");
+ SALOMEDS::SObject_var newObj = myBuilder->NewObject(medfather);
+
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
+ CORBA::ORB_var &orb = init(0,0);
+ string iorStr = orb->object_to_string(myIor);
+ anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
+ aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ aIOR->SetValue(iorStr.c_str());
+ anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue("Objet MED");
+ _medId = newObj->GetID();
+ myBuilder->CommitCommand();
+
+ END_OF("Med_i::addInStudy(SALOMEDS::Study_ptr myStudy)");
+}
+
+
+
+
--- /dev/null
+//=============================================================================
+// File : Med_i.hxx
+// Project : SALOME
+// Author : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Med_i.hxx
+//=============================================================================
+
+#ifndef _MED_MED_I_HXX_
+#define _MED_MED_I_HXX_
+
+#include <string>
+
+#include <SALOMEconfig.h>
+
+#include CORBA_SERVER_HEADER(MED)
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "MEDMEM_Med.hxx"
+
+typedef map<DT_IT_, SALOME_MED::FIELD_ptr, LT_DT_IT_ > MAP_IOR_DT_IT_;
+
+class MED_i: public POA_SALOME_MED::MED
+{
+
+private :
+
+protected:
+ // C++ object containing values
+ //::MED * const _med;
+ ::MED * _med;
+ string _medId;
+
+ map<string,SALOME_MED::MESH_ptr> _meshes; // We can't have two MESHes with the same name.
+
+ map<string,map<MED_FR::med_entite_maillage,SALOME_MED::SUPPORT_ptr> > _supports;
+
+ map<string,MAP_IOR_DT_IT_> _fields; // We can't have two FIELDs with the same name.
+
+public:
+ // Constructors and associated internal methods
+ MED_i();
+ // MED_i(::MED * const m);
+ // MED_i(MED_i & m);
+ ~MED_i();
+
+ void init(SALOMEDS::Study_ptr myStudy, driverTypes driverType, const string & fileName); // Analyse the file <fileName> by calling readFileStruct
+
+ void initWithFieldType(SALOMEDS::Study_ptr myStudy, driverTypes driverType, const string & fileName); // Same method as above but with storage of fields with their type
+
+ // IDL Methods
+ CORBA::Long getNumberOfMeshes() throw (SALOME::SALOME_Exception);
+ CORBA::Long getNumberOfFields() throw (SALOME::SALOME_Exception);
+ Engines::string_array * getMeshNames() throw (SALOME::SALOME_Exception);
+ Engines::string_array * getFieldNames() throw (SALOME::SALOME_Exception);
+ SALOME_MED::MESH_ptr getMeshByName(const char* meshName)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::MESH_ptr getMesh(SALOME_MED::FIELD_ptr fieldPtr)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::FIELD_ptr getField(const char* fieldName,
+ CORBA::Long pasTemps,
+ CORBA::Long numOrdre)
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long addDriver(SALOME_MED::medDriverTypes driverType,
+ const char* fileName)
+ throw (SALOME::SALOME_Exception);
+ void rmDriver(CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ void readFileStruct(CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ void writeFrom(CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ void write(CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ void addMesh(SALOME_MED::MESH_ptr ptrMesh)
+ throw (SALOME::SALOME_Exception);
+ void addField(SALOME_MED::FIELD_ptr ptrField)
+ throw (SALOME::SALOME_Exception);
+ void addInStudy(SALOMEDS::Study_ptr myStudy,
+ SALOME_MED::MED_ptr myIor)
+ throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection);
+};
+
+#endif /* _MED_MED_I_HXX_ */
--- /dev/null
+//=============================================================================
+// File : Mesh_i.cxx
+// Project : SALOME
+// Author : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Mesh_i.cxx
+//=============================================================================
+
+#include <vector>
+
+#include "utilities.h"
+#include "Utils_CorbaException.hxx"
+#include "Utils_ORB_INIT.hxx"
+#include "Utils_SINGLETON.hxx"
+
+#include "convert.hxx"
+#include "Mesh_i.hxx"
+#include "Support_i.hxx"
+#include "Family_i.hxx"
+#include "Group_i.hxx"
+#include "FieldDouble_i.hxx"
+
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Group.hxx"
+#include "MEDMEM_CellModel.hxx"
+
+// Initialisation des variables statiques
+map < int, ::MESH *> MESH_i::meshMap ;
+int MESH_i::meshIndex = 0 ;
+
+
+
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=============================================================================
+MESH_i::MESH_i(): _mesh(constructConstMesh()),
+ _corbaIndex(MESH_i::meshIndex++),
+ _meshId("")
+{
+ BEGIN_OF("Default Constructor MESH_i");
+ MESH_i::meshMap[_corbaIndex]=_mesh;
+ END_OF("Default Constructor MESH_i");
+}
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+MESH_i::~MESH_i()
+{
+}
+//=============================================================================
+/*!
+ * Constructor
+ */
+//=============================================================================
+MESH_i::MESH_i(::MESH * const m ) :_mesh(m),
+ _corbaIndex(MESH_i::meshIndex++),
+ _meshId("")
+{
+ BEGIN_OF("Constructor MESH_i(::MESH * const m )");
+ MESH_i::meshMap[_corbaIndex]=_mesh;
+
+ SCRUTE(_mesh);
+
+ END_OF("Constructor MESH_i(::MESH * const m )");
+}
+//=============================================================================
+/*!
+ * Constructor par recopie
+ */
+//=============================================================================
+//MESH_i::MESH_i(const MESH_i & m) :_mesh(m._mesh),
+MESH_i::MESH_i( MESH_i & m) :_mesh(m._mesh),
+ _corbaIndex(MESH_i::meshIndex++),
+ _meshId("")
+{
+ BEGIN_OF("Constructor MESH_i");
+ MESH_i::meshMap[_corbaIndex]=_mesh;
+ END_OF("Constructor MESH_i");
+}
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+::MESH * MESH_i::constructConstMesh() const
+{
+ ::MESH * const ptrMesh =new ::MESH();
+ return ptrMesh;
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Name
+ */
+//=============================================================================
+char * MESH_i::getName()
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+
+ try
+ {
+ return CORBA::string_dup(_mesh->getName().c_str());
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces the mesh name");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for corbaindex cuisine interne
+ */
+//=============================================================================
+CORBA::Long MESH_i::getCorbaIndex()
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ return _corbaIndex;
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Space Dimension
+ */
+//=============================================================================
+CORBA::Long MESH_i::getSpaceDimension()
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _mesh->getSpaceDimension();
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces the space dimension ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Mesh Dimension
+ */
+//=============================================================================
+CORBA::Long MESH_i::getMeshDimension()
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _mesh->getMeshDimension();
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces the mesh dimension ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Coordinates System
+ */
+//=============================================================================
+char * MESH_i::getCoordinateSystem()
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+
+ try
+ {
+ return CORBA::string_dup(_mesh->getCoordinatesSystem().c_str());
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces the type of CoordinatesSystem");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Coordinates
+ */
+//=============================================================================
+Engines::double_array * MESH_i::getCoordinates(SALOME_MED::medModeSwitch typeSwitch)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ Engines::double_array_var myseq = new Engines::double_array;
+ try
+ {
+ int spaceDimension=_mesh->getSpaceDimension();
+ int nbNodes=_mesh->getNumberOfNodes();
+ const double * coordinates =_mesh->getCoordinates(
+ convertIdlModeToMedMode(typeSwitch));
+
+ myseq->length(nbNodes*spaceDimension);
+ for (int i=0; i<nbNodes*spaceDimension; i++)
+ {
+ myseq[i]=coordinates[i];
+ };
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces the coordinates");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Coordinates Names
+ */
+//=============================================================================
+Engines::string_array * MESH_i::getCoordinatesNames()
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ Engines::string_array_var myseq = new Engines::string_array;
+ try
+ {
+ int spaceDimension=_mesh->getSpaceDimension();
+ string * coordinatesName =_mesh->getCoordinatesNames();
+ myseq->length(spaceDimension);
+ for (int i=0; i<spaceDimension; i++)
+ {
+ myseq[i]=CORBA::string_dup(coordinatesName[i].c_str());
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces the coordinates names");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Coordinates Units
+ */
+//=============================================================================
+Engines::string_array * MESH_i::getCoordinatesUnits()
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ Engines::string_array_var myseq = new Engines::string_array;
+ try
+ {
+ int spaceDimension=_mesh->getSpaceDimension();
+ string * coordinatesUnits =_mesh->getCoordinatesUnits();
+ myseq->length(spaceDimension);
+ for (int i=0; i<spaceDimension; i++)
+ {
+ myseq[i]=CORBA::string_dup(coordinatesUnits[i].c_str());
+ };
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces the coordinates units");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Number of Nodes
+ */
+//=============================================================================
+CORBA::Long MESH_i::getNumberOfNodes()
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _mesh->getNumberOfNodes();
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces number of nodes");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for number of Types
+ */
+//=============================================================================
+CORBA::Long MESH_i::getNumberOfTypes(SALOME_MED::medEntityMesh entity)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _mesh->getNumberOfTypes(convertIdlEntToMedEnt(entity));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces number of differents types");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+
+//=============================================================================
+/*!
+ * CORBA: Accessor for existing geometry element types
+ * Not implemented for MED_ALL_ENTITIES
+ */
+//=============================================================================
+SALOME_MED::medGeometryElement_array * MESH_i::getTypes (SALOME_MED::medEntityMesh entity)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ if (entity ==SALOME_MED::MED_ALL_ENTITIES)
+ THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ENTITIES",\
+ SALOME::BAD_PARAM);
+ SALOME_MED::medGeometryElement_array_var myseq =
+ new SALOME_MED::medGeometryElement_array;
+ try
+ {
+ int nbTypes=_mesh->getNumberOfTypes(convertIdlEntToMedEnt(entity));
+ medGeometryElement * elemts =_mesh->getTypes(
+ convertIdlEntToMedEnt(entity));
+ myseq->length(nbTypes);
+ for (int i=0; i<nbTypes; i++)
+ {
+ myseq[i]=convertMedEltToIdlElt(elemts[i]);
+ };
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces coordinates");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Returns number of elements of type medGeometryElement
+ * Not implemented for MED_ALL_ELEMENTS
+* implemented for MED_ALL_ENTITIES
+ */
+//=============================================================================
+CORBA::Long MESH_i::getNumberOfElements(SALOME_MED::medEntityMesh entity,
+ SALOME_MED::medGeometryElement geomElement)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ if (verifieParam(entity,geomElement)==false)
+ THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
+ SALOME::BAD_PARAM);
+
+ try
+ {
+ return _mesh->getNumberOfElements(convertIdlEntToMedEnt(entity),
+ convertIdlEltToMedElt(geomElement));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces number of elements");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for connectivities
+ */
+//=============================================================================
+Engines::long_array * MESH_i::getConnectivity(SALOME_MED::medModeSwitch typeSwitch,
+ SALOME_MED::medConnectivity mode,
+ SALOME_MED::medEntityMesh entity,
+ SALOME_MED::medGeometryElement geomElement)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ if (verifieParam(entity,geomElement)==false)
+ THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
+ SALOME::BAD_PARAM);
+ Engines::long_array_var myseq= new Engines::long_array;
+ try
+ {
+ int nbelements;
+ int elt1 = _mesh->getNumberOfElements(
+ convertIdlEntToMedEnt(entity),
+ convertIdlEltToMedElt(geomElement));
+SCRUTE(elt1);
+ if ( mode == SALOME_MED::MED_DESCENDING)
+ {
+MESSAGE("MED_DESCENDING");
+ int elt2 =(_mesh->getCellsTypes(MED_CELL))->getNumberOfConstituents(1);
+ //int elt2 =(_mesh->getTypes(convertIdlEltToMedElt(geomElement)))->getNumberOfConstituents(1);
+ nbelements= elt2 * elt1;
+SCRUTE(elt2);
+ }
+ else
+ {
+MESSAGE("MED_NODAL");
+ int * tab=_mesh->getConnectivityIndex(
+ convertIdlConnToMedConn(mode),
+ convertIdlEntToMedEnt(entity));
+ nbelements = tab[elt1 ] - 1 ;
+ }
+SCRUTE(entity);
+SCRUTE(geomElement);
+SCRUTE(nbelements);
+ myseq->length(nbelements);
+ int * numbers=_mesh->getConnectivity(convertIdlModeToMedMode(typeSwitch),
+ convertIdlConnToMedConn(mode),
+ convertIdlEntToMedEnt(entity),
+ convertIdlEltToMedElt(geomElement));
+ for (int i=0;i<nbelements;i++)
+ {
+ myseq[i]=numbers[i];
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces connectivities");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for connectivities
+ */
+//=============================================================================
+Engines::long_array* MESH_i::getConnectivityIndex(SALOME_MED::medConnectivity mode,
+ SALOME_MED::medEntityMesh entity)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ Engines::long_array_var myseq= new Engines::long_array;
+ try
+ {
+ int nbelements = _mesh->getNumberOfElements(
+ convertIdlEntToMedEnt(entity),
+ MED_ALL_ELEMENTS);
+ myseq->length(nbelements);
+ int * numbers=_mesh->getConnectivityIndex(convertIdlConnToMedConn(mode),
+ convertIdlEntToMedEnt(entity));
+ for (int i=0;i<nbelements;i++)
+ {
+ myseq[i]=numbers[i];
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces connectivities index");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: get global element number in connectivity array
+ * not implemented for MED_NODE and MED_ALL_ENTITIES,
+ * MED_NONE and MED_ALL_ELEMENTS.
+ */
+//=============================================================================
+CORBA::Long MESH_i::getElementNumber(SALOME_MED::medConnectivity mode,
+ SALOME_MED::medEntityMesh entity,
+ SALOME_MED::medGeometryElement type,
+ const Engines::long_array& connectivity)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", SALOME::INTERNAL_ERROR);
+ int numberOfValue = connectivity.length() ;
+ int * myConnectivity = new int[numberOfValue] ;
+ for (int i=0; i<numberOfValue; i++)
+ myConnectivity[i]=connectivity[i] ;
+
+ int result ;
+ try {
+ result = _mesh->getElementNumber(convertIdlConnToMedConn(mode),
+ convertIdlEntToMedEnt(entity),
+ convertIdlEltToMedElt(type),
+ myConnectivity) ;
+ }
+ catch (MEDEXCEPTION &ex) {
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+ return result ;
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Ascendant connectivities
+ * not implemented for MED_ALL_ENTITIES and MED_MAILLE
+ */
+//=============================================================================
+Engines::long_array* MESH_i::getReverseConnectivity(SALOME_MED::medConnectivity mode)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ Engines::long_array_var myseq= new Engines::long_array;
+ try
+ {
+ int nbelements;
+ if ( mode == SALOME_MED::MED_DESCENDING)
+ {
+ nbelements =(_mesh->getNumberOfNodes())+1;
+ }
+ else
+ {
+ nbelements = _mesh->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS);
+ }
+ SCRUTE(nbelements);
+ myseq->length(nbelements);
+ int * numbers=_mesh->getReverseConnectivity(convertIdlConnToMedConn(mode));
+ for (int i=0;i<nbelements;i++)
+ {
+ myseq[i]=numbers[i];
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces reverse connectivities");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for connectivities
+ */
+//=============================================================================
+Engines::long_array* MESH_i::getReverseConnectivityIndex(SALOME_MED::medConnectivity mode)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ Engines::long_array_var myseq= new Engines::long_array;
+ try
+ {
+ //int nbelements= ????
+ int nbelements;
+ if ( mode == SALOME_MED::MED_DESCENDING)
+ {
+ nbelements =_mesh->getNumberOfNodes();
+ }
+ else
+ {
+ int dim=_mesh->getMeshDimension();
+ if ( dim == 3)
+ nbelements = _mesh->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS);
+ else
+ if (dim == 2)
+ nbelements = _mesh->getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS);
+ else
+ THROW_SALOME_CORBA_EXCEPTION("Pb ", \
+ SALOME::INTERNAL_ERROR);
+ }
+
+ myseq->length(nbelements);
+ int * numbers=_mesh->getReverseConnectivityIndex(convertIdlConnToMedConn(mode));
+ for (int i=0;i<nbelements;i++)
+ {
+ myseq[i]=numbers[i];
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces reverse connectivities index");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Returns number of families within the mesh
+ */
+//=============================================================================
+CORBA::Long MESH_i::getNumberOfFamilies(SALOME_MED::medEntityMesh entity)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _mesh->getNumberOfFamilies(convertIdlEntToMedEnt(entity));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces number of families of the mesh");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Returns number of groups within the mesh
+ */
+//=============================================================================
+CORBA::Long MESH_i::getNumberOfGroups(SALOME_MED::medEntityMesh entity)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _mesh->getNumberOfGroups(convertIdlEntToMedEnt(entity));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces number of groups of the mesh");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Returns references for families within the mesh
+ */
+//=============================================================================
+SALOME_MED::Family_array * MESH_i::getFamilies(SALOME_MED::medEntityMesh entity)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array;
+ try
+ {
+ int nbfam= _mesh->getNumberOfFamilies(convertIdlEntToMedEnt(entity));
+ myseq->length(nbfam);
+ vector<FAMILY*> fam(nbfam);
+ fam = _mesh->getFamilies(convertIdlEntToMedEnt(entity));
+ for (int i=0;i<nbfam;i++)
+ {
+ FAMILY_i * f1=new FAMILY_i(fam[i]);
+ SALOME_MED::FAMILY_ptr f2 =
+ f1->POA_SALOME_MED::FAMILY::_this();
+ f1->_remove_ref();
+ myseq[i] = f2;
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces families of the mesh");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Returns references for family i within the mesh
+ */
+//=============================================================================
+SALOME_MED::FAMILY_ptr MESH_i::getFamily(SALOME_MED::medEntityMesh entity,
+ CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ FAMILY * fam = _mesh->getFamily(convertIdlEntToMedEnt(entity),i);
+ FAMILY_i * f1=new FAMILY_i(fam);
+ SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this();
+ f1->_remove_ref();
+ return (SALOME_MED::FAMILY::_duplicate(f2));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces specified family of the mesh");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Family C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+
+}
+//=============================================================================
+/*!
+ * CORBA: Returns references for groups within the mesh
+ */
+//=============================================================================
+SALOME_MED::Group_array * MESH_i::getGroups(SALOME_MED::medEntityMesh entity)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ SALOME_MED::Group_array_var myseq = new SALOME_MED::Group_array;
+ try
+ {
+ int nbgroups = _mesh->getNumberOfGroups(convertIdlEntToMedEnt(entity));
+ myseq->length(nbgroups);
+ vector<GROUP*> groups(nbgroups);
+ groups = _mesh->getGroups(convertIdlEntToMedEnt(entity));
+ for (int i=0;i<nbgroups;i++)
+ {
+ GROUP_i * f1=new GROUP_i(groups[i]);
+ SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this();
+ f1->_remove_ref();
+ myseq[i] = f2;
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces number of groups of the mesh");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Returns references for group i within the mesh
+ */
+//=============================================================================
+SALOME_MED::GROUP_ptr MESH_i::getGroup(SALOME_MED::medEntityMesh entity,
+ CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ GROUP * grou = _mesh->getGroup(convertIdlEntToMedEnt(entity),i);
+ GROUP_i * f1=new GROUP_i(grou);
+ SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this();
+ f1->_remove_ref();
+ return (SALOME_MED::GROUP::_duplicate(f2));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to acces specified group of the mesh");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA:
+ */
+//=============================================================================
+SALOME_MED::FIELD_ptr MESH_i::getVolume(SALOME_MED::SUPPORT_ptr mySupport)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ int sup = mySupport->getCorbaIndex();
+ ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
+ const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
+ ::FIELD<double>*f=_mesh->getVolume( myCppSupport);
+ FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(mySupport,f);
+ POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
+ new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
+ SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
+ f1->_remove_ref();
+ return (SALOME_MED::FIELD::_duplicate(f2));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to get the volume ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA:
+ */
+//=============================================================================
+SALOME_MED::FIELD_ptr MESH_i::getArea(SALOME_MED::SUPPORT_ptr mySupport)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ int sup = mySupport->getCorbaIndex();
+ ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
+ const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
+ ::FIELD<double>*f=_mesh->getArea( myCppSupport);
+ FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(mySupport,f);
+ POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
+ new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
+ SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
+ f1->_remove_ref();
+ return (SALOME_MED::FIELD::_duplicate(f2));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to get the area ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA:
+ */
+//=============================================================================
+SALOME_MED::FIELD_ptr MESH_i::getLength(SALOME_MED::SUPPORT_ptr mySupport)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ int sup = mySupport->getCorbaIndex();
+ ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
+ const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
+ ::FIELD<double>*f=_mesh->getLength( myCppSupport);
+ FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(mySupport,f);
+ POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
+ new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
+ SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
+ f1->_remove_ref();
+ return (SALOME_MED::FIELD::_duplicate(f2));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to get the length ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA:
+ */
+//=============================================================================
+SALOME_MED::FIELD_ptr MESH_i::getNormal(SALOME_MED::SUPPORT_ptr mySupport)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ int sup = mySupport->getCorbaIndex();
+ ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
+ const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
+ ::FIELD<double>*f=_mesh->getNormal( myCppSupport);
+ FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(mySupport,f);
+ POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
+ new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
+ SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
+ f1->_remove_ref();
+ return (SALOME_MED::FIELD::_duplicate(f2));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to get the normal ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA:
+ */
+//=============================================================================
+SALOME_MED::FIELD_ptr MESH_i::getBarycenter(SALOME_MED::SUPPORT_ptr mySupport)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ int sup = mySupport->getCorbaIndex();
+ ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
+ const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
+ ::FIELD<double>*f=_mesh->getBarycenter( myCppSupport);
+ FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(mySupport,f);
+ POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
+ new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
+ SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
+ f1->_remove_ref();
+ return (SALOME_MED::FIELD::_duplicate(f2));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to get the barycenter ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA:
+ */
+//=============================================================================
+SALOME_MED::FIELD_ptr MESH_i::getNeighbourhood(SALOME_MED::SUPPORT_ptr mySupport)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ MESSAGE("Not Implemented");
+}
+//=============================================================================
+/*!
+ * CORBA: add the Mesh in the StudyManager
+ */
+//=============================================================================
+void MESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::MESH_ptr myIor )
+throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
+{
+ BEGIN_OF("MED_Mesh_i::addInStudy");
+ if ( _meshId != "" )
+ {
+ MESSAGE("Mesh already in Study");
+ THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", \
+ SALOME::BAD_PARAM);
+ };
+
+ SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var aIOR;
+
+ // Find SComponent labelled 'MED'
+ SALOMEDS::SComponent_var medfather = myStudy->FindComponent("Med");
+ if ( CORBA::is_nil(medfather) )
+ THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
+
+ // Create SObject labelled 'MESH' if it doesn't already exit
+ SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
+ myBuilder->NewCommand();
+ if ( CORBA::is_nil(medmeshfather) )
+ {
+ MESSAGE("Add Object MEDMESH");
+ medmeshfather = myBuilder->NewObject(medfather);
+ //medmeshfather.Name = "MEDMESH" ;
+ anAttr = myBuilder->FindOrCreateAttribute(medmeshfather, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue("MEDMESH");
+
+ } ;
+
+ MESSAGE("Add a mesh Object under MED/MEDMESH");
+ SALOMEDS::SObject_var newObj = myBuilder->NewObject(medmeshfather);
+
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
+ CORBA::ORB_var &orb = init(0,0);
+ string iorStr = orb->object_to_string(myIor);
+ anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
+ aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ aIOR->SetValue(iorStr.c_str());
+ anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue(_mesh->getName().c_str());
+ _meshId = newObj->GetID();
+ myBuilder->CommitCommand();
+
+ END_OF("Mesh_i::addInStudy(SALOMEDS::Study_ptr myStudy)");
+}
+//=============================================================================
+/*!
+ * CORBA: add the Mesh in the StudyManager
+ */
+//=============================================================================
+void MESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::MESH_ptr myIor,const string & fileName )
+throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
+{
+ BEGIN_OF("MED_Mesh_i::addInStudy");
+ if ( _meshId != "" )
+ {
+ MESSAGE("Mesh already in Study");
+ THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", \
+ SALOME::BAD_PARAM);
+ };
+
+ SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var aIOR;
+ SALOMEDS::AttributeComment_var aComment;
+
+ // Find SComponent labelled 'Med'
+ SALOMEDS::SComponent_var medfather = myStudy->FindComponent("Med");
+ if ( CORBA::is_nil(medfather) )
+ THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
+
+ // Create SObject labelled 'MESH' if it doesn't already exit
+ SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
+ myBuilder->NewCommand();
+ if ( CORBA::is_nil(medmeshfather) )
+ {
+ MESSAGE("Add Object MEDMESH");
+ medmeshfather = myBuilder->NewObject(medfather);
+ //medmeshfather.Name = "MEDMESH" ;
+ anAttr = myBuilder->FindOrCreateAttribute(medmeshfather, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue("MEDMESH");
+
+ } ;
+
+ MESSAGE("Add a mesh Object under MED/MEDMESH");
+ SALOMEDS::SObject_var newObj = myBuilder->NewObject(medmeshfather);
+
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
+ CORBA::ORB_var &orb = init(0,0);
+ string iorStr = orb->object_to_string(myIor);
+ anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
+ aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ aIOR->SetValue(iorStr.c_str());
+ anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue(_mesh->getName().c_str());
+ anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeComment");
+ aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
+ aComment->SetValue(fileName.c_str());
+ _meshId = newObj->GetID();
+ myBuilder->CommitCommand();
+
+ END_OF("Mesh_i::addInStudy(SALOMEDS::Study_ptr myStudy)");
+}
+//=============================================================================
+
+//=============================================================================
+/*!
+ * CORBA: write mesh in a med file
+ */
+//=============================================================================
+void MESH_i::write(CORBA::Long i, const char* driverMeshName)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ _mesh->write(i,driverMeshName);
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to write the mesh ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: read mesh in a med file
+ */
+//=============================================================================
+void MESH_i::read(CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ _mesh->read(i);
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to read the mesh ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA : release driver
+ */
+//=============================================================================
+void MESH_i::rmDriver(CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ _mesh->rmDriver();
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to unlink the mesh from the driver ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA : attach driver
+ */
+//=============================================================================
+CORBA::Long MESH_i::addDriver(SALOME_MED::medDriverTypes driverType,
+ const char* fileName, const char* meshName)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ int drivernum=_mesh->addDriver(
+ convertIdlDriverToMedDriver(driverType),
+ fileName,
+ meshName);
+ return drivernum;
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to link the mesh to the driver ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+
--- /dev/null
+//=============================================================================
+// File : Mesh_i.hxx
+// Project : SALOME
+// Author : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Mesh_i.hxx
+//=============================================================================
+
+#ifndef _MED_MESH_I_HXX_
+#define _MED_MESH_I_HXX_
+
+#include <map>
+#include <string>
+
+#include <SALOMEconfig.h>
+//#include "SALOME_Component_i.hxx"
+#include CORBA_SERVER_HEADER(MED)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+//#include "MED.hh"
+
+class MESH;
+class MESH_i:
+ public POA_SALOME_MED::MESH,
+ public PortableServer::RefCountServantBase
+// public Engines_Component_i
+{
+public :
+ static map < int,::MESH *> meshMap;
+private :
+ static int meshIndex;
+
+private :
+
+protected:
+ // C++ object containing values
+ ::MESH * const _mesh;
+ const int _corbaIndex;
+ string _meshId;
+
+
+public:
+
+ // Constructors and associated internal methods
+ MESH_i();
+ MESH_i(::MESH * const m);
+ MESH_i(MESH_i & m);
+ ~MESH_i();
+
+ // IDL Methods
+ char * getName() throw (SALOME::SALOME_Exception);
+
+ CORBA::Long getSpaceDimension() throw (SALOME::SALOME_Exception);
+
+ CORBA::Long getMeshDimension() throw (SALOME::SALOME_Exception);
+
+ char * getCoordinateSystem()
+ throw (SALOME::SALOME_Exception);
+
+ Engines::double_array* getCoordinates(SALOME_MED::medModeSwitch typeSwitch)
+ throw (SALOME::SALOME_Exception);
+
+ Engines::string_array* getCoordinatesNames()
+ throw (SALOME::SALOME_Exception);
+
+ Engines::string_array* getCoordinatesUnits()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long getNumberOfNodes()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long getNumberOfTypes (SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+
+ SALOME_MED::medGeometryElement_array* getTypes(SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long getNumberOfElements (SALOME_MED::medEntityMesh entity,
+ SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception);
+
+ Engines::long_array* getConnectivity(SALOME_MED::medModeSwitch typeSwitch,
+ SALOME_MED::medConnectivity mode,
+ SALOME_MED::medEntityMesh entity,
+ SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception);
+
+ Engines::long_array* getConnectivityIndex(SALOME_MED::medConnectivity mode,
+ SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long getElementNumber(SALOME_MED::medConnectivity mode,
+ SALOME_MED::medEntityMesh entity,
+ SALOME_MED::medGeometryElement type,
+ const Engines::long_array& connectivity)
+ throw (SALOME::SALOME_Exception);
+
+ Engines::long_array* getReverseConnectivity(SALOME_MED::medConnectivity mode)
+ throw (SALOME::SALOME_Exception);
+
+ Engines::long_array* getReverseConnectivityIndex(SALOME_MED::medConnectivity mode)
+ throw (SALOME::SALOME_Exception);
+
+ // Family and Group
+ CORBA::Long getNumberOfFamilies (SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getNumberOfGroups (SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::Family_array* getFamilies (SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::FAMILY_ptr getFamily (SALOME_MED::medEntityMesh entity,
+ CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::Group_array* getGroups (SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::GROUP_ptr getGroup (SALOME_MED::medEntityMesh entity,
+ CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ //
+ SALOME_MED::FIELD_ptr getVolume (SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::FIELD_ptr getArea (SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::FIELD_ptr getLength (SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::FIELD_ptr getNormal (SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::FIELD_ptr getBarycenter (SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::FIELD_ptr getNeighbourhood (SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception);
+
+
+ // Others
+ void addInStudy (SALOMEDS::Study_ptr myStudy,
+ SALOME_MED::MESH_ptr myIor) throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection);
+ void addInStudy (SALOMEDS::Study_ptr myStudy,
+ SALOME_MED::MESH_ptr myIor,
+ const string & fileName) throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection);
+ CORBA::Long addDriver (SALOME_MED::medDriverTypes driverType,
+ const char* fileName, const char* meshName)
+ throw (SALOME::SALOME_Exception);
+ void rmDriver (CORBA::Long i) throw (SALOME::SALOME_Exception);
+ void read (CORBA::Long i) throw (SALOME::SALOME_Exception);
+ void write (CORBA::Long i, const char* driverMeshName)
+ throw (SALOME::SALOME_Exception);
+
+ // Cuisine interne
+ CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception);
+ ::MESH * constructConstMesh() const;
+};
+
+#endif /* _MED_MESH_I_HXX_ */
--- /dev/null
+Users Guide
+
+1. You can see file med_test2.cxx for an example of using library
+
+2. To get meshes and fields from an MED file, the simplest way is to create a MED object with argument string filename. It scan MED file to get all meshes and fields in it. After you could say to MED object to read a particular mesh or field and get it with appropriate method of MED object (see MED.hxx and med_test2.cxx)
+
+3. When you have a Mesh object (or Field object), you could get information in using get_... methods (see Mesh.hxx, Support.hxx, Field.hxx and med_test2.cxx)
+
+I work on documentation with doxygen tool.
+
+
+Patrick GOLDBRONN
+DEN/DM2S/SFME/LGLS
+patrick.goldbronn@cea.fr
+tel : 0169087355
--- /dev/null
+//=============================================================================
+// File : Support_i.cxx
+// Project : SALOME
+// Author : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Support_i.cxx
+//=============================================================================
+
+#include "utilities.h"
+#include "Utils_CorbaException.hxx"
+#include "Utils_ORB_INIT.hxx"
+#include "Utils_SINGLETON.hxx"
+
+#include CORBA_SERVER_HEADER(MED)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_Support.hxx"
+
+#include "Support_i.hxx"
+#include "Mesh_i.hxx"
+#include "convert.hxx"
+
+// Initialisation des variables statiques
+map < int, ::SUPPORT *> SUPPORT_i::supportMap ;
+int SUPPORT_i::supportIndex = 0 ;
+
+
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=============================================================================
+SUPPORT_i::SUPPORT_i() :_support((::SUPPORT *)NULL)
+{
+ BEGIN_OF("Default Constructor SUPPORT_i");
+ END_OF("Default Constructor SUPPORT_i");
+}
+
+//=============================================================================
+/*!
+ * Constructor
+ */
+//=============================================================================
+SUPPORT_i::SUPPORT_i(const ::SUPPORT * const s) :_support(s),
+ _corbaIndex(SUPPORT_i::supportIndex++)
+{
+ BEGIN_OF("Constructor SUPPORT_i");
+ SUPPORT_i::supportMap[_corbaIndex]=(::SUPPORT *)_support;
+ END_OF("Constructor SUPPORT_i");
+}
+//=============================================================================
+/*!
+ * Constructor
+ */
+//=============================================================================
+SUPPORT_i::SUPPORT_i(const SUPPORT_i &s) :_support(s._support),
+ _corbaIndex(SUPPORT_i::supportIndex++)
+{
+ BEGIN_OF("Constructor SUPPORT_i");
+ SUPPORT_i::supportMap[_corbaIndex]=(::SUPPORT *)_support;
+ END_OF("Constructor SUPPORT_i");
+}
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+
+SUPPORT_i::~SUPPORT_i()
+{
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Corba Index
+ */
+//=============================================================================
+
+CORBA::Long SUPPORT_i::getCorbaIndex()
+throw (SALOME::SALOME_Exception)
+{
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ return _corbaIndex;
+}
+
+//=============================================================================
+/*!
+ * CORBA: Accessor for Name
+ */
+//=============================================================================
+
+char * SUPPORT_i::getName()
+throw (SALOME::SALOME_Exception)
+{
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return CORBA::string_dup(_support->getName().c_str());
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to access the name of the support ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+
+}
+
+//=============================================================================
+/*!
+ * CORBA: Accessor for Description
+ */
+//=============================================================================
+
+char* SUPPORT_i::getDescription()
+throw (SALOME::SALOME_Exception)
+{
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return CORBA::string_dup(_support->getDescription().c_str());
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to access the description of the support ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+
+//=============================================================================
+/*!
+ * CORBA: Accessor for Mesh
+ */
+//=============================================================================
+
+SALOME_MED::MESH_ptr SUPPORT_i::getMesh()
+throw (SALOME::SALOME_Exception)
+{
+ BEGIN_OF("SALOME_MED::MESH_ptr SUPPORT_i::getMesh()");
+
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ MESH * mesh = _support->getMesh();
+
+ SCRUTE(mesh) ;
+
+ MESH_i * m1 = new MESH_i(mesh);
+ SALOME_MED::MESH_ptr m2 = m1->POA_SALOME_MED::MESH::_this();
+
+
+
+ MESSAGE("SALOME_MED::MESH_ptr SUPPORT_i::getMesh() checking des pointeurs CORBA");
+
+ SCRUTE(m1);
+ SCRUTE(m2);
+
+ m1->_remove_ref();
+
+ END_OF("SALOME_MED::MESH_ptr SUPPORT_i::getMesh()");
+
+ return (SALOME_MED::MESH::_duplicate(m2));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to access the assoicated mesh");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+
+//=============================================================================
+/*!
+ * CORBA: boolean indicating if support concerns all elements
+ */
+//=============================================================================
+
+CORBA::Boolean SUPPORT_i::isOnAllElements()
+throw (SALOME::SALOME_Exception)
+{
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _support->isOnAllElements();
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to access the type of the support");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+
+//=============================================================================
+/*!
+ * CORBA: Accessor for type of support's entity
+ */
+//=============================================================================
+
+SALOME_MED::medEntityMesh SUPPORT_i::getEntity()
+throw (SALOME::SALOME_Exception)
+{
+ BEGIN_OF("SALOME_MED::medEntityMesh SUPPORT_i::getEntity()");
+
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ END_OF("SALOME_MED::medEntityMesh SUPPORT_i::getEntity()");
+ return convertMedEntToIdlEnt(_support->getEntity());
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to access support s entity");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object", \
+ SALOME::INTERNAL_ERROR);
+ }
+}
+
+//=============================================================================
+/*!
+ * CORBA: Accessor for types of geometry elements
+ */
+//=============================================================================
+
+SALOME_MED::medGeometryElement_array * SUPPORT_i::getTypes()
+throw (SALOME::SALOME_Exception)
+{
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ SALOME_MED::medGeometryElement_array_var myseq = new SALOME_MED::medGeometryElement_array;
+ try
+ {
+ int mySeqLength=_support->getNumberOfTypes();
+ myseq->length(mySeqLength);
+ medGeometryElement * elemts = _support->getTypes();
+ for (int i=0;i<mySeqLength;i++)
+ {
+ myseq[i]=convertMedEltToIdlElt(elemts[i]);
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to access support different types");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object", \
+ SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+
+//=============================================================================
+/*!
+ * CORBA: Number of different types of geometry elements
+ * existing in the support
+ */
+//=============================================================================
+CORBA::Long SUPPORT_i::getNumberOfElements(SALOME_MED::medGeometryElement geomElement)
+throw (SALOME::SALOME_Exception)
+{
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _support->getNumberOfElements(convertIdlEltToMedElt(geomElement));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to access the number of support different types");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+
+}
+
+//=============================================================================
+/*!
+ * CORBA: get Nodes
+ */
+//=============================================================================
+
+Engines::long_array * SUPPORT_i::getNumber(SALOME_MED::medGeometryElement geomElement)
+throw (SALOME::SALOME_Exception)
+{
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ Engines::long_array_var myseq= new Engines::long_array;
+ try
+ {
+ int nbelements=_support->getNumberOfElements(convertIdlEltToMedElt(geomElement));
+ myseq->length(nbelements);
+SCRUTE(_support->getName());
+SCRUTE(nbelements);
+SCRUTE(convertIdlEltToMedElt(geomElement));
+ int * numbers=_support->getNumber(convertIdlEltToMedElt(geomElement));
+ for (int i=0;i<nbelements;i++)
+ {
+ myseq[i]=numbers[i];
+SCRUTE(numbers[i]);
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to access the support optionnal index");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+
+}
+//=============================================================================
+/*!
+ * CORBA: Global Nodes Index (optionnaly designed by the user)
+ * CORBA: ??????????????????????????????
+ */
+//=============================================================================
+
+Engines::long_array * SUPPORT_i::getNumberIndex()
+throw (SALOME::SALOME_Exception)
+{
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ Engines::long_array_var myseq= new Engines::long_array;
+ try
+ {
+ MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS");
+ int nbelements=_support->getNumberOfElements(::MED_ALL_ELEMENTS);
+ myseq->length(nbelements);
+ int * numbers=_support->getNumberIndex();
+ for (int i=0;i<nbelements;i++)
+ {
+ myseq[i]=numbers[i];
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to access the support index");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+
+}
+
+//=============================================================================
+/*!
+ * CORBA: Array containing indexes for elements included in the support
+ */
+//=============================================================================
+
+CORBA::Long SUPPORT_i::getNumberOfGaussPoints(SALOME_MED::medGeometryElement geomElement)
+throw (SALOME::SALOME_Exception)
+{
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _support->getNumberOfGaussPoint(convertIdlEltToMedElt(geomElement));
+ }
+ catch(...)
+ {
+ MESSAGE("Unable to access number of Gauss points");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+
+//=============================================================================
+/*!
+ * CORBA: add the Support in the StudyManager
+ */
+//=============================================================================
+void SUPPORT_i::addInStudy (SALOMEDS::Study_ptr myStudy, SALOME_MED::SUPPORT_ptr myIor)
+ throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
+{
+ BEGIN_OF("SUPPORT_i::addInStudy");
+
+ if ( _supportId != "" )
+ {
+ MESSAGE("Support already in Study");
+ THROW_SALOME_CORBA_EXCEPTION("Support already in Study", \
+ SALOME::BAD_PARAM);
+ };
+
+ SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var aIOR;
+
+ // Find SComponent labelled 'Med'
+ MESSAGE("Find SComponent labelled 'Med'");
+ SALOMEDS::SComponent_var medfather = myStudy->FindComponent("Med");
+ if ( CORBA::is_nil(medfather) )
+ THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
+
+ // Find SObject labelled 'MEDMESH'
+ MESSAGE("Find SObject labelled 'MEDMESH'");
+ cerr<<flush;
+ MESSAGE(flush);
+ if ( CORBA::is_nil(myStudy) )
+ THROW_SALOME_CORBA_EXCEPTION("Study deleted !!!",SALOME::INTERNAL_ERROR);
+ SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
+ MESSAGE("Find SObject labelled 'MEDMESH' 2");
+ cerr<<flush;
+ MESSAGE(flush);
+ if ( CORBA::is_nil(medmeshfather) ){
+ MESSAGE( "On a leve l exception" << flush);
+ THROW_SALOME_CORBA_EXCEPTION("SObject labelled 'MEDMESH' not Found",SALOME::INTERNAL_ERROR);
+ }
+ // Find SObject MESH (represent mesh in support)
+ MESSAGE( "Find SObject MESH (represent mesh in support)"<< flush);
+ cerr<<flush;
+ MESSAGE(flush);
+ string meshName = getMesh()->getName() ;
+ SALOMEDS::SObject_var medsupportfather = myStudy->FindObject(meshName.c_str()); // seulement sous Med : il peut y avoir le meme sous SMESH !!!
+ if ( CORBA::is_nil(medsupportfather) )
+ 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");
+ cerr<<flush;
+ MESSAGE(flush);
+ myBuilder->NewCommand();
+
+ SALOMEDS::SObject_var supportEntry = myStudy->FindObject(_support->getName().c_str()); // c'est pas bon, car il faut rechercher uniquement sous le bon MESH !!!
+ if ( CORBA::is_nil(supportEntry) ) {
+ // not already in study : we create it !
+ SALOMEDS::SObject_var newObj = myBuilder->NewObject(medsupportfather);
+
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
+ CORBA::ORB_var &orb = init(0,0);
+ string iorStr = orb->object_to_string(myIor);
+ anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
+ aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ aIOR->SetValue(iorStr.c_str());
+ anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue(_support->getName().c_str());
+ _supportId = newObj->GetID();
+ } else {
+ // already in study : put new AttributeIOR !
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
+ CORBA::ORB_var &orb = init(0,0);
+ string iorStr = orb->object_to_string(myIor);
+ anAttr = myBuilder->FindOrCreateAttribute(supportEntry, "AttributeIOR");
+ aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ aIOR->SetValue(iorStr.c_str());
+ }
+ myBuilder->CommitCommand();
+
+ END_OF("SUPPORT_i::addInStudy");
+}
--- /dev/null
+//=============================================================================
+// File : Support_i.hxx
+// Project : SALOME
+// Author : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Support_i.hxx
+//=============================================================================
+
+#ifndef _MED_SUPPORT_I_HXX_
+#define _MED_SUPPORT_I_HXX_
+
+#include <map>
+#include <string>
+
+#include <SALOMEconfig.h>
+
+#include CORBA_SERVER_HEADER(MED)
+
+class SUPPORT;
+class SALOME_MED::MESH;
+
+class SUPPORT_i:
+ public POA_SALOME_MED::SUPPORT,
+ public PortableServer::RefCountServantBase
+{
+public :
+ static map < int,::SUPPORT *> supportMap;
+private :
+ static int supportIndex;
+
+protected :
+
+ // C++ object containing values
+ const ::SUPPORT * const _support;
+ const int _corbaIndex ;
+ string _supportId ;
+
+public:
+
+ SUPPORT_i();
+ ~SUPPORT_i();
+
+ // Constructors and associated internal methods
+ SUPPORT_i(const ::SUPPORT * const s);
+ SUPPORT_i(const SUPPORT_i & s);
+
+ // IDL Methods
+ char * getName() throw (SALOME::SALOME_Exception);
+ char * getDescription() throw (SALOME::SALOME_Exception);
+ SALOME_MED::MESH_ptr getMesh() throw (SALOME::SALOME_Exception);
+ CORBA::Boolean isOnAllElements() throw (SALOME::SALOME_Exception);
+ SALOME_MED::medEntityMesh getEntity() throw (SALOME::SALOME_Exception);
+ CORBA::Long getNumberOfElements(SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception);
+ Engines::long_array* getNumber(SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception);
+ Engines::long_array* getNumberIndex()
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getNumberOfGaussPoints(SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::medGeometryElement_array* getTypes()
+ throw (SALOME::SALOME_Exception);
+
+ // Others
+ void addInStudy (SALOMEDS::Study_ptr myStudy,
+ SALOME_MED::SUPPORT_ptr myIor)
+ throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection);
+
+ // Cuisine interne
+ CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception);
+};
+
+#endif /* _MED_SUPPORT_I_HXX_ */
--- /dev/null
+//=============================================================================
+// File : convert.cxx
+// Created : mer fév 20 15:47:57 CET 2002
+// Author : EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/convert.cxx
+//=============================================================================
+
+#include "utilities.h"
+#include "Utils_CorbaException.hxx"
+
+#include "convert.hxx"
+
+
+SALOME_MED::medGeometryElement convertMedEltToIdlElt(medGeometryElement element)
+throw (SALOME::SALOME_Exception)
+{
+ switch (element)
+ {
+ case MED_NONE : return SALOME_MED::MED_NONE;
+ case MED_POINT1 : return SALOME_MED::MED_POINT1;
+ case MED_SEG2 : return SALOME_MED::MED_SEG2;
+ case MED_SEG3 : return SALOME_MED::MED_SEG3;
+ case MED_TRIA3 : return SALOME_MED::MED_TRIA3;
+ case MED_QUAD4 : return SALOME_MED::MED_QUAD4;
+ case MED_TRIA6 : return SALOME_MED::MED_TRIA6;
+ case MED_QUAD8 : return SALOME_MED::MED_QUAD8;
+ case MED_TETRA4 : return SALOME_MED::MED_TETRA4;
+ case MED_PYRA5 : return SALOME_MED::MED_PYRA5;
+ case MED_PENTA6 : return SALOME_MED::MED_PENTA6;
+ case MED_HEXA8 : return SALOME_MED::MED_HEXA8;
+ case MED_TETRA10 : return SALOME_MED::MED_TETRA10;
+ case MED_PYRA13 : return SALOME_MED::MED_PYRA13;
+ case MED_PENTA15 : return SALOME_MED::MED_PENTA15;
+ case MED_HEXA20 : return SALOME_MED::MED_HEXA20;
+ case MED_ALL_ELEMENTS : return SALOME_MED::MED_ALL_ELEMENTS;
+ default :
+ { MESSAGE("Unknown Geometry Element");
+ THROW_SALOME_CORBA_EXCEPTION("Unknown Geometry Element",
+ SALOME::INTERNAL_ERROR);
+ }
+ }
+}
+
+medGeometryElement convertIdlEltToMedElt(SALOME_MED::medGeometryElement element)
+throw (SALOME::SALOME_Exception)
+{
+ switch (element)
+ {
+ case SALOME_MED::MED_NONE : return MED_NONE;
+ case SALOME_MED::MED_POINT1 : return MED_POINT1;
+ case SALOME_MED::MED_SEG2 : return MED_SEG2;
+ case SALOME_MED::MED_SEG3 : return MED_SEG3;
+ case SALOME_MED::MED_TRIA3 : return MED_TRIA3;
+ case SALOME_MED::MED_QUAD4 : return MED_QUAD4;
+ case SALOME_MED::MED_TRIA6 : return MED_TRIA6;
+ case SALOME_MED::MED_QUAD8 : return MED_QUAD8;
+ case SALOME_MED::MED_TETRA4 : return MED_TETRA4;
+ case SALOME_MED::MED_PYRA5 : return MED_PYRA5;
+ case SALOME_MED::MED_PENTA6 : return MED_PENTA6;
+ case SALOME_MED::MED_HEXA8 : return MED_HEXA8;
+ case SALOME_MED::MED_TETRA10 : return MED_TETRA10;
+ case SALOME_MED::MED_PYRA13 : return MED_PYRA13;
+ case SALOME_MED::MED_PENTA15 : return MED_PENTA15;
+ case SALOME_MED::MED_HEXA20 : return MED_HEXA20;
+ case SALOME_MED::MED_ALL_ELEMENTS : return MED_ALL_ELEMENTS;
+ default :
+ { MESSAGE("unknown Geometry Element");
+ THROW_SALOME_CORBA_EXCEPTION("Unknown Geometry Element",
+ SALOME::INTERNAL_ERROR);
+ }
+ }
+}
+
+SALOME_MED::medEntityMesh convertMedEntToIdlEnt(medEntityMesh entity)
+throw (SALOME::SALOME_Exception)
+{
+ switch (entity)
+ {
+ case MED_CELL : return SALOME_MED::MED_CELL;
+ case MED_FACE : return SALOME_MED::MED_FACE;
+ case MED_EDGE : return SALOME_MED::MED_EDGE;
+ case MED_NODE : return SALOME_MED::MED_NODE;
+ case MED_ALL_ENTITIES : return SALOME_MED::MED_ALL_ENTITIES;
+ default :
+ { MESSAGE("Unknown entity element");
+ THROW_SALOME_CORBA_EXCEPTION("Unknown Entity Element",
+ SALOME::INTERNAL_ERROR);
+ }
+ }
+}
+
+medEntityMesh convertIdlEntToMedEnt(SALOME_MED::medEntityMesh entity)
+throw (SALOME::SALOME_Exception)
+{
+ switch (entity)
+ {
+ case SALOME_MED::MED_CELL : return MED_CELL;
+ case SALOME_MED::MED_FACE : return MED_FACE;
+ case SALOME_MED::MED_EDGE : return MED_EDGE;
+ case SALOME_MED::MED_NODE : return MED_NODE;
+ case SALOME_MED::MED_ALL_ENTITIES : return MED_ALL_ENTITIES;
+ default :
+ { MESSAGE("Unknown Entity Element");
+ THROW_SALOME_CORBA_EXCEPTION("Unknown Entity Element",
+ SALOME::INTERNAL_ERROR);
+ }
+ }
+}
+
+medModeSwitch convertIdlModeToMedMode(SALOME_MED::medModeSwitch mode)
+throw (SALOME::SALOME_Exception)
+{
+ switch (mode)
+ {
+ case SALOME_MED::MED_FULL_INTERLACE : return MED_FULL_INTERLACE;
+ case SALOME_MED::MED_NO_INTERLACE : return MED_NO_INTERLACE;
+ default :
+ { MESSAGE("Unknown interlace mode");
+ THROW_SALOME_CORBA_EXCEPTION("Unknown interlace mode",
+ SALOME::INTERNAL_ERROR);
+ }
+ }
+}
+
+SALOME_MED::medModeSwitch convertMedModeToIdlMode(medModeSwitch mode)
+throw (SALOME::SALOME_Exception)
+{
+ switch (mode)
+ {
+ case MED_FULL_INTERLACE : return SALOME_MED::MED_FULL_INTERLACE;
+ case MED_NO_INTERLACE : return SALOME_MED::MED_NO_INTERLACE;
+ default :
+ { MESSAGE("Unknown interlace mode");
+ THROW_SALOME_CORBA_EXCEPTION("Unknown interlace mode",
+ SALOME::INTERNAL_ERROR);
+ }
+ }
+}
+SALOME_MED::medConnectivity convertMedConnToIdlConn(medConnectivity connectivite)
+throw (SALOME::SALOME_Exception)
+{
+ switch (connectivite)
+ {
+ case MED_NODAL : return SALOME_MED::MED_NODAL;
+ case MED_DESCENDING : return SALOME_MED::MED_DESCENDING;
+ default :
+ { MESSAGE("Unknown connectivity type");
+ THROW_SALOME_CORBA_EXCEPTION("Unknown connectivity type",
+ SALOME::INTERNAL_ERROR);
+ }
+ }
+}
+medConnectivity convertIdlConnToMedConn(SALOME_MED::medConnectivity connectivite)
+throw (SALOME::SALOME_Exception)
+{
+ switch (connectivite)
+ {
+ case SALOME_MED::MED_NODAL : return MED_NODAL;
+ case SALOME_MED::MED_DESCENDING : return MED_DESCENDING;
+ default :
+ { MESSAGE("Unknown connectivity type");
+ THROW_SALOME_CORBA_EXCEPTION("Unknown connectivity type",
+ SALOME::INTERNAL_ERROR);
+ }
+ }
+}
+SALOME_MED::medDriverTypes convertMedDriverToIdlDriver(driverTypes driverType)
+throw (SALOME::SALOME_Exception)
+{
+ switch (driverType)
+ {
+ case MED_DRIVER : return SALOME_MED::MED_DRIVER;
+ case VTK_DRIVER : return SALOME_MED::VTK_DRIVER;
+ case NO_DRIVER : return SALOME_MED::NO_DRIVER;
+ default :
+ { MESSAGE("Unknown driver type");
+ THROW_SALOME_CORBA_EXCEPTION("Unknown driver type",
+ SALOME::INTERNAL_ERROR);
+ }
+ }
+}
+
+driverTypes convertIdlDriverToMedDriver(SALOME_MED::medDriverTypes driverType)
+throw (SALOME::SALOME_Exception)
+{
+ switch (driverType)
+ {
+ case SALOME_MED::MED_DRIVER : return MED_DRIVER;
+ case SALOME_MED::VTK_DRIVER : return VTK_DRIVER;
+ case SALOME_MED::NO_DRIVER : return NO_DRIVER;
+ default :
+ { MESSAGE("Unknown driver type");
+ THROW_SALOME_CORBA_EXCEPTION("Unknown driver type",
+ SALOME::INTERNAL_ERROR);
+ }
+ }
+}
+bool verifieParam (SALOME_MED::medEntityMesh entity,SALOME_MED::medGeometryElement geomElement)
+throw (SALOME::SALOME_Exception)
+{
+ SCRUTE(entity);
+ SCRUTE(geomElement);
+ bool coherent=false;
+ switch (entity)
+ {
+ case SALOME_MED::MED_FACE :
+ {
+ switch (geomElement)
+ {
+ case SALOME_MED::MED_TRIA3 : coherent=true;
+ case SALOME_MED::MED_QUAD4 : coherent=true;
+ case SALOME_MED::MED_TRIA6 : coherent=true;
+ case SALOME_MED::MED_QUAD8 : coherent=true;
+ }
+ break;
+ }
+ case SALOME_MED::MED_CELL :
+ {
+ switch (geomElement)
+ {
+ case SALOME_MED::MED_POINT1 : coherent=true;
+ case SALOME_MED::MED_SEG2 : coherent=true;
+ case SALOME_MED::MED_SEG3 : coherent=true;
+ case SALOME_MED::MED_TRIA3 : coherent=true;
+ case SALOME_MED::MED_TRIA6 : coherent=true;
+ case SALOME_MED::MED_QUAD4 : coherent=true;
+ case SALOME_MED::MED_QUAD8 : coherent=true;
+ case SALOME_MED::MED_TETRA4 : coherent=true;
+ case SALOME_MED::MED_TETRA10 : coherent=true;
+ case SALOME_MED::MED_HEXA8 : coherent=true;
+ case SALOME_MED::MED_HEXA20 : coherent=true;
+ case SALOME_MED::MED_PENTA6 : coherent=true;
+ case SALOME_MED::MED_PENTA15 : coherent=true;
+ case SALOME_MED::MED_PYRA5 : coherent=true;
+ case SALOME_MED::MED_PYRA13 : coherent=true;
+ }
+ break;
+ }
+ case SALOME_MED::MED_EDGE :
+ {
+ switch (geomElement)
+ {
+ case SALOME_MED::MED_SEG2 : coherent=true;
+ case SALOME_MED::MED_SEG3 : coherent=true;
+ }
+ break;
+ }
+ case SALOME_MED::MED_NODE :
+ {
+ switch (geomElement)
+ {
+ case SALOME_MED::MED_POINT1 : coherent=true;
+ }
+ break;
+ }
+ case SALOME_MED::MED_ALL_ENTITIES :
+ {
+ switch (geomElement)
+ {
+ case SALOME_MED::MED_NONE : coherent=true;
+ }
+ break;
+ }
+ default :
+ { MESSAGE("Unknown geometric entity");
+ THROW_SALOME_CORBA_EXCEPTION("Unknown geometric entity",
+ SALOME::INTERNAL_ERROR);
+ }
+ break;
+ }
+
+ switch (geomElement)
+ {
+ case SALOME_MED::MED_ALL_ELEMENTS : coherent=true;
+ }
+ return coherent;
+}
--- /dev/null
+//=============================================================================
+// File : convert.hxx
+// Created : mer fév 20 15:47:57 CET 2002
+// Author : EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/convert.hxx
+//=============================================================================
+# if ! defined ( __CONVERT_H__ )
+# define __CONVERT_H__
+
+#include <SALOMEconfig.h>
+
+#include CORBA_SERVER_HEADER(MED)
+
+#include "MEDMEM_define.hxx"
+
+using namespace MED_EN;
+
+#include "MEDMEM_GenDriver.hxx"
+
+SALOME_MED::medGeometryElement convertMedEltToIdlElt(medGeometryElement element)
+ throw (SALOME::SALOME_Exception);
+SALOME_MED::medEntityMesh convertMedEntToIdlEnt(medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+SALOME_MED::medModeSwitch convertMedModeToIdlMode(medModeSwitch mode)
+ throw (SALOME::SALOME_Exception);
+SALOME_MED::medDriverTypes convertMedDriverToIdlDriver(driverTypes driverType)
+ throw (SALOME::SALOME_Exception);
+SALOME_MED::medConnectivity convertMedConnToIdlConn(medConnectivity connectivite)
+ throw (SALOME::SALOME_Exception);
+
+medGeometryElement convertIdlEltToMedElt (SALOME_MED::medGeometryElement element)
+ throw (SALOME::SALOME_Exception);
+medEntityMesh convertIdlEntToMedEnt(SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+medModeSwitch convertIdlModeToMedMode(SALOME_MED::medModeSwitch mode)
+ throw (SALOME::SALOME_Exception);
+driverTypes convertIdlDriverToMedDriver(SALOME_MED::medDriverTypes driverType)
+ throw (SALOME::SALOME_Exception);
+medConnectivity convertIdlConnToMedConn(SALOME_MED::medConnectivity connectivite)
+ throw (SALOME::SALOME_Exception);
+
+
+bool verifieParam (SALOME_MED::medEntityMesh entity, SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception);
+
+# endif /* # if ! defined ( __CONVERT_H__ ) */