interface MESH;
interface SUPPORT;
- enum medGeometryElement {
- MED_NONE,
- MED_POINT1,
- MED_SEG2,
- MED_SEG3,
- MED_TRIA3,
- MED_QUAD4,
- MED_TRIA6,
- MED_QUAD8,
- MED_TETRA4,
- MED_PYRA5,
- MED_PENTA6,
- MED_HEXA8,
- MED_TETRA10,
- MED_PYRA13,
- MED_PENTA15,
- MED_HEXA20,
- MED_ALL_ELEMENTS
- };
-
- enum medEntityMesh {
- MED_CELL,
- MED_FACE,
- MED_EDGE,
- MED_NODE,
- MED_ALL_ENTITIES
- };
-
- enum medModeSwitch {
- MED_FULL_INTERLACE,
- MED_NO_INTERLACE
- };
+ typedef long medGeometryElement;
+ const medGeometryElement MED_NONE = 0;
+ const medGeometryElement MED_POINT1 = 1;
+ const medGeometryElement MED_SEG2 = 102;
+ const medGeometryElement MED_SEG3 = 103;
+ const medGeometryElement MED_TRIA3 = 203;
+ const medGeometryElement MED_QUAD4 = 204;
+ const medGeometryElement MED_TRIA6 = 206;
+ const medGeometryElement MED_QUAD8 = 208;
+ const medGeometryElement MED_TETRA4 = 304;
+ const medGeometryElement MED_PYRA5 = 305;
+ const medGeometryElement MED_PENTA6 = 306;
+ const medGeometryElement MED_HEXA8 = 308;
+ const medGeometryElement MED_TETRA10 = 310;
+ const medGeometryElement MED_PYRA13 = 313;
+ const medGeometryElement MED_PENTA15 = 315;
+ const medGeometryElement MED_HEXA20 = 320;
+ const medGeometryElement MED_ALL_ELEMENTS = 999;
+
+ typedef long medEntityMesh;
+ const medEntityMesh MED_CELL = 0;
+ const medEntityMesh MED_FACE = 1;
+ const medEntityMesh MED_EDGE = 2;
+ const medEntityMesh MED_NODE = 3;
+ const medEntityMesh MED_ALL_ENTITIES = 4;
+
+ typedef long medModeSwitch;
+ const medModeSwitch MED_FULL_INTERLACE = 0;
+ const medModeSwitch MED_NO_INTERLACE = 1;
- enum medConnectivity {
- MED_NODAL,
- MED_DESCENDING
- };
+ typedef long medConnectivity;
+ const medConnectivity MED_NODAL = 0;
+ const medConnectivity MED_DESCENDING = 1;
- enum medDriverTypes {
- MED_DRIVER ,
- VTK_DRIVER ,
- NO_DRIVER
- };
+ typedef long medDriverTypes;
+ const medDriverTypes MED_DRIVER = 0;
+ const medDriverTypes VTK_DRIVER = 1;
+ const medDriverTypes NO_DRIVER = 2;
/*!
An array of medGeometryElement
- "CYLINDRICAL"
- "SPHERICAL"
*/
- string getCoordinateSystem() raises (SALOME::SALOME_Exception);
+ string getCoordinatesSystem() raises (SALOME::SALOME_Exception);
/*!
Returns the number of nodes defined in mesh.
/*!
If isOnAllElements is false, returns index of element number.
- Use it with getNumber(MED_ALL_ELEMENTS).
+ Use it with getNumber(MED_ALL_ELEMENTS).
+ _numberOfCellsFamilies,
+ IOR_Mesh->getFamilies(MED_CELL),
+ (void *) (convertFamily), this);
Note : See getConnectivityIndex for details.
*/
--- /dev/null
+# ifndef INTERPOLATION_HXX
+# define INTERPOLATION_HXX
+
+class MESH;
+//template < class T> class FIELD;
+//template < int > class Wrapper_Nuage;
+//template < int > class Wrapper_Noeud;
+//template <class ,class ,int ,int > class dTree;
+
+#include "utilities.h"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_InterpolationHighLevelObjects.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Field.hxx"
+
+template <int DIMENSION=3> class INTERPOLATION
+{
+protected:
+
+ FIELD<double> * _fromField;
+ FIELD<double> * _toField;
+ MESH * _fromMesh;
+ MESH * _toMesh;
+
+ Meta_Wrapper<DIMENSION> * _fromWrapper;
+ Meta_Wrapper<DIMENSION> * _toWrapper;
+
+ Meta_Mapping <DIMENSION> * _mapping;
+
+public :
+
+ void init();
+
+ // Initialize INTERPOLATION in order to get :
+ // 1- the node number in the MESH <fromMesh> which
+ // is the nearest from a given one ( use method : getNearestNode( double * node ) );
+ // 2- the cell number (if exists) in the MESH <fromMesh> which
+ // contains a specified node ( use method : getContainingCell ( double * node) )
+ INTERPOLATION(const MESH & fromMesh );
+ // Initialize INTERPOLATION in order to get :
+ // 1- the complete mapping ( use methode : getMapping() )
+ // 2- the functionalities above
+ INTERPOLATION(const MESH & fromMesh,const MESH & toMesh );
+ // Initialize INTERPOLATION in order to get the interpolation of <field> on <toMesh>
+ // Moreover, all the others functionalities are so available
+ INTERPOLATION(const FIELD<double> & fromField, const MESH & toMesh);
+
+ ~INTERPOLATION( );
+
+ // Get the node number in the MESH <fromMesh> which is the nearest from a given one
+ int getNearestNode ( double * node );
+ // Get the cell number (if exists) in the MESH <fromMesh> which contains a specified node
+ int getContainingCell ( double * node , int beginingCell=0, int flagIsConvexMesh=0 );
+ // Get the complete mapping, defaultly, fromMesh is supposed to be non-convex, if it is false, set flagIsConvexMesh to 1
+ vector<int> getMapping ( int flagIsConvexMesh=0 );
+ // Get the interpolated field toField
+ FIELD<double> * interpolate( /*med_interpolation_type*/ int itype,int flagIsConvexFromMesh=0);
+
+};
+
+
+template <int DIMENSION> void INTERPOLATION<DIMENSION>::init() {
+
+ const char * LOC = "INTERPOLATION::init(): ";
+
+ BEGIN_OF(LOC);
+ _fromField = ( FIELD<double> * ) NULL;
+ _toField = ( FIELD<double> * ) NULL;
+ _fromMesh = ( MESH * ) NULL;
+ _toMesh = ( MESH * ) NULL;
+ _fromWrapper = ( Meta_Wrapper<DIMENSION> * ) NULL;
+ _toWrapper = ( Meta_Wrapper<DIMENSION> * ) NULL;
+ _mapping = ( Meta_Mapping<DIMENSION> * ) NULL;
+ END_OF(LOC);
+}
+
+
+template <int DIMENSION> INTERPOLATION<DIMENSION>::INTERPOLATION(const MESH & fromMesh ) {
+
+ const char * LOC = "INTERPOLATION::INTERPOLATION(MESH * fromMesh ) : ";
+ BEGIN_OF(LOC);
+
+ init();
+
+ _fromMesh=const_cast<MESH * > (&fromMesh);
+
+ if (! _fromMesh ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"fromMesh is a NULL pointer !")) ;
+
+ int spaceDimension = _fromMesh->getSpaceDimension();
+ if (spaceDimension != DIMENSION ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The spaceDimension of mesh |" << _fromMesh->getName() << "| is |" << spaceDimension << "| and should be |" << DIMENSION << "|" << endl)) ;
+
+ _fromWrapper = new Meta_Wrapper<DIMENSION>(_fromMesh->getNumberOfNodes(),
+ const_cast<double *> (_fromMesh->getCoordinates(MED_FULL_INTERLACE)),
+ const_cast<CONNECTIVITY *> (_fromMesh->getConnectivityptr())
+ );
+
+ _mapping = new Meta_Mapping<DIMENSION> (_fromWrapper);
+
+ END_OF(LOC);
+};
+
+template <int DIMENSION> INTERPOLATION<DIMENSION>::INTERPOLATION(const MESH & fromMesh,const MESH & toMesh ) {
+
+ const char * LOC = "INTERPOLATION::INTERPOLATION(MESH * fromMesh,,const MESH & toMesh) : ";
+ BEGIN_OF(LOC);
+
+ init();
+
+ _fromMesh = const_cast<MESH * > ( &fromMesh );
+ _toMesh = const_cast<MESH * > ( &toMesh );
+
+ if (! _fromMesh ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"fromMesh is a NULL pointer !")) ;
+ if (! _toMesh ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"toMesh is a NULL pointer !")) ;
+
+ int fromSpaceDimension = _fromMesh->getSpaceDimension();
+ int toSpaceDimension = _toMesh->getSpaceDimension();
+
+ if (fromSpaceDimension != DIMENSION ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The spaceDimension of mesh |" << _fromMesh->getName() << "| is |" << spaceDimension << "| and should be |" << DIMENSION << "|" << endl)) ;
+ if ( toSpaceDimension != DIMENSION ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The spaceDimension of mesh |" << _toMesh->getName() << "| is |" << spaceDimension << "| and should be |" << DIMENSION << "|" << endl)) ;
+
+ _fromWrapper = new Meta_Wrapper<DIMENSION>(_fromMesh->getNumberOfNodes(),
+ const_cast<double *> (_fromMesh->getCoordinates(MED_FULL_INTERLACE)),
+ const_cast<CONNECTIVITY *> (_fromMesh->getConnectivityptr())
+ );
+
+ _toWrapper = new Meta_Wrapper<DIMENSION>(_toMesh->getNumberOfNodes(),
+ const_cast<double *> (_toMesh->getCoordinates(MED_FULL_INTERLACE))
+ );
+
+ _mapping = new Meta_Mapping<DIMENSION> (_fromWrapper);
+
+ END_OF(LOC);
+};
+
+template <int DIMENSION> INTERPOLATION<DIMENSION>::INTERPOLATION(const FIELD<double> & fromField,const MESH & toMesh) {
+
+ const char * LOC = "INTERPOLATION::INTERPOLATION(const FIELD<double> & field,const MESH & toMesh) : ";
+ BEGIN_OF(LOC);
+
+ init();
+
+ _toMesh = const_cast<MESH *>(&toMesh);
+ _fromField = const_cast<FIELD<double> *>(&fromField);
+
+ if ( ! _toMesh ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"toMesh is a NULL pointer !")) ;
+ if ( ! _fromField ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"field is a NULL pointer !")) ;
+
+ _fromMesh = _fromField->getSupport()->getMesh();
+
+ _fromWrapper = new Meta_Wrapper<DIMENSION>(_fromMesh->getNumberOfNodes(),
+ const_cast<double *> (_fromMesh->getCoordinates(MED_FULL_INTERLACE)),
+ const_cast<CONNECTIVITY *> (_fromMesh->getConnectivityptr()),
+ const_cast<FIELD<double> *>(_fromField)
+ );
+
+ _toWrapper = new Meta_Wrapper<DIMENSION>(_toMesh->getNumberOfNodes(),
+ const_cast<double *> (_toMesh->getCoordinates(MED_FULL_INTERLACE))
+ );
+
+ _mapping = new Meta_Mapping<DIMENSION> (_fromWrapper);
+
+ END_OF(LOC);
+};
+
+template <int DIMENSION> INTERPOLATION<DIMENSION>::~INTERPOLATION()
+{
+ if ( _fromWrapper ) delete _fromWrapper ;
+ if ( _toWrapper ) delete _toWrapper ;
+ if ( _mapping ) delete _mapping ;
+};
+
+template <int DIMENSION> int INTERPOLATION<DIMENSION>::getNearestNode( double * node ) {
+
+ const char * LOC = "INTERPOLATION::getNearestNode( double * node ) ";
+
+ BEGIN_OF(LOC);
+
+ if ( ! _mapping ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"mapping is a NULL pointer !")) ;
+
+ return _mapping->Donne_dTree()->trouve_plus_proche_point(Wrapper_Noeud<DIMENSION > (node) );
+
+ END_OF(LOC);
+
+};
+
+template <int DIMENSION> int INTERPOLATION<DIMENSION>::getContainingCell ( double * node , int beginingCell, int flagIsConvexMesh ) {
+
+ const char * LOC = "INTERPOLATION::getContainingCell( double * node ) ";
+
+ BEGIN_OF(LOC);
+
+ if ( ! _mapping ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"mapping is a NULL pointer !")) ;
+
+ return _mapping->Trouve_Maille_Contenant_Noeud(node,beginingCell,flagIsConvexMesh);
+
+ END_OF(LOC);
+
+};
+
+template <int DIMENSION> vector<int> INTERPOLATION<DIMENSION>::getMapping ( int flagIsConvexMesh ) {
+
+ const char * LOC = "INTERPOLATION::getMapping( ) ";
+
+ BEGIN_OF(LOC);
+
+ if ( ! _mapping ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"mapping is a NULL pointer !")) ;
+ if ( ! _toWrapper ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"toWrapper is a NULL pointer !")) ;
+
+ mapping_->Cree_Mapping(_toWrapper,flag_convexe);
+
+ return _mapping->Get_Mapping();
+
+ END_OF(LOC);
+
+};
+
+template <int DIMENSION> FIELD<double> * INTERPOLATION<DIMENSION>::interpolate( /*med_interpolation_type*/ int itype,int flagIsConvexFromMesh) {
+
+ const char * LOC = "INTERPOLATION::interpolate( /*med_interpolation_type*/ int itype) ";
+
+ BEGIN_OF(LOC);
+
+ if ( ! _mapping ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"mapping is a NULL pointer !")) ;
+ if ( ! _toWrapper ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"toWrapper is a NULL pointer !")) ;
+ if ( ! _fromField ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"fromField is a NULL pointer !")) ;
+
+ _mapping->Cree_Mapping(_toWrapper,flagIsConvexFromMesh);
+
+ Wrapper_Nuage_Noeud<DIMENSION> * toNodes = _toWrapper->Get_Nuage_Noeuds();
+
+ Wrapper_MED_Field resultat;
+
+cout<<"On commence l'interpolation"<<endl;
+
+ switch (itype)
+ {
+ case 0 : // INTERPOLATION P0
+ cout<<"Avant ="<<endl;
+ resultat=Meta_Interpolateur< Meta_Calcul_Interpolation_P0<DIMENSION>,DIMENSION >(_mapping,_fromWrapper).Perform_Interpolation(toNodes);
+ break;
+ case 1 : // INTERPOLATION P-Hybride (Interpole avec la fonction d'interpolation naturelle de la maille contenant le point)
+ resultat=Meta_Interpolateur< Meta_Calcul_Interpolation_Hybride<DIMENSION>,DIMENSION >(_mapping,_fromWrapper).Perform_Interpolation(toNodes);
+ break;
+ case 2 : // INTERPOLATION (P/Q) 1 forcée (Interpole avec la fonction élément fini de la maille de degré 1 -meme si la maille est de degré supérieur-)
+ resultat=Meta_Interpolateur< Meta_Calcul_Interpolation_Hybride_P1<DIMENSION>, DIMENSION >(_mapping,_fromWrapper).Perform_Interpolation(toNodes);
+ break;
+ default :
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Interpolation type "<<itype<<" not yet implemented !")) ;
+ }
+
+cout<<"On a fini l'interpolation"<<endl;
+
+ _toField = new FIELD<double>;
+
+ _toField->setName ( _fromField->getName()+"XXX" );
+ _toField->setDescription ( _fromField->getDescription() );
+ _toField->setNumberOfComponents ( _fromField->getNumberOfComponents() );
+ _toField->setNumberOfValues ( _toMesh ->getNumberOfNodes() );
+ _toField->setComponentsNames ( _fromField->getComponentsNames() );
+ _toField->setComponentsDescriptions ( _fromField->getComponentsDescriptions() );
+ _toField->setMEDComponentsUnits ( _fromField->getMEDComponentsUnits() );
+ _toField->setIterationNumber ( _fromField->getIterationNumber() );
+ _toField->setTime ( _fromField->getTime() );
+ _toField->setOrderNumber ( _fromField->getOrderNumber() );
+ _toField->setValueType ( MED_EN::MED_REEL64 );
+
+ SUPPORT * mySupport(new SUPPORT(_toMesh,"support",MED_NODE));
+ _toField->setSupport(mySupport);
+
+ _toField->allocValue(_toField->getNumberOfComponents(),_toField->getNumberOfValues());
+
+ _toField->setValue(MED_FULL_INTERLACE,resultat.Get_Valeurs());
+
+ _toWrapper->Construit_Wrapper_Champ(_toField);
+
+ return _toField;
+
+ END_OF(LOC);
+
+};
+
+#endif
+
+
--- /dev/null
+#ifndef MEDMEM_INTERPOLATION_HIGHLEVEL_OBJECTS_HXX
+#define MEDMEM_INTERPOLATION_HIGHLEVEL_OBJECTS_HXX
+
+#include "MEDMEM_Connectivity.hxx"
+#include "MEDMEM_WrapperConnectivity.hxx"
+#include "MEDMEM_dTree.hxx"
+#include "MEDMEM_WrapperNodes.hxx"
+#include "MEDMEM_WrapperMesh.hxx"
+#include "MEDMEM_WrapperCells.hxx"
+#include "MEDMEM_Mapping.hxx"
+#include "MEDMEM_WrapperField.hxx"
+#include "MEDMEM_InterpolationTools.hxx"
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+template <int DIMENSION> class Meta_Wrapper;
+
+/*********************************************************/
+/* */
+/* Meta_dTree */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> class Meta_dTree : public dTree<Wrapper_Noeud<DIMENSION>,Wrapper_Nuage_Noeud<DIMENSION>,DIMENSION>
+{
+public :
+ inline int trouve_plus_proche_point(double *node);
+};
+
+/*********************************************************/
+/* */
+/* Meta_Nuage_Maille */
+/* */
+/*********************************************************/
+
+
+class Meta_Nuage_Maille : public Wrapper_Nuage_Maille<Wrapper_Med_Connectivity>
+{
+protected :
+ Wrapper_Med_Connectivity * connectivite_med;
+public :
+ Meta_Nuage_Maille(CONNECTIVITY * connmed);
+ Meta_Nuage_Maille():connectivite_med(NULL) {}
+ ~Meta_Nuage_Maille() {if (connectivite_med) delete connectivite_med;}
+};
+
+/*********************************************************/
+/* */
+/* Meta_Maillage */
+/* */
+/*********************************************************/
+
+
+typedef Wrapper_Maillage<Meta_Nuage_Maille> Meta_Maillage;
+
+/*********************************************************/
+/* */
+/* Meta_Mapping */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> class Meta_Mapping : public Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>
+{
+public :
+ Meta_Mapping(Meta_Wrapper<DIMENSION> * MW):Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>(MW->Get_Maillage(),MW->Get_Nuage_Noeuds(),NULL) {}
+ Meta_Mapping(Meta_Wrapper<DIMENSION> * MW,Meta_Wrapper<DIMENSION> * TWB):Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>(MW->Get_Maillage(),MW->Get_Nuage_Noeuds(),TWB->Get_Nuage_Noeuds()) {}
+ void Cree_Mapping(Meta_Wrapper<DIMENSION> * MWB, int flag_convexe) {Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>::Cree_Mapping(MWB->Get_Nuage_Noeuds(),flag_convexe);}
+ inline int Trouve_Maille_Contenant_Noeud(double * node,int num_maille, int flag_convexe=0);
+};
+
+/*********************************************************/
+/* */
+/* Meta_Wrapper */
+/* */
+/*********************************************************/
+
+
+template <int DIMENSION> class Meta_Wrapper
+{
+protected :
+ Wrapper_Nuage_Noeud<DIMENSION> * noeuds ;
+ Meta_Nuage_Maille * mailles ;
+ Meta_Maillage * maillage ;
+ Wrapper_MED_Field * champ ;
+
+ void init( ){noeuds=NULL;mailles=NULL;maillage=NULL;champ=NULL;}
+public :
+ Meta_Wrapper():noeuds(NULL),mailles(NULL),maillage(NULL),champ(NULL){}
+ ~Meta_Wrapper();
+ inline void Construit_Wrapper_Nuage_Noeud ( int nn, double * nodes );
+ inline void Construit_Wrapper_Nuage_Maille ( CONNECTIVITY * connmed );
+ inline void Construit_Wrapper_Maillage ( void );
+ inline void Construit_Wrapper_Champ ( const FIELD<double> * medfield );
+ Meta_Wrapper(int nn,double *nodes,CONNECTIVITY *connmed, int flag_maillage=1);
+ Meta_Wrapper(int nn,double *nodes);
+ // defaultly, the connectivity (neighbouhood and so like) is built,
+ // Set flag_mesh to 0 if you don't want these informations to be built
+ Meta_Wrapper(int nn,double *nodes,CONNECTIVITY *connmed, const FIELD<double> * c,int flag_mesh=1);
+ // fonctions d'acces sures
+ inline Wrapper_Nuage_Noeud<DIMENSION> * Get_Nuage_Noeuds ( void );
+ inline Meta_Nuage_Maille * Get_Nuage_Mailles ( void );
+ inline Meta_Maillage * Get_Maillage ( void );
+ inline Wrapper_MED_Field * Get_Champ ( void );
+};
+
+/*********************************************************/
+/* */
+/* Meta_Calcul_Interpolation_Hybride */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> class Meta_Calcul_Interpolation_Hybride : public Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>
+{
+public :
+ Meta_Calcul_Interpolation_Hybride(Meta_Wrapper<DIMENSION> * MW):Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(MW->Get_Nuage_Noeuds(),MW->Get_Nuage_Mailles(),MW->Get_Champ()) {}
+ Valeur<double> operator() (Wrapper_Noeud<DIMENSION> & node, int num_maille){return Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>::operator()(node,num_maille);}
+ Valeur<double> operator() (double * node, int num_maille)
+ {
+ static Wrapper_Noeud<DIMENSION> tmp;
+ tmp.positionne(node);
+ return Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(tmp,num_maille);
+ }
+};
+
+/*********************************************************/
+/* */
+/* Meta_Calcul_Interpolation_Hybride_P1 */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> class Meta_Calcul_Interpolation_Hybride_P1 : public Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>
+{
+public :
+ Meta_Calcul_Interpolation_Hybride_P1(Meta_Wrapper<DIMENSION> * MW)
+ {
+
+ Wrapper_Nuage_Noeud<DIMENSION> * nn = MW->Get_Nuage_Noeuds();
+ Meta_Nuage_Maille * nm = MW->Get_Nuage_Mailles();
+ Wrapper_MED_Field * c = MW->Get_Champ();
+
+ mailles=nm;
+
+ fonctions[MED_TRIA3 ]=new Calcul_Interpolation_Tria3 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ fonctions[MED_QUAD4 ]=new Calcul_Interpolation_Quad4 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ fonctions[MED_TETRA4 ]=new Calcul_Interpolation_Tetra4 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ fonctions[MED_HEXA8 ]=new Calcul_Interpolation_Hexa8 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ fonctions[MED_PENTA6 ]=new Calcul_Interpolation_Penta6 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ fonctions[MED_PYRA5 ]=new Calcul_Interpolation_Pyra5 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ fonctions[MED_TRIA6 ]=fonctions[MED_TRIA3 ];
+ fonctions[MED_QUAD8 ]=fonctions[MED_QUAD4 ];
+ fonctions[MED_TETRA10]=fonctions[MED_TETRA4 ];
+ fonctions[MED_HEXA20 ]=fonctions[MED_HEXA8 ];
+ fonctions[MED_PENTA15]=fonctions[MED_PENTA6 ];
+ fonctions[MED_PYRA13 ]=fonctions[MED_PYRA5 ];
+ }
+ Valeur<double> operator() (Wrapper_Noeud<DIMENSION> & node, int num_maille){return Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>::operator()(node,num_maille);}
+ Valeur<double> operator() (double * node, int num_maille)
+ {
+ static Wrapper_Noeud<DIMENSION> tmp;
+ tmp.positionne(node);
+ return Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(tmp,num_maille);
+ }
+};
+
+/*********************************************************/
+/* */
+/* Meta_Calcul_Interpolation_P0 */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> class Meta_Calcul_Interpolation_P0 : public Calcul_Interpolation_P0<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>
+{
+public :
+ Meta_Calcul_Interpolation_P0(Meta_Wrapper<DIMENSION> * MW):Calcul_Interpolation_P0<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(MW->Get_Nuage_Noeuds(),MW->Get_Nuage_Mailles(),MW->Get_Champ()) {}
+ Valeur<double> operator() (Wrapper_Noeud<DIMENSION> & node, int num_maille){return Calcul_Interpolation_P0<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>::operator()(node,num_maille);}
+ Valeur<double> operator() (double * node, int num_maille)
+ {
+ static Wrapper_Noeud<DIMENSION> tmp;
+ tmp.positionne(node);
+ return Calcul_Interpolation_P0<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(tmp,num_maille);
+ }
+};
+
+/*********************************************************/
+/* */
+/* Meta_Interpolateur */
+/* */
+/*********************************************************/
+
+template <class FONCTEUR, int DIMENSION> class Meta_Interpolateur
+{
+protected :
+ FONCTEUR * fct;
+ Meta_Mapping<DIMENSION> * mapping;
+ Meta_Wrapper<DIMENSION> * fromWrapper;
+public :
+ Meta_Interpolateur():fct(NULL),mapping(NULL),fromWrapper(NULL) {}
+ Meta_Interpolateur(Meta_Mapping<DIMENSION> * map, Meta_Wrapper<DIMENSION> * mw):mapping(map),fromWrapper(mw),fct(new FONCTEUR(mw)){}
+ ~Meta_Interpolateur() {if (fct) delete fct;}
+ Wrapper_MED_Field Perform_Interpolation(Wrapper_Nuage_Noeud<DIMENSION> * toNodes)
+ {
+ int i;
+
+ int nbr_composantes = fromWrapper->Get_Champ()->Get_Nbr_Composantes();
+ int nbr_valeurs = toNodes->SIZE();
+
+ double * valeurs=new double[nbr_valeurs*nbr_composantes];
+
+ Wrapper_MED_Field resultat(nbr_valeurs,nbr_composantes,valeurs);
+
+ int nlpp,nmc;
+
+ for (i=0;i<nbr_valeurs;i++)
+ {
+ cout<<"Interpolation du noeud "<<i<<flush;
+ nmc = (*mapping)[i];
+ cout<<" | mappé dans la maille "<<nmc<<flush;
+ cout<<" | coordonnées = "<<flush<<(*toNodes)[i]<<flush;
+ if (nmc>=0)
+ {
+ cout<<" | valeurs qui va etre assignée = "<<flush<<(*fct)((*toNodes)[i],nmc)<<flush;
+ resultat[i]=(*fct)((*toNodes)[i],nmc);
+ }
+ else
+ {
+ nlpp = mapping->Get_Noeud_Le_Plus_Proche(i);
+ cout<<" | et dont le point le plus proche a pour numéro : "<<nlpp<<flush;
+ cout<<" | valeurs qui va etre assignée = "<<(*fromWrapper->Get_Champ())[nlpp]<<flush;
+ if (nlpp!=UNDEFINED) resultat[i]=(*fromWrapper->Get_Champ())[nlpp];
+ else
+ {
+ cerr<<"Meta_Interpolateur : Le noeud "<<i+1<<" n'a ni maille contenante, ni point le plus proche"<<flush;
+ exit(-1);
+ }
+ }
+ cout<<" | => OK ! "<<endl;
+ }
+
+ cout<<"Avant return"<<endl;
+
+ return resultat;
+
+ }
+};
+
+
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// CODE ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Meta_dTree */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> inline int Meta_dTree<DIMENSION>::trouve_plus_proche_point(double *node)
+ {
+ static Wrapper_Noeud<DIMENSION> nodetmp;
+ nodetmp.positionne(node);
+ return dTree<Wrapper_Noeud<DIMENSION>,Wrapper_Nuage_Noeud<DIMENSION>,DIMENSION>::trouve_plus_proche_point(Wrapper_Noeud<DIMENSION>(nodetmp));
+ }
+
+/*********************************************************/
+/* */
+/* Meta_Nuage_Maille */
+/* */
+/*********************************************************/
+
+Meta_Nuage_Maille::Meta_Nuage_Maille(CONNECTIVITY * conmed):Wrapper_Nuage_Maille<Wrapper_Med_Connectivity>(connectivite_med=new Wrapper_Med_Connectivity(conmed))
+ {
+ }
+
+/*********************************************************/
+/* */
+/* Meta_Mapping */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> inline int Meta_Mapping<DIMENSION>::Trouve_Maille_Contenant_Noeud(double * node,int num_maille,int flag_convexe)
+ {
+ int interdit=num_maille;
+ int max_loop=100;
+ int nme=0;
+ static Wrapper_Noeud<DIMENSION> nodetmp;
+ nodetmp.positionne(node);
+ return Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>::Trouve_Maille_Contenant_Point_Mth_Co(nodetmp,num_maille,interdit,max_loop,nme,flag_convexe);
+ }
+
+/*********************************************************/
+/* */
+/* Meta_Wrapper */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> Meta_Wrapper<DIMENSION>::~Meta_Wrapper()
+ {
+ if ( noeuds ) delete noeuds ;
+ if ( mailles ) delete mailles ;
+ if ( maillage ) delete maillage ;
+ if ( champ ) delete champ ;
+ }
+template <int DIMENSION> inline void Meta_Wrapper<DIMENSION>::Construit_Wrapper_Nuage_Noeud ( int nn, double * nodes )
+ {
+ if (nodes) noeuds=new Wrapper_Nuage_Noeud<DIMENSION>(nn,nodes);
+ else
+ {
+ cerr<<"Meta_Wrapper : Nuage MED_FULL_INTERLACE vide passé en argument au constructeur"<<endl;
+ exit(-1);
+ }
+ }
+template <int DIMENSION> inline void Meta_Wrapper<DIMENSION>::Construit_Wrapper_Nuage_Maille ( CONNECTIVITY * connmed )
+ {
+ if (connmed) mailles=new Meta_Nuage_Maille(connmed);
+ else
+ {
+ cerr<<"Meta_Wrapper : CONNECTIVITY vide passée en argument au constructeur"<<endl;
+ exit(-1);
+ }
+ }
+template <int DIMENSION> inline void Meta_Wrapper<DIMENSION>::Construit_Wrapper_Maillage ( void )
+ {
+ if (mailles==NULL)
+ {
+ cerr<<"Meta_Wrapper : Le nuage de maille n'a pas été initialisé !"<<endl;
+ exit(-1);
+ }
+ if (noeuds==NULL)
+ {
+ cerr<<"Meta_Wrapper : Le nuage de noeuds n'a pas été initialisé !"<<endl;
+ exit(-1);
+ }
+ maillage=new Meta_Maillage(mailles,noeuds->SIZE());
+ }
+template <int DIMENSION> inline void Meta_Wrapper<DIMENSION>::Construit_Wrapper_Champ ( const FIELD<double> * medfield )
+ {
+ if (medfield) champ=new Wrapper_MED_Field(medfield);
+ else
+ {
+ cerr<<"Meta_Wrapper : FIELD MED vide passé en argument au constructeur"<<endl;
+ exit(-1);
+ }
+ }
+template <int DIMENSION> Meta_Wrapper<DIMENSION>::Meta_Wrapper(int nn,double *nodes,CONNECTIVITY *connmed, int flag_maillage=1)
+ {
+ init();
+ Construit_Wrapper_Nuage_Noeud(nn,nodes);
+ Construit_Wrapper_Nuage_Maille(connmed);
+ if (flag_maillage) Construit_Wrapper_Maillage();
+ }
+template <int DIMENSION> Meta_Wrapper<DIMENSION>::Meta_Wrapper(int nn,double *nodes,CONNECTIVITY *connmed, const FIELD<double> * c,int flag_maillage=1)
+ {
+ init();
+ Construit_Wrapper_Nuage_Noeud(nn,nodes);
+ Construit_Wrapper_Nuage_Maille(connmed);
+ if (flag_maillage) Construit_Wrapper_Maillage();
+ Construit_Wrapper_Champ(c);
+ }
+template <int DIMENSION> Meta_Wrapper<DIMENSION>::Meta_Wrapper(int nn,double *nodes)
+ {
+ init();
+ Construit_Wrapper_Nuage_Noeud(nn,nodes);
+ }
+template <int DIMENSION> inline Wrapper_Nuage_Noeud<DIMENSION> * Meta_Wrapper<DIMENSION>::Get_Nuage_Noeuds ( void )
+ {
+ if (noeuds) return noeuds;
+ else
+ {
+ cerr<<"Meta_Wrapper : Nuage noeuds demandé alors qu'il n'est pas construit !"<<endl;
+ exit(-1);
+ }
+ }
+template <int DIMENSION> inline Meta_Nuage_Maille * Meta_Wrapper<DIMENSION>::Get_Nuage_Mailles ( void )
+ {
+ if (mailles) return mailles ;
+ else
+ {
+ cerr<<"Meta_Wrapper : Nuage mailles demandé alors qu'il n'est pas construit !"<<endl;
+ exit(-1);
+ }
+ }
+template <int DIMENSION> inline Meta_Maillage * Meta_Wrapper<DIMENSION>::Get_Maillage ( void )
+ {
+ if (maillage) return maillage ;
+ else
+ {
+ cerr<<"Meta_Wrapper : Connectivitée maillage demandée alors qu'elle n'est pas construite !"<<endl;
+ exit(-1);
+ }
+ }
+
+template <int DIMENSION> inline Wrapper_MED_Field * Meta_Wrapper<DIMENSION>::Get_Champ ( void )
+ {
+ if (champ) return champ;
+ else
+ {
+ cerr<<"Meta_Wrapper : Champ demandé alors qu'il n'est pas construit !"<<endl;
+ exit(-1);
+ }
+ }
+
+#endif
--- /dev/null
+#ifndef MEDMEM_INTERPOLATION_HIGHLEVEL_OBJECTS_HXX
+
+#define MEDMEM_INTERPOLATION_HIGHLEVEL_OBJECTS_HXX
+#include "MEDMEM_Connectivity.hxx"
+#include "MEDMEM_WrapperConnectivity.hxx"
+#include "MEDMEM_dTree.hxx"
+#include "MEDMEM_WrapperNodes.hxx"
+#include "MEDMEM_WrapperMesh.hxx"
+#include "MEDMEM_WrapperCells.hxx"
+#include "MEDMEM_Mapping.hxx"
+
+// DECLARATIONS
+
+template <int DIMENSION> class Meta_dTree : public dTree<Wrapper_Noeud<DIMENSION>,Wrapper_Nuage_Noeud<DIMENSION>,DIMENSION>
+{
+protected :
+ Wrapper_Nuage_Noeud<DIMENSION> * nuagetmp;
+public :
+ Meta_dTree(int nn,double * fullinterlace);
+ ~Meta_dTree() {if ((etat==DTREE_RACINE)&&(nuagetmp)) delete nuagetmp;}
+ inline int trouve_plus_proche_point(double *node);
+};
+
+class Meta_Nuage_Maille : public Wrapper_Nuage_Maille<Wrapper_Med_Connectivity>
+{
+protected :
+ Wrapper_Med_Connectivity * connectivite_med;
+public :
+ Meta_Nuage_Maille(CONNECTIVITY * connmed);
+ Meta_Nuage_Maille():Wrapper_Nuage_Maille<Wrapper_Med_Connectivity>(connectivite_med=new Wrapper_Med_Connectivity) {}
+ ~Meta_Nuage_Maille() {if (connectivite_med) delete connectivite_med;}
+};
+
+
+typedef Wrapper_Maillage<Meta_Nuage_Maille> Meta_Maillage;
+
+template <int DIMENSION> class Meta_Mapping : public Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>
+{
+protected :
+ Wrapper_Nuage_Noeud<DIMENSION> * wrapping_nuage_source;
+ Wrapper_Nuage_Noeud<DIMENSION> * wrapping_nuage_cible;
+public :
+ Meta_Mapping(Meta_Maillage * mb,double * noeudssource,int ns,double * noeudscible,int nc);
+ ~Meta_Mapping() {if (wrapping_nuage_source) delete wrapping_nuage_source;if (wrapping_nuage_cible) delete wrapping_nuage_cible;}
+ inline int Trouve_Maille_Contenant_Noeud(double * node,int num_maille, int flag_convexe=0);
+ double donne_valeur_interpolee_P1(double * node,vector<double> vals);
+};
+
+// CODE
+
+template <int DIMENSION> Meta_dTree<DIMENSION>::Meta_dTree(int nn,double * fullinterlace)
+:dTree<Wrapper_Noeud<DIMENSION>,Wrapper_Nuage_Noeud<DIMENSION>,DIMENSION>
+(nuagetmp=new Wrapper_Nuage_Noeud<DIMENSION>(nn,fullinterlace))
+ {
+ }
+
+template <int DIMENSION> inline int Meta_dTree<DIMENSION>::trouve_plus_proche_point(double *node)
+ {
+ static Wrapper_Noeud<DIMENSION> nodetmp;
+ nodetmp.positionne(node);
+ return dTree<Wrapper_Noeud<DIMENSION>,Wrapper_Nuage_Noeud<DIMENSION>,DIMENSION>::trouve_plus_proche_point(Wrapper_Noeud<DIMENSION>(nodetmp));
+ }
+
+//*
+Meta_Nuage_Maille::Meta_Nuage_Maille(CONNECTIVITY * conmed):Wrapper_Nuage_Maille<Wrapper_Med_Connectivity>(connectivite_med=new Wrapper_Med_Connectivity(conmed))
+ {
+ }
+//*/
+
+template <int DIMENSION> Meta_Mapping<DIMENSION>::Meta_Mapping(Meta_Maillage * mb,double * noeudssource,int ns,double * noeudscible,int nc)
+:Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>
+(mb,
+wrapping_nuage_source=new Wrapper_Nuage_Noeud<DIMENSION>(ns,noeudssource),
+wrapping_nuage_cible=new Wrapper_Nuage_Noeud<DIMENSION>(nc,noeudscible))
+ {
+ }
+
+template <int DIMENSION> inline int Meta_Mapping<DIMENSION>::Trouve_Maille_Contenant_Noeud(double * node,int num_maille,int flag_convexe)
+ {
+ int interdit=num_maille;
+ int max_loop=100;
+ int nme=0;
+ static Wrapper_Noeud<DIMENSION> nodetmp;
+ nodetmp.positionne(node);
+ return Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>::Trouve_Maille_Contenant_Point_Mth_Co(nodetmp,num_maille,interdit,max_loop,nme,flag_convexe);
+ }
+template <int DIMENSION> double Meta_Mapping<DIMENSION>::donne_valeur_interpolee_P1(double * node,vector<double> vals)
+ {
+ int num_maille_contenant=Trouve_Maille_Contenant_Noeud(node,0);
+ double valeur_interpol=0;
+ vector<double> valeurs=CB->Calcule_Coord_Baryc(num_maille_contenant,node);
+ int i;
+ int num_som;
+ for (i=0;i<valeurs.size();i++)
+ {
+ cout<<"Lambda(M):"<<i<<" = "<<valeurs[i]<<endl;
+ num_som=mailles_back->DONNE_SOMMET_MAILLE(num_maille_contenant,i);
+ valeur_interpol+=vals[num_som]*valeurs[i];
+ }
+
+ return valeur_interpol;
+ }
+
+#endif
--- /dev/null
+#ifndef MEDMEM_INTERPOLATION_TOOLS_HXX
+#define MEDMEM_INTERPOLATION_TOOLS_HXX
+
+#include "MEDMEM_define.hxx"
+
+#define _TEMPLATE_ template <class CHAMP,class VALEURCHAMP,class NUAGENOEUD, class NOEUD, class NUAGEMAILLE>
+#define _PARAM_ CHAMP,VALEURCHAMP,NUAGENOEUD,NOEUD,NUAGEMAILLE
+
+#define face2367(x,y,z) ((x6*(-y2 + y3) + x3*(y2 - y6) + x2*(-y3 + y6))*z - x6*y3*z2 + x3*y6*z2 + x6*y2*z3 - x2*y6*z3 - x3*y2*z6 + x2*y3*z6 + y*(x6*(z2 - z3) + x2*(z3 - z6) + x3*(-z2 + z6)) + x*(y6*(-z2 + z3) + y3*(z2 - z6) + y2*(-z3 + z6)))
+#define face4567(x,y,z) ((x6*(-y4 + y5) + x5*(y4 - y6) + x4*(-y5 + y6))*z - x6*y5*z4 + x5*y6*z4 + x6*y4*z5 - x4*y6*z5 - x5*y4*z6 + x4*y5*z6 + y*(x6*(z4 - z5) + x4*(z5 - z6) + x5*(-z4 + z6)) + x*(y6*(-z4 + z5) + y5*(z4 - z6) + y4*(-z5 + z6)))
+#define face1256(x,y,z) ((x5*(-y1 + y2) + x2*(y1 - y5) + x1*(-y2 + y5))*z - x5*y2*z1 + x2*y5*z1 + x5*y1*z2 - x1*y5*z2 - x2*y1*z5 + x1*y2*z5 + y*(x5*(z1 - z2) + x1*(z2 - z5) + x2*(-z1 + z5)) + x*(y5*(-z1 + z2) + y2*(z1 - z5) + y1*(-z2 + z5)))
+#define face0347(x,y,z) ((x4*(-y0 + y3) + x3*(y0 - y4) + x0*(-y3 + y4))*z - x4*y3*z0 + x3*y4*z0 + x4*y0*z3 - x0*y4*z3 - x3*y0*z4 + x0*y3*z4 + y*(x4*(z0 - z3) + x0*(z3 - z4) + x3*(-z0 + z4)) + x*(y4*(-z0 + z3) + y3*(z0 - z4) + y0*(-z3 + z4)))
+#define face0145(x,y,z) ((x4*(-y0 + y1) + x1*(y0 - y4) + x0*(-y1 + y4))*z - x4*y1*z0 + x1*y4*z0 + x4*y0*z1 - x0*y4*z1 - x1*y0*z4 + x0*y1*z4 + y*(x4*(z0 - z1) + x0*(z1 - z4) + x1*(-z0 + z4)) + x*(y4*(-z0 + z1) + y1*(z0 - z4) + y0*(-z1 + z4)))
+#define face0123(x,y,z) ((x2*(-y0 + y1) + x1*(y0 - y2) + x0*(-y1 + y2))*z - x2*y1*z0 + x1*y2*z0 + x2*y0*z1 - x0*y2*z1 - x1*y0*z2 + x0*y1*z2 + y*(x2*(z0 - z1) + x0*(z1 - z2) + x1*(-z0 + z2)) + x*(y2*(-z0 + z1) + y1*(z0 - z2) + y0*(-z1 + z2)))
+
+
+
+// DECLARATION
+
+_TEMPLATE_ class Calcul_Interpolation
+{
+protected :
+ NUAGENOEUD * noeuds;
+ NUAGEMAILLE * mailles;
+ CHAMP * champ;
+public :
+ Calcul_Interpolation():noeuds(NULL),mailles(NULL),champ(NULL) {}
+ Calcul_Interpolation(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):noeuds(nn),mailles(nm),champ(c) {}
+ ~Calcul_Interpolation() {}
+ virtual VALEURCHAMP operator() (const NOEUD & n, int num_maille) {cerr<<"APPEL OPERATOR() DE LA CLASSE MERE CALCUL_INTERPOLATION => EXIT(-1)"<<endl;exit(-1);}
+};
+
+_TEMPLATE_ class Calcul_Interpolation_P0;
+
+_TEMPLATE_ class Calcul_Interpolation_Tria3;
+_TEMPLATE_ class Calcul_Interpolation_Tria6;
+_TEMPLATE_ class Calcul_Interpolation_Quad4;
+_TEMPLATE_ class Calcul_Interpolation_Quad8;
+_TEMPLATE_ class Calcul_Interpolation_Tetra4;
+_TEMPLATE_ class Calcul_Interpolation_Tetra10;
+_TEMPLATE_ class Calcul_Interpolation_Hexa8;
+_TEMPLATE_ class Calcul_Interpolation_Hexa20;
+_TEMPLATE_ class Calcul_Interpolation_Penta6;
+_TEMPLATE_ class Calcul_Interpolation_Penta15;
+_TEMPLATE_ class Calcul_Interpolation_Pyra5;
+_TEMPLATE_ class Calcul_Interpolation_Pyra13;
+
+_TEMPLATE_ class Calcul_Hybride
+{
+protected :
+ NUAGEMAILLE * mailles;
+ map<int,Calcul_Interpolation<_PARAM_> *> fonctions;
+public :
+ Calcul_Hybride():mailles(NULL) {}
+ Calcul_Hybride(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c);
+ ~Calcul_Hybride() {}
+ VALEURCHAMP operator() (const NOEUD & n, int num_maille);
+};
+
+//CODE
+
+_TEMPLATE_ Calcul_Hybride<_PARAM_>::Calcul_Hybride(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):mailles(nm)
+ {
+ fonctions[MED_TRIA3 ]=new Calcul_Interpolation_Tria3 <_PARAM_>(nn,nm,c);
+ fonctions[MED_TRIA6 ]=new Calcul_Interpolation_Tria6 <_PARAM_>(nn,nm,c);
+ fonctions[MED_QUAD4 ]=new Calcul_Interpolation_Quad4 <_PARAM_>(nn,nm,c);
+ fonctions[MED_QUAD8 ]=new Calcul_Interpolation_Quad8 <_PARAM_>(nn,nm,c);
+ fonctions[MED_TETRA4 ]=new Calcul_Interpolation_Tetra4 <_PARAM_>(nn,nm,c);
+ fonctions[MED_TETRA10]=new Calcul_Interpolation_Tetra10<_PARAM_>(nn,nm,c);
+ fonctions[MED_HEXA8 ]=new Calcul_Interpolation_Hexa8 <_PARAM_>(nn,nm,c);
+ fonctions[MED_HEXA20 ]=new Calcul_Interpolation_Hexa20 <_PARAM_>(nn,nm,c);
+ fonctions[MED_PENTA6 ]=new Calcul_Interpolation_Penta6 <_PARAM_>(nn,nm,c);
+ fonctions[MED_PENTA15]=new Calcul_Interpolation_Penta15<_PARAM_>(nn,nm,c);
+ fonctions[MED_PYRA5 ]=new Calcul_Interpolation_Pyra5 <_PARAM_>(nn,nm,c);
+ fonctions[MED_PYRA13 ]=new Calcul_Interpolation_Pyra13 <_PARAM_>(nn,nm,c);
+ }
+
+_TEMPLATE_ VALEURCHAMP Calcul_Hybride<_PARAM_>::operator() (const NOEUD & n, int num_maille)
+ {
+ return fonctions[mailles->DONNE_TYPE_MAILLE(num_maille)]->operator()(n,num_maille);
+ }
+
+_TEMPLATE_ class Calcul_Interpolation_P0 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_P0(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ return (*champ)[num_maille];
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Tria3 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Tria3(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ int num0=mailles->DONNE_SOMMET_MAILLE(num_maille,0);
+ int num1=mailles->DONNE_SOMMET_MAILLE(num_maille,1);
+ int num2=mailles->DONNE_SOMMET_MAILLE(num_maille,2);
+
+ double x0=(*noeuds)[num0][0];
+ double y0=(*noeuds)[num0][1];
+ double x1=(*noeuds)[num1][0];
+ double y1=(*noeuds)[num1][1];
+ double x2=(*noeuds)[num2][0];
+ double y2=(*noeuds)[num2][1];
+
+ VALEURCHAMP v0=(*champ)[num0];
+ VALEURCHAMP v1=(*champ)[num1];
+ VALEURCHAMP v2=(*champ)[num2];
+
+ double x=n[0];
+ double y=n[1];
+
+ double lambda0=(y1-y2)*x+(x2-x1)*y+(x1*y2-x2*y1);
+ double lambda1=(y2-y0)*x+(x0-x2)*y+(x2*y0-x0*y2);
+ double lambda2=(y0-y1)*x+(x1-x0)*y+(x0*y1-x1*y0);
+
+ double delta = (x2-x1)*y0+(x0-x2)*y1+(x1-x0)*y2;
+
+ VALEURCHAMP retour(v0.SIZE());
+
+ return (1/delta)*(lambda0*v0+lambda1*v1+lambda2*v2);
+
+ // return retour; //
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Tria6 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Tria6(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ // ON SUPPOSE IMPLICITEMENT QUE LES NOEUDS SUPPLEMENTAIRES SONT BIEN DES NOEUDS MILIEUX
+ int num0=mailles->DONNE_SOMMET_MAILLE(num_maille,0);
+ int num1=mailles->DONNE_SOMMET_MAILLE(num_maille,1);
+ int num2=mailles->DONNE_SOMMET_MAILLE(num_maille,2);
+ int num01=mailles->DONNE_SOMMET_MAILLE(num_maille,3);
+ int num12=mailles->DONNE_SOMMET_MAILLE(num_maille,4);
+ int num20=mailles->DONNE_SOMMET_MAILLE(num_maille,5);
+
+ double x0=(*noeuds)[num0][0];
+ double y0=(*noeuds)[num0][1];
+ double x1=(*noeuds)[num1][0];
+ double y1=(*noeuds)[num1][1];
+ double x2=(*noeuds)[num2][0];
+ double y2=(*noeuds)[num2][1];
+
+ VALEURCHAMP v0=(*champ)[num0];
+ VALEURCHAMP v1=(*champ)[num1];
+ VALEURCHAMP v2=(*champ)[num2];
+ VALEURCHAMP v01=(*champ)[num01];
+ VALEURCHAMP v12=(*champ)[num12];
+ VALEURCHAMP v20=(*champ)[num20];
+
+ double x=n[0];
+ double y=n[1];
+
+ double lambda0=(y1-y2)*x+(x2-x1)*y+(x1*y2-x2*y1);
+ double lambda1=(y2-y0)*x+(x0-x2)*y+(x2*y0-x0*y2);
+ double lambda2=(y0-y1)*x+(x1-x0)*y+(x0*y1-x1*y0);
+
+ double delta = (x2-x1)*y0+(x0-x2)*y1+(x1-x0)*y2;
+
+
+ // VALEURCHAMP retour(v0.SIZE()); //
+
+ return 2*(lambda0*lambda0*v0+
+ lambda1*lambda1*v1+
+ lambda2*lambda2*v2+
+ 2*(lambda0*lambda1*v01+
+ lambda1*lambda2*v12+
+ lambda2*lambda0*v20))/(delta*delta)+
+ (lambda0*v0+lambda1*v1+lambda2*v2)/(-delta);
+
+ // return retour; //
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Quad4 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Quad4(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ int num0=mailles->DONNE_SOMMET_MAILLE(num_maille,0);
+ int num1=mailles->DONNE_SOMMET_MAILLE(num_maille,1);
+ int num2=mailles->DONNE_SOMMET_MAILLE(num_maille,2);
+ int num3=mailles->DONNE_SOMMET_MAILLE(num_maille,3);
+
+ double x0=(*noeuds)[num0][0];
+ double y0=(*noeuds)[num0][1];
+ double x1=(*noeuds)[num1][0];
+ double y1=(*noeuds)[num1][1];
+ double x2=(*noeuds)[num2][0];
+ double y2=(*noeuds)[num2][1];
+ double x3=(*noeuds)[num3][0];
+ double y3=(*noeuds)[num3][1];
+
+ VALEURCHAMP v0=(*champ)[num0];
+ VALEURCHAMP v1=(*champ)[num1];
+ VALEURCHAMP v2=(*champ)[num2];
+ VALEURCHAMP v3=(*champ)[num3];
+
+ double x=n[0];
+ double y=n[1];
+
+
+ double mu0=-((x3*(y1-y2)+x1*(y2-y3)+x2*(y3-y1))*x*y+(x2*y2*(y1-y3)+x3*(-y1+y2)*y3+x1*y1*(y3-y2))*x+(x2*x3*(y2-y3)+x1*(x2*(y1-y2)+x3*(y3-y1)))*y+(x2*x3*y1*(y3-y2)+x1*(x3*y2*(y1-y3)+x2*(y2-y1)*y3)));
+ double mu1=(x0*(y2-y3)+x2*(y3-y0)+x3*(y0-y2))*x*y+(x3*y3*(y2-y0)+x0*(-y2+y3)*y0+x2*y2*(y0-y3))*x+(x3*x0*(y3-y0)+x2*(x3*(y2-y3)+x0*(y0-y2)))*y+(x2*x0*y2*(y0-y2)+x2*(x0*y2*(y2-y0)+x3*(y3-y2)*y0));
+ double mu2=-((x1*(y3-y0)+x3*(y0-y1)+x0*(y1-y3))*x*y+(x0*y0*(y3-y1)+x1*(-y3+y0)*y1+x3*y3*(y1-y0))*x+(x0*x1*(y0-y1)+x3*(x0*(y3-y0)+x1*(y1-y3)))*y+(x3*x1*y3*(y1-y2)+x3*(x1*y2*(y3-y1)+x0*(y0-y3)*y1)));
+ double mu3=(x2*(y0-y1)+x0*(y1-y2)+x1*(y2-y0))*x*y+(x1*y1*(y0-y2)+x2*(-y0+y1)*y2+x0*y0*(y2-y1))*x+(x1*x2*(y1-y2)+x0*(x1*(y0-y1)+x2*(y2-y0)))*y+(x0*x2*y0*(y2-y2)+x0*(x2*y2*(y0-y2)+x1*(y1-y0)*y2));
+
+ double delta=(y0-y2)*(y1-y3)*(x0*x2+x1*x3)-(x1*x2+x0*x3)*(y1-y2)*(y0-y3)-(x0*x1+x2*x3)*(y0-y1)*(y2-y3);
+
+ /*
+ cout<<" ### Pour ( "<<x<<" , "<<y<<" )"<<endl;
+ cout<<" ### delta = "<<delta<<endl;
+ cout<<" ### Mu0 = "<<mu0<<endl;
+ cout<<" ### Mu1 = "<<mu1<<endl;
+ cout<<" ### Mu2 = "<<mu2<<endl;
+ cout<<" ### Mu3 = "<<mu3<<endl;
+ //*/
+ // VALEURCHAMP retour(v0.SIZE()); //
+
+ return (mu0*v0+mu1*v1+mu2*v2+mu3*v3)/delta;
+
+ // return retour; //
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Quad8 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Quad8(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ cerr<<"Interpolation Q2 pas encore implémentée"<<endl;
+ exit(-1);
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Tetra4 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Tetra4(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ int num0=mailles->DONNE_SOMMET_MAILLE(num_maille,0);
+ int num1=mailles->DONNE_SOMMET_MAILLE(num_maille,1);
+ int num2=mailles->DONNE_SOMMET_MAILLE(num_maille,2);
+ int num3=mailles->DONNE_SOMMET_MAILLE(num_maille,3);
+
+ double x0=(*noeuds)[num0][0];
+ double y0=(*noeuds)[num0][1];
+ double z0=(*noeuds)[num0][2];
+ double x1=(*noeuds)[num1][0];
+ double y1=(*noeuds)[num1][1];
+ double z1=(*noeuds)[num1][2];
+ double x2=(*noeuds)[num2][0];
+ double y2=(*noeuds)[num2][1];
+ double z2=(*noeuds)[num2][2];
+ double x3=(*noeuds)[num3][0];
+ double y3=(*noeuds)[num3][1];
+ double z3=(*noeuds)[num3][2];
+
+ VALEURCHAMP v0=(*champ)[num0];
+ VALEURCHAMP v1=(*champ)[num1];
+ VALEURCHAMP v2=(*champ)[num2];
+ VALEURCHAMP v3=(*champ)[num3];
+
+ double x=n[0];
+ double y=n[1];
+ double z=n[2];
+
+ double lambda0=(y3*(z1-z2)+y1*(z2-z3)+y2*(z3-z1))*x+(x3*(z2-z1)+x2*(z1-z3)+x1*(z3-z2))*y+(x3*(y1-y2)+x1*(y2-y3)+x2*(y3-y1))*z+((x3*y2-x2*y3)*z1+(x1*y3-x3*y1)*z2+(x2*y1-x1*y2)*z3);
+ double lambda1=-((y0*(z2-z3)+y2*(z3-z0)+y3*(z0-z2))*x+(x0*(z3-z2)+x3*(z2-z0)+x2*(z0-z3))*y+(x0*(y2-y3)+x2*(y3-y0)+x3*(y0-y2))*z+((x0*y3-x2*y0)*z2+(x2*y0-x0*y2)*z3+(x3*y2-x2*y3)*z0));
+ double lambda2=(y1*(z3-z0)+y3*(z0-z1)+y0*(z1-z3))*x+(x1*(z0-z3)+x0*(z3-z1)+x3*(z1-z0))*y+(x1*(y3-y0)+x3*(y0-y1)+x0*(y1-y3))*z+((x1*y0-x2*y1)*z3+(x3*y1-x1*y3)*z0+(x0*y3-x3*y0)*z1);
+ double lambda3=-((y2*(z0-z1)+y0*(z1-z2)+y1*(z2-z0))*x+(x2*(z1-z0)+x1*(z0-z2)+x0*(z2-z1))*y+(x2*(y0-y1)+x0*(y1-y2)+x1*(y2-y0))*z+((x2*y1-x2*y2)*z0+(x0*y2-x2*y0)*z1+(x1*y0-x0*y1)*z2));
+
+ // A SIMPLFIFIER, FEIGNASSE !
+ double delta = (x1*y2-x1*y3)*z0 +(x0-y3- x0*y2)*z1 + x0*y3*z1 - x1*y0*z2 + x0*y1*z2 - x0*y3*z2 + x1*y3*z2 + x3*(y1*z0 - y2*z0 - y0*z1 + y2*z1 + y0*z2 - y1*z2) + x1*y0*z3 - x0*y1*z3 + x0*y2*z3 - x1*y2*z3 + x2*(y3*z0 + y0*z1 - y3*z1 - y0*z3 + y1*(-z0 + z3));
+
+ VALEURCHAMP retour(v0.SIZE()); //
+
+ retour=(lambda0*v0+lambda1*v1+lambda2*v2+lambda3*v3)/delta;
+
+ return retour; //
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Tetra10 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Tetra10(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ // ON SUPPOSE IMPLICITEMENT QUE LES NOEUDS SUPPLEMENTAIRES SONT BIEN DES NOEUDS MILIEUX
+ int num0=mailles->DONNE_SOMMET_MAILLE(num_maille,0);
+ int num1=mailles->DONNE_SOMMET_MAILLE(num_maille,1);
+ int num2=mailles->DONNE_SOMMET_MAILLE(num_maille,2);
+ int num3=mailles->DONNE_SOMMET_MAILLE(num_maille,3);
+ int num01=mailles->DONNE_SOMMET_MAILLE(num_maille,4);
+ int num02=mailles->DONNE_SOMMET_MAILLE(num_maille,6);
+ int num03=mailles->DONNE_SOMMET_MAILLE(num_maille,7);
+ int num12=mailles->DONNE_SOMMET_MAILLE(num_maille,5);
+ int num13=mailles->DONNE_SOMMET_MAILLE(num_maille,8);
+ int num23=mailles->DONNE_SOMMET_MAILLE(num_maille,9);
+
+ double x0=(*noeuds)[num0][0];
+ double y0=(*noeuds)[num0][1];
+ double z0=(*noeuds)[num0][2];
+ double x1=(*noeuds)[num1][0];
+ double y1=(*noeuds)[num1][1];
+ double z1=(*noeuds)[num1][2];
+ double x2=(*noeuds)[num2][0];
+ double y2=(*noeuds)[num2][1];
+ double z2=(*noeuds)[num2][2];
+ double x3=(*noeuds)[num3][0];
+ double y3=(*noeuds)[num3][1];
+ double z3=(*noeuds)[num3][2];
+
+ VALEURCHAMP v0=(*champ)[num0];
+ VALEURCHAMP v1=(*champ)[num1];
+ VALEURCHAMP v2=(*champ)[num2];
+ VALEURCHAMP v3=(*champ)[num3];
+ VALEURCHAMP v01=(*champ)[num01];
+ VALEURCHAMP v02=(*champ)[num02];
+ VALEURCHAMP v03=(*champ)[num03];
+ VALEURCHAMP v12=(*champ)[num12];
+ VALEURCHAMP v13=(*champ)[num13];
+ VALEURCHAMP v23=(*champ)[num23];
+
+ double x=n[0];
+ double y=n[1];
+ double z=n[2];
+
+ double lambda0=(y3*(z1-z2)+y1*(z2-z3)+y2*(z3-z1))*x+(x3*(z2-z1)+x2*(z1-z3)+x1*(z3-z2))*y+(x3*(y1-y2)+x1*(y2-y3)+x2*(y3-y1))*z+((x3*y2-x2*y3)*z1+(x1*y3-x3*y1)*z2+(x2*y1-x1*y2)*z3);
+ double lambda1=-((y0*(z2-z3)+y2*(z3-z0)+y3*(z0-z2))*x+(x0*(z3-z2)+x3*(z2-z0)+x2*(z0-z3))*y+(x0*(y2-y3)+x2*(y3-y0)+x3*(y0-y2))*z+((x0*y3-x2*y0)*z2+(x2*y0-x0*y2)*z3+(x3*y2-x2*y3)*z0));
+ double lambda2=(y1*(z3-z0)+y3*(z0-z1)+y0*(z1-z3))*x+(x1*(z0-z3)+x0*(z3-z1)+x3*(z1-z0))*y+(x1*(y3-y0)+x3*(y0-y1)+x0*(y1-y3))*z+((x1*y0-x2*y1)*z3+(x3*y1-x1*y3)*z0+(x0*y3-x3*y0)*z1);
+ double lambda3=-((y2*(z0-z1)+y0*(z1-z2)+y1*(z2-z0))*x+(x2*(z1-z0)+x1*(z0-z2)+x0*(z2-z1))*y+(x2*(y0-y1)+x0*(y1-y2)+x1*(y2-y0))*z+((x2*y1-x2*y2)*z0+(x0*y2-x2*y0)*z1+(x1*y0-x0*y1)*z2));
+
+
+ // A SIMPLFIFIER, FEIGNASSE !
+ double delta = (x1*y2-x1*y3)*z0 +(x0-y3- x0*y2)*z1 + x0*y3*z1 - x1*y0*z2 + x0*y1*z2 - x0*y3*z2 + x1*y3*z2 + x3*(y1*z0 - y2*z0 - y0*z1 + y2*z1 + y0*z2 - y1*z2) + x1*y0*z3 - x0*y1*z3 + x0*y2*z3 - x1*y2*z3 + x2*(y3*z0 + y0*z1 - y3*z1 - y0*z3 + y1*(-z0 + z3));
+
+ /*
+ cout<<" ### Pour ( "<<x<<" , "<<y<<" , "<<z<<" )"<<endl;
+ cout<<" ### delta = "<<delta<<endl;
+ cout<<" ### Lambda0 = "<<lambda0<<endl;
+ cout<<" ### Lambda1 = "<<lambda1<<endl;
+ cout<<" ### Lambda2 = "<<lambda2<<endl;
+ cout<<" ### Lambda3 = "<<lambda3<<endl;
+ //*/
+
+ VALEURCHAMP retour(v0.SIZE()); //
+
+ retour=2*(lambda0*lambda0*v0+
+ lambda1*lambda1*v1+
+ lambda2*lambda2*v2+
+ lambda3*lambda3*v3+
+ 2*(lambda0*lambda1*v01+
+ lambda0*lambda2*v02+
+ lambda0*lambda3*v03+
+ lambda1*lambda2*v12+
+ lambda1*lambda3*v13+
+ lambda2*lambda3*v23))/(delta*delta)+
+ (lambda0*v0+lambda1*v1+lambda2*v2+lambda3*v3)/(-delta);
+
+ return retour; //
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Hexa8 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Hexa8(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+
+ int num0=mailles->DONNE_SOMMET_MAILLE(num_maille,0);
+ int num1=mailles->DONNE_SOMMET_MAILLE(num_maille,1);
+ int num2=mailles->DONNE_SOMMET_MAILLE(num_maille,2);
+ int num3=mailles->DONNE_SOMMET_MAILLE(num_maille,3);
+ int num4=mailles->DONNE_SOMMET_MAILLE(num_maille,4);
+ int num5=mailles->DONNE_SOMMET_MAILLE(num_maille,5);
+ int num6=mailles->DONNE_SOMMET_MAILLE(num_maille,6);
+ int num7=mailles->DONNE_SOMMET_MAILLE(num_maille,7);
+
+
+ double x0=(*noeuds)[num0][0];double y0=(*noeuds)[num0][1];double z0=(*noeuds)[num0][2];
+ double x1=(*noeuds)[num1][0];double y1=(*noeuds)[num1][1];double z1=(*noeuds)[num1][2];
+ double x2=(*noeuds)[num2][0];double y2=(*noeuds)[num2][1];double z2=(*noeuds)[num2][2];
+ double x3=(*noeuds)[num3][0];double y3=(*noeuds)[num3][1];double z3=(*noeuds)[num3][2];
+ double x4=(*noeuds)[num4][0];double y4=(*noeuds)[num4][1];double z4=(*noeuds)[num4][2];
+ double x5=(*noeuds)[num5][0];double y5=(*noeuds)[num5][1];double z5=(*noeuds)[num5][2];
+ double x6=(*noeuds)[num6][0];double y6=(*noeuds)[num6][1];double z6=(*noeuds)[num6][2];
+ double x7=(*noeuds)[num7][0];double y7=(*noeuds)[num7][1];double z7=(*noeuds)[num7][2];
+
+
+ VALEURCHAMP v0=(*champ)[num0];
+ VALEURCHAMP v1=(*champ)[num1];
+ VALEURCHAMP v2=(*champ)[num2];
+ VALEURCHAMP v3=(*champ)[num3];
+ VALEURCHAMP v4=(*champ)[num4];
+ VALEURCHAMP v5=(*champ)[num5];
+ VALEURCHAMP v6=(*champ)[num6];
+ VALEURCHAMP v7=(*champ)[num7];
+
+ double x=n[0];
+ double y=n[1];
+ double z=n[2];
+
+
+ // double face2367(double x,double y,double z) {return (x6*(-y2 + y3) + x3*(y2 - y6) + x2*(-y3 + y6))*z - x6*y3*z2 + x3*y6*z2 + x6*y2*z3 - x2*y6*z3 - x3*y2*z6 + x2*y3*z6 + y*(x6*(z2 - z3) + x2*(z3 - z6) + x3*(-z2 + z6)) + x*(y6*(-z2 + z3) + y3*(z2 - z6) + y2*(-z3 + z6));}
+ // double face4567(double x,double y,double z) {return (x6*(-y4 + y5) + x5*(y4 - y6) + x4*(-y5 + y6))*z - x6*y5*z4 + x5*y6*z4 + x6*y4*z5 - x4*y6*z5 - x5*y4*z6 + x4*y5*z6 + y*(x6*(z4 - z5) + x4*(z5 - z6) + x5*(-z4 + z6)) + x*(y6*(-z4 + z5) + y5*(z4 - z6) + y4*(-z5 + z6));}
+ // double face1256(double x,double y,double z) {return (x5*(-y1 + y2) + x2*(y1 - y5) + x1*(-y2 + y5))*z - x5*y2*z1 + x2*y5*z1 + x5*y1*z2 - x1*y5*z2 - x2*y1*z5 + x1*y2*z5 + y*(x5*(z1 - z2) + x1*(z2 - z5) + x2*(-z1 + z5)) + x*(y5*(-z1 + z2) + y2*(z1 - z5) + y1*(-z2 + z5));}
+ // double face0347(double x,double y,double z) {return (x4*(-y0 + y3) + x3*(y0 - y4) + x0*(-y3 + y4))*z - x4*y3*z0 + x3*y4*z0 + x4*y0*z3 - x0*y4*z3 - x3*y0*z4 + x0*y3*z4 + y*(x4*(z0 - z3) + x0*(z3 - z4) + x3*(-z0 + z4)) + x*(y4*(-z0 + z3) + y3*(z0 - z4) + y0*(-z3 + z4));}
+ // double face0145(double x,double y,double z) {return (x4*(-y0 + y1) + x1*(y0 - y4) + x0*(-y1 + y4))*z - x4*y1*z0 + x1*y4*z0 + x4*y0*z1 - x0*y4*z1 - x1*y0*z4 + x0*y1*z4 + y*(x4*(z0 - z1) + x0*(z1 - z4) + x1*(-z0 + z4)) + x*(y4*(-z0 + z1) + y1*(z0 - z4) + y0*(-z1 + z4));}
+ // double face0123(double x,double y,double z) {return (x2*(-y0 + y1) + x1*(y0 - y2) + x0*(-y1 + y2))*z - x2*y1*z0 + x1*y2*z0 + x2*y0*z1 - x0*y2*z1 - x1*y0*z2 + x0*y1*z2 + y*(x2*(z0 - z1) + x0*(z1 - z2) + x1*(-z0 + z2)) + x*(y2*(-z0 + z1) + y1*(z0 - z2) + y0*(-z1 + z2));}
+
+ double mu0=face1256(x,y,z)*face2367(x,y,z)*face4567(x,y,z)/(face1256(x0,y0,z0)*face2367(x0,y0,z0)*face4567(x0,y0,z0));
+ double mu1=face0347(x,y,z)*face2367(x,y,z)*face4567(x,y,z)/(face0347(x1,y1,z1)*face2367(x1,y1,z1)*face4567(x1,y1,z1));
+ double mu2=face0347(x,y,z)*face0145(x,y,z)*face4567(x,y,z)/(face0347(x2,y2,z2)*face0145(x2,y2,z2)*face4567(x2,y2,z2));
+ double mu3=face1256(x,y,z)*face0145(x,y,z)*face4567(x,y,z)/(face1256(x3,y3,z3)*face0145(x3,y3,z3)*face4567(x3,y3,z3));
+ double mu4=face1256(x,y,z)*face2367(x,y,z)*face0123(x,y,z)/(face1256(x4,y4,z4)*face2367(x4,y4,z4)*face0123(x4,y4,z4));
+ double mu5=face0347(x,y,z)*face2367(x,y,z)*face0123(x,y,z)/(face0347(x5,y5,z5)*face2367(x5,y5,z5)*face0123(x5,y5,z5));
+ double mu6=face0347(x,y,z)*face0145(x,y,z)*face0123(x,y,z)/(face0347(x6,y6,z6)*face0145(x6,y6,z6)*face0123(x6,y6,z6));
+ double mu7=face1256(x,y,z)*face0145(x,y,z)*face0123(x,y,z)/(face1256(x7,y7,z7)*face0145(x7,y7,z7)*face0123(x7,y7,z7));
+
+ VALEURCHAMP retour(v0.SIZE()); //
+
+ retour=(mu0*v0+mu1*v1+mu2*v2+mu3*v3+mu4*v4+mu5*v5+mu6*v6+mu7*v7);
+
+ return retour; //
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Hexa20 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Hexa20(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ cerr<<"Interpolation H2 pasencore implémentée"<<endl;
+ exit(-1);
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Penta6 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Penta6(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ cerr<<"Interpolation Pe1 pasencore implémentée"<<endl;
+ exit(-1);
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Penta15 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Penta15(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ cerr<<"Interpolation Pe2 pasencore implémentée"<<endl;
+ exit(-1);
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Pyra5 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Pyra5(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ cerr<<"Interpolation Py1 pasencore implémentée"<<endl;
+ exit(-1);
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Pyra13 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Pyra13(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ cerr<<"Interpolation Py2 pasencore implémentée"<<endl;
+ exit(-1);
+ }
+};
+
+#undef _TEMPLATE_
+#undef _PARAM_
+
+#endif
--- /dev/null
+#ifndef MEDMEM_MAPPING_HXX
+#define MEDMEM_MAPPING_HXX
+
+#include "MEDMEM_MappingTools.hxx"
+#include "MEDMEM_dTree.hxx"
+
+#define NBR_MAX_MAILLES_EXAMINEES 100
+
+#ifndef NBR_FACES_MAX
+#define NBR_FACES_MAX 6
+#endif
+
+#define _TEMPLATE_ template <class MAILLAGE, class NUAGEMAILLE, class NUAGENOEUD, class NOEUD, int DIMENSION>
+#define _MAPPING_ Mapping<MAILLAGE,NUAGEMAILLE,NUAGENOEUD,NOEUD,DIMENSION>
+
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Classe Mapping */
+/* */
+/*********************************************************/
+
+// ATTENTION LE NUAGE DE NOEUD EST SUPPOSE NON REDONDANT ET AUCUNE VERIFICATION N'EST FAITE !
+
+template <class MAILLAGE, class NUAGEMAILLE, class NUAGENOEUD, class NOEUD, int DIMENSION> class Mapping
+{
+protected :
+ MAILLAGE * maillage_back;
+ NUAGEMAILLE * mailles_back;
+ NUAGENOEUD * noeuds_back;
+ NUAGENOEUD * noeuds_front;
+ Coordonnees_Barycentriques<NUAGEMAILLE,NUAGENOEUD,NOEUD,DIMENSION> * CB;
+ dTree<NOEUD,NUAGENOEUD,DIMENSION> * my_dTree;
+ vector<int> resultat_mapping;
+ vector<int> point_le_plus_proche;
+
+public :
+
+ Mapping():maillage_back(NULL),mailles_back(NULL),noeuds_back(NULL),noeuds_front(NULL),CB(NULL),my_dTree(NULL) {}
+ Mapping(MAILLAGE * mb,NUAGENOEUD * nb,NUAGENOEUD * nf); // le dTree est crée à l'initialisation, par contre, le mapping lui meme doit etre invoqué
+ ~Mapping() {if (CB) delete CB;if (my_dTree) delete my_dTree;}
+ dTree<NOEUD,NUAGENOEUD,DIMENSION> * Donne_dTree() {return my_dTree;}
+ int Donne_Directions(int num_maille,const NOEUD &n,int etat_face[NBR_FACES_MAX]);
+ // Méthode interne de localisation
+ int Trouve_Maille_Contenant_Point_Mth_Co(const NOEUD &n,int num_maille,int num_maille_interdit,int max_loop,int &nbr_mailles_examinees,int flag_convexe);
+ void Cree_Mapping(int flag_convexe=0); // SUPPOSE NON CONVEXE PAR DEFAUT
+ void Cree_Mapping(NUAGENOEUD * nf, int flag_convexe=0); // SUPPOSE NON CONVEXE PAR DEFAUT
+ inline int operator[](int i) const {return resultat_mapping[i];} // Renvoie la valeur mappé, si le mapping a été fait, sinon, n'importe quoi
+ inline vector<int> Get_Mapping() {return resultat_mapping;} // Renvoie le vector contenant le mapping
+ inline int Get_Noeud_Le_Plus_Proche(int i) const {return point_le_plus_proche[i];} // Invoque la méthode de d-Tree qui donne le noeud le plus proche
+ inline int Exist_dTree() const {return (my_dTree);} // Teste si le dTree existe
+};
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// CODE ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+_TEMPLATE_ void _MAPPING_::Cree_Mapping(NUAGENOEUD * nf, int flag_convexe)
+ {
+ noeuds_front=nf;
+ Cree_Mapping(flag_convexe);
+ }
+
+_TEMPLATE_ void _MAPPING_::Cree_Mapping(int flag_convexe)
+ {
+ if (!noeuds_front)
+ {
+ cerr<<"Mapping : Pas de noeuds à mapper !"<<endl;
+ exit(-1);
+ }
+
+ int i,j,k;
+ int nbr_noeuds=noeuds_front->SIZE();
+ int num_maille_depart;
+ int nma=0;
+ resultat_mapping = vector<int>(nbr_noeuds,UNDEFINED);
+ point_le_plus_proche = vector<int>(nbr_noeuds,UNDEFINED);
+ noeuds_back->affiche();
+
+ for (i=0;i<nbr_noeuds;i++)
+ {
+ point_le_plus_proche[i]=my_dTree->trouve_plus_proche_point((*noeuds_front)[i]);
+ num_maille_depart=maillage_back->DONNE_PREMIERE_MAILLE_CONTENANT(point_le_plus_proche[i]);
+ resultat_mapping[i]=Trouve_Maille_Contenant_Point_Mth_Co((*noeuds_front)[i],num_maille_depart,num_maille_depart,NBR_MAX_MAILLES_EXAMINEES,nma,flag_convexe);
+ }
+ }
+_TEMPLATE_ _MAPPING_::Mapping(MAILLAGE * mb,NUAGENOEUD * nb,NUAGENOEUD * nf):maillage_back(mb),noeuds_back(nb),noeuds_front(nf),my_dTree(NULL)
+ {
+
+ if (!maillage_back)
+ {
+ cerr<<"Mapping : constructeur appelé avec Maillage Vide"<<endl;
+ exit(-1);
+ }
+
+ if (!noeuds_back)
+ {
+ cerr<<"Mapping : constructeur appelé avec Nuage Noeuds Vide"<<endl;
+ exit(-1);
+ }
+
+ mailles_back=maillage_back->DONNE_POINTEUR_NUAGEMAILLE();
+
+ CB=new Coordonnees_Barycentriques<NUAGEMAILLE,NUAGENOEUD,NOEUD,DIMENSION>(mailles_back,noeuds_back);
+
+ cout<<"MAPPING : VERIFICATION REDONDANCES DANS NUAGE NOEUD BACK"<<endl;
+
+ int i,j;
+
+ int nnb=noeuds_back->SIZE();
+
+ vector<int> redondance(nnb,0);
+
+ for (i=0;i<nnb;i++)
+ {
+ for (j=i+1;j<nnb;j++) if ((*noeuds_back)[i]==(*noeuds_back)[j])
+ {
+ cerr<<"Le Noeud "<<j<<" est identique au Noeud "<<i<<endl;
+ exit(-1);
+ }
+ }
+
+ cout<<"MAPPING : FIN VERIFICATION"<<endl;
+
+ my_dTree=new dTree<NOEUD,NUAGENOEUD,DIMENSION>(noeuds_back);
+
+
+ }
+// Renvoie :
+// 1 si le point est intérieur
+// -1 si le point est extérieur à la maille via uniquement des faces qui ne sont pas au bord
+// -2 si le point est extérieur à la maille par au moins une face de bord
+// Et modifie etat_face de telle sorte que :
+// etat_face[i] = -1 s'il n'existe pas de voisin via la face i
+// etat_face[i] = 0 si le point est intérieur via la face i et que le voisin i existe
+// etat_face[i] = 1 si le point est extérieur via la face i et que le voisin i existe
+_TEMPLATE_ int _MAPPING_::Donne_Directions(int num_maille,const NOEUD &n,int etat_face[NBR_FACES_MAX])
+ {
+ vector<double> ef=CB->Donne_Pseudo_Coord_Baryc(num_maille,n);
+ int etat_int=VRAI;
+ int etat_ext_bord=FAUX;
+ int tf,tv,tb;
+ int nbr_faces=mailles_back->DONNE_NBR_FACES(num_maille);
+ for (int i=0;i<nbr_faces;i++)
+ {
+ tf=(ef[i]<0);
+ tv=(maillage_back->DONNE_VOISIN_DE_MAILLE(num_maille,i)==UNDEFINED);
+ tb=(maillage_back->EST_AU_BORD_FACE_DE_MAILLE(num_maille,i));
+ if (tf)
+ {
+ etat_int=FAUX;
+ if (tb) etat_ext_bord=VRAI;
+ }
+ if (tv) etat_face[i]=-1;
+ else
+ {
+ if (tf) etat_face[i]=1;
+ else etat_face[i]=0;
+ }
+ }
+ if (etat_int) return 1;
+ if (etat_ext_bord) return -2;
+ return -1;
+ }
+_TEMPLATE_ int _MAPPING_::Trouve_Maille_Contenant_Point_Mth_Co(const NOEUD &n,int num_maille,int num_maille_interdit,int max_loop,int &nbr_mailles_examinees,int flag_convexe)
+ {
+
+ int etat_face[NBR_FACES_MAX];
+ int i,tmp,nbr_rnd;
+ int indirection[NBR_FACES_MAX];
+ int ind_reel;
+ int num_reel;
+ int new_num=UNDEFINED;
+
+ int test=Donne_Directions(num_maille,n,etat_face);
+
+ int nbr_faces=maillage_back->DONNE_NBR_FACES_MAILLE(num_maille);
+
+ for (i=0;i<nbr_faces;i++) indirection[i]=i;
+
+ nbr_mailles_examinees=0;
+
+ while (nbr_mailles_examinees<max_loop)
+ {
+ if (test==1)
+ {
+ return num_maille;
+ }
+ if ((test==-2)&&(flag_convexe))
+ {
+ return 2*UNDEFINED;
+ }
+ nbr_mailles_examinees++;
+ for (i=0;i<nbr_faces;i++)
+ {
+ tmp=indirection[i];
+ nbr_rnd=rand()%nbr_faces;
+ indirection[i]=indirection[nbr_rnd];
+ indirection[nbr_rnd]=tmp;
+ }
+ for (i=0;(i<nbr_faces)&&(new_num==UNDEFINED);i++)
+ {
+ ind_reel=indirection[i];
+ num_reel=maillage_back->DONNE_VOISIN_DE_MAILLE(num_maille,ind_reel);
+ if ((etat_face[ind_reel]==1)&&(num_reel!=num_maille_interdit))
+ {
+ new_num=num_reel;
+ }
+ }
+ for (i=0;(i<nbr_faces)&&(new_num==UNDEFINED);i++)
+ {
+ ind_reel=indirection[i];
+ num_reel=maillage_back->DONNE_VOISIN_DE_MAILLE(num_maille,ind_reel);
+ if ((etat_face[ind_reel]==0)&&(num_reel!=num_maille_interdit))
+ {
+ new_num=num_reel;
+ }
+ }
+ if (new_num==UNDEFINED)
+ {
+ new_num=num_maille_interdit;
+ }
+ num_maille_interdit=num_maille;
+ num_maille=new_num;
+ new_num=UNDEFINED;
+ test=Donne_Directions(num_maille,n,etat_face);
+ }
+ return UNDEFINED;
+ }
+
+#undef _TEMPLATE_
+#undef _MAPPING_
+
+#endif
--- /dev/null
+#ifndef COORDONNEES_BARYCENTRIQUES_HPP
+#define COORDONNEES_BARYCENTRIQUES_HPP
+
+// DECLARATIONS
+
+#define _TEMPL_SPE_ template <class NUAGEMAILLE, class NUAGENOEUD, class NOEUD>
+#define _COORDBARYC_ Coordonnees_Barycentriques<NUAGEMAILLE,NUAGENOEUD,NOEUD,DIMENSION>
+#define _COORDBARY_2D_ Coordonnees_Barycentriques<NUAGEMAILLE,NUAGENOEUD,NOEUD,2>
+#define _COORDBARY_3D_ Coordonnees_Barycentriques<NUAGEMAILLE,NUAGENOEUD,NOEUD,3>
+
+template <class NUAGEMAILLE, class NUAGENOEUD, class NOEUD, int DIMENSION> class Coordonnees_Barycentriques
+{
+// TEMPLATE GENERIQUE VIDE OBLIGE DE PASSER PAR UNE SPECIALISATION
+};
+
+_TEMPL_SPE_ class _COORDBARY_2D_
+{
+protected :
+ NUAGEMAILLE * mailles;
+ NUAGENOEUD * sommets;
+
+ vector<int> etat_coord_baryc;
+ vector< vector< vector<double> > > coord_baryc;
+
+public :
+
+ Coordonnees_Barycentriques():mailles(NULL),sommets(NULL) {}
+ Coordonnees_Barycentriques(NUAGEMAILLE * m, NUAGENOEUD *n);
+ ~Coordonnees_Barycentriques() {}
+ vector<double> Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M);
+ vector<double> Calcule_Base_Coord_Baryc(const vector<int> &simplexe_base);
+ vector<double> Calcule_Coord_Baryc(int num_maille, const NOEUD & M);
+};
+
+_TEMPL_SPE_ class _COORDBARY_3D_
+{
+protected :
+ NUAGEMAILLE * mailles;
+ NUAGENOEUD * sommets;
+
+ vector<int> etat_coord_baryc;
+ vector< vector< vector<double> > > coord_baryc;
+
+public :
+
+ Coordonnees_Barycentriques():mailles(NULL),sommets(NULL) {}
+ Coordonnees_Barycentriques(NUAGEMAILLE * m, NUAGENOEUD *n);
+ ~Coordonnees_Barycentriques() {}
+ vector<double> Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M);
+ vector<double> Calcule_Base_Coord_Baryc(const vector<int> &simplexe_base);
+ vector<double> Calcule_Coord_Baryc(int num_maille, const NOEUD & M);
+};
+
+// CODE
+
+_TEMPL_SPE_ _COORDBARY_2D_::Coordonnees_Barycentriques(NUAGEMAILLE * m, NUAGENOEUD *n):mailles(m),sommets(n)
+ {
+ cout<<"Creation des Coordonnées Barycentriques : "<<flush;
+ int nbr_mailles=mailles->SIZE();
+ etat_coord_baryc=vector<int>(nbr_mailles,FAUX);
+ coord_baryc=vector< vector< vector<double> > >(nbr_mailles);
+ cout<<"OK ! "<<endl;
+ }
+
+_TEMPL_SPE_ vector<double> _COORDBARY_2D_::Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M)
+ {
+ int i,j,nbr_faces;
+ if (etat_coord_baryc[num_maille]==FAUX)
+ {
+ nbr_faces=mailles->DONNE_NBR_FACES(num_maille);
+
+ coord_baryc[num_maille]=vector< vector<double> >(nbr_faces);
+
+ for (i=0;i<nbr_faces;i++)
+ {
+ vector<int> simplexe_base=mailles->DONNE_SIMPLEXE_BASE(num_maille,i);
+ coord_baryc[num_maille][i]=Calcule_Base_Coord_Baryc(simplexe_base);
+ etat_coord_baryc[num_maille]=VRAI;
+ }
+ }
+ return Calcule_Coord_Baryc(num_maille,M);
+ }
+
+_TEMPL_SPE_ vector<double> _COORDBARY_2D_::Calcule_Base_Coord_Baryc(const vector<int> &simplexe_base)
+ {
+ const vector<int> &ref=simplexe_base;
+ vector<double> retour(3);
+ int i,j;
+
+ double x0=(*sommets)[ref[0]][0];
+ double y0=(*sommets)[ref[0]][1];
+ double x1=(*sommets)[ref[1]][0];
+ double y1=(*sommets)[ref[1]][1];
+ double x2=(*sommets)[ref[2]][0];
+ double y2=(*sommets)[ref[2]][1];
+
+ double delta=(x1*y2-x2*y1)+(x2*y0-x0*y2)+(x0*y1-x1*y0);
+
+ retour[0]=(y1-y2)/delta;
+ retour[1]=(x2-x1)/delta;
+ retour[2]=(x1*y2-x2*y1)/delta;
+
+ return retour;
+ }
+
+_TEMPL_SPE_ vector<double> _COORDBARY_2D_::Calcule_Coord_Baryc(int num_maille, const NOEUD & M)
+ {
+ int i,j;
+ vector<double> coord_baryc_M(3,0);
+ for (i=0;i<3;i++)
+ {
+ for (j=0;j<2;j++) coord_baryc_M[i]+=coord_baryc[num_maille][i][j]*M[j];
+ coord_baryc_M[i]+=coord_baryc[num_maille][i][2];
+ }
+ return coord_baryc_M;
+ }
+
+_TEMPL_SPE_ _COORDBARY_3D_::Coordonnees_Barycentriques(NUAGEMAILLE * m, NUAGENOEUD *n):mailles(m),sommets(n)
+ {
+ cout<<"Creation des Coordonnées Barycentriques : "<<flush;
+ int nbr_mailles=mailles->SIZE();
+ etat_coord_baryc=vector<int>(nbr_mailles,FAUX);
+ coord_baryc=vector< vector< vector<double> > >(nbr_mailles);
+ cout<<"OK ! "<<endl;
+ }
+
+_TEMPL_SPE_ vector<double> _COORDBARY_3D_::Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M)
+ {
+ int i,j,nbr_faces;
+ if (etat_coord_baryc[num_maille]==FAUX)
+ {
+ nbr_faces=mailles->DONNE_NBR_FACES(num_maille);
+
+ coord_baryc[num_maille]=vector< vector<double> >(nbr_faces);
+
+ for (i=0;i<nbr_faces;i++)
+ {
+ vector<int> simplexe_base=mailles->DONNE_SIMPLEXE_BASE(num_maille,i);
+ coord_baryc[num_maille][i]=Calcule_Base_Coord_Baryc(simplexe_base);
+ etat_coord_baryc[num_maille]=VRAI;
+ }
+ }
+ return Calcule_Coord_Baryc(num_maille,M);
+ }
+
+
+_TEMPL_SPE_ vector<double> _COORDBARY_3D_::Calcule_Base_Coord_Baryc(const vector<int> &simplexe_base)
+ {
+ const vector<int> &ref=simplexe_base;
+ vector<double> retour(4);
+ int i,j;
+
+ double x0=(*sommets)[ref[0]][0];
+ double y0=(*sommets)[ref[0]][1];
+ double z0=(*sommets)[ref[0]][2];
+ double x1=(*sommets)[ref[1]][0];
+ double y1=(*sommets)[ref[1]][1];
+ double z1=(*sommets)[ref[1]][2];
+ double x2=(*sommets)[ref[2]][0];
+ double y2=(*sommets)[ref[2]][1];
+ double z2=(*sommets)[ref[2]][2];
+ double x3=(*sommets)[ref[3]][0];
+ double y3=(*sommets)[ref[3]][1];
+ double z3=(*sommets)[ref[3]][2];
+
+ double delta1=((y2-y1)*(z3-z1)-(z2-z1)*(y3-y1));
+ double delta2=((x3-x1)*(z2-z1)-(x2-x1)*(z3-z1));
+ double delta3=((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1));
+
+ double delta=delta1*(x0-x1)+delta2*(y0-y1)+delta3*(z0-z1);
+
+ retour[0]=delta1/delta;
+ retour[1]=delta2/delta;
+ retour[2]=delta3/delta;
+ retour[3]=-(delta1*x1+delta2*y1+delta3*z1)/delta;
+
+ return retour;
+ }
+
+_TEMPL_SPE_ vector<double> _COORDBARY_3D_::Calcule_Coord_Baryc(int num_maille, const NOEUD & M)
+ {
+ int i,j;
+ int nbr_faces=coord_baryc[num_maille].size();
+ vector<double> coord_baryc_M(nbr_faces,0);
+ for (i=0;i<nbr_faces;i++)
+ {
+ for (j=0;j<3;j++) coord_baryc_M[i]+=coord_baryc[num_maille][i][j]*M[j];
+ coord_baryc_M[i]+=coord_baryc[num_maille][i][3];
+ }
+ return coord_baryc_M;
+ }
+
+//*/
+
+#undef _TEMPLATE_SPE_ template <class NUAGEMAILLE, class NUAGENOEUD, class NOEUD, int DIMENSION>
+#undef _COORDBARYC_2D_ Coordonnees_Barycentriques<NUAGEMAILLE,NUAGENOEUD,NOEUD,2>
+#undef _COORDBARYC_3D_ Coordonnees_Barycentriques<NUAGEMAILLE,NUAGENOEUD,NOEUD,3>
+
+#endif
--- /dev/null
+#ifndef WRAPPERS_CELLS_HXX
+#define WRAPPERS_CELLS_HXX
+
+#include "stdio.h"
+#include "stdlib.h"
+
+#include <typeinfo>
+
+#include <vector>
+#include <map>
+
+#ifndef FAUX
+#define FAUX 0
+#endif
+
+#ifndef VRAI
+#define VRAI 1
+#endif
+
+#ifndef UNDEFINED
+#define UNDEFINED -1
+#endif
+
+#include "MEDMEM_define.hxx"
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Fonction Comparaison_Informe(...) */
+/* */
+/*********************************************************/
+
+int Comparaison_Informe(const vector<int> &v1,const vector<int> &v2);
+
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille */
+/* */
+/*********************************************************/
+
+// REMARQUE : A REFAIRE COMPLETEMENT !
+
+class Wrapper_Maille
+{
+protected :
+ int * sommets;
+public :
+ Wrapper_Maille():sommets(NULL) {}
+ ~Wrapper_Maille() {}
+ inline const Wrapper_Maille & positionne(int * pos){sommets=pos;return *this;}
+ inline int operator[](int i) const {return sommets[i];}
+ virtual int DONNE_NBR_NOEUDS() const {cerr<<"APPEL D'UNE FONCTION VIRTUELLE DE LA CLASSE MERE WRAPPER_MAILLE => EXIT"<<endl;exit(-1);}
+ virtual int DONNE_NBR_FACES() const {cerr<<"APPEL D'UNE FONCTION VIRTUELLE DE LA CLASSE MERE WRAPPER_MAILLE => EXIT"<<endl;exit(-1);}
+ virtual vector<int> DONNE_SIMPLEXE_BASE(int num_face) const {cerr<<"APPEL D'UNE FONCTION VIRTUELLE DE LA CLASSE MERE WRAPPER_MAILLE => EXIT"<<endl;exit(-1);}
+ virtual vector<int> DONNE_FACE(int num_face) const {cerr<<"APPEL D'UNE FONCTION VIRTUELLE DE LA CLASSE MERE WRAPPER_MAILLE => EXIT"<<endl;exit(-1);}
+ virtual int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const {cerr<<"APPEL D'UNE FONCTION VIRTUELLE DE LA CLASSE MERE WRAPPER_MAILLE => EXIT"<<endl;exit(-1);}
+};
+
+/*********************************************************/
+/* */
+/* Dérivées de Wrapper_Maille */
+/* */
+/*********************************************************/
+
+// class Wrapper_Maille_Seg2 ; // public Wrapper_Maille;
+// class Wrapper_Maille_Seg3 ; // public Wrapper_Maille;
+class Wrapper_Maille_Tria3 ; // public Wrapper_Maille;
+class Wrapper_Maille_Tria6 ; // public Wrapper_Maille;
+class Wrapper_Maille_Quad4 ; // public Wrapper_Maille;
+class Wrapper_Maille_Quad8 ; // public Wrapper_Maille;
+class Wrapper_Maille_Tetra4 ; // public Wrapper_Maille;
+class Wrapper_Maille_Tetra10 ; // public Wrapper_Maille;
+class Wrapper_Maille_Hexa8 ; // public Wrapper_Maille;
+class Wrapper_Maille_Hexa20 ; // public Wrapper_Maille;
+class Wrapper_Maille_Pyra5 ; // public Wrapper_Maille;
+class Wrapper_Maille_Pyra13 ; // public Wrapper_Maille;
+class Wrapper_Maille_Penta6 ; // public Wrapper_Maille;
+class Wrapper_Maille_Penta15 ; // public Wrapper_Maille;
+
+/*********************************************************/
+/* */
+/* Classe Type_Wrapper_Maille */
+/* */
+/*********************************************************/
+
+// Permet de switcher en fonction du type de maille
+
+class Type_Wrapper_Maille
+{
+protected :
+ map<int,Wrapper_Maille *> contenu;
+public :
+ ~Type_Wrapper_Maille();
+ Type_Wrapper_Maille();
+ inline Wrapper_Maille * operator[] (int i) {return contenu[i];}
+};
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Nuage_Maille */
+/* */
+/*********************************************************/
+
+template <class FORME_SKYLINE> class Wrapper_Nuage_Maille
+{
+protected :
+ FORME_SKYLINE * mailles;
+ Type_Wrapper_Maille show;
+ int nbr_mailles;
+ vector<int> types;
+ vector< int* > premier_pointeur;
+public :
+ Wrapper_Nuage_Maille():mailles(NULL) {}
+ Wrapper_Nuage_Maille(FORME_SKYLINE * fs);
+ ~Wrapper_Nuage_Maille() {}
+ // Méthodes de la politique
+ inline const Wrapper_Maille & operator[](int i);
+ inline int SIZE() {return nbr_mailles;}
+ inline int DONNE_NBR_FACES(int num_maille);
+ inline int DONNE_NBR_NOEUDS(int num_maille);
+ inline vector<int> DONNE_SIMPLEXE_BASE(int num_maille,int num_face);
+ inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_maille,int num_face_loc);
+ inline vector<int> DONNE_FACE(int num_maille,int num_local_formant);
+ inline int DONNE_NUM_LOC_FACE_EGALE_A_FORMANT(int num_maille_sec,const vector<int> &sommets_face);
+ inline int DONNE_SOMMET_MAILLE(int num_maille,int num_som);
+ inline int DONNE_TYPE_MAILLE(int num_maille) {return mailles->DONNE_TYPE_MAILLE(num_maille);}
+};
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// CODE ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Fonction Comparaison_Informe(...) */
+/* */
+/*********************************************************/
+
+int Comparaison_Informe(const vector<int> &v1,const vector<int> &v2)
+ {
+ int s1=v1.size();
+ int s2=v2.size();
+ if (s1!=s2) return FAUX;
+ int i1,i2;
+ int test;
+ for (i1=0;i1<s1;i1++)
+ {
+ test=1;
+ for (i2=0;(i2<s2)&&(test);i2++)
+ {
+ if (v1[i1]==v2[i2]) test=0;
+ }
+ if (test) return FAUX;
+ }
+ return VRAI;
+ }
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Nuage_Maille */
+/* */
+/*********************************************************/
+
+template <class FORME_SKYLINE> Wrapper_Nuage_Maille<FORME_SKYLINE>::Wrapper_Nuage_Maille(FORME_SKYLINE * fs):mailles(fs)
+ {
+ int i;
+ nbr_mailles=mailles->SIZE();
+ types.resize(nbr_mailles);
+ premier_pointeur.resize(nbr_mailles);
+ for (i=0;i<nbr_mailles;i++)
+ {
+ types[i]=mailles->DONNE_TYPE_MAILLE(i);
+ premier_pointeur[i]=mailles->DONNE_PREMIER_POINTEUR(i);
+ }
+ show[types[0]]->positionne(premier_pointeur[0]);
+ }
+template <class FORME_SKYLINE> const Wrapper_Maille & Wrapper_Nuage_Maille<FORME_SKYLINE>::operator[](int i)
+ {
+ return show[types[i]]->positionne(premier_pointeur[i]);
+ }
+template <class FORME_SKYLINE> inline int Wrapper_Nuage_Maille<FORME_SKYLINE>::DONNE_SOMMET_MAILLE(int num_maille,int num_som)
+ {
+ return (*this)[num_maille][num_som];
+ }
+
+template <class FORME_SKYLINE> inline int Wrapper_Nuage_Maille<FORME_SKYLINE>::DONNE_NUM_LOC_FACE_EGALE_A_FORMANT(int num_maille,const vector<int> &sommets_face)
+ {
+ vector<int> face_loc;
+ int num_face;
+ int test=FAUX;
+ for (num_face=0;num_face<DONNE_NBR_FACES(num_maille);num_face++)
+ {
+ face_loc=DONNE_FACE(num_maille,num_face);
+ if (Comparaison_Informe(face_loc,sommets_face)) return num_face;
+ }
+ return UNDEFINED;
+ }
+template <class FORME_SKYLINE> int Wrapper_Nuage_Maille<FORME_SKYLINE>::DONNE_NBR_NOEUDS(int num_maille)
+ {
+ return (*this)[num_maille].DONNE_NBR_NOEUDS();
+ }
+template <class FORME_SKYLINE> int Wrapper_Nuage_Maille<FORME_SKYLINE>::DONNE_NBR_FACES(int num_maille)
+ {
+ return (*this)[num_maille].DONNE_NBR_FACES();
+ }
+template <class FORME_SKYLINE> vector<int> Wrapper_Nuage_Maille<FORME_SKYLINE>::DONNE_SIMPLEXE_BASE(int num_maille,int num_face)
+ {
+ return (*this)[num_maille].DONNE_SIMPLEXE_BASE(num_face);
+ }
+template <class FORME_SKYLINE> vector<int> Wrapper_Nuage_Maille<FORME_SKYLINE>::DONNE_FACE(int num_maille,int num_face)
+ {
+ return (*this)[num_maille].DONNE_FACE(num_face);
+ }
+template <class FORME_SKYLINE> int Wrapper_Nuage_Maille<FORME_SKYLINE>::DONNE_PREMIER_NOEUD_DE_FACE(int num_maille,int num_face)
+ {
+ return (*this)[num_maille].DONNE_PREMIER_NOEUD_DE_FACE(num_face);
+ }
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille_Seg2 */
+/* */
+/*********************************************************/
+
+/*
+class Wrapper_Maille_Seg2 : public Wrapper_Maille
+{
+public :
+ inline int DONNE_NBR_FACES() const {return 2;}
+ inline int DONNE_NBR_NOEUDS() const {return 2;}
+};
+//*/
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille_Seg3 */
+/* */
+/*********************************************************/
+
+/*
+class Wrapper_Maille_Seg3 : public Wrapper_Maille
+{
+public :
+ inline int DONNE_NBR_FACES() const {return 2;}
+ inline int DONNE_NBR_NOEUDS() const {return 3;}
+};
+//*/
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille_Tria3 */
+/* */
+/*********************************************************/
+
+class Wrapper_Maille_Tria3 : public Wrapper_Maille
+{
+public :
+ inline int DONNE_NBR_FACES() const {return 3;}
+ inline int DONNE_NBR_NOEUDS() const {return 3;}
+ inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const
+ {
+ switch (num_face)
+ {
+ case 0 : return sommets[0];
+ case 1 : return sommets[1];
+ case 2 : return sommets[2];
+ }
+ }
+ inline vector<int> DONNE_FACE(int num_face) const
+ {
+ vector<int> retour(2);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[0];retour[1]=sommets[1];break;
+ case 1 : retour[0]=sommets[1];retour[1]=sommets[2];break;
+ case 2 : retour[0]=sommets[2];retour[1]=sommets[0];break;
+ }
+ return retour;
+ }
+ inline vector<int> DONNE_SIMPLEXE_BASE(int num_face) const
+ {
+ vector<int> retour(3);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[2];retour[1]=sommets[0];retour[2]=sommets[1];break;
+ case 1 : retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[2];break;
+ case 2 : retour[0]=sommets[1];retour[1]=sommets[2];retour[2]=sommets[0];break;
+ }
+ return retour;
+ }
+};
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille_Tria6 */
+/* */
+/*********************************************************/
+
+class Wrapper_Maille_Tria6 : public Wrapper_Maille
+{
+public :
+ inline int DONNE_NBR_FACES() const {return 3;}
+ inline int DONNE_NBR_NOEUDS() const {return 6;}
+ inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const
+ {
+ switch (num_face)
+ {
+ case 0 : return sommets[0];
+ case 1 : return sommets[1];
+ case 2 : return sommets[2];
+ }
+ }
+ inline vector<int> DONNE_FACE(int num_face) const
+ {
+ vector<int> retour(2);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[0];retour[1]=sommets[1];break;
+ case 1 : retour[0]=sommets[1];retour[1]=sommets[2];break;
+ case 2 : retour[0]=sommets[2];retour[1]=sommets[0];break;
+ }
+ return retour;
+ }
+ inline vector<int> DONNE_SIMPLEXE_BASE(int num_face) const
+ {
+ vector<int> retour(3);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[2];retour[1]=sommets[0];retour[2]=sommets[1];break;
+ case 1 : retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[2];break;
+ case 2 : retour[0]=sommets[1];retour[1]=sommets[2];retour[2]=sommets[0];break;
+ }
+ return retour;
+ }
+};
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille_Quad4 */
+/* */
+/*********************************************************/
+
+class Wrapper_Maille_Quad4 : public Wrapper_Maille
+{
+public :
+ inline int DONNE_NBR_FACES() const {return 4;}
+ inline int DONNE_NBR_NOEUDS() const {return 4;}
+ inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const
+ {
+ switch (num_face)
+ {
+ case 0 : return sommets[0];
+ case 1 : return sommets[1];
+ case 2 : return sommets[2];
+ case 3 : return sommets[3];
+ }
+ }
+ inline vector<int> DONNE_FACE(int num_face) const
+ {
+ vector<int> retour(2);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[0];retour[1]=sommets[1];break;
+ case 1 : retour[0]=sommets[1];retour[1]=sommets[2];break;
+ case 2 : retour[0]=sommets[2];retour[1]=sommets[3];break;
+ case 3 : retour[0]=sommets[3];retour[1]=sommets[0];break;
+ }
+ return retour;
+ }
+ inline vector<int> DONNE_SIMPLEXE_BASE(int num_face) const
+ {
+ vector<int> retour(3);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[2];retour[1]=sommets[0];retour[2]=sommets[1];break;
+ case 1 : retour[0]=sommets[3];retour[1]=sommets[1];retour[2]=sommets[2];break;
+ case 2 : retour[0]=sommets[0];retour[1]=sommets[2];retour[2]=sommets[3];break;
+ case 3 : retour[0]=sommets[1];retour[1]=sommets[0];retour[3]=sommets[0];break;
+ }
+ return retour;
+ }
+};
+
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille_Quad8 */
+/* */
+/*********************************************************/
+
+class Wrapper_Maille_Quad8 : public Wrapper_Maille
+{
+public :
+ inline int DONNE_NBR_FACES() const {return 4;}
+ inline int DONNE_NBR_NOEUDS() const {return 8;}
+ inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const
+ {
+ switch (num_face)
+ {
+ case 0 : return sommets[0];
+ case 1 : return sommets[1];
+ case 2 : return sommets[2];
+ case 3 : return sommets[3];
+ }
+ }
+ inline vector<int> DONNE_FACE(int num_face) const
+ {
+ vector<int> retour(2);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[0];retour[1]=sommets[1];break;
+ case 1 : retour[0]=sommets[1];retour[1]=sommets[2];break;
+ case 2 : retour[0]=sommets[2];retour[1]=sommets[3];break;
+ case 3 : retour[0]=sommets[3];retour[1]=sommets[0];break;
+ }
+ return retour;
+ }
+ inline vector<int> DONNE_SIMPLEXE_BASE(int num_face) const
+ {
+ vector<int> retour(3);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[2];retour[1]=sommets[0];retour[2]=sommets[1];break;
+ case 1 : retour[0]=sommets[3];retour[1]=sommets[1];retour[2]=sommets[2];break;
+ case 2 : retour[0]=sommets[0];retour[1]=sommets[2];retour[2]=sommets[3];break;
+ case 3 : retour[0]=sommets[1];retour[1]=sommets[0];retour[3]=sommets[0];break;
+ }
+ return retour;
+ }
+};
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille_Tetra4 */
+/* */
+/*********************************************************/
+
+class Wrapper_Maille_Tetra4 : public Wrapper_Maille
+{
+public :
+ inline int DONNE_NBR_FACES() const {return 4;}
+ inline int DONNE_NBR_NOEUDS() const {return 4;}
+ inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const
+ {
+ switch (num_face)
+ {
+ case 0 : return sommets[0];
+ case 1 : return sommets[0];
+ case 2 : return sommets[1];
+ case 3 : return sommets[2];
+ }
+ }
+ inline vector<int> DONNE_FACE(int num_face) const
+ {
+ vector<int> retour(3);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[2];break;
+ case 1 : retour[0]=sommets[0];retour[1]=sommets[3];retour[2]=sommets[1];break;
+ case 2 : retour[0]=sommets[1];retour[1]=sommets[3];retour[2]=sommets[2];break;
+ case 3 : retour[0]=sommets[2];retour[1]=sommets[3];retour[2]=sommets[0];break;
+ }
+ return retour;
+ }
+ inline vector<int> DONNE_SIMPLEXE_BASE(int num_face) const
+ {
+ vector<int> retour(4);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[3];retour[1]=sommets[0];retour[2]=sommets[1];retour[3]=sommets[2];break;
+ case 1 : retour[0]=sommets[2];retour[1]=sommets[0];retour[2]=sommets[3];retour[3]=sommets[1];break;
+ case 2 : retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[3];retour[3]=sommets[2];break;
+ case 3 : retour[0]=sommets[1];retour[1]=sommets[2];retour[2]=sommets[3];retour[3]=sommets[0];break;
+ }
+ return retour;
+ }
+};
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille_Tetra10 */
+/* */
+/*********************************************************/
+
+class Wrapper_Maille_Tetra10 : public Wrapper_Maille
+{
+public :
+ inline int DONNE_NBR_FACES() const {return 4;}
+ inline int DONNE_NBR_NOEUDS() const {return 10;}
+ inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const
+ {
+ switch (num_face)
+ {
+ case 0 : return sommets[0];
+ case 1 : return sommets[0];
+ case 2 : return sommets[1];
+ case 3 : return sommets[2];
+ }
+ }
+ inline vector<int> DONNE_FACE(int num_face) const
+ {
+ vector<int> retour(3);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[2];break;
+ case 1 : retour[0]=sommets[0];retour[1]=sommets[3];retour[2]=sommets[1];break;
+ case 2 : retour[0]=sommets[1];retour[1]=sommets[3];retour[2]=sommets[2];break;
+ case 3 : retour[0]=sommets[2];retour[1]=sommets[3];retour[2]=sommets[0];break;
+ }
+ return retour;
+ }
+ inline vector<int> DONNE_SIMPLEXE_BASE(int num_face) const
+ {
+ vector<int> retour(4);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[3];retour[1]=sommets[0];retour[2]=sommets[1];retour[3]=sommets[2];break;
+ case 1 : retour[0]=sommets[2];retour[1]=sommets[0];retour[2]=sommets[3];retour[3]=sommets[1];break;
+ case 2 : retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[3];retour[3]=sommets[2];break;
+ case 3 : retour[0]=sommets[1];retour[1]=sommets[2];retour[2]=sommets[3];retour[3]=sommets[0];break;
+ }
+ return retour;
+ }
+};
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille_Hexa8 */
+/* */
+/*********************************************************/
+
+class Wrapper_Maille_Hexa8 : public Wrapper_Maille
+{
+public :
+ inline int DONNE_NBR_FACES() const {return 6;}
+ inline int DONNE_NBR_NOEUDS() const {return 8;}
+ inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const
+ {
+ switch (num_face)
+ {
+ case 0 : return sommets[0];
+ case 1 : return sommets[4];
+ case 2 : return sommets[0];
+ case 3 : return sommets[1];
+ case 4 : return sommets[2];
+ case 5 : return sommets[3];
+ }
+ }
+ inline vector<int> DONNE_FACE(int num_face) const
+ {
+ vector<int> retour(4);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[2];retour[3]=sommets[3];break;
+ case 1 : retour[0]=sommets[4];retour[1]=sommets[5];retour[2]=sommets[6];retour[3]=sommets[7];break;
+ case 2 : retour[0]=sommets[0];retour[1]=sommets[4];retour[2]=sommets[5];retour[3]=sommets[1];break;
+ case 3 : retour[0]=sommets[1];retour[1]=sommets[5];retour[2]=sommets[6];retour[3]=sommets[2];break;
+ case 4 : retour[0]=sommets[2];retour[1]=sommets[6];retour[2]=sommets[7];retour[3]=sommets[3];break;
+ case 5 : retour[0]=sommets[3];retour[1]=sommets[7];retour[2]=sommets[4];retour[3]=sommets[0];break;
+
+ }
+ return retour;
+ }
+ inline vector<int> DONNE_SIMPLEXE_BASE(int num_face) const
+ {
+ vector<int> retour(4);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[5];retour[1]=sommets[0];retour[2]=sommets[1];retour[3]=sommets[2];break;
+ case 1 : retour[0]=sommets[0];retour[1]=sommets[7];retour[2]=sommets[6];retour[3]=sommets[5];break;
+ case 2 : retour[0]=sommets[3];retour[1]=sommets[0];retour[2]=sommets[4];retour[3]=sommets[5];break;
+ case 3 : retour[0]=sommets[4];retour[1]=sommets[1];retour[2]=sommets[5];retour[3]=sommets[6];break;
+ case 4 : retour[0]=sommets[1];retour[1]=sommets[2];retour[2]=sommets[6];retour[3]=sommets[3];break;
+ case 5 : retour[0]=sommets[2];retour[1]=sommets[3];retour[2]=sommets[7];retour[3]=sommets[0];break;
+
+ }
+ return retour;
+ }
+};
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille_Hexa20 */
+/* */
+/*********************************************************/
+
+class Wrapper_Maille_Hexa20 : public Wrapper_Maille
+{
+public :
+ inline int DONNE_NBR_FACES() const {return 6;}
+ inline int DONNE_NBR_NOEUDS() const {return 20;}
+ inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const
+ {
+ switch (num_face)
+ {
+ case 0 : return sommets[0];
+ case 1 : return sommets[4];
+ case 2 : return sommets[0];
+ case 3 : return sommets[1];
+ case 4 : return sommets[2];
+ case 5 : return sommets[3];
+ }
+ }
+ inline vector<int> DONNE_FACE(int num_face) const
+ {
+ vector<int> retour(4);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[2];retour[3]=sommets[3];break;
+ case 1 : retour[0]=sommets[4];retour[1]=sommets[5];retour[2]=sommets[6];retour[3]=sommets[7];break;
+ case 2 : retour[0]=sommets[0];retour[1]=sommets[4];retour[2]=sommets[5];retour[3]=sommets[1];break;
+ case 3 : retour[0]=sommets[1];retour[1]=sommets[5];retour[2]=sommets[6];retour[3]=sommets[2];break;
+ case 4 : retour[0]=sommets[2];retour[1]=sommets[6];retour[2]=sommets[7];retour[3]=sommets[3];break;
+ case 5 : retour[0]=sommets[3];retour[1]=sommets[7];retour[2]=sommets[4];retour[3]=sommets[0];break;
+ }
+ return retour;
+ }
+ inline vector<int> DONNE_SIMPLEXE_BASE(int num_face) const
+ {
+ vector<int> retour(4);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[5];retour[1]=sommets[0];retour[2]=sommets[1];retour[3]=sommets[2];break;
+ case 1 : retour[0]=sommets[0];retour[1]=sommets[7];retour[2]=sommets[6];retour[3]=sommets[5];break;
+ case 2 : retour[0]=sommets[3];retour[1]=sommets[0];retour[2]=sommets[4];retour[3]=sommets[5];break;
+ case 3 : retour[0]=sommets[4];retour[1]=sommets[1];retour[2]=sommets[5];retour[3]=sommets[6];break;
+ case 4 : retour[0]=sommets[1];retour[1]=sommets[2];retour[2]=sommets[6];retour[3]=sommets[3];break;
+ case 5 : retour[0]=sommets[2];retour[1]=sommets[3];retour[2]=sommets[7];retour[3]=sommets[0];break;
+ }
+ return retour;
+ }
+};
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille_Pyra5 */
+/* */
+/*********************************************************/
+
+class Wrapper_Maille_Pyra5 : public Wrapper_Maille
+{
+public :
+ inline int DONNE_NBR_FACES() const {return 5;}
+ inline int DONNE_NBR_NOEUDS() const {return 5;}
+ inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const
+ {
+ switch (num_face)
+ {
+ case 0 : return sommets[0];
+ case 1 : return sommets[0];
+ case 2 : return sommets[1];
+ case 3 : return sommets[2];
+ case 4 : return sommets[3];
+ }
+ }
+ inline vector<int> DONNE_FACE(int num_face) const
+ {
+ vector<int> retour;
+ switch (num_face)
+ {
+ case 0 : retour.resize(4);retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[2];retour[3]=sommets[3];break;
+ case 1 : retour.resize(3);retour[0]=sommets[0];retour[1]=sommets[4];retour[2]=sommets[1];break;
+ case 2 : retour.resize(3);retour[0]=sommets[1];retour[1]=sommets[4];retour[2]=sommets[2];break;
+ case 3 : retour.resize(3);retour[0]=sommets[2];retour[1]=sommets[4];retour[2]=sommets[3];break;
+ case 4 : retour.resize(3);retour[0]=sommets[3];retour[1]=sommets[4];retour[2]=sommets[0];break;
+ }
+ return retour;
+ }
+
+ inline vector<int> DONNE_SIMPLEXE_BASE(int num_face) const
+ {
+ vector<int> retour(4);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[4];retour[1]=sommets[0];retour[2]=sommets[1];retour[3]=sommets[2];break;
+ case 1 : retour[0]=sommets[3];retour[1]=sommets[0];retour[2]=sommets[4];retour[3]=sommets[1];break;
+ case 2 : retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[4];retour[3]=sommets[2];break;
+ case 3 : retour[0]=sommets[1];retour[1]=sommets[2];retour[2]=sommets[4];retour[3]=sommets[3];break;
+ case 4 : retour[0]=sommets[2];retour[1]=sommets[0];retour[2]=sommets[3];retour[3]=sommets[4];break;
+ }
+ return retour;
+ }
+};
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille_Pyra13 */
+/* */
+/*********************************************************/
+
+class Wrapper_Maille_Pyra13 : public Wrapper_Maille
+{
+public :
+ inline int DONNE_NBR_FACES() const {return 5;}
+ inline int DONNE_NBR_NOEUDS() const {return 13;}
+ inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const
+ {
+ switch (num_face)
+ {
+ case 0 : return sommets[0];
+ case 1 : return sommets[0];
+ case 2 : return sommets[1];
+ case 3 : return sommets[2];
+ case 4 : return sommets[3];
+ }
+ }
+ inline vector<int> DONNE_FACE(int num_face) const
+ {
+ vector<int> retour;
+ switch (num_face)
+ {
+ case 0 : retour.resize(4);retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[2];retour[3]=sommets[3];break;
+ case 1 : retour.resize(3);retour[0]=sommets[0];retour[1]=sommets[4];retour[2]=sommets[1];break;
+ case 2 : retour.resize(3);retour[0]=sommets[1];retour[1]=sommets[4];retour[2]=sommets[2];break;
+ case 3 : retour.resize(3);retour[0]=sommets[2];retour[1]=sommets[4];retour[2]=sommets[3];break;
+ case 4 : retour.resize(3);retour[0]=sommets[3];retour[1]=sommets[4];retour[2]=sommets[0];break;
+ }
+ return retour;
+ }
+ inline vector<int> DONNE_SIMPLEXE_BASE(int num_face) const
+ {
+ vector<int> retour(4);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[4];retour[1]=sommets[0];retour[2]=sommets[1];retour[3]=sommets[2];break;
+ case 1 : retour[0]=sommets[3];retour[1]=sommets[0];retour[2]=sommets[4];retour[3]=sommets[1];break;
+ case 2 : retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[4];retour[3]=sommets[2];break;
+ case 3 : retour[0]=sommets[1];retour[1]=sommets[2];retour[2]=sommets[4];retour[3]=sommets[3];break;
+ case 4 : retour[0]=sommets[2];retour[1]=sommets[0];retour[2]=sommets[3];retour[3]=sommets[4];break;
+ }
+ }
+};
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille_Penta6 */
+/* */
+/*********************************************************/
+
+class Wrapper_Maille_Penta6 : public Wrapper_Maille
+{
+public :
+ inline int DONNE_NBR_FACES() const {return 5;}
+ inline int DONNE_NBR_NOEUDS() const {return 6;}
+ inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const
+ {
+ switch (num_face)
+ {
+ case 0 : return sommets[0];
+ case 1 : return sommets[3];
+ case 2 : return sommets[0];
+ case 3 : return sommets[1];
+ case 4 : return sommets[2];
+ }
+ }
+ inline vector<int> DONNE_FACE(int num_face) const
+ {
+ vector<int> retour;
+ switch (num_face)
+ {
+ case 0 : retour.resize(3);retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[2];break;
+ case 1 : retour.resize(3);retour[0]=sommets[3];retour[1]=sommets[4];retour[2]=sommets[5];break;
+ case 2 : retour.resize(4);retour[0]=sommets[0];retour[1]=sommets[3];retour[2]=sommets[4];retour[3]=sommets[1];break;
+ case 3 : retour.resize(4);retour[0]=sommets[1];retour[1]=sommets[4];retour[2]=sommets[5];retour[3]=sommets[2];break;
+ case 4 : retour.resize(4);retour[0]=sommets[2];retour[1]=sommets[5];retour[2]=sommets[3];retour[3]=sommets[1];break;
+ }
+ return retour;
+ }
+
+ inline vector<int> DONNE_SIMPLEXE_BASE(int num_face) const
+ {
+ vector<int> retour(4);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[3];retour[1]=sommets[0];retour[2]=sommets[1];retour[3]=sommets[2];break;
+ case 1 : retour[0]=sommets[2];retour[1]=sommets[3];retour[2]=sommets[4];retour[3]=sommets[5];break;
+ case 2 : retour[0]=sommets[5];retour[1]=sommets[0];retour[2]=sommets[3];retour[3]=sommets[1];break;
+ case 3 : retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[4];retour[3]=sommets[2];break;
+ case 4 : retour[0]=sommets[1];retour[1]=sommets[2];retour[2]=sommets[5];retour[3]=sommets[0];break;
+ }
+ return retour;
+ }
+};
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille_Penta15 */
+/* */
+/*********************************************************/
+
+class Wrapper_Maille_Penta15 : public Wrapper_Maille
+{
+public :
+ inline int DONNE_NBR_FACES() const {return 5;}
+ inline int DONNE_NBR_NOEUDS() const {return 15;}
+ inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const
+ {
+ switch (num_face)
+ {
+ case 0 : return sommets[0];
+ case 1 : return sommets[3];
+ case 2 : return sommets[0];
+ case 3 : return sommets[1];
+ case 4 : return sommets[2];
+ }
+ }
+ inline vector<int> DONNE_FACE(int num_face) const
+ {
+ vector<int> retour;
+ switch (num_face)
+ {
+ case 0 : retour.resize(3);retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[2];break;
+ case 1 : retour.resize(3);retour[0]=sommets[3];retour[1]=sommets[4];retour[2]=sommets[5];break;
+ case 2 : retour.resize(4);retour[0]=sommets[0];retour[1]=sommets[3];retour[2]=sommets[4];retour[3]=sommets[1];break;
+ case 3 : retour.resize(4);retour[0]=sommets[1];retour[1]=sommets[4];retour[2]=sommets[5];retour[3]=sommets[2];break;
+ case 4 : retour.resize(4);retour[0]=sommets[2];retour[1]=sommets[5];retour[2]=sommets[3];retour[3]=sommets[1];break;
+ }
+ return retour;
+ }
+
+ inline vector<int> DONNE_SIMPLEXE_BASE(int num_face) const
+ {
+ vector<int> retour(4);
+ switch (num_face)
+ {
+ case 0 : retour[0]=sommets[3];retour[1]=sommets[0];retour[2]=sommets[1];retour[3]=sommets[2];break;
+ case 1 : retour[0]=sommets[2];retour[1]=sommets[3];retour[2]=sommets[4];retour[3]=sommets[5];break;
+ case 2 : retour[0]=sommets[5];retour[1]=sommets[0];retour[2]=sommets[3];retour[3]=sommets[1];break;
+ case 3 : retour[0]=sommets[0];retour[1]=sommets[1];retour[2]=sommets[4];retour[3]=sommets[2];break;
+ case 4 : retour[0]=sommets[1];retour[1]=sommets[2];retour[2]=sommets[5];retour[3]=sommets[0];break;
+ }
+ return retour;
+ }
+};
+
+/*********************************************************/
+/* */
+/* Classe Type_Wrapper_Maille */
+/* */
+/*********************************************************/
+
+Type_Wrapper_Maille::~Type_Wrapper_Maille()
+ {
+ // delete contenu[MED_SEG2 ];
+ // delete contenu[MED_SEG3 ];
+ delete contenu[MED_TRIA3 ];
+ delete contenu[MED_TRIA6 ];
+ delete contenu[MED_QUAD4 ];
+ delete contenu[MED_QUAD8 ];
+ delete contenu[MED_TETRA4 ];
+ delete contenu[MED_TETRA10];
+ delete contenu[MED_HEXA8 ];
+ delete contenu[MED_HEXA20 ];
+ delete contenu[MED_PYRA5 ];
+ delete contenu[MED_PYRA13 ];
+ delete contenu[MED_PENTA6 ];
+ delete contenu[MED_PENTA15];
+ }
+
+Type_Wrapper_Maille::Type_Wrapper_Maille()
+ {
+ // contenu[MED_SEG2 ]= new Wrapper_Maille_Seg2 ();
+ // contenu[MED_SEG3 ]= new Wrapper_Maille_Seg3 ();
+ contenu[MED_TRIA3 ]= new Wrapper_Maille_Tria3 ();
+ contenu[MED_TRIA6 ]= new Wrapper_Maille_Tria6 ();
+ contenu[MED_QUAD4 ]= new Wrapper_Maille_Quad4 ();
+ contenu[MED_QUAD8 ]= new Wrapper_Maille_Quad8 ();
+ contenu[MED_TETRA4 ]= new Wrapper_Maille_Tetra4 ();
+ contenu[MED_TETRA10]= new Wrapper_Maille_Tetra10 ();
+ contenu[MED_HEXA8 ]= new Wrapper_Maille_Hexa8 ();
+ contenu[MED_HEXA20 ]= new Wrapper_Maille_Hexa20 ();
+ contenu[MED_PYRA5 ]= new Wrapper_Maille_Pyra5 ();
+ contenu[MED_PYRA13 ]= new Wrapper_Maille_Pyra13 ();
+ contenu[MED_PENTA6 ]= new Wrapper_Maille_Penta6 ();
+ contenu[MED_PENTA15]= new Wrapper_Maille_Penta15 ();
+ }
+
+
+#endif
--- /dev/null
+#ifndef MEDMEM_WRAPPER_CONNECTIVITY_HXX
+#define MEDMEM_WRAPPER_CONNECTIVITY_HXX
+
+#include "MEDMEM_Connectivity.hxx"
+
+#include <vector>
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ET CODE ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Wrapper_Med_Connectivity */
+/* */
+/*********************************************************/
+
+// obligé de faire de la recopie car MED n'utilise pas la numérotation standart C
+
+class Wrapper_Med_Connectivity
+{
+protected :
+ int * mailles;
+ int nbr_mailles;
+ vector<int> types;
+ vector< int* > premier_pointeur;
+
+public :
+ ~Wrapper_Med_Connectivity() {if (mailles) delete [] mailles;}
+ Wrapper_Med_Connectivity():mailles(NULL) {}
+ Wrapper_Med_Connectivity(CONNECTIVITY * maillesmed)
+ {
+ const med_int * tab_sommets_mailles=maillesmed->getConnectivity(MED_NODAL,MED_CELL,MED_ALL_ELEMENTS);
+ const med_int * med_connectivite=maillesmed->getConnectivityIndex(MED_FULL_INTERLACE,MED_CELL);
+ const med_int * med_index=maillesmed->getValueIndex(MED_FULL_INTERLACE);
+ nbr_mailles=maillesmed->getNumberOf(MED_CELL,MED_ALL_ELEMENTS);
+ int size=med_index[nbr_mailles]-med_index[0];
+ types.resize(nbr_mailles);
+ premier_pointeur.resize(nbr_mailles);
+ mailles=new int[size];
+ int i;
+ for (i=0;i<size;i++)
+ {
+ mailles[i]=tab_sommets_mailles[i]-1;
+ }
+ for (i=0;i<nbr_mailles;i++)
+ {
+ types[i]=maillesmed->getElementType(MED_CELL,i+1); // A VERIFIER : le +1
+ premier_pointeur[i]=&mailles[med_index[i]-1]; // A VERIFIER : la formule
+ }
+ }
+ // Méthodes de la politique
+ inline int SIZE() {return nbr_mailles;}
+ inline int DONNE_TYPE_MAILLE(int i) {return types[i];}
+ inline int * DONNE_PREMIER_POINTEUR(int i) {return premier_pointeur[i];}
+};
+
+
+#endif
--- /dev/null
+#ifndef MEDMEM_WRAPPER_FIELD_HXX
+#define MEDMEM_WRAPPER_FIELD_HXX
+
+#include "MEDMEM_Field.hxx"
+
+#include <vector>
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ET CODE ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Template Arithmétiques de Valdhuizen */
+/* */
+/*********************************************************/
+
+template <class TYPE> class Valeur;
+
+struct Plus
+{
+public :
+ static double apply(double a,double b) {return a+b;}
+};
+
+struct Multiply
+{
+public :
+ static double apply(double a,double b) {return a*b;}
+};
+
+
+template <typename Left,typename Op, typename Right> struct X
+{
+ Left left;
+ Right right;
+ X(Left l,Right r):left(l),right(r){}
+ double operator[](int i)
+ {
+ return Op::apply(left[i],right[i]);
+ }
+};
+
+template <typename Right> struct X<double,Multiply,Right>
+{
+ double left;
+ Right right;
+ X(double l,Right r):left(l),right(r){}
+ double operator[](int i)
+ {
+ return Multiply::apply(left,right[i]);
+ }
+};
+
+template <typename TYPE> X< Valeur<TYPE>,Plus,Valeur<TYPE> > operator+(Valeur<TYPE> v1,Valeur<TYPE> v2)
+{
+return X< Valeur<TYPE>,Plus,Valeur<TYPE> >(v1,v2);
+}
+
+template <typename TYPE> X< double,Multiply,Valeur<double> > operator*(TYPE sca,Valeur<TYPE> v)
+{
+return X< TYPE,Multiply,Valeur<TYPE> >(sca,v);
+}
+
+template <typename TYPE,typename L, typename O, typename R> X< Valeur<TYPE>,Plus,X<L,O,R> > operator+(Valeur<TYPE> v,X<L,O,R> expression)
+{
+return X< Valeur<TYPE>,Plus,X<L,O,R> >(v,expression);
+}
+
+template <typename TYPE,typename L, typename O, typename R> X< X<L,O,R>,Plus,Valeur<TYPE> > operator+(X<L,O,R> expression,Valeur<TYPE> v)
+{
+return X< X<L,O,R>,Plus,Valeur<TYPE> >(expression,v);
+}
+
+template <typename Ll, typename Ol, typename Rl,typename Lr, typename Or, typename Rr> X< X<Ll,Ol,Rl>,Plus, X<Lr,Or,Rr> > operator+(X<Ll,Ol,Rl> el, X<Lr,Or,Rr> er )
+{
+return X< X<Ll,Ol,Rl>,Plus,X<Lr,Or,Rr> >(el,er);
+}
+
+template <typename L, typename O, typename R> X< double,Multiply,X<L,O,R> > operator*(double sca,X<L,O,R> expression)
+{
+return X< double,Multiply,X<L,O,R> >(sca,expression);
+}
+
+template <typename Left,typename Op,typename Right> X< double,Multiply,X<Left,Op,Right> > operator/(X<Left,Op,Right> l,double x)
+{
+return X< double,Multiply,X<Left,Op,Right> >(((double) 1/x),l);
+}
+
+/*********************************************************/
+/* */
+/* Classe Valeur */
+/* */
+/*********************************************************/
+
+// Problèmes : les constructeurs par copie ne sont pas satisfaisants
+
+template <class TYPE> class Valeur
+{
+protected :
+ TYPE * valeurs;
+ int nbr_valeurs;
+ int a_detruire;
+public :
+ Valeur():valeurs(NULL),a_detruire(0){}
+ Valeur(TYPE * val,int nv):valeurs(val),nbr_valeurs(nv),a_detruire(0){} // A VERIFIER
+ Valeur(int n):nbr_valeurs(n),a_detruire(1)
+ {
+ valeurs=new TYPE[nbr_valeurs];
+ }
+ template <typename Left,typename Op,typename Right> Valeur(X<Left,Op,Right> expression)
+ {
+ for (int i=0;i<nbr_valeurs;i++) valeurs[i]=expression[i];
+ }
+ template <typename Left,typename Op,typename Right> void operator=(X<Left,Op,Right> expression)
+ {
+ for (int i=0;i<nbr_valeurs;i++) valeurs[i]=expression[i];
+ }
+ void operator=(Valeur v)
+ {
+ for (int i=0;i<nbr_valeurs;i++) valeurs[i]=v[i];
+ }
+ Valeur(const Valeur &v):nbr_valeurs(v.nbr_valeurs)
+ {
+ if (v.a_detruire)
+ {
+ a_detruire=1;
+ valeurs=new TYPE[nbr_valeurs];
+ for (int i=0;i<nbr_valeurs;i++) valeurs[i]=v.valeurs[i];
+ }
+ else
+ {
+ a_detruire=0;
+ valeurs=v.valeurs;
+ }
+ }
+ ~Valeur(){if (a_detruire) delete [] valeurs;}
+ TYPE operator[](int i){return valeurs[i];}
+ int SIZE() const {return nbr_valeurs;}
+};
+
+template <class TYPE> ostream &operator<<(ostream &os,Valeur<TYPE> v)
+{
+os<<"("<<flush;
+for (int i=0;i<v.SIZE();i++) os<<" "<<v[i]<<flush;
+os<<" ) "<<flush;
+return os;
+}
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_MED_Field */
+/* */
+/*********************************************************/
+
+class Wrapper_MED_Field
+{
+protected :
+ int nbr_valeurs;
+ int nbr_composantes;
+ double * valeurs;
+public :
+ Wrapper_MED_Field():valeurs(NULL){}
+ Wrapper_MED_Field(int nv, int nc, double * v):nbr_valeurs(nv),nbr_composantes(nc),valeurs(v)
+ {
+ }
+ Wrapper_MED_Field(const FIELD<double> * medfield)
+ {
+ nbr_valeurs=medfield->getNumberOfValues();
+ nbr_composantes=medfield->getNumberOfComponents();
+ valeurs=const_cast<double *>(medfield->getValue(MED_FULL_INTERLACE));
+ }
+ ~Wrapper_MED_Field(){}
+ inline Valeur<double> operator[](int i)
+ {
+ if ((i<0)||(i>=nbr_valeurs))
+ {
+ cerr<<endl;
+ cerr<<"Outbound call dans Wrapper MED Field"<<endl;
+ cerr<<"Inférior Bound = "<<0<<endl;
+ cerr<<"Supérior Bound = "<<nbr_valeurs-1<<endl;
+ cerr<<"Call = "<<i<<endl;
+ exit(-1);
+ }
+ return Valeur<double>(&valeurs[nbr_composantes*i],nbr_composantes);
+ }
+ double * Get_Valeurs() {return valeurs;}
+ inline int Get_Nbr_Valeurs() const {return nbr_valeurs;}
+ inline int Get_Nbr_Composantes() const {return nbr_composantes;}
+ friend ostream & operator<<(ostream &os, Wrapper_MED_Field);
+};
+
+ostream & operator<<(ostream &os, Wrapper_MED_Field wmf)
+{
+for (int i=0;i<wmf.nbr_valeurs;i++) os<<"Wrapper_MED_Field["<<i<<"] = "<<wmf[i]<<endl;
+return os;
+}
+
+#endif
--- /dev/null
+#ifndef MEDMEM_WRAPPER_MESH_HXX
+#define MEDMEM_WRAPPER_MESH_HXX
+
+#include "stdio.h"
+#include "stdlib.h"
+
+#include <vector>
+
+#ifndef UNDEFINED
+#define UNDEFINED -1
+#endif
+
+#ifndef FAUX
+#define FAUX 0
+#endif
+
+#ifndef VRAI
+#define VRAI 1
+#endif
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Wrapper_Maillage */
+/* */
+/*********************************************************/
+
+template <class NUAGEMAILLE> class Wrapper_Maillage
+{
+protected :
+ NUAGEMAILLE * mailles;
+
+ int nbr_noeuds;
+
+ vector< vector<int> > faces_contenues;
+ vector< vector<int> > mailles_contenant_noeud;
+ vector< vector<int> > voisins_de_maille;
+
+ vector<int> face_au_bord;
+ vector<int> maille_au_bord;
+
+ // Méthode privée
+ void Construit_Contenant_Noeud();
+
+public :
+
+ Wrapper_Maillage():mailles(NULL) {}
+ // Construit les Connectivités du maillage à la construction
+ Wrapper_Maillage(NUAGEMAILLE * fs, int nn);
+ ~Wrapper_Maillage() {}
+
+ // Méthodes de la politique
+ inline int DONNE_NBR_FACES_MAILLE(int num_maille);
+ inline int DONNE_VOISIN_DE_MAILLE(int num_maille,int num_face) const;
+ inline int EST_AU_BORD_FACE_DE_MAILLE(int num_maille,int num_face) const;
+ inline int DONNE_NBR_FACES(int num_maille) const;
+ inline vector<int> DONNE_SIMPLEXE_BASE(int num_maille,int num_face) const;
+ inline int DONNE_PREMIERE_MAILLE_CONTENANT(int num_noeud) const;
+ inline NUAGEMAILLE * DONNE_POINTEUR_NUAGEMAILLE();
+
+};
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// CODE ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+template <class NUAGEMAILLE> int Wrapper_Maillage<NUAGEMAILLE>::DONNE_PREMIERE_MAILLE_CONTENANT(int num_noeud) const
+ {
+ return mailles_contenant_noeud[num_noeud][0];
+ }
+template <class NUAGEMAILLE> int Wrapper_Maillage<NUAGEMAILLE>::DONNE_VOISIN_DE_MAILLE(int num_maille,int num_face) const
+ {
+ return voisins_de_maille[num_maille][num_face];
+ }
+template <class NUAGEMAILLE> int Wrapper_Maillage<NUAGEMAILLE>::EST_AU_BORD_FACE_DE_MAILLE(int num_maille,int num_face) const
+ {
+ return face_au_bord[faces_contenues[num_maille][num_face]];
+ }
+template <class NUAGEMAILLE> int Wrapper_Maillage<NUAGEMAILLE>::DONNE_NBR_FACES_MAILLE(int num_maille)
+ {
+ return mailles->DONNE_NBR_FACES(num_maille);
+ }
+template <class NUAGEMAILLE> vector<int> Wrapper_Maillage<NUAGEMAILLE>::DONNE_SIMPLEXE_BASE(int num_maille,int num_face) const
+ {
+ return mailles->DONNE_SIMPLEXE_BASE(num_maille,num_face);
+ }
+template <class NUAGEMAILLE> NUAGEMAILLE * Wrapper_Maillage<NUAGEMAILLE>::DONNE_POINTEUR_NUAGEMAILLE()
+ {
+ return mailles;
+ }
+template <class NUAGEMAILLE> void Wrapper_Maillage<NUAGEMAILLE>::Construit_Contenant_Noeud()
+ {
+ int nbr_noeuds_maille;
+ int num,num_noeud,num_maille;
+
+ mailles_contenant_noeud.resize(nbr_noeuds);
+
+ for (num_maille=0;num_maille<mailles->SIZE();num_maille++)
+ {
+ nbr_noeuds_maille=mailles->DONNE_NBR_NOEUDS(num_maille);
+ for (num_noeud=0;num_noeud<nbr_noeuds_maille;num_noeud++)
+ {
+ num=mailles->DONNE_SOMMET_MAILLE(num_maille,num_noeud);
+// if ((num<0)||(num>=mailles_contenant_noeud.size()))
+// {
+// cerr<<endl;
+// cerr<<"Outbound call dans Construit Contenant Noeud"<<endl;
+// cerr<<"Inférior bound = 0"<<endl;
+// cerr<<"Supérior bound = "<<mailles_contenant_noeud.size()-1<<endl;
+// cerr<<"Call = "<<num<<endl;
+// exit(-1);
+// }
+ mailles_contenant_noeud[num].push_back(num_maille);
+ }
+ }
+
+ }
+template <class NUAGEMAILLE> Wrapper_Maillage<NUAGEMAILLE>::Wrapper_Maillage(NUAGEMAILLE * fs,int nn)
+ {
+
+ cout<<"Calcul de la Connectivité du Maillage"<<endl;
+
+ if (fs) mailles=fs;
+ else
+ {
+ cerr<<"Wrapper_Maillage : Nuage mailles vide passé en argument"<<endl;
+ exit(-1);
+ }
+
+ int i,j,k;
+ int num_local_face;
+ int ind_num_noeud,num_noeud;
+ int num_maille;
+ int ind_num_maille_sec,num_maille_sec;
+ int num_local_sec;
+ int flag_existence;
+ int nbr_mailles=mailles->SIZE();
+ int nbr_formants=0;
+ int approx_nbr_formants=0;
+ int tmp;
+ int num_loc;
+
+ nbr_noeuds=nn;
+
+ voisins_de_maille.resize(nbr_mailles);
+ faces_contenues.resize(nbr_mailles);
+ maille_au_bord.resize(nbr_mailles,UNDEFINED);
+
+ vector<int> sommets_face;
+
+ cout<<"Calcul du lien Sommet->Maille"<<endl;
+
+ Construit_Contenant_Noeud();
+
+ for (num_maille=0;num_maille<nbr_mailles;num_maille++)
+ {
+ tmp=mailles->DONNE_NBR_FACES(num_maille);
+ voisins_de_maille[num_maille]=vector<int>(tmp,UNDEFINED);
+ faces_contenues[num_maille]=vector<int>(tmp,UNDEFINED);
+ approx_nbr_formants+=tmp;
+ }
+
+ face_au_bord.reserve(approx_nbr_formants/10);
+
+ cout<<"Calcul des voisins"<<endl;
+
+ int flag_interm;
+ for (num_maille=0;num_maille<nbr_mailles;num_maille++)
+ {
+ for (num_local_face=0;num_local_face<mailles->DONNE_NBR_FACES(num_maille);num_local_face++)
+ {
+ num_noeud=mailles->DONNE_PREMIER_NOEUD_DE_FACE(num_maille,num_local_face);
+ flag_existence=0;
+ sommets_face=mailles->DONNE_FACE(num_maille,num_local_face);
+ flag_interm=0;
+ for (ind_num_maille_sec=0;(flag_existence==0)&&(ind_num_maille_sec<mailles_contenant_noeud[num_noeud].size());ind_num_maille_sec++)
+ {
+ num_maille_sec=mailles_contenant_noeud[num_noeud][ind_num_maille_sec];
+ if (num_maille_sec>num_maille)
+ {
+ flag_interm=1;
+ num_loc=mailles->DONNE_NUM_LOC_FACE_EGALE_A_FORMANT(num_maille_sec,sommets_face);
+ if (num_loc>UNDEFINED)
+ {
+ cout<<"La maille "<<num_maille<<" a pour voisin la maille "<<num_maille_sec<<" via la face "<<nbr_formants<<endl;
+ face_au_bord.push_back(FAUX);
+ faces_contenues[num_maille][num_local_face]=nbr_formants;
+ voisins_de_maille[num_maille][num_local_face]=num_maille_sec;
+ faces_contenues[num_maille_sec][num_loc]=nbr_formants;
+ voisins_de_maille[num_maille_sec][num_loc]=num_maille;
+ flag_existence=1;
+ nbr_formants++;
+ }
+ }
+ }
+ }
+ }
+
+ // Construction de la connexité des mailles de bord
+
+ cout<<"Calcul des bords"<<endl;
+
+ int ind_num_cont,test_bord,nbr_faces_bord=0;
+ for (num_maille=0;num_maille<nbr_mailles;num_maille++)
+ {
+ test_bord=0;
+ for (ind_num_cont=0;ind_num_cont<faces_contenues[num_maille].size();ind_num_cont++)
+ {
+ if (faces_contenues[num_maille][ind_num_cont]==UNDEFINED)
+ {
+ cout<<"La maille "<<num_maille<<" est au bord via sa face "<<ind_num_cont<<endl;
+ test_bord=1;
+ faces_contenues[num_maille][ind_num_cont]=nbr_formants;
+ maille_au_bord[num_maille]=VRAI;
+ face_au_bord.push_back(VRAI);
+ nbr_faces_bord++;
+ nbr_formants++;
+ }
+ }
+ if (test_bord==0)
+ {
+ maille_au_bord[num_maille]=FAUX;
+ }
+ }
+
+ // Vérification
+
+ cout<<"Vérification de la connectivité"<<endl;
+
+ int verif=0;
+ int nf,nbf=0;
+ for (i=0;i<nbr_mailles;i++)
+ {
+ nf=0;
+ for (j=0;j<faces_contenues[i].size();j++)
+ {
+ if (faces_contenues[i][j]==UNDEFINED) verif++;
+ if (voisins_de_maille[i][j]==UNDEFINED) nf++;
+ }
+ if (maille_au_bord[i]==UNDEFINED) cout<<"Maille "<<i<<" non completement construite"<<endl;
+ if (nf==faces_contenues[i].size()) nbf++;
+ }
+
+
+ cout<<" IL Y A "<<verif<<" PROBLEMES A LA SUITE DE LA CONSTRUCTION DE CONNEXITE"<<endl;
+ cout<<"Nombre de mailles : "<<nbr_mailles<<endl;
+ cout<<"Approximation du nombre de faces : "<<approx_nbr_formants<<endl;
+ cout<<"Nombre réel de faces de bord : "<<nbr_faces_bord<<endl;
+ cout<<"Nombre réel total de faces : "<<nbr_formants<<endl;
+ cout<<"Nombre de Mailles Isolées : "<<nbf<<endl;
+ }
+
+#endif
--- /dev/null
+
+#ifndef MEDMEM_WRAPPER_NODES_HXX
+#define MEDMEM_WRAPPER_NODES_HXX
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+// les classes de wrapping
+
+template <int DIMENSION> class Wrapper_Noeud
+{
+protected :
+ double * coordonnees;
+public :
+ Wrapper_Noeud():coordonnees(NULL)
+ {
+ }
+ Wrapper_Noeud(double * coord):coordonnees(coord)
+ {
+ }
+ ~Wrapper_Noeud()
+ {
+ }
+ void positionne(double *place)
+ {
+ coordonnees=place;
+ }
+ const double & operator[] (int i) const
+ {
+ return coordonnees[i];
+ }
+ double operator[] (int i)
+ {
+ return coordonnees[i];
+ }
+ friend double DistanceInf(const Wrapper_Noeud<DIMENSION> &A,const Wrapper_Noeud<DIMENSION> &B)
+ {
+ double max=0;
+ double tmp;
+ for (int i=0;i<DIMENSION;i++)
+ {
+ tmp=fabs(A[i]-B[i]);
+ if (tmp>max) max=tmp;
+ }
+ return max;
+ }
+ friend double DistanceL2(const Wrapper_Noeud<DIMENSION> &A,const Wrapper_Noeud<DIMENSION> &B)
+ {
+ double tmp,somme=0;
+ for (int i=0;i<DIMENSION;i++)
+ {
+ tmp=(A[i]-B[i]);
+ somme+=tmp*tmp;
+ }
+ return sqrt(somme);
+ }
+ friend int operator==(const Wrapper_Noeud<DIMENSION> &A,const Wrapper_Noeud<DIMENSION> &B)
+ {
+ for (int i=0;i<DIMENSION;i++) if (A[i]!=B[i]) return 1;
+ return 0;
+ }
+ friend ostream & operator<<(ostream &os,const Wrapper_Noeud<DIMENSION> &A)
+ {
+ os<<"( "<<flush;
+ for (int i=0;i<DIMENSION;i++) os<<A[i]<<" "<<flush;
+ os<<")"<<flush;
+ return os;
+ }
+ };
+
+template <int DIMENSION> class Wrapper_Nuage_Noeud
+ {
+ protected :
+ int nbr_noeuds;
+ double *noeuds;
+ Wrapper_Noeud<DIMENSION> show;
+ public :
+ Wrapper_Nuage_Noeud():nbr_noeuds(0),noeuds(NULL) {}
+ Wrapper_Nuage_Noeud(int nn, double *n):nbr_noeuds(nn),noeuds(n),show(noeuds) {}
+ ~Wrapper_Nuage_Noeud() {}
+ Wrapper_Noeud<DIMENSION> & operator [] (int i)
+ {
+ if ((i<0)||(i>=nbr_noeuds))
+ {
+ cerr<<"Outbound call dans Wrapper Nuage Noeud"<<endl;
+ cerr<<"Inférior Bound = "<<0<<endl;
+ cerr<<"Supérior Bound = "<<nbr_noeuds-1<<endl;
+ cerr<<"Call = "<<i<<endl;
+ exit(-1);
+ }
+ show.positionne((double *) &noeuds[DIMENSION*i]);
+ return show;
+ }
+ int size() const {return nbr_noeuds;}
+ int SIZE() const {return nbr_noeuds;}
+ void affiche()
+ {
+ int i,j;
+ for (i=0;i<nbr_noeuds;i++)
+ {
+ cout<<"Noeud "<<i<<" : "<<flush;
+ for (j=0;j<DIMENSION;j++) cout<<noeuds[i*DIMENSION+j]<<" "<<flush;
+ cout<<endl;
+ }
+ }
+ };
+
+#endif
--- /dev/null
+#ifndef MEDMEM_DTREE_HXX
+#define MEDMEM_DTREE_HXX
+
+#include "MEDMEM_dTreeSommet.hxx"
+
+#define DTREE_FANTOME -1
+#define DTREE_RACINE 0
+#define DTREE_TERMINAL 1
+#define DTREE_COURANT 2
+// etat_descendance
+#define DTREE_NON_CALCULE -1
+#define DTREE_AUCUNE 0
+#define DTREE_VALIDE 1
+// val min nbr noeud
+#define DTREE_NBR_MIN_NOEUDS 1
+#define DTREE_NBR_MAX_DESC 8
+// pour meilleu re lecture
+#define _TEMPLATE_ template <class NOEUD,class NUAGENOEUD,int DIMENSION,int NBR_NOEUDS_PAR_CASE>
+#define _DTREE_ dTree<NOEUD,NUAGENOEUD,DIMENSION,NBR_NOEUDS_PAR_CASE>
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Calcul Statique de Puissance */
+/* */
+/*********************************************************/
+
+// Permet de Calculer 2^n de façon statique
+
+template < int DIMENSION > struct DeuxPuissance
+ {
+ enum { valeur = 2 * DeuxPuissance<DIMENSION-1>::valeur } ;
+ };
+
+template <> struct DeuxPuissance<0>
+ {
+ enum { valeur = 1 } ;
+ };
+
+/*********************************************************/
+/* */
+/* DTREE */
+/* */
+/*********************************************************/
+
+// Classe Utilisateur
+// # Bugs connus :
+// - Problemes avec points sur les faces des hypercubes ?
+// - Plantage sauvage si le point est plus loin de l'hypercube père que le diametre Linf de celui-ci.
+// # Politique de classe :
+// - NOEUD : voir dans MEDMEM_WrapperNodes.hxx la classe Wrapper_Noeud<..>
+// - NUAGENOEUD : typiquement, c'est vector<NOEUD> en rédefinissant NUAGENOEUD<...>::SIZE()=vector<...>::size()
+// Remarques :
+// - NBR_NOEUDS_PAR_CASE ne doit pas être modifié sauf peut-être dans le cas où l'utilisateur veut utiliser des d-Tree parallèles
+
+template <class NOEUD,class NUAGENOEUD,int DIMENSION,int NBR_NOEUDS_PAR_CASE=DTREE_NBR_MIN_NOEUDS> class dTree
+{
+protected :
+ // types
+ typedef _DTREE_ * Ptr_dTree;
+ // Static Const
+ static const int nbr_descendants=DeuxPuissance<DIMENSION>::valeur;
+ // champs
+ NUAGENOEUD * nuage;
+ Ptr_dTree descendant[nbr_descendants];
+ vector<int> * noeud_contenu;
+ int etat;
+ int niveau;
+ dTree * pere;
+ Sommet_dTree<DIMENSION> coord_max;
+ Sommet_dTree<DIMENSION> coord_min;
+public :
+
+ void init();
+ dTree();
+ dTree(NUAGENOEUD *n);
+ dTree(const Sommet_dTree<DIMENSION> &A,const Sommet_dTree<DIMENSION> &B,dTree *mypere);
+ dTree(const dTree &F);
+ ~dTree();
+ void Get_Noeuds_Filtre(vector<int> &tmp);
+ Sommet_dTree<DIMENSION> Get_Max() const;
+ Sommet_dTree<DIMENSION> Get_Min() const;
+ int is_in_dTree(NOEUD P) const;
+ double calcule_distance(NOEUD P) const;
+ dTree & operator = (const dTree & F);
+ Sommet_dTree<DIMENSION> dTree::donne_sommet(int selecteur) const;
+ int a_des_fils() const;
+ dTree * trouve_dTree_contenant(NOEUD P) const;
+ int trouve_plus_proche_point_bourrin(NOEUD P) const;
+ int trouve_plus_proche_point(NOEUD P) const;
+ int trouve_un_point() const;
+ int tppp_rec(NOEUD P,double &delta,int &flag) const;
+ int Localise_Point(NOEUD P,double d) const;
+ void cree_filiation();
+ int Get_Nbr_Descendants_Non_Vides() const;
+ int Get_Nbr_Descendants_Vides() const;
+ int Get_Profondeur_Max() const;
+};
+
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// CODE ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+_TEMPLATE_ void _DTREE_::init()
+ {
+ int i;
+ nuage=NULL;
+ noeud_contenu=NULL;
+ etat=DTREE_FANTOME;
+ for (i=0;i<nbr_descendants;i++) descendant[i]=NULL;
+ niveau=-1;
+ pere=NULL;
+ }
+_TEMPLATE_ _DTREE_::dTree()
+ {
+ init();
+ coord_max=0.0;
+ coord_min=0.0;
+ }
+_TEMPLATE_ _DTREE_::dTree(NUAGENOEUD *n)
+ {
+
+ int i,j;
+ double tmp;
+
+ if (n==NULL)
+ {
+ cerr<<"DTREE : Nuage vide !"<<endl;
+ exit(-1);
+ }
+
+ init();
+ nuage=n;
+ etat=DTREE_RACINE;
+ noeud_contenu=new vector<int>(nuage->size());
+ niveau=0;
+
+ for (i=0;i<DIMENSION;i++)
+ {
+ coord_max[i]=(*nuage)[0][i];
+ coord_min[i]=(*nuage)[0][i];
+ }
+ (*noeud_contenu)[0]=0;
+ for (i=1;i<nuage->size();i++)
+ {
+ (*noeud_contenu)[i]=i;
+ for (j=0;j<DIMENSION;j++)
+ {
+ if ((*nuage)[i][j]>coord_max[j]) coord_max[j]=(*nuage)[i][j];
+ if ((*nuage)[i][j]<coord_min[j]) coord_min[j]=(*nuage)[i][j];
+ }
+ }
+ for (j=0;j<DIMENSION;j++)
+ {
+ tmp=(coord_max[j]-coord_min[j])*0.01;
+ coord_max[j]+=tmp;
+ coord_min[j]-=tmp;
+ }
+
+ cree_filiation();
+
+ }
+_TEMPLATE_ _DTREE_::dTree(const Sommet_dTree<DIMENSION> &A,const Sommet_dTree<DIMENSION> &B,dTree *mypere)
+ {
+ if (mypere!=NULL)
+ {
+ int i,j;
+ double tmp;
+
+ init();
+
+ pere=mypere;
+ nuage=pere->nuage;
+ niveau=pere->niveau+1;
+
+ etat=DTREE_COURANT;
+
+ noeud_contenu=new vector<int>;
+ noeud_contenu->reserve((pere->noeud_contenu->size())/nbr_descendants);
+
+ for (i=0;i<DIMENSION;i++)
+ {
+ coord_max[i]=(*nuage)[0][i];
+ coord_min[i]=(*nuage)[0][i];
+ }
+
+ for (i=0;i<DIMENSION;i++)
+ {
+ if (A[i]>B[i])
+ {
+ coord_max[i]=A[i];
+ coord_min[i]=B[i];
+ }
+ else
+ {
+ coord_min[i]=A[i];
+ coord_max[i]=B[i];
+ }
+ }
+ }
+ else
+ {
+ cerr<<"DTREE : Construction de descendance sans père !"<<endl;
+ exit(-1);
+ }
+ }
+_TEMPLATE_ _DTREE_::dTree(const _DTREE_ &F)
+ {
+ // Pas Super Top Moumoute ... Recopie de pointeurs et pas de contenus, merdique
+ int i,j;
+ init();
+ for (i=0;i<nbr_descendants;i++) descendant[i]=F.descendant[i];
+ noeud_contenu=F.noeud_contenu;
+ etat=F.etat;
+ niveau=F.niveau;
+ pere=F.pere;
+ coord_max=F.coord_max;
+ coord_min=F.coord_min;
+ }
+_TEMPLATE_ _DTREE_::~dTree()
+ {
+ int i;
+ nuage=NULL;
+ pere=NULL;
+ // cout<<*this<<endl;
+ if (noeud_contenu)
+ {
+ delete noeud_contenu;
+ }
+ for (i=0;i<nbr_descendants;i++) if (descendant[i])
+ {
+ delete descendant[i];
+ }
+ }
+_TEMPLATE_ void _DTREE_::Get_Noeuds_Filtre(vector<int> &tmp)
+ {
+ int i;
+ switch (etat)
+ {
+ case DTREE_RACINE : int pourlefunlecompilolesttropcon;
+ case DTREE_COURANT :
+ for (i=0;i<nbr_descendants;i++) descendant[i]->Get_Noeuds_Filtre(tmp);
+ case DTREE_TERMINAL :
+ if (noeud_contenu->size()>0)
+ {
+ for (i=0;i<NBR_NOEUDS_PAR_CASE;i++) tmp.push_back((*noeud_contenu)[i]);
+ }
+ default :
+ cerr<<"DTREE : dTree Non Valide dans Rempli_Noeuds_Filtre"<<endl;
+ exit(-1);
+ }
+ }
+_TEMPLATE_ Sommet_dTree<DIMENSION> _DTREE_::Get_Max() const
+ {
+ return coord_max;
+ }
+_TEMPLATE_ Sommet_dTree<DIMENSION> _DTREE_::Get_Min() const
+ {
+ return coord_min;
+ }
+_TEMPLATE_ int _DTREE_::is_in_dTree(NOEUD P) const
+ {
+ int test;
+ for (int i=0;i<DIMENSION;i++)
+ {
+ test=((coord_min[i]<=P[i])&&(P[i]<=coord_max[i]));
+ if (!test) return 0;
+ }
+ return 1;
+
+ }
+// calcule la distance Linf d'un point exterieur, si le point est interieur, le resultat sera erroné
+_TEMPLATE_ double _DTREE_::calcule_distance(NOEUD P) const
+ {
+ double min=fabs(coord_max[0]-P[0]);
+ double tmp;
+ int i;
+ for (i=0;i<DIMENSION;i++)
+ {
+ tmp=fabs(coord_max[i]-P[i]);
+ if (min>tmp) min=tmp;
+ tmp=fabs(coord_min[i]-P[i]);
+ if (min>tmp) min=tmp;
+ }
+ return min;
+ }
+_TEMPLATE_ _DTREE_ & _DTREE_::operator = (const _DTREE_ & F)
+ {
+ // Pas Super Top Moumoute ... Recopie de pointeurs et pas de contenus, merdique
+ int i,j;
+ init();
+ for (i=0;i<nbr_descendans;i++) descendant[i]=F.descendant[i];
+ noeud_contenu=F.noeud_contenu;
+ etat=F.etat;
+ niveau=F.niveau;
+ pere=F.pere;
+ coord_max=F.coord_max;
+ coord_min=F.coord_min;
+ }
+// selecteur doit etre lu comme un nombre en base 2
+// il specifie les coordonnes de reference du sommet dont on veut les coordonnees reelles
+// ex : en dim 3 : coord_min=0+0*2+0*4=0
+// coord_max=1+1*2*1*4=7
+// donc les unites pour x, les 2aines pour y, les 4aines pour z
+_TEMPLATE_ Sommet_dTree<DIMENSION> _DTREE_::donne_sommet(int selecteur) const
+ {
+ Sommet_dTree<DIMENSION> p;
+ int i;
+ int residu=selecteur;
+ int reste;
+ for (i=0;i<DIMENSION;i++)
+ {
+ reste=residu%2;
+ if (reste==0) p[i]=coord_min[i]; else p[i]=coord_max[i];
+ residu=(residu-reste)/2;
+ }
+ return p;
+ }
+_TEMPLATE_ int _DTREE_::a_des_fils() const
+ {
+ if ((etat==DTREE_COURANT)||(etat=DTREE_RACINE)) return 1;
+ else return 0;
+ }
+_TEMPLATE_ _DTREE_ * _DTREE_::trouve_dTree_contenant(NOEUD P) const
+ {
+ Sommet_dTree<DIMENSION> B(coord_min,coord_max);
+ int i;
+ if ((etat==DTREE_RACINE)&&(!is_in_dTree(P))) return NULL; // Le noeud est extérieur a l'dTree
+ else if (etat==DTREE_TERMINAL) return (dTree *) this; // Le noeud est dans *this qui est terminal
+
+ for (i=0;i<nbr_descendants;i++)
+ {
+ Sommet_dTree<DIMENSION> A=donne_sommet(i);
+ int test,j;
+ for (j=0;j<DIMENSION;j++)
+ {
+ if (A[j]<=B[j]) test=((A[j]<=P[j])&&(P[j]<=B[j]));
+ else test=((A[j]>=P[j])&&(P[j]>=B[j]));
+ if (!test) break;
+ }
+
+ if (test) return descendant[i]->trouve_dTree_contenant(P); // Propagation
+ }
+ }
+// si de le dTree n'est pas TERMINAL, scanne tous les points du nuage du pere pour trouver le point le plus proche
+// sinon scanne uniquement les points contenus dans le dTree
+_TEMPLATE_ int _DTREE_::trouve_plus_proche_point_bourrin(NOEUD P) const
+ {
+ int i;
+ int num_sol;
+ double min;
+ double tmp;
+ if (etat!=DTREE_TERMINAL)
+ {
+ min=DistanceL2(P,(*nuage)[0]);
+ for (i=1;i<nuage->size();i++)
+ {
+ tmp=DistanceL2(P,(*nuage)[i]);
+ if (tmp<min)
+ {
+ num_sol=i;
+ min=tmp;
+ }
+ }
+ return num_sol;
+ }
+ else
+ {
+ if (noeud_contenu->size()!=0)
+ {
+ num_sol=(*noeud_contenu)[0];
+ min=DistanceL2(P,(*nuage)[num_sol]);
+ for (i=1;i<noeud_contenu->size();i++)
+ {
+ tmp=DistanceL2(P,(*nuage)[(*noeud_contenu)[i]]);
+ if (tmp<min)
+ {
+ num_sol=(*noeud_contenu)[i];
+ min=tmp;
+ }
+ }
+ return num_sol;
+ }
+ else return DTREE_FANTOME;
+ }
+ }
+// Fonction de pilotage de la recursion, lance les tests preliminaires et invoque la recursion
+_TEMPLATE_ int _DTREE_::trouve_plus_proche_point(NOEUD P) const
+ {
+
+ if (etat==DTREE_FANTOME)
+ {
+ cerr<<"DTREE : TROUVE PLUS PROCHE POINT : L'octree n'est pas construit !"<<endl;
+ exit(-1);
+ }
+ dTree *ref=trouve_dTree_contenant(P);
+ double delta;
+
+ if (ref!=NULL)
+ {
+ // Le point est intérieur
+
+ if (ref->pere!=NULL)
+ {
+ delta=DistanceInf((ref->pere->coord_max),(ref->pere->coord_min));
+ }
+ else
+ {
+ cerr<<"DTREE : TROUVE PLUS PROCHE POINT : l'octree contenant le noeud n'a pas de pere !"<<endl;
+ exit(-1);
+ }
+ }
+ else
+ {
+ // Le point est extérieur
+
+ delta=DistanceL2(P,(*nuage)[0]);
+ }
+
+ int flag=0;
+ int retour;
+
+ retour=tppp_rec(P,delta,flag);
+
+ return retour;
+ }
+_TEMPLATE_ int _DTREE_::trouve_un_point() const
+ {
+ if (noeud_contenu!=NULL)
+ {
+ if (noeud_contenu->size()>0) return (*(noeud_contenu))[0];
+ }
+ else
+ {
+ int i;
+ for (i=0;i<nbr_descendants;i++)
+ {
+ return descendant[i]->trouve_un_point();
+ }
+ }
+ }
+// partie recursive de l'algo ci dessus
+// change le flag en 1 si un point plus proche est trouvé
+// adapte automatiquement la distance delta de filtrage
+_TEMPLATE_ int _DTREE_::tppp_rec(NOEUD P,double &delta,int &flag) const
+ {
+ if (Localise_Point(P,delta)==0)
+ {
+ // La distance du point à l'octree est plus grande que delta
+ return DTREE_FANTOME;
+ }
+ int num_Ptmp;
+ double dtmp;
+ if (etat==DTREE_TERMINAL)
+ {
+ if (noeud_contenu->size()>0)
+ {
+ num_Ptmp=trouve_plus_proche_point_bourrin(P);
+ dtmp=DistanceL2((*nuage)[num_Ptmp],P);
+ if (dtmp<=delta)
+ {
+ // Le point le plus proche minimise delta, c'est un bon candidat, on l'envoie !
+ delta=dtmp;
+ flag=1;
+ return num_Ptmp;
+ }
+ // Le point le plus proche ne minimise pas delta
+ // ===========> peut etre rajouter exit(-1); ??????????
+ return DTREE_FANTOME;
+ }
+ else
+ {
+ // L'octree qui contient P ne contient aucun point
+ return DTREE_FANTOME;
+ }
+ }
+ int i;
+ int num_sol=DTREE_FANTOME;
+ for (i=0;i<nbr_descendants;i++)
+ {
+ num_Ptmp=descendant[i]->tppp_rec(P,delta,flag);
+ if ((num_Ptmp!=DTREE_FANTOME)&&(flag==1))
+ {
+ // On a trouvé un point qui minimise delta dans une branche
+ num_sol=num_Ptmp;
+ }
+ }
+ // A ce stade, on a trouvé un point qui minimise tous les deltas, c'est donc le point le plus proche
+ return num_sol;
+ }
+// renvoie 1 si la distance L inf du noeud a l'octree est plus petite que d, 0 sinon
+_TEMPLATE_ int _DTREE_::Localise_Point(NOEUD P,double d) const
+ {
+ int i;
+ for (i=0;i<DIMENSION;i++)
+ {
+ if (P[i]>coord_max[i]+d) return 0;
+ if (P[i]<coord_min[i]-d) return 0;
+ }
+ return 1;
+ }
+// Méthode de construction du dTree par propagation
+_TEMPLATE_ void _DTREE_::cree_filiation()
+ {
+ if (etat!=DTREE_RACINE)
+ {
+ niveau=pere->niveau+1;
+ }
+ else
+ {
+ niveau=0;
+ }
+
+ if (noeud_contenu->size()<=NBR_NOEUDS_PAR_CASE)
+ {
+ etat=DTREE_TERMINAL;
+ }
+ else
+ {
+ int i,num_loc,test;
+
+ Sommet_dTree<DIMENSION> centre(coord_max,coord_min);
+
+ for (i=0;i<nbr_descendants;i++)
+ {
+ descendant[i]=new dTree(centre,donne_sommet(i),this);
+ }
+
+ for (num_loc=0;num_loc<noeud_contenu->size();num_loc++)
+ {
+ int indice=(*noeud_contenu)[num_loc];
+ NOEUD & courant=(*nuage)[indice];
+ test=1;
+ for (i=0;(test)&&(i<nbr_descendants);i++)
+ {
+ if (descendant[i]->is_in_dTree(courant))
+ {
+ descendant[i]->noeud_contenu->push_back(indice);
+ test=0;
+ }
+ }
+ }
+
+ delete noeud_contenu;
+ noeud_contenu=NULL;
+
+ for (i=0;i<nbr_descendants;i++) descendant[i]->cree_filiation();
+ }
+ }
+_TEMPLATE_ int _DTREE_::Get_Nbr_Descendants_Non_Vides() const
+ {
+ int i;
+ int ndnv=0;
+ switch (etat)
+ {
+ case DTREE_RACINE : int pourlefunlecompilolesttropcon;
+ case DTREE_COURANT :
+ for (i=0;i<nbr_descendants;i++) ndnv+=descendant[i]->Get_Nbr_Descendants_Non_Vides();
+ return ndnv;
+ case DTREE_TERMINAL :
+ if (noeud_contenu->size()>0) return 1;
+ else return 0;
+ default :
+ cerr<<"dTree Non Valide dans Get_Nbr_Descendants_Non_Vides"<<endl;
+ return -1;
+ }
+ }
+_TEMPLATE_ int _DTREE_::Get_Nbr_Descendants_Vides() const
+ {
+ int i;
+ int ndnv=0;
+ switch (etat)
+ {
+ case DTREE_RACINE : int pourlefunlecompilolesttropcon;
+ case DTREE_COURANT :
+ for (i=0;i<nbr_descendants;i++) ndnv+=descendant[i]->Get_Nbr_Descendants_Vides();
+ return ndnv;
+ case DTREE_TERMINAL :
+ if (noeud_contenu->size()==0) return 1;
+ else return 0;
+ default :
+ cerr<<"dTree Non Valide dans Get_Nbr_Descendants_Non_Vides"<<endl;
+ return -1;
+ }
+ }
+_TEMPLATE_ int _DTREE_::Get_Profondeur_Max() const
+ {
+ int i;
+ int prof=0;
+ int tmp;
+ switch (etat)
+ {
+ case DTREE_RACINE : int pourlefunlecompilolesttropcon;
+ case DTREE_COURANT :
+ for (i=0;i<nbr_descendants;i++)
+ {
+ tmp=descendant[i]->Get_Profondeur_Max();
+ if (tmp>prof) prof=tmp;
+ }
+ return prof;
+ case DTREE_TERMINAL : return niveau;
+ default :
+ cerr<<"dTree Non Valide dans Get_Nbr_Descendants_Non_Vides"<<endl;
+ return -1;
+ }
+ }
+
+#undef _TEMPLATE_
+#undef _DTREE_
+
+
+#endif
--- /dev/null
+#ifndef SOMMET_HPP
+#define SOMMET_HPP
+
+
+// La classe qui suit sert UNIQUEMENT pour les sommets du dTree
+
+template <int DIMENSION> class Sommet_dTree
+{
+protected :
+ double coord[DIMENSION];
+public :
+ Sommet_dTree()
+ {
+ }
+ Sommet_dTree(double *c)
+ {
+ for (int i=0;i<DIMENSION;i++) coord[i]=c[i];
+ }
+ Sommet_dTree(double c)
+ {
+ for (int i=0;i<DIMENSION;i++) coord[i]=c;
+ }
+ Sommet_dTree(const Sommet_dTree & SO)
+ {
+ for (int i=0;i<DIMENSION;i++) coord[i]=SO.coord[i];
+ }
+ Sommet_dTree(const Sommet_dTree &s1,const Sommet_dTree &s2)
+ {
+ for (int i=0;i<DIMENSION;i++) coord[i]=0.5*(s1[i]+s2[i]);
+ }
+ ~Sommet_dTree()
+ {
+ }
+ const double operator[](int i) const
+ {
+ return coord[i];
+ }
+ double & operator[](int i)
+ {
+ return coord[i];
+ }
+ Sommet_dTree & operator=(const Sommet_dTree &f)
+ {
+ for (int i=0;i<DIMENSION;i++) coord[i]=f.coord[i];return *this;
+ }
+ friend double DistanceInf(const Sommet_dTree<DIMENSION> &A,const Sommet_dTree<DIMENSION> &B)
+ {
+ double max=0;
+ double tmp;
+ for (int i=0;i<DIMENSION;i++)
+ {
+ tmp=fabs(A[i]-B[i]);
+ if (tmp>max) max=tmp;
+ }
+ return max;
+ }
+};
+
+#endif
--- /dev/null
+#include <med.h>
+#include <string.h>
+
+#define MED_NOPG 1 /* -> pas de point de Gauss */
+#define MED_NOPFL "" /* -> pas de profils utilisateur */
+#define MED_NOPFLi " " /* Variable Interne */
+#define MED_NOPF 0 /* -> pas de profils pour _MEDdataseNnumEcrire */
+#define MED_NOPDT -1 /* rem: pas de pas de temps negatifs */
+#define MED_NONOR -1 /* rem: pas de n°ordre negatif */
+#define MED_DIM1 1 /* PAS */
+
+#define MED_ALL 0
+
+/*****************************************************************************************************/
+
+void affiche_noeuds(med_float * nodes,int nnpl)
+ {
+ int nbr_nodes=nnpl*nnpl*nnpl;
+ int i;
+
+ for (i=0;i<nbr_nodes;i++) printf("Noeud %d : ( %4.5f ; %4.5f ; %4.5f )\n",i+1,nodes[3*i],nodes[3*i+1],nodes[3*i+2]);
+
+ }
+
+
+void cree_nodes(med_float * coord_nodes,int nnpl, int flag)
+ {
+ int i,j,k;
+ int nbr_nodes=nnpl*nnpl*nnpl;
+ int num_noeud;
+ int diviseur=nnpl-1+flag;
+
+ /*coord_nodes=(med_float *) malloc(3*nbr_nodes*sizeof(med_float));*/
+
+ for (i=0;i<nnpl;i++) for (j=0;j<nnpl;j++) for (k=0;k<nnpl;k++)
+ {
+ num_noeud=i+nnpl*j+nnpl*nnpl*k;
+
+ if (3*num_noeud >=3*nbr_nodes) {printf("%d : OUT OF RANGE REQUEST\n",num_noeud);exit(-1);}
+ if (3*num_noeud+1>=3*nbr_nodes) {printf("%d : OUT OF RANGE REQUEST\n",num_noeud);exit(-1);}
+ if (3*num_noeud+2>=3*nbr_nodes) {printf("%d : OUT OF RANGE REQUEST\n",num_noeud);exit(-1);}
+
+ coord_nodes[3*num_noeud ]= (double) (i+flag)/diviseur;
+ coord_nodes[3*num_noeud+1]= (double) (j+flag)/diviseur;
+ coord_nodes[3*num_noeud+2]= (double) (k+flag)/diviseur;
+ }
+
+ affiche_noeuds(coord_nodes,nnpl);
+
+ }
+void cree_num_nodes(med_int * num_nodes,int nnpl)
+ {
+ int nbr_nodes=nnpl*nnpl*nnpl;
+ int i;
+ /*num_nodes=(med_int *) malloc(nbr_nodes*sizeof(med_int));*/
+ for (i=0;i<nbr_nodes;i++) num_nodes[i]=i+1;
+ }
+void cree_Hexa8(med_int * conn_hexa8, int nnpl)
+ {
+ int i,j,k;
+ int i0,j0,k0,i1,j1,k1;
+ int nbr_nodes=nnpl*nnpl*nnpl;
+ int nbr_hexa8=(nnpl-1)*(nnpl-1)*(nnpl-1);
+ int num_hexa8;
+
+ /*conn_hexa8=(med_int *) malloc(8*nbr_hexa8*sizeof(med_int));*/
+
+ for (i=0;i<nnpl-1;i++) for (j=0;j<nnpl-1;j++) for (k=0;k<nnpl-1;k++)
+ {
+ i0=i;j0=j;k0=k;
+ i1=i+1;j1=j+1;k1=k+1;
+
+ num_hexa8=i+(nnpl-1)*j+(nnpl-1)*(nnpl-1)*k;
+
+ printf("Maille numéro %4d :",num_hexa8);
+
+ if (8*num_hexa8 >=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+ if (8*num_hexa8+1>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+ if (8*num_hexa8+2>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+ if (8*num_hexa8+3>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+ if (8*num_hexa8+4>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+ if (8*num_hexa8+5>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+ if (8*num_hexa8+6>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+ if (8*num_hexa8+7>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+
+ conn_hexa8[8*num_hexa8 ] = 1 + i0+nnpl*j1+nnpl*nnpl*k1 ; printf("%4d ",1+i0+nnpl*j1+nnpl*nnpl*k1);
+ conn_hexa8[8*num_hexa8+1] = 1 + i0+nnpl*j0+nnpl*nnpl*k1 ; printf("%4d ",1+i0+nnpl*j0+nnpl*nnpl*k1);
+ conn_hexa8[8*num_hexa8+2] = 1 + i1+nnpl*j0+nnpl*nnpl*k1 ; printf("%4d ",1+i1+nnpl*j0+nnpl*nnpl*k1);
+ conn_hexa8[8*num_hexa8+3] = 1 + i1+nnpl*j1+nnpl*nnpl*k1 ; printf("%4d ",1+i1+nnpl*j1+nnpl*nnpl*k1);
+ conn_hexa8[8*num_hexa8+4] = 1 + i0+nnpl*j1+nnpl*nnpl*k0 ; printf("%4d ",1+i0+nnpl*j1+nnpl*nnpl*k0);
+ conn_hexa8[8*num_hexa8+5] = 1 + i0+nnpl*j0+nnpl*nnpl*k0 ; printf("%4d ",1+i0+nnpl*j0+nnpl*nnpl*k0);
+ conn_hexa8[8*num_hexa8+6] = 1 + i1+nnpl*j0+nnpl*nnpl*k0 ; printf("%4d ",1+i1+nnpl*j0+nnpl*nnpl*k0);
+ conn_hexa8[8*num_hexa8+7] = 1 + i1+nnpl*j1+nnpl*nnpl*k0 ; printf("%4d ",1+i1+nnpl*j1+nnpl*nnpl*k0);
+
+ printf("\n");
+ }
+ }
+void cree_noms_mailles(char * noms, int nnpl)
+ {
+ int nbr_hexa8=(nnpl-1)*(nnpl-1)*(nnpl-1);
+ int i;
+ char pnom[MED_TAILLE_PNOM+1]="hexa ";
+
+ /*noms=(char *) malloc((nbr_hexa8*MED_TAILLE_PNOM+1)*sizeof(char));*/
+
+ for (i=0;i<nbr_hexa8;i++) strncpy(&noms[i*MED_TAILLE_PNOM],pnom,MED_TAILLE_PNOM);
+
+ noms[nbr_hexa8*MED_TAILLE_PNOM]='\n';
+
+ }
+void cree_num_mailles(med_int * num_mailles,int nnpl)
+ {
+ int nbr_hexa8=(nnpl-1)*(nnpl-1)*(nnpl-1);
+ int i;
+
+ /*num_mailles=(med_int *) malloc(nbr_hexa8*sizeof(med_int));*/
+
+ for (i=0;i<nbr_hexa8;i++) num_mailles[i]=i+1;
+ }
+void cree_fam_nodes(med_int * fam,int nnpl)
+ {
+ int nbr_nodes=nnpl*nnpl*nnpl;
+ int i;
+
+ /*fam=(med_int *) malloc(nbr_nodes*sizeof(med_int));*/
+
+ for (i=0;i<nbr_nodes;i++) fam[i]=0;
+ }
+void cree_fam_mailles(med_int * fam,int nnpl)
+ {
+ int nbr_hexa8=(nnpl-1)*(nnpl-1)*(nnpl-1);
+ int i;
+
+ /*fam=(med_int *) malloc(nbr_hexa8*sizeof(med_int));*/
+
+ for (i=0;i<nbr_hexa8;i++) fam[i]=0;
+ }
+void cree_valeurs_champ_node(med_float * val,int nnpl)
+ {
+ int i,j,k;
+ int nbr_nodes=nnpl*nnpl*nnpl;
+ int num_noeud;
+ int diviseur=nnpl-1;
+
+ /*val=(med_float *) malloc(nbr_nodes*sizeof(med_float));*/
+
+ for (i=0;i<nnpl;i++) for (j=0;j<nnpl;j++) for (k=0;k<nnpl;k++)
+ {
+ num_noeud=i+nnpl*j+nnpl*nnpl*k;
+ val[num_noeud] = (med_float) (i+j+k)/diviseur;
+ }
+ }
+void cree_valeurs_champ_vector_cell(med_float * val,int nnpl)
+ {
+ int i,j,k;
+ int nbr_cells=(nnpl-1)*(nnpl-1)*(nnpl-1);
+ int num_cell;
+
+ int diviseur=nnpl-1;
+
+ /*val=(med_float *) malloc(3*nbr_cells*sizeof(med_float));*/
+
+ for (i=0;i<nnpl-1;i++) for (j=0;j<nnpl-1;j++) for (k=0;k<nnpl-1;k++)
+ {
+ num_cell=i+(nnpl-1)*j+(nnpl-1)*(nnpl-1)*k;
+ val[3*num_cell ] = (med_float) i/diviseur;
+ val[3*num_cell+1] = (med_float) j/diviseur;
+ val[3*num_cell+2] = (med_float) k/diviseur;
+ }
+ }
+
+
+/*****************************************************************************************************/
+
+int main (int argc, char **argv)
+ {
+
+ int i,j,k;
+
+ int nnpl;
+
+ int nbr_nodes, nbr_hexa8;
+
+ med_err ret;
+ med_idt fromfid;
+ med_idt tofid;
+ char frommaa[MED_TAILLE_NOM+1] = "fromMesh";
+ char tomaa[MED_TAILLE_NOM+1] = "toMesh";
+ const med_int mdim = 3;
+ med_int fromnnoe;
+ med_int tonnoe;
+
+ med_float * tocoo;
+ med_float * fromcoo;
+
+ char nomcoo[3*MED_TAILLE_PNOM+1] = "x y z ";
+ char unicoo[3*MED_TAILLE_PNOM+1] = "cm cm cm ";
+
+ char * nomnoe = NULL ;
+
+ med_int * fromnumnoe;
+ med_int * fromnufano;
+
+ med_int * tonumnoe;
+ med_int * tonufano;
+
+ med_int fromnhexa8;
+ med_int * fromhexa8;
+
+ med_int tonhexa8;
+ med_int * tohexa8;
+
+
+ char * fromnomhexa8;
+ med_int * fromnumhexa8;
+ med_int * fromnufahexa8;
+
+ char * tonomhexa8;
+ med_int * tonumhexa8;
+ med_int * tonufahexa8;
+
+/*****************************************************************************************************/
+
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ char attdes[MED_TAILLE_DESC+1];
+ med_int natt;
+ med_int attide;
+ med_int attval;
+ med_int ngro;
+ char gro[MED_TAILLE_LNOM+1];
+ char gro2[MED_TAILLE_LNOM*2+1];
+ char gro3[MED_TAILLE_LNOM*3+1];
+ int nfame = 1;
+ int nfamn = 1;
+
+/*****************************************************************************************************/
+
+ /* Some fields : one on nodes : double , one on cells : double */
+
+ char champnode[MED_TAILLE_NOM+1]="fieldnodedouble" ;
+ char champnode_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champnode_unit[MED_TAILLE_PNOM+1]="J " ;
+ med_float * fieldnodedouble;
+
+ char champcell[MED_TAILLE_NOM+1]="fieldcelldoublevector" ;
+ char champcell_comp[MED_TAILLE_PNOM*3+1]="comp1 comp2 comp3 " ;
+ char champcell_unit[MED_TAILLE_PNOM*3+1]="m/s m/s m/s " ;
+ med_float * fieldcelldoublevector;
+
+/*****************************************************************************************************/
+
+
+ if (argc!=2)
+ {
+ printf("Il manque un paramètre : le nombre de point par ligne\n");
+ exit(-1);
+ }
+
+ sscanf(argv[1],"%d",&nnpl);
+
+ printf("Traitement avec %d noeuds par ligne\n",nnpl);
+
+ fromnnoe = nnpl*nnpl*nnpl ;
+ fromnhexa8 = (nnpl-1)*(nnpl-1)*(nnpl-1) ;
+ tonnoe = (nnpl-1)*(nnpl-1)*(nnpl-1) ;
+ tonhexa8 = (nnpl-2)*(nnpl-2)*(nnpl-2) ;
+
+
+
+ nbr_nodes=nnpl*nnpl*nnpl;
+ nbr_hexa8=(nnpl-1)*(nnpl-1)*(nnpl-1);
+
+ fromcoo = (med_float *) malloc(3*nbr_nodes*sizeof(med_float)); cree_nodes ( fromcoo , nnpl, 0 );
+ fromnumnoe = (med_int *) malloc(nbr_nodes*sizeof(med_int)); cree_num_nodes ( fromnumnoe , nnpl );
+ fromnufano = (med_int *) malloc(nbr_nodes*sizeof(med_int)); cree_fam_nodes ( fromnufano , nnpl );
+ fromhexa8 = (med_int *) malloc(8*nbr_hexa8*sizeof(med_int)); cree_Hexa8 ( fromhexa8 , nnpl );
+ fromnomhexa8 = (char *) malloc((nbr_hexa8*MED_TAILLE_PNOM+1)*sizeof(char)); cree_noms_mailles ( fromnomhexa8 , nnpl );
+ fromnumhexa8 = (med_int *) malloc(nbr_hexa8*sizeof(med_int)); cree_num_mailles ( fromnumhexa8 , nnpl );
+ fromnufahexa8 = (med_int *) malloc(nbr_hexa8*sizeof(med_int)); cree_fam_mailles ( fromnufahexa8 , nnpl );
+
+ fieldnodedouble = (med_float *) malloc(nbr_nodes*sizeof(med_float)); cree_valeurs_champ_node ( fieldnodedouble , nnpl );
+ fieldcelldoublevector = (med_float *) malloc(3*nbr_hexa8*sizeof(med_float)); cree_valeurs_champ_vector_cell ( fieldcelldoublevector , nnpl );
+
+ nbr_nodes=(nnpl-1)*(nnpl-1)*(nnpl-1);
+ nbr_hexa8=(nnpl-2)*(nnpl-2)*(nnpl-2);
+
+ tocoo = (med_float *) malloc(3*nbr_nodes*sizeof(med_float)); cree_nodes ( tocoo , nnpl-1, 1 );
+ tonumnoe = (med_int *) malloc(nbr_nodes*sizeof(med_int)); cree_num_nodes ( tonumnoe , nnpl-1 );
+ tonufano = (med_int *) malloc(nbr_nodes*sizeof(med_int)); cree_fam_nodes ( tonufano , nnpl-1 );
+ tohexa8 = (med_int *) malloc(8*nbr_hexa8*sizeof(med_int)); cree_Hexa8 ( tohexa8 , nnpl-1 );
+ tonomhexa8 = (char *) malloc((nbr_hexa8*MED_TAILLE_PNOM+1)*sizeof(char)); cree_noms_mailles ( tonomhexa8 , nnpl-1 );
+ tonumhexa8 = (med_int *) malloc(nbr_hexa8*sizeof(med_int)); cree_num_mailles ( tonumhexa8 , nnpl-1 );
+ tonufahexa8 = (med_int *) malloc(nbr_hexa8*sizeof(med_int)); cree_fam_mailles ( tonufahexa8 , nnpl-1 );
+
+
+/*****************************************************************************************************/
+ fromfid = MEDouvrir("fromMesh.med",MED_REMP);
+ if (fromfid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("MEDouvrir : %d\n",ret);
+
+/*****************************************************************************************************/
+ tofid = MEDouvrir("toMesh.med",MED_REMP);
+ if (tofid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("MEDouvrir : %d\n",ret);
+/*****************************************************************************************************/
+ if (ret == 0)
+ ret = MEDmaaCr(fromfid,frommaa,mdim);
+ printf("MEDmaaCr : %d\n",ret);
+
+/*****************************************************************************************************/
+
+ if (ret == 0)
+ ret = MEDmaaCr(tofid,tomaa,mdim);
+ printf("MEDmaaCr : %d\n",ret);
+
+/*****************************************************************************************************/
+ if (ret == 0)
+ ret = MEDnoeudsEcr(fromfid,frommaa,mdim,fromcoo,MED_FULL_INTERLACE,MED_CART,
+ nomcoo,unicoo,nomnoe,MED_FAUX,fromnumnoe,MED_VRAI,
+ fromnufano,fromnnoe,MED_ECRI);
+ printf("MEDnoeudsEcr : %d\n",ret);
+/*****************************************************************************************************/
+
+ if (ret == 0)
+ ret = MEDnoeudsEcr(tofid,tomaa,mdim,tocoo,MED_FULL_INTERLACE,MED_CART,
+ nomcoo,unicoo,nomnoe,MED_FAUX,tonumnoe,MED_VRAI,
+ tonufano,tonnoe,MED_ECRI);
+ printf("MEDnoeudsEcr : %d\n",ret);
+
+
+/*****************************************************************************************************/
+/* ecriture des mailles MED_HEXA8 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fromfid,frommaa,mdim,fromhexa8,MED_FULL_INTERLACE,
+ fromnomhexa8,MED_FAUX,fromnumhexa8,MED_VRAI,fromnufahexa8,fromnhexa8,
+ MED_MAILLE,MED_HEXA8,MED_NOD,MED_ECRI);
+ printf("MEDelementsEcr : %d \n",ret);
+
+/*****************************************************************************************************/
+/* ecriture des mailles MED_HEXA8 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+
+ if (ret == 0)
+ ret = MEDelementsEcr(tofid,tomaa,mdim,tohexa8,MED_FULL_INTERLACE,
+ tonomhexa8,MED_FAUX,tonumhexa8,MED_VRAI,tonufahexa8,tonhexa8,
+ MED_MAILLE,MED_HEXA8,MED_NOD,MED_ECRI);
+ printf("MEDelementsEcr : %d \n",ret);
+
+/*****************************************************************************************************/
+/* ecriture des familles */
+/* Conventions :
+ - toujours creer une famille de numero 0 ne comportant aucun attribut
+ ni groupe (famille de reference pour les noeuds ou les elements
+ qui ne sont rattaches a aucun groupe ni attribut)
+ - les numeros de familles de noeuds sont > 0
+ - les numeros de familles des elements sont < 0
+ - rien d'imposer sur les noms de familles
+ */
+
+/* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fromfid,frommaa,nomfam,numfam,&attide,&attval,attdes,0,gro,0);
+ }
+ printf("MEDfamCr : %d \n",ret);
+/*****************************************************************************************************/
+
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(tofid,tomaa,nomfam,numfam,&attide,&attval,attdes,0,gro,0);
+ }
+ printf("MEDfamCr : %d \n",ret);
+
+/*****************************************************************************************************/
+/* Les champs */
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fromfid,champnode,MED_REEL64,champnode_comp,champnode_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fromfid, frommaa, champnode, (unsigned char *)fieldnodedouble,
+ MED_NO_INTERLACE, fromnnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0. , MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fromfid,champcell,MED_REEL64,champcell_comp,champcell_unit,3);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fromfid, frommaa, champcell, (unsigned char *)fieldcelldoublevector,
+ MED_NO_INTERLACE, fromnhexa8,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+
+/***************************************************************************/
+ret = MEDfermer(fromfid);
+printf("MEDfermer : %d\n",ret);
+/***************************************************************************/
+ret = MEDfermer(tofid);
+printf("MEDfermer : %d\n",ret);
+
+return 0;
+}
+
--- /dev/null
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Interpolation.hxx"
+
+#include "stdio.h"
+
+main () {
+
+ const char * fromFileName = "fromMesh.med";
+ const char * toFileName = "toMesh.med";
+ //const char * fieldName = "fieldcelldoublevector";
+ const char * fieldName = "fieldnodedouble";
+
+ const char * fromMeshName = "fromMesh";
+ const char * toMeshName = "toMesh";
+
+ try {
+
+ cout<<"Lecture du Maillage Source : "<<flush; MESH fromMesh (MED_DRIVER,fromFileName,fromMeshName); cout<<"OK !"<<endl;
+ //cout<<"Construction du support : "<<flush; SUPPORT fromSupport (&fromMesh,"XsupportX",MED_CELL); cout<<"OK !"<<endl;
+ cout<<"Construction du support : "<<flush; SUPPORT fromSupport (&fromMesh,"XsupportX",MED_NODE); cout<<"OK !"<<endl;
+ cout<<"Lecture du champ : "<<flush; FIELD<double> fromField (&fromSupport,MED_DRIVER,fromFileName,fieldName); cout<<"OK !"<<endl;
+ cout<<"Lecture du Mailllage Cible : "<<flush; MESH toMesh (MED_DRIVER,toFileName,toMeshName); cout<<"OK !"<<endl;
+
+ INTERPOLATION<3> myInter (fromField,toMesh);
+
+ //FIELD<double> * toField = myInter.interpolate(0,1);
+ FIELD<double> * toField = myInter.interpolate(1,1);
+
+ cout<<"Creation du driver"<<endl;
+
+ toField->addDriver(MED_DRIVER,toFileName,toField->getName()) ;
+
+ cout<<"toField->getName() = "<<toField->getName() <<endl;
+ cout<<"toField->getDescription() = "<<toField->getDescription() <<endl;
+ cout<<"toField->getNumberOfComponents() = "<<toField->getNumberOfComponents() <<endl;
+ cout<<"toField->getNumberOfValues() = "<<toField->getNumberOfValues() <<endl;
+ cout<<"toField->getComponentsNames() = "<<toField->getComponentsNames() <<endl;
+ cout<<"toField->getComponentsDescriptions() = "<<toField->getComponentsDescriptions()<<endl;
+ cout<<"toField->getMEDComponentsUnits() = "<<toField->getMEDComponentsUnits() <<endl;
+ cout<<"toField->getIterationNumber() = "<<toField->getIterationNumber() <<endl;
+ cout<<"toField->getTime() = "<<toField->getTime() <<endl;
+ cout<<"toField->getOrderNumber() = "<<toField->getOrderNumber() <<endl;
+ cout<<"toField->getValueType() = "<<toField->getValueType() <<endl;
+
+ toField->write();
+
+ cout<<"Fin"<<endl;
+
+ } catch (MEDEXCEPTION& ex){
+ MESSAGE(ex.what()) ;
+ }
+}
@COMMENCE@
-SUBDIRS = MEDMEM MEDMEM_SWIG MedMem MED MEDGUI MedCorba_Swig MED_SWIG
+SUBDIRS = MEDMEM MEDMEM_SWIG MedMem MED MEDGUI MedCorba_Swig MED_SWIG MedClient
@MODULE@
--- /dev/null
+# MED MedClient : tool to transfer MED CORBA from server producer of MED object to a client using those MED object
+#
+# 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@
+VPATH=.:@srcdir@:@srcdir@/idl
+
+@COMMENCE@
+
+SUBDIRS = src test
+
+MODULE = MEDClient
+
+@MODULE@
--- /dev/null
+#include <convert.hxx>
+#include "UtilClient.hxx"
+#include "CONNECTIVITYClient.hxx"
+
+CONNECTIVITYClient::CONNECTIVITYClient(const SALOME_MED::MESH_ptr m,
+ medEntityMesh Entity) :
+ CONNECTIVITY(m->getNumberOfTypes(Entity), Entity),
+ IOR_Mesh(SALOME_MED::MESH::_duplicate(m)),
+ _numberOfElements_client(0),
+ _complete(false)
+{
+ BEGIN_OF("CONNECTIVITYClient::CONNECTIVITYClient()");
+
+ ASSERT(m);
+
+ blankCopy();
+
+ END_OF("CONNECTIVITYClient::CONNECTIVITYClient()");
+}
+
+CONNECTIVITYClient::~CONNECTIVITYClient()
+{
+ BEGIN_OF("CONNECTIVITYClient::~CONNECTIVITYClient()");
+
+ if (_numberOfElements_client)
+ delete [] _numberOfElements_client;
+
+ END_OF("CONNECTIVITYClient::~CONNECTIVITYClient()");
+}
+
+void CONNECTIVITYClient::blankCopy()
+{
+ BEGIN_OF("CONNECTIVITYClient::blankCopy()");
+
+ _numberOfNodes = IOR_Mesh->getNumberOfNodes();
+
+ medEntityMesh Entity = getEntity();
+ medGeometryElement * Types;
+
+ long iT, nT;
+ convertCorbaArray<SALOME_MED::medGeometryElement>
+ (Types, nT, IOR_Mesh->getTypes(Entity));
+
+ ASSERT(nT == (int) getNumberOfTypes(Entity));
+ SCRUTE(nT);
+
+ setGeometricTypes(Types, Entity);
+
+ _totalNumberOfElements_client = 0L;
+ _numberOfElements_client = new long[nT];
+ for (iT=0; iT<nT; iT++) {
+ _numberOfElements_client[iT]
+ = IOR_Mesh->getNumberOfElements(Entity, Types[iT]);
+ _totalNumberOfElements_client += _numberOfElements_client[iT];
+ SCRUTE(iT);
+ SCRUTE(_numberOfElements_client[iT]);
+ }
+
+ _complete = false;
+
+ END_OF("CONNECTIVITYClient::blankCopy()");
+}
+
+
+void CONNECTIVITYClient::fillCopy()
+{
+ BEGIN_OF("void CONNECTIVITYClient::fillCopy()");
+
+
+ if (!_complete) {
+
+ int *pC;
+ long nC;
+
+ medEntityMesh Entity = getEntity();
+ int iT, nT = getNumberOfTypes(Entity);
+ SCRUTE(nT);
+ const medGeometryElement * T = getGeometricTypes(Entity);
+
+ int * Count = new int[nT+1] ;
+ Count[0]=1 ;
+ SCRUTE(Count[0]);
+ for (iT=0; iT<nT; iT++) {
+ Count[iT+1]=Count[iT] + _numberOfElements_client[iT];
+ SCRUTE(Count[iT+1]);
+ }
+ setCount(Count, Entity) ;
+
+ for (iT=0; iT<nT; iT++) {
+
+ SCRUTE(iT);
+ int kT = Count[iT+1]-Count[iT];
+ SCRUTE(kT);
+
+ convertCorbaArray(pC, nC, IOR_Mesh->getConnectivity
+ (MED_FULL_INTERLACE, MED_NODAL, Entity, T[iT]));
+ SCRUTE(nC);
+ ASSERT(nC == (T[iT]%100) * kT);
+
+ setNodal(pC, Entity, T[iT]);
+ delete [] pC;
+ }
+
+ delete[] Count;
+
+ _complete = true;
+ }
+
+ END_OF("void CONNECTIVITYClient::fillCopy()");
+}
+
+med_int CONNECTIVITYClient::getNumberOf(medEntityMesh Entity,
+ medGeometryElement Type) const
+{
+ BEGIN_OF("void CONNECTIVITYClient::getNumberOf()");
+
+ med_int n = 0;
+
+ SCRUTE(Type);
+ SCRUTE(Entity);
+
+ if (!_complete) {
+
+ if (Entity == _entity) {
+
+ if (Type==MED_ALL_ELEMENTS)
+ n = _totalNumberOfElements_client;
+
+ for (med_int i=0; i<_numberOfTypes; i++) {
+ SCRUTE(_geometricTypes[i]);
+ if (_geometricTypes[i] == Type) {
+ n = _numberOfElements_client[i];
+ break;
+ }
+ }
+ }
+ else if (_constituent != NULL)
+ n = _constituent->getNumberOf(Entity,Type);
+
+ }
+ else
+ n = CONNECTIVITY::getNumberOf(Entity, Type);
+
+ SCRUTE(n);
+ END_OF("void CONNECTIVITYClient::getNumberOf()");
+ return n;
+}
+
+const med_int * CONNECTIVITYClient::getConnectivity
+ (medConnectivity ConnectivityType,
+ medEntityMesh Entity,
+ medGeometryElement Type)
+{
+ BEGIN_OF("void CONNECTIVITYClient::getConnectivity()");
+
+ if (!_complete)
+ fillCopy();
+
+ const med_int * c = CONNECTIVITY::getConnectivity
+ (ConnectivityType, Entity, Type);
+
+ END_OF("void CONNECTIVITYClient::getConnectivity()");
+ return c;
+}
+
+const med_int * CONNECTIVITYClient::getConnectivityIndex
+ (medConnectivity ConnectivityType,
+ medEntityMesh Entity)
+{
+ BEGIN_OF("void CONNECTIVITYClient::getConnectivityIndex()");
+
+ if (!_complete)
+ fillCopy();
+
+ const med_int *c = CONNECTIVITY::getConnectivityIndex
+ (ConnectivityType, Entity);
+
+ END_OF("void CONNECTIVITYClient::getConnectivityIndex()");
+ return c;
+}
+
+void CONNECTIVITYClient::calculateConnectivity
+ (medConnectivity connectivityType,
+ medEntityMesh Entity)
+{
+ BEGIN_OF("void CONNECTIVITYClient::calculateConnectivity()");
+
+ if (!_complete)
+ fillCopy();
+
+ CONNECTIVITY::calculateConnectivity(connectivityType, Entity);
+
+ END_OF("void CONNECTIVITYClient::calculateConnectivity()");
+}
+
+void CONNECTIVITYClient::updateFamily (vector<FAMILY*> myFamilies)
+{
+ BEGIN_OF("void CONNECTIVITYClient::updateFamily()");
+
+ if (!_complete)
+ fillCopy();
+
+ CONNECTIVITY::updateFamily(myFamilies);
+
+ END_OF("void CONNECTIVITYClient::updateFamily()");
+}
+
+const int * CONNECTIVITYClient::getGlobalNumberingIndex
+ (medEntityMesh Entity) const throw (MEDEXCEPTION)
+{
+ BEGIN_OF("void CONNECTIVITYClient::getGlobalNumberingIndex()");
+
+ if (!_complete)
+ (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
+
+ CONNECTIVITY::getGlobalNumberingIndex(Entity);
+
+ END_OF("void CONNECTIVITYClient::getGlobalNumberingIndex()");
+}
+
+bool CONNECTIVITYClient::existConnectivity(medConnectivity ConnectivityType,
+ medEntityMesh Entity) const
+{
+ BEGIN_OF("void CONNECTIVITYClient::existConnectivity()");
+
+ if (!_complete)
+ (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
+
+ bool b = CONNECTIVITY::existConnectivity(ConnectivityType, Entity);
+
+ END_OF("void CONNECTIVITYClient::existConnectivity()");
+
+ return b;
+}
+
+const med_int * CONNECTIVITYClient::getReverseConnectivity
+ (medConnectivity ConnectivityType,
+ medEntityMesh Entity) throw (MEDEXCEPTION)
+{
+ BEGIN_OF("void CONNECTIVITYClient::getReverseConnectivity()");
+
+ if (!_complete)
+ fillCopy();
+
+ const med_int *c = CONNECTIVITY::getReverseConnectivity
+ (ConnectivityType, Entity);
+
+ END_OF("void CONNECTIVITYClient::getReverseConnectivity()");
+
+ return c;
+}
+
+const med_int * CONNECTIVITYClient::getReverseConnectivityIndex
+ (medConnectivity ConnectivityType,
+ medEntityMesh Entity) throw (MEDEXCEPTION)
+{
+ BEGIN_OF("void CONNECTIVITYClient::getReverseConnectivityIndex()");
+
+ if (!_complete)
+ fillCopy();
+
+ const med_int *c = CONNECTIVITY::getReverseConnectivityIndex
+ (ConnectivityType, Entity);
+
+ END_OF("void CONNECTIVITYClient::getReverseConnectivityIndex()");
+
+ return c;
+}
+
+const med_int* CONNECTIVITYClient::getValue(medConnectivity TypeConnectivity,
+ medGeometryElement Type)
+{
+ BEGIN_OF("void CONNECTIVITYClient::getValue()");
+
+ if (!_complete)
+ fillCopy();
+
+ const med_int * c = CONNECTIVITY::getValue(TypeConnectivity, Type);
+
+ END_OF("void CONNECTIVITYClient::()");
+
+ return c;
+}
+
+const med_int* CONNECTIVITYClient::getValueIndex(medConnectivity TypeConnectivity)
+{
+ BEGIN_OF("void CONNECTIVITYClient::getValueIndex()");
+
+ if (!_complete)
+ fillCopy();
+
+ const med_int * c = CONNECTIVITY::getValueIndex(TypeConnectivity);
+
+ END_OF("void CONNECTIVITYClient::getValueIndex()");
+
+ return c;
+}
+
+const med_int* CONNECTIVITYClient::getNeighbourhood() const
+{
+ BEGIN_OF("void CONNECTIVITYClient::getNeighbourhood()");
+
+ if (!_complete)
+ (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
+
+ const med_int * c = CONNECTIVITY::getNeighbourhood();
+
+ END_OF("void CONNECTIVITYClient::getNeighbourhood()");
+
+ return c;
+}
+
--- /dev/null
+#ifndef _CONNECTIVITY_CLIENT_HXX
+#define _CONNECTIVITY_CLIENT_HXX
+
+#include <SALOMEconfig.h>
+#include "MEDMEM_Connectivity.hxx"
+#include CORBA_CLIENT_HEADER(MED)
+
+class CONNECTIVITYClient : public CONNECTIVITY {
+
+protected:
+
+ long *_numberOfElements_client;
+ long _totalNumberOfElements_client;
+
+ mutable bool _complete;
+ SALOME_MED::MESH_var IOR_Mesh ;
+
+public:
+
+ CONNECTIVITYClient(const SALOME_MED::MESH_ptr m,
+ medEntityMesh Entity=MED_CELL);
+
+ virtual ~CONNECTIVITYClient();
+
+ void fillCopy();
+ void blankCopy();
+
+ med_int getNumberOf(medEntityMesh Entity, medGeometryElement Type) const;
+
+ const med_int * getConnectivity (medConnectivity ConnectivityType,
+ medEntityMesh Entity,
+ medGeometryElement Type);
+ const med_int * getConnectivityIndex (medConnectivity ConnectivityType,
+ medEntityMesh Entity);
+
+ void calculateConnectivity (medConnectivity connectivityType,
+ medEntityMesh Entity);
+
+ void updateFamily (vector<FAMILY*> myFamilies);
+
+ const int * getGlobalNumberingIndex (medEntityMesh Entity) const throw (MEDEXCEPTION);
+
+ bool existConnectivity(medConnectivity ConnectivityType,
+ medEntityMesh Entity) const;
+
+ const med_int* getReverseConnectivity (medConnectivity ConnectivityType,
+ medEntityMesh Entity=MED_CELL)
+ throw (MEDEXCEPTION);
+
+ const med_int* getReverseConnectivityIndex (medConnectivity ConnectivityType,
+ medEntityMesh Entity=MED_CELL)
+ throw (MEDEXCEPTION);
+
+ const med_int* getValue (medConnectivity TypeConnectivity,
+ medGeometryElement Type);
+
+ const med_int* getValueIndex (medConnectivity TypeConnectivity);
+ const med_int* getNeighbourhood() const;
+};
+
+
+#endif
--- /dev/null
+#include "COORDINATEClient.hxx"
+#include <string>
+#include "UtilClient.hxx"
+
+COORDINATEClient::COORDINATEClient(const SALOME_MED::MESH_ptr m,
+ medModeSwitch Mode) :
+ COORDINATE(m->getSpaceDimension(), 1, Mode),
+ _complete(false),
+ IOR_Mesh(SALOME_MED::MESH::_duplicate(m))
+{
+ BEGIN_OF("COORDINATEClient::COORDINATEClient(...)");
+
+ blankCopy();
+
+ END_OF("COORDINATEClient::COORDINATEClient(...)");
+}
+
+void COORDINATEClient::blankCopy()
+{
+ BEGIN_OF("void COORDINATEClient::blankCopy()");
+
+ std::string *tA;
+ long nA;
+
+ convertCorbaArray(tA, nA, IOR_Mesh->getCoordinatesNames());
+ ASSERT(nA == getSpaceDimension());
+ setCoordinatesNames(tA);
+ delete [] tA;
+
+ convertCorbaArray(tA, nA, IOR_Mesh->getCoordinatesUnits());
+ ASSERT(nA == getSpaceDimension());
+ setCoordinatesUnits(tA);
+ delete [] tA;
+
+ setCoordinatesSystem(IOR_Mesh->getCoordinatesSystem());
+
+ _complete = false;
+
+ END_OF("void COORDINATEClient::blankCopy()");
+}
+
+void COORDINATEClient::fillCopy()
+{
+ BEGIN_OF("void COORDINATEClient::fillCopy()");
+
+ long nN = IOR_Mesh->getNumberOfNodes();
+ double *tC;
+ long nC;
+ convertCorbaArray(tC, nC, IOR_Mesh->getCoordinates(MED_FULL_INTERLACE));
+ ASSERT(nC == (getSpaceDimension() * nN));
+
+ MEDARRAY<double> mC(tC, getSpaceDimension(), nN);
+ setCoordinates(&mC);
+
+ _complete = true;
+
+ END_OF("void COORDINATEClient::fillCopy()");
+}
+
+
+const double * COORDINATEClient::getCoordinates(medModeSwitch Mode)
+{
+ BEGIN_OF("void COORDINATEClient::getCoordinates()");
+
+ if (!_complete) fillCopy();
+ const double * c = COORDINATE::getCoordinates(Mode);
+
+ END_OF("void COORDINATEClient::getCoordinates()");
+
+ return c;
+}
+
+double COORDINATEClient::getCoordinate(int Number,int Axis)
+{
+ BEGIN_OF("void COORDINATEClient::getCoordinate()");
+
+ if (!_complete) fillCopy();
+ double d = COORDINATE::getCoordinate(Number, Axis);
+
+ END_OF("void COORDINATEClient::getCoordinate()");
+
+ return d;
+}
+
+const double * COORDINATEClient::getCoordinateAxis(int Axis)
+{
+ BEGIN_OF("void COORDINATEClient::getCoordinateAxis()");
+
+ if (!_complete) fillCopy();
+ const double *c = COORDINATE::getCoordinateAxis(Axis);
+
+ END_OF("void COORDINATEClient::getCoordinateAxis()");
+
+ return c;
+}
+
+const int* COORDINATEClient::getNodesNumbers() const
+{
+ BEGIN_OF("void COORDINATEClient::getNodesNumbers()");
+
+ if (!_complete) (const_cast < COORDINATEClient * >(this))->fillCopy();
+
+ MESSAGE("NON IMPLEMENTE DANS L'API CORBA");
+ END_OF("void COORDINATEClient::getNodesNumbers()");
+
+ return NULL;
+}
--- /dev/null
+#ifndef _COORDINATE_CLIENT_HXX
+#define _COORDINATE_CLIENT_HXX
+
+#include <SALOMEconfig.h>
+#include "MEDMEM_Coordinate.hxx"
+#include CORBA_CLIENT_HEADER(MED)
+
+class COORDINATEClient : public COORDINATE {
+
+protected:
+
+ mutable bool _complete;
+ SALOME_MED::MESH_var IOR_Mesh ;
+
+public:
+
+ /*!
+ COORDINATEClient constructor
+
+ Build an "empty" coordinate object (without the actual coordinate values).
+ The object hold a Corba IOR and get data from it on user demand.
+
+ Parameters in : m (Mesh Corba IOR)
+ mode (FULL_ or NO_ interlace)
+ */
+ COORDINATEClient(const SALOME_MED::MESH_ptr m, medModeSwitch Mode);
+
+
+ /*!
+ COORDINATEClient::blankCopy()
+
+ "(Re)Blank" the coordinate object.
+
+ Update fixed sized data from the Corba IOR (dimensions, strings).
+ Get rid of variable sized data (coordinate values).
+ Next call of getCoordinates (for instance) will update the
+ object.
+ */
+ void blankCopy();
+
+
+ /*!
+ COORDINATEClient::fillCopy()
+
+ (Re)fill the coordinate object from the Corba IOR
+ */
+ void fillCopy();
+
+
+ virtual ~COORDINATEClient() {};
+
+ virtual const double * getCoordinates(medModeSwitch Mode);
+ virtual double getCoordinate(int Number,int Axis);
+ virtual const double * getCoordinateAxis(int Axis);
+ virtual const int* getNodesNumbers() const;
+
+};
+
+#endif
--- /dev/null
+#include "FAMILYClient.hxx"
+#include "MESHClient.hxx"
+#include "UtilClient.hxx"
+
+FAMILYClient::FAMILYClient(const SALOME_MED::FAMILY_ptr F,
+ MESH * M)
+ : SUPPORTClient(F, M),
+ FAMILY(),
+ IOR_Family(SALOME_MED::FAMILY::_duplicate(F))
+{
+ BEGIN_OF("FAMILYClient::FAMILYClient(SALOME_MED::FAMILY_ptr m)");
+
+ SCRUTE(F);
+ SCRUTE(M);
+
+ blankCopy(false);
+
+ END_OF("FAMILYClient::FAMILYClient(SALOME_MED::FAMILY_ptr m)");
+}
+
+void FAMILYClient::blankCopy(bool blankSupport)
+{
+ BEGIN_OF("FAMILYClient::blankCopy()");
+
+ if (blankSupport)
+ SUPPORTClient::blankCopy();
+
+ MESSAGE("");
+
+// setIdentifier(IOR_Family->getIdentifier());
+
+// int nAttr, nGr, n;
+// int *i;
+// std::string *s;
+
+// nAttr = IOR_Family->getNumberOfAttributes();
+// setNumberOfAttributes(nAttr);
+
+// convertCorbaArray(i, n, IOR_Family->getAttributesIdentifiers());
+// ASSERT(n == nAttr);
+// setAttributesIdentifiers(i);
+
+// convertCorbaArray(i, n, IOR_Family->getAttributesValues());
+// ASSERT(n == _numberOfAttribute);
+// setAttributesValues(i);
+
+// convertCorbaArray(s, n, IOR_Family->getAttributesDescriptions());
+// ASSERT(n == _numberOfAttribute);
+// setAttributesDescriptions(s);
+
+// nGr = IOR_Family->getNumberOfGroups();
+// setNumberOfGroups(nGr);
+
+// convertCorbaArray(s, n, IOR_Family->getGroupsNames());
+// ASSERT(n == _numberOfAttribute);
+// setGroupsNames(s);
+
+ _complete = false;
+
+ END_OF("FAMILYClient::blankCopy()");
+}
+
+void FAMILYClient::fillCopy(bool fillSupport)
+{
+ BEGIN_OF("FAMILYClient::fillCopy()");
+
+ if (!_complete) {
+
+ if (fillSupport)
+ SUPPORTClient::fillCopy();
+
+ _complete = true;
+ }
+
+ END_OF("FAMILYClient::fillCopy()");
+}
+
+
+FAMILYClient::~FAMILYClient()
+{
+ BEGIN_OF("FAMILYClient::~FAMILYClient()");
+ END_OF("FAMILYClient::~FAMILYClient()");
+}
--- /dev/null
+#ifndef _FAMILYCLIENT_HXX
+#define _FAMILYCLIENT_HXX
+
+#include <SALOMEconfig.h>
+#include <utilities.h>
+#include "MEDMEM_Family.hxx"
+#include CORBA_CLIENT_HEADER(MED)
+#include "SUPPORTClient.hxx"
+
+
+class FAMILYClient :
+ public SUPPORTClient, public FAMILY {
+
+private :
+
+ const SALOME_MED::FAMILY_var IOR_Family;
+
+ mutable bool _complete;
+
+public :
+
+ FAMILYClient(const SALOME_MED::FAMILY_ptr S,
+ MESH * M = NULL);
+ virtual ~FAMILYClient();
+
+ virtual void blankCopy(bool blankSupport = true);
+ virtual void fillCopy(bool fillSupport = true);
+};
+
+
+#endif
--- /dev/null
+#ifndef _FIELDCLIENT_HXX
+#define _FIELDCLIENT_HXX
+
+#include <SALOMEconfig.h>
+#include <utilities.h>
+#include "MEDMEM_Field.hxx"
+#include CORBA_CLIENT_HEADER(MED)
+
+template <typename T>
+class FIELDClient : virtual public FIELD<T> {
+
+private :
+
+ const SALOME_MED::FIELD_var IOR_Field;
+
+ mutable bool _complete_field;
+
+public :
+
+ FIELDClient(const SALOME_MED::FIELD_ptr S,
+ SUPPORT * S = NULL);
+ virtual ~FIELDClient();
+
+ void blankCopy();
+ void fillCopy();
+
+
+};
+
+template <typename T>
+FIELDClient<T>::FIELDClient(const SALOME_MED::FIELD_ptr F,
+ SUPPORT * S) :
+ FIELD<T>(),
+ IOR_Field(SALOME_MED::FIELD::_duplicate(F))
+{
+ BEGIN_OF("FIELDClient::FIELDClient(SALOME_MED::FIELD_ptr m)");
+
+ if (S) setSupport(S);
+
+ END_OF("FIELDClient::FIELDClient(SALOME_MED::FIELD_ptr m)");
+}
+
+template <typename T>
+void FIELDClient<T>::blankCopy()
+{
+ BEGIN_OF("FIELDClient::blankCopy");
+
+
+ END_OF("FIELDClient::blankCopy");
+
+}
+
+template <typename T>
+void FIELDClient<T>::fillCopy()
+{
+ BEGIN_OF("FIELDClient::fillCopy");
+
+ END_OF("FIELDClient::fillCopy");
+}
+
+
+template <typename T>
+FIELDClient<T>::~FIELDClient()
+{
+ BEGIN_OF("FIELDClient::~FIELDClient");
+
+ END_OF("FIELDClient::~FIELDClient");
+}
+
+#endif
--- /dev/null
+#include "GROUPClient.hxx"
+#include "MESHClient.hxx"
+
+GROUPClient::GROUPClient(const SALOME_MED::GROUP_ptr G,
+ MESH * M)
+ : SUPPORTClient(G, M),
+ GROUP(),
+ IOR_Group(SALOME_MED::GROUP::_duplicate(G))
+{
+ BEGIN_OF("GROUPClient::GROUPClient()");
+
+ SCRUTE(G);
+ SCRUTE(M);
+
+ END_OF("GROUPClient::GROUPClient()");
+}
+
+
+void GROUPClient::blankCopy()
+{
+ BEGIN_OF("GROUPClient::blankCopy()");
+
+ SUPPORTClient::blankCopy();
+ _complete = false;
+
+ END_OF("GROUPClient::blankCopy()");
+}
+
+void GROUPClient::fillCopy()
+{
+ BEGIN_OF("GROUPClient::fillCopy()");
+
+ SUPPORTClient::fillCopy();
+ _complete = true;
+
+ END_OF("GROUPClient::fillCopy()");
+}
+
+
+GROUPClient::~GROUPClient()
+{
+ BEGIN_OF("GROUPClient::~GROUPClient()");
+ END_OF("GROUPClient::~GROUPClient()");
+}
--- /dev/null
+#ifndef _GROUPCLIENT_HXX
+#define _GROUPCLIENT_HXX
+
+#include <SALOMEconfig.h>
+#include <utilities.h>
+#include "MEDMEM_Group.hxx"
+#include CORBA_CLIENT_HEADER(MED)
+#include "SUPPORTClient.hxx"
+
+class GROUPClient :
+ public SUPPORTClient,
+ public GROUP
+{
+
+private :
+
+ const SALOME_MED::GROUP_var IOR_Group;
+
+ mutable bool _complete;
+
+public :
+
+ GROUPClient(const SALOME_MED::GROUP_ptr S,
+ MESH * M = NULL);
+ virtual ~GROUPClient();
+
+ virtual void blankCopy();
+ virtual void fillCopy();
+};
+
+
+#endif
--- /dev/null
+#include "MESHClient.hxx"
+#include <convert.hxx>
+#include "UtilClient.hxx"
+#include "COORDINATEClient.hxx"
+#include "CONNECTIVITYClient.hxx"
+#include "FAMILYClient.hxx"
+#include "GROUPClient.hxx"
+
+MESHClient::MESHClient(const SALOME_MED::MESH_ptr m) :
+ MESH(),
+ IOR_Mesh(SALOME_MED::MESH::_duplicate(m)),
+ _complete(false)
+
+{
+ BEGIN_OF("MESHClient::MESHClient(SALOME_MED::MESH_ptr m)");
+
+ ASSERT(m);
+
+ _coordinate = new COORDINATEClient(m, MED_FULL_INTERLACE);
+ _connectivity = new CONNECTIVITYClient(m, MED_FULL_INTERLACE);
+
+ blankCopy();
+
+ END_OF("MESHClient::MESHClient(SALOME_MED::MESH_ptr m)");
+}
+
+FAMILY * convertFamily(const SALOME_MED::FAMILY_ptr &F, MESH *M) {
+ return new FAMILYClient(F, M);
+}
+
+GROUP * convertGroup(const SALOME_MED::GROUP_ptr &F, MESH *M) {
+ return new GROUPClient(F, M);
+}
+
+void MESHClient::blankCopy()
+{
+ BEGIN_OF("MESHClient::blankCopy()");
+
+ CORBA::String_var s;
+
+ s= IOR_Mesh->getName(); _name = s;
+ _spaceDimension = IOR_Mesh->getSpaceDimension();
+ _meshDimension = IOR_Mesh->getMeshDimension();
+ _numberOfNodes = IOR_Mesh->getNumberOfNodes();
+
+ COORDINATEClient *_coord
+ = dynamic_cast<COORDINATEClient*>(_coordinate);
+ ASSERT(_coord);
+ CONNECTIVITYClient *_connect
+ = dynamic_cast<CONNECTIVITYClient*>(_connectivity);
+ ASSERT(_connect);
+
+ _coord->blankCopy();
+ _connect->blankCopy();
+
+ MESSAGE("");
+ convertCorbaArray<SALOME_MED::FAMILY_ptr>
+ (_familyNode,
+ _numberOfNodesFamilies,
+ IOR_Mesh->getFamilies(MED_NODE),
+ (void *) (convertFamily), this);
+
+ MESSAGE("");
+ convertCorbaArray<SALOME_MED::FAMILY_ptr>
+ (_familyEdge,
+ _numberOfEdgesFamilies,
+ IOR_Mesh->getFamilies(MED_EDGE),
+ (void *) (convertFamily), this);
+
+ MESSAGE("");
+ convertCorbaArray<SALOME_MED::FAMILY_ptr>
+ (_familyFace,
+ _numberOfFacesFamilies,
+ IOR_Mesh->getFamilies(MED_FACE),
+ (void *) (convertFamily), this);
+
+ MESSAGE("");
+ convertCorbaArray<SALOME_MED::FAMILY_ptr>
+ (_familyCell,
+ _numberOfCellsFamilies,
+ IOR_Mesh->getFamilies(MED_CELL),
+ (void *) (convertFamily), this);
+
+ MESSAGE("");
+ convertCorbaArray<SALOME_MED::GROUP_ptr>
+ (_groupNode,
+ _numberOfNodesGroups,
+ IOR_Mesh->getGroups(MED_NODE),
+ (void *) (convertGroup), this);
+
+ MESSAGE("");
+ convertCorbaArray<SALOME_MED::GROUP_ptr>
+ (_groupEdge,
+ _numberOfEdgesGroups,
+ IOR_Mesh->getGroups(MED_EDGE),
+ (void *) (convertGroup), this);
+
+ MESSAGE("");
+ convertCorbaArray<SALOME_MED::GROUP_ptr>
+ (_groupFace,
+ _numberOfFacesGroups,
+ IOR_Mesh->getGroups(MED_FACE),
+ (void *) (convertGroup), this);
+
+ MESSAGE("");
+ convertCorbaArray<SALOME_MED::GROUP_ptr>
+ (_groupCell,
+ _numberOfCellsGroups,
+ IOR_Mesh->getGroups(MED_CELL),
+ (void *) (convertGroup), this);
+
+ MESSAGE("");
+ _complete = false;
+
+ END_OF("MESHClient::blankCopy()");
+}
+
+void MESHClient::fillCopy()
+{
+ BEGIN_OF("MESHClient::fillCopy()");
+
+ COORDINATEClient *_coord
+ = dynamic_cast<COORDINATEClient *> (_coordinate);
+ ASSERT(_coord);
+ CONNECTIVITYClient *_connect
+ = dynamic_cast<CONNECTIVITYClient *> (_connectivity);
+ ASSERT(_connect);
+
+ _coord->fillCopy();
+ _connect->fillCopy();
+
+ _complete = true;
+
+ END_OF("MESHClient::fillCopy()");
+}
+
+
+MESHClient::~MESHClient()
+{
+ BEGIN_OF("MESHClient::~MESHClient()");
+ END_OF("MESHClient::~MESHClient()");
+}
+
--- /dev/null
+#ifndef _MESHCLIENT_HXX
+#define _MESHCLIENT_HXX
+
+#include <SALOMEconfig.h>
+#include <utilities.h>
+#include "MEDMEM_Mesh.hxx"
+#include CORBA_CLIENT_HEADER(MED)
+
+class MESHClient : public MESH {
+
+private :
+
+ const SALOME_MED::MESH_var IOR_Mesh;
+
+ mutable bool _complete;
+
+
+public :
+
+ MESHClient(const SALOME_MED::MESH_ptr m);
+
+ virtual ~MESHClient();
+
+ void blankCopy();
+ void fillCopy();
+
+};
+
+#endif
+
--- /dev/null
+# MED MedClient : tool to transfer MED CORBA from server producer of MED object to a client using those MED object
+#
+# 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@
+VPATH=.:$(srcdir):$(top_srcdir)/idl:$(top_builddir)/idl:${KERNEL_ROOT_DIR}/idl/salome
+
+MACHINE=PCLINUX
+
+@COMMENCE@
+
+
+EXPORT_HEADERS = \
+ COORDINATEClient.hxx \
+ CONNECTIVITYClient.hxx \
+ MESHClient.hxx \
+ SUPPORTClient.hxx \
+ FAMILYClient.hxx \
+ GROUPClient.hxx \
+ FIELDClient.hxx \
+ libMEDClient.i
+
+SWIG_DEF = libMEDClient.i
+
+EXPORT_PYSCRIPTS = libMEDClient.py
+
+# Libraries targets
+
+LIB=libMEDClientcmodule.la
+LIB_SRC = \
+ COORDINATEClient.cxx \
+ CONNECTIVITYClient.cxx \
+ MESHClient.cxx \
+ SUPPORTClient.cxx \
+ FAMILYClient.cxx \
+ GROUPClient.cxx
+
+LIB_CLIENT_IDL= \
+ SALOME_Component.idl \
+ SALOMEDS.idl \
+ SALOMEDS_Attributes.idl \
+ SALOME_Exception.idl \
+ MED.idl
+
+# Executables targets
+BIN_SRC =
+BIN_SERVER_IDL =
+BIN_CLIENT_IDL =
+
+
+CPPFLAGS+= $(MED2_INCLUDES) $(HDF5_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
+CXXFLAGS+=-I${KERNEL_ROOT_DIR}/include/salome
+LDFLAGS+=-L${KERNEL_ROOT_DIR}/lib/salome -lOpUtil -lMedCorba_Swigcmodule -lmedmem
+
+MED.hh MEDSK.cc: MED.idl
+ omniidl -bcxx -Wbtp -I$(top_builddir)/idl -I${KERNEL_ROOT_DIR}/idl/salome $^
+
+@CONCLUDE@
--- /dev/null
+#include "UtilClient.hxx"
+#include "SUPPORTClient.hxx"
+#include "MESHClient.hxx"
+
+SUPPORTClient::SUPPORTClient(const SALOME_MED::SUPPORT_ptr S,
+ MESH * M) :
+ SUPPORT(),
+ IOR_Support(SALOME_MED::SUPPORT::_duplicate(S))
+{
+ BEGIN_OF("SUPPORTClient::SUPPORTClient(SALOME_MED::SUPPORT_ptr m)");
+
+ SCRUTE(S);
+ SCRUTE(M);
+
+ setMesh(M ? M : new MESHClient(IOR_Support->getMesh()));
+
+ blankCopy();
+
+ END_OF("SUPPORTClient::SUPPORTClient(SALOME_MED::SUPPORT_ptr m)");
+}
+
+void SUPPORTClient::blankCopy()
+{
+ BEGIN_OF("SUPPORTClient::blankCopy");
+
+ setName(IOR_Support->getName());
+ setDescription(IOR_Support->getDescription());
+ setAll(IOR_Support->isOnAllElements());
+ setEntity(IOR_Support->getEntity());
+
+ convertCorbaArray(_geometricType, _numberOfGeometricType,
+ IOR_Support->getTypes());
+
+ int *nE = new int[_numberOfGeometricType];
+ int i;
+ for (i=0; i<_numberOfGeometricType; i++)
+ nE[i] = IOR_Support->getNumberOfElements(_geometricType[i]);
+ setNumberOfElements(nE);
+ SCRUTE(_totalNumberOfElements);
+
+ SCRUTE(_name);
+ SCRUTE(_description);
+
+ _complete_support = false;
+
+ END_OF("SUPPORTClient::blankCopy");
+
+}
+
+void SUPPORTClient::fillCopy()
+{
+ BEGIN_OF("SUPPORTClient::fillCopy");
+
+ int * index, * value;
+ long n_index, n_value;
+
+ MESSAGE("");
+ try {
+ convertCorbaArray(value, n_value,
+ IOR_Support->getNumber(MED_ALL_ELEMENTS));
+ }
+ catch (...) {
+ std::cerr << "erreur ...." << std::endl;
+ exit(-1);
+ }
+
+ SCRUTE(n_value);
+ SCRUTE(value[0]);
+ SCRUTE(value[1]);
+ MESSAGE("");
+
+ try {
+ convertCorbaArray(index, n_index,
+ IOR_Support->getNumberIndex());
+ }
+ catch (...) {
+ std::cerr << "erreur ...." << std::endl;
+ exit(-1);
+ }
+
+ SCRUTE(n_index);
+ SCRUTE(n_value);
+ setNumber(index, value);
+
+ delete [] index;
+ delete [] value;
+
+ _complete_support = true;
+
+ END_OF("SUPPORTClient::fillCopy");
+}
+
+
+SUPPORTClient::~SUPPORTClient()
+{
+ BEGIN_OF("SUPPORTClient::~SUPPORTClient");
+
+ END_OF("SUPPORTClient::~SUPPORTClient");
+}
+
+MEDSKYLINEARRAY * SUPPORTClient::getnumber() const throw (MEDEXCEPTION)
+{
+ BEGIN_OF("SUPPORTClient::getnumber()");
+
+ if (!_complete_support) (const_cast<SUPPORTClient *>(this))->fillCopy();
+ MEDSKYLINEARRAY *m = SUPPORT::getnumber();
+
+ END_OF("SUPPORTClient::getnumber()");
+ return m;
+}
+
+const int * SUPPORTClient::getNumber(medGeometryElement GeometricType)
+ const throw (MEDEXCEPTION)
+{
+ BEGIN_OF("SUPPORTClient::getnumber(medGeometryElement)");
+
+ if (!_complete_support) (const_cast<SUPPORTClient *>(this))->fillCopy();
+ const int *n = SUPPORT::getNumber(GeometricType);
+
+ END_OF("SUPPORTClient::getnumber(medGeometryElement)");
+ return n;
+}
+
+const int * SUPPORTClient::getNumberIndex() const throw (MEDEXCEPTION)
+{
+ BEGIN_OF("SUPPORTClient::getnumberIndex()");
+
+ if (!_complete_support) (const_cast<SUPPORTClient *>(this))->fillCopy();
+ const int * n = SUPPORT::getNumberIndex();
+
+ END_OF("SUPPORTClient::getnumberIndex()");
+ return n;
+}
+
--- /dev/null
+#ifndef _SUPPORTCLIENT_HXX
+#define _SUPPORTCLIENT_HXX
+
+#include <SALOMEconfig.h>
+#include <utilities.h>
+#include "MEDMEM_Support.hxx"
+#include CORBA_CLIENT_HEADER(MED)
+
+
+class SUPPORTClient : virtual public SUPPORT {
+
+private :
+
+ const SALOME_MED::SUPPORT_var IOR_Support;
+
+ mutable bool _complete_support;
+
+public :
+
+ SUPPORTClient(const SALOME_MED::SUPPORT_ptr S,
+ MESH * M = NULL);
+ virtual ~SUPPORTClient();
+
+ void blankCopy();
+ void fillCopy();
+
+ MEDSKYLINEARRAY * getnumber()
+ const throw (MEDEXCEPTION);
+ const int * getNumber(medGeometryElement GeometricType)
+ const throw (MEDEXCEPTION);
+ const int * getNumberIndex()
+ const throw (MEDEXCEPTION);
+
+};
+
+
+#endif
--- /dev/null
+#ifndef UTILCLIENT_HXX_
+#define UTILCLIENT_HXX_
+
+#include <vector>
+#include <utilities.h>
+
+template <typename TLocal,
+ typename TCorbaSeq,
+ typename Tint>
+inline void convertCorbaArray (TLocal * & T, Tint &nT, const TCorbaSeq & S)
+{
+ Tint i, n = S->length();
+
+ nT = n;
+ T = n > 0 ? new TLocal[n] : NULL;
+
+ for (i=0; i<n; i++) {
+ T[i] = (*S)[i];
+ }
+}
+
+template <typename TCorba,
+ typename TLocal,
+ typename TCorbaSeq>
+inline void convertCorbaArray (TLocal * & T, long &nT, const TCorbaSeq & S,
+ void *f)
+{
+ int i, n = S->length();
+ SCRUTE(n);
+
+ nT = n;
+ T = n > 0 ? new TLocal[n] : NULL;
+
+ typedef TLocal (*pfn) (const TCorba &T);
+
+ pfn convert = pfn(f);
+ for (i=0; i<n; i++) {
+ SCRUTE((*S)[i]);
+ T[i] = convert((*S)[i]);
+ SCRUTE(T[i]);
+ }
+}
+
+template <typename TLocal,
+ typename TCorbaSeq>
+inline void convertCorbaArray (vector<TLocal> & T, int &nT,
+ const TCorbaSeq & S)
+{
+ int i, n = S->length();
+ SCRUTE(n);
+
+ nT = n;
+ T.resize(nT);
+
+ for (i=0; i<nT; i++) {
+ SCRUTE((*S)[i]);
+ T[i] = convert((*S)[i]);
+ SCRUTE(T[i]);
+ }
+}
+
+
+template <typename TCorba,
+ typename TLocal,
+ typename TCorbaSeq>
+inline void convertCorbaArray (vector<TLocal> & T, int &nT,
+ const TCorbaSeq & S,
+ void *f)
+{
+ int i, n = S->length();
+ SCRUTE(n);
+
+ nT = n;
+ T.resize(nT);
+
+ typedef TLocal (*pfn) (const TCorba &T);
+
+ pfn convert = pfn(f);
+ for (i=0; i<nT; i++) {
+ SCRUTE((*S)[i]);
+ T[i] = convert((*S)[i]);
+ SCRUTE(T[i]);
+ }
+
+}
+
+
+template <typename TCorba,
+ typename TLocal,
+ typename TCorbaSeq,
+ typename TInfo>
+inline void convertCorbaArray (vector<TLocal> & T, int &nT,
+ const TCorbaSeq & S,
+ void *f, TInfo M)
+{
+ int i, n = S->length();
+ SCRUTE(n);
+
+ nT = n;
+ T.resize(nT);
+
+ typedef TLocal (*pfn) (const TCorba & , TInfo);
+
+ pfn convert = pfn(f);
+ for (i=0; i<nT; i++) {
+ SCRUTE((*S)[i]);
+ T[i] = convert((*S)[i], M);
+ SCRUTE(T[i]);
+ }
+
+}
+
+#endif
--- /dev/null
+%module libMEDClient
+
+%{
+#include "MESHClient.hxx"
+#include "SUPPORTClient.hxx"
+#include "FIELDClient.hxx"
+#include CORBA_CLIENT_HEADER(MED)
+%}
+
+%include "libMedCorba_Swig.i"
+%include "libMEDMEM_Swig.i"
+
+class MESHClient : public MESH {
+
+ public:
+
+ MESHClient(const SALOME_MED::MESH_ptr m);
+ virtual ~MESHClient();
+
+ void blankCopy();
+ void fillCopy();
+
+};
+
+class SUPPORTClient : public SUPPORT {
+
+ public:
+
+ SUPPORTClient(const SALOME_MED::SUPPORT_ptr S,
+ MESH * M = NULL);
+ ~SUPPORTClient();
+
+ void blankCopy();
+ void fillCopy();
+
+};
+
+template<typename T>
+class FIELDClient : public FIELD<T> {
+
+ public:
+
+ FIELDClient(const SALOME_MED::FIELD_ptr S,
+ MESH * M = NULL);
+ ~FIELDClient();
+
+ void blankCopy();
+ void fillCopy();
+
+};
--- /dev/null
+# MED MedClient : tool to transfer MED CORBA from server producer of MED object to a client using those MED object
+#
+# 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@
+VPATH=.:@srcdir@:@srcdir@/resources
+
+@COMMENCE@
+
+RESOURCES_FILES = pointe.med carre_en_quad4_seg2.med maill.0.med test_hydro_darcy1a_out.med
+
+SUBDIRS = environ test1 test2
+
+@MODULE@
--- /dev/null
+# MED MedClient : tool to transfer MED CORBA from server producer of MED object to a client using those MED object
+#
+# 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@
+VPATH=.:@srcdir@
+
+BIN= runEnvironTests
+
+all:
+ $(MAKE) inc
+ $(MAKE) depend_idl
+ $(MAKE) depend
+ $(MAKE) lib
+ $(MAKE) bin
+ $(MAKE) resources
+
+depend depend_idl clean_dep lib idl resources:
+
+inc: ${BIN} Makefile
+
+
+bin:
+ chmod u+x ${BIN}
+ cp -f runTestMedCorba ${top_builddir}/bin
+ chmod +x ${top_builddir}/bin/runTestMedCorba
+ chmod +x runContainer stopContainer runEnvironTests
+ chmod +x csh/*
+
+install:
+ mkdir -p @prefix@/Tests/environ
+ cp -rf ${BIN} csh @prefix@/Tests/environ
+ cd @prefix@/Tests/environ ; chmod u+x ${BIN}
+ cp -f ${top_builddir}/bin/runTestMedCorba @prefix@/bin
+ chmod +x @prefix@/bin/runTestMedCorba
+
+./%: @srcdir@/%.in
+ cd $(top_builddir) ; \
+ ./config.status
+
+$(top_builddir)/config.status: $(top_srcdir)/configure
+ cd $(top_builddir) ; ./config.status --recheck
+
+clean:
+ \rm -f dummy *~ */*~
+
+cleandep:
+
--- /dev/null
+
+top_srcdir=@top_srcdir@
+top_builddir=../../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@
+
+BIN= init1 init2 init3 init4 init5 runContainer stopContainer
+
+TYPESHELL=csh
+INSTALLDIR=@prefix@/Tests/environ/${TYPESHELL}
+
+all:
+ $(MAKE) inc
+ $(MAKE) depend_idl
+ $(MAKE) depend
+ $(MAKE) lib
+ $(MAKE) bin
+ $(MAKE) resources
+ chmod u+x ${BIN}
+
+depend depend_idl clean_dep lib idl resources:
+
+inc: ${BIN} Makefile
+
+bin:
+ chmod u+x ${BIN}
+
+install:
+ mkdir -p ${INSTALLDIR}
+ cp -rf ${BIN} ${INSTALLDIR}
+ cd ${INSTALLDIR} ; chmod u+x ${BIN}
+
+%: @srcdir@/%.in
+ @echo $^ "->" $@
+ cd $(top_builddir) ; \
+ ./config.status ${patsubst @top_srcdir@/%, ./%, @srcdir@/$@}
+
+%: @srcdir@/%
+ @echo $^ "->" $@
+ cp -f $^ $@
+
+$(top_builddir)/config.status: $(top_srcdir)/configure
+ cd $(top_builddir) ; ./config.status --recheck
--- /dev/null
+cd ${SALOME_ROOT_DIR}/bin
+pwd
+./allkill || true
+./killall python || true
+./runSession
+csh
+
--- /dev/null
+#!/bin/csh
+
+cd ${SALOME_BIN_TESTS}
+
+while ( `ps | grep omniNames > /dev/null ` )
+ sleep 2
+end
+sleep 2
+
+./csh/runContainer TrucPy
+csh
--- /dev/null
+cd ${SALOME_ROOT_DIR}/bin
+csh
--- /dev/null
+#! /bin/csh
+
+set CONTAINER_NAME=$1
+
+set PYTHON_VERSION=python@PYTHON_VERSION@
+
+# you must define SALOME_ROOT_DIR and SALOME_SITE_DIR (if you need it)
+
+setenv SALOME_ROOT_DIR @prefix@
+
+if ( ${?SALOME_ROOT_DIR} ) then
+ setenv PATH ${SALOME_ROOT_DIR}/bin:${SALOME_ROOT_DIR}/Tests:${PATH}
+ setenv LD_LIBRARY_PATH ${SALOME_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+ setenv PYTHONPATH ${SALOME_ROOT_DIR}/lib:${SALOME_ROOT_DIR}/lib/${PYTHON_VERSION}/site-packages/salome:${PYTHONPATH}
+endif
+
+if ( ${?SALOME_SITE_DIR} ) then
+ setenv PATH ${SALOME_SITE_DIR}/bin:${PATH}
+ setenv LD_LIBRARY_PATH ${SALOME_SITE_DIR}/lib:${LD_LIBRARY_PATH}
+ setenv PYTHONPATH ${SALOME_SITE_DIR}/lib:${SALOME_SITE_DIR}/lib/${PYTHON_VERSION}/site-packages/salome:${PYTHONPATH}
+endif
+
+if ( -d ${HOME}/.salome/bin ) then
+ setenv PATH ${HOME}/.salome/bin:${PATH}
+endif
+
+if ( -d ${HOME}/.salome/lib ) then
+ setenv LD_LIBRARY_PATH ${HOME}/.salome/lib:${LD_LIBRARY_PATH}
+endif
+
+setenv tmp /usr/tmp
+
+echo
+./csh/stopContainer ${CONTAINER_NAME}
+
+switch ($?)
+case 11:
+ echo " Start container ${CONTAINER_NAME}"
+ breaksw
+case 12:
+ echo " Restart container ${CONTAINER_NAME}"
+ breaksw
+default:
+ exit 0
+ breaksw
+endsw
+echo
+
+set CONTAINER_TYPE = `echo ${CONTAINER_NAME} | grep 'Py$'`
+echo ${?CONTAINER_TYPE}
+
+if ( ${?CONTAINER_TYPE} ) then
+ ( ${SALOME_ROOT_DIR}/bin/SALOME_ContainerPy.py ${CONTAINER_NAME} &)
+else
+ ( ${SALOME_ROOT_DIR}/bin/SALOME_Container ${CONTAINER_NAME} & )
+endif
+
--- /dev/null
+#
+[ -f ~/.Xresources ] && xrdb ~/.Xresources
+
+setenv SALOME_BIN_TESTS ${SALOME_ROOT_DIR}/MED/src/MedClient/test/environ
+
+[ -f ${SALOME_BIN_TESTS}/killEnviron ] && ${SALOME_BIN_TESTS}/killEnviron
+
+
+set TERMINAL="konsole --caption"
+set TERMINAL="xterm -vb -sl 1000 -title"
+
+\rm -f ${SALOME_BIN_TESTS}/killEnviron
+touch ${SALOME_BIN_TESTS}/killEnviron
+chmod u+x ${SALOME_BIN_TESTS}/killEnviron
+
+set TITRE1="Session"
+set TITRE2="Container"
+set TITRE3="Essais"
+
+setenv PATH .:${PATH}
+
+echo "#! /bin/sh" >> ${SALOME_BIN_TESTS}/killEnviron
+${TERMINAL} ${TITRE1} -e ${SALOME_BIN_TESTS}/csh/init1 &
+echo "kill -9 $! >& /dev/null" >> ${SALOME_BIN_TESTS}/killEnviron
+${TERMINAL} ${TITRE2} -e ${SALOME_BIN_TESTS}/csh/init2 &
+echo "kill -9 $! >& /dev/null" >> ${SALOME_BIN_TESTS}/killEnviron
+${TERMINAL} ${TITRE3} -e ${SALOME_BIN_TESTS}/csh/init3 &
+echo "kill -9 $! >& /dev/null" >> ${SALOME_BIN_TESTS}/killEnviron
+
+echo "cd ${SALOME_ROOT_DIR}/bin ; ./allkill ; killall python >& /dev/null" >> ${SALOME_BIN_TESTS}/killEnviron
+echo "\\rm -f ${SALOME_BIN_TESTS}/killEnviron" >> ${SALOME_BIN_TESTS}/killEnviron
+chmod u+x ${SALOME_BIN_TESTS}/killEnviron
--- /dev/null
+#! /bin/sh
+
+EXEC_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"`
+
+removeTree() {
+
+ local list
+ local noeud=$1
+
+ case $noeud in
+ *.dir/ | *.dir)
+ j=`echo $noeud | sed -e 's,^/,,' -e 's,/$,,' -`
+ list=`nameclt list $j 2> /dev/null`
+ for i in "$list"
+ do
+ [ -n "$i" ] && removeTree "$j/$i"
+ done
+ nameclt remove_context $j 2> /dev/null
+ ;;
+ *)
+ nameclt unbind $noeud 2> /dev/null
+ ;;
+ esac
+
+}
+
+CONTAINER_NAME="$1"
+if test -z ${CONTAINER_NAME=}
+then
+ echo "Usage : $0 <container name>"
+ exit -1
+fi
+
+
+PYTHON_VERSION=python2.2
+
+# you must define SALOME_ROOT_DIR and SALOME_SITE_DIR (if you need it)
+
+if test -n ${SALOME_ROOT_DIR}
+then
+ export PATH=${SALOME_ROOT_DIR}/bin:${PATH}
+ export LD_LIBRARY_PATH=${SALOME_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+ export PYTHONPATH=${SALOME_ROOT_DIR}/lib:${SALOME_ROOT_DIR}/lib/${PYTHON_VERSION}/site-packages/salome:${PYTHONPATH}
+fi
+if test -n ${SALOME_SITE_DIR}
+then
+ export PATH=${SALOME_SITE_DIR}/bin:${PATH}
+ export LD_LIBRARY_PATH=${SALOME_SITE_DIR}/lib:${LD_LIBRARY_PATH}
+ export PYTHONPATH=${SALOME_SITE_DIR}/lib:${SALOME_SITE_DIR}/lib/${PYTHON_VERSION}/site-packages/salome:${PYTHONPATH}
+fi
+
+if test -d ${HOME}/.salome/bin
+then
+ export PATH=${HOME}/.salome/bin:${PATH}
+fi
+if test -d ${HOME}/.salome/lib
+then
+ export LD_LIBRARY_PATH=${HOME}/.salome/lib:${LD_LIBRARY_PATH}
+fi
+
+export tmp=/usr/tmp
+
+NODE=Containers.dir/${HOSTNAME}.dir/${CONTAINER_NAME}
+removeTree ${NODE}.object
+removeTree ${NODE}.dir/
+
+
+PROCESS=`ps --width 200 -f -u ${USER} | \
+ grep -w ${CONTAINER_NAME} | \
+ grep SALOME_Container |
+ awk '{print \$2}'`
+
+
+if test -n "${PROCESS}"
+then
+ kill -9 `echo ${PROCESS}` >& /dev/null
+ echo
+ echo " Stop container ${CONTAINER_NAME}"
+ echo
+ exit 12
+fi
+
+exit 11
--- /dev/null
+#
+
+set xTest = 1
+test "$xTest" = 1 && goto CSH
+
+echo BASH
+`dirname $0`/bash/runContainer $1
+
+exit 0
+
+CSH:
+
+echo CSH
+set dir=`expr "x$0" : 'x\(.*\)/[^/]*' \| '.'`
+${dir}/csh/runContainer $1
+
+
--- /dev/null
+#
+
+set xTest = 1
+test "$xTest" = 1 && goto CSH
+
+echo BASH
+`dirname $0`/bash/runEnvironTests
+
+exit 0
+
+CSH:
+
+echo CSH
+set dir=`expr "x$0" : 'x\(.*\)/[^/]*' \| '.'`
+${dir}/csh/runEnvironTests
+
+
--- /dev/null
+#! /bin/bash
+
+PYTHON_VERSION=python@PYTHON_VERSION@
+
+if test -n $SALOME_ROOT_DIR
+then
+ export PATH=$SALOME_ROOT_DIR/bin:${PATH}
+ export LD_LIBRARY_PATH=$SALOME_ROOT_DIR/lib:${LD_LIBRARY_PATH}
+ export PYTHONPATH=${SALOME_ROOT_DIR}/lib:${SALOME_ROOT_DIR}/lib/$PYTHON_VERSION/site-packages/salome:${SALOME_ROOT_DIR}/share/salome/resources:${PYTHONPATH}
+ # add bin, because some script are in (SALOME_SWIG) !!!!
+ export PYTHONPATH=${SALOME_ROOT_DIR}/bin:${PYTHONPATH}
+fi
+if test -n $SALOME_SITE_DIR
+then
+ export PATH=$SALOME_SITE_DIR/bin:${PATH}
+ export LD_LIBRARY_PATH=$SALOME_SITE_DIR/lib:${LD_LIBRARY_PATH}
+ export PYTHONPATH=${SALOME_SITE_DIR}/lib:${SALOME_SITE_DIR}/lib/$PYTHON_VERSION/site-packages/salome:${SALOME_SITE_DIR}/share/salome/resources:${PYTHONPATH}
+fi
+
+mkdir -p resultats
+((python $1 2>&1 1>&3 | tee resultats/$1_err) 3>&1 1>&2 | tee resultats/$1_out ) 2>&1
+
--- /dev/null
+#
+
+set xTest = 1
+test "$xTest" = 1 && goto CSH
+
+echo BASH
+`dirname $0`/bash/stopContainer $1
+
+exit 0
+
+CSH:
+
+echo CSH
+set dir=`expr "x$0" : 'x\(.*\)/[^/]*' \| '.'`
+${dir}/csh/stopContainer $1
+
+
--- /dev/null
+from libMEDMEM_Swig import *
+
+
+class Compo1:
+
+ def __init__(self):
+ print "Initialisation Compo1"
+ self.mesh = None
+ self.support = None
+ self.md = None
+ self.medFile = None
+
+ def __del__(self):
+ print "destruction Compo1"
+
+ def Initialise(self, medFile):
+ if ((self.medFile != medFile) | (self.md is None)):
+ print "fichier MED monte"
+ self.md = MED()
+ mdDriver = MED_MED_RDONLY_DRIVER(medFile, self.md)
+ mdDriver.open()
+ mdDriver.readFileStruct()
+ mdDriver.close()
+ self.mesh = None
+ self.support = None
+ self.medFile = medFile
+ else:
+ print "fichier MED deja monte"
+
+ def Test(self):
+ if (self.md is None):
+ raise RuntimeError, 'call Initialise first'
+
+ def Calcul1(self):
+
+ self.Test();
+ if (self.mesh is None):
+ self.mesh = self.md.getMesh(self.md.getMeshName(0))
+ self.mesh.read()
+
+ return self.mesh
+
+ def Calcul2(self):
+
+ self.Test();
+ if (self.mesh is None):
+ self.Calcul1()
+
+ if (self.support is None):
+ self.support = SUPPORT(self.mesh, "my_support", MED_CELL)
+ self.support.setAll(1)
+
+ return self.support
--- /dev/null
+#include "SALOME_Component.idl"
+#include "MED.idl"
+
+module Engines
+{
+
+ interface Compo1Py : Component
+ {
+ void Initialise(in string medFile);
+ SALOME_MED::MESH Calcul1();
+ SALOME_MED::SUPPORT Calcul2();
+ };
+
+};
--- /dev/null
+import sys
+from omniORB import CORBA, PortableServer
+import CosNaming
+import Engines, Engines__POA
+from SALOME_ComponentPy import *
+from libMedCorba_Swig import *
+
+import Compo1
+
+class Compo1Py( Engines__POA.Compo1Py, SALOME_ComponentPy_i):
+
+ def __init__(self, orb, poa, contID, \
+ containerName, instanceName, interfaceName):
+ notif = 1
+ SALOME_ComponentPy_i.__init__(self, orb, poa, contID, \
+ containerName, instanceName, \
+ interfaceName, notif)
+
+ self.C = Compo1.Compo1()
+
+ print "Compo1Py_Impl::__init__"
+
+
+ def Initialise(self, medFile):
+ self.C.Initialise(medFile);
+
+ def Calcul1(self):
+ m = self.C.Calcul1()
+ return createCorbaMesh(m)
+
+ def Calcul2(self):
+ s = self.C.Calcul2()
+ return createCorbaSupport(s)
+
--- /dev/null
+# MED MedClient : tool to transfer MED CORBA from server producer of MED object to a client using those MED object
+#
+# 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@
+VPATH=.:@srcdir@:@top_srcdir@/idl
+
+@COMMENCE@
+
+EXPORT_PYSCRIPTS = Compo1.py Compo1Py.py \
+ ${patsubst ${srcdir}/%, %, ${wildcard ${srcdir}/TestMedCorba*.py} }
+
+
+# Libraries targets
+
+LIB =
+LIB_SRC =
+LIB_CLIENT_IDL =
+
+# Executables targets
+BIN =
+BIN_SRC =
+
+LDFLAGS+=
+
+
+@CONCLUDE@
--- /dev/null
+import os
+BASE = os.environ["SALOME_ROOT_DIR"] + '/share/salome/resources/'
+
+fileName = BASE + 'pointe.med'
+fileName = BASE + 'carre_en_quad4_seg2.med'
+fileName = BASE + 'test_hydro_darcy1a_out.med'
+
+# MED Mesh read from a (local) file
+
+from libMEDMEM_Swig import *
+
+md = MED()
+
+mdDriver = MED_MED_RDONLY_DRIVER(fileName, md)
+
+mdDriver.open()
+mdDriver.readFileStruct()
+mdDriver.close()
+
+mLocal = md.getMesh(md.getMeshName(0))
+mLocal.read()
+
+# MED Mesh recieved from a distant component (via CORBA)
+
+from omniORB import CORBA
+from LifeCycleCORBA import *
+from libSALOME_Swig import *
+
+orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+lcc = LifeCycleCORBA(orb)
+
+C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py")
+C.Initialise(fileName)
+
+mDistant = C.Calcul1()
+
+# Compare local and distant copies
+
+def ecart(x, y):
+ s = 0.
+ if (len(x) != len(y)):
+ return 1.
+
+ for i in xrange(len(x)):
+ s = s + abs(x[i] - y[i]);
+ return s
+
+def compare(x, y):
+ if (len(x) != len(y)):
+ return 0
+ for i in xrange(len(x)):
+ if x[i] != y[i]:
+ return 0
+ return 1
+
+print "Name : ", mDistant.getName()
+if (mLocal.getName() != mDistant.getName()):
+ raise RuntimeError, "MESH::getName()"
+
+print "SpaceDimension : ", mDistant.getSpaceDimension()
+if (mLocal.getSpaceDimension() != mDistant.getSpaceDimension()):
+ raise RuntimeError, "MESH::getSpaceDimension()"
+
+print "MeshDimension : ", mDistant.getMeshDimension()
+if (mLocal.getMeshDimension() != mDistant.getMeshDimension()):
+ raise RuntimeError, "MESH::getMeshDimension()"
+
+print "CoordinatesSystem : ", mDistant.getCoordinatesSystem()
+if (mLocal.getCoordinatesSystem() != mDistant.getCoordinatesSystem()):
+ raise RuntimeError, "MESH::getCoordinatesSystem()"
+
+print "NumberOfNodes : ", mDistant.getNumberOfNodes()
+if (mLocal.getNumberOfNodes() != mDistant.getNumberOfNodes()):
+ raise RuntimeError, "MESH::getNumberOfNodes()"
+
+
+print
+print "All tests passed"
--- /dev/null
+import os
+BASE = os.environ["SALOME_ROOT_DIR"] + '/share/salome/resources/'
+
+fileName = BASE + 'pointe.med'
+fileName = BASE + 'carre_en_quad4_seg2.med'
+
+# MED Mesh read from a (local) file
+
+from libMEDMEM_Swig import *
+
+md = MED()
+
+mdDriver = MED_MED_RDONLY_DRIVER(fileName, md)
+
+mdDriver.open()
+mdDriver.readFileStruct()
+mdDriver.close()
+
+mLocal = md.getMesh(md.getMeshName(0))
+mLocal.read()
+
+# MED Mesh recieved from a distant component (via CORBA)
+
+from omniORB import CORBA
+from LifeCycleCORBA import *
+from libSALOME_Swig import *
+
+orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+lcc = LifeCycleCORBA(orb)
+
+C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py")
+C.Initialise(fileName)
+
+mDistant = C.Calcul1()
+
+# Compare local and distant copies
+
+def ecart(x, y):
+ s = 0.
+ if (len(x) != len(y)):
+ return 1.
+
+ for i in xrange(len(x)):
+ s = s + abs(x[i] - y[i]);
+ return s
+
+def compare(x, y):
+ if (len(x) != len(y)):
+ return 0
+ for i in xrange(len(x)):
+ if x[i] != y[i]:
+ return 0
+ return 1
+
+def transpose(x, n, m):
+ y = range(len(x));
+ for i in xrange(n):
+ for j in xrange(m):
+ y[i + j*n] = x[i*m + j];
+ return y
+
+m = mDistant.getSpaceDimension();
+print "SpaceDimension : ", m
+n = mDistant.getNumberOfNodes();
+print "NumberOfNodes : ", n
+
+x1 = mDistant.getCoordinates(MED_FULL_INTERLACE);
+x2 = mDistant.getCoordinates(MED_NO_INTERLACE);
+x3 = mDistant.getCoordinates(MED_FULL_INTERLACE);
+
+print "Coordinates (MED_FULL_INTERLACE) : ", x1
+print "Coordinates (MED_NO_INTERLACE) : ", x2
+
+if (ecart(x1, x3) > 1e-7):
+ raise RuntimeError, "getCoordinates : INTERLACE"
+
+x4 = transpose(x1, n, m);
+print "Coordinates (MED_NO_INTERLACE) : ", x4
+
+if (ecart(x2, x4) > 1e-7):
+ raise RuntimeError, "getCoordinates : NO_INTERLACE"
+
+print
+print "All tests passed"
--- /dev/null
+import os
+BASE = os.environ["SALOME_ROOT_DIR"] + '/share/salome/resources/'
+
+fileName = BASE + 'pointe.med'
+fileName = BASE + 'carre_en_quad4_seg2.med'
+
+# MED Mesh read from a (local) file
+
+from libMEDMEM_Swig import *
+
+md = MED()
+
+mdDriver = MED_MED_RDONLY_DRIVER(fileName, md)
+
+mdDriver.open()
+mdDriver.readFileStruct()
+mdDriver.close()
+
+mLocal = md.getMesh(md.getMeshName(0))
+mLocal.read()
+
+# MED Mesh recieved from a distant component (via CORBA)
+
+from omniORB import CORBA
+from LifeCycleCORBA import *
+from libSALOME_Swig import *
+
+orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+lcc = LifeCycleCORBA(orb)
+
+C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py")
+C.Initialise(fileName)
+
+mDistant = C.Calcul1()
+
+# Compare local and distant copies
+
+def ecart(x, y):
+ s = 0.
+ if (len(x) != len(y)):
+ return 1.
+
+ for i in xrange(len(x)):
+ s = s + abs(x[i] - y[i]);
+ return s
+
+def compare(x, y):
+ if (len(x) != len(y)):
+ return 0
+ for i in xrange(len(x)):
+ if x[i] != y[i]:
+ return 0
+ return 1
+
+print "Name : ", mDistant.getName()
+if (mLocal.getName() != mDistant.getName()):
+ raise RuntimeError, "MESH::getName()"
+
+print "SpaceDimension : ", mDistant.getSpaceDimension()
+if (mLocal.getSpaceDimension() != mDistant.getSpaceDimension()):
+ raise RuntimeError, "MESH::getSpaceDimension()"
+
+print "MeshDimension : ", mDistant.getMeshDimension()
+if (mLocal.getMeshDimension() != mDistant.getMeshDimension()):
+ raise RuntimeError, "MESH::getMeshDimension()"
+
+print "CoordinatesSystem : ", mDistant.getCoordinatesSystem()
+if (mLocal.getCoordinatesSystem() != mDistant.getCoordinatesSystem()):
+ raise RuntimeError, "MESH::getCoordinatesSystem()"
+
+print "NumberOfNodes : ", mDistant.getNumberOfNodes()
+if (mLocal.getNumberOfNodes() != mDistant.getNumberOfNodes()):
+ raise RuntimeError, "MESH::getNumberOfNodes()"
+
+x1 = mLocal.getCoordinates(MED_FULL_INTERLACE);
+x2 = mDistant.getCoordinates(MED_FULL_INTERLACE);
+
+print "Coordinates (local) : ", x1
+print "Coordinates (distant) : ", x2
+
+d = ecart(x1, x2);
+print " (differences between local and distant) : ", d
+if (d > 1.0e-7):
+ raise RuntimeError, "MESH::getCoordinates()"
+
+s1 = mLocal.getCoordinatesNames();
+s2 = mDistant.getCoordinatesNames();
+print "CoordinatesNames (local) : ", s1
+print "CoordinatesNames (distant) : ", s2
+
+if (not compare(s1, s2)):
+ raise RuntimeError, "MESH::CoordinatesNames()"
+
+s1 = mLocal.getCoordinatesUnits();
+s2 = mDistant.getCoordinatesUnits();
+print "CoordinatesUnits (local) : ", s1
+print "CoordinatesUnits (distant) : ", s2
+
+if (not compare(s1, s2)):
+ raise RuntimeError, "MESH::CoordinatesUnits()"
+
+
+
+print
+print "All tests passed"
--- /dev/null
+import os
+BASE = os.environ["SALOME_ROOT_DIR"] + '/share/salome/resources/'
+
+fileName = BASE + 'pointe.med'
+fileName = BASE + 'carre_en_quad4_seg2.med'
+
+# MED Mesh read from a (local) file
+
+from libMEDMEM_Swig import *
+
+md = MED()
+
+mdDriver = MED_MED_RDONLY_DRIVER(fileName, md)
+
+mdDriver.open()
+mdDriver.readFileStruct()
+mdDriver.close()
+
+mLocal = md.getMesh(md.getMeshName(0))
+mLocal.read()
+
+# MED Mesh recieved from a distant component (via CORBA)
+
+from omniORB import CORBA
+from LifeCycleCORBA import *
+from libSALOME_Swig import *
+
+orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+lcc = LifeCycleCORBA(orb)
+
+C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py")
+C.Initialise(fileName)
+
+mDistant = C.Calcul1()
+
+
+print "Name : ", mDistant.getName()
+
+
+for i in [MED_CELL,
+ MED_FACE,
+ MED_EDGE,
+ MED_NODE,
+ MED_ALL_ENTITIES ]:
+
+ n1 = mLocal.getNumberOfTypes(i);
+ n2 = mDistant.getNumberOfTypes(i);
+
+ if (n1 != n2):
+ raise RuntimeError, "MESH::getNumberOfTypes()"
+
+ if ((n1 > 0) & (i != MED_NODE)):
+ T1 = mLocal.getTypes(i);
+ T2 = mDistant.getTypes(i);
+ print "types (local) : ", i, " : ", T1;
+ print "types (distant) : ", i, " : ", T2;
+
+ if (n2 != len(T2)):
+ raise RuntimeError, \
+ "len(MESH::getTypes()) <> MESH::getNumberOfTypes()"
+
+ for j in range(n2):
+ if (T1[j] != eval(T2[j].__str__())):
+ raise RuntimeError, "MESH::getTypes()"
+
+ e1 = mLocal.getNumberOfElements(i, T1[j]);
+ e2 = mDistant.getNumberOfElements(i, T2[j]);
+
+ print "elements (local) : ", T1[j], " : ", e1;
+ print "elements (distant) : ", T2[j], " : ", e2;
+
+ if (e1 != e2):
+ raise RuntimeError, "MESH::getNumberOfElements"
+
+print
+print "All tests passed"
--- /dev/null
+import os
+BASE = os.environ["SALOME_ROOT_DIR"] + '/share/salome/resources/'
+
+fileName = BASE + 'pointe.med'
+fileName = BASE + 'carre_en_quad4_seg2.med'
+
+
+def compare(x, y):
+ if (len(x) != len(y)):
+ return 0
+ for i in xrange(len(x)):
+ if x[i] != y[i]:
+ return 0
+ return 1
+
+# MED Mesh read from a (local) file
+
+from libMEDMEM_Swig import *
+
+md = MED()
+
+mdDriver = MED_MED_RDONLY_DRIVER(fileName, md)
+
+mdDriver.open()
+mdDriver.readFileStruct()
+mdDriver.close()
+
+mLocal = md.getMesh(md.getMeshName(0))
+mLocal.read()
+
+# MED Mesh recieved from a distant component (via CORBA)
+
+from omniORB import CORBA
+from LifeCycleCORBA import *
+from libSALOME_Swig import *
+
+orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+lcc = LifeCycleCORBA(orb)
+
+C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py")
+C.Initialise(fileName)
+
+mDistant = C.Calcul1()
+
+
+print "Name : ", mDistant.getName()
+
+
+for i in [MED_CELL,
+ MED_FACE,
+ MED_EDGE,
+ MED_NODE,
+ MED_ALL_ENTITIES ]:
+
+ n1 = mLocal.getNumberOfTypes(i);
+ n2 = mDistant.getNumberOfTypes(i);
+
+ if (n1 != n2):
+ raise RuntimeError, "MESH::getNumberOfTypes()"
+
+ if ((n1 > 0) & (i != MED_NODE)):
+ T1 = mLocal.getTypes(i);
+ T2 = mDistant.getTypes(i);
+
+ if (n2 != len(T2)):
+ raise RuntimeError, \
+ "len(MESH::getTypes()) <> MESH::getNumberOfTypes()"
+
+ for j in range(n2):
+ if (T1[j] != T2[j]):
+ raise RuntimeError, "MESH::getTypes()"
+
+ c1 = mLocal.getConnectivity(MED_FULL_INTERLACE, MED_NODAL, \
+ i, T1[j]);
+ c2 = mDistant.getConnectivity(MED_FULL_INTERLACE, MED_NODAL, \
+ i, T2[j]);
+
+ print "connectivity (local) : ", T1[j], " : ", c1;
+ print "connectivity (distant) : ", T2[j], " : ", c2;
+
+ if (compare(c1, c2) == 0):
+ raise RuntimeError, "MESH::getConnectivity()"
+
+print
+print "All tests passed"
--- /dev/null
+#ifndef _DEBUG_
+#define _DEBUG_
+#endif
+
+#include "Compo2.hxx"
+#include <utilities.h>
+#include <typeinfo>
+#include <iostream>
+
+Compo2::Compo2() : _F(NULL)
+{
+}
+
+Compo2::~Compo2()
+{
+ if (_F) delete _F;
+}
+
+std::string Compo2::Calcul(const MESH &M)
+{
+ BEGIN_OF("std::string Compo2::Calcul(MESH &M)");
+
+ MESSAGE("type virtuel : MESH");
+ MESSAGE("type reel : " << typeid(M).name());
+
+ std::string name = M.getName();
+
+ name += " recu";
+
+ try {
+ std::cerr << M << std::endl;
+ }
+ catch (...) {
+ std::cerr << "erreur Compo2::Calcul" << std::endl;
+ }
+
+ END_OF("std::string Compo2::Calcul(MESH &M)");
+ return name;
+}
+
+const FAMILY * Compo2::Calcul2(const MESH &M)
+{
+ BEGIN_OF("const FAMILY * Compo2::Calcul2(const MESH &M)");
+
+ const FAMILY * F = M.getFamily(MED_CELL, 1);
+ std::cerr << "ok ici 2" << std::endl;
+ try {
+ std::cout << F << std::endl;
+ }
+ catch (...) {
+ std::cerr << "erreur Compo2::Calcul2" << std::endl;
+ }
+
+ END_OF("const FAMILY * Compo2::Calcul2(const MESH &M)");
+ return F;
+}
+
+void Compo2::Calcul3(const FIELD<double> &F)
+{
+ BEGIN_OF("void Compo2::Calcul3(const FIELD<double> *)");
+
+ const double *v = F.getValue(MED_FULL_INTERLACE);
+ long i, n = F.getSupport()->getNumberOfElements(MED_CELL);
+ int j, m = F.getNumberOfComponents();
+
+ for (i=0; i<n; i++) {
+ std::cout << i << " : ";
+ for (j=0; j<m; j++)
+ std::cout << v[j + i*m];
+ std::cout << std::endl;
+ }
+
+ END_OF("void Compo2::Calcul2(const FIELD<double> *)");
+}
--- /dev/null
+#ifndef __COMPO2
+#define __COMPO2
+
+#ifndef SWIG
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Field.hxx"
+#endif
+
+class Compo2
+{
+
+ FIELD<double> * _F;
+
+public:
+ Compo2();
+ ~Compo2();
+
+ std::string Calcul(const MESH &M);
+ const FAMILY * Calcul2(const MESH &M);
+ void Calcul3(const FIELD<double> &S);
+};
+
+#endif
--- /dev/null
+# MED MedClient : tool to transfer MED CORBA from server producer of MED object to a client using those MED object
+#
+# 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@
+VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:${KERNEL_ROOT_DIR}/idl/salome
+
+@COMMENCE@
+
+EXPORT_PYSCRIPTS = \
+ ${patsubst ${srcdir}/%, %, ${wildcard ${srcdir}/TestMedCorba*.py} } \
+ libCompo2.py
+
+# Libraries targets
+
+LIB = libCompo2cmodule.la
+LIB_SRC = Compo2.cxx
+LIB_CLIENT_IDL= SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl MED.idl
+
+CPPFLAGS += ${MED2_INCLUDES} ${HDF5_INCLUDES} ${PYTHON_INCLUDES} -I${KERNEL_ROOT_DIR}/include/salome
+LIBS = -L${KERNEL_ROOT_DIR}/lib/salome -lMEDClientcmodule -lMEDMEM_Swigcmodule -lMEDImpl -lmedmem ${MED2_LIBS} ${HDF5_LIBS}
+
+# Executables targets
+
+SWIG_DEF = libCompo2.i
+
+MED.hh MEDSK.cc: MED.idl
+ omniidl -bcxx -Wbtp -I$(top_builddir)/idl -I${KERNEL_ROOT_DIR}/idl/salome $^
+
+@CONCLUDE@
+
--- /dev/null
+import os
+
+## ne fonctionne pas ?
+## import salome
+
+BASE = os.environ["SALOME_ROOT_DIR"] + '/share/salome/resources/'
+
+fileName = BASE + 'pointe.med'
+fileName = BASE + 'carre_en_quad4_seg2.med'
+
+
+def compare(x, y):
+ if (len(x) != len(y)):
+ return 0
+ for i in xrange(len(x)):
+ if x[i] != y[i]:
+ return 0
+ return 1
+
+# MED Mesh read from a (local) file
+
+from libMEDMEM_Swig import *
+
+md = MED()
+
+mdDriver = MED_MED_RDONLY_DRIVER(fileName, md)
+
+mdDriver.open()
+mdDriver.readFileStruct()
+mdDriver.close()
+
+mLocal = md.getMesh(md.getMeshName(0))
+mLocal.read()
+
+# MED Mesh received from a distant component (via CORBA)
+
+from omniORB import CORBA
+from LifeCycleCORBA import *
+from libSALOME_Swig import *
+from libMEDClient import *
+
+orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+lcc = LifeCycleCORBA(orb)
+
+C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py")
+C.Initialise(fileName)
+
+mDistant = C.Calcul1()
+mDistantCopy = MESHClient(mDistant)
+
+from libCompo2 import *
+C2 = Compo2()
+
+print "Local ", C2.Calcul(mLocal)
+print "DistantCopy ", C2.Calcul(mDistantCopy)
+
+testDistant = 0;
+try:
+ print "Distant ", C2.Calcul(mDistant)
+except:
+ print "an exception has been received, it's the normal behaviour"
+ testDistant = 1
+
+if (testDistant == 0):
+ raise RuntimeError, "no exception has been received, test failed"
+
+
+print
+print "All tests passed"
--- /dev/null
+import os
+
+BASE = os.environ["SALOME_ROOT_DIR"] + '/share/salome/resources/'
+
+fileName = BASE + 'pointe.med'
+fileName = BASE + 'test_hydro_darcy1a_out.med'
+fileName = BASE + 'carre_en_quad4_seg2.med'
+
+def compare(x, y):
+ if (len(x) != len(y)):
+ return 0
+ for i in xrange(len(x)):
+ if x[i] != y[i]:
+ return 0
+ return 1
+
+# MED Mesh read from a (local) file
+
+from libMEDMEM_Swig import *
+
+md = MED()
+
+mdDriver = MED_MED_RDONLY_DRIVER(fileName, md)
+
+mdDriver.open()
+mdDriver.readFileStruct()
+mdDriver.close()
+
+mLocal = md.getMesh(md.getMeshName(0))
+mLocal.read()
+
+# MED Mesh received from a distant component (via CORBA)
+
+from omniORB import CORBA
+from LifeCycleCORBA import *
+from libSALOME_Swig import *
+from libMEDClient import *
+
+orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+lcc = LifeCycleCORBA(orb)
+
+C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py")
+C.Initialise(fileName)
+
+mDistant = C.Calcul1()
+mDistantCopy = MESHClient(mDistant)
+
+from libCompo2 import *
+C2 = Compo2()
+
+for i in xrange(10):
+ print "-"
+
+print "Local "
+print C2.Calcul(mLocal)
+
+for i in xrange(10):
+ print "-"
+
+print "DistantCopy "
+s = C2.Calcul(mDistantCopy)
+print
+
+##print "ok ici"
+##for i in xrange(10):
+## print "-"
+
+##try:
+## sDistant = C.Calcul2()
+##except:
+## print "erreur"
+
+##sDistantCopy = SUPPORTClient(sDistant)
+##print sDistant
+print
+print "All tests passed"
--- /dev/null
+import os
+
+# import salome
+
+BASE = os.environ["SALOME_ROOT_DIR"] + '/share/salome/resources/'
+
+fileName = BASE + 'pointe.med'
+fileName = BASE + 'test_hydro_darcy1a_out.med'
+fileName = BASE + 'carre_en_quad4_seg2.med'
+
+
+from omniORB import CORBA
+from LifeCycleCORBA import *
+from libSALOME_Swig import *
+from libMEDClient import *
+
+orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+lcc = LifeCycleCORBA(orb)
+
+C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py")
+
+print "ok"
+C.Initialise(fileName)
+
+mDistant = C.Calcul1()
+print mDistant
+mDistantCopy = MESHClient(mDistant)
+print mDistantCopy
+
+print "###################################"
+for i in xrange(10):
+ print mDistantCopy.getName()
+
+for i in xrange(1):
+ print "-"
+
+
+print
+print "All tests passed"
--- /dev/null
+%module libCompo2
+
+%{
+#include "Compo2.hxx"
+%}
+
+%include "std_string.i"
+%include "libMEDClient.i"
+
+%include "Compo2.hxx"