+// 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"
#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;
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<medGeometryElement> getAllConstituentsType() const; */
+
+
+/* map<medGeometryElement,int> getNumberOfConstituentsForeachType() const; */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ~CELLMODEL();
+
+ %extend {
+ %newobject getName();
char * getName()
{
string tmp_str = self->getName();
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 );
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)
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)
self->setName(string(Name));
}
+ %newobject getName();
const char * getName()
{
string tmp_str = self->getName();
self->setDescription(string(Description));
}
+ %newobject getDescription();
const char * getDescription()
{
string tmp_str = self->getDescription();
{
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++)
return NULL;
}
}
- return Py_BuildValue("O", py_list);
- }
-
- /*
- PyObject * getGeometricTypeNumber()
- {
- PyObject *py_list;
-
- int * GeometricTypeNumber = self->getGeometricTypeNumber();
- int size = self->getNumberOfTypes();
- py_list = PyList_New(size);
- for (int i=0; i < size; i++)
- {
- int err = PyList_SetItem(py_list, i,
- Py_BuildValue("i",
- GeometricTypeNumber[i]));
- if(err)
- {
- char * message = "Error in SUPPORT::getGeometricTypeNumber";
- PyErr_SetString(PyExc_RuntimeError, message);
- return NULL;
- }
- }
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
*/
{
PyObject *py_list;
- int * number = self->getNumber(GeometricType);
+ const int * number = self->getNumber(GeometricType);
int size = self->getNumberOfElements(GeometricType);
py_list = PyList_New(size);
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);
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
}
};
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);
return tmp;
}
+ %newobject getGroupName(int );
const char * getGroupName(int i)
{
string tmp_str = self->getGroupName(i);
{
PyObject *py_list;
- int * attributesids = self->getAttributesIdentifiers();
+ const int * attributesids = self->getAttributesIdentifiers();
int size = self->getNumberOfAttributes();
py_list = PyList_New(size);
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);
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
}
};
{
public:
FIELD_(const SUPPORT * Support, const int NumberOfComponents);
- // ~FIELD_();
+
+ ~FIELD_();
void rmDriver(int index=0);
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")
self->setName(string(name));
}
+ %newobject getName();
const char * getName()
{
string tmp_str = self->getName();
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);
self->setComponentName(i,string(ComponentName));
}
+ %newobject getComponentDescription(int );
const char * getComponentDescription(int i)
{
string tmp_str = self->getComponentDescription(i);
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)
class FIELDDOUBLE : public FIELD_
{
public:
- // ~FIELDDOUBLE();
+ ~FIELDDOUBLE();
FIELDDOUBLE(const SUPPORT * Support, const int NumberOfComponents);
SWIG with a version lesser than 1.3
*/
- //FIELDDOUBLE();
+ FIELDDOUBLE();
void read(int index=0);
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="")
{
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++)
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;
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++)
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
void allocValue2(int NumberOfComponents, int LengthValue)
class FIELDINT : public FIELD_
{
public:
- // ~FIELDINT();
+ ~FIELDINT();
FIELDINT(const SUPPORT * Support, const int NumberOfComponents);
SWIG with a version lesser than 1.3
*/
- /*
FIELDINT();
- */
void read(int index=0);
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="")
{
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++)
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
PyObject * getValueI(medModeSwitch Mode, int index)
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++)
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
void allocValue2(int NumberOfComponents, int LengthValue)
{
public:
GROUP();
- // ~GROUP();
+
+ ~GROUP();
void setNumberOfFamilies(int numberOfFamilies);
void setFamilies(vector<FAMILY*> Family);
SWIG with a version lesser than 1.3
*/
- // MESH();
+ MESH();
+
+ ~MESH();
void rmDriver(int index=0);
int getNumberOfNodes();
+ bool getIsAGrid();
+
const double getCoordinate(int Number, int Axis);
int getNumberOfTypes(medEntityMesh Entity);
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)
{
self->setName(string(name));
}
+ %newobject getName();
const char * getName()
{
string tmp_str = self->getName();
return tmp;
}
+ %newobject getCoordinatesSystem();
const char * getCoordinatesSystem()
{
string tmp_str = self->getCoordinatesSystem();
return tmp;
}
+ %newobject getCoordinateName(int );
const char * getCoordinateName(int i)
{
string tmp_str = self->getCoordinatesNames()[i];
return tmp;
}
+ %newobject getCoordinateUnit(int );
const char * getCoordinateUnit(int i)
{
string tmp_str = self->getCoordinatesUnits()[i];
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++)
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++)
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
PyObject * getCoordinates(medModeSwitch Mode)
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++)
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
PyObject * getConnectivity(medModeSwitch Mode,
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
{
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;
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;
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++)
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;
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
{
int getNumberOfFields ( void ) const;
- void updateSupport ( void ) ;
+ void updateSupport () ;
void write (int index=0);
- %addmethods {
+ %extend {
/*
WARNING:
other constructor of MED object.
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<string> list_string = self->getMeshNames();
return tmp;
}
+ %newobject getFieldName(int );
const char * getFieldName(int i)
{
deque<string> list_string = self->getFieldNames();
};
/*
- 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();
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);
}
};
-class MED_MED_WRONLY_DRIVER : public virtual MED_MED_DRIVER
+class MED_MED_WRONLY_DRIVER
{
public :
void open();
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);
};
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();
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);
};
/*
- 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)
self->setMeshName(string(meshName));
}
+ %newobject getMeshName();
char * getMeshName()
{
string tmp_str = self->getMeshName();
}
}
};
-*/
-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)
}
};
-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<FAMILY*> & 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)
}
};
-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)
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;
+ }
%}