From: nri Date: Thu, 10 Jul 2003 15:19:40 +0000 (+0000) Subject: NRI : Merge from V1_2. X-Git-Tag: V1_2_1~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9f2d306824ee9f3a18d714740689ec02d6413b6b;p=modules%2Fmed.git NRI : Merge from V1_2. --- diff --git a/adm_local/unix/make_commence.in b/adm_local/unix/make_commence.in index 2435e1062..f6d5ea9cc 100644 --- a/adm_local/unix/make_commence.in +++ b/adm_local/unix/make_commence.in @@ -144,7 +144,7 @@ CORBA_INCLUDES = @CORBA_INCLUDES@ CORBA_LIBS = @CORBA_LIBS@ CORBA_CXXFLAGS = @CORBA_CXXFLAGS@ -IDLCXXFLAGS = @IDLCXXFLAGS@ -I$(top_srcdir)/idl -I$(top_builddir)/idl -I$(KERNEL_ROOT_DIR)/idl/salome +IDLCXXFLAGS = -bcxx @IDLCXXFLAGS@ -I$(top_srcdir)/idl -I$(top_builddir)/idl -I$(KERNEL_ROOT_DIR)/idl/salome IDLPYFLAGS = @IDLPYFLAGS@ IDL = @IDL@ diff --git a/src/MEDGUI/Makefile.in b/src/MEDGUI/Makefile.in index c7f88fd2a..447045ff2 100644 --- a/src/MEDGUI/Makefile.in +++ b/src/MEDGUI/Makefile.in @@ -1,13 +1,31 @@ -#============================================================================== -# File : Makefile.in -# Created : dim déc 9 18:35:11 CET 2001 -# Author : Paul RASCLE, EDF -# Project : SALOME -# Copyright : EDF 2001 +# MED MEDGUI : MED component GUI implemetation +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Paul RASCLE, EDF +# Module : MED # $Header$ -#============================================================================== -# source path top_srcdir=@top_srcdir@ top_builddir=../.. srcdir=@srcdir@ diff --git a/src/MEDGUI/MedGUI.cxx b/src/MEDGUI/MedGUI.cxx index f3e2a855e..09bdce969 100644 --- a/src/MEDGUI/MedGUI.cxx +++ b/src/MEDGUI/MedGUI.cxx @@ -1,10 +1,30 @@ -using namespace std; -//============================================================================= -// File : MedGUI.cxx -// Project : SALOME -// Copyright : EDF 2001 -//============================================================================= +// MED MEDGUI : MED component GUI implemetation +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MedGUI.cxx +// Module : MED +using namespace std; #include "MedGUI.h" // SALOME Includes diff --git a/src/MEDGUI/MedGUI.h b/src/MEDGUI/MedGUI.h index 428ce386c..a0be4e6c0 100644 --- a/src/MEDGUI/MedGUI.h +++ b/src/MEDGUI/MedGUI.h @@ -1,8 +1,11 @@ -//============================================================================= -// File : MEDGUI.h -// Project : SALOME -// Copyright : EDF 2001 -//============================================================================= +// MED MEDGUI : MED component GUI implemetation +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : MEDGUI.h +// Module : MED #ifndef _MEDGUI_H_ #define _MEDGUI_H_ diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.cxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.cxx index cca6f423e..fe011b004 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.cxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.cxx @@ -1,3 +1,29 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_SWIG_FieldDouble.cxx +// Module : MED + using namespace std; #include "MEDMEM_SWIG_FieldDouble.hxx" diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.hxx index 8f28a842f..c4e0a5d8d 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.hxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.hxx @@ -1,3 +1,29 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_SWIG_FieldDouble.hxx +// Module : MED + #ifndef MEDMEM_SWIG_FIELDDOUBLE_HXX_ #define MEDMEM_SWIG_FIELDDOUBLE_HXX_ diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.cxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.cxx index da52d1083..125948dbb 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.cxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.cxx @@ -1,3 +1,29 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_SWIG_FieldInt.cxx +// Module : MED + using namespace std; #include "MEDMEM_SWIG_FieldInt.hxx" diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.hxx index e84e53466..1393c9b78 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.hxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.hxx @@ -1,3 +1,29 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_SWIG_FieldInt.hxx +// Module : MED + #ifndef MEDMEM_SWIG_FIELDINT_HXX_ #define MEDMEM_SWIG_FIELDINT_HXX_ diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.cxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.cxx index 8b662aee8..69f1e777f 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.cxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.cxx @@ -1,3 +1,29 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_SWIG_MedFieldDoubleDriver.cxx +// Module : MED + using namespace std; #include "MEDMEM_SWIG_MedFieldDoubleDriver.hxx" diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.hxx index 65e5d6573..8238c94e1 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.hxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.hxx @@ -1,3 +1,29 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_SWIG_MedFieldDoubleDriver.hxx +// Module : MED + #ifndef MEDMEM_SWIG_MEDFIELDDOUBLEDRIVER_HXX_ #define MEDMEM_SWIG_MEDFIELDDOUBLEDRIVER_HXX_ diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.cxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.cxx index 87b25165d..8639d925f 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.cxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.cxx @@ -1,3 +1,29 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_SWIG_MedFieldIntDriver.cxx +// Module : MED + using namespace std; #include "MEDMEM_SWIG_MedFieldIntDriver.hxx" diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.hxx index bb43c893f..5ba830817 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.hxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.hxx @@ -1,3 +1,29 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MEDMEM_SWIG_MedFieldIntDriver.hxx +// Module : MED + #ifndef MEDMEM_SWIG_MEDFIELDINTDRIVER_HXX_ #define MEDMEM_SWIG_MEDFIELDINTDRIVER_HXX_ diff --git a/src/MEDMEM_SWIG/Makefile.in b/src/MEDMEM_SWIG/Makefile.in index 41136298a..8c5657104 100644 --- a/src/MEDMEM_SWIG/Makefile.in +++ b/src/MEDMEM_SWIG/Makefile.in @@ -1,10 +1,30 @@ -#============================================================================== -# File : Makefile.in -# Author : Nadir BOUHAMOU (CEA/DEN/DM2S/SFME/LGLS) -# CVS : $Header$ -#============================================================================== +# MED MEDMEM_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Nadir BOUHAMOU (CEA/DEN/DM2S/SFME/LGLS) +# Module : MED -# source path top_srcdir=@top_srcdir@ top_builddir=../.. srcdir=@srcdir@ @@ -29,10 +49,9 @@ LIB_SRC = MEDMEM_SWIG_FieldDouble.cxx \ MEDMEM_SWIG_MedFieldDoubleDriver.cxx \ MEDMEM_SWIG_MedFieldIntDriver.cxx - SWIG_DEF = libMEDMEM_Swig.i -EXPORT_PYSCRIPTS = libMEDMEM_Swig.py med_test1.py med_test2.py med_test3.py +EXPORT_PYSCRIPTS = libMEDMEM_Swig.py med_test1.py med_test2.py med_test3.py med_test_grid.py med_test_skin.py medMeshing_test.py ############################################################################# diff --git a/src/MEDMEM_SWIG/libMEDMEM_Swig.i b/src/MEDMEM_SWIG/libMEDMEM_Swig.i index 166f1992d..e35fe911e 100644 --- a/src/MEDMEM_SWIG/libMEDMEM_Swig.i +++ b/src/MEDMEM_SWIG/libMEDMEM_Swig.i @@ -1,8 +1,31 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : libMEDMEM_Swig.i +// Module : MED + %module libMEDMEM_Swig -%include "typemaps.i" -%include "my_typemap.i" - %{ #include "MEDMEM_CellModel.hxx" #include "MEDMEM_GenDriver.hxx" @@ -24,19 +47,54 @@ #include "MEDMEM_Unit.hxx" #include "MEDMEM_Field.hxx" #include "MEDMEM_MedMedDriver.hxx" +#include "MEDMEM_Grid.hxx" #include "MEDMEM_SWIG_FieldDouble.hxx" #include "MEDMEM_SWIG_FieldInt.hxx" #include "MEDMEM_SWIG_MedFieldDoubleDriver.hxx" #include "MEDMEM_SWIG_MedFieldIntDriver.hxx" +#include "MEDMEM_Meshing.hxx" %} +%include "typemaps.i" +%include "my_typemap.i" + +/* + managing C++ exception in the Python API +*/ + +%exception +{ + try + { + $action ; + } + catch(MEDEXCEPTION& exception) + { + PyErr_SetString(PyExc_RuntimeError,exception.what()); + return NULL; + } +} + +/* + managing the use of operator= of any class by renaming it assign() + because assignment can't be overloaded in python. + + In python, you would then use + + a.assign(b) # a = b +*/ + +%rename(assign) *::operator=; + /* - enum du MED++ que l'on utilise dans l'API Python + enum of the C++ MED used in the Python API */ +typedef enum {MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED} med_grid_type; + typedef enum {MED_FULL_INTERLACE, MED_NO_INTERLACE} medModeSwitch; -typedef enum {MED_LECT,MED_ECRI,MED_REMP} med_mode_acces; +typedef enum {MED_LECT, MED_ECRI, MED_REMP} med_mode_acces; typedef enum {MED_CELL, MED_FACE, MED_EDGE, MED_NODE, MED_ALL_ENTITIES} medEntityMesh; @@ -75,11 +133,96 @@ typedef struct { int dt; int it; } DT_IT_; class CELLMODEL { public: - medGeometryElement getType(); + CELLMODEL(); + + CELLMODEL(medGeometryElement t); + + CELLMODEL(const CELLMODEL &m); + + int getNumberOfVertexes(); int getNumberOfNodes(); - %addmethods { + int getDimension(); + + medGeometryElement getType(); + + int getNumberOfConstituents(int dim); + + int getNodeConstituent(int dim,int num,int nodes_index); + + medGeometryElement getConstituentType(int dim,int num); + + int getNumberOfConstituentsType(); + + + +/* int* getNodesConstituent(int dim,int num) const; */ + + + + + + + + + +/* medGeometryElement* getConstituentsType(int dim) const; */ + + + + + + + + + + + +/* set getAllConstituentsType() const; */ + + +/* map getNumberOfConstituentsForeachType() const; */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ~CELLMODEL(); + + %extend { + %newobject getName(); char * getName() { string tmp_str = self->getName(); @@ -87,14 +230,27 @@ class CELLMODEL strcpy(tmp,tmp_str.c_str()); return tmp; } + + %newobject __str__(); + const char* __str__() + { + ostrstream line; + line << "Python Printing CELLMODEL : " << *self << endl; + char * tmp = new char[strlen(line.str())+1]; + strcpy(tmp,line.str()); + return tmp; + } } }; class SUPPORT { public: - // SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL); - // ~SUPPORT(); + SUPPORT(); + + SUPPORT(const SUPPORT & m); + + ~SUPPORT(); void update ( void ); @@ -118,11 +274,11 @@ class SUPPORT void setGeometricType(medGeometryElement *GeometricType); - /* void setGeometricTypeNumber(int *GeometricTypeNumber); */ + void setNumberOfElements(int *NumberOfElements); - void setNumberOfEntities(int *NumberOfEntities); + void setTotalNumberOfElements(int TotalNumberOfElements); - void setTotalNumberOfEntities(int TotalNumberOfEntities); + void getBoundaryElements(); %addmethods { SUPPORT(MESH* Mesh, char * Name="", medEntityMesh Entity=MED_CELL) @@ -130,13 +286,23 @@ class SUPPORT return new SUPPORT(Mesh,string(Name),Entity); } + %newobject __str__(); + const char* __str__() + { + ostrstream line; + line << "Python Printing SUPPORT : " << *self << endl; + char * tmp = new char[strlen(line.str())+1]; + strcpy(tmp,line.str()); + return tmp; + } + void setpartial(char * Description, int NumberOfGeometricType, - int TotalNumberOfEntity, medGeometryElement *GeometricType, - int *NumberOfEntity, int *NumberValue) + int TotalNumberOfElements, medGeometryElement *GeometricType, + int *NumberOfElements, int *NumberValue) { self->setpartial(string(Description), NumberOfGeometricType, - TotalNumberOfEntity, GeometricType, - NumberOfEntity, NumberValue); + TotalNumberOfElements, GeometricType, + NumberOfElements, NumberValue); } void setName(char * Name) @@ -144,6 +310,7 @@ class SUPPORT self->setName(string(Name)); } + %newobject getName(); const char * getName() { string tmp_str = self->getName(); @@ -157,6 +324,7 @@ class SUPPORT self->setDescription(string(Description)); } + %newobject getDescription(); const char * getDescription() { string tmp_str = self->getDescription(); @@ -169,7 +337,7 @@ class SUPPORT { PyObject *py_list; - medGeometryElement * types = self->getTypes(); + const medGeometryElement * types = self->getTypes(); int size = self->getNumberOfTypes(); py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -183,30 +351,8 @@ class SUPPORT return NULL; } } - return Py_BuildValue("O", py_list); - } - - /* - PyObject * getGeometricTypeNumber() - { - PyObject *py_list; - - int * GeometricTypeNumber = self->getGeometricTypeNumber(); - int size = self->getNumberOfTypes(); - py_list = PyList_New(size); - for (int i=0; i < size; i++) - { - int err = PyList_SetItem(py_list, i, - Py_BuildValue("i", - GeometricTypeNumber[i])); - if(err) - { - char * message = "Error in SUPPORT::getGeometricTypeNumber"; - PyErr_SetString(PyExc_RuntimeError, message); - return NULL; - } - } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } */ @@ -214,7 +360,7 @@ class SUPPORT { PyObject *py_list; - int * number = self->getNumber(GeometricType); + const int * number = self->getNumber(GeometricType); int size = self->getNumberOfElements(GeometricType); py_list = PyList_New(size); @@ -229,14 +375,15 @@ class SUPPORT return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getNumberIndex() { PyObject *py_list; - int * numberindex = self->getNumberIndex(); + const int * numberindex = self->getNumberIndex(); int size = (self->getNumberOfElements(MED_ALL_ELEMENTS))+1; py_list = PyList_New(size); @@ -251,7 +398,8 @@ class SUPPORT return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } } }; @@ -259,36 +407,60 @@ class SUPPORT class FAMILY : public SUPPORT { public: - // ~FAMILY(); + FAMILY(); + + FAMILY(const FAMILY & m); + + ~FAMILY(); + + FAMILY & operator=(const FAMILY &fam); void setIdentifier(int Identifier); + void setNumberOfAttributes(int NumberOfAttribute); + void setAttributesIdentifiers(int * AttributeIdentifier); + void setAttributesValues(int * AttributeValue); + void setAttributesDescriptions(string * AttributeDescription); + void setNumberOfGroups(int NumberOfGroups); + void setGroupsNames(string * GroupName); int getIdentifier() const; + int getNumberOfAttributes() const; - /* int * getAttributesIdentifiers() const;*/ - /* int * getAttributesValues() const;*/ - /* string * getAttributesDescriptions() const;*/ + int getNumberOfGroups() const; - /* string * getGroupsNames() const;*/ %addmethods { FAMILY(MESH* Mesh, int Identifier, char * Name, int NumberOfAttribute, int *AttributeIdentifier, int *AttributeValue, char * AttributeDescription, int NumberOfGroup, - char * GroupName) + char * GroupName, int * MEDArrayNodeFamily, + int ** MEDArrayCellFamily, int ** MEDArrayFaceFamily, + int ** MEDArrayEdgeFamily) { return new FAMILY(Mesh,Identifier,string(Name),NumberOfAttribute, AttributeIdentifier,AttributeValue, string(AttributeDescription),NumberOfGroup, - string(GroupName)); + string(GroupName), MEDArrayNodeFamily, + MEDArrayCellFamily, MEDArrayFaceFamily, + MEDArrayEdgeFamily); } + %newobject __str__(); + const char* __str__() + { + ostrstream line; + line << "Python Printing Family : " << *self << endl; + char * tmp = new char[strlen(line.str())+1]; + strcpy(tmp,line.str()); + } + + %newobject getAttributeDescription(int ); const char * getAttributeDescription(int i) { string tmp_str = self->getAttributeDescription(i); @@ -297,6 +469,7 @@ class FAMILY : public SUPPORT return tmp; } + %newobject getGroupName(int ); const char * getGroupName(int i) { string tmp_str = self->getGroupName(i); @@ -309,7 +482,7 @@ class FAMILY : public SUPPORT { PyObject *py_list; - int * attributesids = self->getAttributesIdentifiers(); + const int * attributesids = self->getAttributesIdentifiers(); int size = self->getNumberOfAttributes(); py_list = PyList_New(size); @@ -324,14 +497,15 @@ class FAMILY : public SUPPORT return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getAttributesValues() { PyObject *py_list; - int * attributesvals = self->getAttributesValues(); + const int * attributesvals = self->getAttributesValues(); int size = self->getNumberOfAttributes(); py_list = PyList_New(size); @@ -346,7 +520,8 @@ class FAMILY : public SUPPORT return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } } }; @@ -355,7 +530,8 @@ class FIELD_ { public: FIELD_(const SUPPORT * Support, const int NumberOfComponents); - // ~FIELD_(); + + ~FIELD_(); void rmDriver(int index=0); @@ -377,7 +553,10 @@ public: void setNumberOfComponents(int NumberOfComponents); int getNumberOfComponents() const; - %addmethods { + void setNumberOfValues(int NumberOfValues); + int getNumberOfValues() const; + + %extend { int addDriver(driverTypes driverType, char * fileName="Default File Name.med", char * driverName="Default Field Name") @@ -391,6 +570,7 @@ public: self->setName(string(name)); } + %newobject getName(); const char * getName() { string tmp_str = self->getName(); @@ -404,14 +584,16 @@ public: self->setDescription(string(Description)); } - const char * getDescription() + %newobject getDescription(); + const char * getDescription() const { string tmp_str = self->getDescription(); char * tmp = new char[strlen(tmp_str.c_str())+1]; strcpy(tmp,tmp_str.c_str()); - return tmp; + return tmp; } + %newobject getComponentName(int ); const char * getComponentName(int i) { string tmp_str = self->getComponentName(i); @@ -425,6 +607,7 @@ public: self->setComponentName(i,string(ComponentName)); } + %newobject getComponentDescription(int ); const char * getComponentDescription(int i) { string tmp_str = self->getComponentDescription(i); @@ -438,12 +621,13 @@ public: self->setComponentDescription(i,string(ComponentDescription)); } + %newobject getMEDComponentUnit(int ); const char * getMEDComponentUnit(int i) { string tmp_str = self->getMEDComponentUnit(i); char * tmp = new char[strlen(tmp_str.c_str())+1]; strcpy(tmp,tmp_str.c_str()); - return tmp; + return tmp; } void setMEDComponentUnit(int i, char * MEDComponentUnit) @@ -456,7 +640,7 @@ public: class FIELDDOUBLE : public FIELD_ { public: - // ~FIELDDOUBLE(); + ~FIELDDOUBLE(); FIELDDOUBLE(const SUPPORT * Support, const int NumberOfComponents); @@ -468,7 +652,7 @@ public: SWIG with a version lesser than 1.3 */ - //FIELDDOUBLE(); + FIELDDOUBLE(); void read(int index=0); @@ -484,15 +668,13 @@ public: void deallocValue(); - %addmethods { - /* + %extend { FIELDDOUBLE (const SUPPORT * Support, driverTypes driverType, char * fileName, char * fieldName) { return new FIELDDOUBLE(Support, driverType, string(fileName), string(fieldName)); } - <*/ void write(int index=0, char * driverName="") { @@ -506,7 +688,7 @@ public: int size = (self->getNumberOfComponents())* ((self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS)); - double * value = self->getValue(Mode); + const double * value = self->getValue(Mode); py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -520,9 +702,11 @@ public: return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } + %newobject getValueI(medModeSwitch , int ); PyObject * getValueI(medModeSwitch Mode, int index) { PyObject *py_list; @@ -531,7 +715,7 @@ public: if ( Mode == MED_NO_INTERLACE ) size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS); - double * value = self->getValueI(Mode,index); + const double * value = self->getValueI(Mode,index); py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -545,7 +729,8 @@ public: return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } void allocValue2(int NumberOfComponents, int LengthValue) @@ -558,7 +743,7 @@ public: class FIELDINT : public FIELD_ { public: - // ~FIELDINT(); + ~FIELDINT(); FIELDINT(const SUPPORT * Support, const int NumberOfComponents); @@ -571,9 +756,7 @@ public: SWIG with a version lesser than 1.3 */ - /* FIELDINT(); - */ void read(int index=0); @@ -589,15 +772,13 @@ public: void deallocValue(); - %addmethods { - /* + %extend { FIELDINT(const SUPPORT * Support, driverTypes driverType, char * fileName, char * fieldName) { - return new FIELDDOUBLE(Support, driverType, string(fileName), - string(fieldName)); + return new FIELDINT(Support, driverType, string(fileName), + string(fieldName)); } - */ void write(int index=0, char * driverName="") { @@ -611,7 +792,7 @@ public: int size = (self->getNumberOfComponents())* ((self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS)); - int * value = self->getValue(Mode); + const int * value = self->getValue(Mode); py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -625,7 +806,8 @@ public: return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getValueI(medModeSwitch Mode, int index) @@ -636,7 +818,7 @@ public: if ( Mode == MED_NO_INTERLACE ) size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS); - int * value = self->getValueI(Mode,index); + const int * value = self->getValueI(Mode,index); py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -650,7 +832,8 @@ public: return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } void allocValue2(int NumberOfComponents, int LengthValue) @@ -664,7 +847,8 @@ class GROUP : public SUPPORT { public: GROUP(); - // ~GROUP(); + + ~GROUP(); void setNumberOfFamilies(int numberOfFamilies); void setFamilies(vector Family); @@ -685,7 +869,9 @@ public : SWIG with a version lesser than 1.3 */ - // MESH(); + MESH(); + + ~MESH(); void rmDriver(int index=0); @@ -697,6 +883,8 @@ public : int getNumberOfNodes(); + bool getIsAGrid(); + const double getCoordinate(int Number, int Axis); int getNumberOfTypes(medEntityMesh Entity); @@ -719,13 +907,23 @@ public : medGeometryElement getElementType(medEntityMesh Entity,int Number); - SUPPORT * getBoundaryElements(medEntityMesh Entity) ; + %extend { + %newobject getBoundaryElements(medEntityMesh ); + SUPPORT * getBoundaryElements(medEntityMesh Entity) + { + return self->getBoundaryElements(Entity); + } + + %newobject getSkin(const SUPPORT * ); + SUPPORT * getSkin(const SUPPORT * Support3D) + { + return self->getSkin(Support3D); + } - %addmethods { CELLMODEL getCellType(medEntityMesh Entity,int i) { return self->getCellsTypes(Entity)[i]; - }; + } MESH (driverTypes driverType, char * fileName, char * meshName) { @@ -750,6 +948,7 @@ public : self->setName(string(name)); } + %newobject getName(); const char * getName() { string tmp_str = self->getName(); @@ -758,6 +957,7 @@ public : return tmp; } + %newobject getCoordinatesSystem(); const char * getCoordinatesSystem() { string tmp_str = self->getCoordinatesSystem(); @@ -766,6 +966,7 @@ public : return tmp; } + %newobject getCoordinateName(int ); const char * getCoordinateName(int i) { string tmp_str = self->getCoordinatesNames()[i]; @@ -774,6 +975,7 @@ public : return tmp; } + %newobject getCoordinateUnit(int ); const char * getCoordinateUnit(int i) { string tmp_str = self->getCoordinatesUnits()[i]; @@ -785,7 +987,7 @@ public : PyObject * getCoordinatesNames() { PyObject *py_list; - string * array = self->getCoordinatesNames(); + const string * array = self->getCoordinatesNames(); int size = self->getSpaceDimension(); py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -799,13 +1001,14 @@ public : return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getCoordinatesUnits() { PyObject *py_list; - string * array = self->getCoordinatesUnits(); + const string * array = self->getCoordinatesUnits(); int size = self->getSpaceDimension(); py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -819,7 +1022,8 @@ public : return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getCoordinates(medModeSwitch Mode) @@ -839,14 +1043,15 @@ public : return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getTypes(medEntityMesh Entity) { PyObject *py_list; - medGeometryElement * types = self->getTypes(Entity); + const medGeometryElement * types = self->getTypes(Entity); int size = self->getNumberOfTypes(Entity); py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -860,7 +1065,8 @@ public : return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getConnectivity(medModeSwitch Mode, @@ -869,14 +1075,14 @@ public : medGeometryElement Type) { PyObject *py_list; - int * connectivity = self->getConnectivity(Mode,ConnectivityType, + const int * connectivity = self->getConnectivity(Mode,ConnectivityType, Entity,Type); int nbOfElm = self->getNumberOfElements(Entity,Type); int size; if (Type == MED_ALL_ELEMENTS) { - size = self->getConnectivityIndex(ConnectivityType,Entity)[nbOfElm]; + size = self->getConnectivityIndex(ConnectivityType,Entity)[nbOfElm]-1; } else { @@ -895,14 +1101,15 @@ public : return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity) { PyObject *py_list; - int * connectivity_index = + const int * connectivity_index = self->getConnectivityIndex(ConnectivityType,Entity); int size = (self->getNumberOfElements(Entity,MED_ALL_ELEMENTS))+1; @@ -919,13 +1126,14 @@ public : return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getReverseConnectivity(medConnectivity ConnectivityType) { PyObject *py_list; - int * reverseconnectivity = + const int * reverseconnectivity = self->getReverseConnectivity(ConnectivityType); int spaceDim = self->getSpaceDimension(); int nb; @@ -944,7 +1152,7 @@ public : MED_ALL_ELEMENTS)); } - int size = self->getReverseConnectivityIndex(ConnectivityType)[nb]; + int size = self->getReverseConnectivityIndex(ConnectivityType)[nb]-1; py_list = PyList_New(size); for (int i=0; i < size; i++) @@ -959,14 +1167,15 @@ public : return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } PyObject * getReverseConnectivityIndex(medConnectivity ConnectivityType) { PyObject *py_list; - int * reverseconnectivity_index = + const int * reverseconnectivity_index = self->getReverseConnectivityIndex(ConnectivityType); int size; @@ -998,35 +1207,176 @@ public : return NULL; } } - return Py_BuildValue("O", py_list); + PyObject * result = Py_BuildValue("O", py_list); + return result; } - FIELDDOUBLE * getVolume(const SUPPORT * Support) - { - return (FIELDDOUBLE *) self->getVolume(Support); - } + %newobject getVolume(const SUPPORT * ); + FIELDDOUBLE * getVolume(const SUPPORT * Support) + { + return (FIELDDOUBLE *) self->getVolume(Support); + } - FIELDDOUBLE * getArea(const SUPPORT * Support) - { - return (FIELDDOUBLE *) self->getArea(Support); - } + %newobject getArea(const SUPPORT * ); + FIELDDOUBLE * getArea(const SUPPORT * Support) + { + return (FIELDDOUBLE *) self->getArea(Support); + } - FIELDDOUBLE * getLength(const SUPPORT * Support) - { - return (FIELDDOUBLE *) self->getLength(Support); - } + %newobject getLength(const SUPPORT * ); + FIELDDOUBLE * getLength(const SUPPORT * Support) + { + return (FIELDDOUBLE *) self->getLength(Support); + } + + %newobject getNormal(const SUPPORT * ); + FIELDDOUBLE * getNormal(const SUPPORT * Support) + { + return (FIELDDOUBLE *) self->getNormal(Support); + } + + %newobject getBarycenter(const SUPPORT * ); + FIELDDOUBLE * getBarycenter(const SUPPORT * Support) + { + return (FIELDDOUBLE *) self->getBarycenter(Support); + } + } +} ; + +class MESHING: public MESH +{ +public : + MESHING(); + ~MESHING(); + + void setSpaceDimension (const int SpaceDimension) ; + + void setNumberOfNodes (const int NumberOfNodes) ; + + void setNumberOfTypes (const int NumberOfTypes, + const medEntityMesh Entity) ; - FIELDDOUBLE * getNormal(const SUPPORT * Support) + void setTypes (const medGeometryElement * Types, + const medEntityMesh Entity) ; + + void setNumberOfElements (const int * NumberOfElements, + const medEntityMesh Entity) ; + + void setConnectivity (const int * Connectivity, + const medEntityMesh Entity, + const medGeometryElement Type) ; + + void setConnectivities (const int * ConnectivityIndex, + const int * ConnectivityValue, + const medConnectivity ConnectivityType, + const medEntityMesh Entity) ; + + void addGroup (const GROUP & Group) ; + + %extend { + void setCoordinates(const int SpaceDimension, const int NumberOfNodes, + const double * Coordinates, const char * System, + const medModeSwitch Mode) + { + self->setCoordinates(SpaceDimension, NumberOfNodes, Coordinates, + string(System), Mode); + } + + void setCoordinatesSystem(const char * System) + { + self->setCoordinatesSystem(string(System)); + } + + void setCoordinateName (const char * name, const int i) + { + self->setCoordinateName(string(name), i); + } + + void setCoordinateUnit (const char* unit, const int i) { - return (FIELDDOUBLE *) self->getNormal(Support); + self->setCoordinateUnit (string(unit), i) ; } + } +}; + +class GRID : public MESH +{ + public: + GRID(); + + GRID(const GRID &m); + + ~GRID(); + + int getNodeNumber(const int i, const int j=0, const int k=0); + + int getCellNumber(const int i, const int j=0, const int k=0) ; + + int getEdgeNumber(const int Axis, const int i, const int j=0, const int k=0); + + int getFaceNumber(const int Axis, const int i, const int j=0, const int k=0); + + med_grid_type getGridType(); + + int getArrayLength( const int Axis ); + + const double getArrayValue (const int Axis, const int i); + + void setGridType(med_grid_type gridType); + + %extend { + GRID(driverTypes driverType, const char * fileName="", const char * meshName="") + { + return new GRID(driverType, string(fileName), string(meshName)); + } - FIELDDOUBLE * getBarycenter(const SUPPORT * Support) + PyObject * getEntityPosition(const medEntityMesh Entity, const int Number) { - return (FIELDDOUBLE *) self->getBarycenter(Support); + int ijk[3], Axis; + int i=0, size = self->getSpaceDimension(); + int j=0; + switch (Entity) { + case MED_CELL: + self->getCellPosition(Number, ijk[0], ijk[1], ijk[2]); + break; + case MED_NODE: + self->getNodePosition(Number, ijk[0], ijk[1], ijk[2]); + break; + case MED_FACE: + self->getFacePosition(Number, Axis, ijk[0], ijk[1], ijk[2]); + size++; + i++; + break; + case MED_EDGE: + self->getEdgePosition(Number, Axis, ijk[0], ijk[1], ijk[2]); + size++; + i++; + break; + default: + char * message = "Error in GRID::getEntityPosition: wrong Entity"; + PyErr_SetString(PyExc_RuntimeError, message); + return NULL; + } + PyObject *py_list = PyList_New( size ); + for (; i < size; ++i) + { + int err = PyList_SetItem(py_list, i, + Py_BuildValue("i", ijk[j++])); + if(err) + { + char * message = "Error in GRID::getNodePosition"; + PyErr_SetString(PyExc_RuntimeError, message); + return NULL; + } + } + if (Entity == MED_FACE || Entity == MED_EDGE) + PyList_SetItem(py_list, 0, Py_BuildValue("i", Axis)); + + PyObject * result = Py_BuildValue("O", py_list); + return result; } } -} ; +}; class MED { @@ -1041,11 +1391,11 @@ class MED int getNumberOfFields ( void ) const; - void updateSupport ( void ) ; + void updateSupport () ; void write (int index=0); - %addmethods { + %extend { /* WARNING: other constructor of MED object. @@ -1053,18 +1403,19 @@ class MED the others commented out when using SWIG with a version lesser than 1.3 */ - /* + MED(driverTypes driverType, char * fileName) { return new MED(driverType,string(fileName)); } - */ + int addDriver(driverTypes driverType, char * fileName="Default File Name.med") { return self->addDriver(driverType,string(fileName)); } + %newobject getMeshName(int ); const char * getMeshName(int i) { deque list_string = self->getMeshNames(); @@ -1073,6 +1424,7 @@ class MED return tmp; } + %newobject getFieldName(int ); const char * getFieldName(int i) { deque list_string = self->getFieldNames(); @@ -1109,29 +1461,10 @@ class MED }; /* - APPI du driver MED_MED + API de MED_MED_[RDONLY,WRONLY,RDWR]_DRIVER */ -class MED_MED_DRIVER -{ - public : - void open(); - void close(); - - virtual void write ( void ) const ; - virtual void writeFrom ( void ) const ; - virtual void read ( void ) ; - virtual void readFileStruct ( void ) ; - - %addmethods { - MED_MED_DRIVER(char * fileName, MED * ptrMed) - { - return new MED_MED_DRIVER(string(fileName), ptrMed); - } - } -}; - -class MED_MED_RDONLY_DRIVER : public virtual MED_MED_DRIVER +class MED_MED_RDONLY_DRIVER { public : void open(); @@ -1140,7 +1473,9 @@ class MED_MED_RDONLY_DRIVER : public virtual MED_MED_DRIVER void read ( void ) ; void readFileStruct ( void ) ; - %addmethods { + virtual ~MED_MED_RDONLY_DRIVER(); + + %extend { MED_MED_RDONLY_DRIVER(char * fileName, MED * ptrMed) { return new MED_MED_RDONLY_DRIVER(string(fileName), ptrMed); @@ -1148,7 +1483,7 @@ class MED_MED_RDONLY_DRIVER : public virtual MED_MED_DRIVER } }; -class MED_MED_WRONLY_DRIVER : public virtual MED_MED_DRIVER +class MED_MED_WRONLY_DRIVER { public : void open(); @@ -1157,7 +1492,9 @@ class MED_MED_WRONLY_DRIVER : public virtual MED_MED_DRIVER void write ( void ) const ; void writeFrom ( void ) const ; - %addmethods { + virtual ~MED_MED_WRONLY_DRIVER(); + + %extend { MED_MED_WRONLY_DRIVER(char * fileName, MED * ptrMed) { return new MED_MED_WRONLY_DRIVER(string(fileName), ptrMed); @@ -1166,8 +1503,7 @@ class MED_MED_WRONLY_DRIVER : public virtual MED_MED_DRIVER }; class MED_MED_RDWR_DRIVER : public virtual MED_MED_RDONLY_DRIVER, - public virtual MED_MED_WRONLY_DRIVER, - public virtual MED_MED_DRIVER + public virtual MED_MED_WRONLY_DRIVER { public : void open(); @@ -1178,7 +1514,9 @@ class MED_MED_RDWR_DRIVER : public virtual MED_MED_RDONLY_DRIVER, void read ( void ) ; void readFileStruct ( void ) ; - %addmethods { + ~MED_MED_RDWR_DRIVER(); + + %extend { MED_MED_RDWR_DRIVER(char * fileName, MED * ptrMed) { return new MED_MED_RDWR_DRIVER(string(fileName), ptrMed); @@ -1187,27 +1525,27 @@ class MED_MED_RDWR_DRIVER : public virtual MED_MED_RDONLY_DRIVER, }; /* - API du driver MED_MESH + API de MED_MESH_[RDONLY,WRONLY,RDWR]_DRIVER */ -/* -class MED_MESH_DRIVER +class MED_MESH_RDONLY_DRIVER { -public : + public : + + ~MED_MESH_RDONLY_DRIVER(); void open(); void close(); - virtual void write( void ) const = 0 ; + void write( void ) ; - virtual void read ( void ) = 0 ; + void read ( void ) ; - %addmethods { - MED_MESH_DRIVER(char * fileName, MESH * ptrMesh, - med_mode_acces accessMode) + %extend { + MED_MESH_RDONLY_DRIVER(char * fileName, MESH * ptrMesh) { - return new MED_MESH_DRIVER(string(fileName), ptrMesh, accessMode); + return new MED_MESH_RDONLY_DRIVER(string(fileName), ptrMesh); } void setMeshName(char * meshName) @@ -1215,6 +1553,7 @@ public : self->setMeshName(string(meshName)); } + %newobject getMeshName(); char * getMeshName() { string tmp_str = self->getMeshName(); @@ -1224,36 +1563,187 @@ public : } } }; -*/ -class MED_MESH_RDONLY_DRIVER : public virtual MED_MESH_DRIVER +class MED_MESH_WRONLY_DRIVER +{ + public : + ~MED_MESH_WRONLY_DRIVER(); + + void write( void ) const ; + + void read ( void ) ; + + void open(); + + void close(); + + %extend { + MED_MESH_WRONLY_DRIVER(char * fileName, MESH * ptrMesh) + { + return new MED_MESH_WRONLY_DRIVER(string(fileName), ptrMesh); + } + + void setMeshName(char * meshName) + { + self->setMeshName(string(meshName)); + } + + %newobject getMeshName(); + char * getMeshName() + { + string tmp_str = self->getMeshName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; + } + } +}; + +class MED_MESH_RDWR_DRIVER : public virtual MED_MESH_RDONLY_DRIVER, + public virtual MED_MESH_WRONLY_DRIVER { public : - - // MED_MESH_RDONLY_DRIVER(); - // MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh); + ~MED_MESH_RDWR_DRIVER(); - ~MED_MESH_RDONLY_DRIVER(); + void write(void) const ; + + void read (void) ; + + void open(); + + void close(); + + %extend { + MED_MESH_RDWR_DRIVER(char * fileName, MESH * ptrMesh) + { + return new MED_MESH_RDWR_DRIVER(string(fileName), ptrMesh); + } + + void setMeshName(char * meshName) + { + self->setMeshName(string(meshName)); + } + + %newobject getMeshName(); + char * getMeshName() + { + string tmp_str = self->getMeshName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; + } + } +}; - int getCOORDINATE(); +/* + API de MED_FIELDDOUBLE_[RDONLY,WRONLY,RDWR]_DRIVER +*/ - int getCONNECTIVITY(); +class MED_FIELDDOUBLE_RDONLY_DRIVER +{ +public: - int getFAMILY(); + ~MED_FIELDDOUBLE_RDONLY_DRIVER(); void open(); void close(); - void write( void ) ; + void write( void ) const ; void read ( void ) ; - %addmethods { - MED_MESH_RDONLY_DRIVER(char * fileName, MESH * ptrMesh) + %extend { + MED_FIELDDOUBLE_RDONLY_DRIVER(char * fileName, FIELDDOUBLE * ptrField) { - return new MED_MESH_RDONLY_DRIVER(string(fileName), ptrMesh); + return new MED_FIELDDOUBLE_RDONLY_DRIVER(string(fileName), ptrField); + } + + void setFieldName(char * fieldName) + { + self->setFieldName(string(fieldName)); + } + + %newobject getFieldName(); + char * getFieldName() + { + string tmp_str = self->getFieldName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; + } + } +}; + +class MED_FIELDDOUBLE_WRONLY_DRIVER +{ +public: + + ~MED_FIELDDOUBLE_WRONLY_DRIVER(); + + void open(); + + void close(); + + void write( void ) const ; + + void read ( void ) ; + + %extend { + MED_FIELDDOUBLE_WRONLY_DRIVER(char * fileName, FIELDDOUBLE * ptrField) + { + return new MED_FIELDDOUBLE_WRONLY_DRIVER(string(fileName), ptrField); + } + + void setFieldName(char * fieldName) + { + self->setFieldName(string(fieldName)); + } + + %newobject getFieldName(); + char * getFieldName() + { + string tmp_str = self->getFieldName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; + } + } +}; + +class MED_FIELDDOUBLE_RDWR_DRIVER : public virtual MED_FIELDDOUBLE_RDONLY_DRIVER, public virtual MED_FIELDDOUBLE_WRONLY_DRIVER +{ +public: + + ~MED_FIELDDOUBLE_RDWR_DRIVER(); + + void open(); + + void close(); + + void write( void ) const ; + + void read ( void ) ; + + %extend { + MED_FIELDDOUBLE_RDWR_DRIVER(char * fileName, FIELDDOUBLE * ptrField) + { + return new MED_FIELDDOUBLE_RDWR_DRIVER(string(fileName), ptrField); + } + + void setFieldName(char * fieldName) + { + self->setFieldName(string(fieldName)); + } + + %newobject getFieldName(); + char * getFieldName() + { + string tmp_str = self->getFieldName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; } void setMeshName(char * meshName) @@ -1271,36 +1761,78 @@ class MED_MESH_RDONLY_DRIVER : public virtual MED_MESH_DRIVER } }; -class MED_MESH_WRONLY_DRIVER : public virtual MED_MESH_DRIVER +/* + API de MED_FIELDINT_[RDONLY,WRONLY,RDWR]_DRIVER +*/ + +class MED_FIELDINT_RDONLY_DRIVER { - public : - - // MED_MESH_WRONLY_DRIVER():MED_MESH_DRIVER() {} - - // MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh); +public: - ~MED_MESH_WRONLY_DRIVER(); + ~MED_FIELDINT_RDONLY_DRIVER(); + + void open(); + + void close(); void write( void ) const ; void read ( void ) ; + %extend { + MED_FIELDINT_RDONLY_DRIVER(char * fileName, FIELDINT * ptrField) + { + return new MED_FIELDINT_RDONLY_DRIVER(string(fileName), ptrField); + } + + void setFieldName(char * fieldName) + { + self->setFieldName(string(fieldName)); + } + + %newobject getFieldName(); + char * getFieldName() + { + string tmp_str = self->getFieldName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; + } + } +}; + +class MED_FIELDINT_WRONLY_DRIVER +{ +public: + + ~MED_FIELDINT_WRONLY_DRIVER(); + void open(); void close(); - int writeCoordinates () const; + void write( void ) const ; - int writeConnectivities (medEntityMesh entity) const; + void read ( void ) ; - int writeFamilyNumbers () const; + %extend { + MED_FIELDINT_WRONLY_DRIVER(char * fileName, FIELDINT * ptrField) + { + return new MED_FIELDINT_WRONLY_DRIVER(string(fileName), ptrField); + } - int writeFamilies (vector & families) const; + void setFieldName(char * fieldName) + { + self->setFieldName(string(fieldName)); + } - %addmethods { - MED_MESH_WRONLY_DRIVER(char * fileName, MESH * ptrMesh) + %newobject getFieldName(); + char * getFieldName() { - return new MED_MESH_WRONLY_DRIVER(string(fileName), ptrMesh); + string tmp_str = self->getFieldName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; } void setMeshName(char * meshName) @@ -1318,29 +1850,38 @@ class MED_MESH_WRONLY_DRIVER : public virtual MED_MESH_DRIVER } }; -class MED_MESH_RDWR_DRIVER : public virtual MED_MESH_RDONLY_DRIVER, - public virtual MED_MESH_WRONLY_DRIVER +class MED_FIELDINT_RDWR_DRIVER : public virtual MED_FIELDINT_RDONLY_DRIVER, public virtual MED_FIELDINT_WRONLY_DRIVER { - public : +public: - // MED_MESH_RDWR_DRIVER(); + ~MED_FIELDINT_RDWR_DRIVER(); - // MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh); + void open(); - ~MED_MESH_RDWR_DRIVER(); - - void write(void) const ; + void close(); - void read (void) ; + void write( void ) const ; - void open(); + void read ( void ) ; - void close(); + %extend { + MED_FIELDINT_RDWR_DRIVER(char * fileName, FIELDINT * ptrField) + { + return new MED_FIELDINT_RDWR_DRIVER(string(fileName), ptrField); + } - %addmethods { - MED_MESH_RDWR_DRIVER(char * fileName, MESH * ptrMesh) + void setFieldName(char * fieldName) { - return new MED_MESH_RDWR_DRIVER(string(fileName), ptrMesh); + self->setFieldName(string(fieldName)); + } + + %newobject getFieldName(); + char * getFieldName() + { + string tmp_str = self->getFieldName(); + char * tmp = new char[strlen(tmp_str.c_str())]; + strcat(tmp,tmp_str.c_str()); + return tmp; } void setMeshName(char * meshName) @@ -1644,16 +2185,33 @@ FIELDDOUBLE * createFieldDoubleFromField(FIELD_ * field) ; FIELDINT * createFieldIntFromField(FIELD_ * field) ; +GRID * createGridFromMesh( MESH * aMesh ); + %{ FIELDDOUBLE * createFieldDoubleFromField(FIELD_ * field) { MESSAGE("creatFieldDoubleFromField : Constructor (for Python API) FIELDDOUBLE with parameter FIELD_"); + MESSAGE("Its returns a proper cast of the input pointer :: FIELD_ --> FIELDDOUBLE"); return (FIELDDOUBLE *) field; } FIELDINT * createFieldIntFromField(FIELD_ * field) { MESSAGE("creatFieldIntFromField : Constructor (for Python API) FIELDINT with parameter FIELD_"); + MESSAGE("Its returns a proper cast of the input pointer :: FIELD_ --> FIELDINT"); return (FIELDINT *) field; } + + GRID * createGridFromMesh( MESH * aMesh ) + { + MESSAGE("createGridFromMesh : Constructor (for Python API) GRID with parameter MESH *"); + MESSAGE("Its returns a proper cast of the input pointer :: MESH --> GRID"); + + if (aMesh->getIsAGrid()) + return (GRID *) aMesh; + + char * message = "Error in GRID(mesh): mesh is not a grid"; + PyErr_SetString(PyExc_RuntimeError, message); + return NULL; + } %} diff --git a/src/MEDMEM_SWIG/my_typemap.i b/src/MEDMEM_SWIG/my_typemap.i index b1938597a..f1f5795e4 100644 --- a/src/MEDMEM_SWIG/my_typemap.i +++ b/src/MEDMEM_SWIG/my_typemap.i @@ -1,9 +1,59 @@ +// MED MEDMEM_SWIG : binding of C++ implementation and Python +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : my_typemap.i +// Module : MED + %{ #include %} +%typemap(python,in) string * { + /* Check if is a list */ + if (PyList_Check($source)) { + int size = PyList_Size($source); + int i = 0; + $target = new string[size]; + for (i = 0; i < size; i++) { + PyObject *o = PyList_GetItem($source,i); + if (PyString_Check(o)) + $target[i] = string(PyString_AsString(PyList_GetItem($source,i))); + else { + PyErr_SetString(PyExc_TypeError,"list must contain strings"); + free($target); + return NULL; + } + } + // $target[i] = 0; + } else { + PyErr_SetString(PyExc_TypeError,"not a list"); + return NULL; + } +} + %typemap(python,in) double * { + /* typemap in for double * */ /* Check if is a list */ if (PyList_Check($source)) { int size = PyList_Size($source); @@ -29,6 +79,7 @@ %typemap(python,in) int * { + /* typemap in for int * */ /* Check if is a list */ if (PyList_Check($source)) { int size = PyList_Size($source); @@ -55,6 +106,7 @@ %typemap(python,in) medGeometryElement * { + /* typemap in for medGeometryElement * */ /* Check if is a list */ if (PyList_Check($source)) { int size = PyList_Size($source); @@ -78,7 +130,6 @@ } } - %typemap(python,out) list { int i; list::iterator iL; @@ -87,3 +138,18 @@ for (i=0, iL=$source->begin(); iL!=$source->end(); i++, iL++) PyList_SetItem($target,i,PyString_FromString((*iL).c_str())); } + +%typemap(freearg) int * { + /* free the memory allocated in the typemap in for int * */ + free($1); +} + +%typemap(freearg) double * { + /* free the memory allocated in the typemap in for double * */ + free($1); +} + +%typemap(freearg) medGeometryElement * { + /* free the memory allocated in the typemap in for medGeometryElement * */ + free($1); +}